diff mbox series

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

Message ID 20180302173737.GL16833@redhat.com
State New
Headers show
Series C++ PATCH for c++/84664, ICE on invalid in lambda | expand

Commit Message

Marek Polacek March 2, 2018, 5:37 p.m. UTC
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.


	Marek

Comments

Jason Merrill March 2, 2018, 5:43 p.m. UTC | #1
OK.

On Fri, Mar 2, 2018 at 12:37 PM, Marek Polacek <polacek@redhat.com> wrote:
> 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
diff mbox series

Patch

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" }
+}