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-2160] [Ada] Spurious warning in generic instance Date: Thu, 8 Jul 2021 13:37:35 +0000 (GMT) [thread overview] Message-ID: <20210708133735.864AB39874C3@sourceware.org> (raw) https://gcc.gnu.org/g:629c82d729f1439718aa3759416cdb6cb03052f1 commit r12-2160-g629c82d729f1439718aa3759416cdb6cb03052f1 Author: Arnaud Charlet <charlet@adacore.com> Date: Fri May 28 10:25:39 2021 -0400 [Ada] Spurious warning in generic instance gcc/ada/ * sem_util.ads, sem_util.adb (Apply_Compile_Time_Constraint_Error): New parameter Emit_Message. * sem_ch4.adb (Analyze_Selected_Component): Disable warning within an instance. Diff: --- gcc/ada/sem_ch4.adb | 4 +++- gcc/ada/sem_util.adb | 21 ++++++++++++--------- gcc/ada/sem_util.ads | 16 +++++++++------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 1bfd222301e..c052022886a 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -5471,7 +5471,9 @@ package body Sem_Ch4 is Apply_Compile_Time_Constraint_Error (N, "component not present in }??", CE_Discriminant_Check_Failed, - Ent => Prefix_Type); + Ent => Prefix_Type, + Emit_Message => + SPARK_Mode = On or not In_Instance_Not_Visible); return; end if; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index ba840291345..6fdacdcba23 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -1510,13 +1510,14 @@ package body Sem_Util is ----------------------------------------- procedure Apply_Compile_Time_Constraint_Error - (N : Node_Id; - Msg : String; - Reason : RT_Exception_Code; - Ent : Entity_Id := Empty; - Typ : Entity_Id := Empty; - Loc : Source_Ptr := No_Location; - Warn : Boolean := False) + (N : Node_Id; + Msg : String; + Reason : RT_Exception_Code; + Ent : Entity_Id := Empty; + Typ : Entity_Id := Empty; + Loc : Source_Ptr := No_Location; + Warn : Boolean := False; + Emit_Message : Boolean := True) is Stat : constant Boolean := Is_Static_Expression (N); R_Stat : constant Node_Id := @@ -1530,8 +1531,10 @@ package body Sem_Util is Rtyp := Typ; end if; - Discard_Node - (Compile_Time_Constraint_Error (N, Msg, Ent, Loc, Warn => Warn)); + if Emit_Message then + Discard_Node + (Compile_Time_Constraint_Error (N, Msg, Ent, Loc, Warn => Warn)); + end if; -- Now we replace the node by an N_Raise_Constraint_Error node -- This does not need reanalyzing, so set it as analyzed now. diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index fb8309f4a2b..440ac800c11 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -161,13 +161,14 @@ package Sem_Util is -- part of the current package. procedure Apply_Compile_Time_Constraint_Error - (N : Node_Id; - Msg : String; - Reason : RT_Exception_Code; - Ent : Entity_Id := Empty; - Typ : Entity_Id := Empty; - Loc : Source_Ptr := No_Location; - Warn : Boolean := False); + (N : Node_Id; + Msg : String; + Reason : RT_Exception_Code; + Ent : Entity_Id := Empty; + Typ : Entity_Id := Empty; + Loc : Source_Ptr := No_Location; + Warn : Boolean := False; + Emit_Message : Boolean := True); -- N is a subexpression that will raise Constraint_Error when evaluated -- at run time. Msg is a message that explains the reason for raising the -- exception. The last character is ? if the message is always a warning, @@ -189,6 +190,7 @@ package Sem_Util is -- when the caller wants to parameterize whether an error or warning is -- given), or when the message should be treated as a warning even when -- SPARK_Mode is On (which otherwise would force an error). + -- If Emit_Message is False, then do not emit any message. function Async_Readers_Enabled (Id : Entity_Id) return Boolean; -- Id should be the entity of a state abstraction, an object, or a type.
reply other threads:[~2021-07-08 13:37 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=20210708133735.864AB39874C3@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).