This patch fixes the compiler whereby style checks for extranious
whitespace (under the flag -gnatyb) may crash the compiler when a
manually specified UTF character is present directly before such an
extranious whitespace.
Tested on x86_64-pc-linux-gnu, committed on trunk
2020-06-19 Justin Squirek <squi...@adacore.com>
gcc/ada/
* widechar.adb, widechar.ads (Skip_Wide): Catch validity check
failure when skipping over characters, and update comment to
reflect Skip_Wide's usage in error printing.
--- gcc/ada/widechar.adb
+++ gcc/ada/widechar.adb
@@ -203,7 +203,16 @@ package body Widechar is
-- Start of processing for Skip_Wide
begin
- Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
+ -- Capture invalid wide characters errors since we are going to discard
+ -- the result anyway. We just want to move past it.
+
+ begin
+ Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
+ exception
+ when Constraint_Error =>
+ null;
+ end;
+
Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1);
end Skip_Wide;
@@ -235,7 +244,16 @@ package body Widechar is
-- Start of processing for Skip_Wide
begin
- Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
+ -- Capture invalid wide characters errors since we are going to discard
+ -- the result anyway. We just want to move past it.
+
+ begin
+ Discard := WC_Skip (Skip_Char, Wide_Character_Encoding_Method);
+ exception
+ when Constraint_Error =>
+ null;
+ end;
+
Wide_Char_Byte_Count := Wide_Char_Byte_Count + Nat (P - P_Init - 1);
end Skip_Wide;
--- gcc/ada/widechar.ads
+++ gcc/ada/widechar.ads
@@ -81,9 +81,7 @@ package Widechar is
-- On entry, S (P) points to an ESC character for a wide character escape
-- sequence or to an upper half character if the encoding method uses the
-- upper bit, or to a left bracket if the brackets encoding method is in
- -- use. On exit, P is bumped past the wide character sequence. No error
- -- checking is done, since this is only used on escape sequences generated
- -- by Set_Wide, which are known to be correct.
+ -- use. On exit, P is bumped past the wide character sequence.
procedure Skip_Wide (S : Source_Buffer_Ptr; P : in out Source_Ptr);
-- Similar to the above procedure, but operates on a source buffer