aboutsummaryrefslogtreecommitdiff
path: root/test/Headers/x86_64-apple-macosx-types.cpp
blob: 7cbff6e033b4c8f845e2d4de9e50287b9053c022 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -std=c++11 -verify %s
// expected-no-diagnostics

struct true_type {
  static constexpr const bool value = true;
};

struct false_type {
  static constexpr const bool value = false;
};

template <class _Tp, class _Up> struct is_same           : public false_type {};
template <class _Tp>            struct is_same<_Tp, _Tp> : public true_type {};

// Check that our 'is_same' works.
static_assert(is_same<char, char>::value, "is_same is broken");
static_assert(!is_same<char, char *>::value, "is_same is broken");

template <class _Tp, unsigned _AlignOf, unsigned _SizeOf>
struct check_type {
  static constexpr const bool value =
    (alignof(_Tp) == _AlignOf) && (sizeof(_Tp) == _SizeOf);
};

//===----------------------------------------------------------------------===//
// Fundamental types
//===----------------------------------------------------------------------===//

static_assert(check_type<bool, 1, 1>::value, "bool is wrong");

static_assert(check_type<char, 1, 1>::value, "char is wrong");
static_assert(check_type<signed char, 1, 1>::value, "signed char is wrong");
static_assert(check_type<unsigned char, 1, 1>::value, "unsigned char is wrong");

static_assert(check_type<char16_t, 2, 2>::value, "char16_t is wrong");
static_assert(check_type<char32_t, 4, 4>::value, "char32_t is wrong");
static_assert(check_type<wchar_t, 4, 4>::value, "wchar_t is wrong");

static_assert(check_type<short, 2, 2>::value, "short is wrong");
static_assert(check_type<unsigned short, 2, 2>::value, "unsigned short is wrong");

static_assert(check_type<int, 4, 4>::value, "int is wrong");
static_assert(check_type<unsigned int, 4, 4>::value, "unsigned int is wrong");

static_assert(check_type<long, 8, 8>::value, "long is wrong");
static_assert(check_type<unsigned long, 8, 8>::value, "unsigned long is wrong");

static_assert(check_type<long long, 8, 8>::value, "long long is wrong");
static_assert(check_type<unsigned long long, 8, 8>::value, "unsigned long long is wrong");

static_assert(check_type<float, 4, 4>::value, "float is wrong");
static_assert(check_type<double, 8, 8>::value, "double is wrong");
static_assert(check_type<long double, 16, 16>::value, "long double is wrong");

static_assert(check_type<void *, 8, 8>::value, "'void *' is wrong");
static_assert(check_type<int (*)(int), 8, 8>::value, "function pointer is wrong");

//===----------------------------------------------------------------------===//
// stdarg.h
//===----------------------------------------------------------------------===//

#include <stdarg.h>

static_assert(check_type<va_list, 8, 24>::value, "va_list is wrong");

//===----------------------------------------------------------------------===//
// stddef.h
//===----------------------------------------------------------------------===//

#define __STDC_WANT_LIB_EXT1__ 1
#include <stddef.h>

static_assert(is_same<long int, ::ptrdiff_t>::value, "::ptrdiff_t is wrong");
static_assert(is_same<decltype(sizeof(char)), ::size_t>::value, "::size_t is wrong");
static_assert(is_same<long unsigned int, ::size_t>::value, "::size_t is wrong");
static_assert(is_same<long unsigned int, ::rsize_t>::value, "::rsize_t is wrong");
static_assert(is_same<long double, ::max_align_t>::value, "::max_align_t is wrong");

#define __need_wint_t
#include <stddef.h>

static_assert(is_same<int, ::wint_t>::value, "::wint_t is wrong");