summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2017-07-17 11:54:03 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2017-07-17 11:54:03 +0000
commit55d57ab731875f300ce3adfeb66d5c2b70f8aa16 (patch)
treee2a83001fe2ef31c116c0f4877a9169a885f5a92 /gcc/cp
parent96cea83ca9362a5598ab54ed83132cc0ab30a7e7 (diff)
downloadgcc-55d57ab731875f300ce3adfeb66d5c2b70f8aa16.tar.gz
* semantics.c (classtype_has_nothrow_assign_or_copy_p): Clarify
semantics, simplify implementation. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250272 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/semantics.c32
2 files changed, 17 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 84a21341ce9..ecffbcdde56 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 f6177b32a32..cf19e5fd96a 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. */