diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-07 03:22:51 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-11-07 03:22:51 +0000 |
commit | a08acd8588e461df6ad74af3c5bd3ad1cc4149af (patch) | |
tree | e4e52eae396bb79b892f1ecf14df8d7b650a9f6e /clang/lib | |
parent | ff39be0afca5783cde946eaaf1442d0db34408fc (diff) | |
download | bcm5719-llvm-a08acd8588e461df6ad74af3c5bd3ad1cc4149af.tar.gz bcm5719-llvm-a08acd8588e461df6ad74af3c5bd3ad1cc4149af.zip |
Allow constexpr variables' initializers to be folded in C++11 mode. This
partially undoes the revert in r143491, but does not introduce any new instances
of the underlying issue (which is not yet fixed) in code which does not use
the 'constexpr' keyword.
llvm-svn: 143905
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 9c9e473f7b5..6456376d48f 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -558,12 +558,14 @@ bool HandleLValueToRValueConversion(EvalInfo &Info, QualType Type, // them are not permitted. const VarDecl *VD = dyn_cast<VarDecl>(D); QualType VT = VD->getType(); - if (!VD) + if (!VD || VD->isInvalidDecl()) return false; if (!isa<ParmVarDecl>(VD)) { if (!IsConstNonVolatile(VT)) return false; - if (!VT->isIntegralOrEnumerationType() && !VT->isRealFloatingType()) + // FIXME: Allow folding of values of any literal type in all languages. + if (!VT->isIntegralOrEnumerationType() && !VT->isRealFloatingType() && + !VD->isConstexpr()) return false; } if (!EvaluateVarDeclInit(Info, VD, Frame, RVal)) |