]> granicus.if.org Git - clang/commitdiff
PR28373: fix crash-on-invalid if the condition of an if-statement fails typo-correction.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 30 Jun 2016 18:36:34 +0000 (18:36 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 30 Jun 2016 18:36:34 +0000 (18:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274260 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/condition.cpp

index 56cf5d4fd379785cb71632f458dbd80b5708870b..cc2a11fccfb8979ad732533b908b22e03e1f4510 100644 (file)
@@ -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);
 }
 
index b757fcb8cd5c9f7d37cf8599694531a8a897d8bb..5596564d2481aca107d3908a6dfc8dc3b750fd4c 100644 (file)
@@ -65,3 +65,7 @@ void test5() {
 void test5_inst() {
    test5<int>();
 }
+
+void PR28373() {
+  if (!x) {} // expected-error {{undeclared}}
+}