]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: String interpolation: report error without Extensions allowed
authorJavier Miranda <miranda@adacore.com>
Sun, 11 Aug 2024 11:11:29 +0000 (11:11 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 23 Aug 2024 08:51:05 +0000 (10:51 +0200)
The compiler does not report the correct error in occurrences
of interpolated strings, when the sources are compiled without
language extensions allowed.

gcc/ada/

* scng.adb (Scan): Call Error_Msg_GNAT_Extension() to report an
error, when the sources are compiled without Core_Extensions_
Allowed, and the scanner detects the beginning of an interpolated
string.

gcc/ada/scng.adb

index 08ce2ab5ad1c2ac86e17b7c14698c6557639cf8e..658970fbab2dc566b201c8336ce5a7c29a276ad5 100644 (file)
@@ -2135,14 +2135,19 @@ package body Scng is
          --  Lower case letters
 
          when 'a' .. 'z' =>
-            if Core_Extensions_Allowed
-              and then Source (Scan_Ptr) = 'f'
+            if Source (Scan_Ptr) = 'f'
               and then Source (Scan_Ptr + 1) = '"'
             then
-               Scan_Ptr := Scan_Ptr + 1;
-               Accumulate_Checksum (Source (Scan_Ptr));
-               Token := Tok_Left_Interpolated_String;
-               return;
+               if Core_Extensions_Allowed then
+                  Scan_Ptr := Scan_Ptr + 1;
+                  Accumulate_Checksum (Source (Scan_Ptr));
+                  Token := Tok_Left_Interpolated_String;
+                  return;
+               else
+                  Error_Msg_GNAT_Extension
+                    ("interpolated string", Scan_Ptr,
+                     Is_Core_Extension => True);
+               end if;
             end if;
 
             Name_Len := 1;
@@ -2155,15 +2160,20 @@ package body Scng is
          --  Upper case letters
 
          when 'A' .. 'Z' =>
-            if Core_Extensions_Allowed
-              and then Source (Scan_Ptr) = 'F'
+            if Source (Scan_Ptr) = 'F'
               and then Source (Scan_Ptr + 1) = '"'
             then
-               Error_Msg_S
-                 ("delimiter of interpolated string must be in lowercase");
-               Scan_Ptr := Scan_Ptr + 1;
-               Token := Tok_Left_Interpolated_String;
-               return;
+               if Core_Extensions_Allowed then
+                  Error_Msg_S
+                    ("delimiter of interpolated string must be in lowercase");
+                  Scan_Ptr := Scan_Ptr + 1;
+                  Token := Tok_Left_Interpolated_String;
+                  return;
+               else
+                  Error_Msg_GNAT_Extension
+                    ("interpolated string", Scan_Ptr,
+                     Is_Core_Extension => True);
+               end if;
             end if;
 
             Token_Contains_Uppercase := True;