diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-20 22:01:25 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-20 22:01:25 +0000 |
commit | 39c778b44348c530ef7487915f60e823d2fbc383 (patch) | |
tree | b393891a51975dc24e935416913b4ea3dbe59fd0 | |
parent | 1b6d10555ff70efcc44b8bf25d4755d88a15d48c (diff) | |
download | bcm5719-llvm-39c778b44348c530ef7487915f60e823d2fbc383.tar.gz bcm5719-llvm-39c778b44348c530ef7487915f60e823d2fbc383.zip |
Switch default-initialization of variables of class type (or array thereof) over to InitializationSequence. I could swear that this fixes a PR somewhere, but I couldn't figure out which one
llvm-svn: 91796
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 31 | ||||
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 3 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp | 2 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp | 4 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/constructor-recovery.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaCXX/default2.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/deleted-function.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/direct-initializer.cpp | 6 | ||||
-rw-r--r-- | clang/test/SemaTemplate/explicit-instantiation.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaTemplate/instantiate-static-var.cpp | 2 |
11 files changed, 30 insertions, 39 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c873f395797..a80d62a4738 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3745,28 +3745,19 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl, InitType->isRecordType() && !InitType->isDependentType()) { if (!RequireCompleteType(Var->getLocation(), InitType, diag::err_invalid_incomplete_type_use)) { - ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(*this); - - CXXConstructorDecl *Constructor - = PerformInitializationByConstructor(InitType, - MultiExprArg(*this, 0, 0), - Var->getLocation(), - SourceRange(Var->getLocation(), - Var->getLocation()), - Var->getDeclName(), - InitializationKind::CreateDefault(Var->getLocation()), - ConstructorArgs); - - // FIXME: Location info for the variable initialization? - if (!Constructor) + InitializedEntity Entity + = InitializedEntity::InitializeVariable(Var); + InitializationKind Kind + = InitializationKind::CreateDefault(Var->getLocation()); + + InitializationSequence InitSeq(*this, Entity, Kind, 0, 0); + OwningExprResult Init = InitSeq.Perform(*this, Entity, Kind, + MultiExprArg(*this, 0, 0)); + if (Init.isInvalid()) Var->setInvalidDecl(); else { - // FIXME: Cope with initialization of arrays - if (!Constructor->isTrivial() && - InitializeVarWithConstructor(Var, Constructor, - move_arg(ConstructorArgs))) - Var->setInvalidDecl(); - + Var->setInit(Context, + MaybeCreateCXXExprWithTemporaries(Init.takeAs<Expr>())); FinalizeVarWithDestructor(Var, InitType); } } else { diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 44f6cf3d74c..18164d685f6 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -3391,7 +3391,8 @@ InitializationSequence::Perform(Sema &S, return S.ExprError(); // Build the an expression that constructs a temporary. - CurInit = S.BuildCXXConstructExpr(Loc, Step->Type, Constructor, + CurInit = S.BuildCXXConstructExpr(Loc, Entity.getType().getType(), + Constructor, move_arg(ConstructorArgs), ConstructorInitRequiresZeroInit); if (CurInit.isInvalid()) diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp index 7e87e576ca9..6e7f80842ec 100644 --- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s struct NonDefaultConstructible { - NonDefaultConstructible(const NonDefaultConstructible&); + NonDefaultConstructible(const NonDefaultConstructible&); // expected-note{{candidate function}} }; template<typename T, typename U> diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp index 9e3401a1aef..3eaf89689a2 100644 --- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -struct IntHolder { // expected-note{{here}} - IntHolder(int); +struct IntHolder { // expected-note{{here}} // expected-note 2{{candidate function}} + IntHolder(int); // expected-note 2{{candidate function}} }; template<typename T, typename U> diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp index 718812be30a..7c7ca6cf329 100644 --- a/clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p1.cpp @@ -48,8 +48,8 @@ template void X1<int>::f<>(int&, int*); // expected-note{{instantiation}} // Explicitly instantiate members of a class template struct Incomplete; // expected-note{{forward declaration}} -struct NonDefaultConstructible { - NonDefaultConstructible(int); +struct NonDefaultConstructible { // expected-note{{candidate function}} + NonDefaultConstructible(int); // expected-note{{candidate function}} }; template<typename T, typename U> diff --git a/clang/test/SemaCXX/constructor-recovery.cpp b/clang/test/SemaCXX/constructor-recovery.cpp index 8e006203980..c1bb4362835 100644 --- a/clang/test/SemaCXX/constructor-recovery.cpp +++ b/clang/test/SemaCXX/constructor-recovery.cpp @@ -1,10 +1,9 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -struct C { // expected-note {{candidate function}} - virtual C() = 0; // expected-error{{constructor cannot be declared 'virtual'}} \ - expected-note {{candidate function}} +struct C { + virtual C() = 0; // expected-error{{constructor cannot be declared 'virtual'}} }; void f() { - C c; // expected-error {{call to constructor of 'c' is ambiguous}} + C c; } diff --git a/clang/test/SemaCXX/default2.cpp b/clang/test/SemaCXX/default2.cpp index 58f35dcec31..eda4be29192 100644 --- a/clang/test/SemaCXX/default2.cpp +++ b/clang/test/SemaCXX/default2.cpp @@ -82,7 +82,7 @@ int Y::mem4(int i = a) // expected-error{{invalid use of nonstatic data member ' // constructors. class Z { public: - Z(Z&, int i = 17); // expected-note 2 {{candidate function}} + Z(Z&, int i = 17); // expected-note 3 {{candidate function}} void f(Z& z) { Z z2; // expected-error{{no matching constructor for initialization}} diff --git a/clang/test/SemaCXX/deleted-function.cpp b/clang/test/SemaCXX/deleted-function.cpp index 572ef343309..d9df1bf5b05 100644 --- a/clang/test/SemaCXX/deleted-function.cpp +++ b/clang/test/SemaCXX/deleted-function.cpp @@ -16,7 +16,7 @@ void ov(int) {} // expected-note {{candidate function}} void ov(double) = delete; // expected-note {{candidate function has been explicitly deleted}} struct WithDel { - WithDel() = delete; // expected-note {{candidate function has been explicitly deleted}} + WithDel() = delete; // expected-note {{function has been explicitly marked deleted here}} void fn() = delete; // expected-note {{function has been explicitly marked deleted here}} operator int() = delete; // expected-note {{function has been explicitly marked deleted here}} void operator +(int) = delete; @@ -29,7 +29,7 @@ void test() { ov(1); ov(1.0); // expected-error {{call to deleted function 'ov'}} - WithDel dd; // expected-error {{call to deleted constructor of 'dd'}} + WithDel dd; // expected-error {{call to deleted constructor of 'struct WithDel'}} WithDel *d = 0; d->fn(); // expected-error {{attempt to use a deleted function}} int i = *d; // expected-error {{invokes a deleted function}} diff --git a/clang/test/SemaCXX/direct-initializer.cpp b/clang/test/SemaCXX/direct-initializer.cpp index 0930ff798fb..1a87a3edf33 100644 --- a/clang/test/SemaCXX/direct-initializer.cpp +++ b/clang/test/SemaCXX/direct-initializer.cpp @@ -20,9 +20,9 @@ public: X(float, Y); // expected-note{{candidate function}} }; -class Z { +class Z { // expected-note{{candidate function}} public: - Z(int); + Z(int); // expected-note{{candidate function}} }; void g() { @@ -32,7 +32,7 @@ void g() { Y y(1.0); X x4(3.14, y); - Z z; // expected-error{{no matching constructor for initialization of 'z'}} + Z z; // expected-error{{no matching constructor for initialization of 'class Z'}} } struct Base { diff --git a/clang/test/SemaTemplate/explicit-instantiation.cpp b/clang/test/SemaTemplate/explicit-instantiation.cpp index 9c75cb7d610..fbb5edbefd6 100644 --- a/clang/test/SemaTemplate/explicit-instantiation.cpp +++ b/clang/test/SemaTemplate/explicit-instantiation.cpp @@ -25,8 +25,8 @@ T X0<T>::value; // expected-error{{no matching constructor}} template int X0<int>::value; -struct NotDefaultConstructible { - NotDefaultConstructible(int); +struct NotDefaultConstructible { // expected-note{{candidate function}} + NotDefaultConstructible(int); // expected-note{{candidate function}} }; template NotDefaultConstructible X0<NotDefaultConstructible>::value; // expected-note{{instantiation}} diff --git a/clang/test/SemaTemplate/instantiate-static-var.cpp b/clang/test/SemaTemplate/instantiate-static-var.cpp index bd298fc63a8..8a2f34d475a 100644 --- a/clang/test/SemaTemplate/instantiate-static-var.cpp +++ b/clang/test/SemaTemplate/instantiate-static-var.cpp @@ -30,7 +30,7 @@ T Z<T>::value; // expected-error{{no matching constructor}} struct DefCon {}; struct NoDefCon { - NoDefCon(const NoDefCon&); + NoDefCon(const NoDefCon&); // expected-note{{candidate function}} }; void test() { |