]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Bug using user defined string literals with interpolated strings
authorJavier Miranda <miranda@adacore.com>
Thu, 6 Jun 2024 11:48:02 +0000 (11:48 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 27 Jun 2024 08:19:12 +0000 (10:19 +0200)
The frontend rejects the use of user defined string literals
using interpolated strings.

gcc/ada/

* sem_res.adb (Has_Applicable_User_Defined_Literal): Add missing
support for interpolated strings.

gcc/ada/sem_res.adb

index a0dd1f7962bdc48711d4f561d9f34f0343f14a0a..72bba1f97af1c703095c3fc3a8f6de75061065e6 100644 (file)
@@ -467,7 +467,7 @@ package body Sem_Res is
       Literal_Aspect_Map :
         constant array (N_Numeric_Or_String_Literal) of Aspect_Id :=
           (N_Integer_Literal             => Aspect_Integer_Literal,
-           N_Interpolated_String_Literal => No_Aspect,
+           N_Interpolated_String_Literal => Aspect_String_Literal,
            N_Real_Literal                => Aspect_Real_Literal,
            N_String_Literal              => Aspect_String_Literal);
 
@@ -487,6 +487,7 @@ package body Sem_Res is
 
    begin
       if (Nkind (N) in N_Numeric_Or_String_Literal
+                     | N_Interpolated_String_Literal
            and then Present
             (Find_Aspect (Typ, Literal_Aspect_Map (Nkind (N)))))
         or else
@@ -563,6 +564,10 @@ package body Sem_Res is
             Param1 := Make_String_Literal (Loc, Strval (N));
             Params := New_List (Param1);
 
+         elsif Nkind (N) = N_Interpolated_String_Literal then
+            Param1 := New_Copy_Tree (N);
+            Params := New_List (Param1);
+
          else
             Param1 :=
               Make_String_Literal