From patchwork Mon May 29 08:29:36 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: 100167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1366648vqr; Mon, 29 May 2023 01:46:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7+VDmF6dBMr/zhZo685N6ShyWQqUfdwN3OqsKd3N7YFDCcXp8sR40J+LzonBEb0eQ++LJp X-Received: by 2002:a17:907:9284:b0:966:dd1:bae2 with SMTP id bw4-20020a170907928400b009660dd1bae2mr9859317ejc.73.1685349963315; Mon, 29 May 2023 01:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685349963; cv=none; d=google.com; s=arc-20160816; b=UJk9T6eeqX5jeY9zXSUkFnLcQiETtcgOr7g+aXIUswyIhkYCE9VVkQptAftuQ+16/Y le5V/GOt4FRNdBe8J3iAlgbm0gLeYC77+C5Le19qWrBpEwGaHUtASAq8FbrP9GsV4OSq 5BMh2tXJJ5kn+7JFFEzzHdOOHa1ZgkxnHNbx94tyZ6P9bjq577aXTqyE78df/HfnRZhV 5fyHnzcB9ZXIRfa3ZRzY7IlowTSewpYgqZ3bZ3N1Cn3wLhFfs5+jgO0NZbu2ZBWlfutB WmdJzDY7FyU0y9Zb9yvbM6Oigi7kU5u4eA3nqe/fVlHzMBHAI4pV/Vb6DZyiHwQEvViV b6OQ== 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=VqOLkjDhxWKWeGUosW4pTWwcgD30QTpYpaiTv/Mu0KA=; b=OfrLHkGmsx8O4VI+Z++UJH9Ur7YMOS5xjqFY8vqDe/DOlI2SxzRT48uYj8MqJLUbe5 H/Zi6P38wR2nsgLSzhHH7w9n8K/znz52NKe35GrWcql3k0Cjp9NGxX3zpXHwpCygbjkf U000uJRiUOFzy2bwzFDZ7szW2JJEq/ZwntofuKJc4mHIg6cOGiuFTuadgqLwjOwgv7eC eeUh4k0lU0yV5v0NLOsSP0tPeZOSOaWlwODlE6X1ye7TmnvKzk8rKgq29RhdezgFnaRZ B6xSIuPJ6yzmcFeNvjiYzQsKR9t7Hre69IkUnDZmk/0k/A8R4VrYd5Avn1/bGubPBva+ EsHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fI79Obxa; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fp20-20020a1709069e1400b0096606485250si2178412ejc.390.2023.05.29.01.46.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:46:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fI79Obxa; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 6FAC6395BC7C for ; Mon, 29 May 2023 08:38:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FAC6395BC7C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685349511; bh=VqOLkjDhxWKWeGUosW4pTWwcgD30QTpYpaiTv/Mu0KA=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=fI79ObxazcCh229WD+b2SsIYsraNbF5heMrnIUFC5M2rcz8Niqh4tl/yQIElQgZKu 4zLIDlStqW9MXSibmqTNQBzjN4WDaK+Suew6cRYiXCneICLFM28XgU2sHLDrvjnC9a egUPoo3EsAzAvWZckYrOsSiCwwghCY1lPXziO2Uk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 2AD75384DA52 for ; Mon, 29 May 2023 08:29:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AD75384DA52 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-30ae95c4e75so919339f8f.2 for ; Mon, 29 May 2023 01:29:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685348978; x=1687940978; 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=VqOLkjDhxWKWeGUosW4pTWwcgD30QTpYpaiTv/Mu0KA=; b=lNLR2ufdKur/AwM0+G+pQLwmC0NDYgx+/ozWGBn/DdumrQzXv0ASQEYibO0wTVILP2 2BThr8fEmDMKEUXSD2ApVyfntPfVu5nDwTYyrXh8hL4xlHgJHewGD5vCQAQ6DEAsHg0M Sn4pTF15cTneXGgLMro6XbUX2NdjJas/mO2H2UX3BMj5Bo8Aph8KuUX+PvIibRAsY0ev DRQDEfNd48nnUBR4s3Nyk1DJXWEdRlHN/6RunIHAlhIn4SHz82dllagoq9EVE8Ny6ayE WyBeQFnKiYg9eY2EdKWY0ifTi7DuGA/GdVnIHi4xbmL89fvemLSWLyBJG5D82+p6oDjw 022g== X-Gm-Message-State: AC+VfDx+Y/0hGjYKuGUEbkq6/gUcSLN+KI5kyu/UkvCgi4nOrGfe3Egl GvgozwonfBG76cNvIumoJCok7Wt3bIvlKCmuOCcHnA== X-Received: by 2002:a05:6000:196b:b0:306:26d1:230a with SMTP id da11-20020a056000196b00b0030626d1230amr8052797wrb.65.1685348978437; Mon, 29 May 2023 01:29:38 -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 r9-20020adff109000000b002f9e04459desm12886766wro.109.2023.05.29.01.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:29:37 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix internal error with pragma Compile_Time_{Warning, Error} Date: Mon, 29 May 2023 10:29:36 +0200 Message-Id: <20230529082936.2410625-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?1767217523537289301?= X-GMAIL-MSGID: =?utf-8?q?1767217523537289301?= From: Eric Botcazou This happens when the pragmas are deferred to the back-end from an external unit to the main unit that is generic, because the back-end does not compile a main unit that is generic. gcc/ada/ * sem_prag.adb (Process_Compile_Time_Warning_Or_Error): Do not defer anything to the back-end when the main unit is generic. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_prag.adb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index b74c60cd183..0d62b04cc37 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -8137,7 +8137,9 @@ package body Sem_Prag is -- then. For example, if the expression is "Record_Type'Size /= 32" -- it might be known after the back end has determined the size of -- Record_Type. We do not defer validation if we're inside a generic - -- unit, because we will have more information in the instances. + -- unit, because we will have more information in the instances, and + -- this ultimately applies to the main unit itself, because it is not + -- compiled by the back end when it is generic. if Compile_Time_Known_Value (Arg1x) then Validate_Compile_Time_Warning_Or_Error (N, Sloc (Arg1)); @@ -8155,7 +8157,10 @@ package body Sem_Prag is end if; end loop; - if No (P) then + if No (P) + and then + Nkind (Unit (Cunit (Main_Unit))) not in N_Generic_Declaration + then Defer_Compile_Time_Warning_Error_To_BE (N); end if; end if;