public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH to fix ICE-on-invalid with incomplete type (PR c++/79435)
@ 2017-02-10 15:57 Marek Polacek
  2017-02-10 16:05 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2017-02-10 15:57 UTC (permalink / raw)
  To: GCC Patches, Jason Merrill

I believe that to fix this ice-on-invalid we should just make
type_dependent_expression_p more robust so that it doesn't crash on expressions
that are missing a type.

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

2017-02-10  Marek Polacek  <polacek@redhat.com>

	PR c++/79435
	* pt.c (type_dependent_expression_p): Check if the expression type
	is null.

	* g++.dg/cpp1y/pr79435.C: New.

diff --git gcc/cp/pt.c gcc/cp/pt.c
index 0a4510c..0bb37f8 100644
--- gcc/cp/pt.c
+++ gcc/cp/pt.c
@@ -23818,6 +23818,7 @@ type_dependent_expression_p (tree expression)
      we couldn't determine its length in cp_complete_array_type because
      it is dependent.  */
   if (VAR_P (expression)
+      && TREE_TYPE (expression) != NULL_TREE
       && TREE_CODE (TREE_TYPE (expression)) == ARRAY_TYPE
       && !TYPE_DOMAIN (TREE_TYPE (expression))
       && DECL_INITIAL (expression))
diff --git gcc/testsuite/g++.dg/cpp1y/pr79435.C gcc/testsuite/g++.dg/cpp1y/pr79435.C
index e69de29..a9e4671 100644
--- gcc/testsuite/g++.dg/cpp1y/pr79435.C
+++ gcc/testsuite/g++.dg/cpp1y/pr79435.C
@@ -0,0 +1,6 @@
+// PR c++/79435
+// { dg-do compile { target c++14 } }
+
+struct A;
+extern A a; // { dg-error "'a' has incomplete type" }
+template < int > int f = a.x;

	Marek

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

* Re: C++ PATCH to fix ICE-on-invalid with incomplete type (PR c++/79435)
  2017-02-10 15:57 C++ PATCH to fix ICE-on-invalid with incomplete type (PR c++/79435) Marek Polacek
@ 2017-02-10 16:05 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2017-02-10 16:05 UTC (permalink / raw)
  To: Marek Polacek; +Cc: GCC Patches

OK.

On Fri, Feb 10, 2017 at 10:57 AM, Marek Polacek <polacek@redhat.com> wrote:
> I believe that to fix this ice-on-invalid we should just make
> type_dependent_expression_p more robust so that it doesn't crash on expressions
> that are missing a type.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2017-02-10  Marek Polacek  <polacek@redhat.com>
>
>         PR c++/79435
>         * pt.c (type_dependent_expression_p): Check if the expression type
>         is null.
>
>         * g++.dg/cpp1y/pr79435.C: New.
>
> diff --git gcc/cp/pt.c gcc/cp/pt.c
> index 0a4510c..0bb37f8 100644
> --- gcc/cp/pt.c
> +++ gcc/cp/pt.c
> @@ -23818,6 +23818,7 @@ type_dependent_expression_p (tree expression)
>       we couldn't determine its length in cp_complete_array_type because
>       it is dependent.  */
>    if (VAR_P (expression)
> +      && TREE_TYPE (expression) != NULL_TREE
>        && TREE_CODE (TREE_TYPE (expression)) == ARRAY_TYPE
>        && !TYPE_DOMAIN (TREE_TYPE (expression))
>        && DECL_INITIAL (expression))
> diff --git gcc/testsuite/g++.dg/cpp1y/pr79435.C gcc/testsuite/g++.dg/cpp1y/pr79435.C
> index e69de29..a9e4671 100644
> --- gcc/testsuite/g++.dg/cpp1y/pr79435.C
> +++ gcc/testsuite/g++.dg/cpp1y/pr79435.C
> @@ -0,0 +1,6 @@
> +// PR c++/79435
> +// { dg-do compile { target c++14 } }
> +
> +struct A;
> +extern A a; // { dg-error "'a' has incomplete type" }
> +template < int > int f = a.x;
>
>         Marek

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

end of thread, other threads:[~2017-02-10 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10 15:57 C++ PATCH to fix ICE-on-invalid with incomplete type (PR c++/79435) Marek Polacek
2017-02-10 16:05 ` 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).