public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Function signatures in extern "C".
@ 2020-09-06 15:22 Iain Sandoe
  2020-09-06 20:23 ` Jonathan Wakely
  0 siblings, 1 reply; 10+ messages in thread
From: Iain Sandoe @ 2020-09-06 15:22 UTC (permalink / raw)
  To: gcc; +Cc: Nathan Sidwell, Jason Merrill

Hi

g++.dg/abi/guard3.C

has:

extern "C" int __cxa_guard_acquire();

Which might not be a suitable declaration, depending on how the ‘extern  
“C”’ is supposed to affect the function signature generated.

IF, the extern C should make this parse as a “K&R” style function - then  
the TYPE_ARG_TYPES should be NULL (and the testcase is OK).

However, we are parsing the decl as int __cxa_guard_acquire(void) (i.e. C++  
rules on the empty parens), which makes the testcase not OK.

This means that the declaration is now misleading (and it’s just luck that  
expand_call happens to count the length of the TYPE_ARG_TYPES  list without  
looking to see what the types are) - in this case it happens to work out  
from this luck - since there’s only one arg so the length of the void args  
list agrees with what we want.

——

So .. the question is “which is wrong, the test-case or the assignment of  
the TYPE_ARG_TYPES”?

[we can’t easily diagnose this at this point, but I do have a patch to  
diagnose the case where we pass a void-list to expand_call and then try to  
expand a call to the callee with an inappropriate set of parms]

(it’s trivial to fix the test-case  as extern "C" int  
__cxa_guard_acquire(__UINT64_TYPE__ *);, I guess)

thanks
Iain


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-09-10  7:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-06 15:22 Function signatures in extern "C" Iain Sandoe
2020-09-06 20:23 ` Jonathan Wakely
2020-09-06 20:43   ` Iain Sandoe
2020-09-06 23:05     ` Nathan Sidwell
2020-09-07  8:16       ` Iain Sandoe
2020-09-07  9:27         ` Jonathan Wakely
2020-09-07  9:34           ` Jakub Jelinek
2020-09-07 10:29             ` Jonathan Wakely
2020-09-10  7:58             ` Florian Weimer
2020-09-07  9:38           ` Iain Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).