mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-03 04:30:08 +08:00
ccc1651075
The C standard has required this since at least C99. A new scope should also be created for ifs, but that's currently breaking tests2/122_vla_reuse.
46 lines
1002 B
C
46 lines
1002 B
C
#include <stdio.h>
|
|
enum{ in = 0};
|
|
#define myassert(X) do{ if(!X) printf("%d: assertion failed\n", __LINE__); }while(0)
|
|
int main(){
|
|
#if 0
|
|
{
|
|
myassert(!in);
|
|
if(sizeof(enum{in=1})) myassert(in);
|
|
myassert(!in); //OOPS
|
|
}
|
|
#endif
|
|
{
|
|
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
|
|
}
|
|
|
|
}
|
|
|