From patchwork Mon Jun 6 19:43:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: C++ PATCH for c++/49298 (C++0x regression with pointer to member) Date: Mon, 06 Jun 2011 09:43:27 -0000 From: Jason Merrill X-Patchwork-Id: 99017 Message-Id: <4DED2DDF.90102@redhat.com> To: gcc-patches List 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. commit a07ee89ff40f73dcb1fc11fb66931ee79bf8a2d9 Author: Jason Merrill 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 struct B { }; +template struct A +{ + int i; + B b; +};