Removed conflict in usage of TYPE_LANG_SLOT_0 between Objective-C and C
authorNicola Pero <nicola.pero@meta-innovation.com>
Wed, 23 Feb 2011 10:57:59 +0000 (10:57 +0000)
committerNicola Pero <nicola@gcc.gnu.org>
Wed, 23 Feb 2011 10:57:59 +0000 (10:57 +0000)
From-SVN: r170436

gcc/objc/ChangeLog
gcc/objc/objc-act.c
gcc/objc/objc-act.h
gcc/testsuite/ChangeLog
gcc/testsuite/objc.dg/attributes/objc-exception-1.m [new file with mode: 0644]

index 9c466aa8771e7aab45739a785d0659cd65ddfc15..e5cff3f58aba20ddeea97057ea765f9370545c00 100644 (file)
@@ -1,3 +1,10 @@
+2011-02-23  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc-act.c (build_private_template): Do not copy the
+       CLASS_HAS_EXCEPTION_ATTR from the class to the struct.
+       * objc-act.h (CLASS_HAS_EXCEPTION_ATTR): Define using
+       TYPE_LANG_SLOT_0.
+
 2011-02-22  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        PR objc/47832
index 85ef8fb0526d55edcfc13c7bb71a06de6802c386..049dc00dba1fe9a7f61a8f934438d66e807806f6 100644 (file)
@@ -4203,9 +4203,6 @@ build_private_template (tree klass)
       /* Copy the attributes from the class to the type.  */
       if (TREE_DEPRECATED (klass))
        TREE_DEPRECATED (record) = 1;
-
-      if (CLASS_HAS_EXCEPTION_ATTR (klass))
-       CLASS_HAS_EXCEPTION_ATTR (record) = 1;
     }
 }
 
index 54f067fac076c2c1b7fbcf97f5063854cfb87fa2..3983d4b1adc9021bb35b94933707a9bbe5cf7d72 100644 (file)
@@ -164,9 +164,7 @@ typedef enum objc_property_assign_semantics {
 #define CLASS_CATEGORY_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 3)
 #define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 4)
 #define TOTAL_CLASS_RAW_IVARS(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 5)
-
-/* FIXME */
-#define CLASS_HAS_EXCEPTION_ATTR(CLASS) ((CLASS)->type.lang_flag_0)
+#define CLASS_HAS_EXCEPTION_ATTR(CLASS) (TYPE_LANG_FLAG_0 (CLASS))
 
 #define PROTOCOL_NAME(CLASS) ((CLASS)->type.name)
 #define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_LANG_SLOT_1 (CLASS), 0)
index 60e924bcf3986781b463f3b7036659b0fd444322..a89c08d916114457e4deb92574494013ae959136 100644 (file)
@@ -1,3 +1,7 @@
+2011-02-23  Nicola Pero  <nicola.pero@meta-innovation.com>
+
+       * objc.dg/attributes/objc-exception-1.m: New.
+
 2011-02-23  Jie Zhang  <jie@codesourcery.com>
 
        * gcc.dg/cpp/include7.c: New test.
diff --git a/gcc/testsuite/objc.dg/attributes/objc-exception-1.m b/gcc/testsuite/objc.dg/attributes/objc-exception-1.m
new file mode 100644 (file)
index 0000000..e7f6f85
--- /dev/null
@@ -0,0 +1,32 @@
+/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, February 2011.  */
+/* { dg-do compile } */
+
+/* Test that the 'objc_exception' attribute is accepted for
+   @interfaces, but not for anything else.  */
+
+#include <objc/objc.h>
+
+/* Fine.  */
+__attribute__ ((objc_exception))
+@interface MyClass
+{
+  Class isa;
+}
+@end
+
+/* Fine.  */
+__attribute__ ((__objc_exception__))
+@interface MyClass2
+{
+  Class isa;
+}
+@end
+
+__attribute__ ((objc_exception))
+@protocol MyProtocol; /* { dg-warning "ignored" } */
+
+__attribute__ ((objc_exception))
+int myVariable; /* { dg-warning "ignored" } */
+
+__attribute__ ((objc_exception))
+int myFunction (int argument); /* { dg-warning "ignored" } */