From a6983aca9b859da788dc8b2bcf215c35a40191e1 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 30 Jun 2016 18:36:34 +0000 Subject: [PATCH] PR28373: fix crash-on-invalid if the condition of an if-statement fails typo-correction. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274260 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 7 ++++++- test/SemaCXX/condition.cpp | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 56cf5d4fd3..cc2a11fccf 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -14394,7 +14394,12 @@ Sema::ConditionResult Sema::ActOnCondition(Scope *S, SourceLocation Loc, if (Cond.isInvalid()) return ConditionError(); - return ConditionResult(*this, nullptr, MakeFullExpr(Cond.get(), Loc), + // FIXME: FullExprArg doesn't have an invalid bit, so check nullness instead. + FullExprArg FullExpr = MakeFullExpr(Cond.get(), Loc); + if (!FullExpr.get()) + return ConditionError(); + + return ConditionResult(*this, nullptr, FullExpr, CK == ConditionKind::ConstexprIf); } diff --git a/test/SemaCXX/condition.cpp b/test/SemaCXX/condition.cpp index b757fcb8cd..5596564d24 100644 --- a/test/SemaCXX/condition.cpp +++ b/test/SemaCXX/condition.cpp @@ -65,3 +65,7 @@ void test5() { void test5_inst() { test5(); } + +void PR28373() { + if (!x) {} // expected-error {{undeclared}} +} -- 2.40.0