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 {
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())
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct NonDefaultConstructible {
- NonDefaultConstructible(const NonDefaultConstructible&);
+ NonDefaultConstructible(const NonDefaultConstructible&); // expected-note{{candidate function}}
};
template<typename T, typename U>
// 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>
// 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>
// 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;
}
// 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}}
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;
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}}
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() {
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 {
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}}
struct DefCon {};
struct NoDefCon {
- NoDefCon(const NoDefCon&);
+ NoDefCon(const NoDefCon&); // expected-note{{candidate function}}
};
void test() {