re PR c++/62659 (Regression in template argument substitution in 4.9+)
authorJason Merrill <jason@redhat.com>
Fri, 5 Sep 2014 17:59:40 +0000 (13:59 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 5 Sep 2014 17:59:40 +0000 (13:59 -0400)
PR c++/62659
* semantics.c (potential_constant_expression_1): Handle un-folded
pointer to member constants.

From-SVN: r214974

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

index cce5739a86655d15130b0ad869c6000a50b4797d..3d8723139304e0d3fad4c23ca987a009a48c7116 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-05  Jason Merrill  <jason@redhat.com>
+
+       PR c++/62659
+       * semantics.c (potential_constant_expression_1): Handle un-folded
+       pointer to member constants.
+
 2014-09-04  Markus Trippelsdorf  <markus@trippelsdorf.de>
 
        PR ipa/61659
index 01748dab0e8fda2b050b8161c6eca90b3b97eed4..776fa264488a3e470e50d993aa81a7a85c1f5677 100644 (file)
@@ -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 (file)
index 0000000..7700c0b
--- /dev/null
@@ -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); }
+};