[3.4] fix c/18282, again

Richard Henderson rth@redhat.com
Thu Dec 23 23:52:00 GMT 2004


My test case worked by accident on ilp32 systems, but failed
properly on lp64 systems.  Seems I missed a bit during the
backport from mainline.


r~


        PR c/18282
        * c-decl.c (finish_enum): Retain precision acquired from an attribute.

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.470.4.17
diff -c -p -d -r1.470.4.17 c-decl.c
*** c-decl.c	16 Nov 2004 19:55:32 -0000	1.470.4.17
--- c-decl.c	23 Dec 2004 23:49:19 -0000
*************** finish_enum (tree enumtype, tree values,
*** 5284,5292 ****
  
    TYPE_MIN_VALUE (enumtype) = minnode;
    TYPE_MAX_VALUE (enumtype) = maxnode;
-   TYPE_PRECISION (enumtype) = precision;
    TREE_UNSIGNED (enumtype) = unsign;
    TYPE_SIZE (enumtype) = 0;
    layout_type (enumtype);
  
    if (values != error_mark_node)
--- 5284,5302 ----
  
    TYPE_MIN_VALUE (enumtype) = minnode;
    TYPE_MAX_VALUE (enumtype) = maxnode;
    TREE_UNSIGNED (enumtype) = unsign;
    TYPE_SIZE (enumtype) = 0;
+ 
+   /* If the precision of the type was specific with an attribute and it
+      was too small, give an error.  Otherwise, use it.  */
+   if (TYPE_PRECISION (enumtype))
+     {
+       if (precision > TYPE_PRECISION (enumtype))
+ 	error ("specified mode too small for enumeral values");
+     }
+   else
+     TYPE_PRECISION (enumtype) = precision;
+ 
    layout_type (enumtype);
  
    if (values != error_mark_node)



More information about the Gcc-patches mailing list