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: middle-end/17982: [4.0 regression] asm declaration ignored due to conflict with previous rename


Checking DECL_ASSEMBLER_NAME_SET_P isn't sufficient for rename.
Simply calling DECL_ASSEMBLER_NAME will make DECL_ASSEMBLER_NAME_SET_P
to return TRUE. This patch tries to determine if the assembler name is
the same as the default one before issing a warning.


H.J.
----
2004-11-23  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/17982
	* c-pragma.c (maybe_apply_renaming_pragma): Allow
	DECL_ASSEMBLER_NAME to be modified if it is the same as the
	default one.

--- gcc/c-pragma.c.17982	2004-11-23 16:39:54.831510454 -0800
+++ gcc/c-pragma.c	2004-11-23 17:58:14.391939544 -0800
@@ -476,26 +476,49 @@ maybe_apply_renaming_pragma (tree decl, 
      but we may warn about a rename that conflicts.  */
   if (DECL_ASSEMBLER_NAME_SET_P (decl))
     {
-      const char *oldname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-      oldname = targetm.strip_name_encoding (oldname);
+      tree saved, def;
+      const char *saved_name, *def_name;
 
-      if (asmname && strcmp (TREE_STRING_POINTER (asmname), oldname))
-	  warning ("asm declaration ignored due to "
-		   "conflict with previous rename");
-
-      /* Take any pending redefine_extname off the list.  */
-      for (p = &pending_redefine_extname; (t = *p); p = &TREE_CHAIN (t))
-	if (DECL_NAME (decl) == TREE_PURPOSE (t))
-	  {
-	    /* Only warn if there is a conflict.  */
-	    if (strcmp (IDENTIFIER_POINTER (TREE_VALUE (t)), oldname))
-	      warning ("#pragma redefine_extname ignored due to "
-		       "conflict with previous rename");
-
-	    *p = TREE_CHAIN (t);
-	    break;
-	  }
-      return 0;
+      /* We allow DECL_ASSEMBLER_NAME to be modified if it is the same
+	 as the default one.  */
+      saved = DECL_ASSEMBLER_NAME (decl);
+      SET_DECL_ASSEMBLER_NAME (decl, NULL);
+      def = DECL_ASSEMBLER_NAME (decl);
+      SET_DECL_ASSEMBLER_NAME (decl, saved);
+      if (def != saved)
+	{
+	  saved_name = IDENTIFIER_POINTER (saved);
+	  def_name = IDENTIFIER_POINTER (def);
+	}
+      else
+	{
+	  saved_name = NULL;
+	  def_name = NULL;
+	}
+
+      if (saved_name != def_name && strcmp (saved_name, def_name))
+	{
+	  const char *oldname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+	  oldname = targetm.strip_name_encoding (oldname);
+
+	  if (asmname && strcmp (TREE_STRING_POINTER (asmname), oldname))
+	    warning ("asm declaration ignored due to "
+		     "conflict with previous rename");
+
+	  /* Take any pending redefine_extname off the list.  */
+	  for (p = &pending_redefine_extname; (t = *p); p = &TREE_CHAIN (t))
+	    if (DECL_NAME (decl) == TREE_PURPOSE (t))
+	      {
+		/* Only warn if there is a conflict.  */
+		if (strcmp (IDENTIFIER_POINTER (TREE_VALUE (t)), oldname))
+		  warning ("#pragma redefine_extname ignored due to "
+			   "conflict with previous rename");
+
+		*p = TREE_CHAIN (t);
+		break;
+	      }
+	  return 0;
+	}
     }
 
   /* Find out if we have a pending #pragma redefine_extname.  */


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