aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_res.adb
diff options
context:
space:
mode:
authorGary Dismukes <dismukes@adacore.com>2022-08-19 18:40:05 -0400
committerMarc Poulhiès <poulhies@adacore.com>2022-09-12 10:16:50 +0200
commit1d2bc28c41b6ddf0b11a7a3d7d312ff45cb2cb7d (patch)
treecc3b51e9e1b6ddc58126c78759306c3a423b6fd8 /gcc/ada/sem_res.adb
parent2fa4beae4482f4fac6556e1ef2e941787507073e (diff)
downloadgcc-1d2bc28c41b6ddf0b11a7a3d7d312ff45cb2cb7d.zip
gcc-1d2bc28c41b6ddf0b11a7a3d7d312ff45cb2cb7d.tar.gz
gcc-1d2bc28c41b6ddf0b11a7a3d7d312ff45cb2cb7d.tar.bz2
[Ada] Fix issues with compiling ACATS test for user-defined literals
The draft ACATS test (which we developed) for the Ada 2022 feature of user-defined literals has compile-time problems that are fixed with this set of changes. Two of these involve the resolution of named numbers in the context where an implicit literal conversion can occur, and for equality when a literal or named number is an operand. Furthermore, the compiler can hang in some cases when a numeric literal is used in a context where the expected type is a type derived two levels down from a tagged type that specifies a literal aspect. gcc/ada/ * sem_res.adb (Resolve_Equality_Op): Add handling for equality ops with user-defined literal operands. * sem_util.ads (Is_User_Defined_Literal): Update spec comment to indicate inclusion of named number cases. * sem_util.adb (Corresponding_Primitive_Op): Rather than following the chain of ancestor subprograms via Alias and Overridden_Operation links, we check for matching profiles between primitive subprograms of the descendant type and the ancestor subprogram (by calling a new nested function Profile_Matches_Ancestor). This prevents the compiler from hanging due to circular linkages via those fields that can occur between inherited and overriding subprograms (which might indicate a latent bug, but one that may be rather delicate to resolve). (Profile_Matches_Ancestor): New nested subprogram to compare the profile of a primitive subprogram with the profile of a candidate ancestor subprogram. (Is_User_Defined_Literal): Also return True in cases where the node N denotes a named number (E_Name_Integer and E_Named_Real).
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r--gcc/ada/sem_res.adb14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index f618467..4b76595 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -8876,6 +8876,20 @@ package body Sem_Res is
end if;
else
+
+ -- For Ada 2022, check for user-defined literals when the type has
+ -- the appropriate aspect.
+
+ if Has_Applicable_User_Defined_Literal (L, Etype (R)) then
+ Resolve (L, Etype (R));
+ Set_Etype (N, Standard_Boolean);
+ end if;
+
+ if Has_Applicable_User_Defined_Literal (R, Etype (L)) then
+ Resolve (R, Etype (L));
+ Set_Etype (N, Standard_Boolean);
+ end if;
+
-- Deal with other error cases
if T = Any_String or else