diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2013-10-01 00:28:29 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2013-10-01 00:28:29 +0000 |
| commit | 4a962f03bebef9e3c7d501580357a303638b2700 (patch) | |
| tree | 731432d0b34ae42bc43a04c34d0e3015779702f1 /clang/lib | |
| parent | dd0bc7b560d081d49874991e94317ac8df97eae9 (diff) | |
| download | bcm5719-llvm-4a962f03bebef9e3c7d501580357a303638b2700.tar.gz bcm5719-llvm-4a962f03bebef9e3c7d501580357a303638b2700.zip | |
Tweak changes in r186464 to avoid a crash.
Currently, IR generation can't handle file-scope compound literals with
non-constant initializers in C++.
Fixes PR17415 (the first crash in the bug).
(We should probably change (T){1,2,3} to use the same codepath as T{1,2,3} in
C++ eventually, given that the semantics of the latter are actually defined by
the standard.)
llvm-svn: 191719
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 5 |
2 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index a3a36da65f4..38f5e2f4887 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -2654,9 +2654,6 @@ bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef) const { return Exp->isConstantInitializer(Ctx, false); } case InitListExprClass: { - // FIXME: This doesn't deal with fields with reference types correctly. - // FIXME: This incorrectly allows pointers cast to integers to be assigned - // to bitfields. const InitListExpr *ILE = cast<InitListExpr>(this); if (ILE->getType()->isArrayType()) { unsigned numInits = ILE->getNumInits(); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 9940e8ba79b..239567844d4 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4717,7 +4717,10 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, LiteralExpr = Result.get(); bool isFileScope = getCurFunctionOrMethodDecl() == 0; - if (!getLangOpts().CPlusPlus && isFileScope) { // 6.5.2.5p3 + if (isFileScope && + !LiteralExpr->isTypeDependent() && + !LiteralExpr->isValueDependent() && + !literalType->isDependentType()) { // 6.5.2.5p3 if (CheckForConstantInitializer(LiteralExpr, literalType)) return ExprError(); } |

