OSDN Git Service

For gcc:
authorgavin <gavin@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Jul 1999 10:30:01 +0000 (10:30 +0000)
committergavin <gavin@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Jul 1999 10:30:01 +0000 (10:30 +0000)
* c-decl.c (widest_integer_literal_type_node,
widest_unsigned_literal_type) : New.
(init_decl_processing): Handle/use the two new types.
* c-common.c (type_for_size,type_for_mode) : Same.
* c-lex.c (yylex) : Same.
* c-typeck.c (unsigned_type,signed_type,signed_or_unsigned_type) :
Same.
* c-tree.h (widest_integer_literal_type_node,
widest_unsigned_literal_type) : New.
For gcc/cp:
* cp-tree.h (widest_integer_literal_type_node,
widest_unsigned_literal_type) : New.
* decl.c (widest_integer_literal_type_node,
widest_unsigned_literal_type) : New.
(init_decl_processing): Handle/use the two new types.
* lex.c (real_yylex): Same.
* typeck.c (unsigned_type,signed_type,signed_or_unsigned_type) :
Same.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@27923 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-common.c
gcc/c-decl.c
gcc/c-lex.c
gcc/c-tree.h
gcc/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/lex.c
gcc/cp/typeck.c

index c3ef1de..bc5da17 100644 (file)
@@ -1,3 +1,15 @@
+Fri Jul  2 13:23:39 1999  Gavin Romig-Koch  <gavin@cygnus.com>
+
+       * c-decl.c (widest_integer_literal_type_node,
+       widest_unsigned_literal_type) : New.
+       (init_decl_processing): Handle/use the two new types.
+       * c-common.c (type_for_size,type_for_mode) : Same.
+       * c-lex.c (yylex) : Same.
+       * c-typeck.c (unsigned_type,signed_type,signed_or_unsigned_type) :
+       Same.
+       * c-tree.h (widest_integer_literal_type_node,
+       widest_unsigned_literal_type) : New.
+
 Fri Jul  2 03:05:44 1999  Jeffrey A Law  (law@cygnus.com)
 
        * dwarfout.c (field_byte_offset): Correctly compute the object's
index 1ec3842..f1a61cd 100644 (file)
@@ -2081,6 +2081,10 @@ type_for_size (bits, unsignedp)
     return (unsignedp ? long_long_unsigned_type_node
            : long_long_integer_type_node);
 
+  if (bits == TYPE_PRECISION (widest_integer_literal_type_node))
+    return (unsignedp ? widest_unsigned_literal_type_node
+           : widest_integer_literal_type_node);
+
   if (bits <= TYPE_PRECISION (intQI_type_node))
     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
 
@@ -2120,6 +2124,10 @@ type_for_mode (mode, unsignedp)
   if (mode == TYPE_MODE (long_long_integer_type_node))
     return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node;
 
+  if (mode == TYPE_MODE (widest_integer_literal_type_node))
+    return unsignedp ? widest_unsigned_literal_type_node 
+                     : widest_integer_literal_type_node;
+
   if (mode == TYPE_MODE (intQI_type_node))
     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
 
index a232217..97db33f 100644 (file)
@@ -123,6 +123,14 @@ tree unsigned_type_node;
 tree long_unsigned_type_node;
 tree long_long_unsigned_type_node;
 
+/* These are used for integer literals that are larger than 
+   a long long.  The largest integer literals we can handle
+   are the width of two HOST_WIDE_INTs.  If two HOST_WIDE_INTs
+   are not larger than the target's long long, then these
+   will never be used. */
+tree widest_integer_literal_type_node;
+tree widest_unsigned_literal_type_node;
+
 tree boolean_type_node;
 tree boolean_false_node;
 tree boolean_true_node;
@@ -3103,6 +3111,16 @@ init_decl_processing ()
   pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned char"),
                        unsigned_char_type_node));
 
+  /* Create the widest literal types. */
+  widest_integer_literal_type_node = make_signed_type (HOST_BITS_PER_WIDE_INT * 2);
+  pushdecl (build_decl (TYPE_DECL, NULL_TREE, 
+                       widest_integer_literal_type_node));
+
+  widest_unsigned_literal_type_node = make_unsigned_type (HOST_BITS_PER_WIDE_INT * 2);
+  pushdecl (build_decl (TYPE_DECL, NULL_TREE, 
+                       widest_unsigned_literal_type_node));
+
+  /* Now all the integer mode types. */
   intQI_type_node = make_signed_type (GET_MODE_BITSIZE (QImode));
   pushdecl (build_decl (TYPE_DECL, NULL_TREE, intQI_type_node));
 
index 214bcd1..ed825ee 100644 (file)
@@ -1818,10 +1818,17 @@ yylex ()
                else if (! spec_long_long)
                  traditional_type = (spec_unsigned ? long_unsigned_type_node
                                      : long_integer_type_node);
-               else
+               else if (int_fits_type_p (yylval.ttype,
+                                         spec_unsigned 
+                                         ? long_long_unsigned_type_node
+                                         : long_long_integer_type_node)) 
                  traditional_type = (spec_unsigned
                                      ? long_long_unsigned_type_node
                                      : long_long_integer_type_node);
+               else
+                 traditional_type = (spec_unsigned
+                                     ? widest_unsigned_literal_type_node
+                                     : widest_integer_literal_type_node);
              }
            if (warn_traditional || ! flag_traditional)
              {
@@ -1843,8 +1850,15 @@ yylex ()
                         && int_fits_type_p (yylval.ttype,
                                             long_long_integer_type_node))
                  ansi_type = long_long_integer_type_node;
-               else
+               else if (int_fits_type_p (yylval.ttype,
+                                         long_long_unsigned_type_node))
                  ansi_type = long_long_unsigned_type_node;
+               else if (! spec_unsigned
+                        && int_fits_type_p (yylval.ttype,
+                                            widest_integer_literal_type_node))
+                 ansi_type = widest_integer_literal_type_node;
+               else
+                 ansi_type = widest_unsigned_literal_type_node;
              }
 
            type = flag_traditional ? traditional_type : ansi_type;
index bcf325b..7e01356 100644 (file)
@@ -246,9 +246,11 @@ extern tree integer_type_node;
 extern tree long_double_type_node;
 extern tree long_ftype_long;
 extern tree long_integer_type_node;
+extern tree long_unsigned_type_node;
 extern tree long_long_integer_type_node;
 extern tree long_long_unsigned_type_node;
-extern tree long_unsigned_type_node;
+extern tree widest_integer_literal_type_node;
+extern tree widest_unsigned_literal_type_node;
 extern tree complex_integer_type_node;
 extern tree complex_float_type_node;
 extern tree complex_double_type_node;
index 95d417e..ca98655 100644 (file)
@@ -739,6 +739,8 @@ unsigned_type (type)
     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 (type1 == intDI_type_node)
     return unsigned_intDI_type_node;
   if (type1 == intSI_type_node)
@@ -768,6 +770,8 @@ signed_type (type)
     return long_integer_type_node;
   if (type1 == long_long_unsigned_type_node)
     return long_long_integer_type_node;
+  if (type1 == widest_unsigned_literal_type_node)
+    return widest_integer_literal_type_node;
   if (type1 == unsigned_intDI_type_node)
     return intDI_type_node;
   if (type1 == unsigned_intSI_type_node)
@@ -802,6 +806,9 @@ signed_or_unsigned_type (unsignedp, type)
   if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node)) 
     return (unsignedp ? long_long_unsigned_type_node
            : long_long_integer_type_node);
+  if (TYPE_PRECISION (type) == TYPE_PRECISION (widest_integer_literal_type_node)) 
+    return (unsignedp ? widest_unsigned_literal_type_node
+           : widest_integer_literal_type_node);
   return type;
 }
 
index e3ea60d..40d5aac 100644 (file)
@@ -1,3 +1,14 @@
+1999-07-02  Gavin Romig-Koch  <gavin@cygnus.com>
+
+       * cp-tree.h (widest_integer_literal_type_node,
+       widest_unsigned_literal_type) : New.
+       * decl.c (widest_integer_literal_type_node,
+       widest_unsigned_literal_type) : New.
+       (init_decl_processing): Handle/use the two new types.
+       * lex.c (real_yylex): Same.
+       * typeck.c (unsigned_type,signed_type,signed_or_unsigned_type) :
+       Same. 
+
 1999-07-01  Mark Mitchell  <mark@codesourcery.com>
 
        * decl.c (grokdeclarator): Don't give names "for linkage purposes"
index 4d243b4..28c7e3f 100644 (file)
@@ -336,6 +336,7 @@ extern tree ptrdiff_type_node;
 extern tree short_integer_type_node, short_unsigned_type_node;
 extern tree long_integer_type_node, long_unsigned_type_node;
 extern tree long_long_integer_type_node, long_long_unsigned_type_node;
+extern tree widest_integer_literal_type_node, widest_unsigned_literal_type_node;
 extern tree unsigned_type_node;
 extern tree string_type_node, char_array_type_node, int_array_type_node;
 extern tree wchar_array_type_node;
index b7a36de..1b6b268 100644 (file)
@@ -220,6 +220,14 @@ tree unsigned_type_node;
 tree long_unsigned_type_node;
 tree long_long_unsigned_type_node;
 
+/* These are used for integer literals that are larger than 
+   a long long.  The largest integer literals we can handle
+   are the width of two HOST_WIDE_INTs.  If two HOST_WIDE_INTs
+   are not larger than the target's long long, then these
+   will never be used. */
+tree widest_integer_literal_type_node;
+tree widest_unsigned_literal_type_node;
+
 tree ptrdiff_type_node;
 
 tree unsigned_char_type_node;
@@ -6356,6 +6364,15 @@ init_decl_processing ()
   unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
   record_builtin_type (RID_MAX, "unsigned char", unsigned_char_type_node);
 
+  /* Create the widest literal types. */
+  widest_integer_literal_type_node = make_signed_type (HOST_BITS_PER_WIDE_INT * 2);
+  pushdecl (build_decl (TYPE_DECL, NULL_TREE, 
+                       widest_integer_literal_type_node));
+
+  widest_unsigned_literal_type_node = make_unsigned_type (HOST_BITS_PER_WIDE_INT * 2);
+  pushdecl (build_decl (TYPE_DECL, NULL_TREE, 
+                       widest_unsigned_literal_type_node));
+
   /* These are types that type_for_size and type_for_mode use.  */
   intQI_type_node = make_signed_type (GET_MODE_BITSIZE (QImode));
   pushdecl (build_decl (TYPE_DECL, NULL_TREE, intQI_type_node));
index 5448990..303306a 100644 (file)
@@ -3937,8 +3937,15 @@ real_yylex ()
                     && int_fits_type_p (yylval.ttype,
                                         long_long_integer_type_node))
              type = long_long_integer_type_node;
-           else
+           else if (int_fits_type_p (yylval.ttype,
+                                     long_long_unsigned_type_node))
              type = long_long_unsigned_type_node;
+           else if (! spec_unsigned
+                    && int_fits_type_p (yylval.ttype,
+                                        widest_integer_literal_type_node))
+             type = widest_integer_literal_type_node;
+           else
+             type = widest_unsigned_literal_type_node;
 
            if (!int_fits_type_p (yylval.ttype, type) && !warn)
              pedwarn ("integer constant is larger than the maximum value for its type");
index 9e41af3..81fa296 100644 (file)
@@ -1475,6 +1475,8 @@ unsigned_type (type)
     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;
@@ -1508,6 +1510,8 @@ signed_type (type)
     return long_integer_type_node;
   if (type1 == long_long_unsigned_type_node)
     return long_long_integer_type_node;
+  if (type1 == widest_unsigned_literal_type_node)
+    return widest_integer_literal_type_node;
 #if HOST_BITS_PER_WIDE_INT >= 64
   if (type1 == unsigned_intTI_type_node)
     return intTI_type_node;
@@ -1547,6 +1551,9 @@ signed_or_unsigned_type (unsignedp, type)
   if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node)) 
     return (unsignedp ? long_long_unsigned_type_node
            : long_long_integer_type_node);
+  if (TYPE_PRECISION (type) == TYPE_PRECISION (widest_integer_literal_type_node)) 
+    return (unsignedp ? widest_unsigned_literal_type_node
+           : widest_integer_literal_type_node);
   return type;
 }