diff options
author | Gavin Romig-Koch <gavin@cygnus.com> | 1999-03-16 08:33:24 +0000 |
---|---|---|
committer | Gavin Romig-Koch <gavin@gcc.gnu.org> | 1999-03-16 08:33:24 +0000 |
commit | 0e0fda0dd2073085d3253925c8f2b4cf22c6bd1c (patch) | |
tree | f5ac52146a9858758c4f6fa86da80d1c345b30d7 /gcc/c-lex.c | |
parent | 3ce1ba83d698f792310b7880703dc8b351f82bd2 (diff) | |
download | gcc-0e0fda0dd2073085d3253925c8f2b4cf22c6bd1c.zip gcc-0e0fda0dd2073085d3253925c8f2b4cf22c6bd1c.tar.gz gcc-0e0fda0dd2073085d3253925c8f2b4cf22c6bd1c.tar.bz2 |
c-lex.c (yylex): Remove warning for integer literals being larger than the largest target int.
* 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
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r-- | gcc/c-lex.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 8f63b2d..be366fa 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -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); |