This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fix for c9[09]-impl-decl-1.c tests


This patch corrects the implicit declaration warnings so they are
pedantic warnings in C99 and ordinary otherwise.  They are triggered
by either -pedantic -std=c99 or -Wall, but not by -pedantic -std=c90.

Also, digraphs are properly unrecognized under -std=c90, so
c90-digraph-1 is no longer expected to fail.

I have not yet bootstrapped this, but will do so later tonight along
with some other changes.

zw

	* c-decl.c: Init mesg_implicit_function_declaration to -1.
	* c-lang.c (lang_init): If mesg_implicit_function_declaration
	is -1, set it according to pedantic && flag_isoc99.
	* c-typeck.c (build_external_ref): Condition the warning for
	implicit decl of an intrinsic on mesg_implicit_function_declaration.
	* c-tree.h: Declare mesg_implicit_function_declaration.

testsuite:
	* gcc.dg/c90-digraph-1.c: No longer XFAIL.
	* gcc.dg/c99-impl-decl-1.c: No longer XFAIL.

===================================================================
Index: c-decl.c
--- c-decl.c	2000/07/13 10:12:07	1.131
+++ c-decl.c	2000/07/18 02:05:25
@@ -358,7 +358,7 @@ int warn_long_long = 1;
 /* Nonzero means message about use of implicit function declarations;
  1 means warning; 2 means error. */
 
-int mesg_implicit_function_declaration;
+int mesg_implicit_function_declaration = -1;
 
 /* Nonzero means give string constants the type `const char *'
    to get extra warnings from them.  These warnings will be too numerous
===================================================================
Index: c-lang.c
--- c-lang.c	2000/06/19 22:28:28	1.28
+++ c-lang.c	2000/07/18 02:05:25
@@ -69,6 +69,15 @@ lang_init ()
   if (flag_bounds_check < 0)
     flag_bounds_check = flag_bounded_pointers;
 
+  /* If still unspecified, make it match pedantic && -std=c99.  */
+  if (mesg_implicit_function_declaration < 0)
+    {
+      if (pedantic && flag_isoc99)
+	mesg_implicit_function_declaration = flag_pedantic_errors ? 2 : 1;
+      else
+	mesg_implicit_function_declaration = 0;
+    }
+
   /* the beginning of the file is a new line; check for # */
   /* With luck, we discover the real source file's name from that
      and put it in input_filename.  */
===================================================================
Index: c-typeck.c
--- c-typeck.c	2000/07/12 20:15:20	1.77
+++ c-typeck.c	2000/07/18 02:05:27
@@ -1417,8 +1417,13 @@ build_external_ref (id, fun)
 	      /* Implicit declaration of built-in function.  Don't
 		 change the built-in declaration, but don't let this
 		 go by silently, either.  */
-	      pedwarn ("implicit declaration of function `%s'",
-		       IDENTIFIER_POINTER (DECL_NAME (decl)));
+	      if (mesg_implicit_function_declaration == 2)
+		error ("implicit declaration of function `%s'",
+		       IDENTIFIER_POINTER (id));
+	      else if (mesg_implicit_function_declaration == 1)
+		warning ("implicit declaration of function `%s'",
+			 IDENTIFIER_POINTER (id));
+
 	      C_DECL_ANTICIPATED (decl) = 0;  /* only issue this warning once */
 	      ref = decl;
 	    }
===================================================================
Index: c-tree.h
--- c-tree.h	2000/07/02 05:22:58	1.38
+++ c-tree.h	2000/07/18 02:10:23
@@ -393,6 +393,11 @@ extern int system_header_p;
 #define doing_objc_thang \
   (c_language == clk_objective_c)
 
+/* Nonzero means message about use of implicit function declarations;
+ 1 means warning; 2 means error. */
+
+extern int mesg_implicit_function_declaration;
+
 /* In c-decl.c */
 extern void finish_incomplete_decl PARAMS ((tree));
 
===================================================================
Index: testsuite/gcc.dg/c90-digraph-1.c
--- testsuite/gcc.dg/c90-digraph-1.c	2000/07/17 08:34:27	1.1
+++ testsuite/gcc.dg/c90-digraph-1.c	2000/07/18 02:05:27
@@ -2,7 +2,7 @@
    mode, but not in C90 mode.  Also check correct stringizing.
 */
 /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
-/* { dg-do run { xfail *-*-* } } */
+/* { dg-do run } */
 /* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
 
 #define str(x) xstr(x)
===================================================================
Index: testsuite/gcc.dg/c99-impl-decl-1.c
--- testsuite/gcc.dg/c99-impl-decl-1.c	2000/07/17 08:25:51	1.1
+++ testsuite/gcc.dg/c99-impl-decl-1.c	2000/07/18 02:05:27
@@ -6,8 +6,8 @@
 void
 foo (void)
 {
-  bar (); /* { dg-bogus "warning" "warning in place of error" } */
-  /* { dg-error "implicit" "C99 implicit declaration error" { xfail *-*-* } 9 } */
+  bar (); /* { dg-error "implicit" "C99 implicit declaration error" } */
+  /* { dg-bogus "warning" "warning in place of error" { target *-*-* } 9 } */ 
 }
 
 /* C90 subclause 7.1.7 says we can implicitly declare strcmp; C99 removes
@@ -17,5 +17,5 @@ int
 bar (const char *a, const char *b)
 {
   return strcmp (a, b); /* { dg-bogus "warning" "warning in place of error" } */
-  /* { dg-error "implicit" "C99 implicit declaration error" { target *-*-* } 19 } */
+ /* { dg-error "implicit" "C99 implicit declaration error" { target *-*-* } 19 } */ 
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]