| 1 |
/* { dg-options "-DCE_EXTRACT_FUNCTIONS=f -DCE_NO_EXTERNALIZATION" }*/ |
| 2 |
|
| 3 |
namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) |
| 4 |
{ |
| 5 |
template<typename _CharT> |
| 6 |
struct _Char_types |
| 7 |
{ |
| 8 |
typedef unsigned long int_type; |
| 9 |
#if 0 |
| 10 |
typedef std::streampos pos_type; |
| 11 |
typedef std::streamoff off_type; |
| 12 |
typedef std::mbstate_t state_type; |
| 13 |
#endif |
| 14 |
}; |
| 15 |
template<typename _CharT> |
| 16 |
struct char_traits |
| 17 |
{ |
| 18 |
typedef _CharT char_type; |
| 19 |
typedef typename _Char_types<_CharT>::int_type int_type; |
| 20 |
#if 0 |
| 21 |
typedef typename _Char_types<_CharT>::pos_type pos_type; |
| 22 |
typedef typename _Char_types<_CharT>::off_type off_type; |
| 23 |
typedef typename _Char_types<_CharT>::state_type state_type; |
| 24 |
#endif |
| 25 |
static constexpr void |
| 26 |
assign(char_type& __c1, const char_type& __c2) |
| 27 |
{ |
| 28 |
__c1 = __c2; |
| 29 |
} |
| 30 |
|
| 31 |
static constexpr bool |
| 32 |
eq(const char_type& __c1, const char_type& __c2) |
| 33 |
{ return __c1 == __c2; } |
| 34 |
|
| 35 |
static constexpr bool |
| 36 |
lt(const char_type& __c1, const char_type& __c2) |
| 37 |
{ return __c1 < __c2; } |
| 38 |
#if 0 |
| 39 |
static constexpr int |
| 40 |
compare(const char_type* __s1, const char_type* __s2, std::size_t __n); |
| 41 |
|
| 42 |
static constexpr std::size_t |
| 43 |
length(const char_type* __s); |
| 44 |
|
| 45 |
static constexpr const char_type* |
| 46 |
find(const char_type* __s, std::size_t __n, const char_type& __a); |
| 47 |
|
| 48 |
static char_type* |
| 49 |
move(char_type* __s1, const char_type* __s2, std::size_t __n); |
| 50 |
|
| 51 |
static char_type* |
| 52 |
copy(char_type* __s1, const char_type* __s2, std::size_t __n); |
| 53 |
|
| 54 |
static char_type* |
| 55 |
assign(char_type* __s, std::size_t __n, char_type __a); |
| 56 |
#endif |
| 57 |
static constexpr char_type |
| 58 |
to_char_type(const int_type& __c) |
| 59 |
{ return static_cast<char_type>(__c); } |
| 60 |
|
| 61 |
static constexpr int_type |
| 62 |
to_int_type(const char_type& __c) |
| 63 |
{ return static_cast<int_type>(__c); } |
| 64 |
|
| 65 |
static constexpr bool |
| 66 |
eq_int_type(const int_type& __c1, const int_type& __c2) |
| 67 |
{ return __c1 == __c2; } |
| 68 |
|
| 69 |
static constexpr int_type |
| 70 |
eof() |
| 71 |
{ return static_cast<int_type>(-1); } |
| 72 |
|
| 73 |
static constexpr int_type |
| 74 |
not_eof(const int_type& __c) |
| 75 |
{ return !eq_int_type(__c, eof()) ? __c : to_int_type(char_type()); } |
| 76 |
|
| 77 |
}; |
| 78 |
#if 0 |
| 79 |
template<typename _CharT> |
| 80 |
constexpr int |
| 81 |
char_traits<_CharT>:: |
| 82 |
compare(const char_type* __s1, const char_type* __s2, std::size_t __n) |
| 83 |
{ |
| 84 |
for (std::size_t __i = 0; __i < __n; ++__i) |
| 85 |
if (lt(__s1[__i], __s2[__i])) |
| 86 |
return -1; |
| 87 |
else if (lt(__s2[__i], __s1[__i])) |
| 88 |
return 1; |
| 89 |
return 0; |
| 90 |
} |
| 91 |
|
| 92 |
template<typename _CharT> |
| 93 |
constexpr std::size_t |
| 94 |
char_traits<_CharT>:: |
| 95 |
length(const char_type* __p) |
| 96 |
{ |
| 97 |
std::size_t __i = 0; |
| 98 |
while (!eq(__p[__i], char_type())) |
| 99 |
++__i; |
| 100 |
return __i; |
| 101 |
} |
| 102 |
|
| 103 |
template<typename _CharT> |
| 104 |
constexpr const typename char_traits<_CharT>::char_type* |
| 105 |
char_traits<_CharT>:: |
| 106 |
find(const char_type* __s, std::size_t __n, const char_type& __a) |
| 107 |
{ |
| 108 |
for (std::size_t __i = 0; __i < __n; ++__i) |
| 109 |
if (eq(__s[__i], __a)) |
| 110 |
return __s + __i; |
| 111 |
return 0; |
| 112 |
} |
| 113 |
|
| 114 |
template<typename _CharT> |
| 115 |
typename char_traits<_CharT>::char_type* |
| 116 |
char_traits<_CharT>:: |
| 117 |
move(char_type* __s1, const char_type* __s2, std::size_t __n) |
| 118 |
{ |
| 119 |
if (__n == 0) |
| 120 |
return __s1; |
| 121 |
__builtin_memmove(__s1, __s2, __n * sizeof(char_type)); |
| 122 |
return __s1; |
| 123 |
} |
| 124 |
|
| 125 |
template<typename _CharT> |
| 126 |
typename char_traits<_CharT>::char_type* |
| 127 |
char_traits<_CharT>:: |
| 128 |
copy(char_type* __s1, const char_type* __s2, std::size_t __n) |
| 129 |
{ |
| 130 |
if (__n == 0) |
| 131 |
return __s1; |
| 132 |
__builtin_memcpy(__s1, __s2, __n * sizeof(char_type)); |
| 133 |
return __s1; |
| 134 |
} |
| 135 |
|
| 136 |
template<typename _CharT> |
| 137 |
typename char_traits<_CharT>::char_type* |
| 138 |
char_traits<_CharT>:: |
| 139 |
assign(char_type* __s, std::size_t __n, char_type __a) |
| 140 |
{ |
| 141 |
if constexpr (sizeof(_CharT) == 1 && __is_trivial(_CharT)) |
| 142 |
{ |
| 143 |
if (__n) |
| 144 |
{ |
| 145 |
unsigned char __c; |
| 146 |
__builtin_memcpy(&__c, __builtin_addressof(__a), 1); |
| 147 |
__builtin_memset(__s, __c, __n); |
| 148 |
} |
| 149 |
} |
| 150 |
else |
| 151 |
{ |
| 152 |
for (std::size_t __i = 0; __i < __n; ++__i) |
| 153 |
__s[__i] = __a; |
| 154 |
} |
| 155 |
return __s; |
| 156 |
} |
| 157 |
#endif |
| 158 |
} |
| 159 |
|
| 160 |
template<typename _CharT> |
| 161 |
struct char_traits : public __gnu_cxx::char_traits<_CharT> |
| 162 |
{ }; |
| 163 |
|
| 164 |
void* f(void) |
| 165 |
{ |
| 166 |
static struct char_traits<char> x; |
| 167 |
return (void *) &x; |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
/* { dg-final { scan-tree-dump "char_traits : public __gnu_cxx::char_traits<_CharT>" } } */ |
| 172 |
/* { dg-final { scan-tree-dump "namespace __gnu_cxx" } } */ |
| 173 |
/* { dg-final { scan-tree-dump "return \(void \*\) &x;" } } */ |