From 48776cde064312d9fd9bac8c3d0fd73be6944255 Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Tue, 30 Nov 1999 23:26:37 +0000 Subject: [PATCH] c-lex.c (yylex): With -Wtraditional... * 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: r30730 --- gcc/ChangeLog | 8 ++++++++ gcc/c-lex.c | 6 +++++- gcc/invoke.texi | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b77d214dc18..e0a454bbf7d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +1999-11-30 Kaveh R. Ghazi + + * 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. + Tue Nov 30 15:18:35 1999 Franz Sirl * combine.c (try_combine): Only pass SET or CLOBBER to SET_DEST diff --git a/gcc/c-lex.c b/gcc/c-lex.c index ab71f787228..d4710a81942 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -1901,7 +1901,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)) diff --git a/gcc/invoke.texi b/gcc/invoke.texi index 567c2a2f092..f1b064975c6 100644 --- a/gcc/invoke.texi +++ b/gcc/invoke.texi @@ -1692,6 +1692,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 -- 2.30.2