c-lex.c (parse_float, yylex): For -Wtraditional, issue a warning about non-traditiona...
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Thu, 10 Aug 2000 15:21:18 +0000 (15:21 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Thu, 10 Aug 2000 15:21:18 +0000 (15:21 +0000)
* c-lex.c (parse_float, yylex): For -Wtraditional, issue a
warning about non-traditional numeric constant suffixes.

* cppexp.c (parse_number): Likewise.

* invoke.texi: (-Wtraditional): Document new behavior.

From-SVN: r35607

gcc/ChangeLog
gcc/c-lex.c
gcc/cppexp.c
gcc/invoke.texi

index 0f8a523..0146878 100644 (file)
@@ -1,3 +1,12 @@
+2000-08-10  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * c-lex.c (parse_float, yylex): For -Wtraditional, issue a
+       warning about non-traditional numeric constant suffixes.
+
+       * cppexp.c (parse_number): Likewise.
+
+       * invoke.texi: (-Wtraditional): Document new behavior.
+
 Thu Aug 10 00:11:04 2000  Ovidiu Predescu  <ovidiu@cup.hp.com>
 
        * gthr-posix.h: Include auto-host.h. Conditionally include
index 9cbbc4d..77442e3 100644 (file)
@@ -1109,12 +1109,16 @@ parse_float (data)
        case 'f': case 'F':
          if (fflag)
            error ("more than one `f' in numeric constant");
+         else if (warn_traditional && !in_system_header)
+           warning ("traditional C rejects the `%c' suffix", args->c);
          fflag = 1;
          break;
 
        case 'l': case 'L':
          if (lflag)
            error ("more than one `l' in numeric constant");
+         else if (warn_traditional && !in_system_header)
+           warning ("traditional C rejects the `%c' suffix", args->c);
          lflag = 1;
          break;
 
@@ -1773,6 +1777,8 @@ yylex ()
                  {
                    if (spec_unsigned)
                      error ("two `u's in integer constant");
+                   else if (warn_traditional && !in_system_header)
+                     warning ("traditional C rejects the `%c' suffix", c);
                    spec_unsigned = 1;
                    if (spec_long)
                      suffix_lu = 1;
index 18f494f..9631526 100644 (file)
@@ -218,6 +218,8 @@ parse_number (pfile, tok)
        goto invalid_suffix;
       op.unsignedp = sufftab[i].u;
 
+      if (CPP_WTRADITIONAL (pfile) && sufftab[i].u)
+       cpp_warning (pfile, "traditional C rejects the `U' suffix");
       if (CPP_OPTION (pfile, c89) && sufftab[i].l == 2)
        SYNTAX_ERROR ("too many 'l' suffixes in integer constant");
     }
index a1096f1..14dd109 100644 (file)
@@ -1838,6 +1838,15 @@ omitted.  This is done under the assumption that the zero initializer in
 user code appears conditioned on e.g. @code{__STDC__} to avoid missing
 initializer warnings and relies on default initialization to zero in the
 traditional C case.
+
+@item
+The `U' integer constant suffix, or the `F' or `L' floating point
+constant suffixes.  (Traditonal C does support the `L' suffix on integer
+constants.)  Note, these suffixes appear in macros defined in the system
+headers of most modern systems, e.g. the _MIN/_MAX macros in limits.h.
+Use of these macros can lead to spurious warnings as they do not
+necessarily reflect whether the code in question is any less portable to
+traditional C given that suitable backup definitions are provided.
 @end itemize
 
 @item -Wundef