From: Douglas Gregor Date: Wed, 19 Jan 2011 16:41:58 +0000 (+0000) Subject: Parse the optional semicolon after a C++ in-class member function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ea416e598fa3cb09d67d514c4519c99abb81321;p=clang Parse the optional semicolon after a C++ in-class member function 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 --- diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index 20e2b8b0be..75a6f59eac 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -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; } } diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp index 57831a463b..f863bd198e 100644 --- a/test/Parser/cxx-class.cpp +++ b/test/Parser/cxx-class.cpp @@ -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 void mt(T) { }; + ; // expected-warning{{extra ';' inside a class}} + virtual int vf() const volatile = 0; private: