r196352 - Fix error recovery in return statement.

Serge Pavlov sepavloff at gmail.com
Tue Dec 3 19:51:59 PST 2013


Author: sepavloff
Date: Tue Dec  3 21:51:59 2013
New Revision: 196352

URL: http://llvm.org/viewvc/llvm-project?rev=196352&view=rev
Log:
Fix error recovery in return statement.

This patch fixes PR16989.

Modified:
    cfe/trunk/lib/Parse/ParseStmt.cpp
    cfe/trunk/test/SemaCXX/crashes.cpp

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=196352&r1=196351&r2=196352&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Tue Dec  3 21:51:59 2013
@@ -1730,8 +1730,8 @@ StmtResult Parser::ParseReturnStatement(
           << R.get()->getSourceRange();
     } else
         R = ParseExpression();
-    if (R.isInvalid()) {  // Skip to the semicolon, but don't consume it.
-      SkipUntil(tok::semi, StopBeforeMatch);
+    if (R.isInvalid()) {
+      SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
       return StmtError();
     }
   }

Modified: cfe/trunk/test/SemaCXX/crashes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/crashes.cpp?rev=196352&r1=196351&r2=196352&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/crashes.cpp (original)
+++ cfe/trunk/test/SemaCXX/crashes.cpp Tue Dec  3 21:51:59 2013
@@ -218,3 +218,16 @@ namespace pr12791 {
   template class basic_stringbuf<char>;
 }
 
+namespace pr16989 {
+  class C {
+    template <class T>
+    C tpl_mem(T *) { return }    // expected-error{{expected expression}}
+    void mem(int *p) {
+      tpl_mem(p);
+    }
+  };
+  class C2 {
+    void f();
+  };
+  void C2::f() {}
+}





More information about the cfe-commits mailing list