From: Douglas Gregor Date: Mon, 24 Aug 2009 12:17:54 +0000 (+0000) Subject: Top-level semicolons are allowed in C++0x. Fixes PR4755. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1d71aea847a50b3acbd187d2ae9e5c1ead0f4e2;p=clang Top-level semicolons are allowed in C++0x. Fixes PR4755. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79912 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 1a082db434..798af1840a 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -375,7 +375,7 @@ void Parser::ParseTranslationUnit() { /// external-declaration: [C99 6.9], declaration: [C++ dcl.dcl] /// function-definition /// declaration -/// [EXT] ';' +/// [C++0x] empty-declaration /// [GNU] asm-definition /// [GNU] __extension__ external-declaration /// [OBJC] objc-class-definition @@ -388,12 +388,17 @@ void Parser::ParseTranslationUnit() { /// [GNU] asm-definition: /// simple-asm-expr ';' /// +/// [C++0x] empty-declaration: +/// ';' +/// Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration() { DeclPtrTy SingleDecl; switch (Tok.getKind()) { case tok::semi: - Diag(Tok, diag::ext_top_level_semi) - << CodeModificationHint::CreateRemoval(SourceRange(Tok.getLocation())); + if (!getLang().CPlusPlus0x) + Diag(Tok, diag::ext_top_level_semi) + << CodeModificationHint::CreateRemoval(SourceRange(Tok.getLocation())); + ConsumeToken(); // TODO: Invoke action for top-level semicolon. return DeclGroupPtrTy(); diff --git a/test/Parser/top-level-semi-cxx0x.cpp b/test/Parser/top-level-semi-cxx0x.cpp new file mode 100644 index 0000000000..4a6c0597d0 --- /dev/null +++ b/test/Parser/top-level-semi-cxx0x.cpp @@ -0,0 +1,9 @@ +// RUN: clang-cc -fsyntax-only -pedantic -std=c++0x -verify %s + +void foo(); + +void bar() { }; + +void wibble(); + +; diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp index 0bcec73264..1a7787ee0e 100644 --- a/test/SemaCXX/constructor-initializer.cpp +++ b/test/SemaCXX/constructor-initializer.cpp @@ -122,4 +122,3 @@ struct Q { float *pf; }; - diff --git a/test/SemaCXX/constructor.cpp b/test/SemaCXX/constructor.cpp index ec28e7e045..5ce595cdce 100644 --- a/test/SemaCXX/constructor.cpp +++ b/test/SemaCXX/constructor.cpp @@ -83,3 +83,4 @@ void A::S::f2() {} A::S::operator int() { return 1; } A::S::~S() {} +