]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / make_signed / requirements / typedefs-1.cc
CommitLineData
52066eae 1// { dg-do compile { target c++11 } }
7b50cdef
BK
2
3// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com>
4//
7adcbafe 5// Copyright (C) 2007-2022 Free Software Foundation, Inc.
7b50cdef
BK
6//
7// This file is part of the GNU ISO C++ Library. This library is free
8// software; you can redistribute it and/or modify it under the
9// terms of the GNU General Public License as published by the
748086b7 10// Free Software Foundation; either version 3, or (at your option)
7b50cdef
BK
11// any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License along
748086b7
JJ
19// with this library; see the file COPYING3. If not see
20// <http://www.gnu.org/licenses/>.
7b50cdef
BK
21
22#include <type_traits>
7b50cdef
BK
23
24enum test_enum { first_selection };
25
26void test01()
27{
7b50cdef
BK
28 using std::make_signed;
29 using std::is_same;
ce72d1aa 30 using std::is_signed;
bb85ec6e 31 using std::is_volatile;
7b50cdef
BK
32
33 // Positive tests.
34 typedef make_signed<const int>::type test2_type;
4457e88c
JW
35 static_assert( is_same<test2_type, const int>::value,
36 "make_signed<const int>" );
7b50cdef
BK
37
38 typedef make_signed<const unsigned int>::type test21c_type;
4457e88c
JW
39 static_assert( is_same<test21c_type, const signed int>::value,
40 "make_signed<const unsigned int>" );
7b50cdef
BK
41
42 typedef make_signed<volatile unsigned int>::type test21v_type;
4457e88c
JW
43 static_assert( is_same<test21v_type, volatile signed int>::value,
44 "make_signed<volatile unsigned int>" );
7b50cdef
BK
45
46 typedef make_signed<const volatile unsigned int>::type test21cv_type;
4457e88c
JW
47 static_assert( is_same<test21cv_type, const volatile signed int>::value,
48 "make_signed<const volatile unsigned int>" );
7b50cdef
BK
49
50 typedef make_signed<const char>::type test22_type;
4457e88c
JW
51 static_assert( is_same<test22_type, const signed char>::value,
52 "make_signed<const char>" );
7b50cdef
BK
53
54 typedef make_signed<volatile wchar_t>::type test23_type;
bb85ec6e
JW
55 static_assert( is_signed<test23_type>::value
56 && is_volatile<test23_type>::value
57 && sizeof(test23_type) == sizeof(volatile wchar_t),
4457e88c 58 "make_signed<volatile wchar_t>" );
7b50cdef 59
ce72d1aa 60 // Chapter 48, chapter 20. Smallest rank such that new signed type same size.
6d585f01 61 typedef make_signed<test_enum>::type test24_type;
4457e88c
JW
62 static_assert( is_signed<test24_type>::value,
63 "make_signed<test_enum> makes signed type" );
64 static_assert( sizeof(test24_type) == sizeof(test_enum),
65 "make_signed<test_enum> makes type of same size" );
6d585f01 66
2f297149 67#ifndef __STRICT_ANSI__
6d585f01 68 // GNU Extensions.
29a9de9b 69#ifdef __SIZEOF_INT128__
fd1e62c2 70 typedef make_signed<unsigned __int128>::type test25_type;
4457e88c
JW
71 static_assert( is_same<test25_type, __int128>::value,
72 "make_signed<unsigned __int128>" );
6d585f01 73
fd1e62c2 74 typedef make_signed<__int128>::type test26_type;
4457e88c
JW
75 static_assert( is_same<test26_type, __int128>::value,
76 "make_signed<__int128>" );
6d585f01 77#endif
2f297149 78#endif
7b50cdef 79}