diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-09-06 05:08:54 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-09-05 22:31:09 +0200 |
| commit | 0737609cbddb4f36caf6d052e4be694557567623 (patch) | |
| tree | d65da3af5f37e7c5c0dc77c93e0c8e28bcc63d17 | |
| parent | 6aa0dd51b56f434162e806d50930f165c7804379 (diff) | |
| download | sparse-dev-0737609cbddb4f36caf6d052e4be694557567623.tar.gz | |
add testcases for missing return in last block
In this case the phi-node created for the return value
ends up with a missing operand, violating the semantic
of the phi-node: map one value with each predecessor.
Add testcases for these missing returns.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | validation/linear/missing-return0.c | 11 | ||||
| -rw-r--r-- | validation/linear/missing-return1.c | 16 | ||||
| -rw-r--r-- | validation/linear/missing-return2.c | 12 | ||||
| -rw-r--r-- | validation/linear/missing-return3.c | 19 | ||||
| -rw-r--r-- | validation/linear/missing-return4.c | 15 | ||||
| -rw-r--r-- | validation/linear/missing-return5.c | 24 |
6 files changed, 97 insertions, 0 deletions
diff --git a/validation/linear/missing-return0.c b/validation/linear/missing-return0.c new file mode 100644 index 00000000..d6019941 --- /dev/null +++ b/validation/linear/missing-return0.c @@ -0,0 +1,11 @@ +static int foo(int a) +{ + if (a) + return 1; +} + +/* + * check-name: missing-return0 + * check-command: sparse -vir -flinearize=last $file + * check-known-to-fail + */ diff --git a/validation/linear/missing-return1.c b/validation/linear/missing-return1.c new file mode 100644 index 00000000..c13135ad --- /dev/null +++ b/validation/linear/missing-return1.c @@ -0,0 +1,16 @@ +static inline int fun(int a) +{ + if (a) + return 1; +} + +static int foo(int a) +{ + return fun(a); +} + +/* + * check-name: missing-return1 + * check-command: sparse -vir -flinearize=last $file + * check-known-to-fail + */ diff --git a/validation/linear/missing-return2.c b/validation/linear/missing-return2.c new file mode 100644 index 00000000..c1959b6f --- /dev/null +++ b/validation/linear/missing-return2.c @@ -0,0 +1,12 @@ +static int foo(int a) +{ + switch (a) + case 3: + return 4; +} + +/* + * check-name: missing-return2 + * check-command: sparse -vir -flinearize=last $file + * check-known-to-fail + */ diff --git a/validation/linear/missing-return3.c b/validation/linear/missing-return3.c new file mode 100644 index 00000000..57a03a73 --- /dev/null +++ b/validation/linear/missing-return3.c @@ -0,0 +1,19 @@ +static int foo(int a) +{ + if (a) + return; +} + +static void ref(void) +{ +} + +/* + * check-name: missing-return3 + * check-command: sparse -vir -flinearize=last $file + * check-known-to-fail + * + * check-error-start +linear/missing-return3.c:4:17: error: return with no return value + * check-error-end + */ diff --git a/validation/linear/missing-return4.c b/validation/linear/missing-return4.c new file mode 100644 index 00000000..dd30988b --- /dev/null +++ b/validation/linear/missing-return4.c @@ -0,0 +1,15 @@ +static int foo(int a) +{ + int r = a; + r; +} + +/* + * check-name: missing-return4 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-error-ignore + * check-output-ignore + * check-output-contains: ret\\..*UNDEF + */ diff --git a/validation/linear/missing-return5.c b/validation/linear/missing-return5.c new file mode 100644 index 00000000..bcabd16a --- /dev/null +++ b/validation/linear/missing-return5.c @@ -0,0 +1,24 @@ +int foo(int p) +{ + if (p) + return 0; +} + +int bar(int p) +{ + if (p) + return 0; + p++; +} + +/* + * check-name: missing/undef return + * check-command: test-linearize -Wno-decl -fdump-ir=linearize $file + * check-known-to-fail + * + * check-output-ignore + * check-output-pattern(2): phi\\..*,.* + * check-output-pattern(2): phisrc\\..*\\$0 + * check-output-pattern(2): phisrc\\..*UNDEF + * check-output-excludes: ret\\..*\\$0 + */ |
