diff options
author | Zack Weinberg <zack@codesourcery.com> | 2002-04-22 22:25:14 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2002-04-22 22:25:14 +0000 |
commit | 9340544b77d22d9976a299fe3a348b3bfce2c642 (patch) | |
tree | 9867c8f862eae0149e86442f8e9896c6c9dd2ce8 /gcc/c-lex.c | |
parent | 920f81e7b83620e009c27b8b66e38145a486039b (diff) | |
download | gcc-9340544b77d22d9976a299fe3a348b3bfce2c642.zip gcc-9340544b77d22d9976a299fe3a348b3bfce2c642.tar.gz gcc-9340544b77d22d9976a299fe3a348b3bfce2c642.tar.bz2 |
re PR c/6300 (sparc-sun-solaris2.7 gcc-3.1 C testsuite failure in gcc.dg/cpp/charconst.c)
* c-lex.c (lex_charconst): Call convert to get constant in
proper type; don't just smash the type field.
Fixes PR c/6300.
* config.gcc: Add list of obsolete configurations. Disallow
building these without --enable-obsolete.
* doc/install.texi: Document --enable-obsolete and obsoletion
policy. Mention obsoletion of individual targets in
appropriate places.
From-SVN: r52639
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r-- | gcc/c-lex.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 29c15e7..8a76dd3 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -1338,7 +1338,7 @@ lex_charconst (token) const cpp_token *token; { HOST_WIDE_INT result; - tree value; + tree type, value; unsigned int chars_seen; result = cpp_interpret_charconst (parse_in, token, warn_multichar, @@ -1346,7 +1346,7 @@ lex_charconst (token) if (token->type == CPP_WCHAR) { value = build_int_2 (result, 0); - TREE_TYPE (value) = wchar_type_node; + type = wchar_type_node; } else { @@ -1358,10 +1358,24 @@ lex_charconst (token) /* In C, a character constant has type 'int'. In C++ 'char', but multi-char charconsts have type 'int'. */ if (c_language == clk_cplusplus && chars_seen <= 1) - TREE_TYPE (value) = char_type_node; + type = char_type_node; else - TREE_TYPE (value) = integer_type_node; + type = integer_type_node; } - + + /* cpp_interpret_charconst issues a warning if the constant + overflows, but if the number fits in HOST_WIDE_INT anyway, it + will return it un-truncated, which may cause problems down the + line. So set the type to widest_integer_literal_type, call + convert to truncate it to the proper type, then clear + TREE_OVERFLOW so we don't get a second warning. + + FIXME: cpplib's assessment of overflow may not be accurate on a + platform where the final type can change at (compiler's) runtime. */ + + TREE_TYPE (value) = widest_integer_literal_type_node; + value = convert (type, value); + TREE_OVERFLOW (value) = 0; + return value; } |