This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: (PR 16684) Patch to disable warning about redundantredeclaration of builtin
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Alexander Kabaev <kan at freebsd dot org>
- Cc: gcc-patches at gcc dot gnu dot org, gcc-bugzilla at gcc dot gnu dot org
- Date: Sat, 24 Jul 2004 12:06:01 -0700
- Subject: Re: (PR 16684) Patch to disable warning about redundantredeclaration of builtin
- References: <20040723034537.GA30167@freefall.freebsd.org>
Alexander Kabaev <kan@freebsd.org> writes:
> I tried to describe the problem in bug c/16684 titled "[3.4/3.5
> Regression] GCC should not warn about redundant redeclarations of
> built-ins". The patch below suppresses the warning if redundant
> declaration matches builtin function type exactly. The patch is
> against gcc 3.4 branch.
I am testing the following slight revision against mainline, and will
apply it there if successful. Since it's a regression, I will also
test and apply to 3.4 branch, but only if mainline is happy.
zw
2004-07-21 Alexander Kabaev <kan@freebsd.org>
PR 16684
* c-decl.c (diagnose_mismatched_decls): Don't issue a
redundant-declaration warning the first time a builtin is
declared explicitly.
testsuite:
* gcc.dg/Wredundant-decls-1.c: New test case.
===================================================================
Index: c-decl.c
--- c-decl.c 23 Jul 2004 19:22:08 -0000 1.536
+++ c-decl.c 24 Jul 2004 19:04:07 -0000
@@ -1444,6 +1444,11 @@ diagnose_mismatched_decls (tree newdecl,
definition. */
&& !(TREE_CODE (newdecl) == FUNCTION_DECL
&& DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))
+ /* Don't warn about redundant redeclarations of builtins. */
+ && !(TREE_CODE (newdecl) == FUNCTION_DECL
+ && !DECL_BUILT_IN (newdecl)
+ && DECL_BUILT_IN (olddecl)
+ && !C_DECL_DECLARED_BUILTIN (olddecl))
/* Don't warn about an extern followed by a definition. */
&& !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl))
/* Don't warn about forward parameter decls. */
===================================================================
Index: testsuite/gcc.dg/Wredundant-decls-1.c
--- testsuite/gcc.dg/Wredundant-decls-1.c 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/Wredundant-decls-1.c 24 Jul 2004 19:04:08 -0000
@@ -0,0 +1,7 @@
+/* PR 16684: no redundant declaration warnings should issue the first
+ time a built-in function is declared.
+ { dg-do compile }
+ { dg-options "-Wredundant-decls" } */
+
+void *malloc (__SIZE_TYPE__); /* { dg-bogus "redundant" } */
+void *malloc (__SIZE_TYPE__); /* { dg-warning "redundant" } */