r196757 - Avoid extra error messages if method definition is inside function.

Serge Pavlov sepavloff at gmail.com
Sun Dec 8 21:25:47 PST 2013


Author: sepavloff
Date: Sun Dec  8 23:25:47 2013
New Revision: 196757

URL: http://llvm.org/viewvc/llvm-project?rev=196757&view=rev
Log:
Avoid extra error messages if method definition is inside function.

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/Parser/cxx-class.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=196757&r1=196756&r2=196757&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Sun Dec  8 23:25:47 2013
@@ -1725,7 +1725,8 @@ Parser::DeclGroupPtrTy Parser::ParseDecl
     } else {
       if (Tok.is(tok::l_brace)) {
         Diag(Tok, diag::err_function_definition_not_allowed);
-        SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
+        SkipMalformedDecl();
+        return DeclGroupPtrTy();
       }
     }
   }

Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=196757&r1=196756&r2=196757&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Sun Dec  8 23:25:47 2013
@@ -113,6 +113,16 @@ namespace PR13775 {
   }
 }
 
+class pr16989 {
+  void tpl_mem(int *) {
+    return;
+    class C2 {
+      void f();
+    };
+    void C2::f() {} // expected-error{{function definition is not allowed here}}
+  };
+};
+
 // PR11109 must appear at the end of the source file
 class pr11109r3 { // expected-note{{to match this '{'}}
   public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}}





More information about the cfe-commits mailing list