From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 969903858035; Mon, 7 Nov 2022 08:39:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 969903858035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667810393; bh=AKJU2Iu73PeSgVxDTHUuSQL9VEjoH7Tro2zA9VMvlS0=; h=From:To:Subject:Date:From; b=QpsuBG/wtZrWi5yAWHkD+GYot1UvRnmE2Gks+W/90ulAsxDcuJMh/FlfNyEvYARn7 aT1JvWuoW+1Lsi8LpBL5XbUFPdBMdYO3z7QbnW1RooxzkJSZQawFpkGnRLNlbRcZkN IsHG1elPbR1CKuKzdLm3wOTI5QhLW+nQ4wp45PUE= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3740] ada: Fix inherited postconditions in inlined subprograms X-Act-Checkin: gcc X-Git-Author: Bob Duff X-Git-Refname: refs/heads/master X-Git-Oldrev: b86ff061234ff42934bc08c5dc1ba041724eba22 X-Git-Newrev: 27345558cce16e849884f5d1d4dd7d88974bb724 Message-Id: <20221107083953.969903858035@sourceware.org> Date: Mon, 7 Nov 2022 08:39:53 +0000 (GMT) List-Id: https://gcc.gnu.org/g:27345558cce16e849884f5d1d4dd7d88974bb724 commit r13-3740-g27345558cce16e849884f5d1d4dd7d88974bb724 Author: Bob Duff Date: Thu Oct 13 17:12:18 2022 -0400 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. Diff: --- gcc/ada/freeze.adb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 888e2ecb7af..1fdc9d0d60e 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;