@@ -109,6 +109,17 @@ void c_typecheck_baset::typecheck_type(typet &type)
109
109
typecheck_type (type.subtype ());
110
110
111
111
typet underlying_type=type.subtype ();
112
+
113
+ // gcc allows this, but clang doesn't; it's a compiler hint only,
114
+ // but we'll try to interpret it the GCC way
115
+ if (underlying_type.id ()==ID_c_enum_tag)
116
+ {
117
+ underlying_type=
118
+ follow_tag (to_c_enum_tag_type (underlying_type)).subtype ();
119
+
120
+ assert (underlying_type.id ()==ID_signedbv ||
121
+ underlying_type.id ()==ID_unsignedbv);
122
+ }
112
123
113
124
if (underlying_type.id ()==ID_signedbv ||
114
125
underlying_type.id ()==ID_unsignedbv)
@@ -151,18 +162,20 @@ void c_typecheck_baset::typecheck_type(typet &type)
151
162
// save the location
152
163
result.add_source_location ()=type.source_location ();
153
164
165
+ if (type.subtype ().id ()==ID_c_enum_tag)
166
+ {
167
+ const irep_idt &tag_name=
168
+ to_c_enum_tag_type (type.subtype ()).get_identifier ();
169
+
170
+ symbol_tablet::symbolst::iterator entry=
171
+ symbol_table.symbols .find (tag_name);
172
+ assert (entry!=symbol_table.symbols .end ());
173
+
174
+ entry->second .type .subtype ()=result;
175
+ }
176
+
154
177
type=result;
155
178
}
156
- else if (underlying_type.id ()==ID_c_enum_tag ||
157
- underlying_type.id ()==ID_complex)
158
- {
159
- // gcc allows this, but clang doesn't.
160
- // We ignore for now.
161
- if (underlying_type.id ()==ID_c_enum_tag)
162
- type=follow_tag (to_c_enum_tag_type (underlying_type)).subtype ();
163
- else
164
- type=type.subtype ();
165
- }
166
179
else if (underlying_type.id ()==ID_floatbv)
167
180
{
168
181
typet result;
@@ -189,6 +202,25 @@ void c_typecheck_baset::typecheck_type(typet &type)
189
202
190
203
type=result;
191
204
}
205
+ else if (underlying_type.id ()==ID_complex)
206
+ {
207
+ // gcc allows this, but clang doesn't -- see enums above
208
+ typet result;
209
+
210
+ if (mode==" __SC__" ) // 32 bits
211
+ result=float_type ();
212
+ else if (mode==" __DC__" ) // 64 bits
213
+ result=double_type ();
214
+ else if (mode==" __TC__" ) // 128 bits
215
+ result=gcc_float128_type ();
216
+ else // give up, just use subtype
217
+ result=type.subtype ();
218
+
219
+ // save the location
220
+ result.add_source_location ()=type.source_location ();
221
+
222
+ type=complex_typet (result);
223
+ }
192
224
else
193
225
{
194
226
err_location (type);
0 commit comments