diff options
author | John McCall <rjmccall@apple.com> | 2010-08-02 21:13:48 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-08-02 21:13:48 +0000 |
commit | 4204f07fc8bffe6d320b2de95fea274ccf37a17b (patch) | |
tree | 90f5c06c89e2673b40fd7352a497c661c4901d5c /lib/Sema/SemaDecl.cpp | |
parent | 73dfa3d30ab19d358b782c201201fa2a2dcf51a6 (diff) |
Further adjustments to -Wglobal-constructors; works for references and direct
initializations now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110063 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 8a656bcf16..5252188635 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3855,7 +3855,7 @@ bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) { // "may accept other forms of constant expressions" exception. // (We never end up here for C++, so the constant expression // rules there don't matter.) - if (Init->isConstantInitializer(Context)) + if (Init->isConstantInitializer(Context, false)) return false; Diag(Init->getExprLoc(), diag::err_init_element_not_constant) << Init->getSourceRange(); @@ -4067,8 +4067,11 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) { if (getLangOptions().CPlusPlus) { if (!VDecl->isInvalidDecl() && !VDecl->getDeclContext()->isDependentContext() && - VDecl->hasGlobalStorage() && !Init->isConstantInitializer(Context)) - Diag(VDecl->getLocation(), diag::warn_global_constructor); + VDecl->hasGlobalStorage() && + !Init->isConstantInitializer(Context, + VDecl->getType()->isReferenceType())) + Diag(VDecl->getLocation(), diag::warn_global_constructor) + << Init->getSourceRange(); // Make sure we mark the destructor as used if necessary. QualType InitType = VDecl->getType(); @@ -4281,7 +4284,7 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl, if (getLangOptions().CPlusPlus && !Var->isInvalidDecl() && Var->hasGlobalStorage() && !Var->getDeclContext()->isDependentContext() && - !Var->getInit()->isConstantInitializer(Context)) + !Var->getInit()->isConstantInitializer(Context, false)) Diag(Var->getLocation(), diag::warn_global_constructor); } } |