OSDN Git Service

* lex.c (real_yylex): Clean up the code to fully behave the way
authorbrendan <brendan@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 Oct 1997 16:56:13 +0000 (16:56 +0000)
committerbrendan <brendan@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 1 Oct 1997 16:56:13 +0000 (16:56 +0000)
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

gcc/cp/ChangeLog
gcc/cp/lex.c

index 5634151..5a30120 100644 (file)
@@ -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.
index 6abf0d0..d1b7d69 100644 (file)
@@ -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);