Patch to adjust some C99 warnings

Joseph S. Myers jsm28@cam.ac.uk
Fri Jan 19 09:20:00 GMT 2001


This patch adjusts a couple of warnings for features removed in C99
mode: the warning for return type defaulting to int should be the more
specific one about "return type defaults", as per the comment in the
code, rather than the "type defaults" one; and it enables implicit
function declaration warnings by default in C99 mode (rather than only
pedantic C99 mode).  One cpp test using an implicit function
declaration in C99 mode is fixed.

Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit
to mainline and branch after the end of the slush?

2001-01-19  Joseph S. Myers  <jsm28@cam.ac.uk>

	* c-decl.c (grokdeclarator): In C99 mode, give the more specific
	"return type defaults" warning for functions with return type
	defaulting to int.
	* c-lang.c (c_init): In C99 mode, enable warnings for implicit
	function declarations by default rather than only when pedantic.

2001-01-19  Joseph S. Myers  <jsm28@cam.ac.uk>

	* gcc.dg/c99-impl-int-1.c: Use stricter error string for implicit
	return type.
	* gcc.dg/cpp/digraphs.c: Declare puts.

--- c-decl.c.orig	Sat Jan 13 17:31:32 2001
+++ c-decl.c	Fri Jan 19 11:21:29 2001
@@ -3957,7 +3957,8 @@ grokdeclarator (declarator, declspecs, d
 	  /* Issue a warning if this is an ISO C 99 program or if -Wreturn-type
 	     and this is a function, or if -Wimplicit; prefer the former
 	     warning since it is more explicit.  */
-	  if ((warn_implicit_int || warn_return_type) && funcdef_flag)
+	  if ((warn_implicit_int || warn_return_type || flag_isoc99)
+	      && funcdef_flag)
 	    warn_about_return_type = 1;
 	  else if (warn_implicit_int || flag_isoc99)
 	    pedwarn_c99 ("type defaults to `int' in declaration of `%s'",
--- c-lang.c.orig	Sun Jan 14 21:24:11 2001
+++ c-lang.c	Fri Jan 19 11:24:18 2001
@@ -70,10 +70,11 @@ c_init ()
 {
   c_common_lang_init ();

-  /* If still unspecified, make it match pedantic && -std=c99.  */
+  /* If still unspecified, make it match -std=c99
+     (allowing for -pedantic-errors).  */
   if (mesg_implicit_function_declaration < 0)
     {
-      if (pedantic && flag_isoc99)
+      if (flag_isoc99)
 	mesg_implicit_function_declaration = flag_pedantic_errors ? 2 : 1;
       else
 	mesg_implicit_function_declaration = 0;
--- testsuite/gcc.dg/c99-impl-int-1.c.orig	Mon Jul 17 08:25:51 2000
+++ testsuite/gcc.dg/c99-impl-int-1.c	Fri Jan 19 11:24:58 2001
@@ -6,4 +6,4 @@
 extern foo; /* { dg-bogus "warning" "warning in place of error" } */
 /* { dg-error "type defaults" "C99 implicit int error" { target *-*-* } 6 } */
 bar (void) { } /* { dg-bogus "warning" "warning in place of error" } */
-/* { dg-error "type defaults" "C99 implicit int error" { target *-*-* } 8 } */
+/* { dg-error "return type defaults" "C99 implicit int error" { target *-*-* } 8 } */
--- testsuite/gcc.dg/cpp/digraphs.c.orig	Thu Jul 13 10:12:08 2000
+++ testsuite/gcc.dg/cpp/digraphs.c	Fri Jan 19 16:31:08 2001
@@ -8,6 +8,7 @@

 extern int strcmp (const char *, const char *);
 extern void abort (void);
+extern int puts (const char *);
 #define err(str) do { puts(str); abort(); } while (0)

 %:define glue(x, y) x %:%: y	/* #define glue(x, y) x ## y. */

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-patches mailing list