]> granicus.if.org Git - clang/commitdiff
Avoid extra error messages if method definition is inside function.
authorSerge Pavlov <sepavloff@gmail.com>
Mon, 9 Dec 2013 05:25:47 +0000 (05:25 +0000)
committerSerge Pavlov <sepavloff@gmail.com>
Mon, 9 Dec 2013 05:25:47 +0000 (05:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196757 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/Parser/cxx-class.cpp

index 2c93def4c2bd0d778cf6f301328e6a48c8d30515..9d8af30b5bf10e181687420a2e9277b16e21a573 100644 (file)
@@ -1725,7 +1725,8 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
     } else {
       if (Tok.is(tok::l_brace)) {
         Diag(Tok, diag::err_function_definition_not_allowed);
-        SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
+        SkipMalformedDecl();
+        return DeclGroupPtrTy();
       }
     }
   }
index 5fac79728579a818e845d4b38cd20f1ea7bb1a86..d4d8c44943683904253d89e31c50ded79a79b9bf 100644 (file)
@@ -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}}