summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2018-11-24 10:45:55 +0000
committerBill Wendling <isanbard@gmail.com>2018-11-24 10:45:55 +0000
commit1af8dd6a1edb1d3a2e302b1e92d53d877a7892e1 (patch)
tree83ebeccd064907913a4f21e89e7a83db6e6af0ad /clang/lib/Sema/SemaExpr.cpp
parent7459398a436f67f304c8653f39b8d82109778fec (diff)
downloadbcm5719-llvm-1af8dd6a1edb1d3a2e302b1e92d53d877a7892e1.tar.gz
bcm5719-llvm-1af8dd6a1edb1d3a2e302b1e92d53d877a7892e1.zip
isEvaluatable() implies a constant context.
Assume that we're in a constant context if we're asking if the expression can be compiled into a constant initializer. This fixes the issue where a __builtin_constant_p() in a compound literal was diagnosed as not being constant, even though it's always possible to convert the builtin into a constant. llvm-svn: 347512
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5d99a7ed69a..925988e4a7f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5798,7 +5798,12 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
: VK_LValue;
if (isFileScope)
- LiteralExpr = ConstantExpr::Create(Context, LiteralExpr);
+ if (auto ILE = dyn_cast<InitListExpr>(LiteralExpr))
+ for (unsigned i = 0, j = ILE->getNumInits(); i != j; i++) {
+ Expr *Init = ILE->getInit(i);
+ ILE->setInit(i, ConstantExpr::Create(Context, Init));
+ }
+
Expr *E = new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType,
VK, LiteralExpr, isFileScope);
if (isFileScope) {
OpenPOWER on IntegriCloud