From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x431.google.com with SMTP id b5so14023883wrr.5 for ; Tue, 06 Sep 2022 00:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=deQh9CF2/HC4S9HX1aAOzqrUQPLWwLlaK8fJrawfsEM=; b=f0947r/7BzQZxl3Qb9u79KiidyiMsMJC65WVYcK8PaLHSBBYdRAYO8pwSYiIhtj3eO mP0NvB24ZjMqzoRTJepLDSIkyoS3mY8XTMFMZi2Cz4iljBMi6ir1XRomyk4D2jIWotKt ZAkG6VpLPOQYYwnMHcs0JyDoFJjbca4lmWb/tZAUo9Jri14T7IdCBUkuQXXDnYg+xIbR +1wWNcX4Rnh768mMTqMu/6Hldwet17LZq/ITVxUFhWkBEkkmj0PGbr6W80MXmGOux58Z 4bL7Yy++rwxcbR7TTLCKXfb8QzYR/8qNxkeRc6+dG+YUl8bBD5XHpBWr7JcydtYesret lOFQ== 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-Google-Smtp-Source: AA6agR5pIn1/JvnwXjiUQH4+7frTklNC3CpRRmmdkomJkIPt7Ex2B7cgQVL2ysFiCxbRVacVi0O/fg== 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 From: Marc =?iso-8859-1?Q?Poulhi=E8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Fix missing name for access type in generic instantiation Message-ID: <20220906071603.GA1280545@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J2SCkAp4GZ/dPZZf" 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 List-Id: --J2SCkAp4GZ/dPZZf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --J2SCkAp4GZ/dPZZf Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" 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 --J2SCkAp4GZ/dPZZf--