In gcc/objc/: 2010-12-30 Nicola Pero <nicola@nicola.brainstorm.co.uk>
authorNicola Pero <nicola@gcc.gnu.org>
Thu, 30 Dec 2010 08:59:29 +0000 (08:59 +0000)
committerNicola Pero <nicola@gcc.gnu.org>
Thu, 30 Dec 2010 08:59:29 +0000 (08:59 +0000)
In gcc/objc/:
2010-12-30  Nicola Pero  <nicola@nicola.brainstorm.co.uk>

* objc-act.c (start_class): Warn when a class attribute is
ignored.
(objc_declare_protocols): Warn when a protocol attribute in a
protocol forward-declaration is ignored.
(start_protocol): Warn when a protocol attribute is ignored.

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

* objc.dg/attributes/class-attribute-3.m: New.
* objc.dg/attributes/proto-attribute-4.m: New.
* obj-c++.dg/attributes/class-attribute-3.mm: New.
* obj-c++.dg/attributes/proto-attribute-4.mm: New.

From-SVN: r168337

gcc/objc/ChangeLog
gcc/objc/objc-act.c
gcc/testsuite/ChangeLog
gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm [new file with mode: 0644]
gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm [new file with mode: 0644]
gcc/testsuite/objc.dg/attributes/class-attribute-3.m [new file with mode: 0644]
gcc/testsuite/objc.dg/attributes/proto-attribute-4.m [new file with mode: 0644]

index 562081b98763a7164945a4e757733d140827f56a..b717a946d0511a4f51d34fa2846e32a575aa13ef 100644 (file)
@@ -1,3 +1,11 @@
+2010-12-30  Nicola Pero  <nicola@nicola.brainstorm.co.uk>
+
+       * objc-act.c (start_class): Warn when a class attribute is
+       ignored.
+       (objc_declare_protocols): Warn when a protocol attribute in a
+       protocol forward-declaration is ignored.
+       (start_protocol): Warn when a protocol attribute is ignored.
+
 2010-12-30  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * objc-act.c (objc_set_method_opt): Tidy up error messages.  In
index bc959d6060bb73dfc6b2d6dc16595f3a3f87d3cd..a0a7a095eb424c6ba74dfa0c7907da8f366bd6e3 100644 (file)
@@ -9722,6 +9722,8 @@ start_class (enum tree_code code, tree class_name, tree super_name,
              
              if (is_attribute_p  ("deprecated", name))
                TREE_DEPRECATED (klass) = 1;
+             else
+               warning (OPT_Wattributes, "%qE attribute directive ignored", name);
            }
          TYPE_ATTRIBUTES (klass) = attributes;
        }
@@ -10924,6 +10926,8 @@ objc_declare_protocols (tree names, tree attributes)
          
          if (is_attribute_p  ("deprecated", name))
            deprecated = true;
+         else
+           warning (OPT_Wattributes, "%qE attribute directive ignored", name);
        }
     }
 
@@ -10977,6 +10981,8 @@ start_protocol (enum tree_code code, tree name, tree list, tree attributes)
          
          if (is_attribute_p  ("deprecated", name))
            deprecated = true;
+         else
+           warning (OPT_Wattributes, "%qE attribute directive ignored", name);
        }
     }
 
index 43b5afb6c3984437460522d216ac1675dd82c159..7dd36f1b9b05ff7428d17e1eeecaf73dbd6b5de1 100644 (file)
@@ -1,3 +1,10 @@
+2010-12-30  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc.dg/attributes/class-attribute-3.m: New.
+       * objc.dg/attributes/proto-attribute-4.m: New.
+       * obj-c++.dg/attributes/class-attribute-3.mm: New.
+       * obj-c++.dg/attributes/proto-attribute-4.mm: New.      
+       
 2010-12-30  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/47060
diff --git a/gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm b/gcc/testsuite/obj-c++.dg/attributes/class-attribute-3.mm
new file mode 100644 (file)
index 0000000..f96500d
--- /dev/null
@@ -0,0 +1,14 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
+/* { dg-do compile } */
+
+/* Test that you get a warning when an unknown class attribute is ignored.  */
+
+#include <objc/objc.h>
+
+__attribute__ ((unknown_attribute))
+@interface MyClass /* { dg-warning "ignored" } */
+{
+  Class isa;
+}
++ (id) new;
+@end
diff --git a/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm b/gcc/testsuite/obj-c++.dg/attributes/proto-attribute-4.mm
new file mode 100644 (file)
index 0000000..d2e5f28
--- /dev/null
@@ -0,0 +1,31 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
+/* { dg-do compile } */
+
+/* Test that you get a warning when an unknown protocol attribute is ignored.  */
+
+#include <objc/objc.h>
+
+__attribute__ ((unknown_attribute))
+@protocol MyProtocol /* { dg-warning "ignored" } */
+- (id) new;
+@end
+
+__attribute__ ((unknown_attribute))
+@protocol MyProtocol2; /* { dg-warning "ignored" } */
+
+/* Use the protocols to double-check that no more warnings are
+   generated.  */
+
+@interface MyClass <MyProtocol>
+@end
+
+int test (id <MyProtocol2> x)
+{
+  if (@protocol (MyProtocol) == @protocol (MyProtocol2))
+    return 1;
+
+  if (x)
+    return 2;
+
+  return 3;
+}
diff --git a/gcc/testsuite/objc.dg/attributes/class-attribute-3.m b/gcc/testsuite/objc.dg/attributes/class-attribute-3.m
new file mode 100644 (file)
index 0000000..6cc5d4e
--- /dev/null
@@ -0,0 +1,14 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
+/* { dg-do compile } */
+
+/* Test that you get a warning when an unknown class attribute is ignored.  */
+
+#include <objc/objc.h>
+
+__attribute__ ((unknown_attribute))
+@interface MyClass
+{ /* { dg-warning "ignored" } */
+  Class isa;
+}
++ (id) new;
+@end
diff --git a/gcc/testsuite/objc.dg/attributes/proto-attribute-4.m b/gcc/testsuite/objc.dg/attributes/proto-attribute-4.m
new file mode 100644 (file)
index 0000000..226fd68
--- /dev/null
@@ -0,0 +1,31 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
+/* { dg-do compile } */
+
+/* Test that you get a warning when an unknown protocol attribute is ignored.  */
+
+#include <objc/objc.h>
+
+__attribute__ ((unknown_attribute))
+@protocol MyProtocol
+- (id) new; /* { dg-warning "ignored" } */
+@end
+
+__attribute__ ((unknown_attribute))
+@protocol MyProtocol2; /* { dg-warning "ignored" } */
+
+/* Use the protocols to double-check that no more warnings are
+   generated.  */
+
+@interface MyClass <MyProtocol>
+@end
+
+int test (id <MyProtocol2> x)
+{
+  if (@protocol (MyProtocol) == @protocol (MyProtocol2))
+    return 1;
+
+  if (x)
+    return 2;
+
+  return 3;
+}