diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/PCH/stmts.h | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/PCH/stmts.h')
-rw-r--r-- | clang/test/PCH/stmts.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/clang/test/PCH/stmts.h b/clang/test/PCH/stmts.h new file mode 100644 index 0000000..4267e2c --- /dev/null +++ b/clang/test/PCH/stmts.h @@ -0,0 +1,96 @@ +// Header for PCH test stmts.c + +void f0(int x) { + // NullStmt + ; + // IfStmt + if (x) { + } else if (x + 1) { + } + + switch (x) { + case 0: + x = 17; + break; + + case 1: + break; + + default: + switch (x >> 1) { + case 7: + // fall through + case 9: + break; + } + x += 2; + break; + } + + while (x > 20) { + if (x > 30) { + --x; + continue; + } else if (x < 5) + break; + else + goto done; + } + + do { + x++; + } while (x < 10); + + almost_done: + for (int y = x; y < 20; ++y) { + if (x + y == 12) + return; + else if (x - y == 7) + goto almost_done; + } + + done: + x = x + 2; + + int z = x, *y, j = 5; +} + +int f1(int x) { + switch (x) { + case 17: + return 12; + + default: + break; + } + + // variable-length array + int array[x * 17 + 3]; + + return x*2; +} + +const char* what_is_my_name(void) { return __func__; } + +int computed_goto(int x) { + start: + x = x << 1; + void *location = &&start; + + if (x > 17) + location = &&done; + + while (x > 12) { + --x; + if (x == 15) + goto *location; + } + + done: + return 5; +} + +#define maxint(a,b) ({int _a = (a), _b = (b); _a > _b ? _a : _b; }) +int weird_max(int x, int y) { + return maxint(++x, --y); +} |