aboutsummaryrefslogtreecommitdiff
path: root/gcc/objc
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-11-19 22:23:22 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-11-19 22:23:22 +0000
commitd4e72c58e36abe902834d122b291a91debd5625c (patch)
tree61b8716b8764294b3d8406542d9a1218c831fe48 /gcc/objc
parent39986460d63899e1e4a1a9ee976c9c21c338f643 (diff)
downloadgcc-d4e72c58e36abe902834d122b291a91debd5625c.zip
gcc-d4e72c58e36abe902834d122b291a91debd5625c.tar.gz
gcc-d4e72c58e36abe902834d122b291a91debd5625c.tar.bz2
In gcc/objc/: 2010-11-19 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/objc/: 2010-11-19 Nicola Pero <nicola.pero@meta-innovation.com> * objc-act.c (objc_start_class_interface): Do not warn that class attributes are unimplemented. Pass the attributes to start_class. (objc_start_category_interface): Updated call to start_class. (objc_start_class_implementation): Same change. (objc_start_category_implementation): Same change. (objc_build_class_component_ref): Warn if the class is deprecated. (build_private_template): Mark the template as deprecated if the class is deprecated. (start_class): Added 'attributes' argument. Emit a warning if using a deprecated class as superclass of a class, or original class of a category. Recognize the 'deprecated' attribute when starting and interface, and mark the interface with TREE_DEPRECATED if present. Store attributes in the interface. In gcc/testsuite/: 2010-11-19 Nicola Pero <nicola.pero@meta-innovation.com> * objc.dg/attributes/class-attribute-1.m: Rewritten. * objc.dg/attributes/class-attribute-2.m: Same change. * obj-c++.dg/attributes/class-attribute-1.mm: Same change. * obj-c++.dg/attributes/class-attribute-2.mm: Same change. * objc.dg/fobjc-std-1.m: Updated. * obj-c++.dg/fobjc-std-1.mm: Updated. From-SVN: r166963
Diffstat (limited to 'gcc/objc')
-rw-r--r--gcc/objc/ChangeLog16
-rw-r--r--gcc/objc/objc-act.c74
2 files changed, 70 insertions, 20 deletions
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index a128604..a5ad136 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,5 +1,21 @@
2010-11-19 Nicola Pero <nicola.pero@meta-innovation.com>
+ * objc-act.c (objc_start_class_interface): Do not warn that class
+ attributes are unimplemented. Pass the attributes to start_class.
+ (objc_start_category_interface): Updated call to start_class.
+ (objc_start_class_implementation): Same change.
+ (objc_start_category_implementation): Same change.
+ (objc_build_class_component_ref): Warn if the class is deprecated.
+ (build_private_template): Mark the template as deprecated if the
+ class is deprecated.
+ (start_class): Added 'attributes' argument. Emit a warning if
+ using a deprecated class as superclass of a class, or original
+ class of a category. Recognize the 'deprecated' attribute when
+ starting and interface, and mark the interface with
+ TREE_DEPRECATED if present. Store attributes in the interface.
+
+2010-11-19 Nicola Pero <nicola.pero@meta-innovation.com>
+
* objc-act.c (lookup_protocol): Added 'warn_if_deprecated'
argument. If it is 'true' and the protocol is deprecated, emit a
deprecation warning.
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 1f5e2b2..3a87faf 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -144,7 +144,7 @@ static tree get_proto_encoding (tree);
static tree lookup_interface (tree);
static tree objc_add_static_instance (tree, tree);
-static tree start_class (enum tree_code, tree, tree, tree);
+static tree start_class (enum tree_code, tree, tree, tree, tree);
static tree continue_class (tree);
static void finish_class (tree);
static void start_method_def (tree);
@@ -730,18 +730,12 @@ void
objc_start_class_interface (tree klass, tree super_class,
tree protos, tree attributes)
{
- if (attributes)
- {
- if (flag_objc1_only)
- error_at (input_location, "class attributes are not available in Objective-C 1.0");
- else
- warning_at (input_location, OPT_Wattributes,
- "class attributes are not available in this version"
- " of the compiler, (ignored)");
- }
+ if (flag_objc1_only && attributes)
+ error_at (input_location, "class attributes are not available in Objective-C 1.0");
+
objc_interface_context
= objc_ivar_context
- = start_class (CLASS_INTERFACE_TYPE, klass, super_class, protos);
+ = start_class (CLASS_INTERFACE_TYPE, klass, super_class, protos, attributes);
objc_ivar_visibility = OBJC_IVAR_VIS_PROTECTED;
}
@@ -759,7 +753,7 @@ objc_start_category_interface (tree klass, tree categ,
" of the compiler, (ignored)");
}
objc_interface_context
- = start_class (CATEGORY_INTERFACE_TYPE, klass, categ, protos);
+ = start_class (CATEGORY_INTERFACE_TYPE, klass, categ, protos, NULL_TREE);
objc_ivar_chain
= continue_class (objc_interface_context);
}
@@ -795,7 +789,8 @@ objc_start_class_implementation (tree klass, tree super_class)
{
objc_implementation_context
= objc_ivar_context
- = start_class (CLASS_IMPLEMENTATION_TYPE, klass, super_class, NULL_TREE);
+ = start_class (CLASS_IMPLEMENTATION_TYPE, klass, super_class, NULL_TREE,
+ NULL_TREE);
objc_ivar_visibility = OBJC_IVAR_VIS_PROTECTED;
}
@@ -803,7 +798,8 @@ void
objc_start_category_implementation (tree klass, tree categ)
{
objc_implementation_context
- = start_class (CATEGORY_IMPLEMENTATION_TYPE, klass, categ, NULL_TREE);
+ = start_class (CATEGORY_IMPLEMENTATION_TYPE, klass, categ, NULL_TREE,
+ NULL_TREE);
objc_ivar_chain
= continue_class (objc_implementation_context);
}
@@ -1708,6 +1704,11 @@ objc_build_class_component_ref (tree class_name, tree property_ident)
error_at (input_location, "could not find interface for class %qE", class_name);
return error_mark_node;
}
+ else
+ {
+ if (TREE_DEPRECATED (rtype))
+ warning (OPT_Wdeprecated_declarations, "class %qE is deprecated", class_name);
+ }
x = maybe_make_artificial_property_decl (rtype, NULL_TREE, NULL_TREE,
property_ident,
@@ -4227,7 +4228,6 @@ add_class_reference (tree ident)
/* Get a class reference, creating it if necessary. Also create the
reference variable. */
-
tree
objc_get_class_reference (tree ident)
{
@@ -5623,6 +5623,10 @@ build_private_template (tree klass)
can emit stabs for this struct type. */
if (flag_debug_only_used_symbols && TYPE_STUB_DECL (record))
TREE_USED (TYPE_STUB_DECL (record)) = 1;
+
+ /* Copy the attributes from the class to the type. */
+ if (TREE_DEPRECATED (klass))
+ TREE_DEPRECATED (record) = 1;
}
}
@@ -9316,7 +9320,7 @@ check_protocols (tree proto_list, const char *type, tree name)
static tree
start_class (enum tree_code code, tree class_name, tree super_name,
- tree protocol_list)
+ tree protocol_list, tree attributes)
{
tree klass, decl;
@@ -9344,8 +9348,12 @@ start_class (enum tree_code code, tree class_name, tree super_name,
&& super_name)
{
tree super = objc_is_class_name (super_name);
+ tree super_interface = NULL_TREE;
- if (!super || !lookup_interface (super))
+ if (super)
+ super_interface = lookup_interface (super);
+
+ if (!super_interface)
{
error ("cannot find interface declaration for %qE, superclass of %qE",
super ? super : super_name,
@@ -9353,7 +9361,12 @@ start_class (enum tree_code code, tree class_name, tree super_name,
super_name = NULL_TREE;
}
else
- super_name = super;
+ {
+ if (TREE_DEPRECATED (super_interface))
+ warning (OPT_Wdeprecated_declarations, "class %qE is deprecated",
+ super);
+ super_name = super;
+ }
}
CLASS_NAME (klass) = class_name;
@@ -9436,6 +9449,22 @@ start_class (enum tree_code code, tree class_name, tree super_name,
if (protocol_list)
CLASS_PROTOCOL_LIST (klass)
= lookup_and_install_protocols (protocol_list);
+
+ /* Determine if 'deprecated', the only attribute we recognize
+ for classes, was used. Ignore all other attributes for now,
+ but store them in the klass. */
+ if (attributes)
+ {
+ tree attribute;
+ for (attribute = attributes; attribute; attribute = TREE_CHAIN (attribute))
+ {
+ tree name = TREE_PURPOSE (attribute);
+
+ if (is_attribute_p ("deprecated", name))
+ TREE_DEPRECATED (klass) = 1;
+ }
+ TYPE_ATTRIBUTES (klass) = attributes;
+ }
break;
case CATEGORY_INTERFACE_TYPE:
@@ -9452,8 +9481,13 @@ start_class (enum tree_code code, tree class_name, tree super_name,
exit (FATAL_EXIT_CODE);
}
else
- add_category (class_category_is_assoc_with, klass);
-
+ {
+ if (TREE_DEPRECATED (class_category_is_assoc_with))
+ warning (OPT_Wdeprecated_declarations, "class %qE is deprecated",
+ class_name);
+ add_category (class_category_is_assoc_with, klass);
+ }
+
if (protocol_list)
CLASS_PROTOCOL_LIST (klass)
= lookup_and_install_protocols (protocol_list);