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 C46E03857C4A for ; Tue, 21 Nov 2023 10:00:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C46E03857C4A Authentication-Results: sourceware.org; dmarc=pass (p=none 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 C46E03857C4A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700560844; cv=none; b=bWsMZK6A2P2cURVkVQmlZ4t3PdeHywC6csqanSdy0g6XUVE5A146xk58c1A0Nk4qDYwkw1mOF1aEsVZ0QDmwMudFTS3ASXpRyX2C+NflVAOjrBfTPxPhxfbSiLfZSrOH9YV7qDrq7QX38l9YGaExDSeCE1bpqNDrpH/z+cqZRoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700560844; c=relaxed/simple; bh=SU1dkcknrLoHOGS/fS2ojrWR/+KEvjMJ4uY0n5geRFo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=G6Vko5+sYjzn1r64mxCeK/3upjplFV2s/snxAmdueOj35OEy+k2043T/9m+gMD1Pvi/t6h2197dseLnUjlxBMx/cnrCbCOUdYRDuR/qRDL68fIX+ruPDdWaE2Euvw5Y1on/nL30lFAHuqUNy9BNxm7PBXG9SnccftppmSDao1K8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-332ce3fa438so194975f8f.1 for ; Tue, 21 Nov 2023 02:00:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1700560841; x=1701165641; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=plgX48MN8LwMG+ilcYOBMqlRmLKn1sSJFx6OGgg5Yx4=; b=ZlXglExTwxXbkijiWb8RHMlwaHs8dYnfyaOhdxvMCvKekvuJVyPJUDGUn3bEmHW5Sr wUqTi/x2SD2qb1HNA4cjbqhpnn1QuXr01jvMPmuPfqfsKEZ3cZqELNl75selyZmKr1R+ HZGi+vr4AZkbyPodTNmNNYtVNCwgjcUq1h89HLwtuoNJ4s9mxRT8krN6hGJg874txsWr nZ1XQ4FidDZLi7Vs/dFnmNtOZulJ+bTy32nyscHzQxb6Voqou3v3PGXwevjWGjAXQNuI k8ZntZzx9V6rwIvWPvnZu25gGR7ERufDjG+YfjyHeeO9ZU+SXcfz4PWrSKTg5bQIXSF2 wXAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700560841; x=1701165641; 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=plgX48MN8LwMG+ilcYOBMqlRmLKn1sSJFx6OGgg5Yx4=; b=en20yH5ynrc8kHe8oMDz4Ig3Lg91I9iyJzKVDAPY1j2zfOcl9TdfyXkOU3C+ZjB7TN XdCUPgrlfspc/kUVd4e5jF0j39Kb+D8/gnXYgwK84Afnzaxi7KGbYLqwDii9Lqdlz2Dc 83Q3WgWmO8TQgA5i+kHW+0tTlScJIq6431LCrTTm4KmuwPsX+90tH44cscM5HCv9uz5p 7bXBH61JKnuCdkFEcKLyO12JHD+PaTGXSmxpCQchmACeN4fiixX/+dBAoLMg6XAHCeKM uxvAq88FIO3bz0a9YOZP7FslHelUAsbjmiONgGiBneezHrvac7k1wcvUAY5zG7tu+sdH Qu2w== X-Gm-Message-State: AOJu0YxMe7l6CLw2gaSliwj4gC6+873eCHoOQ0doRI4G4DS8h4HAzeYV Xo6UUVcWGHIekRHH1X66HWj5WzSI/i3XUaU1vm2G2Q== X-Google-Smtp-Source: AGHT+IF5RJLXj6ngrtcwIIxjWMEhBuwM6PgN8vCHZe0QX5dZ6vkl7ysQHnHKJvH2kYgxdKlHnzgBjQ== X-Received: by 2002:a05:6000:ac3:b0:32f:8b1c:106d with SMTP id di3-20020a0560000ac300b0032f8b1c106dmr1473579wrb.10.1700560841599; Tue, 21 Nov 2023 02:00:41 -0800 (PST) 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 i6-20020a05600c354600b004064288597bsm16656121wmq.30.2023.11.21.02.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:00:41 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Further cleanup in finalization machinery Date: Tue, 21 Nov 2023 11:00:39 +0100 Message-ID: <20231121100039.1964698-1-poulhies@adacore.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 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 List-Id: From: Eric Botcazou The bodies of generic units are instantiated separately by GNAT at the end of the processing of the compilation unit. This requires the deferral of the generation of cleanups and finalization actions in enclosing scopes, except for instantiations in generic units where they are not generated. The criterion used to detect this latter case is Inside_A_Generic, but this global variable is not properly updated during the instantiation of generic bodies, leading to problems with nested instantiations, so it is changed to Expander_Active instead. As a matter of fact, the exact same idiom is used a few lines above to clear the Needs_Body variable. gcc/ada/ * sem_ch12.adb (Analyze_Package_Instantiation): Test Expander_Active to detect generic contexts for the generation of cleanup actions. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch12.adb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 31fcbedf774..7c645c490ae 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -4824,10 +4824,7 @@ package body Sem_Ch12 is -- Cleanup actions are not generated within generic units -- or in the formal part of generic units. - if Inside_A_Generic - or else Is_Generic_Unit (S) - or else Ekind (S) = E_Void - then + if not Expander_Active then exit; -- For package scopes, cleanup actions are generated only -- 2.42.0