From 6e0681b715c3fb0c5ff87270f04f7bbd2eefa7b5 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 16 Jun 2014 07:50:14 -0400 Subject: [PATCH] re PR c++/61488 (Regression in template argument substitution in 4.9+) PR c++/61488 * pt.c (check_valid_ptrmem_cst_expr): Fix for template context. From-SVN: r211704 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/pt.c | 4 ++++ gcc/testsuite/g++.dg/template/ptrmem28.C | 10 ++++++++++ 3 files changed, 17 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/ptrmem28.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index de0307df8f3..422e71667c3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2014-06-13 Jason Merrill + 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. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 88589089066..df57293d03d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 index 00000000000..037996087b2 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ptrmem28.C @@ -0,0 +1,10 @@ +// PR c++/61488 + +struct A { + typedef int (A::*cont_func)(); + template void wait(int); + int notify(); + + void fix() { wait<&A::notify>(0); } // OK + template void repair() { wait<&A::notify>(0); } +};