re PR c++/61500 ([C++11] Can't take pointer to member referenced via member pointer...
authorJason Merrill <jason@redhat.com>
Mon, 16 Jun 2014 11:45:37 +0000 (07:45 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 16 Jun 2014 11:45:37 +0000 (07:45 -0400)
PR c++/61500
* tree.c (lvalue_kind): Handle MEMBER_REF and DOTSTAR_EXPR.

From-SVN: r211703

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/template/ptrmem27.C [new file with mode: 0644]

index 9784a59..de0307d 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/61500
+       * tree.c (lvalue_kind): Handle MEMBER_REF and DOTSTAR_EXPR.
+
 2014-06-15  Jan Hubicka  <hubicka@ucw.cz>
 
        * decl.c (grokvardecl): Fix pasto in previous patch.
index 587ae80..3616605 100644 (file)
@@ -102,6 +102,16 @@ lvalue_kind (const_tree ref)
     case IMAGPART_EXPR:
       return lvalue_kind (TREE_OPERAND (ref, 0));
 
+    case MEMBER_REF:
+    case DOTSTAR_EXPR:
+      if (TREE_CODE (ref) == MEMBER_REF)
+       op1_lvalue_kind = clk_ordinary;
+      else
+       op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0));
+      if (TYPE_PTRMEMFUNC_P (TREE_TYPE (TREE_OPERAND (ref, 1))))
+       op1_lvalue_kind = clk_none;
+      return op1_lvalue_kind;
+
     case COMPONENT_REF:
       op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0));
       /* Look at the member designator.  */
diff --git a/gcc/testsuite/g++.dg/template/ptrmem27.C b/gcc/testsuite/g++.dg/template/ptrmem27.C
new file mode 100644 (file)
index 0000000..8c63f9c
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/61500
+
+struct X {
+  int i;
+  int j;
+
+  int foo(int X::* ptr);
+
+  template <int X::* ptr>
+  int bar();
+};
+
+int X::foo(int X::* ptr) {
+  int* p = &(this->*ptr);  // OK.
+  return *p;
+}
+
+template <int X::* ptr>
+int X::bar() {
+  int* p = &(this->*ptr);  // gcc 4.9.0: OK in C++98 mode, fails in C++11 mode.
+  return *p;
+}