This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug c/16684] New: GCC should not warn about redundant redeclarations of built-ins



	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'
------- Additional Comments From kan at FreeBSD dot ORG  2004-07-23 03:26 -------
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))
+      /* Don't warn about redundant redeclarations of builtins. */
+      && !(TREE_CODE (newdecl) == FUNCTION_DECL
+	   && !DECL_BUILT_IN (newdecl) && DECL_BUILT_IN (olddecl))
       /* Don't warn about an extern followed by a definition.  */
       && !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl))
       /* Don't warn about forward parameter decls.  */

-- 
           Summary: GCC should not warn about redundant redeclarations of
                    built-ins
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kan at FreeBSD dot ORG
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-portbld-freebsd5.2
  GCC host triplet: x86_64-portbld-freebsd5.2
GCC target triplet: x86_64-portbld-freebsd5.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16684


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