This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Objective-C PATCH: Make synthetic decls and defns match
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Stan Shebs <shebs at apple dot com>, Ovidiu Predescu <ovidiu at cup dot hp dot com>
- Date: Fri, 27 Jun 2003 17:51:40 -0700
- Subject: Objective-C PATCH: Make synthetic decls and defns match
My patch that detects 'static' mismatches between declarations and
definitions, found a whole bunch of places where the Objective C front
end generates a synthetic declaration marked extern, then later a
synthetic definition of that symbol marked static. This patch
attempts to correct all of these places. I am not checking this in yet,
because it's not obvious to me that I corrected them all the right
way, nor is it clear that I got them all. Could Objective C people
please give some feedback on this patch?
zw
* objc/objc-act.c (build_selector_reference_decl)
(build_class_reference_decl, build_objc_string_decl)
(synth_forward_declarations, build_protocol_reference):
Set TREE_PUBLIC on synthesized declaration to 0, not 1.
===================================================================
Index: objc/objc-act.c
--- objc/objc-act.c 27 Jun 2003 09:05:45 -0000 1.178
+++ objc/objc-act.c 28 Jun 2003 00:06:18 -0000
@@ -1991,7 +1991,7 @@ build_selector_reference_decl ()
decl = build_decl (VAR_DECL, ident, selector_type);
DECL_EXTERNAL (decl) = 1;
- TREE_PUBLIC (decl) = 1;
+ TREE_PUBLIC (decl) = 0;
TREE_USED (decl) = 1;
TREE_READONLY (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
@@ -2206,7 +2206,7 @@ build_class_reference_decl ()
decl = build_decl (VAR_DECL, ident, objc_class_type);
DECL_EXTERNAL (decl) = 1;
- TREE_PUBLIC (decl) = 1;
+ TREE_PUBLIC (decl) = 0;
TREE_USED (decl) = 1;
TREE_READONLY (decl) = 1;
DECL_CONTEXT (decl) = 0;
@@ -2343,7 +2343,7 @@ build_objc_string_decl (section)
decl = build_decl (VAR_DECL, ident, build_array_type (char_type_node, 0));
DECL_EXTERNAL (decl) = 1;
- TREE_PUBLIC (decl) = 1;
+ TREE_PUBLIC (decl) = 0;
TREE_USED (decl) = 1;
TREE_READONLY (decl) = 1;
TREE_CONSTANT (decl) = 1;
@@ -3476,7 +3476,7 @@ synth_forward_declarations ()
{
tree sc_spec, decl_specs, an_id;
- /* extern struct objc_class _OBJC_CLASS_<my_name>; */
+ /* static struct objc_class _OBJC_CLASS_<my_name>; */
an_id = synth_id_with_class_suffix ("_OBJC_CLASS", objc_implementation_context);
@@ -3485,8 +3485,9 @@ synth_forward_declarations ()
UOBJC_CLASS_decl = define_decl (an_id, decl_specs);
TREE_USED (UOBJC_CLASS_decl) = 1;
DECL_ARTIFICIAL (UOBJC_CLASS_decl) = 1;
+ TREE_PUBLIC (UOBJC_CLASS_decl) = 0;
- /* extern struct objc_class _OBJC_METACLASS_<my_name>; */
+ /* static struct objc_class _OBJC_METACLASS_<my_name>; */
an_id = synth_id_with_class_suffix ("_OBJC_METACLASS",
objc_implementation_context);
@@ -3494,6 +3495,7 @@ synth_forward_declarations ()
UOBJC_METACLASS_decl = define_decl (an_id, decl_specs);
TREE_USED (UOBJC_METACLASS_decl) = 1;
DECL_ARTIFICIAL(UOBJC_METACLASS_decl) = 1;
+ TREE_PUBLIC (UOBJC_METACLASS_decl) = 0;
/* Pre-build the following entities - for speed/convenience. */
@@ -5242,7 +5244,7 @@ build_protocol_reference (p)
{
tree decl, ident, ptype;
- /* extern struct objc_protocol _OBJC_PROTOCOL_<mumble>; */
+ /* static struct objc_protocol _OBJC_PROTOCOL_<mumble>; */
ident = synth_id_with_class_suffix ("_OBJC_PROTOCOL", p);
ptype
@@ -5256,7 +5258,7 @@ build_protocol_reference (p)
{
decl = build_decl (VAR_DECL, ident, ptype);
DECL_EXTERNAL (decl) = 1;
- TREE_PUBLIC (decl) = 1;
+ TREE_PUBLIC (decl) = 0;
TREE_USED (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;