]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix small fallout of previous change
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 5 Apr 2023 21:53:18 +0000 (23:53 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Wed, 27 Sep 2023 08:16:26 +0000 (10:16 +0200)
It may lead to an infinite recursion if no interpretation exists.

gcc/ada/

* sem_res.adb (Try_User_Defined_Literal): Restrict previous change
to non-leaf nodes.

gcc/ada/sem_res.adb

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