r274260 - PR28373: fix crash-on-invalid if the condition of an if-statement fails typo-correction.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 30 11:36:35 PDT 2016


Author: rsmith
Date: Thu Jun 30 13:36:34 2016
New Revision: 274260

URL: http://llvm.org/viewvc/llvm-project?rev=274260&view=rev
Log:
PR28373: fix crash-on-invalid if the condition of an if-statement fails typo-correction.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaCXX/condition.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=274260&r1=274259&r2=274260&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jun 30 13:36:34 2016
@@ -14394,7 +14394,12 @@ Sema::ConditionResult Sema::ActOnConditi
   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);
 }
 

Modified: cfe/trunk/test/SemaCXX/condition.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/condition.cpp?rev=274260&r1=274259&r2=274260&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/condition.cpp (original)
+++ cfe/trunk/test/SemaCXX/condition.cpp Thu Jun 30 13:36:34 2016
@@ -65,3 +65,7 @@ void test5() {
 void test5_inst() {
    test5<int>();
 }
+
+void PR28373() {
+  if (!x) {} // expected-error {{undeclared}}
+}




More information about the cfe-commits mailing list