Fix a crash in the diangostic code in EvalConstant. PR12043.

llvm-svn: 151100
This commit is contained in:
Eli Friedman 2012-02-21 22:41:33 +00:00
parent d6e765c69f
commit ebea9aff0d
2 changed files with 8 additions and 1 deletions

View File

@ -538,8 +538,10 @@ namespace {
= diag::note_invalid_subexpr_in_const_expr, = diag::note_invalid_subexpr_in_const_expr,
unsigned ExtraNotes = 0) { unsigned ExtraNotes = 0) {
// Don't override a previous diagnostic. // Don't override a previous diagnostic.
if (!EvalStatus.Diag || !EvalStatus.Diag->empty()) if (!EvalStatus.Diag || !EvalStatus.Diag->empty()) {
HasActiveDiagnostic = false;
return OptionalDiagnostic(); return OptionalDiagnostic();
}
return Diag(Loc, DiagId, ExtraNotes); return Diag(Loc, DiagId, ExtraNotes);
} }

View File

@ -112,3 +112,8 @@ int castViaInt[*(int*)(unsigned long)"test"]; // expected-error {{variable lengt
// PR11391. // PR11391.
struct PR11391 { _Complex float f; } pr11391; struct PR11391 { _Complex float f; } pr11391;
EVAL_EXPR(42, __builtin_constant_p(pr11391.f = 1)) 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}}