* [PATCH] c++: ICE-on-invalid with designated initializer [PR106983]
@ 2022-09-20 21:05 Marek Polacek
2022-09-22 22:18 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2022-09-20 21:05 UTC (permalink / raw)
To: Jason Merrill, GCC Patches
We ICE in the code added in r12-7117: type_build_dtor_call gets
the error_mark_node because the type of 'prev' wasn't declared.
Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
PR c++/106983
gcc/cp/ChangeLog:
* typeck2.cc (split_nonconstant_init_1): Check TYPE_P.
gcc/testsuite/ChangeLog:
* g++.dg/other/error36.C: New test.
---
gcc/cp/typeck2.cc | 2 +-
gcc/testsuite/g++.dg/other/error36.C | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/other/error36.C
diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index 688e9c15326..75fd0e2a9bf 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -597,7 +597,7 @@ split_nonconstant_init_1 (tree dest, tree init, bool last,
if (prev == field_index)
break;
tree ptype = TREE_TYPE (prev);
- if (type_build_dtor_call (ptype))
+ if (TYPE_P (ptype) && type_build_dtor_call (ptype))
{
tree pcref = build3 (COMPONENT_REF, ptype, dest, prev,
NULL_TREE);
diff --git a/gcc/testsuite/g++.dg/other/error36.C b/gcc/testsuite/g++.dg/other/error36.C
new file mode 100644
index 00000000000..556287816fd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/error36.C
@@ -0,0 +1,13 @@
+// PR c++/106983
+// { dg-do compile { target c++20 } }
+
+typedef unsigned long long A;
+typedef union
+{
+ struct B s; // { dg-error "incomplete" }
+ A a;
+} U;
+void f (A x, unsigned int b)
+{
+ const U y = {.a = x};
+}
base-commit: be60aa5b608b5f09fadfeff852a46589ac311a42
--
2.37.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: ICE-on-invalid with designated initializer [PR106983]
2022-09-20 21:05 [PATCH] c++: ICE-on-invalid with designated initializer [PR106983] Marek Polacek
@ 2022-09-22 22:18 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2022-09-22 22:18 UTC (permalink / raw)
To: Marek Polacek, GCC Patches
On 9/20/22 17:05, Marek Polacek wrote:
> We ICE in the code added in r12-7117: type_build_dtor_call gets
> the error_mark_node because the type of 'prev' wasn't declared.
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
OK.
> PR c++/106983
>
> gcc/cp/ChangeLog:
>
> * typeck2.cc (split_nonconstant_init_1): Check TYPE_P.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/other/error36.C: New test.
> ---
> gcc/cp/typeck2.cc | 2 +-
> gcc/testsuite/g++.dg/other/error36.C | 13 +++++++++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/g++.dg/other/error36.C
>
> diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
> index 688e9c15326..75fd0e2a9bf 100644
> --- a/gcc/cp/typeck2.cc
> +++ b/gcc/cp/typeck2.cc
> @@ -597,7 +597,7 @@ split_nonconstant_init_1 (tree dest, tree init, bool last,
> if (prev == field_index)
> break;
> tree ptype = TREE_TYPE (prev);
> - if (type_build_dtor_call (ptype))
> + if (TYPE_P (ptype) && type_build_dtor_call (ptype))
> {
> tree pcref = build3 (COMPONENT_REF, ptype, dest, prev,
> NULL_TREE);
> diff --git a/gcc/testsuite/g++.dg/other/error36.C b/gcc/testsuite/g++.dg/other/error36.C
> new file mode 100644
> index 00000000000..556287816fd
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/other/error36.C
> @@ -0,0 +1,13 @@
> +// PR c++/106983
> +// { dg-do compile { target c++20 } }
> +
> +typedef unsigned long long A;
> +typedef union
> +{
> + struct B s; // { dg-error "incomplete" }
> + A a;
> +} U;
> +void f (A x, unsigned int b)
> +{
> + const U y = {.a = x};
> +}
>
> base-commit: be60aa5b608b5f09fadfeff852a46589ac311a42
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-22 22:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-20 21:05 [PATCH] c++: ICE-on-invalid with designated initializer [PR106983] Marek Polacek
2022-09-22 22:18 ` 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).