]>
Commit | Line | Data |
---|---|---|
52066eae JW |
1 | // { dg-options "-funsigned-char -fshort-enums" } |
2 | // { dg-do compile { target c++11 } } | |
7b50cdef BK |
3 | |
4 | // 2007-05-03 Benjamin Kosnik <bkoz@redhat.com> | |
5 | // | |
83ffe9cd | 6 | // Copyright (C) 2007-2023 Free Software Foundation, Inc. |
7b50cdef BK |
7 | // |
8 | // This file is part of the GNU ISO C++ Library. This library is free | |
9 | // software; you can redistribute it and/or modify it under the | |
10 | // terms of the GNU General Public License as published by the | |
748086b7 | 11 | // Free Software Foundation; either version 3, or (at your option) |
7b50cdef BK |
12 | // any later version. |
13 | // | |
14 | // This library is distributed in the hope that it will be useful, | |
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | // GNU General Public License for more details. | |
18 | // | |
19 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
20 | // with this library; see the file COPYING3. If not see |
21 | // <http://www.gnu.org/licenses/>. | |
7b50cdef BK |
22 | |
23 | #include <type_traits> | |
7b50cdef | 24 | |
a0230468 MM |
25 | // Ensure that this enum has "short" as its underlying type. |
26 | enum test_enum { first_selection = ((unsigned char)-1) + 1 }; | |
7b50cdef BK |
27 | |
28 | void test01() | |
29 | { | |
7b50cdef BK |
30 | using std::make_signed; |
31 | using std::is_same; | |
bb85ec6e JW |
32 | using std::is_signed; |
33 | using std::is_volatile; | |
7b50cdef BK |
34 | |
35 | // Positive tests. | |
36 | typedef make_signed<const int>::type test2_type; | |
44916fe1 | 37 | static_assert(is_same<test2_type, const int>::value, ""); |
7b50cdef BK |
38 | |
39 | typedef make_signed<const unsigned int>::type test21c_type; | |
44916fe1 | 40 | static_assert(is_same<test21c_type, const signed int>::value, ""); |
7b50cdef BK |
41 | |
42 | typedef make_signed<volatile unsigned int>::type test21v_type; | |
44916fe1 | 43 | static_assert(is_same<test21v_type, volatile signed int>::value, ""); |
7b50cdef BK |
44 | |
45 | typedef make_signed<const volatile unsigned int>::type test21cv_type; | |
44916fe1 PC |
46 | static_assert(is_same<test21cv_type, |
47 | const volatile signed int>::value, ""); | |
7b50cdef BK |
48 | |
49 | typedef make_signed<const char>::type test22_type; | |
44916fe1 | 50 | static_assert(is_same<test22_type, const signed char>::value, ""); |
7b50cdef BK |
51 | |
52 | typedef make_signed<volatile wchar_t>::type test23_type; | |
bb85ec6e JW |
53 | static_assert(is_signed<test23_type>::value |
54 | && is_volatile<test23_type>::value | |
55 | && sizeof(test23_type) == sizeof(volatile wchar_t), ""); | |
7b50cdef | 56 | |
6d585f01 | 57 | typedef make_signed<test_enum>::type test24_type; |
44916fe1 | 58 | static_assert(is_same<test24_type, short>::value, ""); |
6d585f01 | 59 | |
2f297149 | 60 | #ifndef __STRICT_ANSI__ |
6d585f01 | 61 | // GNU Extensions. |
29a9de9b | 62 | #ifdef __SIZEOF_INT128__ |
fd1e62c2 | 63 | typedef make_signed<unsigned __int128>::type test25_type; |
44916fe1 | 64 | static_assert(is_same<test25_type, __int128>::value, ""); |
6d585f01 | 65 | |
fd1e62c2 | 66 | typedef make_signed<__int128>::type test26_type; |
44916fe1 | 67 | static_assert(is_same<test26_type, __int128>::value, ""); |
6d585f01 | 68 | #endif |
2f297149 | 69 | #endif |
7b50cdef | 70 | } |