tinycc/tests/tests2/120_alias.c
Michael Matz 78da4586a0 Fix tests2/120_alias.c on macos
While MacOS doesn't natively support the alias attribute, let's support
it with TCC anyway.  This means we need to make a decision if the
string in the alias attribute is decorated or not due to the implicit
underscore on MacOS.  To make life easier we decide that it's the C name,
i.e. without underscore, and so TCC needs to emit alias names with
underscore handling.

Irrespective of that the test case needs to deal with the underscore
itself for __asm__ renaming which is always requiring the assembler name.
2020-10-01 18:03:56 +02:00

30 lines
722 B
C

/* Check semantics of various constructs to generate renamed symbols. */
extern int printf (const char *, ...);
void target(void);
void target(void) {
printf("in target function\n");
}
void alias_for_target(void) __attribute__((alias("target")));
#ifdef __leading_underscore
void asm_for_target(void) __asm__("_target");
#else
void asm_for_target(void) __asm__("target");
#endif
/* This is not supposed to compile, alias targets must be defined in the
same unit. In TCC they even must be defined before the reference
void alias_for_undef(void) __attribute__((alias("undefined")));
*/
extern void inunit2(void);
int main(void)
{
target();
alias_for_target();
asm_for_target();
inunit2();
return 0;
}