From 58196dc06ee27cd4150ef483123e1e3b2c772821 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 30 Nov 2011 23:45:35 +0000 Subject: [PATCH] Revert most of r145372 for now. Lookahead beyond the ';' in a function declaration tickles a bug in the way we handle visibility pragmas. The improvement to error recovery for template function definitions declared with the 'typedef' specifier in r145372 is unrelated and not reverted here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145541 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticParseKinds.td | 2 -- lib/Parse/ParseDecl.cpp | 17 +-------------- lib/Parse/ParseTemplate.cpp | 14 ------------- test/FixIt/fixit-cxx0x.cpp | 23 --------------------- test/FixIt/fixit.c | 8 ------- test/FixIt/fixit.cpp | 10 --------- 6 files changed, 1 insertion(+), 73 deletions(-) diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index 9b5540d4c9..e0b10fa87c 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -138,8 +138,6 @@ def ext_expected_semi_decl_list : ExtWarn< "expected ';' at end of declaration list">; def err_expected_member_name_or_semi : Error< "expected member name or ';' after declaration specifiers">; -def err_stray_semi_function_definition : Error< - "stray ';' in function definition">; def err_function_declared_typedef : Error< "function definition declared 'typedef'">; def err_iboutletcollection_builtintype : Error< diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 75c423340c..3bddd3de13 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1041,28 +1041,13 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS, return DeclGroupPtrTy(); } - // Do we have a stray semicolon in the middle of a function definition? - if (AllowFunctionDefinitions && D.isFunctionDeclarator() && - Tok.is(tok::semi) && Context == Declarator::FileContext) { - const Token &Next = NextToken(); - if (Next.is(tok::l_brace) || Next.is(tok::kw_try) || - (getLang().CPlusPlus && - (Next.is(tok::colon) || Next.is(tok::equal)))) { - // Pretend we didn't see the semicolon. - SourceLocation SemiLoc = ConsumeToken(); - Diag(SemiLoc, diag::err_stray_semi_function_definition) - << FixItHint::CreateRemoval(SemiLoc); - assert(isStartOfFunctionDefinition(D) && "expected a function defn"); - } - } - // Check to see if we have a function *definition* which must have a body. if (AllowFunctionDefinitions && D.isFunctionDeclarator() && // Look at the next token to make sure that this isn't a function // declaration. We have to check this because __attribute__ might be the // start of a function definition in GCC-extended K&R C. !isDeclarationAfterDeclarator()) { - + if (isStartOfFunctionDefinition(D)) { if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) { Diag(Tok, diag::err_function_declared_typedef); diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp index 7b09f8191d..9343f5b733 100644 --- a/lib/Parse/ParseTemplate.cpp +++ b/lib/Parse/ParseTemplate.cpp @@ -240,20 +240,6 @@ Parser::ParseSingleDeclarationAfterTemplate( return 0; } - // Check for a stray semicolon in a function definition. - if (DeclaratorInfo.isFunctionDeclarator() && Tok.is(tok::semi) && - Context == Declarator::FileContext) { - const Token &Next = NextToken(); - if (Next.is(tok::l_brace) || Next.is(tok::kw_try) || - Next.is(tok::equal) || Next.is(tok::colon)) { - SourceLocation SemiLoc = ConsumeToken(); - Diag(SemiLoc, diag::err_stray_semi_function_definition) - << FixItHint::CreateRemoval(SemiLoc); - assert(!isDeclarationAfterDeclarator() && - isStartOfFunctionDefinition(DeclaratorInfo)); - } - } - // If we have a declaration or declarator list, handle it. if (isDeclarationAfterDeclarator()) { // Parse this declaration. diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp index d9b8763b05..9fb647d03f 100644 --- a/test/FixIt/fixit-cxx0x.cpp +++ b/test/FixIt/fixit-cxx0x.cpp @@ -58,26 +58,3 @@ namespace SemiCommaTypo { n [[]], // expected-error {{expected ';' at end of declaration}} int o; } - -int extraSemi(); // expected-error {{stray ';' in function definition}} - = delete; - -class ExtraSemi { -public: - ExtraSemi(); - ExtraSemi(const ExtraSemi &); - int n; -}; -ExtraSemi::ExtraSemi(); // expected-error {{stray ';'}} - : n(0) { -} -ExtraSemi::ExtraSemi(const ExtraSemi &); // expected-error {{stray ';'}} - = default; - -template T extraSemi(T t); - -template T extraSemi(T t); // expected-error {{stray ';'}} -{ - return t; -} -template int extraSemi(int); diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index da1144da0f..967ae23c18 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -77,11 +77,3 @@ void oopsMoreCommas() { static int b[] = { 3, 4, 5 }, &a == &b ? oopsMoreCommas() : removeUnusedLabels(a[0]); } - -void extraSemicolon(); -{ - void extraSemicolon(); - { - return; - } -} diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp index e0fa6088c3..31ef18e404 100644 --- a/test/FixIt/fixit.cpp +++ b/test/FixIt/fixit.cpp @@ -126,16 +126,6 @@ AD oopsMoreCommas() { return ad; } -int extraSemi1(); // expected-error {{stray ';' in function definition}} -{ - return 0; -} - -int extraSemi2(); // expected-error {{stray ';' in function definition}} -try { -} catch (...) { -} - template struct Mystery; template typedef Mystery::type getMysteriousThing() { // \ expected-error {{function definition declared 'typedef'}} \ -- 2.40.0