From patchwork Tue Sep 6 07:16:03 2022 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: 1028 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp507233wrt; Tue, 6 Sep 2022 00:30:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR6wXdWjMUHio5IMpab6dyzTy2BMOo/bugy/kGYZ/mviNA+0gGlGcKJB7B9m8vP4yZtIIqdD X-Received: by 2002:a05:6402:84b:b0:44e:e6ec:ab22 with SMTP id b11-20020a056402084b00b0044ee6ecab22mr226031edz.148.1662449450843; Tue, 06 Sep 2022 00:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662449450; cv=none; d=google.com; s=arc-20160816; b=UcwX1F0g2MG/u+XmwiETrTkCLMjxNuUsi8dhd1gqqFbG2GVJBFa3ZaA9tcI8buz8bI fod0bTzEfntkFA3F/ytT4SJTN2M24Wo3ZX8u9BJa6HdJBtTVple2Bgivsdorraq6G5cR oTE5lW3a1JPe8uYX2AnRaQ01NFcOnUElB4LH6LA0c6AyIDLLOXQ3HpThh07/rN9vheAz oaMwMSAY0fv/+sISZRZO9P7Bl3eKCD3V62YvOCwpG9b00VNPI74xMCtdEXkae7xa39qa JPLHQWWZ6l9KTVJWzgQoVbpVbcNDPONXfl3TN/1sZoAFDRzVy1rqEbRQguxNbsLAfBNJ NG/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=deQh9CF2/HC4S9HX1aAOzqrUQPLWwLlaK8fJrawfsEM=; b=jN3uoWpLYVii8CYiG2gvdARfdaZi+7FbpWeZAmi8+LgTN4vrRD/lBpaOng7/2gBag3 M/khEUyxDyKD+OYlu6JgihrerY4taRog6uQ39yge2HQMF+dGEbvmYFwPQR+BbkDuykNA NLYPy+n5mON1yNEloShAwYaAsvIrVN7235GTu6jiccg5u19xr1A4ZllWUTfd2w3Dsb6b 8jlASgPkVDBKrX4ZB7zyBxkCr2GDTS84a+1eBU03YNM98LH09Hfvkb5ErlT+ki/ujC+p N1+u9ObogmwgZIAIw0va5kM7lZkkrS98YIzg7NZYubpqSdpuzP3m9HvuBEi8T6njupz6 NtkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CtqzKnrX; 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 go43-20020a1709070dab00b007318652a31bsi9449986ejc.577.2022.09.06.00.30.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 00:30:50 -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=CtqzKnrX; 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 A9D24381D440 for ; Tue, 6 Sep 2022 07:23:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9D24381D440 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662449032; bh=deQh9CF2/HC4S9HX1aAOzqrUQPLWwLlaK8fJrawfsEM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CtqzKnrXE2kRI41AjtlC5vxVjWKbDyogj/MPn+Uylnukfo3wWOAXRl9GWl8ubV0U7 d2TJdUbNJLusxqhtLgXFiHRSog7VnkIpqFszJBvxwS6Akw7s4zzLBWcWmGmwdaoOfv zNvo7V53+yRCcxL6uBQ4xEalqaN9RwnKsCQPl/9s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 6DA64385086E for ; Tue, 6 Sep 2022 07:16:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6DA64385086E Received: by mail-wr1-x431.google.com with SMTP id b5so14023883wrr.5 for ; Tue, 06 Sep 2022 00:16:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=deQh9CF2/HC4S9HX1aAOzqrUQPLWwLlaK8fJrawfsEM=; b=jcoTsewUxT4tQLlROREN+fJwDAmJGZVm9iIgyscJUI0m3S5IJGdLvyRKVuXI5Yi3EI rzASrrgc6yI5vADVEM0t/8+LH15TAHljXBB4V41t1MNGHpv96tXHB/FhWZeAZZAFqVKy nPWPgPBZHl6G+l7PbXdfZbsMD93LNDwvOufRpmvce7zsQMhITLjTWdBDZyFiRkvaM6ya Y7klriBHWUIhTm/SgBglXSA/fwp/6gfuum/tcwglJNI6QhTppzqNAKQOxs6N5/X9JXMp 0zFT4qc1100g9ItGOZ3H/oaX5/+YCNS+TVQqSOIZV6/lfvhaf+VaCMf1I5jU7Q53FPQK eCCA== X-Gm-Message-State: ACgBeo3dt0VTaCsokiUCpOFkTDHpLNfMvOCqrMhmSRPaKWvLbzImTRYh s93w8QF+HTucX5lMu4a7ScnrVcyvM91Duw== X-Received: by 2002:a5d:4dcd:0:b0:228:d1e4:9cf1 with SMTP id f13-20020a5d4dcd000000b00228d1e49cf1mr2106346wru.182.1662448564287; Tue, 06 Sep 2022 00:16:04 -0700 (PDT) Received: from poulhies-Precision-5550 (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id h25-20020a1ccc19000000b003a5e9337967sm13208300wmb.13.2022.09.06.00.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 00:16:03 -0700 (PDT) Date: Tue, 6 Sep 2022 09:16:03 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix missing name for access type in generic instantiation Message-ID: <20220906071603.GA1280545@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.0 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: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Eric Botcazou 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?1743204595256302024?= X-GMAIL-MSGID: =?utf-8?q?1743204595256302024?= Pointer types aren't named types in C so we need to take extra care in Ada to make sure that the name of access types is preserved. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gcc-interface/utils.cc (gnat_pushdecl): Preserve named TYPE_DECLs consistently for all kind of pointer types. diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -868,6 +868,13 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) } } +/* Pointer types aren't named types in the C sense so we need to generate a + typedef in DWARF for them. Also do that for fat pointer types because, + even though they are named types in the C sense, they are still the XUP + types created for the base array type at this point. */ +#define TYPE_IS_POINTER_P(NODE) \ + (TREE_CODE (NODE) == POINTER_TYPE || TYPE_IS_FAT_POINTER_P (NODE)) + /* For the declaration of a type, set its name either if it isn't already set or if the previous type name was not derived from a source name. We'd rather have the type named with a real name and all the pointer @@ -877,18 +884,14 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) { tree t = TREE_TYPE (decl); - /* Pointer types aren't named types in the C sense so we need to generate - a typedef in DWARF for them and make sure it is preserved, unless the - type is artificial. */ + /* For pointer types, make sure the typedef is generated and preserved + in DWARF, unless the type is artificial. */ if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL) - && (TREE_CODE (t) != POINTER_TYPE || DECL_ARTIFICIAL (decl))) + && (!TYPE_IS_POINTER_P (t) || DECL_ARTIFICIAL (decl))) ; /* For pointer types, create the DECL_ORIGINAL_TYPE that will generate - the typedef in DWARF. Also do that for fat pointer types because, - even though they are named types in the C sense, they are still the - XUP types created for the base array type at this point. */ - else if (!DECL_ARTIFICIAL (decl) - && (TREE_CODE (t) == POINTER_TYPE || TYPE_IS_FAT_POINTER_P (t))) + the typedef in DWARF. */ + else if (TYPE_IS_POINTER_P (t) && !DECL_ARTIFICIAL (decl)) { tree tt = build_variant_type_copy (t); TYPE_NAME (tt) = decl; @@ -920,9 +923,8 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) to all parallel types too thanks to gnat_set_type_context. */ if (t) for (t = TYPE_MAIN_VARIANT (t); t; t = TYPE_NEXT_VARIANT (t)) - /* ??? Because of the previous kludge, we can have variants of fat - pointer types with different names. */ - if (!(TYPE_IS_FAT_POINTER_P (t) + /* Skip it for pointer types to preserve the typedef. */ + if (!(TYPE_IS_POINTER_P (t) && TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL)) { @@ -932,6 +934,8 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) deferred_decl_context); } } + +#undef TYPE_IS_POINTER_P } /* Create a record type that contains a SIZE bytes long field of TYPE with a