* [v3] Add some type_traits tests
@ 2010-02-21 11:08 Paolo Carlini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Carlini @ 2010-02-21 11:08 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++
[-- Attachment #1: Type: text/plain, Size: 67 bytes --]
Hi,
tested x86_64-linux, committed.
Paolo.
////////////////////
[-- Attachment #2: CL_ttests --]
[-- Type: text/plain, Size: 568 bytes --]
2010-02-21 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/20_util/is_trivial/requirements/typedefs.cc: New.
* testsuite/20_util/is_trivial/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_pod/value.cc: Likewise.
* testsuite/20_util/is_pod/requirements/typedefs.cc: Likewise.
* testsuite/20_util/is_pod/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/is_standard_layout/requiremenents/
typedefs.cc: Likewise.
* testsuite/20_util/is_standard_layout/requiremenents/
explicit_instantiation.cc: Likewise.
[-- Attachment #3: patch_ttests --]
[-- Type: text/plain, Size: 11465 bytes --]
Index: testsuite/20_util/is_trivial/requirements/typedefs.cc
===================================================================
--- testsuite/20_util/is_trivial/requirements/typedefs.cc (revision 0)
+++ testsuite/20_util/is_trivial/requirements/typedefs.cc (revision 0)
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++0x" }
+// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+//
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::is_trivial<int> test_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::type type;
+ typedef test_type::type::value_type type_value_type;
+ typedef test_type::type::type type_type;
+}
Index: testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc
===================================================================
--- testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc (revision 0)
+++ testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc (revision 0)
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+namespace std
+{
+ typedef short test_type;
+ template struct is_trivial<test_type>;
+}
Index: testsuite/20_util/is_pod/value.cc
===================================================================
--- testsuite/20_util/is_pod/value.cc (revision 0)
+++ testsuite/20_util/is_pod/value.cc (revision 0)
@@ -0,0 +1,54 @@
+// { dg-options "-std=gnu++0x" }
+// 2010-02-21 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::is_pod;
+ using namespace __gnu_test;
+
+ VERIFY( (test_category<is_pod, int>(true)) );
+ VERIFY( (test_category<is_pod, float>(true)) );
+ VERIFY( (test_category<is_pod, EnumType>(true)) );
+ VERIFY( (test_category<is_pod, int*>(true)) );
+ VERIFY( (test_category<is_pod, int(*)(int)>(true)) );
+ VERIFY( (test_category<is_pod, int (ClassType::*)>(true)) );
+ VERIFY( (test_category<is_pod, int (ClassType::*) (int)>(true)) );
+ VERIFY( (test_category<is_pod, int[2]>(true)) );
+ VERIFY( (test_category<is_pod, float[][3]>(true)) );
+ VERIFY( (test_category<is_pod, EnumType[2][3][4]>(true)) );
+ VERIFY( (test_category<is_pod, int*[3]>(true)) );
+ VERIFY( (test_category<is_pod, int(*[][2])(int)>(true)) );
+ VERIFY( (test_category<is_pod, int (ClassType::*[2][3])>(true)) );
+ VERIFY( (test_category<is_pod, int (ClassType::*[][2][3]) (int)>(true)) );
+ VERIFY( (test_category<is_pod, ClassType>(true)) );
+
+ VERIFY( (test_category<is_pod, void>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
Index: testsuite/20_util/is_pod/requirements/typedefs.cc
===================================================================
--- testsuite/20_util/is_pod/requirements/typedefs.cc (revision 0)
+++ testsuite/20_util/is_pod/requirements/typedefs.cc (revision 0)
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++0x" }
+// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+//
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::is_pod<int> test_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::type type;
+ typedef test_type::type::value_type type_value_type;
+ typedef test_type::type::type type_type;
+}
Index: testsuite/20_util/is_pod/requirements/explicit_instantiation.cc
===================================================================
--- testsuite/20_util/is_pod/requirements/explicit_instantiation.cc (revision 0)
+++ testsuite/20_util/is_pod/requirements/explicit_instantiation.cc (revision 0)
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+namespace std
+{
+ typedef short test_type;
+ template struct is_pod<test_type>;
+}
Index: testsuite/20_util/is_standard_layout/requiremenents/typedefs.cc
===================================================================
--- testsuite/20_util/is_standard_layout/requiremenents/typedefs.cc (revision 0)
+++ testsuite/20_util/is_standard_layout/requiremenents/typedefs.cc (revision 0)
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++0x" }
+// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+//
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+// { dg-do compile }
+
+void test01()
+{
+ // Check for required typedefs
+ typedef std::is_standard_layout<int> test_type;
+ typedef test_type::value_type value_type;
+ typedef test_type::type type;
+ typedef test_type::type::value_type type_value_type;
+ typedef test_type::type::type type_type;
+}
Index: testsuite/20_util/is_standard_layout/requiremenents/explicit_instantiation.cc
===================================================================
--- testsuite/20_util/is_standard_layout/requiremenents/explicit_instantiation.cc (revision 0)
+++ testsuite/20_util/is_standard_layout/requiremenents/explicit_instantiation.cc (revision 0)
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+// 2010-02-21 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// NB: This file is for testing type_traits with NO OTHER INCLUDES.
+
+#include <type_traits>
+
+namespace std
+{
+ typedef short test_type;
+ template struct is_standard_layout<test_type>;
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [v3] Add some type_traits tests
@ 2010-03-23 15:22 Paolo Carlini
2010-03-23 15:58 ` Paolo Carlini
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Carlini @ 2010-03-23 15:22 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++
[-- Attachment #1: Type: text/plain, Size: 83 bytes --]
Hi,
tested x86_64-linux, committed to mainline.
Paolo.
////////////////////////
[-- Attachment #2: CL_tests --]
[-- Type: text/plain, Size: 208 bytes --]
2010-03-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/20_util/is_trivial/value.cc: New.
* testsuite/20_util/is_standard_layout/value.cc: Likewise.
* testsuite/20_util/is_pod/value.cc: Extend.
[-- Attachment #3: patch_tests --]
[-- Type: text/plain, Size: 5238 bytes --]
Index: testsuite/20_util/is_trivial/value.cc
===================================================================
--- testsuite/20_util/is_trivial/value.cc (revision 0)
+++ testsuite/20_util/is_trivial/value.cc (revision 0)
@@ -0,0 +1,70 @@
+// { dg-options "-std=gnu++0x" }
+// 2010-03-23 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+struct NType // neither trivial nor standard-layout
+{
+ int i;
+ int j;
+ virtual ~NType();
+};
+
+struct TType // trivial but not standard-layout
+{
+ int i;
+
+private:
+ int j;
+};
+
+struct SLType // standard-layout but not trivial
+{
+ int i;
+ int j;
+ ~SLType();
+};
+
+struct PODType // both trivial and standard-layout
+{
+ int i;
+ int j;
+};
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::is_trivial;
+ using namespace __gnu_test;
+
+ VERIFY( (test_category<is_trivial, TType>(true)) );
+ VERIFY( (test_category<is_trivial, PODType>(true)) );
+
+ VERIFY( (test_category<is_trivial, NType>(false)) );
+ VERIFY( (test_category<is_trivial, SLType>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
Index: testsuite/20_util/is_pod/value.cc
===================================================================
--- testsuite/20_util/is_pod/value.cc (revision 157668)
+++ testsuite/20_util/is_pod/value.cc (working copy)
@@ -22,6 +22,34 @@
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
+struct NType // neither trivial nor standard-layout
+{
+ int i;
+ int j;
+ virtual ~NType();
+};
+
+struct TType // trivial but not standard-layout
+{
+ int i;
+
+private:
+ int j;
+};
+
+struct SLType // standard-layout but not trivial
+{
+ int i;
+ int j;
+ ~SLType();
+};
+
+struct PODType // both trivial and standard-layout
+{
+ int i;
+ int j;
+};
+
void test01()
{
bool test __attribute__((unused)) = true;
@@ -43,8 +71,12 @@
VERIFY( (test_category<is_pod, int (ClassType::*[2][3])>(true)) );
VERIFY( (test_category<is_pod, int (ClassType::*[][2][3]) (int)>(true)) );
VERIFY( (test_category<is_pod, ClassType>(true)) );
+ VERIFY( (test_category<is_pod, PODType>(true)) );
VERIFY( (test_category<is_pod, void>(false)) );
+ VERIFY( (test_category<is_pod, NType>(false)) );
+ VERIFY( (test_category<is_pod, TType>(false)) );
+ VERIFY( (test_category<is_pod, SLType>(false)) );
}
int main()
Index: testsuite/20_util/is_standard_layout/value.cc
===================================================================
--- testsuite/20_util/is_standard_layout/value.cc (revision 0)
+++ testsuite/20_util/is_standard_layout/value.cc (revision 0)
@@ -0,0 +1,70 @@
+// { dg-options "-std=gnu++0x" }
+// 2010-03-23 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <type_traits>
+#include <testsuite_hooks.h>
+#include <testsuite_tr1.h>
+
+struct NType // neither trivial nor standard-layout
+{
+ int i;
+ int j;
+ virtual ~NType();
+};
+
+struct TType // trivial but not standard-layout
+{
+ int i;
+
+private:
+ int j;
+};
+
+struct SLType // standard-layout but not trivial
+{
+ int i;
+ int j;
+ ~SLType();
+};
+
+struct PODType // both trivial and standard-layout
+{
+ int i;
+ int j;
+};
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::is_standard_layout;
+ using namespace __gnu_test;
+
+ VERIFY( (test_category<is_standard_layout, SLType>(true)) );
+ VERIFY( (test_category<is_standard_layout, PODType>(true)) );
+
+ VERIFY( (test_category<is_standard_layout, NType>(false)) );
+ VERIFY( (test_category<is_standard_layout, TType>(false)) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [v3] Add some type_traits tests
2010-03-23 15:22 Paolo Carlini
@ 2010-03-23 15:58 ` Paolo Carlini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Carlini @ 2010-03-23 15:58 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++
[-- Attachment #1: Type: text/plain, Size: 52 bytes --]
... oh, well. Committed.
Paolo.
/////////////////
[-- Attachment #2: CL_tests_fu --]
[-- Type: text/plain, Size: 285 bytes --]
2010-03-23 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/util/testsuite_tr1.h (NType, TType, SLType, PODType): Add.
* testsuite/20_util/is_trivial/value.cc: Adjust.
* testsuite/20_util/is_standard_layout/value.cc: Likewise.
* testsuite/20_util/is_pod/value.cc: Likewise.
[-- Attachment #3: patch_tests_fu --]
[-- Type: text/plain, Size: 3039 bytes --]
Index: testsuite/util/testsuite_tr1.h
===================================================================
--- testsuite/util/testsuite_tr1.h (revision 157670)
+++ testsuite/util/testsuite_tr1.h (working copy)
@@ -129,6 +129,33 @@
explicit ExplicitClass(int&);
};
+ struct NType // neither trivial nor standard-layout
+ {
+ int i;
+ int j;
+ virtual ~NType();
+ };
+
+ struct TType // trivial but not standard-layout
+ {
+ int i;
+ private:
+ int j;
+ };
+
+ struct SLType // standard-layout but not trivial
+ {
+ int i;
+ int j;
+ ~SLType();
+ };
+
+ struct PODType // both trivial and standard-layout
+ {
+ int i;
+ int j;
+ };
+
int truncate_float(float x) { return (int)x; }
long truncate_double(double x) { return (long)x; }
Index: testsuite/20_util/is_trivial/value.cc
===================================================================
--- testsuite/20_util/is_trivial/value.cc (revision 157671)
+++ testsuite/20_util/is_trivial/value.cc (working copy)
@@ -22,34 +22,6 @@
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
-struct NType // neither trivial nor standard-layout
-{
- int i;
- int j;
- virtual ~NType();
-};
-
-struct TType // trivial but not standard-layout
-{
- int i;
-
-private:
- int j;
-};
-
-struct SLType // standard-layout but not trivial
-{
- int i;
- int j;
- ~SLType();
-};
-
-struct PODType // both trivial and standard-layout
-{
- int i;
- int j;
-};
-
void test01()
{
bool test __attribute__((unused)) = true;
Index: testsuite/20_util/is_pod/value.cc
===================================================================
--- testsuite/20_util/is_pod/value.cc (revision 157671)
+++ testsuite/20_util/is_pod/value.cc (working copy)
@@ -22,34 +22,6 @@
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
-struct NType // neither trivial nor standard-layout
-{
- int i;
- int j;
- virtual ~NType();
-};
-
-struct TType // trivial but not standard-layout
-{
- int i;
-
-private:
- int j;
-};
-
-struct SLType // standard-layout but not trivial
-{
- int i;
- int j;
- ~SLType();
-};
-
-struct PODType // both trivial and standard-layout
-{
- int i;
- int j;
-};
-
void test01()
{
bool test __attribute__((unused)) = true;
Index: testsuite/20_util/is_standard_layout/value.cc
===================================================================
--- testsuite/20_util/is_standard_layout/value.cc (revision 157671)
+++ testsuite/20_util/is_standard_layout/value.cc (working copy)
@@ -22,34 +22,6 @@
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
-struct NType // neither trivial nor standard-layout
-{
- int i;
- int j;
- virtual ~NType();
-};
-
-struct TType // trivial but not standard-layout
-{
- int i;
-
-private:
- int j;
-};
-
-struct SLType // standard-layout but not trivial
-{
- int i;
- int j;
- ~SLType();
-};
-
-struct PODType // both trivial and standard-layout
-{
- int i;
- int j;
-};
-
void test01()
{
bool test __attribute__((unused)) = true;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-23 15:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-21 11:08 [v3] Add some type_traits tests Paolo Carlini
2010-03-23 15:22 Paolo Carlini
2010-03-23 15:58 ` Paolo Carlini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).