diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 1 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 25 |
2 files changed, 15 insertions, 11 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 273b5ed72f7..e34412e1909 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1044,6 +1044,7 @@ static ICEDiag CheckEvalInICE(const Expr* E, ASTContext &Ctx) { } static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { + assert(!E->isValueDependent() && "Should not see value dependent exprs!"); if (!E->getType()->isIntegralType()) { return ICEDiag(2, E->getLocStart()); } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 57a6c624616..37035b98c75 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2243,20 +2243,23 @@ Sema::DeclTy *Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc, StringLiteral *AssertMessage = cast<StringLiteral>((Expr *)assertmessageexpr.get()); - llvm::APSInt Value(32); - if (!AssertExpr->isIntegerConstantExpr(Value, Context)) { - Diag(AssertLoc, diag::err_static_assert_expression_is_not_constant) << - AssertExpr->getSourceRange(); - return 0; - } + if (!AssertExpr->isTypeDependent() && !AssertExpr->isValueDependent()) { + llvm::APSInt Value(32); + if (!AssertExpr->isIntegerConstantExpr(Value, Context)) { + Diag(AssertLoc, diag::err_static_assert_expression_is_not_constant) << + AssertExpr->getSourceRange(); + return 0; + } + if (Value == 0) { + std::string str(AssertMessage->getStrData(), + AssertMessage->getByteLength()); + Diag(AssertLoc, diag::err_static_assert_failed) << str; + } + } + Decl *Decl = StaticAssertDecl::Create(Context, CurContext, AssertLoc, AssertExpr, AssertMessage); - if (Value == 0) { - std::string str(AssertMessage->getStrData(), - AssertMessage->getByteLength()); - Diag(AssertLoc, diag::err_static_assert_failed) << str; - } CurContext->addDecl(Decl); return Decl; |

