]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* typeck2.c (merge_exception_specifiers): Adjust merging of
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 5 Jun 2010 04:52:07 +0000 (04:52 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 5 Jun 2010 04:52:07 +0000 (04:52 +0000)
throw() and noexcept(true).

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160308 138bc75d-0d04-0410-961f-82ee72b054a4

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

index a67de73c802e9a8526d3d32425344e997dd6a80b..b0510792fcf72006a01c0a936c9523eb212d5f70 100644 (file)
@@ -1,5 +1,8 @@
 2010-06-04  Jason Merrill  <jason@redhat.com>
 
+       * typeck2.c (merge_exception_specifiers): Adjust merging of
+       throw() and noexcept(true).
+
        * pt.c (value_dependent_expression_p) [NOEXCEPT_EXPR]: Avoid
        using an uninitialized variable.
 
index 93ea70d3808fd99d4cbcdd57d7a1c782fc30ce1f..e7b97c4d5c780edd54989b2fecb21c43e2d4181b 100644 (file)
@@ -1721,17 +1721,14 @@ merge_exception_specifiers (tree list, tree add)
 {
   if (!list || !add)
     return NULL_TREE;
-  /* A noexcept(true) spec takes precedence over a throw() spec.
+  /* For merging noexcept(true) and throw(), take the more recent one (LIST).
      A throw(type-list) spec takes precedence over a noexcept(false) spec.
      Any other noexcept-spec should only be merged with an equivalent one.
-     So the !TREE_VALUE code is correct for the latter two cases.  */
-  else if (list == noexcept_true_spec
-          || add == noexcept_true_spec)
-    return noexcept_true_spec;
-  else if (!TREE_VALUE (list))
-    return add;
+     So the !TREE_VALUE code below is correct for all cases.  */
   else if (!TREE_VALUE (add))
     return list;
+  else if (!TREE_VALUE (list))
+    return add;
   else
     {
       tree orig_list = list;
index 7fe8c5010cd057ab71c3058a0fde1b4b4b36271d..0998820f7d0b4caee09ce459e7d919fa82c17a45 100644 (file)
@@ -1,5 +1,8 @@
 2010-06-04  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/noexcept06.C: New.
+       * g++.dg/cpp0x/noexcept07.C: New.
+
        * g++.dg/cpp0x/noexcept01.C: New.
        * g++.dg/cpp0x/noexcept02.C: New.
        * g++.dg/cpp0x/noexcept03.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept06.C b/gcc/testsuite/g++.dg/cpp0x/noexcept06.C
new file mode 100644 (file)
index 0000000..b0135ac
--- /dev/null
@@ -0,0 +1,29 @@
+// Test that checking of a nothrow specification uses the one on the
+// definition.
+// { dg-options "-std=c++0x" }
+// { dg-do run }
+
+#include <exception>
+#include <cstdlib>
+
+void my_unexpected ()
+{
+  std::abort ();
+}
+void my_terminate ()
+{
+  std::exit (0);
+}
+
+void f() throw();
+void f() noexcept
+{
+  throw 1;
+}
+
+int main()
+{
+  std::set_terminate (my_terminate);
+  f();
+  return 1;
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept07.C b/gcc/testsuite/g++.dg/cpp0x/noexcept07.C
new file mode 100644 (file)
index 0000000..0a5773f
--- /dev/null
@@ -0,0 +1,25 @@
+// Test that checking of a nothrow specification uses the one on the
+// definition.
+// { dg-options "-std=c++0x" }
+// { dg-do run }
+
+#include <exception>
+#include <cstdlib>
+
+void my_unexpected ()
+{
+  std::exit (0);
+}
+
+void f() noexcept;
+void f() throw()
+{
+  throw 1;
+}
+
+int main()
+{
+  std::set_unexpected (my_unexpected);
+  f();
+  return 1;
+}