From: Matthias Braun Date: Mon, 14 Jul 2008 14:26:30 +0000 (+0000) Subject: some more testcases I had lying around here X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=b43672c3e931836e6a7e18b0bfb799ac4c419a56;p=cparser some more testcases I had lying around here [r20451] --- diff --git a/parsetest/designators2.c b/parsetest/designators2.c new file mode 100644 index 0000000..b5f7950 --- /dev/null +++ b/parsetest/designators2.c @@ -0,0 +1,15 @@ +#include + +typedef struct blub { + int i; + char a[4]; +} blub; + +blub a = { .a[2] = 2, 3, .i = 23 }; + +int main(void) +{ + assert(a.a[2] == 2); + assert(a.a[3] == 3); + return 0; +} diff --git a/parsetest/should_warn/prototype.c b/parsetest/should_warn/prototype.c new file mode 100644 index 0000000..3d56391 --- /dev/null +++ b/parsetest/should_warn/prototype.c @@ -0,0 +1,5 @@ +int foo(); + +int main(void) { + return 0; +} diff --git a/parsetest/should_warn/prototype2.c b/parsetest/should_warn/prototype2.c new file mode 100644 index 0000000..6f027ed --- /dev/null +++ b/parsetest/should_warn/prototype2.c @@ -0,0 +1,6 @@ +int main(argc, argv) + int argc; + char **argv; +{ + return 0; +} diff --git a/parsetest/statics.c b/parsetest/statics.c new file mode 100644 index 0000000..6be77c3 --- /dev/null +++ b/parsetest/statics.c @@ -0,0 +1,22 @@ +int printf(const char *str, ...); + +void f(void) +{ + static int k = 42; + { + static int k = 13; + ++k; + printf("%d ", k); + } + --k; + printf("%d\n", k); +} + +int main(void) +{ + f(); + f(); + f(); + f(); + return 0; +} diff --git a/parsetest/whiles.c b/parsetest/whiles.c new file mode 100644 index 0000000..eae7888 --- /dev/null +++ b/parsetest/whiles.c @@ -0,0 +1,54 @@ +int a,b,c; + +int f1(void) { + while(a < 10) + return 0; + return 42; +} + +int f2(void) { + while(0) { + return 42; + } + return 0; +} + +int f3(void) { + while(f2()); + return 0; +} + +int f5(void) { + while(0); + return 0; +} + +int f4(void) { + goto label; + + while(0) { +label: + return 0; + } + return 42; +} + +int f6(void) { + return 0; + + while(0); +} + +int f7(void) { + while(1) { + return 0; + } +} + +int endless(void) { + while(1); +} + +int main(void) { + return f1() + f2() + f3() + f4() + f5() * f6() + f7(); +}