From patchwork Wed May 18 14:32:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 54166 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 501F53898C6B for ; Wed, 18 May 2022 14:40:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 501F53898C6B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652884842; bh=Uu/RHpCnqwYRKDdfr0qEOxKHBR37lnzMoeIYDB76HU4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=E93ys++hxRe3H6q3y8OK+WoDbRg7FBd0vwIMqTnjLdU2k1/IXb9Wt1JikxM9c3O8o ZoR4eTbc+roO7Y/xcQbqbBFf6+GDL7jD/0wcahGRwqW+3CNSmh5bSZ0//Iu88scFwc +WWltzfU2DNFYh1KVnJRf9uZv0E2ZVxU7CogOOTo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id A4FBC3838005 for ; Wed, 18 May 2022 14:33:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A4FBC3838005 Received: by mail-wr1-x434.google.com with SMTP id r23so3012912wrr.2 for ; Wed, 18 May 2022 07:33:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=Uu/RHpCnqwYRKDdfr0qEOxKHBR37lnzMoeIYDB76HU4=; b=Oa6P8JPvDm7neHTndkyK5zBV4fToIs3ksf4GOGuMjFd45xcKHFsHhfIMojwojOHRrV qaVHsnBUynpAUorD6AVF5FQjRvjzVB3BX83NvYYi+1HFiwWTPA/fO+5S2qspTfd7CkPP g1BATCR+6Iia+3e4HAkN4pPKxdUYQNgZOQHnP8J8jJYMkEyC0jm6nIKz+HP0V5bzMwh3 UAb8D6LDU/kNfZOGP8HTd4EtrqnlMwpGJ+m7zMKcwnji4DVuyZQTUrYl7IscQgyYb8kh UEpDgM/gmNuOwalRIw4xzCXfmzkKaHqvPyXJFwVPDqS+wDwBEU2PT0CrQER+7LMu4O/d tebA== X-Gm-Message-State: AOAM5308QxgaRrhzLtS1PU770i1rve48g3rIFQG3laQFH+hMdWfzMock b7LKjGjYxKRH791EbADnvBL94KeN0nD3dtSo X-Google-Smtp-Source: ABdhPJyohkpYdfoNkTDO/dI9Bcqzfrzxx4uPdzh5BDx9MHGDu6I+jGSFZoOZMIOF2/yxcOtcuFP6Tg== X-Received: by 2002:adf:f24c:0:b0:20c:fe15:504c with SMTP id b12-20020adff24c000000b0020cfe15504cmr17647175wrp.123.1652884380341; Wed, 18 May 2022 07:33:00 -0700 (PDT) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:bf38:f508:6f40:de1d]) by smtp.gmail.com with ESMTPSA id l9-20020a5d6d89000000b0020c5253d8f3sm2690689wrs.63.2022.05.18.07.32.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 07:32:59 -0700 (PDT) X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [c-family] Reduce usage of limited_with clauses with -fdump-ada-spec Date: Wed, 18 May 2022 16:32:58 +0200 Message-ID: <5722813.MhkbZ0Pkbq@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 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: Eric Botcazou via Gcc-patches From: Eric Botcazou Reply-To: Eric Botcazou Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The problem is that subtypes are not part of the limited view of a package so we need to use types in conjunction with limited_with clauses, which is not always desirable since this yields less portable Ada bindings. The patch also contains a small enhancement for complex floating-point types. Tested on x86-64/Linux, applied on mainline and 12 branch. 2022-05-18 Eric Botcazou * c-ada-spec.cc (dump_ada_node) : Deal with usual floating-point complex types. : Do not use limited_with clause if the designated type is a scalar type. diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc index f291e150934..faf71742522 100644 --- a/gcc/c-family/c-ada-spec.cc +++ b/gcc/c-family/c-ada-spec.cc @@ -2105,6 +2105,21 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, append_withs ("Interfaces.C.Extensions", false); pp_string (buffer, "Extensions.CFloat_128"); } + else if (TREE_TYPE (node) == float_type_node) + { + append_withs ("Ada.Numerics.Complex_Types", false); + pp_string (buffer, "Ada.Numerics.Complex_Types.Complex"); + } + else if (TREE_TYPE (node) == double_type_node) + { + append_withs ("Ada.Numerics.Long_Complex_Types", false); + pp_string (buffer, "Ada.Numerics.Long_Complex_Types.Complex"); + } + else if (TREE_TYPE (node) == long_double_type_node) + { + append_withs ("Ada.Numerics.Long_Long_Complex_Types", false); + pp_string (buffer, "Ada.Numerics.Long_Long_Complex_Types.Complex"); + } else pp_string (buffer, ""); break; @@ -2190,7 +2205,7 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, { tree ref_type = TREE_TYPE (node); const unsigned int quals = TYPE_QUALS (ref_type); - bool is_access = false; + bool is_access; if (VOID_TYPE_P (ref_type)) { @@ -2242,7 +2257,10 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, } if (!package_prefix) - pp_string (buffer, "access"); + { + is_access = false; + pp_string (buffer, "access"); + } else if (AGGREGATE_TYPE_P (ref_type)) { if (!type || TREE_CODE (type) != FUNCTION_DECL) @@ -2256,17 +2274,21 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, pp_string (buffer, "all "); } else if (quals & TYPE_QUAL_CONST) - pp_string (buffer, "in "); + { + is_access = false; + pp_string (buffer, "in "); + } else { is_access = true; pp_string (buffer, "access "); - /* ??? should be configurable: access or in out. */ } } else { - is_access = true; + /* We want to use regular with clauses for scalar types, + as they are not involved in circular declarations. */ + is_access = false; pp_string (buffer, "access "); if (!name_only)