diff options
author | Bob Duff <duff@adacore.com> | 2022-10-13 17:12:18 -0400 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2022-11-07 09:36:34 +0100 |
commit | 27345558cce16e849884f5d1d4dd7d88974bb724 (patch) | |
tree | e1da88c7d858d017fb054aa7a502e3085beacde8 /gcc | |
parent | b86ff061234ff42934bc08c5dc1ba041724eba22 (diff) | |
download | gcc-27345558cce16e849884f5d1d4dd7d88974bb724.zip gcc-27345558cce16e849884f5d1d4dd7d88974bb724.tar.gz gcc-27345558cce16e849884f5d1d4dd7d88974bb724.tar.bz2 |
ada: Fix inherited postconditions in inlined subprograms
Protect the building of postcondition pragmas in case the
postcondition is not present due to inlining.
gcc/ada/
* freeze.adb
(Build_Inherited_Condition_Pragmas): Do nothing if A_Post is
empty.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/freeze.adb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 888e2ec..1fdc9d0 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -1718,11 +1718,16 @@ package body Freeze is end; end if; - New_Prag := New_Copy_Tree (A_Post); - Rewrite - (Expression (First (Pragma_Argument_Associations (New_Prag))), - Class_Post); - Append (New_Prag, Decls); + -- A_Post can be null here if the postcondition was inlined in the + -- called subprogram. + + if Present (A_Post) then + New_Prag := New_Copy_Tree (A_Post); + Rewrite + (Expression (First (Pragma_Argument_Associations (New_Prag))), + Class_Post); + Append (New_Prag, Decls); + end if; end if; end Build_Inherited_Condition_Pragmas; |