]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Restrict string interpolation to single string literal
authorJavier Miranda <miranda@adacore.com>
Fri, 28 Jun 2024 21:46:12 +0000 (21:46 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 1 Aug 2024 15:14:37 +0000 (17:14 +0200)
gcc/ada/

* par-ch2.adb (P_Interpolated_String_Literal): remove support of
multi-line string literals.
* doc/gnat_rm/gnat_language_extensions.rst: Update documentation.
* gnat_rm.texi: Regenerate.

gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
gcc/ada/gnat_rm.texi
gcc/ada/par-ch2.adb

index feceff24e21de69eebccb87772932c4c270c0a99..0f001c4aca9144800cd825549c9e1c527a6ebbd1 100644 (file)
@@ -323,20 +323,8 @@ For example:
        f" a double quote is \" and" &
        f" an open brace is \{");
 
-Finally, a syntax is provided for creating multi-line string literals,
-without having to explicitly use an escape sequence such as ``\n``. For
-example:
-
-.. code-block:: ada
-
-    Put_Line
-      (f"This is a multi-line"
-        "string literal"
-        "There is no ambiguity about how many"
-        "spaces are included in each line");
-
-Here is a link to the original RFC   :
-https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.rst
+Link to the original RFC:
+https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.md
 
 Constrained attribute for generic objects
 -----------------------------------------
index 24c2fdd4f97ae996cb33f6608cdd4d90e6efebb8..b27bd627c17f5ee7b3b671a71dc43cc2efa5fb17 100644 (file)
@@ -29223,20 +29223,8 @@ Put_Line
    f" an open brace is \@{");
 @end example
 
-Finally, a syntax is provided for creating multi-line string literals,
-without having to explicitly use an escape sequence such as @code{\n}. For
-example:
-
-@example
-Put_Line
-  (f"This is a multi-line"
-    "string literal"
-    "There is no ambiguity about how many"
-    "spaces are included in each line");
-@end example
-
-Here is a link to the original RFC   :
-@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.rst}
+Link to the original RFC:
+@indicateurl{https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-string-interpolation.md}
 
 @node Constrained attribute for generic objects,Static aspect on intrinsic functions,String interpolation,Curated Extensions
 @anchor{gnat_rm/gnat_language_extensions constrained-attribute-for-generic-objects}@anchor{448}
index f09daeaba69bc2ebb11bdcc18ae430912fec66c9..f249ae760236b597599cecfc6fafb724b924aa26 100644 (file)
@@ -224,7 +224,6 @@ package body Ch2 is
 
    function P_Interpolated_String_Literal return Node_Id is
       Elements_List : constant List_Id := New_List;
-      NL_Node       : Node_Id;
       Saved_State   : constant Boolean := Inside_Interpolated_String_Literal;
       String_Node   : Node_Id;
 
@@ -258,15 +257,8 @@ package body Ch2 is
                   T_Right_Curly_Bracket;
                end;
             else
-               if Prev_Token = Tok_String_Literal then
-                  NL_Node := New_Node (N_String_Literal, Token_Ptr);
-                  Set_Has_Wide_Character (NL_Node, False);
-                  Set_Has_Wide_Wide_Character (NL_Node, False);
-
-                  Start_String;
-                  Store_String_Char (Get_Char_Code (ASCII.LF));
-                  Set_Strval (NL_Node, End_String);
-                  Append_To (Elements_List, NL_Node);
+               if Prev_Token /= Tok_Right_Curly_Bracket then
+                  Error_Msg_SC ("unexpected string literal");
                end if;
 
                Append_To (Elements_List, Token_Node);