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]

Fix for instantiate12.C problem on 3.3 branch on Darwin


The attached patch fixes the problem that the regression tester's been
complaining about on the 3.3 branch.  It is (so far as I know) the
only regression from 3.3 on the branch on Darwin.

Bootstrapped & tested on powerpc-darwin.  I'll be committing this to
the 3.3 branch, and a similar but not-the-same version to HEAD once
I've double-checked it there.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-darwinselectsection.patch=============
2003-07-15  Geoffrey Keating  <geoffk@apple.com>

	* config/darwin.c (machopic_select_section): Use decl_readonly_section
	to do most of the work.

Index: config/darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.c,v
retrieving revision 1.30
diff -u -p -u -p -r1.30 darwin.c
--- config/darwin.c	29 Sep 2002 13:16:44 -0000	1.30
+++ config/darwin.c	16 Jul 2003 04:11:10 -0000
@@ -1091,18 +1091,21 @@ machopic_select_section (exp, reloc, ali
      int reloc;
      unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED;
 {
-  if (TREE_CODE (exp) == STRING_CST)
-    {
-      if (flag_writable_strings)
-	data_section ();
-      else if (TREE_STRING_LENGTH (exp) !=
-	       strlen (TREE_STRING_POINTER (exp)) + 1)
-	readonly_data_section ();
-      else
-	cstring_section ();
-    }
-  else if (TREE_CODE (exp) == INTEGER_CST
-	   || TREE_CODE (exp) == REAL_CST)
+  void (*base_function)(void);
+  
+  if (decl_readonly_section (exp, reloc))
+    base_function = readonly_data_section;
+  else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))
+    base_function = const_data_section;
+  else
+    base_function = data_section;
+
+  if (TREE_CODE (exp) == STRING_CST
+      && TREE_STRING_LENGTH (exp) == strlen (TREE_STRING_POINTER (exp)) + 1
+      && ! flag_writable_strings)
+    cstring_section ();
+  else if ((TREE_CODE (exp) == INTEGER_CST || TREE_CODE (exp) == REAL_CST)
+	   && flag_merge_constants)
     {
       tree size = TYPE_SIZE (TREE_TYPE (exp));
 
@@ -1115,7 +1118,7 @@ machopic_select_section (exp, reloc, ali
 	       TREE_INT_CST_HIGH (size) == 0)
 	literal8_section ();
       else
-	readonly_data_section ();
+	base_function ();
     }
   else if (TREE_CODE (exp) == CONSTRUCTOR
 	   && TREE_TYPE (exp)
@@ -1129,15 +1132,8 @@ machopic_select_section (exp, reloc, ali
 	objc_constant_string_object_section ();
       else if (!strcmp (IDENTIFIER_POINTER (name), "NXConstantString"))
 	objc_string_object_section ();
-      else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))
-	{
-	  if (TREE_SIDE_EFFECTS (exp) || (flag_pic && reloc))
-	    const_data_section ();
-	  else
-	    readonly_data_section ();
-	}
-      else
-	data_section ();
+      else 
+	base_function ();
     }
   else if (TREE_CODE (exp) == VAR_DECL &&
 	   DECL_NAME (exp) &&
@@ -1191,26 +1187,11 @@ machopic_select_section (exp, reloc, ali
 	objc_cat_cls_meth_section ();
       else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))
 	objc_protocol_section ();
-      else if ((TREE_READONLY (exp) || TREE_CONSTANT (exp))
-	       && !TREE_SIDE_EFFECTS (exp))
-	{
-	  if (flag_pic && reloc)
-	    const_data_section ();
-	  else
-	    readonly_data_section ();
-	}
-      else
-	data_section ();
-    }
-  else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))
-    {
-      if (TREE_SIDE_EFFECTS (exp) || (flag_pic && reloc))
-	const_data_section ();
-      else
-	readonly_data_section ();
+      else 
+	base_function ();
     }
-  else
-    data_section ();
+  else 
+    base_function ();
 }
 
 /* This can be called with address expressions as "rtx".
============================================================


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