c-lex.c (yylex): Remove warning for integer literals being larger than the largest...
authorGavin Romig-Koch <gavin@cygnus.com>
Tue, 16 Mar 1999 08:33:24 +0000 (08:33 +0000)
committerGavin Romig-Koch <gavin@gcc.gnu.org>
Tue, 16 Mar 1999 08:33:24 +0000 (08:33 +0000)
* c-lex.c (yylex) : Remove warning for integer literals being
larger than the largest target int.  Add warning for integer
literal being larger than than its choosen type.

From-SVN: r25800

gcc/ChangeLog
gcc/c-lex.c

index 17955b8f6bd24ac6e01b38df90ec0650de9aa5c7..f9caaace14e81398e77c16e61f40afe66db3e478 100644 (file)
@@ -1,3 +1,9 @@
+Tue Mar 16 11:30:19 1999  Gavin Romig-Koch  <gavin@cygnus.com>
+
+       * c-lex.c (yylex) : Remove warning for integer literals being
+       larger than the largest target int.  Add warning for integer
+       literal being larger than than its choosen type.
+
 Tue Mar 16 10:53:17 1999  Gavin Romig-Koch  <gavin@cygnus.com>
 
        * invoke.texi: Add -mlong32 documentation.
index 8f63b2db7dc3e31b62ef59fb03ab4439a62f2045..be366fae83e632f583e58c689a7c831e92371f44 100644 (file)
@@ -1698,20 +1698,10 @@ yylex ()
                c = GETC();
              }
 
-           /* If the constant won't fit in the targets widest int,
-              or it won't fit in the host's representation for ints, 
-              then warn that the constant is out of range. */
-
-#if HOST_BITS_PER_WIDE_INT >= 64
-           bytes = TYPE_PRECISION (intTI_type_node) / HOST_BITS_PER_CHAR;
-#else
-           bytes = TYPE_PRECISION (intDI_type_node) / HOST_BITS_PER_CHAR;
-#endif
+           /* If it won't fit in the host's representation for integers,
+              then pedwarn. */
 
            warn = overflow;
-           for (i = bytes; i < TOTAL_PARTS; i++)
-             if (parts[i])
-               warn = 1;
            if (warn)
              pedwarn ("integer constant out of range");
 
@@ -1802,7 +1792,10 @@ yylex ()
            if (pedantic && !flag_traditional && !spec_long_long && !warn
                && (TYPE_PRECISION (long_integer_type_node)
                    < TYPE_PRECISION (type)))
-             pedwarn ("integer constant out of range");
+             {
+               warn = 1;
+               pedwarn ("integer constant out of range");
+             }
 
            if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
              warning ("decimal constant is so large that it is unsigned");
@@ -1830,6 +1823,15 @@ yylex ()
              }
            else
              TREE_TYPE (yylval.ttype) = type;
+
+
+           /* If it's still an integer (not a complex), and it doesn't
+              fit in the type we choose for it, then pedwarn. */
+
+           if (! warn
+               && TREE_CODE (TREE_TYPE (yylval.ttype)) == INTEGER_TYPE
+               && ! int_fits_type_p (yylval.ttype, TREE_TYPE (yylval.ttype)))
+             pedwarn ("integer constant out of range");
          }
 
        UNGETC (c);