public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Fix lambda error recovery (PR c++/84446)
@ 2018-02-19 19:05 Jakub Jelinek
  2018-02-19 19:13 ` Paolo Carlini
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2018-02-19 19:05 UTC (permalink / raw)
  To: Jason Merrill, Nathan Sidwell; +Cc: gcc-patches

Hi!

In this case, because the corresponding variable is errorneous, we end up
with error_mark_node in LAMBDA_TYPE_EXTRA_SCOPE.  This patch just makes sure
we won't crash on it.  Not 100% sure if this is the best fix though.

Bootstrapped/regtested on x86_64-linux and i686-linux.

2018-02-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/84446
	* pt.c (template_class_depth): Don't crash if LAMBDA_TYPE_EXTRA_SCOPE
	is error_mark_node.

	* g++.dg/cpp0x/lambda/lambda-ice27.C: New test.

--- gcc/cp/pt.c.jj	2018-02-19 10:48:00.328184302 +0100
+++ gcc/cp/pt.c	2018-02-19 13:07:00.680855104 +0100
@@ -389,7 +389,11 @@ template_class_depth (tree type)
       if (DECL_P (type))
 	type = CP_DECL_CONTEXT (type);
       else if (LAMBDA_TYPE_P (type))
-	type = LAMBDA_TYPE_EXTRA_SCOPE (type);
+	{
+	  type = LAMBDA_TYPE_EXTRA_SCOPE (type);
+	  if (type == error_mark_node)
+	    break;
+	}
       else
 	type = CP_TYPE_CONTEXT (type);
     }
--- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice27.C.jj	2018-02-19 13:11:15.292869216 +0100
+++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice27.C	2018-02-19 13:10:45.186870424 +0100
@@ -0,0 +1,12 @@
+// PR c++/84446
+// { dg-do compile { target c++11 } }
+
+template <int>
+void
+foo ()
+{
+  int i;
+  auto i = [] { virtual; }();	// { dg-error "conflicting declaration" }
+				// { dg-error "templates may not be 'virtual'" "" { target *-*-* } .-1 }
+				// { dg-error "declaration does not declare anything" "" { target *-*-* } .-2 }
+}

	Jakub

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-20  3:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 19:05 [C++ PATCH] Fix lambda error recovery (PR c++/84446) Jakub Jelinek
2018-02-19 19:13 ` Paolo Carlini
2018-02-19 22:49   ` Jakub Jelinek
2018-02-20  3:11   ` 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).