This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
floods of spurious warnings with -traditional
- To: gcc-patches at gcc dot gnu dot org
- Subject: floods of spurious warnings with -traditional
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Mon, 22 May 2000 19:04:37 -0700
- Cc: Bernd Schmidt <bernds at cygnus dot co dot uk>
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,