public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/64222 (ICE with __FUNCTION__)
@ 2014-12-10  2:49 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2014-12-10  2:49 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

In this testcase, while we're tentatively parsing a function declarator 
we came across __FUNCTION__, tried to predeclare it, and failed because 
we were in function parameter scope; then when we try again later it 
fails again because we cached the error_mark_node.  So don't try the 
first time.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 64222.patch --]
[-- Type: text/x-patch, Size: 1199 bytes --]

commit 4468227a2b30526e907664904378bec32ddef9e2
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Dec 9 12:30:19 2014 -0500

    	PR c++/64222
    	* parser.c (cp_parser_unqualified_id): Don't declare fname while
    	parsing function parms.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index d1cd63f..7bd9477 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 0000000..2c18c30
--- /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));
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-12-10  2:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-10  2:49 C++ PATCH for c++/64222 (ICE with __FUNCTION__) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).