diff options
author | Richard Biener <rguenther@suse.de> | 2025-01-07 15:11:47 +0100 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2025-01-08 08:21:50 +0100 |
commit | 640b550425180bdab7bc67edc6a48465f4023888 (patch) | |
tree | a0dc47feb8afe0e7d9adc3ee807f07f1ef5a5445 /gcc | |
parent | 2dd4eb15b63ca1f20a637e8b26567d5064a43a4f (diff) | |
download | gcc-640b550425180bdab7bc67edc6a48465f4023888.zip gcc-640b550425180bdab7bc67edc6a48465f4023888.tar.gz gcc-640b550425180bdab7bc67edc6a48465f4023888.tar.bz2 |
middle-end/118325 - nonlocal goto lowering
When nonlocal goto lowering creates an artificial label it fails
to adjust its context.
PR middle-end/118325
* tree-nested.cc (convert_nl_goto_reference): Assign proper
context to generated artificial label.
* gcc.dg/pr118325.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/pr118325.c | 16 | ||||
-rw-r--r-- | gcc/tree-nested.cc | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr118325.c b/gcc/testsuite/gcc.dg/pr118325.c new file mode 100644 index 0000000..74f92cc --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr118325.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu17 -fchecking" } */ + +void f(void*); + +void z() +{ + void g() + { + __label__ out; + int h(void) { goto out; } + f(h); + out:; + } + f(g); +} diff --git a/gcc/tree-nested.cc b/gcc/tree-nested.cc index d538c8d..8d75a2f 100644 --- a/gcc/tree-nested.cc +++ b/gcc/tree-nested.cc @@ -2694,6 +2694,7 @@ convert_nl_goto_reference (gimple_stmt_iterator *gsi, bool *handled_ops_p, { new_label = create_artificial_label (UNKNOWN_LOCATION); DECL_NONLOCAL (new_label) = 1; + DECL_CONTEXT (new_label) = target_context; *slot = new_label; } else |