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
20 #include "expression.h"
25 * Secondary symbol list for stuff that needs to be output because it
28 struct symbol_list
*translation_unit_used_list
= NULL
;
31 * If the symbol is an inline symbol, add it to the list of symbols to parse
33 void access_symbol(struct symbol
*sym
)
35 if (sym
->ctype
.modifiers
& MOD_INLINE
) {
36 if (!(sym
->ctype
.modifiers
& MOD_ACCESSED
)) {
37 add_symbol(&translation_unit_used_list
, sym
);
38 sym
->ctype
.modifiers
|= MOD_ACCESSED
;
43 struct symbol
*lookup_symbol(struct ident
*ident
, enum namespace ns
)
47 for (sym
= ident
->symbols
; sym
; sym
= sym
->next_id
) {
48 if (sym
->namespace & ns
) {
56 struct symbol
*alloc_symbol(struct position pos
, int type
)
58 struct symbol
*sym
= __alloc_symbol(0);
64 struct struct_union_info
{
65 unsigned long max_align
;
66 unsigned long bit_size
;
71 * Unions are fairly easy to lay out ;)
73 static void lay_out_union(struct symbol
*sym
, struct struct_union_info
*info
)
75 examine_symbol_type(sym
);
77 // Unnamed bitfields do not affect alignment.
78 if (sym
->ident
|| !is_bitfield_type(sym
)) {
79 if (sym
->ctype
.alignment
> info
->max_align
)
80 info
->max_align
= sym
->ctype
.alignment
;
83 if (sym
->bit_size
> info
->bit_size
)
84 info
->bit_size
= sym
->bit_size
;
89 static int bitfield_base_size(struct symbol
*sym
)
91 if (sym
->type
== SYM_NODE
)
92 sym
= sym
->ctype
.base_type
;
93 if (sym
->type
== SYM_BITFIELD
)
94 sym
= sym
->ctype
.base_type
;
99 * Structures are a bit more interesting to lay out
101 static void lay_out_struct(struct symbol
*sym
, struct struct_union_info
*info
)
103 unsigned long bit_size
, align_bit_mask
;
106 examine_symbol_type(sym
);
108 // Unnamed bitfields do not affect alignment.
109 if (sym
->ident
|| !is_bitfield_type(sym
)) {
110 if (sym
->ctype
.alignment
> info
->max_align
)
111 info
->max_align
= sym
->ctype
.alignment
;
114 bit_size
= info
->bit_size
;
115 base_size
= sym
->bit_size
;
118 * Unsized arrays cause us to not align the resulting
122 info
->align_size
= 0;
126 align_bit_mask
= (sym
->ctype
.alignment
<< 3) - 1;
129 * Bitfields have some very special rules..
131 if (is_bitfield_type (sym
)) {
132 unsigned long bit_offset
= bit_size
& align_bit_mask
;
133 int room
= bitfield_base_size(sym
) - bit_offset
;
134 // Zero-width fields just fill up the unit.
135 int width
= base_size
? : (bit_offset
? room
: 0);
138 bit_size
= (bit_size
+ align_bit_mask
) & ~align_bit_mask
;
141 sym
->offset
= (bit_size
- bit_offset
) >> 3;
142 sym
->bit_offset
= bit_offset
;
143 sym
->ctype
.base_type
->bit_offset
= bit_offset
;
144 info
->bit_size
= bit_size
+ width
;
145 // warning (sym->pos, "bitfield: offset=%d:%d size=:%d", sym->offset, sym->bit_offset, width);
151 * Otherwise, just align it right and add it up..
153 bit_size
= (bit_size
+ align_bit_mask
) & ~align_bit_mask
;
154 sym
->offset
= bit_size
>> 3;
156 info
->bit_size
= bit_size
+ base_size
;
157 // warning (sym->pos, "regular: offset=%d", sym->offset);
160 static struct symbol
* examine_struct_union_type(struct symbol
*sym
, int advance
)
162 struct struct_union_info info
= {
167 unsigned long bit_size
, bit_align
;
168 void (*fn
)(struct symbol
*, struct struct_union_info
*);
169 struct symbol
*member
;
171 fn
= advance
? lay_out_struct
: lay_out_union
;
172 FOR_EACH_PTR(sym
->symbol_list
, member
) {
174 } END_FOR_EACH_PTR(member
);
176 if (!sym
->ctype
.alignment
)
177 sym
->ctype
.alignment
= info
.max_align
;
178 bit_size
= info
.bit_size
;
179 if (info
.align_size
) {
180 bit_align
= (sym
->ctype
.alignment
<< 3)-1;
181 bit_size
= (bit_size
+ bit_align
) & ~bit_align
;
183 sym
->bit_size
= bit_size
;
187 static struct symbol
*examine_base_type(struct symbol
*sym
)
189 struct symbol
*base_type
;
191 /* Check the basetype */
192 base_type
= sym
->ctype
.base_type
;
194 base_type
= examine_symbol_type(base_type
);
196 /* "typeof" can cause this */
197 if (base_type
&& base_type
->type
== SYM_NODE
)
198 merge_type(sym
, base_type
);
203 static struct symbol
* examine_array_type(struct symbol
*sym
)
205 struct symbol
*base_type
= examine_base_type(sym
);
206 unsigned long bit_size
, alignment
;
210 bit_size
= base_type
->bit_size
* get_expression_value(sym
->array_size
);
211 if (!sym
->array_size
|| sym
->array_size
->type
!= EXPR_VALUE
)
213 alignment
= base_type
->ctype
.alignment
;
214 if (!sym
->ctype
.alignment
)
215 sym
->ctype
.alignment
= alignment
;
216 sym
->bit_size
= bit_size
;
220 static struct symbol
*examine_bitfield_type(struct symbol
*sym
)
222 struct symbol
*base_type
= examine_base_type(sym
);
223 unsigned long bit_size
, alignment
, modifiers
;
227 bit_size
= base_type
->bit_size
;
228 if (sym
->bit_size
> bit_size
)
229 warning(sym
->pos
, "impossible field-width, %d, for this type", sym
->bit_size
);
231 alignment
= base_type
->ctype
.alignment
;
232 if (!sym
->ctype
.alignment
)
233 sym
->ctype
.alignment
= alignment
;
234 modifiers
= base_type
->ctype
.modifiers
;
236 /* Bitfields are unsigned, unless the base type was explicitly signed */
237 if (!(modifiers
& MOD_EXPLICITLY_SIGNED
))
238 modifiers
= (modifiers
& ~MOD_SIGNED
) | MOD_UNSIGNED
;
239 sym
->ctype
.modifiers
|= modifiers
& MOD_SIGNEDNESS
;
244 * "typeof" will have to merge the types together
246 void merge_type(struct symbol
*sym
, struct symbol
*base_type
)
248 sym
->ctype
.as
|= base_type
->ctype
.as
;
249 sym
->ctype
.modifiers
|= (base_type
->ctype
.modifiers
& ~MOD_STORAGE
);
250 sym
->ctype
.in_context
+= base_type
->ctype
.in_context
;
251 sym
->ctype
.out_context
+= base_type
->ctype
.out_context
;
252 sym
->ctype
.base_type
= base_type
->ctype
.base_type
;
255 static int count_array_initializer(struct symbol
*t
, struct expression
*expr
)
261 * Arrays of character types are special; they can be initialized by
262 * string literal _or_ by string literal in braces. The latter means
263 * that with T x[] = {<string literal>} number of elements in x depends
264 * on T - if it's a character type, we get the length of string literal
265 * (including NUL), otherwise we have one element here.
267 if (t
->ctype
.base_type
== &int_type
&& t
->ctype
.modifiers
& MOD_CHAR
)
270 switch (expr
->type
) {
271 case EXPR_INITIALIZER
: {
272 struct expression
*entry
;
275 FOR_EACH_PTR(expr
->expr_list
, entry
) {
277 switch (entry
->type
) {
279 if (entry
->idx_to
>= nr
)
280 nr
= entry
->idx_to
+1;
284 str_len
= entry
->string
->length
;
288 } END_FOR_EACH_PTR(entry
);
289 if (count
== 1 && str_len
)
295 nr
= expr
->string
->length
;
302 static struct symbol
* examine_node_type(struct symbol
*sym
)
304 struct symbol
*base_type
= examine_base_type(sym
);
306 unsigned long alignment
, modifiers
;
308 /* SYM_NODE - figure out what the type of the node was.. */
309 modifiers
= sym
->ctype
.modifiers
;
316 bit_size
= base_type
->bit_size
;
317 alignment
= base_type
->ctype
.alignment
;
319 /* Pick up signedness information into the node */
320 sym
->ctype
.modifiers
|= (MOD_SIGNEDNESS
& base_type
->ctype
.modifiers
);
322 if (!sym
->ctype
.alignment
)
323 sym
->ctype
.alignment
= alignment
;
325 /* Unsized array? The size might come from the initializer.. */
326 if (bit_size
< 0 && base_type
->type
== SYM_ARRAY
&& sym
->initializer
) {
327 struct symbol
*node_type
= base_type
->ctype
.base_type
;
328 int count
= count_array_initializer(node_type
, sym
->initializer
);
330 if (node_type
&& node_type
->bit_size
>= 0)
331 bit_size
= node_type
->bit_size
* count
;
334 sym
->bit_size
= bit_size
;
338 static struct symbol
*examine_enum_type(struct symbol
*sym
)
340 struct symbol
*base_type
= examine_base_type(sym
);
342 sym
->ctype
.modifiers
|= (base_type
->ctype
.modifiers
& MOD_SIGNEDNESS
);
343 sym
->bit_size
= bits_in_enum
;
344 if (base_type
->bit_size
> sym
->bit_size
)
345 sym
->bit_size
= base_type
->bit_size
;
346 sym
->ctype
.alignment
= enum_alignment
;
347 if (base_type
->ctype
.alignment
> sym
->ctype
.alignment
)
348 sym
->ctype
.alignment
= base_type
->ctype
.alignment
;
352 static struct symbol
*examine_pointer_type(struct symbol
*sym
)
355 * We need to set the pointer size first, and
356 * examine the thing we point to only afterwards.
357 * That's because this pointer type may end up
358 * being needed for the base type size evalutation.
361 sym
->bit_size
= bits_in_pointer
;
362 if (!sym
->ctype
.alignment
)
363 sym
->ctype
.alignment
= pointer_alignment
;
368 * Fill in type size and alignment information for
369 * regular SYM_TYPE things.
371 struct symbol
*examine_symbol_type(struct symbol
* sym
)
384 return examine_node_type(sym
);
386 return examine_array_type(sym
);
388 return examine_struct_union_type(sym
, 1);
390 return examine_struct_union_type(sym
, 0);
392 return examine_pointer_type(sym
);
394 return examine_enum_type(sym
);
396 return examine_bitfield_type(sym
);
398 /* Size and alignment had better already be set up */
401 struct symbol
*base
= evaluate_expression(sym
->initializer
);
403 if (is_bitfield_type(base
))
404 warning(base
->pos
, "typeof applied to bitfield type");
405 if (base
->type
== SYM_NODE
)
406 base
= base
->ctype
.base_type
;
412 case SYM_PREPROCESSOR
:
413 sparse_error(sym
->pos
, "ctype on preprocessor command? (%s)", show_ident(sym
->ident
));
415 case SYM_UNINITIALIZED
:
416 sparse_error(sym
->pos
, "ctype on uninitialized symbol %p", sym
);
419 examine_base_type(sym
);
422 sparse_error(sym
->pos
, "Examining unknown symbol type %d", sym
->type
);
428 void check_declaration(struct symbol
*sym
)
431 struct symbol
*next
= sym
;
433 while ((next
= next
->next_id
) != NULL
) {
434 if (next
->namespace != sym
->namespace)
436 if (sym
->scope
== next
->scope
) {
437 sym
->same_symbol
= next
;
440 if (sym
->ctype
.modifiers
& next
->ctype
.modifiers
& MOD_EXTERN
) {
441 sym
->same_symbol
= next
;
445 if (!Wshadow
|| warned
)
447 if (get_sym_type(next
) == SYM_FN
)
450 warning(sym
->pos
, "symbol '%s' shadows an earlier one", show_ident(sym
->ident
));
451 info(next
->pos
, "originally declared here");
455 void bind_symbol(struct symbol
*sym
, struct ident
*ident
, enum namespace ns
)
459 sparse_error(sym
->pos
, "internal error: symbol type already bound");
462 if (ident
->reserved
&& (ns
& (NS_TYPEDEF
| NS_STRUCT
| NS_LABEL
| NS_SYMBOL
))) {
463 sparse_error(sym
->pos
, "Trying to use reserved word '%s' as identifier", show_ident(ident
));
467 sym
->next_id
= ident
->symbols
;
468 ident
->symbols
= sym
;
469 sym
->id_list
= &ident
->symbols
;
470 if (sym
->ident
&& sym
->ident
!= ident
)
471 warning(sym
->pos
, "Symbol '%s' already bound", show_ident(sym
->ident
));
475 if (ns
== NS_SYMBOL
&& toplevel(scope
)) {
476 unsigned mod
= MOD_ADDRESSABLE
| MOD_TOPLEVEL
;
477 scope
= global_scope
;
478 if (sym
->ctype
.modifiers
& MOD_STATIC
) {
482 sym
->ctype
.modifiers
|= mod
;
487 scope
= function_scope
;
488 bind_scope(sym
, scope
);
491 struct symbol
*create_symbol(int stream
, const char *name
, int type
, int namespace)
493 struct token
*token
= built_in_token(stream
, name
);
494 struct symbol
*sym
= alloc_symbol(token
->pos
, type
);
496 bind_symbol(sym
, token
->ident
, namespace);
500 static int evaluate_to_integer(struct expression
*expr
)
502 expr
->ctype
= &int_ctype
;
506 static int evaluate_expect(struct expression
*expr
)
508 /* Should we evaluate it to return the type of the first argument? */
509 expr
->ctype
= &int_ctype
;
513 static int expand_expect(struct expression
*expr
, int cost
)
515 struct expression
*arg
= first_ptr_list((struct ptr_list
*) expr
->args
);
523 * __builtin_warning() has type "int" and always returns 1,
524 * so that you can use it in conditionals or whatever
526 static int expand_warning(struct expression
*expr
, int cost
)
528 struct expression
*arg
;
529 struct expression_list
*arglist
= expr
->args
;
531 FOR_EACH_PTR (arglist
, arg
) {
533 * Constant strings get printed out as a warning. By the
534 * time we get here, the EXPR_STRING has been fully
535 * evaluated, so by now it's an anonymous symbol with a
536 * string initializer.
538 * Just for the heck of it, allow any constant string
541 if (arg
->type
== EXPR_SYMBOL
) {
542 struct symbol
*sym
= arg
->symbol
;
543 if (sym
->initializer
&& sym
->initializer
->type
== EXPR_STRING
) {
544 struct string
*string
= sym
->initializer
->string
;
545 warning(expr
->pos
, "%*s", string
->length
-1, string
->data
);
551 * Any other argument is a conditional. If it's
552 * non-constant, or it is false, we exit and do
553 * not print any warning.
555 if (arg
->type
!= EXPR_VALUE
)
559 } END_FOR_EACH_PTR(arg
);
561 expr
->type
= EXPR_VALUE
;
567 * Type and storage class keywords need to have the symbols
568 * created for them, so that the parser can have enough semantic
569 * information to do parsing.
571 * "double" == "long float", "long double" == "long long float"
573 static struct sym_init
{
575 struct symbol
*base_type
;
576 unsigned int modifiers
;
577 struct symbol_op
*op
;
578 } symbol_init_table
[] = {
580 { "auto", NULL
, MOD_AUTO
},
581 { "register", NULL
, MOD_REGISTER
},
582 { "static", NULL
, MOD_STATIC
},
583 { "extern", NULL
, MOD_EXTERN
},
585 /* Type specifiers */
586 { "void", &void_ctype
, 0 },
587 { "char", NULL
, MOD_CHAR
},
588 { "short", NULL
, MOD_SHORT
},
589 { "int", &int_type
, 0 },
590 { "long", NULL
, MOD_LONG
},
591 { "float", &fp_type
, 0 },
592 { "double", &fp_type
, MOD_LONG
},
593 { "signed", NULL
, MOD_SIGNED
| MOD_EXPLICITLY_SIGNED
},
594 { "__signed", NULL
, MOD_SIGNED
| MOD_EXPLICITLY_SIGNED
},
595 { "__signed__", NULL
, MOD_SIGNED
| MOD_EXPLICITLY_SIGNED
},
596 { "unsigned", NULL
, MOD_UNSIGNED
},
597 { "__label__", &label_ctype
, MOD_LABEL
| MOD_UNSIGNED
},
598 { "_Bool", &bool_ctype
, MOD_UNSIGNED
},
600 /* Type qualifiers */
601 { "const", NULL
, MOD_CONST
},
602 { "__const", NULL
, MOD_CONST
},
603 { "__const__", NULL
, MOD_CONST
},
604 { "volatile", NULL
, MOD_VOLATILE
},
605 { "__volatile", NULL
, MOD_VOLATILE
},
606 { "__volatile__", NULL
, MOD_VOLATILE
},
608 /* Predeclared types */
609 { "__builtin_va_list", &int_type
, 0 },
612 { "typedef", NULL
, MOD_TYPEDEF
},
615 { "typeof", NULL
, MOD_TYPEOF
},
616 { "__typeof", NULL
, MOD_TYPEOF
},
617 { "__typeof__", NULL
, MOD_TYPEOF
},
620 { "attribute", NULL
, MOD_ATTRIBUTE
},
622 { "__attribute", NULL
, MOD_ATTRIBUTE
},
623 { "__attribute__", NULL
, MOD_ATTRIBUTE
},
625 { "struct", NULL
, MOD_STRUCTOF
},
626 { "union", NULL
, MOD_UNIONOF
},
627 { "enum", NULL
, MOD_ENUMOF
},
629 { "inline", NULL
, MOD_INLINE
},
630 { "__inline", NULL
, MOD_INLINE
},
631 { "__inline__", NULL
, MOD_INLINE
},
633 /* Ignored for now.. */
634 { "restrict", NULL
, 0 },
635 { "__restrict", NULL
, 0 },
640 static struct symbol_op constant_p_op
= {
641 .evaluate
= evaluate_to_integer
,
642 .expand
= expand_constant_p
645 static struct symbol_op safe_p_op
= {
646 .evaluate
= evaluate_to_integer
,
647 .expand
= expand_safe_p
650 static struct symbol_op warning_op
= {
651 .evaluate
= evaluate_to_integer
,
652 .expand
= expand_warning
655 static struct symbol_op expect_op
= {
656 .evaluate
= evaluate_expect
,
657 .expand
= expand_expect
663 static struct symbol builtin_fn_type
= { .type
= SYM_FN
/* , .variadic =1 */ };
664 static struct sym_init eval_init_table
[] = {
665 { "__builtin_constant_p", &builtin_fn_type
, MOD_TOPLEVEL
, &constant_p_op
},
666 { "__builtin_safe_p", &builtin_fn_type
, MOD_TOPLEVEL
, &safe_p_op
},
667 { "__builtin_warning", &builtin_fn_type
, MOD_TOPLEVEL
, &warning_op
},
668 { "__builtin_expect", &builtin_fn_type
, MOD_TOPLEVEL
, &expect_op
},
676 struct symbol int_type
,
680 * C types (ie actual instances that the abstract types
683 struct symbol bool_ctype
, void_ctype
, type_ctype
,
684 char_ctype
, schar_ctype
, uchar_ctype
,
685 short_ctype
, sshort_ctype
, ushort_ctype
,
686 int_ctype
, sint_ctype
, uint_ctype
,
687 long_ctype
, slong_ctype
, ulong_ctype
,
688 llong_ctype
, sllong_ctype
, ullong_ctype
,
689 float_ctype
, double_ctype
, ldouble_ctype
,
690 string_ctype
, ptr_ctype
, lazy_ptr_ctype
,
691 incomplete_ctype
, label_ctype
, bad_ctype
;
693 struct symbol zero_int
;
695 #define __INIT_IDENT(str, res) { .len = sizeof(str)-1, .name = str, .reserved = res }
696 #define __IDENT(n,str,res) \
697 struct ident n = __INIT_IDENT(str,res)
699 #include "ident-list.h"
701 void init_symbols(void)
703 int stream
= init_stream("builtin", -1, includepath
);
704 struct sym_init
*ptr
;
706 #define __IDENT(n,str,res) \
708 #include "ident-list.h"
710 for (ptr
= symbol_init_table
; ptr
->name
; ptr
++) {
712 sym
= create_symbol(stream
, ptr
->name
, SYM_NODE
, NS_TYPEDEF
);
713 sym
->ident
->reserved
= 1;
714 sym
->ctype
.base_type
= ptr
->base_type
;
715 sym
->ctype
.modifiers
= ptr
->modifiers
;
718 builtin_fn_type
.variadic
= 1;
719 for (ptr
= eval_init_table
; ptr
->name
; ptr
++) {
721 sym
= create_symbol(stream
, ptr
->name
, SYM_NODE
, NS_SYMBOL
);
722 sym
->ctype
.base_type
= ptr
->base_type
;
723 sym
->ctype
.modifiers
= ptr
->modifiers
;
728 #define MOD_ESIGNED (MOD_SIGNED | MOD_EXPLICITLY_SIGNED)
729 #define MOD_LL (MOD_LONG | MOD_LONGLONG)
730 static const struct ctype_declare
{
733 unsigned long modifiers
;
736 struct symbol
*base_type
;
737 } ctype_declaration
[] = {
738 { &bool_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
, &bits_in_bool
, &max_int_alignment
, &int_type
},
739 { &void_ctype
, SYM_BASETYPE
, 0, NULL
, NULL
, NULL
},
740 { &type_ctype
, SYM_BASETYPE
, MOD_TYPE
, NULL
, NULL
, NULL
},
741 { &incomplete_ctype
,SYM_BASETYPE
, 0, NULL
, NULL
, NULL
},
742 { &bad_ctype
, SYM_BASETYPE
, 0, NULL
, NULL
, NULL
},
744 { &char_ctype
, SYM_BASETYPE
, MOD_SIGNED
| MOD_CHAR
, &bits_in_char
, &max_int_alignment
, &int_type
},
745 { &schar_ctype
, SYM_BASETYPE
, MOD_ESIGNED
| MOD_CHAR
, &bits_in_char
, &max_int_alignment
, &int_type
},
746 { &uchar_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
| MOD_CHAR
, &bits_in_char
, &max_int_alignment
, &int_type
},
747 { &short_ctype
, SYM_BASETYPE
, MOD_SIGNED
| MOD_SHORT
, &bits_in_short
, &max_int_alignment
, &int_type
},
748 { &sshort_ctype
, SYM_BASETYPE
, MOD_ESIGNED
| MOD_SHORT
, &bits_in_short
, &max_int_alignment
, &int_type
},
749 { &ushort_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
| MOD_SHORT
, &bits_in_short
, &max_int_alignment
, &int_type
},
750 { &int_ctype
, SYM_BASETYPE
, MOD_SIGNED
, &bits_in_int
, &max_int_alignment
, &int_type
},
751 { &sint_ctype
, SYM_BASETYPE
, MOD_ESIGNED
, &bits_in_int
, &max_int_alignment
, &int_type
},
752 { &uint_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
, &bits_in_int
, &max_int_alignment
, &int_type
},
753 { &long_ctype
, SYM_BASETYPE
, MOD_SIGNED
| MOD_LONG
, &bits_in_long
, &max_int_alignment
, &int_type
},
754 { &slong_ctype
, SYM_BASETYPE
, MOD_ESIGNED
| MOD_LONG
, &bits_in_long
, &max_int_alignment
, &int_type
},
755 { &ulong_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
| MOD_LONG
, &bits_in_long
, &max_int_alignment
, &int_type
},
756 { &llong_ctype
, SYM_BASETYPE
, MOD_SIGNED
| MOD_LL
, &bits_in_longlong
, &max_int_alignment
, &int_type
},
757 { &sllong_ctype
, SYM_BASETYPE
, MOD_ESIGNED
| MOD_LL
, &bits_in_longlong
, &max_int_alignment
, &int_type
},
758 { &ullong_ctype
, SYM_BASETYPE
, MOD_UNSIGNED
| MOD_LL
, &bits_in_longlong
, &max_int_alignment
, &int_type
},
760 { &float_ctype
, SYM_BASETYPE
, 0, &bits_in_float
, &max_fp_alignment
, &fp_type
},
761 { &double_ctype
, SYM_BASETYPE
, MOD_LONG
, &bits_in_double
, &max_fp_alignment
, &fp_type
},
762 { &ldouble_ctype
, SYM_BASETYPE
, MOD_LONG
| MOD_LONGLONG
, &bits_in_longdouble
, &max_fp_alignment
, &fp_type
},
764 { &string_ctype
, SYM_PTR
, 0, &bits_in_pointer
, &pointer_alignment
, &char_ctype
},
765 { &ptr_ctype
, SYM_PTR
, 0, &bits_in_pointer
, &pointer_alignment
, &void_ctype
},
766 { &label_ctype
, SYM_PTR
, 0, &bits_in_pointer
, &pointer_alignment
, &void_ctype
},
767 { &lazy_ptr_ctype
, SYM_PTR
, 0, &bits_in_pointer
, &pointer_alignment
, &void_ctype
},
773 void init_ctype(void)
775 const struct ctype_declare
*ctype
;
777 for (ctype
= ctype_declaration
; ctype
->ptr
; ctype
++) {
778 struct symbol
*sym
= ctype
->ptr
;
779 unsigned long bit_size
= ctype
->bit_size
? *ctype
->bit_size
: -1;
780 unsigned long maxalign
= ctype
->maxalign
? *ctype
->maxalign
: 0;
781 unsigned long alignment
= bit_size
>> 3;
783 if (alignment
> maxalign
)
784 alignment
= maxalign
;
785 sym
->type
= ctype
->type
;
786 sym
->bit_size
= bit_size
;
787 sym
->ctype
.alignment
= alignment
;
788 sym
->ctype
.base_type
= ctype
->base_type
;
789 sym
->ctype
.modifiers
= ctype
->modifiers
;