From patchwork Sat Jan 8 14:41:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 77953 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 EB13CB6EEB for ; Sun, 9 Jan 2011 01:41:19 +1100 (EST) Received: (qmail 9887 invoked by alias); 8 Jan 2011 14:41:17 -0000 Received: (qmail 9879 invoked by uid 22791); 8 Jan 2011 14:41:16 -0000 X-SWARE-Spam-Status: No, hits=0.3 required=5.0 tests=AWL, BAYES_50, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RFC_ABUSE_POST, TW_PM X-Spam-Check-By: sourceware.org Received: from mail-qy0-f175.google.com (HELO mail-qy0-f175.google.com) (209.85.216.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 08 Jan 2011 14:41:11 +0000 Received: by qyk8 with SMTP id 8so286981qyk.20 for ; Sat, 08 Jan 2011 06:41:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.235.142 with SMTP id kg14mr23467740qcb.133.1294497669926; Sat, 08 Jan 2011 06:41:09 -0800 (PST) Received: by 10.229.214.131 with HTTP; Sat, 8 Jan 2011 06:41:09 -0800 (PST) In-Reply-To: References: <4D272818.9010204@oracle.com> <4D274562.8020905@redhat.com> Date: Sat, 8 Jan 2011 15:41:09 +0100 Message-ID: Subject: Re: [patch c++]: Fix PR/47211 - ICE: in cp_build_addr_expr_1, at cp/typeck.c:4866 with -fms-extensions From: Kai Tietz To: Paolo Carlini Cc: Jason Merrill , GCC Patches X-IsSubscribed: yes 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 2011/1/8 Paolo Carlini : > ... watch trailing blank lines... ;) > > Paolo > Well, this is caused by copy&paste. corrected. thanks Kai Index: gcc/gcc/cp/typeck.c =================================================================== --- gcc.orig/gcc/cp/typeck.c 2011-01-08 15:39:31.899135600 +0100 +++ gcc/gcc/cp/typeck.c 2011-01-08 15:39:47.528310200 +0100 @@ -4558,7 +4558,14 @@ build_x_unary_op (enum tree_code code, t /* A pointer to member-function can be formed only by saying &X::mf. */ - if (!flag_ms_extensions && TREE_CODE (TREE_TYPE (xarg)) == METHOD_TYPE + if (flag_ms_extensions && TREE_CODE (TREE_TYPE (xarg)) == METHOD_TYPE + && !PTRMEM_OK_P (xarg) && TREE_CODE (xarg) == OFFSET_REF) + { + if (TREE_CODE (TREE_TYPE (xarg)) == METHOD_TYPE + && TYPE_P (TREE_OPERAND (xarg, 0))) + PTRMEM_OK_P (xarg) = 1; + } + if (TREE_CODE (TREE_TYPE (xarg)) == METHOD_TYPE && (TREE_CODE (xarg) != OFFSET_REF || !PTRMEM_OK_P (xarg))) { if (TREE_CODE (xarg) != OFFSET_REF @@ -4863,8 +4870,6 @@ cp_build_addr_expr_1 (tree arg, bool str tree type; tree t; - gcc_assert (PTRMEM_OK_P (arg)); - t = TREE_OPERAND (arg, 1); if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE) { @@ -4873,6 +4878,8 @@ cp_build_addr_expr_1 (tree arg, bool str return error_mark_node; } + gcc_assert (PTRMEM_OK_P (arg)); + type = build_ptrmem_type (context_for_name_lookup (t), TREE_TYPE (t)); t = make_ptrmem_cst (type, TREE_OPERAND (arg, 1)); Index: gcc/gcc/testsuite/g++.dg/ext/pr47211.C =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gcc/gcc/testsuite/g++.dg/ext/pr47211.C 2011-01-08 15:40:00.769067500 +0100 @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fms-extensions" } */ + +class chile +{ + typedef void (chile::* pmf) (); + void bar (pmf pmethod) + { + &(this->*pmethod); // { dg-error "invalid use of" } + } + void doo(void) { } + pmf foo(pmf pmethod) { return &(chile::doo); } +};