From: Piotr Trojanek Date: Wed, 24 Jun 2020 08:25:23 +0000 (+0200) Subject: [Ada] Cleanup defensive guards for Null_Exclusion_Present X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a0a294d3eb78eac2932756a6de8372a8de947567;p=gcc.git [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. --- diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 9232d496462..cce8d37083b 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.