This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix const-str-[34].m on darwin


This patch fixes those regressions by making a CONST_DECL for holding
the constructor and then taking the address of that.  While I was at
it, I removed the setting of TREE_CONSTANT, TREE_INVARIANT, and
TREE_STATIC on the address expression.  I needed to modified staticp
so that a CONST_DECL could be considered for static storage without
that patch we get a regression in const-str-5.m.

OK? Bootstrapped and tested on powerpc-apple-darwin.

Thanks,
Andrew Pinski

ChangeLog:

	* tree.c (staticp): A CONST_DECL has static storage if either
	TREE_STATIC or DECL_EXTERNAL is set.
objc/ChangeLog:
	* objc-act.c (objc_build_string_object): Create a CONST_DECL
	for the NeXT runtime case.

Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.437
diff -u -p -r1.437 tree.c
--- tree.c	29 Sep 2004 13:07:44 -0000	1.437
+++ tree.c	4 Oct 2004 18:41:00 -0000
@@ -1489,6 +1489,10 @@ staticp (tree arg)
 	      && ! DECL_NON_ADDR_CONST_P (arg)
 	      ? arg : NULL);

+    case CONST_DECL:
+      return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
+	      ? arg : NULL);
+
     case CONSTRUCTOR:
       return TREE_STATIC (arg) ? arg : NULL;

Index: objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.249
diff -u -p -r1.249 objc-act.c
--- objc/objc-act.c	2 Oct 2004 15:56:06 -0000	1.249
+++ objc/objc-act.c	4 Oct 2004 18:41:01 -0000
@@ -1661,6 +1661,7 @@ objc_build_string_object (tree string)

   if (!desc)
     {
+      tree var;
       *loc = desc = ggc_alloc (sizeof (*desc));
       desc->literal = string;

@@ -1685,14 +1686,19 @@ objc_build_string_object (tree string)
       if (!flag_next_runtime)
 	constructor
 	  = objc_add_static_instance (constructor, constant_string_type);
-
+      else
+        {
+	  var = build_decl (CONST_DECL, NULL, TREE_TYPE (constructor));
+	  DECL_INITIAL (var) = constructor;
+	  if (global_bindings_p ())
+	    TREE_STATIC (var) = 1;
+	  pushdecl (var);
+	  constructor = var;
+	}
       desc->constructor = constructor;
     }

   addr = build_unary_op (ADDR_EXPR, desc->constructor, 1);
-  TREE_CONSTANT (addr) = true;
-  TREE_INVARIANT (addr) = true;
-  TREE_STATIC (addr) = true;

   return addr;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]