[cfe-commits] r160552 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaObjCXX/delay-parsing-cfunctions.mm

Fariborz Jahanian fjahanian at apple.com
Fri Jul 20 10:19:54 PDT 2012


Author: fjahanian
Date: Fri Jul 20 12:19:54 2012
New Revision: 160552

URL: http://llvm.org/viewvc/llvm-project?rev=160552&view=rev
Log:
Fixes an ObjC++ parse crash caused by delayed parsing
of c-functions nested in namespace in method implementations
by turning off its delayed parsing until a proper solution is 
figured out. pr13418

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/SemaObjCXX/delay-parsing-cfunctions.mm

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=160552&r1=160551&r2=160552&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Jul 20 12:19:54 2012
@@ -1340,9 +1340,12 @@
       // 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.
+      // FIXME. Delayed parsing not done for c/c++ functions nested in namespace
       !isDeclarationAfterDeclarator() && 
       (!CurParsedObjCImpl || Tok.isNot(tok::l_brace) || 
-       (getLangOpts().CPlusPlus && D.getCXXScopeSpec().isSet()))) {
+       (getLangOpts().CPlusPlus && 
+        (D.getCXXScopeSpec().isSet() || 
+         !Actions.CurContext->isTranslationUnit())))) {
 
     if (isStartOfFunctionDefinition(D)) {
       if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {

Modified: cfe/trunk/test/SemaObjCXX/delay-parsing-cfunctions.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/delay-parsing-cfunctions.mm?rev=160552&r1=160551&r2=160552&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/delay-parsing-cfunctions.mm (original)
+++ cfe/trunk/test/SemaObjCXX/delay-parsing-cfunctions.mm Fri Jul 20 12:19:54 2012
@@ -41,4 +41,8 @@
 
 X::X() = default;
 void X::SortWithCollator() {}
+// pr13418
+namespace {
+     int CurrentTabId() {return 0;}
+}
 @end





More information about the cfe-commits mailing list