aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2020-06-24 10:25:23 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-15 05:39:12 -0400
commita0a294d3eb78eac2932756a6de8372a8de947567 (patch)
tree4d80fb32cb1ec7244ec9ed59af9c49f0d4e81288
parent8f366ea4dbe44407ad3f6af2a4a23c9fb007aea3 (diff)
downloadgcc-a0a294d3eb78eac2932756a6de8372a8de947567.zip
gcc-a0a294d3eb78eac2932756a6de8372a8de947567.tar.gz
gcc-a0a294d3eb78eac2932756a6de8372a8de947567.tar.bz2
[Ada] Cleanup defensive guards for Null_Exclusion_Present
gcc/ada/ * sem_ch3.adb (Process_Subtype): Combine guards for Null_Exclusion_Present in May_Have_Null_Exclusion; use this combined guard when checking AI-231.
-rw-r--r--gcc/ada/sem_ch3.adb24
1 files changed, 13 insertions, 11 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 9232d49..cce8d37 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -21541,21 +21541,12 @@ package body Sem_Ch3 is
Check_Incomplete (S);
P := Parent (S);
- -- Ada 2005 (AI-231): Static check
-
- if Ada_Version >= Ada_2005
- and then Present (P)
- and then Null_Exclusion_Present (P)
- and then Nkind (P) /= N_Access_To_Object_Definition
- and then not Is_Access_Type (Entity (S))
- then
- Error_Msg_N ("`NOT NULL` only allowed for an access type", S);
- end if;
-
-- 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 :=
+ Present (P)
+ and then
Nkind (P) in N_Access_Definition
| N_Access_Function_Definition
| N_Access_Procedure_Definition
@@ -21571,6 +21562,17 @@ package body Sem_Ch3 is
| N_Parameter_Specification
| N_Subtype_Declaration;
+ -- Ada 2005 (AI-231): Static check
+
+ if Ada_Version >= Ada_2005
+ and then May_Have_Null_Exclusion
+ and then Null_Exclusion_Present (P)
+ and then Nkind (P) /= N_Access_To_Object_Definition
+ and then not Is_Access_Type (Entity (S))
+ then
+ Error_Msg_N ("`NOT NULL` only allowed for an access type", S);
+ end if;
+
-- Create an Itype that is a duplicate of Entity (S) but with the
-- null-exclusion attribute.