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}}