[cfe-commits] r145541 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseDecl.cpp lib/Parse/ParseTemplate.cpp test/FixIt/fixit-cxx0x.cpp test/FixIt/fixit.c test/FixIt/fixit.cpp

Richard Smith richard-llvm at metafoo.co.uk
Wed Nov 30 15:45:35 PST 2011


Author: rsmith
Date: Wed Nov 30 17:45:35 2011
New Revision: 145541

URL: http://llvm.org/viewvc/llvm-project?rev=145541&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Parse/ParseTemplate.cpp
    cfe/trunk/test/FixIt/fixit-cxx0x.cpp
    cfe/trunk/test/FixIt/fixit.c
    cfe/trunk/test/FixIt/fixit.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=145541&r1=145540&r2=145541&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Nov 30 17:45:35 2011
@@ -138,8 +138,6 @@
   "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<

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=145541&r1=145540&r2=145541&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Nov 30 17:45:35 2011
@@ -1041,28 +1041,13 @@
     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);

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=145541&r1=145540&r2=145541&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Wed Nov 30 17:45:35 2011
@@ -240,20 +240,6 @@
     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.

Modified: cfe/trunk/test/FixIt/fixit-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-cxx0x.cpp?rev=145541&r1=145540&r2=145541&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit-cxx0x.cpp (original)
+++ cfe/trunk/test/FixIt/fixit-cxx0x.cpp Wed Nov 30 17:45:35 2011
@@ -58,26 +58,3 @@
   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<typename T> T extraSemi(T t);
-
-template<typename T> T extraSemi(T t); // expected-error {{stray ';'}}
-{
-  return t;
-}
-template int extraSemi(int);

Modified: cfe/trunk/test/FixIt/fixit.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.c?rev=145541&r1=145540&r2=145541&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit.c (original)
+++ cfe/trunk/test/FixIt/fixit.c Wed Nov 30 17:45:35 2011
@@ -77,11 +77,3 @@
   static int b[] = { 3, 4, 5 },
   &a == &b ? oopsMoreCommas() : removeUnusedLabels(a[0]);
 }
-
-void extraSemicolon();
-{
-  void extraSemicolon();
-  {
-    return;
-  }
-}

Modified: cfe/trunk/test/FixIt/fixit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.cpp?rev=145541&r1=145540&r2=145541&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit.cpp (original)
+++ cfe/trunk/test/FixIt/fixit.cpp Wed Nov 30 17:45:35 2011
@@ -126,16 +126,6 @@
   return ad;
 }
 
-int extraSemi1(); // expected-error {{stray ';' in function definition}}
-{
-  return 0;
-}
-
-int extraSemi2(); // expected-error {{stray ';' in function definition}}
-try {
-} catch (...) {
-}
-
 template<class T> struct Mystery;
 template<class T> typedef Mystery<T>::type getMysteriousThing() { // \
   expected-error {{function definition declared 'typedef'}} \





More information about the cfe-commits mailing list