non-static definition after static declaration

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Tue Nov 30 23:59:00 GMT 1999


 > From: Richard Henderson <rth@cygnus.com>
 >  
 > On Tue, Nov 30, 1999 at 01:04:17PM -0500, Kaveh R. Ghazi wrote:
 > 
 > > So perhaps a good solution would be to disable this particular
 > > warning if the base of the number is not 10, under the assumption
 > > that if the base is hex or octal then the programmer meant what they
 > > wrote.
 >  
 > I'd agree with this.  Feel free to commit the patchlet.
 > r~

Thanks, I installed the following.

Note when documenting this change in invoke.texi, there was no
description of this particular check in -Wtraditional.  So I added a
bullet item about the width & signedness test and mentioned that now
it only occurs when the base is ten.

		--Kaveh


Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ChangeLog,v
retrieving revision 1.5104
diff -u -p -r1.5104 ChangeLog
--- ChangeLog	1999/11/30 23:19:05	1.5104
+++ ChangeLog	1999/11/30 23:25:12
@@ -1,3 +1,11 @@
+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.
+
 Tue Nov 30 15:18:35 1999  Franz Sirl  <Franz.Sirl-kernel@lauterbach.com>
 
 	* combine.c (try_combine): Only pass SET or CLOBBER to SET_DEST
Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-lex.c,v
retrieving revision 1.66
diff -u -p -r1.66 c-lex.c
--- c-lex.c	1999/10/31 04:42:55	1.66
+++ c-lex.c	1999/11/30 23:25:14
@@ -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))
Index: invoke.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/invoke.texi,v
retrieving revision 1.155
diff -u -p -r1.155 invoke.texi
--- invoke.texi	1999/11/30 12:02:08	1.155
+++ invoke.texi	1999/11/30 23:25:20
@@ -1692,6 +1692,12 @@ A @code{switch} statement has an operand
 @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



More information about the Gcc-patches mailing list