aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2023-09-07 05:15:01 -0400
committerJason Merrill <jason@redhat.com>2023-09-12 13:26:23 -0400
commitea5abbb263315e558c876b50c9371b90ddd5e028 (patch)
treede0a188c76653d14b680f6db9d10e778e3ed700b /gcc
parent27e2e7c93e48bcbb63877cc5964fae8dba47d706 (diff)
downloadgcc-ea5abbb263315e558c876b50c9371b90ddd5e028.zip
gcc-ea5abbb263315e558c876b50c9371b90ddd5e028.tar.gz
gcc-ea5abbb263315e558c876b50c9371b90ddd5e028.tar.bz2
c++: ICE with -fno-exceptions and array init [PR107198]
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/typeck2.cc1
-rw-r--r--gcc/testsuite/g++.dg/eh/no-exceptions1.C19
2 files changed, 19 insertions, 1 deletions
diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index 582a73b..cd1ea04 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 0000000..4b77064
--- /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" }
+}