From patchwork Mon Aug 19 08:39:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1149106 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507219-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="oneq5/DL"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46BnRc70Hkz9s3Z for ; Mon, 19 Aug 2019 18:39:56 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=jDqDu3I3m3A5M5Dlyzg/aqfhkp/3eDZT+J1Mor6C862eHwdR3U D3y1T9C5CREgOU2IDtoQt3bXg0h9Y6pxj+hHGBPC3S3I4SmdJbWwUA5dmR0l7NpI Wi4OUG+9vYF3JDJbYAK07thTZ57HIlUq/OGS6trLh21iYg7y2uMMvjZc4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=AF+BoaoX7ZpUbDMwwZ7MWG8CSug=; b=oneq5/DLdhBLDa5VO7Jc GzmZK3JloVmtc/dDfkp28kxtouDgF/osk2S+k1QGAfvnMqzfBwqEAkIALryQsqFC /eCrOcRleQ1JJIGvUIkEePAntsG4EiEVQlqIEvlz2AqpfmepQOTz8+wnOEudfaq8 pkEyyCvfuLdUTeILw9B5l5s= Received: (qmail 115263 invoked by alias); 19 Aug 2019 08:39:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 115210 invoked by uid 89); 19 Aug 2019 08:39:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=dry, Processing, principle, day X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Aug 2019 08:39:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4EE2A5604B; Mon, 19 Aug 2019 04:39:00 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mWrfOwF4S3m0; Mon, 19 Aug 2019 04:39:00 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 3DE5211619A; Mon, 19 Aug 2019 04:39:00 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 3B3366AB; Mon, 19 Aug 2019 04:39:00 -0400 (EDT) Date: Mon, 19 Aug 2019 04:39:00 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Factor out the "size for& too small..." error message Message-ID: <20190819083900.GA33401@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes 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. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-08-19 Bob Duff gcc/ada/ * errout.ads (Size_Too_Small_Message): New constant. * errout.adb, freeze.adb, sem_ch13.adb: Use it. --- gcc/ada/errout.adb +++ 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 --- gcc/ada/errout.ads +++ 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; --- gcc/ada/freeze.adb +++ 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 --- gcc/ada/sem_ch13.adb +++ 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;