From patchwork Sat Jan 8 12:44:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 77950 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 7AECBB70CD for ; Sat, 8 Jan 2011 23:44:52 +1100 (EST) Received: (qmail 6120 invoked by alias); 8 Jan 2011 12:44:51 -0000 Received: (qmail 6112 invoked by uid 22791); 8 Jan 2011 12:44:50 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL, BAYES_00, 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-f182.google.com (HELO mail-qy0-f182.google.com) (209.85.216.182) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 08 Jan 2011 12:44:46 +0000 Received: by qyk36 with SMTP id 36so19423885qyk.20 for ; Sat, 08 Jan 2011 04:44:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.75.18 with SMTP id w18mr1975089qcj.95.1294490684174; Sat, 08 Jan 2011 04:44:44 -0800 (PST) Received: by 10.229.214.131 with HTTP; Sat, 8 Jan 2011 04:44:44 -0800 (PST) In-Reply-To: <4D274562.8020905@redhat.com> References: <4D272818.9010204@oracle.com> <4D274562.8020905@redhat.com> Date: Sat, 8 Jan 2011 13:44:44 +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: Jason Merrill Cc: Paolo Carlini , 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/7 Jason Merrill : > As we discussed on IRC, we should reject this testcase with the same error > we gave in 3.4. > > Jason > According to our discussion I modified patch and do checking in build_x_unary_op. We use same code as without enable flag_ms_extension, beside that we allow parentheses around pointer-to-member for ms_extension. ChangeLog 2011-01-08 Kai Tietz PR c++/47211 * typeck.c (build_x_unary_op): Handle ms-extension flag. (cp_build_addr_expr_1): Move assert after reference check. 2011-01-08 Kai Tietz * g++.dg/ext/pr47211.C: New Tested for x86_64-w64-mingw32 and i686-pc-cygwin. Ok for apply? Regards, Kai Index: gcc/gcc/cp/typeck.c =================================================================== --- gcc.orig/gcc/cp/typeck.c 2011-01-08 13:27:11.000000000 +0100 +++ gcc/gcc/cp/typeck.c 2011-01-08 13:41:40.666964900 +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 13:32:52.527757100 +0100 @@ -0,0 +1,14 @@ +/* { 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); } +}; +