Commit b29441ec by Paolo Carlini Committed by Paolo Carlini

semantics.c (classtype_has_nothrow_copy_or_assign_p): Adjust per N2255; rename…

semantics.c (classtype_has_nothrow_copy_or_assign_p): Adjust per N2255; rename as classtype_has_nothrow_assign_or_copy_p.

gcc/cp
2007-04-25  Paolo Carlini  <pcarlini@suse.de>

	* semantics.c (classtype_has_nothrow_copy_or_assign_p): Adjust
	per N2255; rename as classtype_has_nothrow_assign_or_copy_p.
	(trait_expr_value): Adjust.

gcc/testsuite/
2007-04-25  Paolo Carlini  <pcarlini@suse.de>

	* g++.dg/ext/has_nothrow_assign.C: Adjust per N2255.

gcc/
2007-04-25  Paolo Carlini  <pcarlini@suse.de>

	* doc/extend.texi ([Type Traits]): Adjust per N2255.

From-SVN: r124170
parent d6626ee7
2007-04-25 Paolo Carlini <pcarlini@suse.de>
* doc/extend.texi ([Type Traits]): Adjust per N2255.
2007-04-25 Bob Wilson <bob.wilson@acm.org> 2007-04-25 Bob Wilson <bob.wilson@acm.org>
* config/xtensa/lib1funcs.asm (__udivsi3, __divsi3): Throw an exception * config/xtensa/lib1funcs.asm (__udivsi3, __divsi3): Throw an exception
......
2007-04-25 Paolo Carlini <pcarlini@suse.de>
* semantics.c (classtype_has_nothrow_copy_or_assign_p): Adjust
per N2255; rename as classtype_has_nothrow_assign_or_copy_p.
(trait_expr_value): Adjust.
2007-04-23 Simon Baldwin <simonb@google.com> 2007-04-23 Simon Baldwin <simonb@google.com>
* decl.c (grokparms): Added new error for duplicate function * decl.c (grokparms): Added new error for duplicate function
......
...@@ -4007,63 +4007,37 @@ finish_static_assert (tree condition, tree message, location_t location, ...@@ -4007,63 +4007,37 @@ finish_static_assert (tree condition, tree message, location_t location,
} }
} }
/* Called from trait_expr_value to evaluate either __has_nothrow_copy or /* Called from trait_expr_value to evaluate either __has_nothrow_assign or
__has_nothrow_assign, depending on copy_p. */ __has_nothrow_copy, depending on assign_p. */
static bool static bool
classtype_has_nothrow_copy_or_assign_p (tree type, bool copy_p) classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p)
{ {
if ((copy_p && TYPE_HAS_INIT_REF (type)) tree fns;
|| (!copy_p && TYPE_HAS_ASSIGN_REF (type)))
{
bool const_p = false;
tree t;
struct copy_data
{
tree name;
int quals;
} data;
data.name = copy_p ? NULL_TREE : ansi_assopname (NOP_EXPR);
data.quals = TYPE_QUAL_CONST;
t = locate_copy (type, &data);
if (t)
{
const_p = true;
if (!TREE_NOTHROW (t))
return false;
}
if (copy_p || !CP_TYPE_CONST_P (type))
{
data.quals = TYPE_UNQUALIFIED;
t = locate_copy (type, &data);
if (t && !TREE_NOTHROW (t))
return false;
data.quals = TYPE_QUAL_VOLATILE;
t = locate_copy (type, &data);
if (t && !TREE_NOTHROW (t))
return false;
}
data.quals = (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); if (assign_p)
t = locate_copy (type, &data); {
if (t) int ix;
{ ix = lookup_fnfields_1 (type, ansi_assopname (NOP_EXPR));
const_p = true; if (ix < 0)
if (!TREE_NOTHROW (t))
return false;
}
if (!copy_p && CP_TYPE_CONST_P (type) && !const_p)
return false; return false;
fns = VEC_index (tree, CLASSTYPE_METHOD_VEC (type), ix);
}
else if (TYPE_HAS_INIT_REF (type))
{
/* If construction of the copy constructor was postponed, create
it now. */
if (CLASSTYPE_LAZY_COPY_CTOR (type))
lazily_declare_fn (sfk_copy_constructor, type);
fns = CLASSTYPE_CONSTRUCTORS (type);
} }
else else
return false; return false;
for (; fns; fns = OVL_NEXT (fns))
if (!TREE_NOTHROW (OVL_CURRENT (fns)))
return false;
return true; return true;
} }
...@@ -4080,9 +4054,11 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) ...@@ -4080,9 +4054,11 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
switch (kind) switch (kind)
{ {
case CPTK_HAS_NOTHROW_ASSIGN: case CPTK_HAS_NOTHROW_ASSIGN:
return (trait_expr_value (CPTK_HAS_TRIVIAL_ASSIGN, type1, type2) return (!CP_TYPE_CONST_P (type1) && type_code1 != REFERENCE_TYPE
|| (CLASS_TYPE_P (type1) && (trait_expr_value (CPTK_HAS_TRIVIAL_ASSIGN, type1, type2)
&& classtype_has_nothrow_copy_or_assign_p (type1, false))); || (CLASS_TYPE_P (type1)
&& classtype_has_nothrow_assign_or_copy_p (type1,
true))));
case CPTK_HAS_TRIVIAL_ASSIGN: case CPTK_HAS_TRIVIAL_ASSIGN:
return (!CP_TYPE_CONST_P (type1) && type_code1 != REFERENCE_TYPE return (!CP_TYPE_CONST_P (type1) && type_code1 != REFERENCE_TYPE
...@@ -4104,7 +4080,7 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) ...@@ -4104,7 +4080,7 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
case CPTK_HAS_NOTHROW_COPY: case CPTK_HAS_NOTHROW_COPY:
return (trait_expr_value (CPTK_HAS_TRIVIAL_COPY, type1, type2) return (trait_expr_value (CPTK_HAS_TRIVIAL_COPY, type1, type2)
|| (CLASS_TYPE_P (type1) || (CLASS_TYPE_P (type1)
&& classtype_has_nothrow_copy_or_assign_p (type1, true))); && classtype_has_nothrow_assign_or_copy_p (type1, false)));
case CPTK_HAS_TRIVIAL_COPY: case CPTK_HAS_TRIVIAL_COPY:
return (pod_type_p (type1) || type_code1 == REFERENCE_TYPE return (pod_type_p (type1) || type_code1 == REFERENCE_TYPE
......
...@@ -11246,13 +11246,12 @@ pair of types). ...@@ -11246,13 +11246,12 @@ pair of types).
@table @code @table @code
@item __has_nothrow_assign (type) @item __has_nothrow_assign (type)
If @code{__has_trivial_assign (type)} is true then the trait is true, else if If @code{type} is const qualified or is a reference type then the trait is
@code{type} is a cv class or union type with copy assignment operators that false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
are known not to throw an exception then the trait is true, else it is false. is true, else if @code{type} is a cv class or union type with copy assignment
If @code{type} is const qualified, any copy assignment operator must operators that are known not to throw an exception then the trait is true,
be both known not to throw an exception, and const qualified, for the else it is false. Requires: @code{type} shall be a complete type, an array
trait to be true. Requires: @code{type} shall be a complete type, an type of unknown bound, or is a @code{void} type.
array type of unknown bound, or is a @code{void} type.
@item __has_nothrow_copy (type) @item __has_nothrow_copy (type)
If @code{__has_trivial_copy (type)} is true then the trait is true, else if If @code{__has_trivial_copy (type)} is true then the trait is true, else if
......
2007-04-25 Paolo Carlini <pcarlini@suse.de>
* g++.dg/ext/has_nothrow_assign.C: Adjust per N2255.
2007-04-25 Thiemo Seufer <ths@mips.com> 2007-04-25 Thiemo Seufer <ths@mips.com>
* gcc.target/mips/mips16e-extends.c (cksum8): Change return * gcc.target/mips/mips16e-extends.c (cksum8): Change return
...@@ -146,7 +146,7 @@ int main() ...@@ -146,7 +146,7 @@ int main()
assert (NTEST (I1)); assert (NTEST (I1));
assert (PTEST (J)); assert (PTEST (J));
assert (NTEST (const K)); assert (NTEST (const K));
assert (PTEST (const L)); assert (NTEST (const L));
return 0; return 0;
} }
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