]> granicus.if.org Git - clang/commitdiff
Obj-C++11 parser: handle a fall out of delayed
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 3 Jul 2012 23:22:13 +0000 (23:22 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 3 Jul 2012 23:22:13 +0000 (23:22 +0000)
c-function parsing when a declaration with
C++0x braced-init-list is inside an @implementation.

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

lib/Parse/ParseDecl.cpp
test/SemaObjC/delay-parsing-cfunctions.m
test/SemaObjCXX/delay-parsing-cfunctions.mm [new file with mode: 0644]

index 21dd46f2e9f79057016965c32f9f5fe11b12ed61..a96e29556b9822110fd86e55ac430ce255851c69 100644 (file)
@@ -1614,7 +1614,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(Declarator &D,
                                    /*DirectInit=*/true, TypeContainsAuto);
     }
   } else if (getLangOpts().CPlusPlus0x && Tok.is(tok::l_brace) &&
-             !CurParsedObjCImpl) {
+             (!CurParsedObjCImpl || !D.isFunctionDeclarator())) {
     // Parse C++0x braced-init-list.
     Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
 
index 840923ad6f7b1e9642d0b365fdeb4f8295027465..81734fdda498d3cee292bbb7e89a58891d563764 100644 (file)
@@ -1,6 +1,5 @@
 // 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
diff --git a/test/SemaObjCXX/delay-parsing-cfunctions.mm b/test/SemaObjCXX/delay-parsing-cfunctions.mm
new file mode 100644 (file)
index 0000000..8e9c319
--- /dev/null
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -x objective-c++ -std=c++11 -fsyntax-only -Werror -verify -Wno-objc-root-class %s
+// rdar://10387088
+
+struct X {
+X();
+};
+
+@interface MyClass
+- (void)someMethod;
+@end
+
+@implementation MyClass
+- (void)someMethod {
+    [self privateMethod];  // clang already does not warn here
+}
+
+int bar(MyClass * myObject) {
+    [myObject privateMethod]; 
+    return gorfbar(myObject);
+}
+- (void)privateMethod { }
+
+int gorfbar(MyClass * myObject) {
+    [myObject privateMethod]; 
+    [myObject privateMethod1]; 
+    return getMe + bar(myObject);
+}
+
+- (void)privateMethod1 {
+  getMe = getMe+1;
+}
+
+static int getMe;
+
+static int test() {
+  return 0;
+}
+
+int x{17};
+
+X::X() = default;
+
+@end