diff mbox

[C++] Fix ICE with PARM_DECL with incomplete type (PR c++/77338)

Message ID 20160829194612.GK14857@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Aug. 29, 2016, 7:46 p.m. UTC
Hi!

In r239289 you've done something similar for the VAR_DECL etc. case, but
for PARM_DECL we can still call is_really_empty_class on incomplete types
and ICE because TYPE_BINFO is NULL.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2016-08-29  Jakub Jelinek  <jakub@redhat.com>

	PR c++/77338
	* constexpr.c (cxx_eval_constant_expression) <case PARM_DECL>: Only
	call is_really_empty_class on complete types.

	* g++.dg/cpp0x/decltype-77338.C: New test.


	Jakub

Comments

Jason Merrill Sept. 16, 2016, 7:46 p.m. UTC | #1
OK.

On Mon, Aug 29, 2016 at 3:46 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> In r239289 you've done something similar for the VAR_DECL etc. case, but
> for PARM_DECL we can still call is_really_empty_class on incomplete types
> and ICE because TYPE_BINFO is NULL.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2016-08-29  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/77338
>         * constexpr.c (cxx_eval_constant_expression) <case PARM_DECL>: Only
>         call is_really_empty_class on complete types.
>
>         * g++.dg/cpp0x/decltype-77338.C: New test.
>
> --- gcc/cp/constexpr.c.jj       2016-08-12 17:33:42.000000000 +0200
> +++ gcc/cp/constexpr.c  2016-08-29 14:26:50.342319322 +0200
> @@ -3747,7 +3747,8 @@ cxx_eval_constant_expression (const cons
>         /* Defer in case this is only used for its type.  */;
>        else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
>         /* Defer, there's no lvalue->rvalue conversion.  */;
> -      else if (is_really_empty_class (TREE_TYPE (t)))
> +      else if (COMPLETE_TYPE_P (TREE_TYPE (t))
> +              && is_really_empty_class (TREE_TYPE (t)))
>         {
>           /* If the class is empty, we aren't actually loading anything.  */
>           r = build_constructor (TREE_TYPE (t), NULL);
> --- gcc/testsuite/g++.dg/cpp0x/decltype-77338.C.jj      2016-08-29 14:42:31.974306247 +0200
> +++ gcc/testsuite/g++.dg/cpp0x/decltype-77338.C 2016-08-29 14:41:12.000000000 +0200
> @@ -0,0 +1,7 @@
> +// PR c++/77338
> +// { dg-do compile { target c++11 } }
> +
> +struct S;
> +
> +template <typename>
> +auto f (S s) -> decltype (s (s));      // { dg-error "no match for call to" }
>
>         Jakub
diff mbox

Patch

--- gcc/cp/constexpr.c.jj	2016-08-12 17:33:42.000000000 +0200
+++ gcc/cp/constexpr.c	2016-08-29 14:26:50.342319322 +0200
@@ -3747,7 +3747,8 @@  cxx_eval_constant_expression (const cons
 	/* Defer in case this is only used for its type.  */;
       else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
 	/* Defer, there's no lvalue->rvalue conversion.  */;
-      else if (is_really_empty_class (TREE_TYPE (t)))
+      else if (COMPLETE_TYPE_P (TREE_TYPE (t))
+	       && is_really_empty_class (TREE_TYPE (t)))
 	{
 	  /* If the class is empty, we aren't actually loading anything.  */
 	  r = build_constructor (TREE_TYPE (t), NULL);
--- gcc/testsuite/g++.dg/cpp0x/decltype-77338.C.jj	2016-08-29 14:42:31.974306247 +0200
+++ gcc/testsuite/g++.dg/cpp0x/decltype-77338.C	2016-08-29 14:41:12.000000000 +0200
@@ -0,0 +1,7 @@ 
+// PR c++/77338
+// { dg-do compile { target c++11 } }
+
+struct S;
+
+template <typename>
+auto f (S s) -> decltype (s (s));	// { dg-error "no match for call to" }