aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorBrendan Kehoe <brendan@lasher.cygnus.com>1997-10-01 16:56:13 +0000
committerBrendan Kehoe <brendan@gcc.gnu.org>1997-10-01 12:56:13 -0400
commita3f44a133707389051be1c877f8ac8133ccbaaa7 (patch)
tree86ab308e5e70259d5aea987fe2371f7a19231709 /gcc
parent281de624e33db467fd888e0ac4c4a8a1cad1fa73 (diff)
downloadgcc-a3f44a133707389051be1c877f8ac8133ccbaaa7.zip
gcc-a3f44a133707389051be1c877f8ac8133ccbaaa7.tar.gz
gcc-a3f44a133707389051be1c877f8ac8133ccbaaa7.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/lex.c50
2 files changed, 27 insertions, 28 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5634151..5a30120 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+1997-10-01 Brendan Kehoe <brendan@lasher.cygnus.com>
+
+ * 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 <jason@yorick.cygnus.com>
* method.c (build_decl_overload_real): Reformat.
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 6abf0d0..d1b7d69 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);