From patchwork Fri Jan 7 14:39:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 77876 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 6BDCEB7088 for ; Sat, 8 Jan 2011 01:39:42 +1100 (EST) Received: (qmail 18344 invoked by alias); 7 Jan 2011 14:39:40 -0000 Received: (qmail 18336 invoked by uid 22791); 7 Jan 2011 14:39:39 -0000 X-SWARE-Spam-Status: No, hits=-1.1 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 X-Spam-Check-By: sourceware.org Received: from mail-qw0-f47.google.com (HELO mail-qw0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 07 Jan 2011 14:39:34 +0000 Received: by qwi2 with SMTP id 2so1997859qwi.20 for ; Fri, 07 Jan 2011 06:39:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.95.193 with SMTP id e1mr4484126qcn.171.1294411171848; Fri, 07 Jan 2011 06:39:31 -0800 (PST) Received: by 10.229.214.131 with HTTP; Fri, 7 Jan 2011 06:39:31 -0800 (PST) Date: Fri, 7 Jan 2011 15:39:31 +0100 Message-ID: Subject: [patch c++]: Fix PR/47211 - ICE: in cp_build_addr_expr_1, at cp/typeck.c:4866 with -fms-extensions From: Kai Tietz To: GCC Patches Cc: Jason Merrill 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 Hello, this patch addresses issue reported at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47211 2011-01-07 Kai Tietz PR c++/47211 * decl.c (build_ptrmem_type): Resolve VAR_DECL and FUNCTION_DECL to their underlying type. * typeck.c (cp_build_addr_expr_1): Handle flag_ms_extensions. 2011-01-07 Kai Tietz PR c++/47211 * g++.dg/ext/pr47211.C: New. Tested for x86_64-w64-mingw32, and i686-pc-cygwin. I am not sure if this ...DECL handling should be done in build_ptrmem_type itself, or if we should handle it just in typeck.c's cp_build_addr_expr_1. Ok? Regards, Kai Index: gcc/gcc/cp/decl.c =================================================================== --- gcc.orig/gcc/cp/decl.c 2011-01-07 15:21:47.000000000 +0100 +++ gcc/gcc/cp/decl.c 2011-01-07 14:48:03.354579300 +0100 @@ -7423,6 +7423,9 @@ build_ptrmemfunc_type (tree type) tree build_ptrmem_type (tree class_type, tree member_type) { + if (TREE_CODE (class_type) == FUNCTION_DECL + || TREE_CODE (class_type) == VAR_DECL) + class_type = TREE_TYPE (class_type); if (TREE_CODE (member_type) == METHOD_TYPE) { cp_cv_quals quals = type_memfn_quals (member_type); Index: gcc/gcc/cp/typeck.c =================================================================== --- gcc.orig/gcc/cp/typeck.c 2011-01-07 15:23:34.000000000 +0100 +++ gcc/gcc/cp/typeck.c 2011-01-07 15:18:12.580785500 +0100 @@ -4859,11 +4859,12 @@ cp_build_addr_expr_1 (tree arg, bool str offset_ref: /* Turn a reference to a non-static data member into a pointer-to-member. */ + { tree type; tree t; - gcc_assert (PTRMEM_OK_P (arg)); + gcc_assert (PTRMEM_OK_P (arg) || flag_ms_extensions); t = TREE_OPERAND (arg, 1); if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE) @@ -4878,7 +4879,7 @@ cp_build_addr_expr_1 (tree arg, bool str t = make_ptrmem_cst (type, TREE_OPERAND (arg, 1)); return t; } - + /* Fall through. */ default: break; } 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-07 15:29:44.492606100 +0100 @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fms-extensions" } */ + +class chile +{ + typedef void (chile::* pmf) (); + void bar (pmf pmethod) + { + &(this->*pmethod); + } +}; + +