From dafa2ae46c9f0d95821fd365e8c554008b934819 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Mon, 19 Aug 2019 08:36:12 +0000 Subject: [PATCH] [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 gcc/ada/ * errout.ads (Size_Too_Small_Message): New constant. * errout.adb, freeze.adb, sem_ch13.adb: Use it. From-SVN: r274648 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/errout.adb | 2 +- gcc/ada/errout.ads | 6 ++++++ gcc/ada/freeze.adb | 4 +--- gcc/ada/sem_ch13.adb | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index e1342f48754..c01d358e71e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-08-19 Bob Duff + + * errout.ads (Size_Too_Small_Message): New constant. + * errout.adb, freeze.adb, sem_ch13.adb: Use it. + 2019-08-19 Eric Botcazou * exp_dist.adb (Build_Package_Stubs): Do not specifically visit diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index ea524f33ee3..f5a4925eabc 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -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 diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads index 10a43b1b7b6..9a54c7c68b6 100644 --- a/gcc/ada/errout.ads +++ b/gcc/ada/errout.ads @@ -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; diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 78d1ed46fef..70f4b9dc0f5 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -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 diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 35a295c8cf3..92e308ae0d9 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -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; -- 2.30.2