]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-lex.c (yylex): With -Wtraditional...
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Tue, 20 Mar 2001 23:51:46 +0000 (23:51 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Tue, 20 Mar 2001 23:51:46 +0000 (23:51 +0000)
       1999-11-30  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
        * c-lex.c (yylex): With -Wtraditional, when the ANSI type of an
       integer constant does not match the traditional type, limit the
       warnings to cases where the base of the type is ten.

        * invoke.texi (-Wtraditional): Document it.

From-SVN: r40680

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

index 190cc59ebc2b29c5025ffb46f32814c710d93d23..921089dda7c4cba2a7871475d8bdd6be200768ad 100644 (file)
@@ -1,3 +1,12 @@
+Tue Mar 20 18:31:48 2001  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       1999-11-30  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+        * c-lex.c (yylex): With -Wtraditional, when the ANSI type of an
+       integer constant does not match the traditional type, limit the
+       warnings to cases where the base of the type is ten.
+
+        * invoke.texi (-Wtraditional): Document it.
+
 2001-03-20  David O'Brien  <obrien@FreeBSD.org>
 
        from 2000-07-12  Zack Weinberg  <zack@wolery.cumb.org>
index 27c65f3fa27f20f912a3b00b5f058f8f7b541de8..8ee2fe40db360627a05363eaae74f1e096779f0b 100644 (file)
@@ -1812,7 +1812,11 @@ yylex ()
 
            type = flag_traditional ? traditional_type : ansi_type;
 
-           if (warn_traditional && traditional_type != ansi_type)
+           /* We assume that constants specified in a non-decimal
+              base are bit patterns, and that the programmer really
+              meant what they wrote.  */
+           if (warn_traditional && base == 10
+               && traditional_type != ansi_type)
              {
                if (TYPE_PRECISION (traditional_type)
                    != TYPE_PRECISION (ansi_type))
index e97495e1b6c4c9385ec7d0f34dcb26abd7ba2410..9865a3449ec9753de488c99e122d3c4f6bd47871 100644 (file)
@@ -1694,6 +1694,12 @@ A @code{switch} statement has an operand of type @code{long}.
 @item
 A non-@code{static} function declaration follows a @code{static} one.
 This construct is not accepted by some traditional C compilers.
+
+@item
+The ANSI type of an integer constant has a different width or signedness
+from its traditional type.  This warning is only issued if the base of
+the constant is ten.  I.e. hexadecimal or octal values, which typically
+represent bit patterns, are not warned about.
 @end itemize
 
 @item -Wundef