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]

floods of spurious warnings with -traditional


With current CVS, any program compiled with -traditional gets a flood
of spurious warnings, one for each builtin function.  For example:

<built-in>:0: warning: type of external `__builtin_constant_p' is not global

This is nonsense.  The type it's referring to is the type of the
return value.  For __builtin_constant_p, that type is int, which had
better be globally visible :)

This was introduced by the change

Mon Oct 18 02:38:46 1999  Bernd Schmidt  <bernds@cygnus.co.uk>

        * c-decl.c (pushdecl): Use TYPE_CONTEXT rather than TREE_PERMANENT.

which changed the value tested, but didn't realize that the new and
old values had opposite truth.

I propose the following patch and test case, which is being
bootstrapped even as we speak.  It makes gcc.dg/tradpaste.c stop
failing; the bug that was intended to test was fixed some time ago,
but the fix has been masked by these spurious warnings.

zw

	* c-decl.c (pushdecl): Invert sense of test for non-global
	types.

===================================================================
Index: testsuite/gcc.dg/ext-glob.c
--- testsuite/gcc.dg/ext-glob.c	Tue May  5 13:32:27 1998
+++ testsuite/gcc.dg/ext-glob.c	Mon May 22 18:59:53 2000
@@ -0,0 +1,18 @@
+/* Test for the warning about external functions with non-global
+   types.  In -traditional mode, these functions are globally visible
+   even if declared in an inner scope, so their return types should
+   also be visible.  */
+
+/* { dg-do compile } */
+/* { dg-options -traditional } */
+
+int
+main ()
+{
+  struct foo { int a, b; };
+
+  extern struct foo *bar();  /* { dg-warning "type of external" "good warn" } */
+  extern int baz();	     /* { dg-bogus   "type of external" "bad warn"  } */
+
+  return 0;
+}
===================================================================
Index: c-decl.c
--- c-decl.c	2000/05/18 17:53:04	1.111
+++ c-decl.c	2000/05/23 01:59:56
@@ -2202,7 +2202,7 @@ pushdecl (x)
 	    {
 	      if (type == error_mark_node)
 		break;
-	      if (! TYPE_CONTEXT (type))
+	      if (TYPE_CONTEXT (type))
 		{
 		  warning_with_decl (x, "type of external `%s' is not global");
 		  /* By exiting the loop early, we leave TYPE nonzero,



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