diff options
author | Ed Schonberg <schonberg@adacore.com> | 2021-09-05 11:22:52 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-10-04 08:45:12 +0000 |
commit | 6a53553086657d6b4668f0c3a2030ec1f63447d0 (patch) | |
tree | 2658a1092bd1d06c52e095a9d8e679ccfb49517c /gcc | |
parent | 861dc87d7513f920365f0cf52be7406ca06711cf (diff) | |
download | gcc-6a53553086657d6b4668f0c3a2030ec1f63447d0.zip gcc-6a53553086657d6b4668f0c3a2030ec1f63447d0.tar.gz gcc-6a53553086657d6b4668f0c3a2030ec1f63447d0.tar.bz2 |
[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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_ch13.adb | 20 | ||||
-rw-r--r-- | gcc/ada/sem_ch6.adb | 11 |
2 files changed, 27 insertions, 4 deletions
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 15b3c44..4128554 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 1fcbdfb..e32c4ad 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); |