[COMMITTED] ada: Fix small fallout of previous change

Message ID 20230529082934.2410564-1-poulhies@adacore.com
State Committed
Commit 6fe8909606f79db1fb2107336544b058eaeb6381
Headers
Series [COMMITTED] ada: Fix small fallout of previous change |

Commit Message

Marc Poulhiès May 29, 2023, 8:29 a.m. UTC
  From: Eric Botcazou <ebotcazou@adacore.com>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_res.adb | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 17b74ea65d5..1d4b9acb8ea 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -13333,15 +13333,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);