From patchwork Thu Feb 14 04:29:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: C++ PATCH for c++/55670 (wrong error with function pointer member and nsdmi) Date: Wed, 13 Feb 2013 18:29:48 -0000 From: Jason Merrill X-Patchwork-Id: 220350 Message-Id: <511C683C.3060306@redhat.com> To: gcc-patches List cp_parser_member_declaration was seeing that the type-specifier in the declaration had function type and concluded from that that the declaration would have function type, without noticing that the declarator isn't a simple identifier. We should check that. Tested x86_64-pc-linux-gnu, applying to trunk. commit 96ded20a00ed98805f6ffb5b1b7babcb15d246c5 Author: Jason Merrill Date: Wed Feb 13 13:30:05 2013 -0500 PR c++/55670 * parser.c (cp_parser_member_declaration): Check the declarator form when detecting a function declaration via typedef. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 402f384..d18e027 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -19366,6 +19366,7 @@ cp_parser_member_declaration (cp_parser* parser) if (function_declarator_p (declarator) || (decl_specifiers.type && TREE_CODE (decl_specifiers.type) == TYPE_DECL + && declarator->kind == cdk_id && (TREE_CODE (TREE_TYPE (decl_specifiers.type)) == FUNCTION_TYPE))) initializer = cp_parser_pure_specifier (parser); diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi8.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi8.C new file mode 100644 index 0000000..f89bec6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi8.C @@ -0,0 +1,8 @@ +// PR c++/55670 +// { dg-do compile { target c++11 } } + +template using F = T; +struct X { + F* fp = nullptr; +}; +int main () { return 0; }