aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/except.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2019-04-12 15:29:03 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2019-04-12 15:29:03 +0000
commitc46f1a1791b3ec3a58780a4b882ecf19f047869a (patch)
tree5ebfaf92e50457cb04fa46ccb246df340415737b /gcc/cp/except.c
parentcc3bae3dc2819726e3d3903937e65f4f8d4f2fd5 (diff)
downloadgcc-c46f1a1791b3ec3a58780a4b882ecf19f047869a.zip
gcc-c46f1a1791b3ec3a58780a4b882ecf19f047869a.tar.gz
gcc-c46f1a1791b3ec3a58780a4b882ecf19f047869a.tar.bz2
PR c++/87603 - constexpr functions are no longer noexcept.
* constexpr.c (is_sub_constant_expr): Remove unused function. * cp-tree.h (is_sub_constant_expr): Remove declaration. * except.c (check_noexcept_r): Don't consider a call to a constexpr function noexcept. * g++.dg/cpp0x/constexpr-noexcept.C: Adjust the expected result. * g++.dg/cpp0x/constexpr-noexcept3.C: Likewise. * g++.dg/cpp0x/constexpr-noexcept4.C: Likewise. * g++.dg/cpp0x/constexpr-noexcept8.C: New test. * g++.dg/cpp0x/inh-ctor32.C: Remove dg-message. * g++.dg/cpp1y/constexpr-noexcept1.C: New test. From-SVN: r270320
Diffstat (limited to 'gcc/cp/except.c')
-rw-r--r--gcc/cp/except.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 25ab869..afc2610 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -1128,11 +1128,14 @@ check_noexcept_r (tree *tp, int * /*walk_subtrees*/, void * /*data*/)
&& (DECL_ARTIFICIAL (fn)
|| nothrow_libfn_p (fn)))
return TREE_NOTHROW (fn) ? NULL_TREE : fn;
- /* A call to a constexpr function is noexcept if the call
- is a constant expression. */
- if (DECL_DECLARED_CONSTEXPR_P (fn)
- && is_sub_constant_expr (t))
- return NULL_TREE;
+ /* We used to treat a call to a constexpr function as noexcept if
+ the call was a constant expression (CWG 1129). This has changed
+ in P0003 whereby noexcept has no special rule for constant
+ expressions anymore. Since the current behavior is important for
+ certain library functionality, we treat this as a DR, therefore
+ adjusting the behavior for C++11 and C++14. Previously, we had
+ to evaluate the noexcept-specifier's operand here, but that could
+ cause instantiations that would fail. */
}
if (!TYPE_NOTHROW_P (type))
return fn;