[Ada] Guard against leading and trailing spaces reappearing in errors

Message ID 20210504095222.GA90310@adacore.com
State New
Headers show
Series
  • [Ada] Guard against leading and trailing spaces reappearing in errors
Related show

Commit Message

Pierre-Marie de Rodat May 4, 2021, 9:52 a.m.
The leading and trailing spaces in error message strings have been
recently removed. This patch adds an assertion to prevent those spaces
from appearing again.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* errout.adb (Error_Msg_Internal): Add assertion to prevent
	style mistakes reappearing in the future.

Patch

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -952,6 +952,11 @@  package body Errout is
    --  Start of processing for Error_Msg_Internal
 
    begin
+      --  Detect common mistake of prefixing or suffing the message with a
+      --  space character.
+
+      pragma Assert (Msg (Msg'First) /= ' ' and then Msg (Msg'Last) /= ' ');
+
       if Raise_Exception_On_Error /= 0 then
          raise Error_Msg_Exception;
       end if;