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-4537] [Ada] Small cleanup in Eval_Integer_Literal Date: Wed, 20 Oct 2021 10:17:49 +0000 (GMT) [thread overview] Message-ID: <20211020101749.3AA0E385800E@sourceware.org> (raw) https://gcc.gnu.org/g:4b39bab947436640c20624ec58b61830c8ab2d71 commit r12-4537-g4b39bab947436640c20624ec58b61830c8ab2d71 Author: Eric Botcazou <ebotcazou@adacore.com> Date: Mon Oct 11 16:56:06 2021 +0200 [Ada] Small cleanup in Eval_Integer_Literal gcc/ada/ * sem_eval.ads (Check_Non_Static_Context): Update documentation. * sem_eval.adb (In_Any_Integer_Context): Change parameter type, adjust accordingly and remove unreachable case. (Eval_Integer_Literal): Consider the node kind throughout and trim down verbose condition. Diff: --- gcc/ada/sem_eval.adb | 27 ++++++++++++--------------- gcc/ada/sem_eval.ads | 7 +++---- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index 20bc03ac686..954a4a63689 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -2845,7 +2845,7 @@ package body Sem_Eval is -- the expander that do not correspond to static expressions. procedure Eval_Integer_Literal (N : Node_Id) is - function In_Any_Integer_Context (Context : Node_Id) return Boolean; + function In_Any_Integer_Context (K : Node_Kind) return Boolean; -- If the literal is resolved with a specific type in a context where -- the expected type is Any_Integer, there are no range checks on the -- literal. By the time the literal is evaluated, it carries the type @@ -2856,23 +2856,21 @@ package body Sem_Eval is -- In_Any_Integer_Context -- ---------------------------- - function In_Any_Integer_Context (Context : Node_Id) return Boolean is + function In_Any_Integer_Context (K : Node_Kind) return Boolean is begin -- Any_Integer also appears in digits specifications for real types, -- but those have bounds smaller that those of any integer base type, -- so we can safely ignore these cases. - return - Nkind (Context) in N_Attribute_Definition_Clause - | N_Attribute_Reference - | N_Modular_Type_Definition - | N_Number_Declaration - | N_Signed_Integer_Type_Definition; + return K in N_Attribute_Definition_Clause + | N_Modular_Type_Definition + | N_Number_Declaration + | N_Signed_Integer_Type_Definition; end In_Any_Integer_Context; -- Local variables - Par : constant Node_Id := Parent (N); + PK : constant Node_Kind := Nkind (Parent (N)); Typ : constant Entity_Id := Etype (N); -- Start of processing for Eval_Integer_Literal @@ -2890,12 +2888,11 @@ package body Sem_Eval is -- Check_Non_Static_Context on an expanded literal may lead to spurious -- and misleading warnings. - if (Nkind (Par) in N_Case_Expression_Alternative | N_If_Expression - or else Nkind (Par) not in N_Subexpr) - and then (Nkind (Par) not in N_Case_Expression_Alternative - | N_If_Expression - or else Comes_From_Source (N)) - and then not In_Any_Integer_Context (Par) + if (PK not in N_Subexpr + or else (PK in N_Case_Expression_Alternative | N_If_Expression + and then + Comes_From_Source (N))) + and then not In_Any_Integer_Context (PK) then Check_Non_Static_Context (N); end if; diff --git a/gcc/ada/sem_eval.ads b/gcc/ada/sem_eval.ads index 5e1c2cb3168..c93d97d8822 100644 --- a/gcc/ada/sem_eval.ads +++ b/gcc/ada/sem_eval.ads @@ -149,10 +149,9 @@ package Sem_Eval is -- -- Note: most cases of non-static context checks are handled within -- Sem_Eval itself, including all cases of expressions at the outer level - -- (i.e. those that are not a subexpression). Currently the only outside - -- customer for this procedure is Sem_Attr (because Eval_Attribute is - -- there). There is also one special case arising from ranges (see body of - -- Resolve_Range). + -- (i.e. those that are not a subexpression). The outside customers for + -- this procedure are Sem_Aggr, Sem_Attr (because Eval_Attribute is there) + -- and Sem_Res (for a special case arising from ranges, see Resolve_Range). -- -- Note: this procedure is also called by GNATprove on real literals -- that are not sub-expressions of static expressions, to convert them to
reply other threads:[~2021-10-20 10:17 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=20211020101749.3AA0E385800E@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).