From ed23bf8bd649d2568e7371760841db39c6ac2e63 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 5 Sep 2014 13:59:40 -0400 Subject: [PATCH] re PR c++/62659 (Regression in template argument substitution in 4.9+) PR c++/62659 * semantics.c (potential_constant_expression_1): Handle un-folded pointer to member constants. From-SVN: r214974 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 5 +++++ gcc/testsuite/g++.dg/template/ptrmem29.C | 10 ++++++++++ 3 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/ptrmem29.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cce5739a866..3d872313930 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-09-05 Jason Merrill + + PR c++/62659 + * semantics.c (potential_constant_expression_1): Handle un-folded + pointer to member constants. + 2014-09-04 Markus Trippelsdorf PR ipa/61659 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 01748dab0e8..776fa264488 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -10348,6 +10348,11 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) designates an object with thread or automatic storage duration; */ t = TREE_OPERAND (t, 0); + + if (TREE_CODE (t) == OFFSET_REF && PTRMEM_OK_P (t)) + /* A pointer-to-member constant. */ + return true; + #if 0 /* FIXME adjust when issue 1197 is fully resolved. For now don't do any checking here, as we might dereference the pointer later. If diff --git a/gcc/testsuite/g++.dg/template/ptrmem29.C b/gcc/testsuite/g++.dg/template/ptrmem29.C new file mode 100644 index 00000000000..7700c0b9722 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ptrmem29.C @@ -0,0 +1,10 @@ +// PR c++/62659 + +struct D { + typedef int (D::*cont_func)(); + template struct B; + template void wait(B ***); + + int done(); + template void fix() { wait<&D::done>(0); } +}; -- 2.30.2