noexcept28.C fails with a checking ICE when run with -fpermissive,
because of a checking assert that uses errorcount instead of seen_error.
PR c++/118388
gcc/cp/ChangeLog:
* typeck2.cc (merge_exception_specifiers): Use seen_error
instead of errorcount.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/noexcept128-fpermissive.C: New test.
---
This part was approved by Jason in May 2025 but I'm resending it given
how long it took me to follow-up.
gcc/cp/typeck2.cc | 2 +-
.../g++.dg/cpp0x/noexcept128-fpermissive.C | 21 +++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept128-fpermissive.C
diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index c7ebd080edc6..2d263e085099 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -2981,7 +2981,7 @@ merge_exception_specifiers (tree list, tree add)
return add;
noex = TREE_PURPOSE (list);
gcc_checking_assert (!TREE_PURPOSE (add)
- || errorcount || !flag_exceptions
+ || seen_error () || !flag_exceptions
|| cp_tree_equal (noex, TREE_PURPOSE (add)));
/* Combine the dynamic-exception-specifiers, if any. */
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept128-fpermissive.C
b/gcc/testsuite/g++.dg/cpp0x/noexcept128-fpermissive.C
new file mode 100644
index 000000000000..dfc9629cb063
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept128-fpermissive.C
@@ -0,0 +1,21 @@
+// PR c++/118388
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-fpermissive" }
+
+template<typename T>
+struct traits
+{
+ static constexpr bool foo() { return sizeof(T) > 1; }
+ static constexpr bool bar() { return sizeof(T) > 1; }
+};
+
+template<typename T>
+struct X
+{
+ X& operator=(X&&) noexcept(traits<T>::foo());
+};
+
+template<typename T>
+ X<T>&
+ X<T>::operator=(X&&) noexcept(traits<T>::foo() && traits<T>::bar()) // {
dg-warning "different exception" }
+ { return *this; }
--
2.56.0