OSDN Git Service

gcc/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Apr 2007 23:55:11 +0000 (23:55 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Apr 2007 23:55:11 +0000 (23:55 +0000)
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

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/has_nothrow_assign.C

index c4cfa5c..d20eab5 100644 (file)
@@ -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
index f3eb5de..37b7742 100644 (file)
@@ -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
index bfb84ec..c683ba2 100644 (file)
@@ -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
index ce63202..45a6324 100644 (file)
@@ -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
index 9dc7a39..c7f3dbb 100644 (file)
@@ -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
index f879082..5407b96 100644 (file)
@@ -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;
 }