From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id AD4F8385702D for ; Wed, 11 Nov 2020 13:40:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AD4F8385702D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=botcazou@adacore.com Received: by mail-wr1-x42f.google.com with SMTP id r17so2598700wrw.1 for ; Wed, 11 Nov 2020 05:40:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=uQSSphdSMC4iQ5z1nEdalHRrdK8x88zD41yLagsP+cE=; b=Qa7sbplZj6hmqSZDpkeYB1ncB+Uw+2V3yJnZnwz3zYerBBglb8NSKcQ2peaAhbDeGb o6tWi6lltm48k2Ypn4RAMaKQ8NKYvgZCsYLH9aVRUFiHOnQsQ2pVuu6rLRbgqnzXqbMS xX6vmbVwS2Kt977j8NLrDlOcLycIsn6yPctDNP5pnOye2qPS4bFBOP2ykGbhz/v2VJEr LNS/Wx2zvHDKWDkzZx7gy5e07yZ2MBifoNYF5NettBu24M/Ipmmq3UOLYwhxmFrXITRs z33bUbNceK3q/+zWkbHHw45JOSRmVa0cxJJSwJDWc2OqFOdoEW1i5TAoUcAtp0Qr5w0+ S8NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=uQSSphdSMC4iQ5z1nEdalHRrdK8x88zD41yLagsP+cE=; b=FrOjiOoLkm+suqtkCrh5J3KxgmnMw2WKr1zlD357zCpYiY7KToS+LjMQVCSfSDTnFs uz1gSmVZ+ZljdOkZJlBBVcApc/9ZALF0RCdLWE2c6J7llhC7mz7XXN4UZKpfYLpEML6P DwCstpso2qb4+MKHd7BpAYdKhC+PMBsx00LKf5qSZZpjAUAAzi8Ste1QkScEg/qy5XC5 SQaJ8EDLpBadJvaHCJ4p3Sw9kT9PyHXgpwbmbMwc7e3KirjqgW/zDOYZdh47B/8NFMpa uirE+9iEZxzGSS8AGzvxi1C/VzUzPDEnvDfi4vrzk3Og8Dm0YmCDMmBEGCHKbXFmni9e pyYA== X-Gm-Message-State: AOAM530huYw6k2j3mCiVr4MHFlx06/6AXjmu/i5lx3ON5O+2uaOR6mcF hhv/j2sdwebPOgauq+TUcID+4imA4AIwEDRF X-Google-Smtp-Source: ABdhPJy5oJCrkhmkgcI66XF69sts6oXaqwW1gbJAlDpl+aNnT1Hlv/QHcX6u7kmZCB/Tjc24HIGPVw== X-Received: by 2002:adf:eb4c:: with SMTP id u12mr31499137wrn.73.1605102053385; Wed, 11 Nov 2020 05:40:53 -0800 (PST) Received: from fomalhaut.localnet ([2a01:e0a:41b:9230:7f82:53f4:769e:54b6]) by smtp.gmail.com with ESMTPSA id l13sm2671215wrm.24.2020.11.11.05.40.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Nov 2020 05:40:52 -0800 (PST) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix internal error on chain of constants with -gnatc Date: Wed, 11 Nov 2020 14:40:50 +0100 Message-ID: <2988070.GD7PktBM71@fomalhaut> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1912942.nyhBAerG1H" Content-Transfer-Encoding: 7Bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Wed, 11 Nov 2020 13:40:56 -0000 This is a multi-part message in MIME format. --nextPart1912942.nyhBAerG1H Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" This is a rather obscure case not really worth commenting. :-) Tested on x86-64/Linux, applied on the mainline. 2020-11-11 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity) : In case the constant is not being defined, get the expression in type annotation mode only if its type is elementary. -- Eric Botcazou --nextPart1912942.nyhBAerG1H Content-Disposition: attachment; filename="p.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="p.diff" diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 4e6dc84beea..baae58a025f 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -667,21 +667,24 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* If we have a constant that we are not defining, get the expression it was defined to represent. This is necessary to avoid generating dumb - elaboration code in simple cases, but we may throw it away later if it + elaboration code in simple cases, and we may throw it away later if it is not a constant. But do not do it for dispatch tables because they are only referenced indirectly and we need to have a consistent view of the exported and of the imported declarations of the tables from external units for them to be properly merged in LTO mode. Moreover - simply do not retrieve the expression it if it is an allocator since + simply do not retrieve the expression if it is an allocator because the designated type might still be dummy at this point. Note that we invoke gnat_to_gnu_external and not gnat_to_gnu because the expression may contain N_Expression_With_Actions nodes and thus declarations of - objects from other units that we need to discard. */ + objects from other units that we need to discard. Note also that we + need to do it even if we are only annotating types, so as to be able + to validate representation clauses using constants. */ if (!definition && !No_Initialization (gnat_decl) && !Is_Dispatch_Table_Entity (gnat_entity) && Present (gnat_temp = Expression (gnat_decl)) - && Nkind (gnat_temp) != N_Allocator) + && Nkind (gnat_temp) != N_Allocator + && (Is_Elementary_Type (Etype (gnat_entity)) || !type_annotate_only)) gnu_expr = gnat_to_gnu_external (gnat_temp); /* ... fall through ... */ --nextPart1912942.nyhBAerG1H--