From: Jason Merrill Date: Wed, 10 Dec 2014 02:50:54 +0000 (-0500) Subject: re PR c++/64222 (error: ‘__FUNCTION__’ was not declared in this scope) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9c78f8e6055b086b2e4317e3fe11071f27ef0cb2;p=gcc.git re PR c++/64222 (error: ‘__FUNCTION__’ was not declared in this scope) PR c++/64222 * parser.c (cp_parser_unqualified_id): Don't declare fname while parsing function parms. From-SVN: r218556 --- 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)); +}