]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/util/testsuite_tr1.h
re PR testsuite/39696 (gcc.dg/tree-ssa/ssa-ccp-25.c scan-tree-dump doesn't work on...
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / testsuite_tr1.h
CommitLineData
493bc460
PC
1// -*- C++ -*-
2// Testing utilities for the tr1 testsuite.
3//
22931aa4 4// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
493bc460
PC
5//
6// This file is part of the GNU ISO C++ Library. This library is free
7// software; you can redistribute it and/or modify it under the
8// terms of the GNU General Public License as published by the
9// Free Software Foundation; either version 2, or (at your option)
10// any later version.
11//
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING. If not, write to the Free
83f51799 19// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
493bc460
PC
20// USA.
21//
22// As a special exception, you may use this file as part of a free software
23// library without restriction. Specifically, if other files instantiate
24// templates or use macros or inline functions from this file, or you compile
25// this file and link it with other files to produce an executable, this
26// file does not by itself cause the resulting executable to be covered by
27// the GNU General Public License. This exception does not however
28// invalidate any other reasons why the executable file might be covered by
29// the GNU General Public License.
30
31#ifndef _GLIBCXX_TESTSUITE_TR1_H
32#define _GLIBCXX_TESTSUITE_TR1_H
33
105c6331 34#include <ext/type_traits.h>
ab44b018 35
493bc460 36namespace __gnu_test
0179f2c6 37{
493bc460 38 // For tr1/type_traits.
105c6331 39 template<template<typename> class Category, typename Type>
493bc460 40 bool
db5ff236 41 test_category(bool value)
493bc460
PC
42 {
43 bool ret = true;
db5ff236
PC
44 ret &= Category<Type>::value == value;
45 ret &= Category<const Type>::value == value;
46 ret &= Category<volatile Type>::value == value;
47 ret &= Category<const volatile Type>::value == value;
48 ret &= Category<Type>::type::value == value;
49 ret &= Category<const Type>::type::value == value;
50 ret &= Category<volatile Type>::type::value == value;
51 ret &= Category<const volatile Type>::type::value == value;
493bc460
PC
52 return ret;
53 }
0f910b4f 54
105c6331 55 template<template<typename> class Property, typename Type>
0f910b4f 56 bool
db5ff236 57 test_property(typename Property<Type>::value_type value)
0f910b4f
PC
58 {
59 bool ret = true;
db5ff236
PC
60 ret &= Property<Type>::value == value;
61 ret &= Property<Type>::type::value == value;
0f910b4f 62 return ret;
36651afe
PC
63 }
64
e7e93965
MM
65 // For testing tr1/type_traits/extent, which has a second template
66 // parameter.
67 template<template<typename, unsigned> class Property,
68 typename Type,
69 unsigned Uint>
70 bool
71 test_property(typename Property<Type, Uint>::value_type value)
72 {
73 bool ret = true;
74 ret &= Property<Type, Uint>::value == value;
75 ret &= Property<Type, Uint>::type::value == value;
76 return ret;
77 }
78
d63a0e22 79 template<template<typename, typename> class Relationship,
0179f2c6 80 typename Type1, typename Type2>
d63a0e22 81 bool
db5ff236 82 test_relationship(bool value)
d63a0e22
PC
83 {
84 bool ret = true;
db5ff236
PC
85 ret &= Relationship<Type1, Type2>::value == value;
86 ret &= Relationship<Type1, Type2>::type::value == value;
d63a0e22
PC
87 return ret;
88 }
89
0f910b4f
PC
90 // Test types.
91 class ClassType { };
d63a0e22
PC
92 typedef const ClassType cClassType;
93 typedef volatile ClassType vClassType;
94 typedef const volatile ClassType cvClassType;
a9e7ba81 95
c150a271
PC
96 class DerivedType : public ClassType { };
97
dcd400b5 98 enum EnumType { e0 };
a9e7ba81
PC
99
100 struct ConvType
101 { operator int() const; };
f8023b78
PC
102
103 class AbstractClass
59cffcf6 104 {
cff001b2 105 virtual void rotate(int) = 0;
cff001b2 106 };
0179f2c6 107
442dca70 108 class PolymorphicClass
59cffcf6 109 {
cff001b2 110 virtual void rotate(int);
cff001b2 111 };
442dca70 112
59cffcf6 113 class DerivedPolymorphic : public PolymorphicClass { };
442dca70 114
22931aa4
PC
115 class VirtualDestructorClass
116 {
117 virtual ~VirtualDestructorClass();
118 };
119
9e38f702 120 union UnionType { };
0179f2c6 121
516ebd44 122 class IncompleteClass;
0179f2c6 123
9e38f702
PC
124 int truncate_float(float x) { return (int)x; }
125 long truncate_double(double x) { return (long)x; }
0179f2c6 126
9e38f702
PC
127 struct do_truncate_float_t
128 {
129 do_truncate_float_t()
130 {
131 ++live_objects;
132 }
0179f2c6 133
9e38f702
PC
134 do_truncate_float_t(const do_truncate_float_t&)
135 {
136 ++live_objects;
137 }
59cffcf6 138
9e38f702
PC
139 ~do_truncate_float_t()
140 {
141 --live_objects;
142 }
0179f2c6 143
9e38f702 144 int operator()(float x) { return (int)x; }
59cffcf6 145
9e38f702
PC
146 static int live_objects;
147 };
0179f2c6 148
9e38f702 149 int do_truncate_float_t::live_objects = 0;
0179f2c6 150
9e38f702
PC
151 struct do_truncate_double_t
152 {
153 do_truncate_double_t()
154 {
0179f2c6 155 ++live_objects;
9e38f702 156 }
0179f2c6 157
9e38f702
PC
158 do_truncate_double_t(const do_truncate_double_t&)
159 {
160 ++live_objects;
161 }
0179f2c6 162
9e38f702
PC
163 ~do_truncate_double_t()
164 {
165 --live_objects;
166 }
0179f2c6 167
9e38f702 168 long operator()(double x) { return (long)x; }
59cffcf6 169
9e38f702
PC
170 static int live_objects;
171 };
59cffcf6 172
9e38f702 173 int do_truncate_double_t::live_objects = 0;
59cffcf6 174
9e38f702
PC
175 struct X
176 {
177 int bar;
59cffcf6 178
9e38f702
PC
179 int foo() { return 1; }
180 int foo_c() const { return 2; }
181 int foo_v() volatile { return 3; }
182 int foo_cv() const volatile { return 4; }
183 };
90922b2d
PC
184
185 // For use in 8_c_compatibility.
186 template<typename R, typename T>
dcd400b5 187 typename __gnu_cxx::__enable_if<std::__are_same<R, T>::__value,
105c6331 188 bool>::__type
90922b2d
PC
189 check_ret_type(T)
190 { return true; }
191
59cffcf6 192} // namespace __gnu_test
493bc460
PC
193
194#endif // _GLIBCXX_TESTSUITE_TR1_H