]> granicus.if.org Git - clang/commitdiff
Top-level semicolons are allowed in C++0x. Fixes PR4755.
authorDouglas Gregor <dgregor@apple.com>
Mon, 24 Aug 2009 12:17:54 +0000 (12:17 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 24 Aug 2009 12:17:54 +0000 (12:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79912 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/Parser.cpp
test/Parser/top-level-semi-cxx0x.cpp [new file with mode: 0644]
test/SemaCXX/constructor-initializer.cpp
test/SemaCXX/constructor.cpp

index 1a082db434648546f4c8794b0f87837ebc7a26f1..798af1840a68ef6a554ab25cfe73567cdf756032 100644 (file)
@@ -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 (file)
index 0000000..4a6c059
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: clang-cc -fsyntax-only -pedantic -std=c++0x -verify %s
+
+void foo();
+
+void bar() { };
+
+void wibble();
+
+;
index 0bcec732646015a0cc976cbd065eb36c0bce7ae4..1a7787ee0ea873505a88752ea1d2bb0c8d8c1965 100644 (file)
@@ -122,4 +122,3 @@ struct Q {
 
   float *pf;
 };
-
index ec28e7e0455196f986a40a1dbd2052c6fec7c02a..5ce595cdcececd1fbd88149ff1c3fd8e9b5782fd 100644 (file)
@@ -83,3 +83,4 @@ void A::S::f2() {}
 A::S::operator int() { return 1; }
 
 A::S::~S() {}
+