From 9c78f8e6055b086b2e4317e3fe11071f27ef0cb2 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 9 Dec 2014 21:50:54 -0500 Subject: [PATCH] =?utf8?q?re=20PR=20c++/64222=20(error:=20=E2=80=98=5F=5FF?= =?utf8?q?UNCTION=5F=5F=E2=80=99=20was=20not=20declared=20in=20this=20scop?= =?utf8?q?e)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit PR c++/64222 * parser.c (cp_parser_unqualified_id): Don't declare fname while parsing function parms. From-SVN: r218556 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 5 ++++- gcc/testsuite/g++.dg/parse/fnname1.C | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/parse/fnname1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 361e634ea5f..8a8b536a53d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-12-09 Jason Merrill + + PR c++/64222 + * parser.c (cp_parser_unqualified_id): Don't declare fname while + parsing function parms. + 2014-12-03 Jason Merrill PR c++/64029 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index d1cd63f1ca6..7bd9477a4e4 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5207,7 +5207,10 @@ cp_parser_unqualified_id (cp_parser* parser, case RID_PRETTY_FUNCTION_NAME: case RID_C99_FUNCTION_NAME: cp_lexer_consume_token (parser->lexer); - finish_fname (token->u.value); + /* Don't try to declare this while tentatively parsing a function + declarator, as cp_make_fname_decl will fail. */ + if (current_binding_level->kind != sk_function_parms) + finish_fname (token->u.value); return token->u.value; default: diff --git a/gcc/testsuite/g++.dg/parse/fnname1.C b/gcc/testsuite/g++.dg/parse/fnname1.C new file mode 100644 index 00000000000..2c18c30f8d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/fnname1.C @@ -0,0 +1,17 @@ +// PR c++/64222 + +class A +{ +public: + A (const char *, void *); +}; +class B +{ +public: + B (A); +}; +void +fn1 () +{ + B a (A (__func__, 0)); +} -- 2.30.2