зеркало из https://github.com/microsoft/clang-1.git
Allow null initialization of scalara data members
in constructors's initializer list. pr4854 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80802 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
c857ea4d22
Коммит
636a0ffbd2
|
@ -786,11 +786,17 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args,
|
|||
C = PerformInitializationByConstructor(
|
||||
FieldType, (Expr **)Args, NumArgs, IdLoc,
|
||||
SourceRange(IdLoc, RParenLoc), Member->getDeclName(), IK_Direct);
|
||||
} else if (NumArgs != 1) {
|
||||
} else if (NumArgs != 1 && NumArgs != 0) {
|
||||
return Diag(IdLoc, diag::err_mem_initializer_mismatch)
|
||||
<< Member->getDeclName() << SourceRange(IdLoc, RParenLoc);
|
||||
} else if (!HasDependentArg) {
|
||||
Expr *NewExp = (Expr*)Args[0];
|
||||
Expr *NewExp;
|
||||
if (NumArgs == 0) {
|
||||
NewExp = new (Context) CXXZeroInitValueExpr(FieldType, IdLoc, RParenLoc);
|
||||
NumArgs = 1;
|
||||
}
|
||||
else
|
||||
NewExp = (Expr*)Args[0];
|
||||
if (PerformCopyInitialization(NewExp, FieldType, "passing"))
|
||||
return true;
|
||||
Args[0] = NewExp;
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// RUN: clang-cc -S %s -o %t-64.s &&
|
||||
// RUN: clang-cc -S %s -o %t-32.s &&
|
||||
// RUN: true
|
||||
|
||||
extern "C" int printf(...);
|
||||
|
||||
struct S {
|
||||
S() { printf("S::S\n"); }
|
||||
};
|
||||
|
||||
struct A {
|
||||
double x;
|
||||
A() : x(), y(), s() { printf("x = %f y = %x \n", x, y); }
|
||||
int *y;
|
||||
S s;
|
||||
};
|
||||
|
||||
A a;
|
||||
|
||||
int main() {
|
||||
}
|
Загрузка…
Ссылка в новой задаче