From: Brendan Kehoe Date: Wed, 1 Oct 1997 16:56:13 +0000 (+0000) Subject: lex.c (real_yylex): Clean up the code to fully behave the way the c-lex.c parser... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a3f44a133707389051be1c877f8ac8133ccbaaa7;p=gcc.git lex.c (real_yylex): Clean up the code to fully behave the way the c-lex.c parser does for complex... * lex.c (real_yylex): Clean up the code to fully behave the way the c-lex.c parser does for complex and real numbers. From-SVN: r15826 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 56341515481..5a301208271 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1997-10-01 Brendan Kehoe + + * lex.c (real_yylex): Clean up the code to fully behave the way + the c-lex.c parser does for complex and real numbers. + Tue Sep 30 08:51:36 1997 Jason Merrill * method.c (build_decl_overload_real): Reformat. diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 6abf0d09fbf..d1b7d699aaa 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -3805,17 +3805,14 @@ real_yylex () yylval.ttype = build_int_2 (low, high); TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node; + /* Calculate the ANSI type. */ if (!spec_long && !spec_unsigned && int_fits_type_p (yylval.ttype, integer_type_node)) - { - type = integer_type_node; - } + type = integer_type_node; else if (!spec_long && (base != 10 || spec_unsigned) && int_fits_type_p (yylval.ttype, unsigned_type_node)) - { - /* Nondecimal constants try unsigned even in traditional C. */ - type = unsigned_type_node; - } + /* Nondecimal constants try unsigned even in traditional C. */ + type = unsigned_type_node; else if (!spec_unsigned && !spec_long_long && int_fits_type_p (yylval.ttype, long_integer_type_node)) type = long_integer_type_node; @@ -3827,31 +3824,28 @@ real_yylex () && int_fits_type_p (yylval.ttype, long_long_integer_type_node)) type = long_long_integer_type_node; - else if (int_fits_type_p (yylval.ttype, - long_long_unsigned_type_node)) + else type = long_long_unsigned_type_node; - else - { - type = long_long_integer_type_node; - warning ("integer constant out of range"); + if (!int_fits_type_p (yylval.ttype, type) && !warn) + pedwarn ("integer constant out of range"); - if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type)) - warning ("decimal integer constant is so large that it is unsigned"); - if (spec_imag) - { - if (TYPE_PRECISION (type) - <= TYPE_PRECISION (integer_type_node)) - yylval.ttype - = build_complex (NULL_TREE, integer_zero_node, - cp_convert (integer_type_node, - yylval.ttype)); - else - error ("complex integer constant is too wide for `__complex int'"); - } - } + if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type)) + warning ("decimal integer constant is so large that it is unsigned"); - TREE_TYPE (yylval.ttype) = type; + if (spec_imag) + { + if (TYPE_PRECISION (type) + <= TYPE_PRECISION (integer_type_node)) + yylval.ttype + = build_complex (NULL_TREE, integer_zero_node, + cp_convert (integer_type_node, + yylval.ttype)); + else + error ("complex integer constant is too wide for `__complex int'"); + } + else + TREE_TYPE (yylval.ttype) = type; } put_back (c);