/// @c !Implicit && ImplicitlyDefined.
bool ImplicitlyDefined : 1;
- /// ImplicitMustBeDefined - Implicit constructor was used to create an
- /// object of its class type. It must be defined.
- bool ImplicitMustBeDefined : 1;
-
/// FIXME: Add support for base and member initializers.
CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation L,
DeclarationName N, QualType T,
bool isExplicit, bool isInline, bool isImplicitlyDeclared)
: CXXMethodDecl(CXXConstructor, RD, L, N, T, false, isInline),
- Explicit(isExplicit), ImplicitlyDefined(false),
- ImplicitMustBeDefined(false) {
+ Explicit(isExplicit), ImplicitlyDefined(false) {
setImplicit(isImplicitlyDeclared);
}
"Can only set the implicit-definition flag once the constructor has been defined");
ImplicitlyDefined = ID;
}
-
- /// isImplicitMustBeDefined - Whether a definition must be synthesized for
- /// the implicit constructor.
- bool isImplicitMustBeDefined() const {
- return isImplicit() && ImplicitMustBeDefined;
- }
-
- /// setImplicitMustBeDefined - constructor must be implicitly defined.
- void setImplicitMustBeDefined() {
- ImplicitMustBeDefined = true;
- }
/// isDefaultConstructor - Whether this constructor is a default
/// constructor (C++ [class.ctor]p5), which can be used to
IK_Default);
if (!Constructor)
Var->setInvalidDecl();
- else {
+ else
if (!RD->hasTrivialConstructor())
InitializeVarWithConstructor(Var, Constructor, InitType, 0, 0);
- // Check for valid construction.
- DefineImplicitDefaultConstructor(Var->getLocation(), Constructor);
- }
}
}
void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
CXXConstructorDecl *Constructor) {
if (!Constructor->isDefaultConstructor() ||
- !Constructor->isImplicit() || Constructor->isImplicitMustBeDefined())
+ !Constructor->isImplicit() || Constructor->isUsed())
return;
CXXRecordDecl *ClassDecl
if (CXXConstructorDecl *BaseCtor =
BaseClassDecl->getDefaultConstructor(Context)) {
if (BaseCtor->isImplicit())
- BaseCtor->setImplicitMustBeDefined();
+ BaseCtor->setUsed();
}
else {
Diag(CurrentLocation, diag::err_defining_default_ctor)
if (CXXConstructorDecl *FieldCtor =
FieldClassDecl->getDefaultConstructor(Context)) {
if (FieldCtor->isImplicit())
- FieldCtor->setImplicitMustBeDefined();
+ FieldCtor->setUsed();
}
else {
Diag(CurrentLocation, diag::err_defining_default_ctor)
}
}
if (!err)
- Constructor->setImplicitMustBeDefined();
+ Constructor->setUsed();
}
void Sema::InitializeVarWithConstructor(VarDecl *VD,
VDecl->setCXXDirectInitializer(true);
InitializeVarWithConstructor(VDecl, Constructor, DeclInitType,
(Expr**)Exprs.release(), NumExprs);
- // An implicitly-declared default constructor for a class is implicitly
- // defined when it is used to creat an object of its class type.
- DefineImplicitDefaultConstructor(VDecl->getLocation(), Constructor);
}
return;
}
return;
// Note that this declaration has been used.
+ if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(D)) {
+ DefineImplicitDefaultConstructor(Loc, Constructor);
+ // FIXME: set the Used flag if it is determined that ctor is valid.
+ Constructor->setUsed(true);
+ return;
+ }
+
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
// FIXME: implicit template instantiation
// FIXME: keep track of references to static functions