From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id F1020385840D for ; Mon, 7 Nov 2022 08:39:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F1020385840D 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-wm1-x329.google.com with SMTP id t1so6390524wmi.4 for ; Mon, 07 Nov 2022 00:39:18 -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=6EA+YrXfDh9CuhOBpQns2JjONXCnQXQl3Ft2wmWDmKY=; b=OuvqbX0DvuIqC8uoLKOewoHcZG6VbCVYhOZ/lEjMLlROIv0TzOsq3D+gTLLxtHIYu8 8exUO43QRUgKCsADVuz7bthdBSM6VhaTxzcRmx0t73jxA4iEjucLoyygPvxNuJlgXhbU b+U9kBPYK3iT/tD3e4nx3cI5kzii0cVDF7ZQqtTL3kUaUa3yUjbU703eXYmfvIXo35MC 2vHIrepUpigdGFVSr3ZzuQPBLUBT0HMdd0mNu2tyFzqEgWa7YO7uRZsmEsW518B7cTJR W/sxM5J7uTqsG3TnXRJ5WakasgUnLIZxXQpykr07i2oh/7UoYxw7dByRXdoPNSfcZW66 jBHg== 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=6EA+YrXfDh9CuhOBpQns2JjONXCnQXQl3Ft2wmWDmKY=; b=LRh1hwXwqHRU7CPQYKUWi1P6Q/HFkZeK8vmUYLJJ1zM1yTQKwhvewCrw+F4R7friX0 mfoHhMmP+WwR5j4NjX6UhY+tfFtKtWTXt54MKvYqWJN1LnS8LLxg/uODe2n44Ti/6xRu sQSS3xC1+XARtHvSsC3JEBQNHp/hHJMG/aX4TWp8kdypCg/XxmwbEHo+i2vt2IcsqiPj py2xtOnxjPCTc0k8C4B+VOUuN7lLkxEPBXa8oQ7spUcCaJ0UVt5OZNF6ZjLGrhq39QFO /GRSnYX4XoUSZ5xaigLajLgvTJzlLmGZFEDGcCdo+1oYvHxgyKc7KLs+oTtjJIf7jp7V hQ7A== X-Gm-Message-State: ACrzQf1Eduk4LZhioguBBFy1z3xR2t8hN/bDr5Ku2NSp2J3GTww00SAr DmTJiKOFAtxIaKTyNfCFjCiIK0yySuWKGA== X-Google-Smtp-Source: AMsMyM49aDPzyk7BZmmJ8taHwX/fUUdOS9POZytJJRT9pB+S9Ve8O9CpuSLzSq6FstLN7oUa+MOjlw== X-Received: by 2002:a7b:cc0c:0:b0:3c5:a58f:afbc with SMTP id f12-20020a7bcc0c000000b003c5a58fafbcmr32379363wmh.169.1667810357743; Mon, 07 Nov 2022 00:39:17 -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 d33-20020a05600c4c2100b003cf37c5ddc0sm7321166wmp.22.2022.11.07.00.39.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 00:39:17 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Reject misplaced pragma Obsolescent Date: Mon, 7 Nov 2022 09:39:13 +0100 Message-Id: <20221107083913.150332-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.4 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: Piotr Trojanek Pragma Obsolescent appearing before declaration was putting the Obsolescent flag on the Standard package, which is certainly wrong. The problem was that we relied on the Find_Lib_Unit_Name routine without sanitizing the pragma placement with Check_Valid_Library_Unit_Pragma. Part of cleaning up the warnings machinery to better handle references to unset objects. gcc/ada/ * sem_prag.adb (Analyze_Pragma [Pragma_Obsolescent]): Reject misplaced pragma. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_prag.adb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 60ea681001a..471ef870fa7 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -20502,10 +20502,16 @@ package body Sem_Prag is if No (Decl) then - -- First case: library level compilation unit declaration with + -- Case 0: library level compilation unit declaration with + -- the pragma preceding the declaration. + + if Nkind (Parent (N)) = N_Compilation_Unit then + Pragma_Misplaced; + + -- Case 1: library level compilation unit declaration with -- the pragma immediately following the declaration. - if Nkind (Parent (N)) = N_Compilation_Unit_Aux then + elsif Nkind (Parent (N)) = N_Compilation_Unit_Aux then Set_Obsolescent (Defining_Entity (Unit (Parent (Parent (N))))); return; -- 2.34.1