re PR c++/66684 (ICE in merge_exception_specifiers, at cp/typeck2.c:2114)
authorJason Merrill <jason@redhat.com>
Fri, 26 Jun 2015 21:31:08 +0000 (17:31 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 26 Jun 2015 21:31:08 +0000 (17:31 -0400)
PR c++/66684
* typeck2.c (merge_exception_specifiers): Allow different
noexcept-specifiers if we've had errors.

From-SVN: r225086

gcc/cp/ChangeLog
gcc/cp/typeck2.c
gcc/testsuite/g++.dg/cpp0x/noexcept28.C [new file with mode: 0644]

index e9030a7de22d6c8c7b44db9c755f22d0903c773d..5bfebe2359f121bc85943a3d1a0997dcbc52fe1b 100644 (file)
@@ -1,5 +1,9 @@
 2015-06-26  Jason Merrill  <jason@redhat.com>
 
+       PR c++/66684
+       * typeck2.c (merge_exception_specifiers): Allow different
+       noexcept-specifiers if we've had errors.
+
        PR c++/66255
        * pt.c (check_unstripped_args): Split out from...
        (retrieve_specialization): ...here.  Allow typedefs in the type of
index 7597de1158a78f8b637bef38eb9a4bf32a6813a4..c670879108bf3d914138e4d01df8e4b95e783f23 100644 (file)
@@ -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 (file)
index 0000000..e3eb7db
--- /dev/null
@@ -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; }