From ebea9aff0da1848d805d367f0c882e1a4188e284 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 21 Feb 2012 22:41:33 +0000 Subject: [PATCH] Fix a crash in the diangostic code in EvalConstant. PR12043. llvm-svn: 151100 --- clang/lib/AST/ExprConstant.cpp | 4 +++- clang/test/Sema/const-eval.c | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 4ae5ab42ff79..5420876866d3 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -538,8 +538,10 @@ namespace { = diag::note_invalid_subexpr_in_const_expr, unsigned ExtraNotes = 0) { // Don't override a previous diagnostic. - if (!EvalStatus.Diag || !EvalStatus.Diag->empty()) + if (!EvalStatus.Diag || !EvalStatus.Diag->empty()) { + HasActiveDiagnostic = false; return OptionalDiagnostic(); + } return Diag(Loc, DiagId, ExtraNotes); } diff --git a/clang/test/Sema/const-eval.c b/clang/test/Sema/const-eval.c index 22ac67adad99..a9c8806b5d99 100644 --- a/clang/test/Sema/const-eval.c +++ b/clang/test/Sema/const-eval.c @@ -112,3 +112,8 @@ int castViaInt[*(int*)(unsigned long)"test"]; // expected-error {{variable lengt // PR11391. struct PR11391 { _Complex float f; } pr11391; EVAL_EXPR(42, __builtin_constant_p(pr11391.f = 1)) + +// PR12043 +float varfloat; +const float constfloat = 0; +EVAL_EXPR(43, varfloat && constfloat) // expected-error {{must have a constant size}}