diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/Expr.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index de0c740fd2..8d9bbcb65a 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -670,7 +670,7 @@ bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const { /// expression. The generalization of the wording to include any subexpression /// that is not evaluated (C99 6.6p3) means that nonconstant subexpressions /// can appear as operands to other operators (e.g. &&, ||, ?:). For instance, -/// "0 || f()" can be treated as a constant expression. In C90 this expression, +/// "1 || f()" can be treated as a constant expression. In C90 this expression, /// occurring in a context requiring a constant, would have been a constraint /// violation. FIXME: This routine currently implements C90 semantics. /// To properly implement C99 semantics this routine will need to evaluate diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 80c37b9764..8b98cbad11 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1197,10 +1197,15 @@ bool Sema::CheckArithmeticConstantExpression(const Expr* Init) { } bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) { + Init = Init->IgnoreParens(); + // Look through CXXDefaultArgExprs; they have no meaning in this context. if (CXXDefaultArgExpr* DAE = dyn_cast<CXXDefaultArgExpr>(Init)) return CheckForConstantInitializer(DAE->getExpr(), DclT); + if (CompoundLiteralExpr *e = dyn_cast<CompoundLiteralExpr>(Init)) + return CheckForConstantInitializer(e->getInitializer(), DclT); + if (Init->getType()->isReferenceType()) { // FIXME: Work out how the heck reference types work return false; |