From patchwork Tue Aug 1 22:18: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: 796413 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-459570-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="uUA1Qj4D"; 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 3xMVyp6yRFz9sN7 for ; Wed, 2 Aug 2017 08:16:14 +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:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=QOYbvHxEWymKbap8 jOl1JaGq/0LBzC28MYrzKB4AJI6VzPEJTsBdyQsk50N5bTd+77JueN0wJ8G7tEkA EYG6DVUxoZ0y7Hx0B1dSS0qwZCyPu6RTCHZ4wRM/u2Hjgi+qCNxidHpCby1Yn2eX UEYMo+zcNWWjsYfhfqmuMlA/U6s= 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=7vSoewBv4Z11Cu6BmJknz2 psFLI=; b=uUA1Qj4DlL1J6HvKUDMITxnJWzop4wZQTxYh3hNm5Iart7lR+Suzfm ZyDLp3wTH0oWTrXHXsNHha6rcx1QIzqSLsRwebI5RMsLmOINxzIVmHiOqEVVdzTz GtqXLTXXKXaBrdBcXwSUto65fE71PwInfv3ZdAgDdkom4IiGLk+zQ= Received: (qmail 86297 invoked by alias); 1 Aug 2017 22:16: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 76254 invoked by uid 89); 1 Aug 2017 22:15:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 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; Tue, 01 Aug 2017 22:15:51 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 191D5813D0 for ; Wed, 2 Aug 2017 00:15:49 +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 bDPMSq7Lu8hl for ; Wed, 2 Aug 2017 00:15:49 +0200 (CEST) Received: from arcturus.home (ADijon-653-1-158-213.w92-148.abo.wanadoo.fr [92.148.141.213]) (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 DEF42813CE for ; Wed, 2 Aug 2017 00:15:48 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Restore proper operation of -fdump-ada-spec in C++ Date: Wed, 02 Aug 2017 00:18:21 +0200 Message-ID: <1864403.CGTV8DKqOI@arcturus.home> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 It was broken by the recent removal of TYPE_METHODS. Bootstrapped/regtested on x86_64-suse-linux, applied on the mainline. 2017-08-01 Eric Botcazou c-family/ * c-ada-spec.c (has_static_fields): Look only into fields. (dump_generic_ada_node): Small tweak. (dump_nested_types): Look only into fields. (print_ada_declaration): Look only into methods. Small tweak. (print_ada_struct_decl): Look only into fields. Use DECL_VIRTUAL_P. Index: c-ada-spec.c =================================================================== --- c-ada-spec.c (revision 250797) +++ c-ada-spec.c (working copy) @@ -1052,13 +1052,11 @@ get_underlying_decl (tree type) static bool has_static_fields (const_tree type) { - tree tmp; - if (!type || !RECORD_OR_UNION_TYPE_P (type)) return false; - for (tmp = TYPE_FIELDS (type); tmp; tmp = TREE_CHAIN (tmp)) - if (DECL_NAME (tmp) && TREE_STATIC (tmp)) + for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld)) + if (TREE_CODE (fld) == FIELD_DECL && DECL_NAME (fld) && TREE_STATIC (fld)) return true; return false; @@ -2384,13 +2382,14 @@ dump_generic_ada_node (pretty_printer *buffer, tre { if (is_tagged_type (TREE_TYPE (node))) { - tree tmp = TYPE_FIELDS (TREE_TYPE (node)); int first = 1; /* Look for ancestors. */ - for (; tmp; tmp = TREE_CHAIN (tmp)) + for (tree fld = TYPE_FIELDS (TREE_TYPE (node)); + fld; + fld = TREE_CHAIN (fld)) { - if (!DECL_NAME (tmp) && is_tagged_type (TREE_TYPE (tmp))) + if (!DECL_NAME (fld) && is_tagged_type (TREE_TYPE (fld))) { if (first) { @@ -2400,8 +2399,8 @@ dump_generic_ada_node (pretty_printer *buffer, tre else pp_string (buffer, " and "); - dump_ada_decl_name - (buffer, TYPE_NAME (TREE_TYPE (tmp)), false); + dump_ada_decl_name (buffer, TYPE_NAME (TREE_TYPE (fld)), + false); } } @@ -2504,7 +2503,7 @@ dump_nested_types (pretty_printer *buffer, tree t, dump_nested_type (buffer, field, t, parent, spc); for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) - if (!TYPE_NAME (TREE_TYPE (field))) + if (TREE_CODE (field) == FIELD_DECL && !TYPE_NAME (TREE_TYPE (field))) dump_nested_type (buffer, field, t, parent, spc); TREE_VISITED (t) = 1; @@ -2955,7 +2954,8 @@ print_ada_declaration (pretty_printer *buffer, tre if (is_constructor && RECORD_OR_UNION_TYPE_P (type)) for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld)) - if (cpp_check (fld, IS_ABSTRACT)) + if (TREE_CODE (TREE_TYPE (fld)) == METHOD_TYPE + && cpp_check (fld, IS_ABSTRACT)) { is_abstract_class = true; break; @@ -3020,18 +3020,20 @@ print_ada_declaration (pretty_printer *buffer, tre if (cpp_check && RECORD_OR_UNION_TYPE_P (TREE_TYPE (t))) { - is_interface = -1; + bool has_fields = false; /* Check that there are no fields other than the virtual table. */ for (tree fld = TYPE_FIELDS (TREE_TYPE (t)); - fld; fld = TREE_CHAIN (fld)) + fld; + fld = TREE_CHAIN (fld)) { if (TREE_CODE (fld) == FIELD_DECL) { - if (is_interface < 0 && DECL_VIRTUAL_P (fld)) + if (!has_fields && DECL_VIRTUAL_P (fld)) is_interface = 1; else is_interface = 0; + has_fields = true; } else if (TREE_CODE (TREE_TYPE (fld)) == METHOD_TYPE && !DECL_ARTIFICIAL (fld)) @@ -3212,10 +3214,10 @@ print_ada_struct_decl (pretty_printer *buffer, tre field_num++; } } - else if (TREE_CODE (tmp) != TYPE_DECL && !TREE_STATIC (tmp)) + else if (TREE_CODE (tmp) == FIELD_DECL && !TREE_STATIC (tmp)) { /* Skip internal virtual table field. */ - if (strncmp (IDENTIFIER_POINTER (DECL_NAME (tmp)), "_vptr", 5)) + if (!DECL_VIRTUAL_P (tmp)) { if (is_union) { @@ -3306,7 +3308,9 @@ 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 (DECL_NAME (tmp) && TREE_STATIC (tmp)) + if (TREE_CODE (tmp) == FIELD_DECL + && DECL_NAME (tmp) + && TREE_STATIC (tmp)) { if (need_semicolon) {