From patchwork Sat Aug 5 22:03:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 798313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-459885-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="aRcxi+o9"; 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 3xPyRR2F61z9sDB for ; Sun, 6 Aug 2017 08:01:05 +1000 (AEST) 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:in-reply-to:references:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=odx oCN+Mb8kD98reop/zmeT6rXroetVFMSMS/U/SU0a29Kh/QgjAPumjBfVxHfxbKkm 19cFr9qbGNZ76AoYXst8JsP2wboM7PmXANIl3Qb9EeaBesFRDrT48A6lvuefXKcY c/I1u7ivBIxfDc8wET3hI0O3I5q1N3n/6yAhanMo= 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:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=default; bh=r10eK1bCJ iEl+Hi25+8G2zg0L6s=; b=aRcxi+o9DIYAgqWfmVjtVvAct9RgWbzpcUYEkxkLX lWdJIOagUZl9HvzfyJ0CksefdbUJexcPBzxjBsSCNDEufXswRjbrgQvaAWD40C8d RzXHWbZuB7ae5rpjl8nwV8w0PX5vKIaRwdYSvPWduiv2CiQysF8dzY0Kimgp52Cy Y4= Received: (qmail 22814 invoked by alias); 5 Aug 2017 22:00:54 -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 19859 invoked by uid 89); 5 Aug 2017 22:00:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No 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.2 spammy=CPP 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; Sat, 05 Aug 2017 22:00:51 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 7B74981363 for ; Sun, 6 Aug 2017 00:00:48 +0200 (CEST) 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 INU9YUKNqYhs for ; Sun, 6 Aug 2017 00:00:48 +0200 (CEST) Received: from arcturus.home (ADijon-653-1-154-117.w92-148.abo.wanadoo.fr [92.148.13.117]) (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 4F33981362 for ; Sun, 6 Aug 2017 00:00:48 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Re: Restore proper operation of -fdump-ada-spec in C++ Date: Sun, 06 Aug 2017 00:03:21 +0200 Message-ID: <5093394.kXI4feKI2F@arcturus.home> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) In-Reply-To: <1864403.CGTV8DKqOI@arcturus.home> References: <1864403.CGTV8DKqOI@arcturus.home> MIME-Version: 1.0 > It was broken by the recent removal of TYPE_METHODS. It turns out that the support for constructors/destructors also needs to be adjusted after the recent changes. Tested on x86_64-suse-linux, applied on the mainline. 2017-08-05 Eric Botcazou c-family/ * c-ada-spec.c (has_static_fields): Look only into variables. (print_constructor): Add TYPE parameter and use it for the name. (print_destructor): Likewise. (print_ada_declaration): Adjust to new constructor/destructor names. Adjust calls to print_constructor and print_destructor. (print_ada_struct_decl): Do not test TREE_STATIC on FIELD_DECL. Look only into variables in the final loop. Index: c-ada-spec.c =================================================================== --- c-ada-spec.c (revision 250802) +++ c-ada-spec.c (working copy) @@ -1056,7 +1056,7 @@ has_static_fields (const_tree type) return false; for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld)) - if (TREE_CODE (fld) == FIELD_DECL && DECL_NAME (fld) && TREE_STATIC (fld)) + if (TREE_CODE (fld) == VAR_DECL && DECL_NAME (fld)) return true; return false; @@ -2635,12 +2634,12 @@ dump_nested_type (pretty_printer *buffer, tree fie } } -/* Dump in BUFFER constructor spec corresponding to T. */ +/* Dump in BUFFER constructor spec corresponding to T for TYPE. */ static void -print_constructor (pretty_printer *buffer, tree t) +print_constructor (pretty_printer *buffer, tree t, tree type) { - tree decl_name = DECL_NAME (DECL_ORIGIN (t)); + tree decl_name = DECL_NAME (TYPE_NAME (type)); pp_string (buffer, "New_"); pp_ada_tree_identifier (buffer, decl_name, t, false); @@ -2649,9 +2648,9 @@ static void /* Dump in BUFFER destructor spec corresponding to T. */ static void -print_destructor (pretty_printer *buffer, tree t) +print_destructor (pretty_printer *buffer, tree t, tree type) { - tree decl_name = DECL_NAME (DECL_ORIGIN (t)); + tree decl_name = DECL_NAME (TYPE_NAME (type)); pp_string (buffer, "Delete_"); pp_ada_tree_identifier (buffer, decl_name, t, false); @@ -2907,7 +2906,8 @@ print_ada_declaration (pretty_printer *buffer, tre return 0; /* Only consider constructors/destructors for complete objects. */ - if (strncmp (IDENTIFIER_POINTER (decl_name), "__comp", 6) != 0) + if (strncmp (IDENTIFIER_POINTER (decl_name), "__ct_comp", 9) != 0 + && strncmp (IDENTIFIER_POINTER (decl_name), "__dt_comp", 9) != 0) return 0; } @@ -2935,9 +2935,9 @@ print_ada_declaration (pretty_printer *buffer, tre } if (is_constructor) - print_constructor (buffer, t); + print_constructor (buffer, t, type); else if (is_destructor) - print_destructor (buffer, t); + print_destructor (buffer, t, type); else dump_ada_decl_name (buffer, t, false); @@ -2976,7 +2976,7 @@ print_ada_declaration (pretty_printer *buffer, tre if (is_constructor) { pp_string (buffer, "pragma CPP_Constructor ("); - print_constructor (buffer, t); + print_constructor (buffer, t, type); pp_string (buffer, ", \""); pp_asm_name (buffer, t); pp_string (buffer, "\");"); @@ -2984,7 +2984,7 @@ print_ada_declaration (pretty_printer *buffer, tre else if (is_destructor) { pp_string (buffer, "pragma Import (CPP, "); - print_destructor (buffer, t); + print_destructor (buffer, t, type); pp_string (buffer, ", \""); pp_asm_name (buffer, t); pp_string (buffer, "\");"); @@ -3214,7 +3208,7 @@ print_ada_struct_decl (pretty_printer *buffer, tre field_num++; } } - else if (TREE_CODE (tmp) == FIELD_DECL && !TREE_STATIC (tmp)) + else if (TREE_CODE (tmp) == FIELD_DECL) { /* Skip internal virtual table field. */ if (!DECL_VIRTUAL_P (tmp)) @@ -3308,9 +3302,7 @@ print_ada_struct_decl (pretty_printer *buffer, tre /* Print the static fields of the structure, if any. */ for (tmp = TYPE_FIELDS (node); tmp; tmp = TREE_CHAIN (tmp)) { - if (TREE_CODE (tmp) == FIELD_DECL - && DECL_NAME (tmp) - && TREE_STATIC (tmp)) + if (TREE_CODE (tmp) == VAR_DECL && DECL_NAME (tmp)) { if (need_semicolon) {