2 * This file is part of cparser.
3 * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 #include "lang_features.h"
25 /** The error type. */
26 type_t *type_error_type;
30 type_t *type_const_char;
34 type_t *type_long_double;
35 type_t *type_long_long;
38 type_t *type_unsigned_short;
39 type_t *type_signed_char;
40 type_t *type_unsigned_char;
41 type_t *type_unsigned_int;
42 type_t *type_unsigned_long_long;
43 type_t *type_unsigned_long;
46 type_t *type_char_ptr;
47 type_t *type_const_char_ptr;
49 type_t *type_long_long_ptr;
50 type_t *type_long_ptr;
51 type_t *type_unsigned_long_ptr;
52 type_t *type_short_ptr;
53 type_t *type_signed_char_ptr;
54 type_t *type_void_ptr;
56 type_t *type_char_ptr_ptr;
58 type_t *type_intmax_t;
59 type_t *type_ptrdiff_t;
62 type_t *type_uintmax_t;
63 type_t *type_uptrdiff_t;
65 type_t *type_const_wchar_t;
68 type_t *type_intmax_t_ptr;
69 type_t *type_ptrdiff_t_ptr;
70 type_t *type_ssize_t_ptr;
71 type_t *type_wchar_t_ptr;
72 type_t *type_const_wchar_t_ptr;
77 atomic_type_kind_t int8_type_kind = ATOMIC_TYPE_INVALID;
78 atomic_type_kind_t int16_type_kind = ATOMIC_TYPE_INVALID;
79 atomic_type_kind_t int32_type_kind = ATOMIC_TYPE_INVALID;
80 atomic_type_kind_t int64_type_kind = ATOMIC_TYPE_INVALID;
81 atomic_type_kind_t int128_type_kind = ATOMIC_TYPE_INVALID;
82 atomic_type_kind_t unsigned_int8_type_kind = ATOMIC_TYPE_INVALID;
83 atomic_type_kind_t unsigned_int16_type_kind = ATOMIC_TYPE_INVALID;
84 atomic_type_kind_t unsigned_int32_type_kind = ATOMIC_TYPE_INVALID;
85 atomic_type_kind_t unsigned_int64_type_kind = ATOMIC_TYPE_INVALID;
86 atomic_type_kind_t unsigned_int128_type_kind = ATOMIC_TYPE_INVALID;
92 type_t *type_unsigned_int8;
93 type_t *type_unsigned_int16;
94 type_t *type_unsigned_int32;
95 type_t *type_unsigned_int64;
96 type_t *type_int64_ptr;
99 void init_basic_types(void)
101 static const type_base_t error = { TYPE_ERROR, TYPE_QUALIFIER_NONE, NULL };
103 type_error_type = (type_t*)&error;
104 type_bool = make_atomic_type(ATOMIC_TYPE_BOOL, TYPE_QUALIFIER_NONE);
105 type_signed_char = make_atomic_type(ATOMIC_TYPE_SCHAR, TYPE_QUALIFIER_NONE);
106 type_unsigned_char = make_atomic_type(ATOMIC_TYPE_UCHAR, TYPE_QUALIFIER_NONE);
107 type_short = make_atomic_type(ATOMIC_TYPE_SHORT, TYPE_QUALIFIER_NONE);
108 type_unsigned_short = make_atomic_type(ATOMIC_TYPE_USHORT, TYPE_QUALIFIER_NONE);
109 type_int = make_atomic_type(ATOMIC_TYPE_INT, TYPE_QUALIFIER_NONE);
110 type_unsigned_int = make_atomic_type(ATOMIC_TYPE_UINT, TYPE_QUALIFIER_NONE);
111 type_long = make_atomic_type(ATOMIC_TYPE_LONG, TYPE_QUALIFIER_NONE);
112 type_unsigned_long = make_atomic_type(ATOMIC_TYPE_ULONG, TYPE_QUALIFIER_NONE);
113 type_long_long = make_atomic_type(ATOMIC_TYPE_LONGLONG, TYPE_QUALIFIER_NONE);
114 type_unsigned_long_long = make_atomic_type(ATOMIC_TYPE_ULONGLONG, TYPE_QUALIFIER_NONE);
115 type_long_double = make_atomic_type(ATOMIC_TYPE_LONG_DOUBLE, TYPE_QUALIFIER_NONE);
116 type_double = make_atomic_type(ATOMIC_TYPE_DOUBLE, TYPE_QUALIFIER_NONE);
117 type_float = make_atomic_type(ATOMIC_TYPE_FLOAT, TYPE_QUALIFIER_NONE);
118 type_char = make_atomic_type(ATOMIC_TYPE_CHAR, TYPE_QUALIFIER_NONE);
119 type_void = make_atomic_type(ATOMIC_TYPE_VOID, TYPE_QUALIFIER_NONE);
121 /* microsoft types */
123 int8_type_kind = find_signed_int_atomic_type_kind_for_size(1);
124 type_int8 = make_atomic_type(int8_type_kind, TYPE_QUALIFIER_NONE);
125 int16_type_kind = find_signed_int_atomic_type_kind_for_size(2);
126 type_int16 = make_atomic_type(int16_type_kind, TYPE_QUALIFIER_NONE);
127 int32_type_kind = find_signed_int_atomic_type_kind_for_size(4);
128 type_int32 = make_atomic_type(int32_type_kind, TYPE_QUALIFIER_NONE);
129 int64_type_kind = find_signed_int_atomic_type_kind_for_size(8);
130 type_int64 = make_atomic_type(int64_type_kind, TYPE_QUALIFIER_NONE);
131 unsigned_int8_type_kind = find_unsigned_int_atomic_type_kind_for_size(1);
132 type_unsigned_int8 = make_atomic_type(unsigned_int8_type_kind, TYPE_QUALIFIER_NONE);
133 unsigned_int16_type_kind = find_unsigned_int_atomic_type_kind_for_size(2);
134 type_unsigned_int16 = make_atomic_type(unsigned_int16_type_kind, TYPE_QUALIFIER_NONE);
135 unsigned_int32_type_kind = find_unsigned_int_atomic_type_kind_for_size(4);
136 type_unsigned_int32 = make_atomic_type(unsigned_int32_type_kind, TYPE_QUALIFIER_NONE);
137 unsigned_int64_type_kind = find_unsigned_int_atomic_type_kind_for_size(8);
138 type_unsigned_int64 = make_atomic_type(unsigned_int64_type_kind, TYPE_QUALIFIER_NONE);
141 type_int64_ptr = make_pointer_type(type_int64, TYPE_QUALIFIER_NONE);
145 type_void_ptr = make_pointer_type(type_void, TYPE_QUALIFIER_NONE);
146 type_char_ptr = make_pointer_type(type_char, TYPE_QUALIFIER_NONE);
147 type_signed_char_ptr = make_pointer_type(type_signed_char, TYPE_QUALIFIER_NONE);
148 type_short_ptr = make_pointer_type(type_short, TYPE_QUALIFIER_NONE);
149 type_int_ptr = make_pointer_type(type_int, TYPE_QUALIFIER_NONE);
150 type_long_ptr = make_pointer_type(type_long, TYPE_QUALIFIER_NONE);
151 type_unsigned_long_ptr = make_pointer_type(type_unsigned_long, TYPE_QUALIFIER_NONE);
152 type_long_long_ptr = make_pointer_type(type_long_long, TYPE_QUALIFIER_NONE);
154 type_char_ptr_ptr = make_pointer_type(type_char_ptr, TYPE_QUALIFIER_NONE);
156 /* const character types */
157 type_const_char = make_atomic_type(ATOMIC_TYPE_CHAR, TYPE_QUALIFIER_CONST);
158 type_const_char_ptr = make_pointer_type(type_const_char, TYPE_QUALIFIER_NONE);
161 type_intmax_t = type_long_long;
162 type_size_t = type_unsigned_long;
163 type_ssize_t = type_long;
164 type_ptrdiff_t = type_long;
165 type_uintmax_t = type_unsigned_long_long;
166 type_uptrdiff_t = type_unsigned_long;
167 type_wchar_t = make_atomic_type(wchar_atomic_kind, TYPE_QUALIFIER_NONE);
168 type_wint_t = type_int;
170 = make_atomic_type(wchar_atomic_kind, TYPE_QUALIFIER_CONST);
172 type_intmax_t_ptr = make_pointer_type(type_intmax_t, TYPE_QUALIFIER_NONE);
173 type_ptrdiff_t_ptr = make_pointer_type(type_ptrdiff_t, TYPE_QUALIFIER_NONE);
174 type_ssize_t_ptr = make_pointer_type(type_ssize_t, TYPE_QUALIFIER_NONE);
175 type_wchar_t_ptr = make_pointer_type(type_wchar_t, TYPE_QUALIFIER_NONE);
176 type_const_wchar_t_ptr
177 = make_pointer_type(type_const_wchar_t, TYPE_QUALIFIER_NONE);