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-1623] [Ada] Fix asymmetries in detection of overlapping actuals Date: Fri, 18 Jun 2021 08:38:40 +0000 (GMT) [thread overview] Message-ID: <20210618083840.5D7C839B4423@sourceware.org> (raw) https://gcc.gnu.org/g:7120f082181be2fc8cfc4f121809da71d2554503 commit r12-1623-g7120f082181be2fc8cfc4f121809da71d2554503 Author: Piotr Trojanek <trojanek@adacore.com> Date: Tue Mar 16 18:38:53 2021 +0100 [Ada] Fix asymmetries in detection of overlapping actuals gcc/ada/ * sem_warn.adb (Warn_On_Overlapping_Actuals): Examine types of both formal parameters; refactor a complex detection of by-reference types. Diff: --- gcc/ada/sem_warn.adb | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index b7abd1b7ab1..4ec96fc3c9d 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -3669,6 +3669,9 @@ package body Sem_Warn is --------------------------------- procedure Warn_On_Overlapping_Actuals (Subp : Entity_Id; N : Node_Id) is + function Explicitly_By_Reference (Formal_Id : Entity_Id) return Boolean; + -- Returns True iff the type of Formal_Id is explicitly by-reference + function Refer_Same_Object (Act1 : Node_Id; Act2 : Node_Id) return Boolean; @@ -3680,6 +3683,24 @@ package body Sem_Warn is -- object_name is known to refer to the same object as the other name -- (RM 6.4.1(6.11/3)) + ----------------------------- + -- Explicitly_By_Reference -- + ----------------------------- + + function Explicitly_By_Reference + (Formal_Id : Entity_Id) + return Boolean + is + Typ : constant Entity_Id := Underlying_Type (Etype (Formal_Id)); + begin + if Present (Typ) then + return Is_By_Reference_Type (Typ) + or else Convention (Typ) = Convention_Ada_Pass_By_Reference; + else + return False; + end if; + end Explicitly_By_Reference; + ----------------------- -- Refer_Same_Object -- ----------------------- @@ -3792,17 +3813,13 @@ package body Sem_Warn is then null; - -- If type is explicitly not by-copy, assume that - -- aliasing is intended. + -- If type is explicitly by-reference, then it is not + -- covered by the legality rule, which only applies to + -- elementary types. Actually, the aliasing is most + -- likely intended, so don't emit a warning either. - elsif - Present (Underlying_Type (Etype (Form1))) - and then - (Is_By_Reference_Type - (Underlying_Type (Etype (Form1))) - or else - Convention (Underlying_Type (Etype (Form1))) = - Convention_Ada_Pass_By_Reference) + elsif Explicitly_By_Reference (Form1) + or else Explicitly_By_Reference (Form2) then null; @@ -3810,7 +3827,9 @@ package body Sem_Warn is -- arrays and record types if switch is set. elsif Ada_Version >= Ada_2012 - and then not Is_Elementary_Type (Etype (Form1)) + and then not (Is_Elementary_Type (Etype (Form1)) + and then + Is_Elementary_Type (Etype (Form2))) and then not Warn_On_Overlap then null;
reply other threads:[~2021-06-18 8:38 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=20210618083840.5D7C839B4423@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).