diff mbox

C++ PATCH for c++/66684 (ICE with noexcept mismatch)

Message ID 558DC3F8.3070505@redhat.com
State New
Headers show

Commit Message

Jason Merrill June 26, 2015, 9:28 p.m. UTC
We shouldn't ICE because of a mismatch after we give an error about the 
mismatch.

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

Patch

commit 24e0467a1a5c0099b24aea8c7ec81f49b88f6a2c
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jun 26 16:40:56 2015 -0400

    	PR c++/66684
    	* typeck2.c (merge_exception_specifiers): Allow different
    	noexcept-specifiers if we've had errors.

diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 7597de1..c670879 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -2112,6 +2112,7 @@  merge_exception_specifiers (tree list, tree add)
     return add;
   noex = TREE_PURPOSE (list);
   gcc_checking_assert (!TREE_PURPOSE (add)
+		       || errorcount
 		       || cp_tree_equal (noex, TREE_PURPOSE (add)));
 
   /* Combine the dynamic-exception-specifiers, if any.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept28.C b/gcc/testsuite/g++.dg/cpp0x/noexcept28.C
new file mode 100644
index 0000000..e3eb7db
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept28.C
@@ -0,0 +1,20 @@ 
+// PR c++/66684
+// { dg-do compile { target c++11 } }
+
+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-error "different exception" }
+  { return *this; }