Using the -mrtd switch or declaring standard library functions with __attribute__ ((stdcall)) raise warnings about builtin functions. Warnings are emitted only when compiled as C, not C++ This testcase (test-mrtd.c) =====begin====== /* test-mrtd.c */ double __attribute__((cdecl)) sqrt (double); double __attribute__((stdcall)) log (double); double cos (double); =====-end======= Using -mrtd switch: D:\TEMP>gcc -c -mrtd test-mrtd.c test-mrtd.c:1: warning: conflicting types for built-in function `sqrt' test-mrtd.c:3: warning: conflicting types for built-in function `cos' while, using C (cdecl) convention as default D:\TEMP>gcc -c test-mrtd.c test-mrtd.c:2: warning: conflicting types for built-in function `log' Looking at assembly for code that actually uses the declared functions, it appears that the cdecl (C) calling convention is used for functions with builtin versions, regardless of the attribute on the declaration. This is not a regression. The same problem occurs in 2.95. Release: gcc version 3.4 20030130 (experimental) Environment: i386-pc-mingw32, NT4-sp6 How-To-Repeat: Testcase in description.
Fix: Unknown. If declarations are in system headers, then the #pragma GCC system_header disables the warnings for GCC >= 3.
Hello, I can confirm this behavior on gcc 3.2.3, 3.3 branch and mainline (20030524) on i686-linux. With -mrtd I get: junk.c:1: warning: conflicting types for built-in function `sqrt' without -mrtd I get: junk.c:2: warning: conflicting types for built-in function `log' Either way, this behavior seems wrong. Dara
See Dara's comment.
Branch and mainline (20030711)
> double __attribute__((cdecl)) sqrt (double); > double __attribute__((stdcall)) log (double); > double cos (double); With this code, we still (gcc-4.2) get: $ gcc -c -W -Wall -mrtd b.c b.c:1: warning: conflicting types for built-in function ‘sqrt’ $ gcc -c -W -Wall b.c b.c:2: warning: conflicting types for built-in function ‘log’ This is not related to mingw32, as the same warnings happen on i386-pc-mingw32 and i686-pc-linux-gnu.
Author: ktietz Date: Mon Apr 11 17:44:04 2011 New Revision: 172268 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172268 Log: 2011-04-11 Kai Tietz <ktietz@redhat.com> PR target/9601 PR target/11772 * config/i386/i386-protos.h (ix86_get_callcvt): New prototype. * config/i386/i386.c (ix86_handle_cconv_attribute): Adjust comment. (ix86_is_msabi_thiscall): Removed. (ix86_is_type_thiscall): Likewise. (ix86_get_callcvt): New function. (ix86_comp_type_attributes): Simplify check. (ix86_function_regparm): Use ix86_get_callcvt for calling convention attribute checks. (ix86_return_pops_args): Likewise. (ix86_static_chain): Likewise. (x86_this_parameter): Likewise. (x86_output_mi_thunk): Likewise. (ix86_function_type_abi): Optimize check for types without attributes. * config/i386/i386.h (IX86_CALLCVT_CDECL, IX86_CALLCVT_STDCALL, IX86_CALLCVT_FASTCALL, IX86_CALLCVT_THISCALL, IX86_CALLCVT_REGPARM, IX86_CALLCVT_SSEREGPARM): New macros to represent calling convention by flag-values. (IX86_BASE_CALLCVT): Helper macro. * config/i386/netware.c (i386_nlm_maybe_mangle_decl_assembler_name): Use ix86_get_callcvt for calling convention attribute checks and avoid symbol-decoration for stdcall in TARGET_RTD case. * config/i386/winnt.c (i386_pe_maybe_mangle_decl_assembler_name): Likewise. (gen_stdcall_or_fastcall_suffix): Adjust ident and use DECL_ORIGIN for declaration. Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386-protos.h trunk/gcc/config/i386/i386.c trunk/gcc/config/i386/i386.h trunk/gcc/config/i386/netware.c trunk/gcc/config/i386/winnt.c
Fixed.