diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-09-08 12:23:21 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-09-08 16:50:32 +0200 |
commit | f43d375657f22cf69668a417f555fcc7a0a780d5 (patch) | |
tree | 5a5dfee67c24b704391d59bf09afe0f74e0b9f61 | |
parent | 20042e2851a6ff07232f1a5ac3da4413499bc4d3 (diff) | |
download | sparse-f43d375657f22cf69668a417f555fcc7a0a780d5.tar.gz |
add testcase for non-constant switch-case
Switches with non-constant cases are currently linearized
using as value the bit pattern present in the expression,
creating more or less random multijmps.
Add a basic testcase to catch this.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | validation/linear/non-const-case.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/validation/linear/non-const-case.c b/validation/linear/non-const-case.c new file mode 100644 index 00000000..5cf55717 --- /dev/null +++ b/validation/linear/non-const-case.c @@ -0,0 +1,38 @@ +static int foo(int a) +{ + switch (a) { + case 0: + return a; + case a: + return 0; + case (a - a): + return 1; + default: + return a; + } +} + +static int bar(int a) +{ + switch (a) { + case 0: + break; + case a: + a++; +label: + return a; + } + + goto label; +} + + +/* + * check-name: non-const-case + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-error-ignore + * check-output-ignore + * check-output-excludes:switch \\. + */ |