2 * Symbol lookup and handling.
4 * Copyright (C) 2003 Transmeta Corp.
5 * 2003-2004 Linus Torvalds
7 * Licensed under the Open Software License version 1.1
19 #include "expression.h"
24 * Secondary symbol list for stuff that needs to be output because it
27 struct symbol_list
*translation_unit_used_list
= NULL
;
30 * If the symbol is an inline symbol, add it to the list of symbols to parse
32 void access_symbol(struct symbol
*sym
)
34 if (sym
->ctype
.modifiers
& MOD_INLINE
) {
35 if (!(sym
->ctype
.modifiers
& MOD_ACCESSED
)) {
36 add_symbol(&translation_unit_used_list
, sym
);
37 sym
->ctype
.modifiers
|= MOD_ACCESSED
;
42 struct symbol
*lookup_symbol(struct ident
*ident
, enum namespace ns
)
46 for (sym
= ident
->symbols
; sym
; sym
= sym
->next_id
) {
47 if (sym
->namespace & ns
) {
55 struct symbol
*alloc_symbol(struct position pos
, int type
)
57 struct symbol
*sym
= __alloc_symbol(0);
63 struct struct_union_info
{
64 unsigned long max_align
;
65 unsigned long bit_size
;
70 * Unions are fairly easy to lay out ;)
72 static void lay_out_union(struct symbol
*sym
, struct struct_union_info
*info
)
74 examine_symbol_type(sym
);
76 // Unnamed bitfields do not affect alignment.
77 if (sym
->ident
|| !is_bitfield_type(sym
)) {
78 if (sym
->ctype
.alignment
> info
->max_align
)
79 info
->max_align
= sym
->ctype
.alignment
;
82 if (sym
->bit_size
> info
->bit_size
)
83 info
->bit_size
= sym
->bit_size
;
88 static int bitfield_base_size(struct symbol
*sym
)
90 if (sym
->type
== SYM_NODE
)
91 sym
= sym
->ctype
.base_type
;
92 if (sym
->type
== SYM_BITFIELD
)
93 sym
= sym
->ctype
.base_type
;
98 * Structures are a bit more interesting to lay out
100 static void lay_out_struct(struct symbol
*sym
, struct struct_union_info
*info
)
102 unsigned long bit_size
, align_bit_mask
;
105 examine_symbol_type(sym
);
107 // Unnamed bitfields do not affect alignment.
108 if (sym
->ident
|| !is_bitfield_type(sym
)) {
109 if (sym
->ctype
.alignment
> info
->max_align
)
110 info
->max_align
= sym
->ctype
.alignment
;
113 bit_size
= info
->bit_size
;
114 base_size
= sym
->bit_size
;
117 * Unsized arrays cause us to not align the resulting
121 info
->align_size
= 0;
125 align_bit_mask
= (sym
->ctype
.alignment
<< 3) - 1;
128 * Bitfields have some very special rules..
130 if (is_bitfield_type (sym
)) {
131 unsigned long bit_offset
= bit_size
& align_bit_mask
;
132 int room
= bitfield_base_size(sym
) - bit_offset
;
133 // Zero-width fields just fill up the unit.
134 int width
= base_size
? : (bit_offset
? room
: 0);
137 bit_size
= (bit_size
+ align_bit_mask
) & ~align_bit_mask
;
140 sym
->offset
= (bit_size
- bit_offset
) >> 3;
141 sym
->bit_offset
= bit_offset
;
142 sym
->ctype
.base_type
->bit_offset
= bit_offset
;
143 info
->bit_size
= bit_size
+ width
;
144 // warning (sym->pos, "bitfield: offset=%d:%d size=:%d", sym->offset, sym->bit_offset, width);
150 * Otherwise, just align it right and add it up..
152 bit_size
= (bit_size
+ align_bit_mask
) & ~align_bit_mask
;
153 sym
->offset
= bit_size
>> 3;
155 info
->bit_size
= bit_size
+ base_size
;
156 // warning (sym->pos, "regular: offset=%d", sym->offset);
159 static struct symbol
* examine_struct_union_type(struct symbol
*sym
, int advance
)
161 struct struct_union_info info
= {
166 unsigned long bit_size
, bit_align
;
167 void (*fn
)(struct symbol
*, struct struct_union_info
*);
168 struct symbol
*member
;
170 fn
= advance
? lay_out_struct
: lay_out_union
;
171 FOR_EACH_PTR(sym
->symbol_list
, member
) {
173 } END_FOR_EACH_PTR(member
);
175 if (!sym
->ctype
.alignment
)
176 sym
->ctype
.alignment
= info
.max_align
;
177 bit_size
= info
.bit_size
;
178 if (info
.align_size
) {
179 bit_align
= (sym
->ctype
.alignment
<< 3)-1;
180 bit_size
= (bit_size
+ bit_align
) & ~bit_align
;
182 sym
->bit_size
= bit_size
;
186 static struct symbol
*examine_base_type(struct symbol
*sym
)
188 struct symbol
*base_type
;
190 /* Check the basetype */
191 base_type
= sym
->ctype
.base_type
;
193 base_type
= examine_symbol_type(base_type
);
195 /* "typeof" can cause this */
196 if (base_type
&& base_type
->type
== SYM_NODE
)
197 merge_type(sym
, base_type
);
202 static struct symbol
* examine_array_type(struct symbol
*sym
)
204 struct symbol
*base_type
= examine_base_type(sym
);
205 unsigned long bit_size
, alignment
;
209 bit_size
= base_type
->bit_size
* get_expression_value(sym
->array_size
);
210 if (!sym
->array_size
|| sym
->array_size
->type
!= EXPR_VALUE
)
212 alignment
= base_type
->ctype
.alignment
;
213 if (!sym
->ctype
.alignment
)
214 sym
->ctype
.alignment
= alignment
;
215 sym
->bit_size
= bit_size
;
219 static struct symbol
*examine_bitfield_type(struct symbol
*sym
)
221 struct symbol
*base_type
= examine_base_type(sym
);
222 unsigned long bit_size
, alignment
, modifiers
;
226 bit_size
= base_type
->bit_size
;
227 if (sym
->bit_size
> bit_size
)
228 warning(sym
->pos
, "impossible field-width, %d, for this type", sym
->bit_size
);
230 alignment
= base_type
->ctype
.alignment
;
231 if (!sym
->ctype
.alignment
)
232 sym
->ctype
.alignment
= alignment
;
233 modifiers
= base_type
->ctype
.modifiers
;
235 /* Bitfields are unsigned, unless the base type was explicitly signed */
236 if (!(modifiers
& MOD_EXPLICITLY_SIGNED
))
237 modifiers
= (modifiers
& ~MOD_SIGNED
) | MOD_UNSIGNED
;
238 sym
->ctype
.modifiers
|= modifiers
& MOD_SIGNEDNESS
;
243 * "typeof" will have to merge the types together
245 void merge_type(struct symbol
*sym
, struct symbol
*base_type
)
247 sym
->ctype
.as
|= base_type
->ctype
.as
;
248 sym
->ctype
.modifiers
|= (base_type
->ctype
.modifiers
& ~MOD_STORAGE
);
249 sym
->ctype
.in_context
+= base_type
->ctype
.in_context
;
250 sym
->ctype
.out_context
+= base_type
->ctype
.out_context
;
251 sym
->ctype
.base_type
= base_type
->ctype
.base_type
;
254 static int count_array_initializer(struct expression
*expr
)
258 switch (expr
->type
) {
260 nr
= expr
->string
->length
;
262 case EXPR_INITIALIZER
: {
263 struct expression
*entry
;
264 FOR_EACH_PTR(expr
->expr_list
, entry
) {
265 switch (entry
->type
) {
267 nr
+= entry
->string
->length
;
270 if (entry
->idx_to
> nr
)
276 } END_FOR_EACH_PTR(entry
);
285 static struct symbol
* examine_node_type(struct symbol
*sym
)
287 struct symbol
*base_type
= examine_base_type(sym
);
289 unsigned long alignment
, modifiers
;
291 /* SYM_NODE - figure out what the type of the node was.. */
292 modifiers
= sym
->ctype
.modifiers
;
299 bit_size
= base_type
->bit_size
;
300 alignment
= base_type
->ctype
.alignment
;
302 /* Pick up signedness information into the node */
303 sym
->ctype
.modifiers
|= (MOD_SIGNEDNESS
& base_type
->ctype
.modifiers
);
305 if (!sym
->ctype
.alignment
)
306 sym
->ctype
.alignment
= alignment
;
308 /* Unsized array? The size might come from the initializer.. */
309 if (bit_size
< 0 && base_type
->type
== SYM_ARRAY
&& sym
->initializer
) {
310 int count
= count_array_initializer(sym
->initializer
);
311 struct symbol
*node_type
= base_type
->ctype
.base_type
;
313 if (node_type
&& node_type
->bit_size
>= 0)
314 bit_size
= node_type
->bit_size
* count
;
317 sym
->bit_size
= bit_size
;
321 static struct symbol
*examine_enum_type(struct symbol
*sym
)
323 struct symbol
*base_type
= examine_base_type(sym
);
325 if (!base_type
|| base_type
== &bad_ctype
) {
326 warning(sym
->pos
, "invalid enum type");
330 sym
->ctype
.modifiers
|= (base_type
->ctype
.modifiers
& MOD_SIGNEDNESS
);
331 sym
->bit_size
= bits_in_enum
;
332 if (base_type
->bit_size
> sym
->bit_size
)
333 sym
->bit_size
= base_type
->bit_size
;
334 sym
->ctype
.alignment
= enum_alignment
;
335 if (base_type
->ctype
.alignment
> sym
->ctype
.alignment
)
336 sym
->ctype
.alignment
= base_type
->ctype
.alignment
;
340 static struct symbol
*examine_pointer_type(struct symbol
*sym
)
343 * We need to set the pointer size first, and
344 * examine the thing we point to only afterwards.
345 * That's because this pointer type may end up
346 * being needed for the base type size evalutation.
349 sym
->bit_size
= bits_in_pointer
;
350 if (!sym
->ctype
.alignment
)
351 sym
->ctype
.alignment
= pointer_alignment
;
352 examine_base_type(sym
);
357 * Fill in type size and alignment information for
358 * regular SYM_TYPE things.
360 struct symbol
*examine_symbol_type(struct symbol
* sym
)
373 return examine_node_type(sym
);
375 return examine_array_type(sym
);
377 return examine_struct_union_type(sym
, 1);
379 return examine_struct_union_type(sym
, 0);
381 return examine_pointer_type(sym
);
383 return examine_enum_type(sym
);
385 return examine_bitfield_type(sym
);
387 /* Size and alignment had better already be set up */
390 struct symbol
*base
= evaluate_expression(sym
->initializer
);
392 if (is_bitfield_type(base
))
393 warning(base
->pos
, "typeof applied to bitfield type");
394 if (base
->type
== SYM_NODE
)
395 base
= base
->ctype
.base_type
;
396 sym
->type
= SYM_NODE
;
397 sym
->ctype
.base_type
= base
;
398 sym
->bit_size
= base
->bit_size
;
402 case SYM_PREPROCESSOR
:
403 warning(sym
->pos
, "ctype on preprocessor command? (%s)", show_ident(sym
->ident
));
405 case SYM_UNINITIALIZED
:
406 warning(sym
->pos
, "ctype on uninitialized symbol %p", sym
);
409 examine_base_type(sym
);
412 warning(sym
->pos
, "Examining unknown symbol type %d", sym
->type
);
418 void check_declaration(struct symbol
*sym
)
420 struct symbol
*next
= sym
;
422 while ((next
= next
->next_id
) != NULL
) {
423 if (next
->namespace != sym
->namespace)
425 if (sym
->scope
== next
->scope
) {
426 sym
->same_symbol
= next
;
429 if (sym
->ctype
.modifiers
& next
->ctype
.modifiers
& MOD_EXTERN
) {
430 sym
->same_symbol
= next
;
434 // This may make sense from a warning standpoint:
435 // consider top-level symbols to clash with everything
436 // (but the scoping rules will mean that we actually
437 // _use_ the innermost version)
438 if (toplevel(next
->scope
)) {
439 sym
->same_symbol
= next
;
446 void bind_symbol(struct symbol
*sym
, struct ident
*ident
, enum namespace ns
)
450 warning(sym
->pos
, "internal error: symbol type already bound");
453 if (ident
->reserved
&& (ns
& (NS_TYPEDEF
| NS_STRUCT
| NS_LABEL
| NS_SYMBOL
))) {
454 warning(sym
->pos
, "Trying to use reserved word '%s' as identifier", show_ident(ident
));
458 sym
->next_id
= ident
->symbols
;
459 ident
->symbols
= sym
;
460 sym
->id_list
= &ident
->symbols
;
461 if (sym
->ident
&& sym
->ident
!= ident
)
462 warning(sym
->pos
, "Symbol '%s' already bound", show_ident(sym
->ident
));
466 if (ns
== NS_SYMBOL
&& toplevel(scope
)) {
467 sym
->ctype
.modifiers
|= MOD_TOPLEVEL
| MOD_ADDRESSABLE
;
468 if (sym
->ctype
.modifiers
& MOD_STATIC
)
472 scope
= function_scope
;
473 bind_scope(sym
, scope
);
476 struct symbol
*create_symbol(int stream
, const char *name
, int type
, int namespace)
478 struct token
*token
= built_in_token(stream
, name
);
479 struct symbol
*sym
= alloc_symbol(token
->pos
, type
);
481 bind_symbol(sym
, token
->ident
, namespace);
485 static int evaluate_to_integer(struct expression
*expr
)
487 expr
->ctype
= &int_ctype
;
492 * __builtin_warning() has type "int" and always returns 1,
493 * so that you can use it in conditionals or whatever
495 static int expand_warning(struct expression
*expr
, int cost
)
497 struct expression
*arg
;
498 struct expression_list
*arglist
= expr
->args
;
500 FOR_EACH_PTR (arglist
, arg
) {
502 * Constant strings get printed out as a warning. By the
503 * time we get here, the EXPR_STRING has been fully
504 * evaluated, so by now it's an anonymous symbol with a
505 * string initializer.
507 * Just for the heck of it, allow any constant string
510 if (arg
->type
== EXPR_SYMBOL
) {
511 struct symbol
*sym
= arg
->symbol
;
512 if (sym
->initializer
&& sym
->initializer
->type
== EXPR_STRING
) {
513 struct string
*string
= sym
->initializer
->string
;
514 warning(expr
->pos
, "%*s", string
->length
-1, string
->data
);
520 * Any other argument is a conditional. If it's
521 * non-constant, or it is false, we exit and do
522 * not print any warning.
524 if (arg
->type
!= EXPR_VALUE
)
528 } END_FOR_EACH_PTR(arg
);
530 expr
->type
= EXPR_VALUE
;
536 * Type and storage class keywords need to have the symbols
537 * created for them, so that the parser can have enough semantic
538 * information to do parsing.
540 * "double" == "long float", "long double" == "long long float"
544 struct symbol
*base_type
;
545 unsigned int modifiers
;
546 struct symbol_op
*op
;
547 } symbol_init_table
[] = {
549 { "auto", NULL
, MOD_AUTO
},
550 { "register", NULL
, MOD_REGISTER
},
551 { "static", NULL
, MOD_STATIC
},
552 { "extern", NULL
, MOD_EXTERN
},
554 /* Type specifiers */
555 { "void", &void_ctype
, 0 },
556 { "char", NULL
, MOD_CHAR
},
557 { "short", NULL
, MOD_SHORT
},
558 { "int", &int_type
, 0 },
559 { "long", NULL
, MOD_LONG
},
560 { "float", &fp_type
, 0 },
561 { "double", &fp_type
, MOD_LONG
},
562 { "signed", NULL
, MOD_SIGNED
| MOD_EXPLICITLY_SIGNED
},
563 { "__signed", NULL
, MOD_SIGNED
| MOD_EXPLICITLY_SIGNED
},
564 { "__signed__", NULL
, MOD_SIGNED
| MOD_EXPLICITLY_SIGNED
},
565 { "unsigned", NULL
, MOD_UNSIGNED
},
566 { "__label__", &label_ctype
, MOD_LABEL
| MOD_UNSIGNED
},
567 { "_Bool", &bool_ctype
, MOD_UNSIGNED
},
569 /* Type qualifiers */
570 { "const", NULL
, MOD_CONST
},
571 { "__const", NULL
, MOD_CONST
},
572 { "__const__", NULL
, MOD_CONST
},
573 { "volatile", NULL
, MOD_VOLATILE
},
574 { "__volatile", NULL
, MOD_VOLATILE
},
575 { "__volatile__", NULL
, MOD_VOLATILE
},
577 /* Predeclared types */
578 { "__builtin_va_list", &int_type
, 0 },
581 { "typedef", NULL
, MOD_TYPEDEF
},
584 { "typeof", NULL
, MOD_TYPEOF
},
585 { "__typeof", NULL
, MOD_TYPEOF
},
586 { "__typeof__", NULL
, MOD_TYPEOF
},
589 { "attribute", NULL
, MOD_ATTRIBUTE
},
591 { "__attribute", NULL
, MOD_ATTRIBUTE
},
592 { "__attribute__", NULL
, MOD_ATTRIBUTE
},
594 { "struct", NULL
, MOD_STRUCTOF
},
595 { "union", NULL
, MOD_UNIONOF
},
596 { "enum", NULL
, MOD_ENUMOF
},
598 { "inline", NULL
, MOD_INLINE
},
599 { "__inline", NULL
, MOD_INLINE
},
600 { "__inline__", NULL
, MOD_INLINE
},
602 /* Ignored for now.. */
603 { "restrict", NULL
, 0 },
604 { "__restrict", NULL
, 0 },
609 static struct symbol_op constant_p_op
= {
610 .evaluate
= evaluate_to_integer
,
611 .expand
= expand_constant_p
614 static struct symbol_op safe_p_op
= {
615 .evaluate
= evaluate_to_integer
,
616 .expand
= expand_safe_p
619 static struct symbol_op warning_op
= {
620 .evaluate
= evaluate_to_integer
,
621 .expand
= expand_warning
627 static struct symbol builtin_fn_type
= { .type
= SYM_FN
/* , .variadic =1 */ };
628 static struct sym_init eval_init_table
[] = {
629 { "__builtin_constant_p", &builtin_fn_type
, MOD_TOPLEVEL
, &constant_p_op
},
630 { "__builtin_safe_p", &builtin_fn_type
, MOD_TOPLEVEL
, &safe_p_op
},
631 { "__builtin_warning", &builtin_fn_type
, MOD_TOPLEVEL
, &warning_op
},
639 struct symbol int_type
,
643 * C types (ie actual instances that the abstract types
646 struct symbol bool_ctype
, void_ctype
, type_ctype
,
647 char_ctype
, schar_ctype
, uchar_ctype
,
648 short_ctype
, sshort_ctype
, ushort_ctype
,
649 int_ctype
, sint_ctype
, uint_ctype
,
650 long_ctype
, slong_ctype
, ulong_ctype
,
651 llong_ctype
, sllong_ctype
, ullong_ctype
,
652 float_ctype
, double_ctype
, ldouble_ctype
,
653 string_ctype
, ptr_ctype
, lazy_ptr_ctype
,
654 incomplete_ctype
, label_ctype
, bad_ctype
;
657 #define __INIT_IDENT(str, res) { .len = sizeof(str)-1, .name = str, .reserved = res }
658 #define __IDENT(n,str,res) \
659 struct ident n = __INIT_IDENT(str,res)
661 #include "ident-list.h"
663 void init_symbols(void)
665 int stream
= init_stream("builtin", -1, includepath
);
666 struct sym_init
*ptr
;
668 #define __IDENT(n,str,res) \
670 #include "ident-list.h"
672 for (ptr
= symbol_init_table
; ptr
->name
; ptr
++) {
674 sym
= create_symbol(stream
, ptr
->name
, SYM_NODE
, NS_TYPEDEF
);
675 sym
->ident
->reserved
= 1;
676 sym
->ctype
.base_type
= ptr
->base_type
;
677 sym
->ctype
.modifiers
= ptr
->modifiers
;
680 builtin_fn_type
.variadic
= 1;
681 for (ptr
= eval_init_table
; ptr
->name
; ptr
++) {
683 sym
= create_symbol(stream
, ptr
->name
, SYM_NODE
, NS_SYMBOL
);
684 sym
->ctype
.base_type
= ptr
->base_type
;
685 sym
->ctype
.modifiers
= ptr
->modifiers
;
690 #define MOD_ESIGNED (MOD_SIGNED | MOD_EXPLICITLY_SIGNED)
691 #define MOD_LL (MOD_LONG | MOD_LONGLONG)
692 static const struct ctype_declare
{
695 unsigned long modifiers
;
698 struct symbol
*base_type
;
699 } ctype_declaration
[] = {
700 { &bool_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
, &bits_in_bool
, &max_int_alignment
, &int_type
},
701 { &void_ctype
, SYM_BASETYPE
, 0, NULL
, NULL
, NULL
},
702 { &type_ctype
, SYM_BASETYPE
, MOD_TYPE
, NULL
, NULL
, NULL
},
703 { &incomplete_ctype
,SYM_BASETYPE
, 0, NULL
, NULL
, NULL
},
704 { &bad_ctype
, SYM_BASETYPE
, 0, NULL
, NULL
, NULL
},
706 { &char_ctype
, SYM_BASETYPE
, MOD_SIGNED
| MOD_CHAR
, &bits_in_char
, &max_int_alignment
, &int_type
},
707 { &schar_ctype
, SYM_BASETYPE
, MOD_ESIGNED
| MOD_CHAR
, &bits_in_char
, &max_int_alignment
, &int_type
},
708 { &uchar_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
| MOD_CHAR
, &bits_in_char
, &max_int_alignment
, &int_type
},
709 { &short_ctype
, SYM_BASETYPE
, MOD_SIGNED
| MOD_SHORT
, &bits_in_short
, &max_int_alignment
, &int_type
},
710 { &sshort_ctype
, SYM_BASETYPE
, MOD_ESIGNED
| MOD_SHORT
, &bits_in_short
, &max_int_alignment
, &int_type
},
711 { &ushort_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
| MOD_SHORT
, &bits_in_short
, &max_int_alignment
, &int_type
},
712 { &int_ctype
, SYM_BASETYPE
, MOD_SIGNED
, &bits_in_int
, &max_int_alignment
, &int_type
},
713 { &sint_ctype
, SYM_BASETYPE
, MOD_ESIGNED
, &bits_in_int
, &max_int_alignment
, &int_type
},
714 { &uint_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
, &bits_in_int
, &max_int_alignment
, &int_type
},
715 { &long_ctype
, SYM_BASETYPE
, MOD_SIGNED
| MOD_LONG
, &bits_in_long
, &max_int_alignment
, &int_type
},
716 { &slong_ctype
, SYM_BASETYPE
, MOD_ESIGNED
| MOD_LONG
, &bits_in_long
, &max_int_alignment
, &int_type
},
717 { &ulong_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
| MOD_LONG
, &bits_in_long
, &max_int_alignment
, &int_type
},
718 { &llong_ctype
, SYM_BASETYPE
, MOD_SIGNED
| MOD_LL
, &bits_in_longlong
, &max_int_alignment
, &int_type
},
719 { &sllong_ctype
, SYM_BASETYPE
, MOD_ESIGNED
| MOD_LL
, &bits_in_longlong
, &max_int_alignment
, &int_type
},
720 { &ullong_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
| MOD_LL
, &bits_in_longlong
, &max_int_alignment
, &int_type
},
722 { &float_ctype
, SYM_BASETYPE
, 0, &bits_in_float
, &max_fp_alignment
, &fp_type
},
723 { &double_ctype
, SYM_BASETYPE
, MOD_LONG
, &bits_in_double
, &max_fp_alignment
, &fp_type
},
724 { &ldouble_ctype
, SYM_BASETYPE
, MOD_LONG
| MOD_LONGLONG
, &bits_in_longdouble
, &max_fp_alignment
, &fp_type
},
726 { &string_ctype
, SYM_PTR
, 0, &bits_in_pointer
, &pointer_alignment
, &char_ctype
},
727 { &ptr_ctype
, SYM_PTR
, 0, &bits_in_pointer
, &pointer_alignment
, &void_ctype
},
728 { &label_ctype
, SYM_PTR
, 0, &bits_in_pointer
, &pointer_alignment
, &void_ctype
},
729 { &lazy_ptr_ctype
, SYM_PTR
, 0, &bits_in_pointer
, &pointer_alignment
, &void_ctype
},
735 void init_ctype(void)
737 const struct ctype_declare
*ctype
;
739 for (ctype
= ctype_declaration
; ctype
->ptr
; ctype
++) {
740 struct symbol
*sym
= ctype
->ptr
;
741 unsigned long bit_size
= ctype
->bit_size
? *ctype
->bit_size
: -1;
742 unsigned long maxalign
= ctype
->maxalign
? *ctype
->maxalign
: 0;
743 unsigned long alignment
= bit_size
>> 3;
745 if (alignment
> maxalign
)
746 alignment
= maxalign
;
747 sym
->type
= ctype
->type
;
748 sym
->bit_size
= bit_size
;
749 sym
->ctype
.alignment
= alignment
;
750 sym
->ctype
.base_type
= ctype
->base_type
;
751 sym
->ctype
.modifiers
= ctype
->modifiers
;