From patchwork Wed Nov 13 12:00:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1194229 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513231-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="qs2H4PJn"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Cjr94kzsz9sPJ for ; Wed, 13 Nov 2019 23:01:11 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=krD3OpsCDY3C787R EvvMGP0aVxK6XKzjJSPADFY9nsGxB5yxLIObVQL/UuLnnEMc4gXgqifLcA1pPOhd +xYnpbQCKtHWKQMZRC0YfKh0GByuxp21QLfu30g685BtJhR1TY1t2/9Uk1OChNbi pzN9ttEcd1cu6P143/ZayUKCNBM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=OPvf94Wwpz0hF7PbHdUlBO 8L/j4=; b=qs2H4PJnFPmikGaPolHWbb3sZq3lEr36vmNF0xFe4GwyZzmj9U7Zn+ Dz+886pYRh+hS1JFUAfGahFLQxS9yGQiBhE9lkbn4QSMUL2V4JA9zwfGCJ/vmKr+ BjhC042z+qfew1KAWS3Ey3lBUlx8Zulk4Xjx/Z9eNaApVo2Cy6NnU= Received: (qmail 24980 invoked by alias); 13 Nov 2019 12:01:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 24966 invoked by uid 89); 13 Nov 2019 12:01:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Nov 2019 12:00:59 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 528888137A for ; Wed, 13 Nov 2019 13:00:57 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vYw6A2kIfgyE for ; Wed, 13 Nov 2019 13:00:57 +0100 (CET) Received: from polaris.localnet (unknown [IPv6:2a01:e35:8a16:3850:1a03:73ff:fe45:373a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 2FF5E81369 for ; Wed, 13 Nov 2019 13:00:57 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix -fdump-ada-spec issue with array field Date: Wed, 13 Nov 2019 13:00:56 +0100 Message-ID: <2601463.SceXTyEzXo@polaris> MIME-Version: 1.0 This is a regression present on mainline and 9 branch: if the component type of array type is a structure declared in another file, then the binding would contain a local declaration for this structure type. Tested on x86_64-suse-linux, applied on the mainline and 9 branch. 2019-11-13 Eric Botcazou c-family/ * c-ada-spec.c (get_underlying_decl): Do not look through typedefs. (dump_forward_type): Do not generate a declaration for function types. (dump_nested_type) : Do not generate a nested declaration of the component type if it is declared in another file. Index: c-ada-spec.c =================================================================== --- c-ada-spec.c (revision 277906) +++ c-ada-spec.c (working copy) @@ -1025,7 +1025,9 @@ get_underlying_decl (tree type) if (TYPE_P (type)) { - type = TYPE_MAIN_VARIANT (type); + /* Strip qualifiers but do not look through typedefs. */ + if (TYPE_QUALS_NO_ADDR_SPACE (type)) + type = TYPE_MAIN_VARIANT (type); /* type is a typedef. */ if (TYPE_NAME (type) && DECL_P (TYPE_NAME (type))) @@ -2454,6 +2456,9 @@ dump_forward_type (pretty_printer *buffe if (DECL_SOURCE_FILE (decl) != DECL_SOURCE_FILE (t)) return; + if (TREE_CODE (type) == FUNCTION_TYPE) + return; + /* Generate an incomplete type declaration. */ pp_string (buffer, "type "); dump_ada_node (buffer, decl, NULL_TREE, spc, false, true); @@ -2522,7 +2527,10 @@ dump_nested_type (pretty_printer *buffer while (TREE_CODE (tmp) == ARRAY_TYPE) tmp = TREE_TYPE (tmp); decl = get_underlying_decl (tmp); - if (decl && !DECL_NAME (decl) && !TREE_VISITED (decl)) + if (decl + && !DECL_NAME (decl) + && DECL_SOURCE_FILE (decl) == DECL_SOURCE_FILE (t) + && !TREE_VISITED (decl)) { /* Generate full declaration. */ dump_nested_type (buffer, decl, t, parent, spc);