diff options
author | Steve Baird <baird@adacore.com> | 2025-01-30 13:28:50 -0800 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2025-06-05 10:18:37 +0200 |
commit | 429628e9d38663b15b919d65ef5db8a6e85db89f (patch) | |
tree | f2796b31bb4d38fb682d5c9f612ed04eccca0540 | |
parent | 9fc6eedace2607c5e322f4b874f290975f0d2b0e (diff) | |
download | gcc-429628e9d38663b15b919d65ef5db8a6e85db89f.zip gcc-429628e9d38663b15b919d65ef5db8a6e85db89f.tar.gz gcc-429628e9d38663b15b919d65ef5db8a6e85db89f.tar.bz2 |
ada: Exception-raising loop incorrectly eliminated
If the body of a loop includes a raise statement then the loop should not be
considered to be free of side-effects and therefore eligible for elimination
by the compiler.
gcc/ada/ChangeLog:
* sem_util.adb
(Side_Effect_Free_Statements): Return False if the statement list
includes an explicit (i.e. Comes_From_Source) raise statement.
-rw-r--r-- | gcc/ada/sem_util.adb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index ce54dea..97dc4c0 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -12425,9 +12425,14 @@ package body Sem_Util is while Present (Node) loop case Nkind (Node) is - when N_Null_Statement | N_Call_Marker | N_Raise_xxx_Error => + when N_Null_Statement | N_Call_Marker => null; + when N_Raise_xxx_Error => + if Comes_From_Source (Node) then + return False; + end if; + when N_Object_Declaration => if Present (Expression (Node)) and then not Side_Effect_Free (Expression (Node)) |