]> granicus.if.org Git - clang/commitdiff
Parse the optional semicolon after a C++ in-class member function
authorDouglas Gregor <dgregor@apple.com>
Wed, 19 Jan 2011 16:41:58 +0000 (16:41 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 19 Jan 2011 16:41:58 +0000 (16:41 +0000)
definition, rather than complaining about it. Problem reported by
Marshall Clow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123835 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 20e2b8b0be2677757c965f57577fba076dfca3d6..75a6f59eac0840541757a3acfd01379cd40c5993 100644 (file)
@@ -1489,6 +1489,10 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
         Diag(Tok, diag::err_func_def_no_params);
         ConsumeBrace();
         SkipUntil(tok::r_brace, true);
+        
+        // Consume the optional ';'
+        if (Tok.is(tok::semi))
+          ConsumeToken();
         return;
       }
 
@@ -1499,10 +1503,18 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
         // assumes the declarator represents a function, not a typedef.
         ConsumeBrace();
         SkipUntil(tok::r_brace, true);
+
+        // Consume the optional ';'
+        if (Tok.is(tok::semi))
+          ConsumeToken();
         return;
       }
 
       ParseCXXInlineMethodDef(AS, DeclaratorInfo, TemplateInfo);
+      // Consume the optional ';'
+      if (Tok.is(tok::semi))
+        ConsumeToken();
+
       return;
     }
   }
index 57831a463b9bb9b947517d19f1e85a6544c7b586..f863bd198e507acda27fb9e001bb05cf753abbbf 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
 class C;
 class C {
 public:
@@ -14,7 +14,11 @@ protected:
 public:
   void m() {
     int l = 2;
-  }
+  };
+
+  template<typename T> void mt(T) { };
+  ; // expected-warning{{extra ';' inside a class}}
+
   virtual int vf() const volatile = 0;
   
 private: