* [Ada] Bring defensive guard for Null_Exclusion_Present up to date
@ 2020-10-15 9:40 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-10-15 9:40 UTC (permalink / raw)
To: gcc-patches; +Cc: Piotr Trojanek
[-- Attachment #1: Type: text/plain, Size: 495 bytes --]
An expression for May_Have_Null_Exclusion variable mirrors an assertion
in Null_Exclusion_Present. The assertion was then extended with another
node kind and so May_Have_Null_Exclusion got out of date.
The May_Have_Null_Exclusion is just a defensive code, so compilation is
not affected.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch3.adb (Process_Subtype): Sync May_Have_Null_Exclusion
with assertion in Null_Exclusion_Present; clarify the scope of
local variables.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1893 bytes --]
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -21487,14 +21487,6 @@ package body Sem_Ch3 is
Related_Id : Entity_Id := Empty;
Suffix : Character := ' ') return Entity_Id
is
- P : Node_Id;
- Def_Id : Entity_Id;
- Error_Node : Node_Id;
- Full_View_Id : Entity_Id;
- Subtype_Mark_Id : Entity_Id;
-
- May_Have_Null_Exclusion : Boolean;
-
procedure Check_Incomplete (T : Node_Id);
-- Called to verify that an incomplete type is not used prematurely
@@ -21519,6 +21511,16 @@ package body Sem_Ch3 is
end if;
end Check_Incomplete;
+ -- Local variables
+
+ P : Node_Id;
+ Def_Id : Entity_Id;
+ Error_Node : Node_Id;
+ Full_View_Id : Entity_Id;
+ Subtype_Mark_Id : Entity_Id;
+
+ May_Have_Null_Exclusion : Boolean;
+
-- Start of processing for Process_Subtype
begin
@@ -21550,7 +21552,8 @@ package body Sem_Ch3 is
Error_Msg_N ("`NOT NULL` only allowed for an access type", S);
end if;
- -- The following is ugly, can't we have a range or even a flag???
+ -- The following mirroring of assertion in Null_Exclusion_Present is
+ -- ugly, can't we have a range, a static predicate or even a flag???
May_Have_Null_Exclusion :=
Nkind (P) in N_Access_Definition
@@ -21562,6 +21565,7 @@ package body Sem_Ch3 is
| N_Derived_Type_Definition
| N_Discriminant_Specification
| N_Formal_Object_Declaration
+ | N_Function_Specification
| N_Object_Declaration
| N_Object_Renaming_Declaration
| N_Parameter_Specification
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-15 9:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-15 9:40 [Ada] Bring defensive guard for Null_Exclusion_Present up to date Pierre-Marie de Rodat
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).