Patchwork C++ PATCH for c++/49298 (C++0x regression with pointer to member)

login
register
mail settings
Submitter Jason Merrill
Date June 6, 2011, 7:43 p.m.
Message ID <4DED2DDF.90102@redhat.com>
Download mbox | patch
Permalink /patch/99017/
State New
Headers show

Comments

Jason Merrill - June 6, 2011, 7:43 p.m.
potential_constant_expression_1 didn't know how to deal with a 
pointer-to-member expression in a template.

Tested x86_64-pc-linux-gnu, applied to trunk.

Patch

commit a07ee89ff40f73dcb1fc11fb66931ee79bf8a2d9
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jun 6 12:05:39 2011 -0400

    	PR c++/49298
    	* semantics.c (potential_constant_expression_1): Handle FIELD_DECL.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 5626a86..f005f2f 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7489,6 +7489,8 @@  potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
     case TEMPLATE_PARM_INDEX:
     case TRAIT_EXPR:
     case IDENTIFIER_NODE:
+      /* We can see a FIELD_DECL in a pointer-to-member expression.  */
+    case FIELD_DECL:
       return true;
 
     case PARM_DECL:
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/ptrmem1.C b/gcc/testsuite/g++.dg/cpp0x/regress/ptrmem1.C
new file mode 100644
index 0000000..873000b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/regress/ptrmem1.C
@@ -0,0 +1,9 @@ 
+// PR c++/49298
+// { dg-options -std=c++0x }
+
+template <class T, int T::*> struct B { };
+template <class T> struct A
+{
+  int i;
+  B<A,&A::i> b;
+};