From patchwork Thu Jun 15 08:04:06 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: 108321 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp468814vqr; Thu, 15 Jun 2023 01:11:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6lj3yrpiDvunIT3Ifd9I+6zNNULYGonOkmMFwXYkPQtmGGRUdV4meLlcfhD723VvHgkBUs X-Received: by 2002:a17:906:dac5:b0:974:6335:4239 with SMTP id xi5-20020a170906dac500b0097463354239mr16639136ejb.34.1686816662710; Thu, 15 Jun 2023 01:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686816662; cv=none; d=google.com; s=arc-20160816; b=cqiH8lh4bZ5gTdyjd+g8dDlYPJKgM0d9TJdHKTLbKuXeba2pEzh9v2nBSSHRqJkVDK QoAB6vjtrihutNwC5UGCRxJl0xzKWhRIKB77EOela8a2nkEmB7X5ooCIGACSV0T7BkaO hxKC6R4ZGBJLUsPjqC5JleAHZQPhTAYDlGz3eCscqiuoik/7IAvATeJWt48Ju4Kp13+f 4kt1yJAiEvt8aEUyAfnPsjlRo5BBcbWmu74FyeNrZfhw7/roXiKAipoA607NxuFN5BjM dYwq3yo7Lsaw6LzM5kiuNxDV4O8b9TD7epHotg13JOnn9yWPt/ep0L0F9kbNDszOvD4I fQ7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=TR1WLLtr/5FtjY6mfxWDV9uwHf/462XZIyGD/je6go8=; b=lqMEIIaUTRNM82PTtedq/m+SUsDXdXzTWCAJOoDIoJEpW4KCCEKWccuPzuNJgKIXFT WIAPhk8yUTofpFJNsEZe56Nnh1Ke8iAzMTwbVBfXB3kyA+TKgZ8dwc8j3hNEVfuZkVQY G5CX1GBfAwckXFxzRdN+s2XTE0jGE+1IyCgiiwUmvfpzVn9WRaJ0uWLeMxn1Fui+OkTN LKPu1IkpGZdSzCVsD4Y3kyqNhfKF1NkmzM4XeYe9OMUWRwgnI1rEyqo0NR5yjdx+qHQP DDRC9PcKHLC2cVTDzwXWxbJKX5b5BpVzcjyd0X0yunPKrLO1/fM/M/Rsa6OjNlcLFDwK hgQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BSAgQQ0S; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id zb9-20020a17090687c900b0097462d656f8si8788455ejb.581.2023.06.15.01.11.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 01:11:02 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BSAgQQ0S; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A15DF3821FCE for ; Thu, 15 Jun 2023 08:07:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A15DF3821FCE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686816434; bh=TR1WLLtr/5FtjY6mfxWDV9uwHf/462XZIyGD/je6go8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=BSAgQQ0Spm9fNVxb+vOIc3bPfy1wrTpvchQVjwXInr3Rjazyoz9sMGhbRu+HutQdt X6EF7MfYXp4LS+n/JQxi8hpm8h9b41hTRZRMqSVMV52C6dzL67KhCaX0nYwVkPXuAl zIcKNEQOE5LCGC2ihwLYKxUbEp+9JsSIUBC4DU+Q= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 0029A3857B98 for ; Thu, 15 Jun 2023 08:04:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0029A3857B98 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31114b46d62so416695f8f.3 for ; Thu, 15 Jun 2023 01:04:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686816248; x=1689408248; 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=TR1WLLtr/5FtjY6mfxWDV9uwHf/462XZIyGD/je6go8=; b=KVgdSfUAZeTRlrRL0hiMvyJQGT+CJ9gaLpdhyaQtZ9l34eGHgmCTRFGmTyRtSndwcw 9zjf/J9n0qhlXpqcb9wW41MsCaqUQ7C08TYtWII7aARUrMbxQ0B7WfGTgk/a4pn8OE3i QcQ9XGtX+5H5zhRv4K/GT9mHNP+AaOa+/E2LgLxRtBUFfMl9bdreCrxojtu/+xtyHAJj fwfU2YjYIPgL61+Zt8SdMfWP8p+NezlSnGY7dTil+qEzI+fc2IWc55fUp8CuSM7de534 jjt9poh1+EhsWTCP4U7pYAUGyDxgOvPaWPcqbvcHwYAF5Z+iqPrXM4q2wc6T0aoueqmv Ez4w== X-Gm-Message-State: AC+VfDykY1l5bRM+AAsWDPE4ifb5xI1E0/PzgVZYYRN98z9AJOKu5Fxm YH0G22fEC8GRzhZrWHbUtvaoiqKS1jUFstCOAGx7kA== X-Received: by 2002:a5d:6991:0:b0:306:2f91:302e with SMTP id g17-20020a5d6991000000b003062f91302emr10767212wru.21.1686816247840; Thu, 15 Jun 2023 01:04:07 -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 e10-20020a056000194a00b0030497b3224bsm20284792wry.64.2023.06.15.01.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 01:04:07 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Reject aspect Always_Terminates on functions and generic functions Date: Thu, 15 Jun 2023 10:04:06 +0200 Message-Id: <20230615080406.939322-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 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 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768755469030776044?= X-GMAIL-MSGID: =?utf-8?q?1768755469030776044?= From: Piotr Trojanek The recently added aspect Always_Terminates is only allowed on procedures. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Reject pragma Always_Terminates when it applies to a function or generic function. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_prag.adb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 1fa946439ee..0febc445b35 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -13376,6 +13376,19 @@ package body Sem_Prag is Spec_Id := Unique_Defining_Entity (Subp_Decl); + -- Pragma Always_Terminates is not allowed on functions + + if Ekind (Spec_Id) = E_Function then + Error_Msg_N (Fix_Error + ("pragma % cannot apply to function"), N); + return; + + elsif Ekind (Spec_Id) = E_Generic_Function then + Error_Msg_N (Fix_Error + ("pragma % cannot apply to generic function"), N); + return; + end if; + -- A pragma that applies to a Ghost entity becomes Ghost for the -- purposes of legality checks and removal of ignored Ghost code.