Bug 9601 - -mrtd switch/stdcall attribute raises warnings for __buitltin functions
Summary: -mrtd switch/stdcall attribute raises warnings for __buitltin functions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2003-02-06 20:16 UTC by Danny Smith
Modified: 2011-04-11 17:50 UTC (History)
2 users (show)

See Also:
Host:
Target: i?86-*-* x86_64-*-* (-m32)
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-09-20 08:12:19


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Danny Smith 2003-02-06 20:16:00 UTC
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.
Comment 1 Danny Smith 2003-02-06 20:16:00 UTC
Fix:
Unknown.  If declarations are in system headers, then the
#pragma GCC system_header disables the warnings for GCC >= 3.
Comment 2 Dara Hazeghi 2003-05-26 20:14:42 UTC
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
Comment 3 Andrew Pinski 2003-05-26 20:35:51 UTC
See Dara's comment.
Comment 4 Dara Hazeghi 2003-07-11 15:03:36 UTC
Branch and mainline (20030711)
Comment 5 Francois-Xavier Coudert 2006-09-20 08:12:19 UTC
> 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.
Comment 6 Kai Tietz 2011-04-11 17:44:08 UTC
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
Comment 7 Kai Tietz 2011-04-11 17:50:08 UTC
Fixed.