summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-25 23:55:11 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-25 23:55:11 +0000
commit0aa5d886a91d534c4b42fe6cda9bde019624f061 (patch)
tree6ecdfd411e832bd7ab82f7dc1e3dc7d5b41be3e0 /gcc
parentb82257573b31afc9c22e1a1a4471755e34b5b01f (diff)
downloadgcc-0aa5d886a91d534c4b42fe6cda9bde019624f061.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@124170 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/semantics.c80
-rw-r--r--gcc/doc/extend.texi13
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/ext/has_nothrow_assign.C2
6 files changed, 49 insertions, 60 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c4cfa5cbd21..d20eab51961 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+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>
* config/xtensa/lib1funcs.asm (__udivsi3, __divsi3): Throw an exception
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f3eb5debfd4..37b7742734e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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>
* decl.c (grokparms): Added new error for duplicate function
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index bfb84ec5d5f..c683ba298ff 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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
- __has_nothrow_assign, depending on copy_p. */
+/* Called from trait_expr_value to evaluate either __has_nothrow_assign or
+ __has_nothrow_copy, depending on assign_p. */
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))
- || (!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;
- }
+ tree fns;
- data.quals = (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
- t = locate_copy (type, &data);
- if (t)
- {
- const_p = true;
- if (!TREE_NOTHROW (t))
- return false;
- }
-
- if (!copy_p && CP_TYPE_CONST_P (type) && !const_p)
+ if (assign_p)
+ {
+ int ix;
+ ix = lookup_fnfields_1 (type, ansi_assopname (NOP_EXPR));
+ if (ix < 0)
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
return false;
+ for (; fns; fns = OVL_NEXT (fns))
+ if (!TREE_NOTHROW (OVL_CURRENT (fns)))
+ return false;
+
return true;
}
@@ -4080,9 +4054,11 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
switch (kind)
{
case CPTK_HAS_NOTHROW_ASSIGN:
- return (trait_expr_value (CPTK_HAS_TRIVIAL_ASSIGN, type1, type2)
- || (CLASS_TYPE_P (type1)
- && classtype_has_nothrow_copy_or_assign_p (type1, false)));
+ return (!CP_TYPE_CONST_P (type1) && type_code1 != REFERENCE_TYPE
+ && (trait_expr_value (CPTK_HAS_TRIVIAL_ASSIGN, type1, type2)
+ || (CLASS_TYPE_P (type1)
+ && classtype_has_nothrow_assign_or_copy_p (type1,
+ true))));
case CPTK_HAS_TRIVIAL_ASSIGN:
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)
case CPTK_HAS_NOTHROW_COPY:
return (trait_expr_value (CPTK_HAS_TRIVIAL_COPY, type1, type2)
|| (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:
return (pod_type_p (type1) || type_code1 == REFERENCE_TYPE
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index ce63202ebb0..45a632493de 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -11246,13 +11246,12 @@ pair of types).
@table @code
@item __has_nothrow_assign (type)
-If @code{__has_trivial_assign (type)} is true then the trait is true, else if
-@code{type} is a cv class or union type with copy assignment operators that
-are known not to throw an exception then the trait is true, else it is false.
-If @code{type} is const qualified, any copy assignment operator must
-be both known not to throw an exception, and const qualified, for the
-trait to be true. Requires: @code{type} shall be a complete type, an
-array type of unknown bound, or is a @code{void} type.
+If @code{type} is const qualified or is a reference type then the trait is
+false. Otherwise if @code{__has_trivial_assign (type)} is true then the trait
+is true, else if @code{type} is a cv class or union type with copy assignment
+operators that are known not to throw an exception then the trait is true,
+else it is false. Requires: @code{type} shall be a complete type, an array
+type of unknown bound, or is a @code{void} type.
@item __has_nothrow_copy (type)
If @code{__has_trivial_copy (type)} is true then the trait is true, else if
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9dc7a398a5d..c7f3dbb80e2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+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>
* gcc.target/mips/mips16e-extends.c (cksum8): Change return
diff --git a/gcc/testsuite/g++.dg/ext/has_nothrow_assign.C b/gcc/testsuite/g++.dg/ext/has_nothrow_assign.C
index f8790825351..5407b963e14 100644
--- a/gcc/testsuite/g++.dg/ext/has_nothrow_assign.C
+++ b/gcc/testsuite/g++.dg/ext/has_nothrow_assign.C
@@ -146,7 +146,7 @@ int main()
assert (NTEST (I1));
assert (PTEST (J));
assert (NTEST (const K));
- assert (PTEST (const L));
+ assert (NTEST (const L));
return 0;
}