aboutsummaryrefslogtreecommitdiff
path: root/tinycc/tests/tests2/129_scopes.c
diff options
context:
space:
mode:
Diffstat (limited to 'tinycc/tests/tests2/129_scopes.c')
-rw-r--r--tinycc/tests/tests2/129_scopes.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tinycc/tests/tests2/129_scopes.c b/tinycc/tests/tests2/129_scopes.c
new file mode 100644
index 0000000..b63b682
--- /dev/null
+++ b/tinycc/tests/tests2/129_scopes.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+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
+ }
+
+}
+