public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] revert part of the unsigned_type langhook removal
@ 2007-05-15 10:45 Rafael Espindola
  2007-05-15 13:50 ` Rafael Espindola
  0 siblings, 1 reply; 2+ messages in thread
From: Rafael Espindola @ 2007-05-15 10:45 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 347 bytes --]

The attached patch is a test that reverts part of my previous one and
adds a debug output. It is currently in stage2 in a x86-64 and I am
doing a setup of a i686 environment to give it a try.

-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

[-- Attachment #2: revert.patch --]
[-- Type: text/x-patch, Size: 2981 bytes --]

--- gcc/c-common.c	(revision 124737)
+++ gcc/c-common.c	(local)
@@ -2025,6 +2025,39 @@ c_common_type_for_mode (enum machine_mod
   return 0;
 }
 
+/* Return an unsigned type the same as TYPE in other respects.  */
+tree
+c_common_unsigned_type (tree type)
+{
+  tree type1 = TYPE_MAIN_VARIANT (type);
+  if (type1 == signed_char_type_node || type1 == char_type_node)
+    return unsigned_char_type_node;
+  if (type1 == integer_type_node)
+    return unsigned_type_node;
+  if (type1 == short_integer_type_node)
+    return short_unsigned_type_node;
+  if (type1 == long_integer_type_node)
+    return long_unsigned_type_node;
+  if (type1 == long_long_integer_type_node)
+    return long_long_unsigned_type_node;
+  if (type1 == widest_integer_literal_type_node)
+    return widest_unsigned_literal_type_node;
+#if HOST_BITS_PER_WIDE_INT >= 64
+  if (type1 == intTI_type_node)
+    return unsigned_intTI_type_node;
+#endif
+  if (type1 == intDI_type_node)
+    return unsigned_intDI_type_node;
+  if (type1 == intSI_type_node)
+    return unsigned_intSI_type_node;
+  if (type1 == intHI_type_node)
+    return unsigned_intHI_type_node;
+  if (type1 == intQI_type_node)
+    return unsigned_intQI_type_node;
+
+  return c_common_signed_or_unsigned_type (1, type);
+}
+
 /* Return a signed type the same as TYPE in other respects.  */
 
 tree
--- gcc/c-common.h	(revision 124737)
+++ gcc/c-common.h	(local)
@@ -667,6 +667,7 @@ extern int c_common_handle_option (size_
 extern bool c_common_missing_argument (const char *opt, size_t code);
 extern tree c_common_type_for_mode (enum machine_mode, int);
 extern tree c_common_type_for_size (unsigned int, int);
+extern tree c_common_unsigned_type (tree);
 extern tree c_common_signed_type (tree);
 extern tree c_common_signed_or_unsigned_type (int, tree);
 extern tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT, int);
--- gcc/c-format.c	(revision 124737)
+++ gcc/c-format.c	(local)
@@ -2245,11 +2245,29 @@ check_format_types (format_wanted_type *
 	 -pedantic.  With -pedantic, warn if the type is a pointer
 	 target and not a character type, and for character types at
 	 a second level of indirection.  */
+
+      {
+	tree t1 = c_common_unsigned_type (cur_type);
+	tree t2 = c_common_signed_or_unsigned_type (1, cur_type);
+	tree t3 = unsigned_type_for (cur_type);
+	if (t1 != t2)
+	  {
+	    printf("t1 != t2\n");
+	    debug_tree(t1);
+	    debug_tree(t2);
+	  }
+	else if (t1 != t3)
+	  {
+	    printf("t1 != t3\n");
+	    debug_tree(t1);
+	    debug_tree(t3);
+	  }
+      }
       if (TREE_CODE (wanted_type) == INTEGER_TYPE
 	  && TREE_CODE (cur_type) == INTEGER_TYPE
 	  && (!pedantic || i == 0 || (i == 1 && char_type_flag))
 	  && (TYPE_UNSIGNED (wanted_type)
-	      ? wanted_type == unsigned_type_for (cur_type)
+	      ? wanted_type == c_common_unsigned_type (cur_type)
 	      : wanted_type == c_common_signed_type (cur_type)))
 	continue;
       /* Likewise, "signed char", "unsigned char" and "char" are

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] revert part of the unsigned_type langhook removal
  2007-05-15 10:45 [PATCH] revert part of the unsigned_type langhook removal Rafael Espindola
@ 2007-05-15 13:50 ` Rafael Espindola
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael Espindola @ 2007-05-15 13:50 UTC (permalink / raw)
  To: gcc-patches

On 5/15/07, Rafael Espindola <espindola@google.com> wrote:
> The attached patch is a test that reverts part of my previous one and
> adds a debug output. It is currently in stage2 in a x86-64 and I am
> doing a setup of a i686 environment to give it a try.

OK, it comes down to how each function handles long_integer_type_node on x86.

c_common_unsigned_type returns long_unsigned_type_node.
c_common_signed_or_unsigned_type returns unsigned_type_node, which on
a x86 has the same precision, but is a different type.

I am currently testing  a fix. If it fails I will post a patch to
partially revert my previous one.

-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-05-15 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-15 10:45 [PATCH] revert part of the unsigned_type langhook removal Rafael Espindola
2007-05-15 13:50 ` Rafael Espindola

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).