[cfe-commits] r79912 - in /cfe/trunk: lib/Parse/Parser.cpp test/Parser/top-level-semi-cxx0x.cpp test/SemaCXX/constructor-initializer.cpp test/SemaCXX/constructor.cpp

Douglas Gregor dgregor at apple.com
Mon Aug 24 05:17:55 PDT 2009


Author: dgregor
Date: Mon Aug 24 07:17:54 2009
New Revision: 79912

URL: http://llvm.org/viewvc/llvm-project?rev=79912&view=rev
Log:
Top-level semicolons are allowed in C++0x. Fixes PR4755.

Added:
    cfe/trunk/test/Parser/top-level-semi-cxx0x.cpp   (with props)
Modified:
    cfe/trunk/lib/Parse/Parser.cpp
    cfe/trunk/test/SemaCXX/constructor-initializer.cpp
    cfe/trunk/test/SemaCXX/constructor.cpp

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=79912&r1=79911&r2=79912&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Mon Aug 24 07:17:54 2009
@@ -375,7 +375,7 @@
 ///       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 @@
 /// [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();

Added: cfe/trunk/test/Parser/top-level-semi-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/top-level-semi-cxx0x.cpp?rev=79912&view=auto

==============================================================================
--- cfe/trunk/test/Parser/top-level-semi-cxx0x.cpp (added)
+++ cfe/trunk/test/Parser/top-level-semi-cxx0x.cpp Mon Aug 24 07:17:54 2009
@@ -0,0 +1,9 @@
+// RUN: clang-cc -fsyntax-only -pedantic -std=c++0x -verify %s
+
+void foo();
+
+void bar() { };
+
+void wibble();
+
+;

Propchange: cfe/trunk/test/Parser/top-level-semi-cxx0x.cpp

------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/Parser/top-level-semi-cxx0x.cpp

------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/Parser/top-level-semi-cxx0x.cpp

------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cfe/trunk/test/SemaCXX/constructor-initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constructor-initializer.cpp?rev=79912&r1=79911&r2=79912&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/constructor-initializer.cpp (original)
+++ cfe/trunk/test/SemaCXX/constructor-initializer.cpp Mon Aug 24 07:17:54 2009
@@ -122,4 +122,3 @@
 
   float *pf;
 };
-

Modified: cfe/trunk/test/SemaCXX/constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constructor.cpp?rev=79912&r1=79911&r2=79912&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/constructor.cpp (original)
+++ cfe/trunk/test/SemaCXX/constructor.cpp Mon Aug 24 07:17:54 2009
@@ -83,3 +83,4 @@
 A::S::operator int() { return 1; }
 
 A::S::~S() {}
+





More information about the cfe-commits mailing list