aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-07-03 22:54:28 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-07-03 22:54:28 +0000
commit3b5f9dc024232fe3bde347f6b52155ff7f55a232 (patch)
treec539946b8e938f88c13c2ef842f80f463902b1dd
parentcda104171088d721f627420962fc940d69c313b4 (diff)
Obj-C++11 parser: fix broken parsing of c-function
defined in class implementations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159691 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Parse/ParseDecl.cpp7
-rw-r--r--lib/Parse/Parser.cpp1
-rw-r--r--test/SemaObjC/delay-parsing-cfunctions.m5
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 0a8ab1ac1a..21dd46f2e9 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -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;
@@ -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);
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 8ae0aa9976..c2c4c90090 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -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
}
diff --git a/test/SemaObjC/delay-parsing-cfunctions.m b/test/SemaObjC/delay-parsing-cfunctions.m
index dcebcfa947..840923ad6f 100644
--- a/test/SemaObjC/delay-parsing-cfunctions.m
+++ b/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
@@ -29,4 +30,8 @@ int gorfbar(MyClass * myObject) {
static int getMe;
+static int test() {
+ return 0;
+}
+
@end