]> granicus.if.org Git - clang/commitdiff
Fixes an ObjC++ parse crash caused by delayed parsing
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 20 Jul 2012 17:19:54 +0000 (17:19 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 20 Jul 2012 17:19:54 +0000 (17:19 +0000)
of c-functions nested in namespace in method implementations
by turning off its delayed parsing until a proper solution is
figured out. pr13418

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160552 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/SemaObjCXX/delay-parsing-cfunctions.mm

index 05d44a5af0ca15e340f2b84b7f4a5b6f52e306d2..38aff5d4b9f3936999d2d630adb8f860fc0a540e 100644 (file)
@@ -1340,9 +1340,12 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
       // 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) {
index fbdf8bad0aa769e39311ec3ce31592137333539b..fa65dbea9eceda31b4f44032dc1425ca8a3ede39 100644 (file)
@@ -41,4 +41,8 @@ int x{17};
 
 X::X() = default;
 void X::SortWithCollator() {}
+// pr13418
+namespace {
+     int CurrentTabId() {return 0;}
+}
 @end