From: Ed Schonberg Date: Sun, 5 Sep 2021 15:22:52 +0000 (-0400) Subject: [Ada] Handle properly user_defined literals given by operators. X-Git-Tag: basepoints/gcc-13~4178 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a53553086657d6b4668f0c3a2030ec1f63447d0;p=thirdparty%2Fgcc.git [Ada] Handle properly user_defined literals given by operators. gcc/ada/ * sem_ch6.adb (Analyze_Operator_Symbol): Recognize strings as operator names when they are the value of one of the Ada2022 aspects for User_Defined_Literals. * sem_ch13.adb (Analyze_One_Aspect): Handle an aspect value given by an Operator_Name. (Validate_Literal_Aspect): Call Analyze_Operator_Symbol when needed. --- diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 15b3c4441256..412855490d38 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -2991,7 +2991,15 @@ package body Sem_Ch13 is -- Copy expression for later processing by the procedures -- Check_Aspect_At_[Freeze_Point | End_Of_Declarations] - Set_Entity (Id, New_Copy_Tree (Expr)); + -- The expression may be a subprogram name, and can + -- be an operator name that appears as a string, but + -- requires its own analysis procedure (see sem_ch6). + + if Nkind (Expr) = N_Operator_Symbol then + Set_Entity (Id, Expr); + else + Set_Entity (Id, New_Copy_Tree (Expr)); + end if; -- Set Delay_Required as appropriate to aspect @@ -16668,7 +16676,15 @@ package body Sem_Ch13 is end if; if not Overloaded and then not Present (Entity (Func_Name)) then - Analyze (Func_Name); + -- The aspect is specified by a subprogram name, which + -- may be an operator name given originally by a string. + + if Is_Operator_Name (Chars (Func_Name)) then + Analyze_Operator_Symbol (Func_Name); + else + Analyze (Func_Name); + end if; + Overloaded := Is_Overloaded (Func_Name); end if; diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 1fcbdfbf918b..e32c4ad504c1 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -2126,8 +2126,15 @@ package body Sem_Ch6 is and then Attribute_Name (Par) /= Name_Value) or else (Nkind (Maybe_Aspect_Spec) = N_Aspect_Specification and then Get_Aspect_Id (Maybe_Aspect_Spec) - -- include other aspects here ??? - in Aspect_Stable_Properties | Aspect_Aggregate) + + -- Include aspects that can be specified by a + -- subprogram name, which can be an operator. + + in Aspect_Stable_Properties + | Aspect_Integer_Literal + | Aspect_Real_Literal + | Aspect_String_Literal + | Aspect_Aggregate) then Find_Direct_Name (N);