From patchwork Tue May 21 07:01:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1102568 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-501298-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="v7tiUc4/"; 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 457RX25LmXz9s5c for ; Tue, 21 May 2019 17:01:52 +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=IR4psEw5NIGze3LK 92vAorBPbNc1E05jtwuiL7l/Ah/R0tF3L6K61edeW2x/aLfQ0Fh6nbI6TnOTfCf/ pITm9sLZz7/h+9N1yJDPCMHKTtq1a1GxmPQx+RD1C/Sgl79FDNHhpDNPeg+fsju1 wqMN5vcT9OzEdp7/Od8dsJfzzEs= 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=Js8vhuapqXpZ+lOIUdKq02 yA93g=; b=v7tiUc4/AwpUiIEALrmNEdjdQk5LcV+W4u9pHcmHDRibSK8YSpB+1x yf3uJxlIqS2VV31IZF7vYolEUBAw0xUE/CEHrqC5NvYB0IH3eJjcWkJlisvtxDZj bJbz6ssRmBwlJUZUBJGXbnba1lYEEGomTmWH4BOblBsF0dl2dilRk= Received: (qmail 60787 invoked by alias); 21 May 2019 07:01:45 -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 60779 invoked by uid 89); 21 May 2019 07:01:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, 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; Tue, 21 May 2019 07:01:43 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 1F8B781353 for ; Tue, 21 May 2019 09:01:41 +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 h6O-qDq-nw_H for ; Tue, 21 May 2019 09:01:41 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (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 EFCCA81348 for ; Tue, 21 May 2019 09:01:40 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Small tweak to -fdump-ada-spec for assignment operators Date: Tue, 21 May 2019 09:01:38 +0200 Message-ID: <25552208.uRRxOHYkah@polaris> MIME-Version: 1.0 The interfacing with C++ assignment operators in Ada is not very clear but we should at least make sure that the generated binding compile. Tested on x86_64-suse-linux, applied on mainline as obvious for the cp/ part. 2019-05-21 Eric Botcazou c-family/ * c-ada-spec.h (enum cpp_operation): Add IS_ASSIGNMENT_OPERATOR. * c-ada-spec.c (print_assignment_operator): New function. (dump_ada_declaration) : Call it do dump explicit copy assignment operators declared as methods and filter out the others. 2019-05-21 Eric Botcazou cp/ * decl2.c (cpp_check) : New case. Index: c-family/c-ada-spec.c =================================================================== --- c-family/c-ada-spec.c (revision 271106) +++ c-family/c-ada-spec.c (working copy) @@ -2681,6 +2681,17 @@ print_destructor (pretty_printer *buffer pp_ada_tree_identifier (buffer, decl_name, t, false); } +/* Dump in BUFFER assignment operator spec corresponding to T. */ + +static void +print_assignment_operator (pretty_printer *buffer, tree t, tree type) +{ + tree decl_name = DECL_NAME (TYPE_NAME (type)); + + pp_string (buffer, "Assign_"); + pp_ada_tree_identifier (buffer, decl_name, t, false); +} + /* Return the name of type T. */ static const char * @@ -2920,6 +2931,7 @@ dump_ada_declaration (pretty_printer *bu bool is_method = TREE_CODE (TREE_TYPE (t)) == METHOD_TYPE; tree decl_name = DECL_NAME (t); bool is_abstract = false; + bool is_assignment_operator = false; bool is_constructor = false; bool is_destructor = false; bool is_copy_constructor = false; @@ -2931,6 +2943,7 @@ dump_ada_declaration (pretty_printer *bu if (cpp_check) { is_abstract = cpp_check (t, IS_ABSTRACT); + is_assignment_operator = cpp_check (t, IS_ASSIGNMENT_OPERATOR); is_constructor = cpp_check (t, IS_CONSTRUCTOR); is_destructor = cpp_check (t, IS_DESTRUCTOR); is_copy_constructor = cpp_check (t, IS_COPY_CONSTRUCTOR); @@ -2955,6 +2968,13 @@ dump_ada_declaration (pretty_printer *bu return 0; } + else if (is_assignment_operator) + { + /* ??? Skip implicit or non-method assignment operators for now. */ + if (DECL_ARTIFICIAL (t) || !is_method) + return 0; + } + /* If this function has an entry in the vtable, we cannot omit it. */ else if (!DECL_VINDEX (t) && *IDENTIFIER_POINTER (decl_name) == '_') { @@ -2977,6 +2997,8 @@ dump_ada_declaration (pretty_printer *bu print_constructor (buffer, t, type); else if (is_destructor) print_destructor (buffer, t, type); + else if (is_assignment_operator) + print_assignment_operator (buffer, t, type); else dump_ada_decl_name (buffer, t, false); Index: c-family/c-ada-spec.h =================================================================== --- c-family/c-ada-spec.h (revision 271106) +++ c-family/c-ada-spec.h (working copy) @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. enum cpp_operation { HAS_DEPENDENT_TEMPLATE_ARGS, IS_ABSTRACT, + IS_ASSIGNMENT_OPERATOR, IS_CONSTRUCTOR, IS_DESTRUCTOR, IS_COPY_CONSTRUCTOR, Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 271106) +++ cp/decl2.c (working copy) @@ -4247,6 +4247,8 @@ cpp_check (tree t, cpp_operation op) } case IS_ABSTRACT: return DECL_PURE_VIRTUAL_P (t); + case IS_ASSIGNMENT_OPERATOR: + return DECL_ASSIGNMENT_OPERATOR_P (t); case IS_CONSTRUCTOR: return DECL_CONSTRUCTOR_P (t); case IS_DESTRUCTOR: