]> granicus.if.org Git - clang/commitdiff
objective-c: deprecated C-like parameters in Objective-C
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 21 Jun 2012 18:43:08 +0000 (18:43 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 21 Jun 2012 18:43:08 +0000 (18:43 +0000)
method declarations.
// rdar://11578353.

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

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseObjc.cpp
test/SemaObjC/method-prototype-scope.m
test/SemaObjC/mismatched-undefined-method.m
test/SemaObjC/objc-cstyle-args-in-methods.m
test/SemaObjC/protocols.m
test/SemaObjC/related-result-type-inference.m

index ab3bf7ed451a62d0d61b9e7e967182a2cc8d24a0..a0e4ef958e6a62867aca678a49017cb669ba944b 100644 (file)
@@ -339,6 +339,9 @@ def err_illegal_super_cast : Error<
   "cannot cast 'super' (it isn't an expression)">;
 def err_nsnumber_nonliteral_unary : Error<
   "@%0 must be followed by a number to form an NSNumber object">;
+def warn_cstyle_param : Warning<
+  "use of C-style parameters in Objective-C method declarations"
+  " is deprecated">, InGroup<DeprecatedDeclarations>;
 
 let CategoryName = "ARC Parse Issue" in {
 def err_arc_bridge_retain : Error<
index d3016c7c15436a4876bf97960a774493de0aa65f..b96a8dde9f2528ee421ebfcf9f18d191189794db 100644 (file)
@@ -1106,7 +1106,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
   }
 
   bool isVariadic = false;
-
+  bool cStyleParamWarned = false;
   // Parse the (optional) parameter list.
   while (Tok.is(tok::comma)) {
     ConsumeToken();
@@ -1115,6 +1115,10 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
       ConsumeToken();
       break;
     }
+    if (!cStyleParamWarned) {
+      Diag(Tok, diag::warn_cstyle_param);
+      cStyleParamWarned = true;
+    }
     DeclSpec DS(AttrFactory);
     ParseDeclarationSpecifiers(DS);
     // Parse the declarator.
@@ -1126,7 +1130,6 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
                                                     ParmDecl.getIdentifierLoc(), 
                                                     Param,
                                                    0));
-
   }
 
   // FIXME: Add support for optional parameter list...
index 0bebd9b029d7e5d5189c3adee304656a451f13c2..c581500d02c837ae1a64c206267e1d070b191e2f 100644 (file)
@@ -7,7 +7,7 @@ int object;
 @class NSString, NSArray;
 
 @interface Test 
-- Func:(int)XXXX, id object;
+- Func:(int)XXXX, id object; // expected-warning {{use of C-style parameters in Objective-C method declarations is deprecated}}
 
 - doSomethingElseWith:(id)object;
 
@@ -23,7 +23,7 @@ int object;
     return object; // expected-warning {{incompatible pointer types returning 'NSArray *' from a function with result type 'NSString *'}}
 }
 
-- Func:(int)XXXX, id object { return object; }
+- Func:(int)XXXX, id object { return object; } // expected-warning {{use of C-style parameters in Objective-C method declarations is deprecated}}
 
 - doSomethingElseWith:(id)object { return object; }
 
index 936e892020d75b1f691edf4b014f7259d9f1c063..c41d142a40851be537f8b2a270928cb0662dca37 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify %s
+// RUN: %clang_cc1  -fsyntax-only -Wno-deprecated-declarations -verify %s
 // rdar://11460990
 
 typedef unsigned int CGDirectDisplayID;
index d37b5897b1140cd37f3811eae425fbde03d88ce1..ebc7192f0f5af4125e473bf2962f07db1db483d4 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1  -fsyntax-only -Wno-deprecated-declarations -verify -Wno-objc-root-class %s
 
 @interface Foo 
 - (id)test:(id)one, id two;
index ca38f20fbd0179c6d15847ed9f6e5c8315faf256..eb27341007691b40395ffe161842246955532e84 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-declarations -verify %s
 
 @interface INTF1
 @required  // expected-error {{directive may only be specified in protocols only}}
index 90671145a61f606c3083a21e93a4ed6eb7c08b23..b1d77dc1727747899f317d823b62539a0177ba39 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -Wno-deprecated-declarations -Wno-objc-root-class %s
 
 @interface Unrelated
 @end