Commit 5337720c by Nathan Sidwell Committed by Nathan Sidwell

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
parent 26c5b549
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> 2017-07-16 Volker Reichelt <v.reichelt@netcologne.de>
* parser.c (cp_parser_cast_expression): Use %q#T instead of %qT * parser.c (cp_parser_cast_expression): Use %q#T instead of %qT
......
...@@ -9072,19 +9072,16 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, ...@@ -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 /* 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 static bool
classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p) classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p)
{ {
tree fns; tree fns = NULL_TREE;
if (assign_p) if (assign_p)
{ fns = lookup_fnfields_slot (type, cp_assignment_operator_id (NOP_EXPR));
fns = lookup_fnfields_slot (type, cp_assignment_operator_id (NOP_EXPR));
if (!fns)
return false;
}
else if (TYPE_HAS_COPY_CTOR (type)) else if (TYPE_HAS_COPY_CTOR (type))
{ {
/* If construction of the copy constructor was postponed, create /* 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) ...@@ -9095,27 +9092,22 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p)
lazily_declare_fn (sfk_move_constructor, type); lazily_declare_fn (sfk_move_constructor, type);
fns = CLASSTYPE_CONSTRUCTORS (type); fns = CLASSTYPE_CONSTRUCTORS (type);
} }
else
return false;
bool saw_copy = false;
for (ovl_iterator iter (fns); iter; ++iter) for (ovl_iterator iter (fns); iter; ++iter)
{ {
tree fn = *iter; tree fn = *iter;
if (assign_p) if (copy_fn_p (fn) > 0)
{ {
if (copy_fn_p (fn) == 0) saw_copy = true;
continue; 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. */ /* Actually evaluates the trait. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment