16684 – [3.4 Regression] GCC should not warn about redundant redeclarations of built-ins (original) (raw)

Description Alexander Kabaev 2004-07-23 03:26:07 UTC

Every built-in function is expected to have a matching prototype
in at least one header file and completely matching prototypes are
something that _should_ happen. Therefore, warning about that probably
does not serve any useful purpose but only generates an unwanted noice.

Environment: System: FreeBSD k8.dnsalias.net 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Mon Jul 12 00:28:33 EDT 2004 kan@k8.dnsalias.net:/usr/src/sys/amd64/compile/KAN amd64

<machine, os, target, libraries (multiple lines)>

host: x86_64-portbld-freebsd5.2 build: x86_64-portbld-freebsd5.2 target: x86_64-portbld-freebsd5.2 configured with: ./..//gcc-3.4-20040709/configure --disable-nls --with-system-zlib --with-libiconv-prefix=/usr/local --program-suffix=34 --with-gxx-include-dir=/usr/local/lib/gcc/x86_64-portbld-freebsd5.2/3.4.2/include/c++/ --disable-shared --disable-libgcj --prefix=/usr/local x86_64-portbld-freebsd5.2

How-To-Repeat: Simplified test case for amd64 (replace long long with int for i386):

% cat test.c void * malloc(unsigned long long size);

% gcc34 -save-temps -Wredundant-decls -c test.c test.c:1: warning: redundant redeclaration of 'malloc'

Comment 1 Alexander Kabaev 2004-07-23 03:26:07 UTC

Fix:

Disable warning if built-in function declaration is being redeclared
by normal declaration in user source files. 

Index: c-decl.c

RCS file: /usr/download/ncvs/src/contrib/gcc/c-decl.c,v retrieving revision 1.1.1.18 diff -u -r1.1.1.18 c-decl.c --- c-decl.c 21 Jun 2004 23:47:45 -0000 1.1.1.18 +++ c-decl.c 22 Jul 2004 01:55:22 -0000 @@ -1253,6 +1255,9 @@ definition. */ && !(TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))

Comment 2 Drea Pinski 2004-07-23 03:34:49 UTC

: Search converges between 2004-01-01-trunk (#437) and 2004-01-17-trunk (#438).

Confirmed, a regression from 3.3.3. Caused most likely by: 2004-01-10 Zack Weinberg <zack@codesourcery.com>

    * c-decl.c (duplicate_decls): Break apart into...
    (diagnose_arglist_conflict, validate_proto_after_old_defn)
    (locate_old_defn, diagnose_mismatched_decls, merge_decls):
    ... these new functions.  Restructure for comprehensibility.
    Remove various archaic special cases.  Always report the
    location of the previous declaration when a diagnostic is issued.
    (redeclaration_error_message): Fold into diagnose_mismatched_decls.
    (match_builtin_function_types): Delete unnecessary forward declaration.

patches as usually goto gcc-patches@gcc.gnu.org.

Comment 3 Zack Weinberg 2004-07-24 19:06:07 UTC

Subject: Re: (PR 16684) Patch to disable warning about redundant redeclaration of builtin

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

Comment 7 Zack Weinberg 2004-07-25 04:00:17 UTC

fixed in 3.5 now. will commit for 3.4 shortly.

Comment 8 Zack Weinberg 2004-07-25 04:00:51 UTC

grar stupid new/assigned thing never works the way i think it does.

Comment 9 Zack Weinberg 2004-07-25 04:24:15 UTC

3.4 branch commit message seems to have gone off into the weeds. Oh well. It's in now.