summaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-22 22:25:14 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-22 22:25:14 +0000
commitc2527f80d5b4fffc08c6175cef2578f9a6105081 (patch)
tree9867c8f862eae0149e86442f8e9896c6c9dd2ce8 /gcc/c-lex.c
parent3af89ec6df4466b91fb6473376b353218432e734 (diff)
downloadgcc-c2527f80d5b4fffc08c6175cef2578f9a6105081.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52639 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 29c15e79909..8a76dd35c31 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;
}