From: Javier Miranda Date: Sun, 11 Aug 2024 11:11:29 +0000 (+0000) Subject: ada: String interpolation: report error without Extensions allowed X-Git-Tag: basepoints/gcc-16~6437 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=87bdd17829e93bf98d8984d6a16ed25081af6c0d;p=thirdparty%2Fgcc.git ada: String interpolation: report error without Extensions allowed 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. --- diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb index 08ce2ab5ad1..658970fbab2 100644 --- a/gcc/ada/scng.adb +++ b/gcc/ada/scng.adb @@ -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;