public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/84664, ICE on invalid in lambda
@ 2018-03-02 17:37 Marek Polacek
  2018-03-02 17:43 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2018-03-02 17:37 UTC (permalink / raw)
  To: Jason Merrill, GCC Patches

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

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

* Re: C++ PATCH for c++/84664, ICE on invalid in lambda
  2018-03-02 17:37 C++ PATCH for c++/84664, ICE on invalid in lambda Marek Polacek
@ 2018-03-02 17:43 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2018-03-02 17:43 UTC (permalink / raw)
  To: Marek Polacek; +Cc: GCC Patches

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

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

end of thread, other threads:[~2018-03-02 17:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-02 17:37 C++ PATCH for c++/84664, ICE on invalid in lambda Marek Polacek
2018-03-02 17:43 ` 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).