Skip to content

Commit

Permalink
Obj-C++11 parser: fix broken parsing of c-function
Browse files Browse the repository at this point in the history
defined in class implementations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159691 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Fariborz Jahanian committed Jul 3, 2012
1 parent cda1041 commit 3b5f9dc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/Parse/ParseDecl.cpp
Expand Up @@ -1379,10 +1379,8 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,

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;
Expand Down Expand Up @@ -1615,7 +1613,8 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(Declarator &D,
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);

Expand Down
1 change: 0 additions & 1 deletion lib/Parse/Parser.cpp
Expand Up @@ -775,7 +775,6 @@ bool Parser::isDeclarationAfterDeclarator() {
(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
}

Expand Down
5 changes: 5 additions & 0 deletions test/SemaObjC/delay-parsing-cfunctions.m
@@ -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
Expand Down Expand Up @@ -29,4 +30,8 @@ - (void)privateMethod1 {

static int getMe;

static int test() {
return 0;
}

@end

0 comments on commit 3b5f9dc

Please sign in to comment.