From patchwork Thu Oct 11 22:24:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 191012 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]) by ozlabs.org (Postfix) with SMTP id 83F4D2C0093 for ; Fri, 12 Oct 2012 09:24:19 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1350599059; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:cc:Subject:Message-ID:User-Agent:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=eqnl1TT IObDNAlg6Dg0LvYmnT4c=; b=Eb4Y3SxIiKYSlqgztfIMM8jy3dQOn0lClPkWRyW Qpr7+9PWycRLy/ILxlesNboFqQOGwQQLn1yxBabvxeRn2a0ax4L2evT+6UdjUVJ6 YcdG2qUIq01l4gP+fd8vAlaYPS6Jhdbc00IfuinTBIq8vcVGwnwVr3rIFlgzIyWP d4FE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Date:From:To:cc:Subject:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=mbZ30+LcMzyp6PrrcEwZMkSUOSiQQR1XUs/RNSdVPHBJdnZfe7aAajxI3X1Shn BAxea1m0j9WrEVkGobfZLudVtUR1GDMK9C41vXDYcI+KlnLJqIDtnTeaL/8AaNeK lOScEiWVkPsX0QRgrcPFSSozg1sNGwfZDqP5/yP5p6G9Y=; Received: (qmail 21144 invoked by alias); 11 Oct 2012 22:24:12 -0000 Received: (qmail 21130 invoked by uid 22791); 11 Oct 2012 22:24:11 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SUBJ_ALL_CAPS, TW_TM X-Spam-Check-By: sourceware.org Received: from mail1-relais-roc.national.inria.fr (HELO mail1-relais-roc.national.inria.fr) (192.134.164.82) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 11 Oct 2012 22:24:06 +0000 Received: from stedding.saclay.inria.fr ([193.55.250.194]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 12 Oct 2012 00:24:05 +0200 Received: from glisse (helo=localhost) by stedding.saclay.inria.fr with local-esmtp (Exim 4.80) (envelope-from ) id 1TMRAj-000638-33; Fri, 12 Oct 2012 00:24:05 +0200 Date: Fri, 12 Oct 2012 00:24:05 +0200 (CEST) From: Marc Glisse To: gcc-patches@gcc.gnu.org cc: jason@redhat.com Subject: [C++] PR53055 Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 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 Hello, this is an old patch that Paolo dug out of bugzilla and where I only changed the error message. It fixes an ICE on invalid code. Note that the code uses error() like the nearby code so the caret appears on the RHS while the message is about the LHS. Paolo offered to look into it as a follow-up (the LHS doesn't have a location attached to it, so it isn't just a matter of using error_at). bootstrap+testsuite ok. 2012-10-12 Marc Glisse PR c++/53055 gcc/c-family/ * c-common.h (enum ref_operator) [RO_ARROW_PM]: New. gcc/cp/ * call.c (build_new_op_1): Pass RO_ARROW_PM to cp_build_indirect_ref. * typeck.c (cp_build_indirect_ref): Handle RO_ARROW_PM. gcc/testsuite/ * g++.dg/pr53055.C: New testcase. Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 192378) +++ cp/typeck.c (working copy) @@ -2901,20 +2901,24 @@ cp_build_indirect_ref (tree ptr, ref_ope { case RO_ARRAY_INDEXING: error ("invalid use of array indexing on pointer to member"); break; case RO_UNARY_STAR: error ("invalid use of unary %<*%> on pointer to member"); break; case RO_IMPLICIT_CONVERSION: error ("invalid use of implicit conversion on pointer to member"); break; + case RO_ARROW_PM: + error ("left hand operand of %<->*%> must be a pointer to class, " + "but is a pointer to member of type %qT", type); + break; default: gcc_unreachable (); } else if (pointer != error_mark_node) invalid_indirection_error (input_location, type, errorstring); return error_mark_node; } /* This handles expressions of the form "a[i]", which denotes Index: cp/call.c =================================================================== --- cp/call.c (revision 192378) +++ cp/call.c (working copy) @@ -5302,21 +5302,21 @@ build_new_op_1 (location_t loc, enum tre case POSTDECREMENT_EXPR: case REALPART_EXPR: case IMAGPART_EXPR: case ABS_EXPR: return cp_build_unary_op (code, arg1, candidates != 0, complain); case ARRAY_REF: return cp_build_array_ref (input_location, arg1, arg2, complain); case MEMBER_REF: - return build_m_component_ref (cp_build_indirect_ref (arg1, RO_NULL, + return build_m_component_ref (cp_build_indirect_ref (arg1, RO_ARROW_PM, complain), arg2, complain); /* The caller will deal with these. */ case ADDR_EXPR: case COMPONENT_REF: case COMPOUND_EXPR: return NULL_TREE; default: Index: c-family/c-common.h =================================================================== --- c-family/c-common.h (revision 192378) +++ c-family/c-common.h (working copy) @@ -470,21 +470,23 @@ extern c_language_kind c_language; typedef enum ref_operator { /* NULL */ RO_NULL, /* array indexing */ RO_ARRAY_INDEXING, /* unary * */ RO_UNARY_STAR, /* -> */ RO_ARROW, /* implicit conversion */ - RO_IMPLICIT_CONVERSION + RO_IMPLICIT_CONVERSION, + /* ->* */ + RO_ARROW_PM } ref_operator; /* Information about a statement tree. */ struct GTY(()) stmt_tree_s { /* A stack of statement lists being collected. */ VEC(tree,gc) *x_cur_stmt_list; /* In C++, Nonzero if we should treat statements as full expressions. In particular, this variable is non-zero if at the Index: testsuite/g++.dg/pr53055.C =================================================================== --- testsuite/g++.dg/pr53055.C (revision 0) +++ testsuite/g++.dg/pr53055.C (revision 0) @@ -0,0 +1,5 @@ +// PR c++/53055 +// { dg-do compile } + +struct A A :: * p ; +int i = p ->* p ; // { dg-error "" }