aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrendan <brendan@138bc75d-0d04-0410-961f-82ee72b054a4>1997-10-01 16:56:13 +0000
committerbrendan <brendan@138bc75d-0d04-0410-961f-82ee72b054a4>1997-10-01 16:56:13 +0000
commit6559dc1180c3fe4724cded118b5607b690bfca53 (patch)
tree86ab308e5e70259d5aea987fe2371f7a19231709
parenta73a2af15f8da5101bf1cc890a68e0ac56f43de8 (diff)
* lex.c (real_yylex): Clean up the code to fully behave the way
the c-lex.c parser does for complex and real numbers. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@15826 138bc75d-0d04-0410-961f-82ee72b054a4
-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 56341515481..5a301208271 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 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);