[Ada] Factor out the "size for& too small..." error message

Use a constant for the Size_Too_Small_Message, so if it changes, it
won't change in one place but not another.  DRY. It might be better to
move this code out of errout.adb, but that's for another day.

2019-08-19  Bob Duff  <duff@adacore.com>

gcc/ada/

	* errout.ads (Size_Too_Small_Message): New constant.
	* errout.adb, freeze.adb, sem_ch13.adb: Use it.

From-SVN: r274648
This commit is contained in:
Bob Duff 2019-08-19 08:36:12 +00:00 committed by Pierre-Marie de Rodat
parent 27b2fbc95c
commit dafa2ae46c
5 changed files with 14 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2019-08-19 Bob Duff <duff@adacore.com>
* errout.ads (Size_Too_Small_Message): New constant.
* errout.adb, freeze.adb, sem_ch13.adb: Use it.
2019-08-19 Eric Botcazou <ebotcazou@adacore.com>
* exp_dist.adb (Build_Package_Stubs): Do not specifically visit

View File

@ -3259,7 +3259,7 @@ package body Errout is
-- Processing for "Size too small" messages
elsif Msg = "size for& too small, minimum allowed is ^" then
elsif Msg = Size_Too_Small_Message then
-- Suppress "size too small" errors in CodePeer mode, since code may
-- be analyzed in a different configuration than the one used for

View File

@ -948,4 +948,10 @@ package Errout is
-- This name is the identifier name as passed, cased according to the
-- default identifier casing for the given file.
Size_Too_Small_Message : constant String :=
"size for& too small, minimum allowed is ^";
-- This message is explicitly tested in Special_Msg_Delete in the package
-- body, which is somewhat questionable, but at least by using a constant
-- we are obeying the DRY principle.
end Errout;

View File

@ -786,9 +786,7 @@ package body Freeze is
elsif Has_Size_Clause (T) then
if RM_Size (T) < S then
Error_Msg_Uint_1 := S;
Error_Msg_NE
("size for& too small, minimum allowed is ^",
Size_Clause (T), T);
Error_Msg_NE (Size_Too_Small_Message, Size_Clause (T), T);
end if;
-- Set size if not set already

View File

@ -10835,7 +10835,7 @@ package body Sem_Ch13 is
if not ASIS_Mode then
Error_Msg_Uint_1 := Min_Siz;
Error_Msg_NE ("size for& too small, minimum allowed is ^", N, T);
Error_Msg_NE (Size_Too_Small_Message, N, T);
end if;
end Size_Too_Small_Error;