[cfe-commits] r91796 - in /cfe/trunk: lib/Sema/SemaDecl.cpp lib/Sema/SemaInit.cpp test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp test/CXX/temp/temp.spec/temp.explicit/p1.cpp test/SemaCXX/constructor-recovery.cpp test/SemaCXX/default2.cpp test/SemaCXX/deleted-function.cpp test/SemaCXX/direct-initializer.cpp test/SemaTemplate/explicit-instantiation.cpp test/SemaTemplate/instantiate-static-var.cpp
Douglas Gregor
dgregor at apple.com
Sun Dec 20 14:01:25 PST 2009
Author: dgregor
Date: Sun Dec 20 16:01:25 2009
New Revision: 91796
URL: http://llvm.org/viewvc/llvm-project?rev=91796&view=rev
Log:
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
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp
cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp
cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p1.cpp
cfe/trunk/test/SemaCXX/constructor-recovery.cpp
cfe/trunk/test/SemaCXX/default2.cpp
cfe/trunk/test/SemaCXX/deleted-function.cpp
cfe/trunk/test/SemaCXX/direct-initializer.cpp
cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp
cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Dec 20 16:01:25 2009
@@ -3745,28 +3745,19 @@
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 {
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sun Dec 20 16:01:25 2009
@@ -3391,7 +3391,8 @@
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())
Modified: cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp Sun Dec 20 16:01:25 2009
@@ -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>
Modified: cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp Sun Dec 20 16:01:25 2009
@@ -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>
Modified: cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p1.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p1.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p1.cpp Sun Dec 20 16:01:25 2009
@@ -48,8 +48,8 @@
// 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>
Modified: cfe/trunk/test/SemaCXX/constructor-recovery.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constructor-recovery.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constructor-recovery.cpp (original)
+++ cfe/trunk/test/SemaCXX/constructor-recovery.cpp Sun Dec 20 16:01:25 2009
@@ -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;
}
Modified: cfe/trunk/test/SemaCXX/default2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default2.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/default2.cpp (original)
+++ cfe/trunk/test/SemaCXX/default2.cpp Sun Dec 20 16:01:25 2009
@@ -82,7 +82,7 @@
// 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}}
Modified: cfe/trunk/test/SemaCXX/deleted-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deleted-function.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/deleted-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/deleted-function.cpp Sun Dec 20 16:01:25 2009
@@ -16,7 +16,7 @@
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 @@
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}}
Modified: cfe/trunk/test/SemaCXX/direct-initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/direct-initializer.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/direct-initializer.cpp (original)
+++ cfe/trunk/test/SemaCXX/direct-initializer.cpp Sun Dec 20 16:01:25 2009
@@ -20,9 +20,9 @@
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 @@
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 {
Modified: cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp (original)
+++ cfe/trunk/test/SemaTemplate/explicit-instantiation.cpp Sun Dec 20 16:01:25 2009
@@ -25,8 +25,8 @@
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}}
Modified: cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp?rev=91796&r1=91795&r2=91796&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp Sun Dec 20 16:01:25 2009
@@ -30,7 +30,7 @@
struct DefCon {};
struct NoDefCon {
- NoDefCon(const NoDefCon&);
+ NoDefCon(const NoDefCon&); // expected-note{{candidate function}}
};
void test() {
More information about the cfe-commits
mailing list