[cfe-commits] r159691 - in /cfe/trunk: lib/Parse/ParseDecl.cpp lib/Parse/Parser.cpp test/SemaObjC/delay-parsing-cfunctions.m

Fariborz Jahanian fjahanian at apple.com
Tue Jul 3 15:54:28 PDT 2012


Author: fjahanian
Date: Tue Jul  3 17:54:28 2012
New Revision: 159691

URL: http://llvm.org/viewvc/llvm-project?rev=159691&view=rev
Log:
Obj-C++11 parser: fix broken parsing of c-function
defined in class implementations.


Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Parse/Parser.cpp
    cfe/trunk/test/SemaObjC/delay-parsing-cfunctions.m

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=159691&r1=159690&r2=159691&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Jul  3 17:54:28 2012
@@ -1379,10 +1379,8 @@
 
   bool ExpectSemi = Context != Declarator::ForContext;
 
-  // FIXME. make this work for Obj-C++11 parser.
   if (CurParsedObjCImpl && D.isFunctionDeclarator() &&
-      Tok.is(tok::l_brace) &&
-      !getLangOpts().CPlusPlus0x) {
+      Tok.is(tok::l_brace)) {
     // Consume the tokens and store them for later parsing.
     StashAwayMethodOrFunctionBodyTokens(FirstDecl);
     CurParsedObjCImpl->HasCFunction = true;
@@ -1615,7 +1613,8 @@
       Actions.AddInitializerToDecl(ThisDecl, Initializer.take(),
                                    /*DirectInit=*/true, TypeContainsAuto);
     }
-  } else if (getLangOpts().CPlusPlus0x && Tok.is(tok::l_brace)) {
+  } else if (getLangOpts().CPlusPlus0x && Tok.is(tok::l_brace) &&
+             !CurParsedObjCImpl) {
     // Parse C++0x braced-init-list.
     Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
 

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=159691&r1=159690&r2=159691&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Tue Jul  3 17:54:28 2012
@@ -775,7 +775,6 @@
     (getLangOpts().CPlusPlus &&
      Tok.is(tok::l_paren)) ||       // int X(0) -> not a function def [C++]
     (CurParsedObjCImpl && 
-     !getLangOpts().CPlusPlus0x && // FIXME for Obj-C++11 parser.
      Tok.is(tok::l_brace));        // C-function  nested in an @implementation
 }
 

Modified: cfe/trunk/test/SemaObjC/delay-parsing-cfunctions.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/delay-parsing-cfunctions.m?rev=159691&r1=159690&r2=159691&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/delay-parsing-cfunctions.m (original)
+++ cfe/trunk/test/SemaObjC/delay-parsing-cfunctions.m Tue Jul  3 17:54:28 2012
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1  -fsyntax-only -Werror -verify -Wno-objc-root-class %s
 // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -Werror -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -std=c++11 -fsyntax-only -Werror -verify -Wno-objc-root-class %s
 // rdar://10387088
 
 @interface MyClass
@@ -29,4 +30,8 @@
 
 static int getMe;
 
+static int test() {
+  return 0;
+}
+
 @end





More information about the cfe-commits mailing list