re PR c++/36855 (__has_trivial_destructor() returns false for reference types.)
authorPaolo Carlini <paolo@gcc.gnu.org>
Thu, 17 Jul 2008 09:11:11 +0000 (09:11 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 17 Jul 2008 09:11:11 +0000 (09:11 +0000)
/cp
2008-07-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/36855
* semantics.c (trait_expr_value): Update __has_trivial_destructor
semantics to the current WP (N2691).

/testsuite
2008-07-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/36855
* g++.dg/ext/has_trivial_destructor.C: Rename to...
* g++.dg/ext/has_trivial_destructor-1.C: ... this.
* g++.dg/ext/has_trivial_destructor-2.C: New.

From-SVN: r137914

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/has_trivial_destructor-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/has_trivial_destructor-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/has_trivial_destructor.C [deleted file]

index 8f87551ee369bb470b9f61eb5d7beacb7c227c5c..0e537b855c7c5dd04e4a2a4b48734d0bbfb628ad 100644 (file)
@@ -1,8 +1,13 @@
+2008-07-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/36855
+       * semantics.c (trait_expr_value): Update __has_trivial_destructor
+       semantics to the current WP (N2691).
+
 2008-07-16  Dodji Seketeli  <dseketel@redhat.com>
 
        PR c++/13699
-       * gcc/cp/name-lookup.c (lookup_extern_c_fun_binding_in_all_ns):
-       New function.
+       * name-lookup.c (lookup_extern_c_fun_binding_in_all_ns): New function.
        (pushdecl_maybe_friend): Check if a redeclaration of extern C function
        complies with exception specification constraints.
 
@@ -22,8 +27,8 @@
 
        PR c++/13101
        * decl.c (grokdeclarator): Warn about initializing variables
-         of storage class 'extern' only after the type of the declarator
-         has been properly computed.
+       of storage class 'extern' only after the type of the declarator
+       has been properly computed.
 
 2008-07-11  Dodji Seketeli  <dseketel@redhat.com>
 
index 17b1e5dee498afba533b4d3670f275ca618d260d..d2f56ea810a312f4d79ac34f55285841806aca49 100644 (file)
@@ -4730,7 +4730,7 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
 
     case CPTK_HAS_TRIVIAL_DESTRUCTOR:
       type1 = strip_array_types (type1);
-      return (pod_type_p (type1)
+      return (pod_type_p (type1) || type_code1 == REFERENCE_TYPE
              || (CLASS_TYPE_P (type1)
                  && TYPE_HAS_TRIVIAL_DESTRUCTOR (type1)));
 
index ec7dc0540d8cde5dab503947f4dec3d2f151f690..528a1114b30df6845921ae684f330eef995f0e8e 100644 (file)
@@ -1,3 +1,10 @@
+2008-07-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/36855
+       * g++.dg/ext/has_trivial_destructor.C: Rename to...
+       * g++.dg/ext/has_trivial_destructor-1.C: ... this.
+       * g++.dg/ext/has_trivial_destructor-2.C: New.
+
 2008-07-17  Paolo Bonzini  <bonzini@gnu.org>
 
        PR rtl-optimization/36753
diff --git a/gcc/testsuite/g++.dg/ext/has_trivial_destructor-1.C b/gcc/testsuite/g++.dg/ext/has_trivial_destructor-1.C
new file mode 100644 (file)
index 0000000..719f05f
--- /dev/null
@@ -0,0 +1,86 @@
+// { dg-do "run" }
+#include <cassert>
+
+struct A
+{
+  double a;
+  double b;
+};
+
+union U
+{
+  double a;
+  double b;
+};
+
+struct B
+{
+  ~B() { }
+};
+
+struct C 
+: public B { };
+
+struct D
+: public A { };
+
+template<typename T>
+  bool
+  f()
+  { return __has_trivial_destructor(T); } 
+
+template<typename T>
+  class My
+  {
+  public:
+    bool
+    f()
+    { return !!__has_trivial_destructor(T); }
+  };
+
+template<typename T>
+  class My2
+  {
+  public:
+    static const bool trait = __has_trivial_destructor(T);
+  };
+
+template<typename T>
+  const bool My2<T>::trait;
+
+template<typename T, bool b = __has_trivial_destructor(T)>
+  struct My3_help
+  { static const bool trait = b; };
+
+template<typename T, bool b>
+  const bool My3_help<T, b>::trait;
+
+template<typename T>
+  class My3
+  {
+  public:
+    bool
+    f()
+    { return My3_help<T>::trait; }
+  };
+
+#define PTEST(T) (__has_trivial_destructor(T) && f<T>() \
+                  && My<T>().f() && My2<T>::trait && My3<T>().f())
+
+#define NTEST(T) (!__has_trivial_destructor(T) && !f<T>() \
+                  && !My<T>().f() && !My2<T>::trait && !My3<T>().f())
+
+int main()
+{
+  assert (PTEST (int));
+  assert (NTEST (int (int)));
+  assert (NTEST (void));
+  assert (PTEST (A));
+  assert (PTEST (U));
+  assert (NTEST (B));
+  assert (NTEST (C));
+  assert (PTEST (D));
+  assert (PTEST (D[]));
+
+  return 0;
+}
diff --git a/gcc/testsuite/g++.dg/ext/has_trivial_destructor-2.C b/gcc/testsuite/g++.dg/ext/has_trivial_destructor-2.C
new file mode 100644 (file)
index 0000000..f9dacf1
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/36855
+
+typedef char assert_0 [__has_trivial_destructor (int&) ? 1 : -1];
diff --git a/gcc/testsuite/g++.dg/ext/has_trivial_destructor.C b/gcc/testsuite/g++.dg/ext/has_trivial_destructor.C
deleted file mode 100644 (file)
index 719f05f..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-// { dg-do "run" }
-#include <cassert>
-
-struct A
-{
-  double a;
-  double b;
-};
-
-union U
-{
-  double a;
-  double b;
-};
-
-struct B
-{
-  ~B() { }
-};
-
-struct C 
-: public B { };
-
-struct D
-: public A { };
-
-template<typename T>
-  bool
-  f()
-  { return __has_trivial_destructor(T); } 
-
-template<typename T>
-  class My
-  {
-  public:
-    bool
-    f()
-    { return !!__has_trivial_destructor(T); }
-  };
-
-template<typename T>
-  class My2
-  {
-  public:
-    static const bool trait = __has_trivial_destructor(T);
-  };
-
-template<typename T>
-  const bool My2<T>::trait;
-
-template<typename T, bool b = __has_trivial_destructor(T)>
-  struct My3_help
-  { static const bool trait = b; };
-
-template<typename T, bool b>
-  const bool My3_help<T, b>::trait;
-
-template<typename T>
-  class My3
-  {
-  public:
-    bool
-    f()
-    { return My3_help<T>::trait; }
-  };
-
-#define PTEST(T) (__has_trivial_destructor(T) && f<T>() \
-                  && My<T>().f() && My2<T>::trait && My3<T>().f())
-
-#define NTEST(T) (!__has_trivial_destructor(T) && !f<T>() \
-                  && !My<T>().f() && !My2<T>::trait && !My3<T>().f())
-
-int main()
-{
-  assert (PTEST (int));
-  assert (NTEST (int (int)));
-  assert (NTEST (void));
-  assert (PTEST (A));
-  assert (PTEST (U));
-  assert (NTEST (B));
-  assert (NTEST (C));
-  assert (PTEST (D));
-  assert (PTEST (D[]));
-
-  return 0;
-}