From patchwork Sun Sep 8 20:26:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 273464 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id A964B2C00BF for ; Mon, 9 Sep 2013 06:27:12 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=W3peBsCz/hPW8e9fNtG2lOTecv1mE+aVPZHzeGih3EH qHSCEvnvXCoFIFN/V1BrqKEmo5HTIp5u+GaczVE9mwVG1BpglGSGkYnG1o8R5Rly eanYCgBwix1wS0+oiQgBI2uUIu8O1BczopT7APpKSwJaFUOsI7IaYHBg3Ruv4KVY = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=Z7rmvkgEB/YRK1pgrTDQwW6NRT4=; b=u6ZBm4ERKsp+bkaPQ wKCiTkK5mUDohMRqfuBM75S+qHOuFL/nTj/NtJFDV7UhCNZ/+y5fy0AQWrFHookw Md3BXtVUHCxQ370BjiYRFM3WThB5bDE+yjTv4CWvtcoxkbAph11S1HwHi/UMs6SS +xShwMsON0FRTpR38EnuuLQvdk= Received: (qmail 26157 invoked by alias); 8 Sep 2013 20:27: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 26145 invoked by uid 89); 8 Sep 2013 20:27:04 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sun, 08 Sep 2013 20:27:04 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: aserp1040.oracle.com Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r88KQxu9006463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 8 Sep 2013 20:27:00 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r88KQwUX027111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 8 Sep 2013 20:26:59 GMT Received: from abhmt109.oracle.com (abhmt109.oracle.com [141.146.116.61]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r88KQwDm027108; Sun, 8 Sep 2013 20:26:58 GMT Received: from poldo4.casa (/79.43.214.237) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 08 Sep 2013 13:26:58 -0700 Message-ID: <522CDD90.9030708@oracle.com> Date: Sun, 08 Sep 2013 22:26:56 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Gabriel Dos Reis Subject: [C++ diagnostic Patch] Partially fix c++/58363 and more X-IsSubscribed: yes Hi all, Gaby, I was having a look to c++/58363 and besides the main issue, that is we probably want to help the user and tell him/her something about destructors, etc, I noticed that we aren't able to pretty print the pseudo destructor expression at issue: cannot convert ‘f.#‘var_decl’ not supported by dump_type#::~’ (type ‘void’) to type ‘int’ Weird. Thus I went to cp-tree.def and found the very clear comment: /* A pseudo-destructor, of the form "OBJECT.~DESTRUCTOR" or "OBJECT.SCOPE::~DESTRUCTOR. The first operand is the OBJECT. The second operand (if non-NULL) is the SCOPE. The third operand is the TYPE node corresponding to the DESTRUCTOR. which in fact is inconsistent with the code in error.c:dump_expr. As regards cxx-pretty-print.c, the code in postfix_expression seems largely Ok (that confirmed my analysis), only I don't think the case of NULL second operand is handled correctly. What do you think about the below? Certainly passes the testsuite and the pretty printing for 58363 is Ok. Thanks! Paolo. /////////////////////// 2013-09-08 Paolo Carlini * error.c (dump_expr, [PSEUDO_DTOR_EXPR]): Fix. * cxx-pretty-print.c (cxx_pretty_printer::postfix_expression): Tweak, TREE_OPERAND (t, 1) may be null. Index: error.c =================================================================== --- error.c (revision 202365) +++ error.c (working copy) @@ -2472,12 +2472,15 @@ dump_expr (cxx_pretty_printer *pp, tree t, int fla break; case PSEUDO_DTOR_EXPR: - dump_expr (pp, TREE_OPERAND (t, 2), flags); + dump_expr (pp, TREE_OPERAND (t, 0), flags); pp_cxx_dot (pp); - dump_type (pp, TREE_OPERAND (t, 0), flags); - pp_cxx_colon_colon (pp); + if (TREE_OPERAND (t, 1)) + { + dump_type (pp, TREE_OPERAND (t, 1), flags); + pp_cxx_colon_colon (pp); + } pp_cxx_complement (pp); - dump_type (pp, TREE_OPERAND (t, 1), flags); + dump_type (pp, TREE_OPERAND (t, 2), flags); break; case TEMPLATE_ID_EXPR: Index: cxx-pretty-print.c =================================================================== --- cxx-pretty-print.c (revision 202365) +++ cxx-pretty-print.c (working copy) @@ -618,8 +618,11 @@ cxx_pretty_printer::postfix_expression (tree t) case PSEUDO_DTOR_EXPR: postfix_expression (TREE_OPERAND (t, 0)); pp_cxx_dot (this); - pp_cxx_qualified_id (this, TREE_OPERAND (t, 1)); - pp_cxx_colon_colon (this); + if (TREE_OPERAND (t, 1)) + { + pp_cxx_qualified_id (this, TREE_OPERAND (t, 1)); + pp_cxx_colon_colon (this); + } pp_complement (this); pp_cxx_unqualified_id (this, TREE_OPERAND (t, 2)); break;