re PR c++/64222 (error: ‘__FUNCTION__’ was not declared in this scope)
authorJason Merrill <jason@redhat.com>
Wed, 10 Dec 2014 02:50:54 +0000 (21:50 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 10 Dec 2014 02:50:54 +0000 (21:50 -0500)
PR c++/64222
* parser.c (cp_parser_unqualified_id): Don't declare fname while
parsing function parms.

From-SVN: r218556

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/parse/fnname1.C [new file with mode: 0644]

index 361e634ea5f6e6efcce085529bf182e37016cef0..8a8b536a53d47b557b471c1bd4950fb411d15a1a 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-09  Jason Merrill  <jason@redhat.com>
+
+       PR c++/64222
+       * parser.c (cp_parser_unqualified_id): Don't declare fname while
+       parsing function parms.
+
 2014-12-03  Jason Merrill  <jason@redhat.com>
 
        PR c++/64029
index d1cd63f1ca62e53809129d7933cde3ce1f452dca..7bd9477a4e48234209b6f2f6afa825439b8e6714 100644 (file)
@@ -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 (file)
index 0000000..2c18c30
--- /dev/null
@@ -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));
+}