re PR c++/61488 (Regression in template argument substitution in 4.9+)
authorJason Merrill <jason@redhat.com>
Mon, 16 Jun 2014 11:50:14 +0000 (07:50 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 16 Jun 2014 11:50:14 +0000 (07:50 -0400)
PR c++/61488
* pt.c (check_valid_ptrmem_cst_expr): Fix for template context.

From-SVN: r211704

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

index de0307d..422e716 100644 (file)
@@ -1,5 +1,8 @@
 2014-06-13  Jason Merrill  <jason@redhat.com>
 
+       PR c++/61488
+       * pt.c (check_valid_ptrmem_cst_expr): Fix for template context.
+
        PR c++/61500
        * tree.c (lvalue_kind): Handle MEMBER_REF and DOTSTAR_EXPR.
 
index 8858908..df57293 100644 (file)
@@ -5350,6 +5350,10 @@ check_valid_ptrmem_cst_expr (tree type, tree expr,
     return true;
   if (cxx_dialect >= cxx11 && null_member_pointer_value_p (expr))
     return true;
+  if (processing_template_decl
+      && TREE_CODE (expr) == ADDR_EXPR
+      && TREE_CODE (TREE_OPERAND (expr, 0)) == OFFSET_REF)
+    return true;
   if (complain & tf_error)
     {
       error ("%qE is not a valid template argument for type %qT",
diff --git a/gcc/testsuite/g++.dg/template/ptrmem28.C b/gcc/testsuite/g++.dg/template/ptrmem28.C
new file mode 100644 (file)
index 0000000..0379960
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/61488
+
+struct A {
+  typedef int (A::*cont_func)();
+  template <A::cont_func> void wait(int);
+  int notify();
+
+  void fix() { wait<&A::notify>(0); } // OK
+  template <int> void repair() { wait<&A::notify>(0); }
+};