Top-level semicolons are allowed in C++0x. Fixes PR4755.

llvm-svn: 79912
This commit is contained in:
Douglas Gregor 2009-08-24 12:17:54 +00:00
parent c8c277a1b3
commit 8b9575f27e
4 changed files with 18 additions and 4 deletions

View 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();

View File

@ -0,0 +1,9 @@
// RUN: clang-cc -fsyntax-only -pedantic -std=c++0x -verify %s
void foo();
void bar() { };
void wibble();
;

View File

@ -122,4 +122,3 @@ struct Q {
float *pf;
};

View File

@ -83,3 +83,4 @@ void A::S::f2() {}
A::S::operator int() { return 1; }
A::S::~S() {}