diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-07-17 11:54:03 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-07-17 11:54:03 +0000 |
commit | 5337720c54ee8529d7d16d6f1eaa0b5556f60426 (patch) | |
tree | e2a83001fe2ef31c116c0f4877a9169a885f5a92 /gcc | |
parent | 26c5b549cf954899e4c383e4f23e0b1c305449b2 (diff) | |
download | gcc-5337720c54ee8529d7d16d6f1eaa0b5556f60426.zip gcc-5337720c54ee8529d7d16d6f1eaa0b5556f60426.tar.gz gcc-5337720c54ee8529d7d16d6f1eaa0b5556f60426.tar.bz2 |
semantics.c (classtype_has_nothrow_assign_or_copy_p): Clarify semantics, simplify implementation.
* semantics.c (classtype_has_nothrow_assign_or_copy_p): Clarify
semantics, simplify implementation.
From-SVN: r250272
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 32 |
2 files changed, 17 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 84a2134..ecffbcd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-07-17 Nathan Sidwell <nathan@acm.org> + + * semantics.c (classtype_has_nothrow_assign_or_copy_p): Clarify + semantics, simplify implementation. + 2017-07-16 Volker Reichelt <v.reichelt@netcologne.de> * parser.c (cp_parser_cast_expression): Use %q#T instead of %qT diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f6177b3..cf19e5f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9072,19 +9072,16 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, } /* Called from trait_expr_value to evaluate either __has_nothrow_assign or - __has_nothrow_copy, depending on assign_p. */ + __has_nothrow_copy, depending on assign_p. Returns true iff all + the copy {ctor,assign} fns are nothrow. */ static bool classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p) { - tree fns; + tree fns = NULL_TREE; if (assign_p) - { - fns = lookup_fnfields_slot (type, cp_assignment_operator_id (NOP_EXPR)); - if (!fns) - return false; - } + fns = lookup_fnfields_slot (type, cp_assignment_operator_id (NOP_EXPR)); else if (TYPE_HAS_COPY_CTOR (type)) { /* If construction of the copy constructor was postponed, create @@ -9095,27 +9092,22 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p) lazily_declare_fn (sfk_move_constructor, type); fns = CLASSTYPE_CONSTRUCTORS (type); } - else - return false; + bool saw_copy = false; for (ovl_iterator iter (fns); iter; ++iter) { tree fn = *iter; - - if (assign_p) + + if (copy_fn_p (fn) > 0) { - if (copy_fn_p (fn) == 0) - continue; + saw_copy = true; + maybe_instantiate_noexcept (fn); + if (!TYPE_NOTHROW_P (TREE_TYPE (fn))) + return false; } - else if (copy_fn_p (fn) <= 0) - continue; - - maybe_instantiate_noexcept (fn); - if (!TYPE_NOTHROW_P (TREE_TYPE (fn))) - return false; } - return true; + return saw_copy; } /* Actually evaluates the trait. */ |