In gcc/: 2010-11-19 Nicola Pero <nicola.pero@meta-innovation.com>
authorNicola Pero <nicola@gcc.gnu.org>
Fri, 19 Nov 2010 12:29:45 +0000 (12:29 +0000)
committerNicola Pero <nicola@gcc.gnu.org>
Fri, 19 Nov 2010 12:29:45 +0000 (12:29 +0000)
In gcc/:
2010-11-19  Nicola Pero  <nicola.pero@meta-innovation.com>

        * c-parser.c (c_parser_objc_protocol_definition): Pass attributes
        to objc_declare_protocols.

In gcc/c-family/:
2010-11-19  Nicola Pero  <nicola.pero@meta-innovation.com>

        * c-common.h (objc_declare_protocols): Added additional argument.
        * stub-objc.c (objc_declare_protocol): Same change.

In gcc/cp/:
2010-11-19  Nicola Pero  <nicola.pero@meta-innovation.com>

        * parser.c (cp_parser_objc_protocol_declaration): Pass attributes
        to objc_declare_protocols.

In gcc/objc/:
2010-11-19  Nicola Pero  <nicola@nicola.brainstorm.co.uk>

        * objc-act.c (lookup_protocol): Added 'warn_if_deprecated'
        argument.  If it is 'true' and the protocol is deprecated, emit a
        deprecation warning.
        (objc_start_protocol): Do not warn that protocol attributes are
        unimplemented.  Pass the attributes to start_protocol.
        (start_protocol): Added attributes argument.  Recognize the
        'deprecated' attribute and mark the protocols with TREE_DEPRECATED
        if present.  Store attributes in the protocol.
        (objc_declare_protocols): Added 'attributes' argument.  Recognize
        the 'deprecated' attribute and mark the protocols with
        TREE_DEPRECATED if present.  Store attributes in the protocol.
        Updated call to lookup_protocol.
        (objc_build_protocol_expr): Updated call to lookup_protocol.
        (check_protocol_recursively): Same change.
        (lookup_and_install_protocols): Same change.
        * objc-act.h: Updated comments.

In gcc/testsuite/:
2010-11-19  Nicola Pero  <nicola.pero@meta-innovation.com>

        * objc.dg/attributes/proto-attribute-1.m: Updated.
        * objc.dg/attributes/proto-attribute-2.m: New.
        * objc.dg/attributes/proto-attribute-3.m: New.
        * obj-c++.dg/attributes/proto-attribute-1.mm: Updated.
        * obj-c++.dg/attributes/proto-attribute-2.mm: New.
        * obj-c++.dg/attributes/proto-attribute-3.mm: New.

From-SVN: r166938

17 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.h
gcc/c-family/stub-objc.c
gcc/c-parser.c
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/objc/ChangeLog
gcc/objc/objc-act.c
gcc/objc/objc-act.h
gcc/testsuite/ChangeLog
gcc/testsuite/obj-c++.dg/attributes/proto-attribute-1.mm
gcc/testsuite/obj-c++.dg/attributes/proto-attribute-2.mm [new file with mode: 0644]
gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm [new file with mode: 0644]
gcc/testsuite/objc.dg/attributes/proto-attribute-1.m
gcc/testsuite/objc.dg/attributes/proto-attribute-2.m [new file with mode: 0644]
gcc/testsuite/objc.dg/attributes/proto-attribute-3.m [new file with mode: 0644]

index 195f96d3b2d99eef43522820a7a0e553570ea621..2ca38e4db51606405d3c2e1761c9f3999e62c65a 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-19  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * c-parser.c (c_parser_objc_protocol_definition): Pass attributes
+       to objc_declare_protocols.
+
 2010-11-19  Richard Guenther  <rguenther@suse.de>
 
        PR lto/45789
index 86fbd1335106e49e6024a9796438437158ebbc05..61dc8b621cf6dc8947c29442f11e4784c7eb0d0d 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-19  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * c-common.h (objc_declare_protocols): Added additional argument.
+       * stub-objc.c (objc_declare_protocol): Same change.
+       
 2010-11-18  Nathan Froyd  <froydnj@codesourcery.com>
 
        PR c/33193
index 3de32cf6ddaa5f182edfc0c07ac70d2be0d958dd..6c6da9d1b1d0334e8c47a0ed42b1464ad9adb860 100644 (file)
@@ -996,7 +996,7 @@ extern int objc_is_public (tree, tree);
 extern tree objc_is_id (tree);
 extern void objc_declare_alias (tree, tree);
 extern void objc_declare_class (tree);
-extern void objc_declare_protocols (tree);
+extern void objc_declare_protocols (tree, tree);
 extern tree objc_build_message_expr (tree);
 extern tree objc_finish_message_expr (tree, tree, tree);
 extern tree objc_build_selector_expr (location_t, tree);
index 5cd6e6d6e79eac89ac3556591cb40740902c0186..e1e3090f768c3ea32a31403182982a0ac2408ecc 100644 (file)
@@ -126,7 +126,7 @@ objc_declare_class (tree ARG_UNUSED (list))
 }
 
 void
-objc_declare_protocols (tree ARG_UNUSED (list))
+objc_declare_protocols (tree ARG_UNUSED (list), tree ARG_UNUSED (attributes))
 {
 }
 
index 0c4662a9c7cd31be6a517f3946dcd94d273830f9..c63f001ad4d60980186d17bb890faf5d2a5e7b49 100644 (file)
@@ -7046,7 +7046,7 @@ c_parser_objc_protocol_definition (c_parser *parser, tree attributes)
            break;
        }
       c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>");
-      objc_declare_protocols (list);
+      objc_declare_protocols (list, attributes);
     }
   else
     {
index 6f9bb075f288394dc81cde483b2f5064a474505b..b192ed150db5c30062882ef6220ebe5885b336cf 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-19  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * parser.c (cp_parser_objc_protocol_declaration): Pass attributes
+       to objc_declare_protocols.
+
 2010-11-18  Nathan Froyd  <froydnj@codesourcery.com>
 
        PR c/33193
index 906b0c36565b90413240b2ff22db469f96c1b734..c82eb036749b85bbe2e563f1b16368ecfa139698 100644 (file)
@@ -22314,7 +22314,8 @@ cp_parser_objc_protocol_declaration (cp_parser* parser, tree attributes)
   /* Try a forward declaration first.  */
   if (tok->type == CPP_COMMA || tok->type == CPP_SEMICOLON)
     {
-      objc_declare_protocols (cp_parser_objc_identifier_list (parser));
+      objc_declare_protocols (cp_parser_objc_identifier_list (parser), 
+                             attributes);
      finish:
       cp_parser_consume_semicolon_at_end_of_statement (parser);
     }
index dd4814891a720473b158d9136a292e320f2bbad7..5b460a8096a87dda786c8d168000c3a1313aff6a 100644 (file)
@@ -1,3 +1,22 @@
+2010-11-19  Nicola Pero  <nicola@nicola.brainstorm.co.uk>
+
+       * objc-act.c (lookup_protocol): Added 'warn_if_deprecated'
+       argument.  If it is 'true' and the protocol is deprecated, emit a
+       deprecation warning.
+       (objc_start_protocol): Do not warn that protocol attributes are
+       unimplemented.  Pass the attributes to start_protocol.
+       (start_protocol): Added attributes argument.  Recognize the
+       'deprecated' attribute and mark the protocols with TREE_DEPRECATED
+       if present.  Store attributes in the protocol.
+       (objc_declare_protocols): Added 'attributes' argument.  Recognize
+       the 'deprecated' attribute and mark the protocols with
+       TREE_DEPRECATED if present.  Store attributes in the protocol.
+       Updated call to lookup_protocol.
+       (objc_build_protocol_expr): Updated call to lookup_protocol.
+       (check_protocol_recursively): Same change.
+       (lookup_and_install_protocols): Same change.
+       * objc-act.h: Updated comments.
+       
 2010-11-17  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * objc-act.c (lookup_method_in_protocol_list): Search methods in
index 96a3998221a72f0080ffeeb4b273a0cf38e2a400..1f5e2b2f2e4be0f83e6561e01a55f2e7eb2a4928 100644 (file)
@@ -153,7 +153,7 @@ static void objc_start_function (tree, tree, tree, tree);
 #else
 static void objc_start_function (tree, tree, tree, struct c_arg_info *);
 #endif
-static tree start_protocol (enum tree_code, tree, tree);
+static tree start_protocol (enum tree_code, tree, tree, tree);
 static tree build_method_decl (enum tree_code, tree, tree, tree, bool);
 static tree objc_add_method (tree, tree, int, bool);
 static tree add_instance_variable (tree, objc_ivar_visibility_kind, tree);
@@ -234,9 +234,9 @@ enum string_section
 static tree add_objc_string (tree, enum string_section);
 static void build_selector_table_decl (void);
 
-/* Protocol additions.  */
+/* Protocols.  */
 
-static tree lookup_protocol (tree);
+static tree lookup_protocol (tree, bool);
 static tree lookup_and_install_protocols (tree);
 
 /* Type encoding.  */
@@ -767,17 +767,11 @@ objc_start_category_interface (tree klass, tree categ,
 void
 objc_start_protocol (tree name, tree protos, tree attributes)
 {
-  if (attributes)
-    {
-      if (flag_objc1_only)
-       error_at (input_location, "protocol attributes are not available in Objective-C 1.0");  
-      else
-       warning_at (input_location, OPT_Wattributes, 
-                   "protocol attributes are not available in this version"
-                   " of the compiler, (ignored)");
-    }
+  if (flag_objc1_only && attributes)
+    error_at (input_location, "protocol attributes are not available in Objective-C 1.0");     
+
   objc_interface_context
-    = start_protocol (PROTOCOL_INTERFACE_TYPE, name, protos);
+    = start_protocol (PROTOCOL_INTERFACE_TYPE, name, protos, attributes);
   objc_method_optional_flag = false;
 }
 
@@ -2866,7 +2860,7 @@ check_protocol_recursively (tree proto, tree list)
       tree pp = TREE_VALUE (p);
 
       if (TREE_CODE (pp) == IDENTIFIER_NODE)
-       pp = lookup_protocol (pp);
+       pp = lookup_protocol (pp, /* warn if deprecated */ false);
 
       if (pp == proto)
        fatal_error ("protocol %qE has circular dependency",
@@ -2876,8 +2870,9 @@ check_protocol_recursively (tree proto, tree list)
     }
 }
 
-/* Look up PROTOCOLS, and return a list of those that are found.
-   If none are found, return NULL.  */
+/* Look up PROTOCOLS, and return a list of those that are found.  If
+   none are found, return NULL.  Note that this function will emit a
+   warning if a protocol is found and is deprecated.  */
 
 static tree
 lookup_and_install_protocols (tree protocols)
@@ -2891,7 +2886,7 @@ lookup_and_install_protocols (tree protocols)
   for (proto = protocols; proto; proto = TREE_CHAIN (proto))
     {
       tree ident = TREE_VALUE (proto);
-      tree p = lookup_protocol (ident);
+      tree p = lookup_protocol (ident, /* warn_if_deprecated */ true);
 
       if (p)
        return_value = chainon (return_value,
@@ -8237,7 +8232,7 @@ tree
 objc_build_protocol_expr (tree protoname)
 {
   tree expr;
-  tree p = lookup_protocol (protoname);
+  tree p = lookup_protocol (protoname, /* warn if deprecated */ true);
 
   if (!p)
     {
@@ -10544,14 +10539,28 @@ add_protocol (tree protocol)
   return protocol_chain;
 }
 
+/* Looks up a protocol.  If 'warn_if_deprecated' is true, a warning is
+   emitted if the protocol is deprecated.  */
+
 static tree
-lookup_protocol (tree ident)
+lookup_protocol (tree ident, bool warn_if_deprecated)
 {
   tree chain;
 
   for (chain = protocol_chain; chain; chain = TREE_CHAIN (chain))
     if (ident == PROTOCOL_NAME (chain))
-      return chain;
+      {
+       if (warn_if_deprecated && TREE_DEPRECATED (chain))
+         {
+           /* It would be nice to use warn_deprecated_use() here, but
+              we are using TREE_CHAIN (which is supposed to be the
+              TYPE_STUB_DECL for a TYPE) for something different.  */
+           warning (OPT_Wdeprecated_declarations, "protocol %qE is deprecated", 
+                    PROTOCOL_NAME (chain));
+         }
+
+       return chain;
+      }
 
   return NULL_TREE;
 }
@@ -10560,9 +10569,10 @@ lookup_protocol (tree ident)
    they are already declared or defined, the function has no effect.  */
 
 void
-objc_declare_protocols (tree names)
+objc_declare_protocols (tree names, tree attributes)
 {
   tree list;
+  bool deprecated = false;
 
 #ifdef OBJCPLUS
   if (current_namespace != global_namespace) {
@@ -10570,11 +10580,25 @@ objc_declare_protocols (tree names)
   }
 #endif /* OBJCPLUS */
 
+  /* Determine if 'deprecated', the only attribute we recognize for
+     protocols, was used.  Ignore all other attributes.  */
+  if (attributes)
+    {
+      tree attribute;
+      for (attribute = attributes; attribute; attribute = TREE_CHAIN (attribute))
+       {
+         tree name = TREE_PURPOSE (attribute);
+         
+         if (is_attribute_p  ("deprecated", name))
+           deprecated = true;
+       }
+    }
+
   for (list = names; list; list = TREE_CHAIN (list))
     {
       tree name = TREE_VALUE (list);
 
-      if (lookup_protocol (name) == NULL_TREE)
+      if (lookup_protocol (name, /* warn if deprecated */ false) == NULL_TREE)
        {
          tree protocol = make_node (PROTOCOL_INTERFACE_TYPE);
 
@@ -10585,14 +10609,22 @@ objc_declare_protocols (tree names)
          add_protocol (protocol);
          PROTOCOL_DEFINED (protocol) = 0;
          PROTOCOL_FORWARD_DECL (protocol) = NULL_TREE;
+         
+         if (attributes)
+           {
+             TYPE_ATTRIBUTES (protocol) = attributes;
+             if (deprecated)
+               TREE_DEPRECATED (protocol) = 1;
+           }
        }
     }
 }
 
 static tree
-start_protocol (enum tree_code code, tree name, tree list)
+start_protocol (enum tree_code code, tree name, tree list, tree attributes)
 {
   tree protocol;
+  bool deprecated = false;
 
 #ifdef OBJCPLUS
   if (current_namespace != global_namespace) {
@@ -10600,7 +10632,21 @@ start_protocol (enum tree_code code, tree name, tree list)
   }
 #endif /* OBJCPLUS */
 
-  protocol = lookup_protocol (name);
+  /* Determine if 'deprecated', the only attribute we recognize for
+     protocols, was used.  Ignore all other attributes.  */
+  if (attributes)
+    {
+      tree attribute;
+      for (attribute = attributes; attribute; attribute = TREE_CHAIN (attribute))
+       {
+         tree name = TREE_PURPOSE (attribute);
+         
+         if (is_attribute_p  ("deprecated", name))
+           deprecated = true;
+       }
+    }
+
+  protocol = lookup_protocol (name, /* warn_if_deprecated */ false);
 
   if (!protocol)
     {
@@ -10627,6 +10673,14 @@ start_protocol (enum tree_code code, tree name, tree list)
       warning (0, "duplicate declaration for protocol %qE",
               name);
     }
+
+  if (attributes)
+    {
+      TYPE_ATTRIBUTES (protocol) = attributes;
+      if (deprecated)
+       TREE_DEPRECATED (protocol) = 1;
+    }
+
   return protocol;
 }
 
index 276b33f5ec3c4c93b45d975c11fda6f0aad39a95..f612e745d046dd0617c1296ff179826e09d05533 100644 (file)
@@ -166,11 +166,16 @@ typedef enum objc_property_assign_semantics {
 #define PROTOCOL_OPTIONAL_CLS_METHODS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 2)
 #define PROTOCOL_OPTIONAL_NST_METHODS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 3)
 
+
 /* For CATEGORY_INTERFACE_TYPE, CLASS_INTERFACE_TYPE or PROTOCOL_INTERFACE_TYPE */
 #define CLASS_PROPERTY_DECL(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 6)
 /* For CLASS_IMPLEMENTATION_TYPE or CATEGORY_IMPLEMENTATION_TYPE. */
 #define IMPL_PROPERTY_DECL(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 6)
 
+/* TREE_DEPRECATED is used for a CLASS_INTERFACE_TYPE or PROTOCOL_INTERFACE_TYPE.  */
+
+/* TYPE_ATTRIBUTES is used for a CLASS_INTERFACE_TYPE or PROTOCOL_INTERFACE_TYPE.  */
+
 /* ObjC-specific information pertaining to RECORD_TYPEs are stored in
    the LANG_SPECIFIC structures, which may itself need allocating first.  */
 
index f857e94047f50f85229bd51b030678cab94f2e85..2e5888491d8fe53d814d88fe2261f75667597ed9 100644 (file)
@@ -1,3 +1,12 @@
+2010-11-19  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc.dg/attributes/proto-attribute-1.m: Updated.
+       * objc.dg/attributes/proto-attribute-2.m: New.
+       * objc.dg/attributes/proto-attribute-3.m: New.
+       * obj-c++.dg/attributes/proto-attribute-1.mm: Updated.
+       * obj-c++.dg/attributes/proto-attribute-2.mm: New.
+       * obj-c++.dg/attributes/proto-attribute-3.mm: New.      
+
 2010-11-19  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.dg/lto/20090210_1.c: Do not pass -fPIC on the SPARC.
index c21caad3be6540ffc1aafcc67bc58db5f073aaa4..a852a7a6c2fd66dbdc2dc63428e39eeab4d50c40 100644 (file)
@@ -1,14 +1,13 @@
 /* { dg-do compile } */
 
 #include <objc/objc.h>
-#include "../../objc-obj-c++-shared/Object1.h"
 
 __attribute ((deprecated)) 
-@protocol dep_proto /* { dg-warning "protocol attributes are not available in this version" } */
-- (int) depprotomth; 
+@protocol dep_proto 
+- (int) depprotomth;
 @end
 
-@interface obj : Object <dep_proto>
+@interface obj <dep_proto> /* { dg-warning "is deprecated" } */
 { 
 @public 
   int var; 
@@ -20,10 +19,3 @@ __attribute ((deprecated))
 - (int) mth {  return var; } 
 - (int) depprotomth { return var + 1; }
 @end
-
-int foo (void)
-{
-    obj *p = [obj new];         
-    int q = [p depprotomth];
-    return [p mth];    
-}
diff --git a/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-2.mm b/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-2.mm
new file mode 100644 (file)
index 0000000..5b2eecb
--- /dev/null
@@ -0,0 +1,45 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
+/* { dg-do compile } */
+
+/* Test deprecate attribute with a forward declarations of
+   @protocol.  */
+
+#include <stdlib.h>
+#include <objc/objc.h>
+#include <objc/runtime.h>
+
+__attribute__ ((deprecated))
+@protocol DeprecatedProtocol1;
+
+@protocol NonDeprecatedProtocol1;
+
+
+@interface Class1 <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+@interface Class2 <NonDeprecatedProtocol1>
+@end
+
+@interface Class3 <NonDeprecatedProtocol1, DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+@interface Class2 (Category1) <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+void function1 (id <DeprecatedProtocol1> object); /* { dg-warning "is deprecated" } */
+void function2 (id <NonDeprecatedProtocol1> object);
+
+@class Class4;
+
+void function3 (Class4 <DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+void function4 (Class4 <NonDeprecatedProtocol1> *object);
+void function5 (Class4 <NonDeprecatedProtocol1, DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+
+int function6 (void)
+{
+  Protocol *p1 = @protocol (DeprecatedProtocol1); /* { dg-warning "is deprecated" } */
+  Protocol *p2 = @protocol (NonDeprecatedProtocol1);
+
+  return (p1 == p2);
+}
+
diff --git a/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm b/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-3.mm
new file mode 100644 (file)
index 0000000..f509bb7
--- /dev/null
@@ -0,0 +1,60 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
+/* { dg-do compile } */
+
+/* Test deprecate attribute with normal @protocol declarations.  */
+
+
+#include <stdlib.h>
+#include <objc/objc.h>
+#include <objc/runtime.h>
+
+__attribute__ ((deprecated))
+@protocol DeprecatedProtocol1
+- (void) aMethod;
+@end
+
+@protocol NonDeprecatedProtocol1
+- (void) anotherMethod;
+@end
+
+@protocol Protocol2 <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+- (void) someOtherMethod;
+@end
+
+@protocol Protocol3 <NonDeprecatedProtocol1>
+- (void) someOtherMethod2;
+@end
+
+@protocol Protocol4 <NonDeprecatedProtocol1, DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+- (void) someOtherMethod3;
+@end
+
+
+@interface Class1 <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+@interface Class2 <NonDeprecatedProtocol1>
+@end
+
+@interface Class3 <NonDeprecatedProtocol1, DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+@interface Class2 (Category1) <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+void function1 (id <DeprecatedProtocol1> object); /* { dg-warning "is deprecated" } */
+void function2 (id <NonDeprecatedProtocol1> object);
+
+@class Class4;
+
+void function3 (Class4 <DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+void function4 (Class4 <NonDeprecatedProtocol1> *object);
+void function5 (Class4 <NonDeprecatedProtocol1, DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+
+int function6 (void)
+{
+  Protocol *p1 = @protocol (DeprecatedProtocol1); /* { dg-warning "is deprecated" } */
+  Protocol *p2 = @protocol (NonDeprecatedProtocol1);
+
+  return (p1 == p2);
+}
index c9dc8786f76fbe888ada6745a063291a686225da..a852a7a6c2fd66dbdc2dc63428e39eeab4d50c40 100644 (file)
@@ -1,14 +1,13 @@
 /* { dg-do compile } */
 
 #include <objc/objc.h>
-#include "../../objc-obj-c++-shared/Object1.h"
 
 __attribute ((deprecated)) 
 @protocol dep_proto 
-- (int) depprotomth; /* { dg-warning "protocol attributes are not available in this version" } */
+- (int) depprotomth;
 @end
 
-@interface obj : Object <dep_proto>
+@interface obj <dep_proto> /* { dg-warning "is deprecated" } */
 { 
 @public 
   int var; 
@@ -20,10 +19,3 @@ __attribute ((deprecated))
 - (int) mth {  return var; } 
 - (int) depprotomth { return var + 1; }
 @end
-
-int foo (void)
-{
-    obj *p = [obj new];         
-    int q = [p depprotomth];
-    return [p mth];    
-}
diff --git a/gcc/testsuite/objc.dg/attributes/proto-attribute-2.m b/gcc/testsuite/objc.dg/attributes/proto-attribute-2.m
new file mode 100644 (file)
index 0000000..5b2eecb
--- /dev/null
@@ -0,0 +1,45 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
+/* { dg-do compile } */
+
+/* Test deprecate attribute with a forward declarations of
+   @protocol.  */
+
+#include <stdlib.h>
+#include <objc/objc.h>
+#include <objc/runtime.h>
+
+__attribute__ ((deprecated))
+@protocol DeprecatedProtocol1;
+
+@protocol NonDeprecatedProtocol1;
+
+
+@interface Class1 <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+@interface Class2 <NonDeprecatedProtocol1>
+@end
+
+@interface Class3 <NonDeprecatedProtocol1, DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+@interface Class2 (Category1) <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+void function1 (id <DeprecatedProtocol1> object); /* { dg-warning "is deprecated" } */
+void function2 (id <NonDeprecatedProtocol1> object);
+
+@class Class4;
+
+void function3 (Class4 <DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+void function4 (Class4 <NonDeprecatedProtocol1> *object);
+void function5 (Class4 <NonDeprecatedProtocol1, DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+
+int function6 (void)
+{
+  Protocol *p1 = @protocol (DeprecatedProtocol1); /* { dg-warning "is deprecated" } */
+  Protocol *p2 = @protocol (NonDeprecatedProtocol1);
+
+  return (p1 == p2);
+}
+
diff --git a/gcc/testsuite/objc.dg/attributes/proto-attribute-3.m b/gcc/testsuite/objc.dg/attributes/proto-attribute-3.m
new file mode 100644 (file)
index 0000000..f509bb7
--- /dev/null
@@ -0,0 +1,60 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
+/* { dg-do compile } */
+
+/* Test deprecate attribute with normal @protocol declarations.  */
+
+
+#include <stdlib.h>
+#include <objc/objc.h>
+#include <objc/runtime.h>
+
+__attribute__ ((deprecated))
+@protocol DeprecatedProtocol1
+- (void) aMethod;
+@end
+
+@protocol NonDeprecatedProtocol1
+- (void) anotherMethod;
+@end
+
+@protocol Protocol2 <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+- (void) someOtherMethod;
+@end
+
+@protocol Protocol3 <NonDeprecatedProtocol1>
+- (void) someOtherMethod2;
+@end
+
+@protocol Protocol4 <NonDeprecatedProtocol1, DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+- (void) someOtherMethod3;
+@end
+
+
+@interface Class1 <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+@interface Class2 <NonDeprecatedProtocol1>
+@end
+
+@interface Class3 <NonDeprecatedProtocol1, DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+@interface Class2 (Category1) <DeprecatedProtocol1> /* { dg-warning "is deprecated" } */
+@end
+
+void function1 (id <DeprecatedProtocol1> object); /* { dg-warning "is deprecated" } */
+void function2 (id <NonDeprecatedProtocol1> object);
+
+@class Class4;
+
+void function3 (Class4 <DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+void function4 (Class4 <NonDeprecatedProtocol1> *object);
+void function5 (Class4 <NonDeprecatedProtocol1, DeprecatedProtocol1> *object); /* { dg-warning "is deprecated" } */
+
+int function6 (void)
+{
+  Protocol *p1 = @protocol (DeprecatedProtocol1); /* { dg-warning "is deprecated" } */
+  Protocol *p2 = @protocol (NonDeprecatedProtocol1);
+
+  return (p1 == p2);
+}