public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] c++: ICE with -fno-exceptions and array init [PR107198]
@ 2023-09-12 17:27 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2023-09-12 17:27 UTC (permalink / raw)
  To: gcc-patches

Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

The removed line no longer has an effect on anew5.C error recovery, and
removing it improves error recovery for this testcase.

	PR c++/107198

gcc/cp/ChangeLog:

	* typeck2.cc (process_init_constructor_array): Use VEC_INIT_EXPR
	regardless of seen_error.

gcc/testsuite/ChangeLog:

	* g++.dg/eh/no-exceptions1.C: New test.
---
 gcc/cp/typeck2.cc                        |  1 -
 gcc/testsuite/g++.dg/eh/no-exceptions1.C | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/eh/no-exceptions1.C

diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index 582a73bb053..cd1ea045720 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -1683,7 +1683,6 @@ process_init_constructor_array (tree type, tree init, int nested, int flags,
 	if (next)
 	  {
 	    if (next != error_mark_node
-		&& ! seen_error () // Improves error-recovery on anew5.C.
 		&& (initializer_constant_valid_p (next, TREE_TYPE (next))
 		    != null_pointer_node))
 	      {
diff --git a/gcc/testsuite/g++.dg/eh/no-exceptions1.C b/gcc/testsuite/g++.dg/eh/no-exceptions1.C
new file mode 100644
index 00000000000..4b77064c646
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/no-exceptions1.C
@@ -0,0 +1,19 @@
+// PR c++/107198
+// { dg-additional-options -fno-exceptions }
+
+struct A {
+  A() { throw 0; }		// { dg-error disabled }
+  A(int i) { throw i; }
+  A(const A&) { throw 10; }
+};
+
+void try_idx (int i)
+{
+  int t = 10;
+  try {
+    struct X {
+      A e1[2], e2;
+    }
+    x2[3] = { { 1, 2, 3 }, { 4, 5, 6 } };
+  } catch (int x) { t = x; }	// { dg-prune-output "not declared" }
+}

base-commit: 27e2e7c93e48bcbb63877cc5964fae8dba47d706
-- 
2.39.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-12 17:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-12 17:27 [pushed] c++: ICE with -fno-exceptions and array init [PR107198] 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).