forked from iains/gcc-14-branch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
c++: computed goto from catch block [PR81438]
As with 37722, we don't clean up the exception object if a computed goto leaves a catch block, but we can warn about that. PR c++/81438 gcc/cp/ChangeLog: * decl.cc (poplevel_named_label_1): Handle leaving catch. (check_previous_goto_1): Likewise. (check_goto_1): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/label15.C: Require indirect_jumps. * g++.dg/ext/label16.C: New test.
- Loading branch information
Showing
3 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// PR c++/81438 | ||
// { dg-do compile { target indirect_jumps } } | ||
// { dg-options "" } | ||
|
||
bool b; | ||
int main() | ||
{ | ||
try | ||
{ | ||
try { throw 3; } | ||
catch(...) { | ||
h:; // { dg-warning "jump to label" } | ||
try { throw 7; } | ||
catch(...) { | ||
if (b) | ||
goto *&&h; // { dg-message "computed goto" } | ||
// { dg-message "handled exception" "" { target *-*-* } .-1 } | ||
else | ||
goto *&&g; // { dg-message "computed goto" } | ||
// { dg-message "handled exception" "" { target *-*-* } .-1 } | ||
} | ||
g:; // { dg-warning "jump to label" } | ||
throw; | ||
} | ||
} | ||
catch(int v) | ||
{ | ||
__builtin_printf("%d\n", v); | ||
if(v != 3) // 7 because we don't clean up the catch on | ||
__builtin_abort(); // computed goto | ||
} | ||
|
||
return 0; | ||
} |