[patch c++]: Fix PR/47211 - ICE: in cp_build_addr_expr_1, at cp/typeck.c:4866 with -fms-extensions

Kai Tietz ktietz70@googlemail.com
Fri Jan 7 14:58:00 GMT 2011


2011/1/7 Paolo Carlini <paolo.carlini@oracle.com>:
> ... very minor nit:
>
> +};
> +
> +
>
> watch trailing empty lines.
>
> Paolo.
>
>

Thanks, testcase corrected.

Regards,
Kai
-------------- next part --------------
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:53:25.048572600 +0100
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-fms-extensions" } */
+
+class chile
+{
+  typedef void (chile::* pmf) ();
+  void bar (pmf pmethod)
+  {
+    &(this->*pmethod);
+  }
+};


More information about the Gcc-patches mailing list