public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-2149] [Ada] Fix on computation of packed array size in case of error Date: Thu, 8 Jul 2021 13:36:39 +0000 (GMT) [thread overview] Message-ID: <20210708133639.4EB26398B87C@sourceware.org> (raw) https://gcc.gnu.org/g:242c0f4772c6697ba0b27853f153a13970bbded9 commit r12-2149-g242c0f4772c6697ba0b27853f153a13970bbded9 Author: Yannick Moy <moy@adacore.com> Date: Wed May 26 10:49:14 2021 +0200 [Ada] Fix on computation of packed array size in case of error gcc/ada/ * layout.adb (Layout_Type): Add guard before calling Expr_Value. Diff: --- gcc/ada/layout.adb | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/gcc/ada/layout.adb b/gcc/ada/layout.adb index cbc296a6e45..ee8e281785e 100644 --- a/gcc/ada/layout.adb +++ b/gcc/ada/layout.adb @@ -513,18 +513,28 @@ package body Layout is begin Get_Index_Bounds (First_Index (E), Lo, Hi); - Siz := (Expr_Value (Hi) - Expr_Value (Lo) + 1) - * Component_Size (E); - -- Do not overwrite a different value of 'Size specified - -- explicitly by the user. In that case, also do not set Esize. + -- Even if the bounds are known at compile time, they could + -- have been replaced by an error node. Check each bound + -- explicitly. - if Unknown_RM_Size (E) or else RM_Size (E) = Siz then - Set_RM_Size (E, Siz); + if Compile_Time_Known_Value (Lo) + and then Compile_Time_Known_Value (Hi) + then + Siz := (Expr_Value (Hi) - Expr_Value (Lo) + 1) + * Component_Size (E); + + -- Do not overwrite a different value of 'Size specified + -- explicitly by the user. In that case, also do not set + -- Esize. - if Unknown_Esize (E) then - Siz := ((Siz + (Abits - 1)) / Abits) * Abits; - Set_Esize (E, Siz); + if Unknown_RM_Size (E) or else RM_Size (E) = Siz then + Set_RM_Size (E, Siz); + + if Unknown_Esize (E) then + Siz := ((Siz + (Abits - 1)) / Abits) * Abits; + Set_Esize (E, Siz); + end if; end if; end if; end;
reply other threads:[~2021-07-08 13:36 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210708133639.4EB26398B87C@sourceware.org \ --to=pmderodat@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).