]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix remaining failures in Roman Numbers test
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 5 Apr 2023 18:43:54 +0000 (20:43 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 27 Sep 2023 08:16:26 +0000 (10:16 +0200)
The test is inspired from the example of user-defined literals given in the
Ada 2022 RM.  Mixed Arabic numbers/Roman numbers computations are rejected
because the second resolution pass would try to resolve Arabic numbers only
as user-defined literals.

gcc/ada/

* sem_res.adb (Try_User_Defined_Literal): For arithmetic operators,
also accept operands whose type is covered by the resolution type.

gcc/ada/sem_res.adb

index b819deb8c39a4b5b1b81c7e1fc6bf918c66d53b3..615d9d81a84cc07d3e00622a13a2db2f433cb99d 100644 (file)
@@ -13219,12 +13219,16 @@ package body Sem_Res is
          --  Both operands must have the same type as the context
          --  (ignoring for now fixed-point and exponentiation ops).
 
-         if Has_Applicable_User_Defined_Literal (Right_Opnd (N), Typ) then
+         if Covers (Typ, Etype (Right_Opnd (N)))
+           or else Has_Applicable_User_Defined_Literal (Right_Opnd (N), Typ)
+         then
             Resolve (Left_Opnd (N), Typ);
             Analyze_And_Resolve (N, Typ);
             return True;
 
-         elsif Has_Applicable_User_Defined_Literal (Left_Opnd (N), Typ) then
+         elsif Covers (Typ, Etype (Left_Opnd (N)))
+           or else Has_Applicable_User_Defined_Literal (Left_Opnd (N), Typ)
+         then
             Resolve (Right_Opnd (N), Typ);
             Analyze_And_Resolve (N, Typ);
             return True;