This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ Patch] PR 36855


Hi,

tested x86_64-linux. Ok for mainline?

Thanks,
Paolo.

/////////////////
/cp
2008-07-16  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-16  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.
Index: testsuite/g++.dg/ext/has_trivial_destructor.C
===================================================================
*** testsuite/g++.dg/ext/has_trivial_destructor.C	(revision 137892)
--- testsuite/g++.dg/ext/has_trivial_destructor.C	(working copy)
***************
*** 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;
- }
--- 0 ----
Index: testsuite/g++.dg/ext/has_trivial_destructor-2.C
===================================================================
*** testsuite/g++.dg/ext/has_trivial_destructor-2.C	(revision 0)
--- testsuite/g++.dg/ext/has_trivial_destructor-2.C	(revision 0)
***************
*** 0 ****
--- 1,3 ----
+ // PR c++/36855
+ 
+ typedef char assert_0 [__has_trivial_destructor (int&) ? 1 : -1];
Index: cp/semantics.c
===================================================================
*** cp/semantics.c	(revision 137892)
--- cp/semantics.c	(working copy)
*************** trait_expr_value (cp_trait_kind kind, tr
*** 4730,4736 ****
  
      case CPTK_HAS_TRIVIAL_DESTRUCTOR:
        type1 = strip_array_types (type1);
!       return (pod_type_p (type1)
  	      || (CLASS_TYPE_P (type1)
  		  && TYPE_HAS_TRIVIAL_DESTRUCTOR (type1)));
  
--- 4730,4736 ----
  
      case CPTK_HAS_TRIVIAL_DESTRUCTOR:
        type1 = strip_array_types (type1);
!       return (pod_type_p (type1) || type_code1 == REFERENCE_TYPE
  	      || (CLASS_TYPE_P (type1)
  		  && TYPE_HAS_TRIVIAL_DESTRUCTOR (type1)));
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]