A goto done into an piece of code discarded at expand or linearize time will produce an invalid IR. Add a testcase for it. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- validation/label-stmt-expr1.c | 30 +++++++++++++++++++++++++ validation/linear/goto-and-expr-stmt0.c | 28 +++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 validation/label-stmt-expr1.c create mode 100644 validation/linear/goto-and-expr-stmt0.c diff --git a/validation/label-stmt-expr1.c b/validation/label-stmt-expr1.c new file mode 100644 index 000000000000..47ba54ae7305 --- /dev/null +++ b/validation/label-stmt-expr1.c @@ -0,0 +1,30 @@ +static int foo(void) +{ + goto l; + return ({ +l: + 0; + }); +} + +static void bar(void) +{ + int r; + r = ({ +l: + 0; + }); + goto l; +} + +/* + * check-name: label-stmt-expr1 + * check-known-to-fail + * + * check-error-start +label-stmt-expr1.c:3:9: error: goto into statement expression +label-stmt-expr1.c:5:1: label 'l' is defined here +label-stmt-expr1.c:17:9: error: goto into statement expression +label-stmt-expr1.c:14:1: label 'l' is defined here + * check-error-end + */ diff --git a/validation/linear/goto-and-expr-stmt0.c b/validation/linear/goto-and-expr-stmt0.c new file mode 100644 index 000000000000..548813531779 --- /dev/null +++ b/validation/linear/goto-and-expr-stmt0.c @@ -0,0 +1,28 @@ +int t(void) +{ + goto inside; + return 1 ? 2 : ({ +inside: + return 3; + 4; + }); +} + +void f(int x, int y) +{ + 1 ? x : ({ +a: + y; + }); + goto a; +} + +/* + * check-name: goto-and-expr-stmt0 + * check-command: test-linearize -Wno-decl $file + * check-known-to-fail + * + * check-output-ignore + * check-output-excludes: END + * check-error-ignore + */ -- 2.26.0