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 <ja...@redhat.com>
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 <class T> using F = T;
+struct X {
+ F<void ()>* fp = nullptr;
+};
+int main () { return 0; }