public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PDP10][PATCH]
@ 2008-05-01 18:57 Martin Chaney
  0 siblings, 0 replies; only message in thread
From: Martin Chaney @ 2008-05-01 18:57 UTC (permalink / raw)
  To: gcc-patches

Sorry to intrude on this busy list.  If this is not the best way of 
bringing up this issue I trust one or more people will send me advice.

Checkin R134438 to fix_string_type(tree value) in c-common.c broke my 
pdp10 customization of gcc.  I believe the attached patch is at worst 
innocuous for other versions while it fixes my customization.

The issue is the addition of CHAR16_TYPE and CHAR32_TYPE.  This 
necessitated new code in fix_string_type which was written in the form 
of a cascaded if-then-else checking for different character array 
types.  But the pdp10 adds its own custom character types and the 
cascade was written to assume the final else block would be reached only 
if (TREE_TYPE(value) == wchar_array_type).  Since this is not true the 
values that get set are incorrect and things go awry.

The proposed patch checks for wchar_array_type, adds a final block which 
calls gcc_unreachable, and adds a block to generically handle other 
character array types.  Note that the generic block does not assume that 
the precision is a multiple of BITS_PER_UNIT, as is assumed with 
CHAR16_TYPE and CHAR32_TYPE.

Martin Chaney




Index: c-common.c
===================================================================
--- c-common.c  (revision 134692)
+++ c-common.c  (working copy)
@@ -898,11 +898,18 @@ fix_string_type (tree value)
       nchars = length / (TYPE_PRECISION (char32_type_node) / 
BITS_PER_UNIT);
       e_type = char32_type_node;
     }
-  else
+  else if (TREE_TYPE (value) == wchar_array_type_node)
     {
       nchars = length / (TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT);
       e_type = wchar_type_node;
     }
+  else if (TREE_TYPE(TREE_TYPE(value)))
+    {
+     e_type = TREE_TYPE(TREE_TYPE(value));
+     nchars = length / ((TYPE_PRECISION(e_type) + BITS_PER_UNIT - 1) / 
BITS_PER_UNIT);
+    }
+  else
+    gcc_unreachable();

   /* C89 2.2.4.1, C99 5.2.4.1 (Translation limits).  The analogous
      limit in C++98 Annex B is very large (65536) and is not normative,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-05-01 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-01 18:57 [PDP10][PATCH] Martin Chaney

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).