* C++ PATCH for c++/62659 (rejects-valid with pointer to member function in template)
@ 2014-09-05 17:58 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2014-09-05 17:58 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 232 bytes --]
potential_constant_expression was getting confused by the (non-constant)
object argument of the OFFSET_REF, but it isn't really involved in
calculating the value of the PMF.
Tested x86_64-pc-linux-gnu, applying to trunk and 4.9.
[-- Attachment #2: 62659.patch --]
[-- Type: text/x-patch, Size: 1340 bytes --]
commit cbf61fb5d2ae5db8ff4986e2124105cb899c0037
Author: Jason Merrill <jason@redhat.com>
Date: Fri Sep 5 11:36:34 2014 -0400
PR c++/62659
* semantics.c (potential_constant_expression_1): Handle un-folded
pointer to member constants.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 01748da..776fa26 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 0000000..7700c0b
--- /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 <cont_func> struct B;
+ template <cont_func cont_f> void wait(B<cont_f> ***);
+
+ int done();
+ template <bool> void fix() { wait<&D::done>(0); }
+};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-09-05 17:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-05 17:58 C++ PATCH for c++/62659 (rejects-valid with pointer to member function in template) Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).