From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 6378D3858023 for ; Thu, 5 Jan 2023 14:39:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6378D3858023 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42c.google.com with SMTP id z16so19845668wrw.1 for ; Thu, 05 Jan 2023 06:39:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=imqcIUsi27MmUki6STPcboYVpfrn5GEuLV1q+YyYKXE=; b=JXhX8wr1xnt9BeNJM7OE3jTyVHkl0XL/MgBP1cSu6IBRq6iycbwCoEqe89QI9MseYb FvtTahV8hTUJCi6+Td0/xCbE+EfbowH7v7uN5lQxmA/esAapfkp0wPY8QALwR16PBkoh PLZCvJ3MGrlvk0rvy01S1hSr0+fjEO12jw3DFHwYZDBJ+xgAFpDGRx5jryI7I9EiT5TS JFgaarX2lsVeIel22PG+4Fh4dTQvMK1Iu68dhS91F2xk5dIs+ymxzS1AIyamMQNwSKiS 17wPVA5omqWE0qGzeTyjRhzLSGIl5lV3kMgEDgqYoTCWzNvN5pMpKLuGrpgEL1owdM6X TORQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=imqcIUsi27MmUki6STPcboYVpfrn5GEuLV1q+YyYKXE=; b=czSSjtrKtg0mmlNaKyCgzg/qTe3tMejnH/3B6OlBwZY8lNmh0Z+roNtDJnTTDMgDw4 4JNsbWdv45b0z3mKEqENR4J8T1b+egMTpcPchppMyfz/X9Inv2zjagkR409CMp2D1Nf2 gB3lgLeNfAQvB9lolV9ZbZ+Xn2PrrrCytO+xsQRt2ksC745fqAb7aa2okttYzrzPMo8K selLIeIenz1XOWaANydmg3xzz0aCUopaFDMpxs5fyFZ3ypRQnLoUDx4o2O2GOR31FzFW bE3IncW811kKxVtGZqW3CvDNncJBkWRVIDdbrf6mHj3cgwDumLRosWc3szK+mCNWJKYG r5AA== X-Gm-Message-State: AFqh2kry/aSbimt65CTN2fqTSgzjieVWESNrCvizDkp5aoTZp10OxyIi +Re1C4PorBphSQpTowKJFTglV9zs6PiZURA3RiE= X-Google-Smtp-Source: AMrXdXu+JiaenKSbuE13YDAS5evfbKYnuh6PiiqD5rBGIgHLWAYFacKRGeHv9wf1Ru52Tv9oFVnKwA== X-Received: by 2002:adf:d846:0:b0:29f:4e42:33c5 with SMTP id k6-20020adfd846000000b0029f4e4233c5mr6145355wrl.55.1672929544217; Thu, 05 Jan 2023 06:39:04 -0800 (PST) Received: from poulhies-Precision-5550.lan (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id m24-20020a056000181800b00296730b5c3esm13350037wrh.102.2023.01.05.06.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 06:39:03 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED] ada: Better error message for bad Discard_Names configuration pragma Date: Thu, 5 Jan 2023 15:39:01 +0100 Message-Id: <20230105143901.155499-1-poulhies@adacore.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 List-Id: From: Steve Baird When a pragma Discard_Names is used as a configuration pragma, it does not take an argument. If an argument is given, the resulting error message was incorrect and confusing. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Fix Is_Configuration_Pragma function to handle case where the pragma's parent is an N_Aspect_Specification node. In analyzing a Discard_Names pragma, do not assume that a nonzero number of arguments implies that the pragma is not a configuration pragma; that assumption only holds for legal programs. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_prag.adb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index f3c23caeae4..555e09b74e9 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -7298,11 +7298,20 @@ package body Sem_Prag is -- the test below also permits use in a configuration pragma file. function Is_Configuration_Pragma return Boolean is - Lis : constant List_Id := List_Containing (N); + Lis : List_Id; Par : constant Node_Id := Parent (N); Prg : Node_Id; begin + -- Don't evaluate List_Containing (N) if Parent (N) could be + -- an N_Aspect_Specification node. + + if not Is_List_Member (N) then + return False; + end if; + + Lis := List_Containing (N); + -- If no parent, then we are in the configuration pragma file, -- so the placement is definitely appropriate. @@ -15729,8 +15738,13 @@ package body Sem_Prag is -- Deal with configuration pragma case - if Arg_Count = 0 and then Is_Configuration_Pragma then - Global_Discard_Names := True; + if Is_Configuration_Pragma then + if Arg_Count /= 0 then + Error_Pragma + ("nonzero number of arguments for configuration pragma%"); + else + Global_Discard_Names := True; + end if; return; -- Otherwise, check correct appropriate context -- 2.34.1