This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/84664, ICE on invalid in lambda


This patch fixes an ICE-on-invalid by checking the result of mark_rvalue_use,
similarly to perform_implicit_conversion_flags.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2018-03-02  Marek Polacek  <polacek@redhat.com>

	PR c++/84664
	* typeck.c (cp_perform_integral_promotions): Check the result of
	mark_rvalue_use.

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

diff --git gcc/cp/typeck.c gcc/cp/typeck.c
index 0e7c63dd197..f535902231d 100644
--- gcc/cp/typeck.c
+++ gcc/cp/typeck.c
@@ -2161,6 +2161,8 @@ cp_perform_integral_promotions (tree expr, tsubst_flags_t complain)
   tree promoted_type;
 
   expr = mark_rvalue_use (expr);
+  if (error_operand_p (expr))
+    return error_mark_node;
 
   /* [conv.prom]
 
diff --git gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice28.C gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice28.C
index e69de29bb2d..5fe32129744 100644
--- gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice28.C
+++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice28.C
@@ -0,0 +1,9 @@
+// PR c++/84664
+// { dg-do compile { target c++11 } }
+
+void
+foo ()
+{
+  auto &b = 1; // { dg-error "cannot bind" }
+  [] { b > 0; }; // { dg-error ".b. is not captured" }
+}

	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]