mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-22 21:04:19 +08:00
Some checks are pending
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
... see tests Also: - tccgen.c: cleanup _Generic a little - libtcc.c: cleanup mem-debug a little - arm-link.c: read/write only once - tcc.h: another fix for clang offsetof - tccdbg.c: * stabs: handle forward struct/enum decls * stabs: fix anonymous struct members (must not have a .L123 name) * avoid strncpy()
87 lines
1.6 KiB
C
87 lines
1.6 KiB
C
int printf(const char*, ...);
|
|
|
|
#define myassert(x) \
|
|
printf("%s:%d: %s : \"%s\"\n", __FILE__,__LINE__,(x)?"ok":"error",#x)
|
|
|
|
enum{ in = 0};
|
|
|
|
int main_1(){
|
|
{
|
|
myassert(!in);
|
|
if(sizeof(enum{in=1})) myassert(in);
|
|
myassert(!in); //OOPS
|
|
}
|
|
{
|
|
myassert(!in);
|
|
switch(sizeof(enum{in=1})) { default: myassert(in); }
|
|
myassert(!in); //OOPS
|
|
}
|
|
{
|
|
myassert(!in);
|
|
while(sizeof(enum{in=1})) { myassert(in); break; }
|
|
myassert(!in); //OOPS
|
|
}
|
|
{
|
|
myassert(!in);
|
|
do{ myassert(!in);}while(0*sizeof(enum{in=1}));
|
|
myassert(!in); //OOPS
|
|
}
|
|
|
|
{
|
|
myassert(!in);
|
|
for(sizeof(enum{in=1});;){ myassert(in); break; }
|
|
myassert(!in); //OK
|
|
}
|
|
{
|
|
myassert(!in);
|
|
for(;;sizeof(enum{in=1})){ myassert(in); break; }
|
|
myassert(!in); //OK
|
|
}
|
|
{
|
|
myassert(!in);
|
|
for(;sizeof(enum{in=1});){ myassert(in); break; }
|
|
myassert(!in); //OK
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/* --------------------------------------------- */
|
|
int main_2()
|
|
{
|
|
char c = 'a';
|
|
void func1(char c); /* param 'c' must not shadow local 'c' */
|
|
func1(c);
|
|
return 0;
|
|
}
|
|
|
|
void func1(char c)
|
|
{
|
|
myassert(c == 'a');
|
|
}
|
|
|
|
struct st { int a; };
|
|
|
|
/* --------------------------------------------- */
|
|
int main_3()
|
|
{
|
|
struct st func(void);
|
|
struct st st = func(); /* not an 'incompatible redefinition' */
|
|
myassert(st.a == 10);
|
|
return 0;
|
|
}
|
|
|
|
struct st func(void)
|
|
{
|
|
struct st st = { 10 };
|
|
return st;
|
|
}
|
|
|
|
/* --------------------------------------------- */
|
|
int main()
|
|
{
|
|
main_1();
|
|
main_2();
|
|
main_3();
|
|
return 0;
|
|
}
|