|
From: | Petr Skocik |
Subject: | [Tinycc-devel] Fixing nonconformant scoping |
Date: | Sun, 5 Mar 2023 22:49:36 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 |
#include <stdio.h>Fors are done correctly.
enum{ in = 0};
#define myassert(X) do{ if(!X) printf("%d: assertion failed\n", __LINE__); }while(0)
int main(){
{
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
}
}
[Prev in Thread] | Current Thread | [Next in Thread] |