diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-06-22 17:30:33 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-06-22 17:30:33 +0000 |
commit | b7f4cc09ead099c1306d06db53e258d648d0f652 (patch) | |
tree | 84d1494ac758b2a57b8d0585bee82a3b8966be35 /lib/Sema | |
parent | 1a5364e0fa0482d8d477d6f136d52e503bbe13f4 (diff) |
Remove ImplicitMustBeDefined, use universal 'Used' flag
instead. Do the implicit default ctor checking in MarkDeclarationReferenced.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 11 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 7 |
3 files changed, 12 insertions, 11 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 06fd1a1736..eba1d58d60 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2733,12 +2733,9 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl) { 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); - } } } diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 6d740eb5b7..6e17450093 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1843,7 +1843,7 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S, void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor) { if (!Constructor->isDefaultConstructor() || - !Constructor->isImplicit() || Constructor->isImplicitMustBeDefined()) + !Constructor->isImplicit() || Constructor->isUsed()) return; CXXRecordDecl *ClassDecl @@ -1862,7 +1862,7 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, if (CXXConstructorDecl *BaseCtor = BaseClassDecl->getDefaultConstructor(Context)) { if (BaseCtor->isImplicit()) - BaseCtor->setImplicitMustBeDefined(); + BaseCtor->setUsed(); } else { Diag(CurrentLocation, diag::err_defining_default_ctor) @@ -1887,7 +1887,7 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, if (CXXConstructorDecl *FieldCtor = FieldClassDecl->getDefaultConstructor(Context)) { if (FieldCtor->isImplicit()) - FieldCtor->setImplicitMustBeDefined(); + FieldCtor->setUsed(); } else { Diag(CurrentLocation, diag::err_defining_default_ctor) @@ -1912,7 +1912,7 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, } } if (!err) - Constructor->setImplicitMustBeDefined(); + Constructor->setUsed(); } void Sema::InitializeVarWithConstructor(VarDecl *VD, @@ -1990,9 +1990,6 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl, 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; } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 692502bbbe..e989b1f282 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -5461,6 +5461,13 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) { 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 |