From patchwork Fri May 26 07:36:18 2023 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: 70137 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 2D121395BC4F for ; Fri, 26 May 2023 07:42:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D121395BC4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685086932; bh=mbnNMXVnWwpEy2GGFK/jBBwbtS/Ps6DdWFR1u9UJhUo=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=LEbARhWpt7cDiUGJtO2BnD8dM/rVRVePjb4fJtEBPRq1toUk3LHslw6vc8p37vJh2 QqodTDhwi384etxSysL8K8zMmW2Lc7QM7q3o06Wn2CM08kwwjEtmKrFIHcEB38hW9K /On1oknxy+RYqnkAnkkRq+XJJZsdjn4JXn+oDgs8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 7FE843836E87 for ; Fri, 26 May 2023 07:36:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FE843836E87 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3078d1c8828so341764f8f.3 for ; Fri, 26 May 2023 00:36:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685086580; x=1687678580; 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=mbnNMXVnWwpEy2GGFK/jBBwbtS/Ps6DdWFR1u9UJhUo=; b=P6ZwBY/TDrYJ1TUPcWLfgVRiPI9Foqj6SZ4f3FR3mkVb6jaKQyETCnXLIFOzFiXXHh 9tg/hx02oNFbuhr9P4WlyGTGIItXi6B/PmuOW9ULE/ETsQDAFl81scADhDmksI1oUVNM wgwmlkhRZLWupOFQgUm1AAWn3uMn+UlQDa9Ya5Jo3Yv6hKZFhxaQ4IgQhpj+kNvLuidz k2hWD8m06bDZfjZOetac0x+8cvjBvKz6DL/BkxJfGeWWc15zXpMvhvx47OeLTC1qgNlq MTwLVdS66hGSr274OLvXaYJ49c1I1irN0fvwYCcU2FiDl+wDswnpJJbM8ykzGbg2Fydh k3vQ== X-Gm-Message-State: AC+VfDyaFCKzBx52hIOpQFYWghs9bK3AvflP8qViDTBfTHhITSzYi3/w ptbFABKUrm8+fup5CYWqRd/ER2hxVg9LBEwhNFrnBg== X-Google-Smtp-Source: ACHHUZ5JiCMOEO8A3eMF/vLvZAZYUDf3w8eaY1Dx8VyeVqQrbaSrK+pMut1la6gWHUAVGmnilLDv2g== X-Received: by 2002:a05:6000:4e3:b0:309:ccad:b2fb with SMTP id cr3-20020a05600004e300b00309ccadb2fbmr685326wrb.5.1685086580376; Fri, 26 May 2023 00:36:20 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:777b:eef4:6f79:f26f]) by smtp.gmail.com with ESMTPSA id m19-20020a7bcb93000000b003f605566610sm7956426wmi.13.2023.05.26.00.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:36:19 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Fix handling of Global contracts inside generic subprograms Date: Fri, 26 May 2023 09:36:18 +0200 Message-Id: <20230526073618.2068882-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 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, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Piotr Trojanek Routine Get_Argument works differently for generic units (as explained in its comment), but it failed to reliably detect such units when their kind is temporarily made non-generic (for resolving recursive calls, as explained in the comment at the end of Is_Generic_Declaration_Or_Body). With this patch the frontend will look at the decorated expression of the Global contract attached to the Global aspect; previously it was looking at the undecorated expression attached to the corresponding pragma. gcc/ada/ * sem_prag.adb (Get_Argument): Improve detection of generic units. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_prag.adb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index d66e5612135..96ea17209f3 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -31650,7 +31650,9 @@ package body Sem_Prag is -- to save the global references in the generic context. if From_Aspect_Specification (Prag) - and then (Present (Context_Id) and then Is_Generic_Unit (Context_Id)) + and then Present (Context_Id) + and then + Is_Generic_Declaration_Or_Body (Unit_Declaration_Node (Context_Id)) then return Corresponding_Aspect (Prag);