From patchwork Thu Sep 11 09:18:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 120034 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1B5D3857C58 for ; Thu, 11 Sep 2025 09:28:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id D10DA3858C42 for ; Thu, 11 Sep 2025 09:19:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D10DA3858C42 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D10DA3858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582360; cv=none; b=qlIpwuT3axBW7zCwTr2mOSp4ySB5CVNBhuqm/dyuB3za2LQgPReXPB5ESJ5ihPJ9ejNqPvFprM6/rT6TFwL6xXqDWjebcBLVIhj4P1MAKKSMQ6UL3H6hQPb5YipziqKkiZgRW/0F4RoKQAQLsRCN9jgqoh23TJzACqKhMdU0KWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582360; c=relaxed/simple; bh=BRRI+BKEoL7I0jVHBMU3PtudfiNWV3H7/EoFbkrmiRg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WTMQewJnPTclvKqsCad59MLPf3jwAUl/SODYBMrrE71GVuOFCIg4dG+I0u6hl3lfGNu2CAV1Giz3KaFfu97FxG/bt8ptxT4y9kcxseiVQ7wrzN8jjpdl14zZ1Ff7vxiyWGLGGeiVOaCvICxLpW8e4vBrqfxFjuYMxjM5uVFKkhw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D10DA3858C42 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=SMcCzJez Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3e5190bca95so379003f8f.0 for ; Thu, 11 Sep 2025 02:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582358; x=1758187158; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7SjsT4v6YDrcDOD3q0Ax4Edlr3NpCsYGbZK2hAiznio=; b=SMcCzJezEr0vfG7wRM8XukKrx3icbQTVQeOS4EjcF8N41RrfdTad0GdgMcPnQF0taj kPmMQg/oI+54OfHFPN82x5cJjjyVyCjxMFIYOPDJGjx8K/cF0NV4wysN7AU8H68LFO8s F6+1loPW7wjgeDZxLrtWrRyKi/PJ4vPPXRO1MO09Qs1Esw05IpHcnfcOYrMnd8syT3uk ZvVHl3ALekUdWSXQwKsCFmV6uz1eYdT6bMyt8QB25G8yMHiQGUeqMkl/iwNfKtPBsAvA wfyXO60sf3FPTZWPxi3oQN0wogp4QYJbds1UnbDiX1NI1rzoYp3REKBIzMitfBwSrNlh 72ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582358; x=1758187158; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7SjsT4v6YDrcDOD3q0Ax4Edlr3N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FMCtYOIywzmB53/LE17yEr8UdtURQ== X-Received: by 2002:adf:e350:0:b0:3e7:5ecf:c760 with SMTP id ffacd0b85a97d-3e75ecfca36mr1404955f8f.11.1757582358466; Thu, 11 Sep 2025 02:19:18 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:18 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Denis Mazzucato Subject: [COMMITTED 04/31] ada: Better warning when single letter package conflicts with predefined unit naming Date: Thu, 11 Sep 2025 11:18:36 +0200 Message-ID: <20250911091904.1505690-4-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Denis Mazzucato This patch improves the warning message when the actual file name of a child package with a single letter parent isn't the expected one because it may collide with a predefined unit name. The warning explain why in this specific case the expected name is not the standard one using the minus to separate parents with children. gcc/ada/ChangeLog: * par-load.adb (Load): Better warning message. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/par-load.adb | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/gcc/ada/par-load.adb b/gcc/ada/par-load.adb index 4a97f14ffb51..0206b56e174f 100644 --- a/gcc/ada/par-load.adb +++ b/gcc/ada/par-load.adb @@ -117,6 +117,29 @@ procedure Load is end Same_File_Name_Except_For_Case; + function Actual_Name_Collides_With_Predefined_Unit_Name + (Actual_File_Name : File_Name_Type) return Boolean; + -- Given an actual file name, determine if it is a child unit whose parent + -- unit is a single letter that is a, g, i, or s. Such a name could create + -- confusion with predefined units and thus is required to use a tilde + -- instead of the minus as the second character. + + ---------------------------------------------------- + -- Actual_Name_Collides_With_Predefined_Unit_Name -- + ---------------------------------------------------- + + function Actual_Name_Collides_With_Predefined_Unit_Name + (Actual_File_Name : File_Name_Type) return Boolean + is + N1 : Character; + begin + Get_Name_String (Actual_File_Name); + N1 := Name_Buffer (1); + return Name_Len > 1 + and then Name_Buffer (2) = '-' + and then (N1 = 'a' or else N1 = 'g' or else N1 = 'i' or else N1 = 's'); + end Actual_Name_Collides_With_Predefined_Unit_Name; + -- Start of processing for Load begin @@ -163,8 +186,18 @@ begin (File_Name, Unit_File_Name (Cur_Unum))) then Error_Msg_File_1 := File_Name; - Error_Msg - ("??file name does not match unit name, should be{", Sloc (Curunit)); + if Actual_Name_Collides_With_Predefined_Unit_Name + (Unit_File_Name (Cur_Unum)) + then + Error_Msg + ("??file name may conflict with predefined units, " + & "the expected file name for this unit is{", + Sloc (Curunit)); + else + Error_Msg + ("??file name does not match unit name, should be{", + Sloc (Curunit)); + end if; end if; -- For units other than the main unit, the expected unit name is set and