4 * Copyright (C) 2003 Transmeta Corp.
7 * Licensed under the Open Software License version 1.1
9 * Evaluate constant expressions.
26 #include "expression.h"
28 static struct symbol
*current_fn
;
29 static int current_context
, current_contextmask
;
31 static struct symbol
*degenerate(struct expression
*expr
);
33 static struct symbol
*evaluate_symbol_expression(struct expression
*expr
)
35 struct symbol
*sym
= expr
->symbol
;
36 struct symbol
*base_type
;
40 expr
->ctype
= &int_ctype
;
43 warn(expr
->pos
, "undefined identifier '%s'", show_ident(expr
->symbol_name
));
47 examine_symbol_type(sym
);
48 if ((sym
->ctype
.context
^ current_context
) & (sym
->ctype
.contextmask
& current_contextmask
))
49 warn(expr
->pos
, "Using symbol '%s' in wrong context", show_ident(expr
->symbol_name
));
51 base_type
= sym
->ctype
.base_type
;
53 warn(expr
->pos
, "identifier '%s' has no type", show_ident(expr
->symbol_name
));
57 /* The type of a symbol is the symbol itself! */
60 /* enum's can be turned into plain values */
61 if (sym
->type
!= SYM_ENUM
) {
62 struct expression
*addr
= alloc_expression(expr
->pos
, EXPR_SYMBOL
);
64 addr
->symbol_name
= expr
->symbol_name
;
65 addr
->ctype
= NULL
; /* Lazy evaluation: we need to do a proper job if somebody does &sym */
66 expr
->type
= EXPR_PREOP
;
71 expr
->type
= EXPR_VALUE
;
72 expr
->value
= sym
->value
;
73 expr
->ctype
= base_type
;
77 static struct symbol
*evaluate_string(struct expression
*expr
)
79 struct symbol
*sym
= alloc_symbol(expr
->pos
, SYM_NODE
);
80 struct symbol
*array
= alloc_symbol(expr
->pos
, SYM_ARRAY
);
81 struct expression
*addr
= alloc_expression(expr
->pos
, EXPR_SYMBOL
);
82 struct expression
*initstr
= alloc_expression(expr
->pos
, EXPR_STRING
);
83 unsigned int length
= expr
->string
->length
;
85 sym
->array_size
= alloc_const_expression(expr
->pos
, length
);
86 sym
->bit_size
= bits_in_char
* length
;
87 sym
->ctype
.alignment
= 1;
88 sym
->ctype
.modifiers
= MOD_STATIC
;
89 sym
->ctype
.base_type
= array
;
90 sym
->initializer
= initstr
;
93 initstr
->string
= expr
->string
;
95 array
->array_size
= sym
->array_size
;
96 array
->bit_size
= bits_in_char
* length
;
97 array
->ctype
.alignment
= 1;
98 array
->ctype
.modifiers
= MOD_STATIC
;
99 array
->ctype
.base_type
= &char_ctype
;
104 expr
->type
= EXPR_PREOP
;
111 static struct symbol
*bigger_int_type(struct symbol
*left
, struct symbol
*right
)
113 unsigned long lmod
, rmod
, mod
;
118 if (left
->bit_size
> right
->bit_size
)
121 if (right
->bit_size
> left
->bit_size
)
124 /* Same size integers - promote to unsigned, promote to long */
125 lmod
= left
->ctype
.modifiers
;
126 rmod
= right
->ctype
.modifiers
;
132 return ctype_integer(mod
);
137 if (left
->bit_size
< bits_in_int
)
142 static struct expression
* cast_to(struct expression
*old
, struct symbol
*type
)
144 struct expression
*expr
= alloc_expression(old
->pos
, EXPR_CAST
);
146 expr
->cast_type
= type
;
147 expr
->cast_expression
= old
;
151 static int is_type_type(struct symbol
*type
)
153 return (type
->ctype
.modifiers
& MOD_TYPE
) != 0;
156 static int is_ptr_type(struct symbol
*type
)
158 if (type
->type
== SYM_NODE
)
159 type
= type
->ctype
.base_type
;
160 return type
->type
== SYM_PTR
|| type
->type
== SYM_ARRAY
|| type
->type
== SYM_FN
;
163 static int is_int_type(struct symbol
*type
)
165 if (type
->type
== SYM_NODE
)
166 type
= type
->ctype
.base_type
;
167 return (type
->type
== SYM_BITFIELD
) || type
->ctype
.base_type
== &int_type
;
170 static struct symbol
*bad_expr_type(struct expression
*expr
)
172 warn(expr
->pos
, "incompatible types for operation");
176 static struct symbol
* compatible_integer_binop(struct expression
*expr
, struct expression
**lp
, struct expression
**rp
)
178 struct expression
*left
= *lp
, *right
= *rp
;
179 struct symbol
*ltype
= left
->ctype
, *rtype
= right
->ctype
;
181 if (ltype
->type
== SYM_NODE
)
182 ltype
= ltype
->ctype
.base_type
;
183 if (rtype
->type
== SYM_NODE
)
184 rtype
= rtype
->ctype
.base_type
;
185 /* Integer promotion? */
186 if (ltype
->type
== SYM_ENUM
|| ltype
->type
== SYM_BITFIELD
)
188 if (rtype
->type
== SYM_ENUM
|| rtype
->type
== SYM_BITFIELD
)
190 if (is_int_type(ltype
) && is_int_type(rtype
)) {
191 struct symbol
*ctype
= bigger_int_type(ltype
, rtype
);
193 /* Don't bother promoting same-size entities, it only adds clutter */
194 if (ltype
->bit_size
!= ctype
->bit_size
)
195 *lp
= cast_to(left
, ctype
);
196 if (rtype
->bit_size
!= ctype
->bit_size
)
197 *rp
= cast_to(right
, ctype
);
203 static struct symbol
*evaluate_int_binop(struct expression
*expr
)
205 struct symbol
*ctype
= compatible_integer_binop(expr
, &expr
->left
, &expr
->right
);
210 return bad_expr_type(expr
);
213 static inline int lvalue_expression(struct expression
*expr
)
215 while (expr
->type
== EXPR_CAST
)
216 expr
= expr
->cast_expression
;
217 return (expr
->type
== EXPR_PREOP
&& expr
->op
== '*') || expr
->type
== EXPR_BITFIELD
;
220 static struct symbol
*evaluate_ptr_add(struct expression
*expr
, struct expression
*ptr
, struct expression
*i
)
222 struct symbol
*ctype
;
223 struct symbol
*ptr_type
= ptr
->ctype
;
224 struct symbol
*i_type
= i
->ctype
;
227 if (i_type
->type
== SYM_NODE
)
228 i_type
= i_type
->ctype
.base_type
;
229 if (ptr_type
->type
== SYM_NODE
)
230 ptr_type
= ptr_type
->ctype
.base_type
;
232 if (i_type
->type
== SYM_ENUM
)
234 if (!is_int_type(i_type
))
235 return bad_expr_type(expr
);
238 examine_symbol_type(ctype
);
240 ctype
= degenerate(ptr
);
241 if (!ctype
->ctype
.base_type
) {
242 warn(expr
->pos
, "missing type information");
246 /* Get the size of whatever the pointer points to */
248 if (ptr_type
->type
== SYM_NODE
)
249 ptr_type
= ptr_type
->ctype
.base_type
;
250 if (ptr_type
->type
== SYM_PTR
)
251 ptr_type
= ptr_type
->ctype
.base_type
;
252 bit_size
= ptr_type
->bit_size
;
254 /* Special case: adding zero commonly happens as a result of 'array[0]' */
255 if (i
->type
== EXPR_VALUE
&& !i
->value
) {
257 } else if (bit_size
> bits_in_char
) {
258 struct expression
*add
= expr
;
259 struct expression
*mul
= alloc_expression(expr
->pos
, EXPR_BINOP
);
260 struct expression
*val
= alloc_expression(expr
->pos
, EXPR_VALUE
);
262 val
->ctype
= size_t_ctype
;
263 val
->value
= bit_size
>> 3;
266 mul
->ctype
= size_t_ctype
;
270 /* Leave 'add->op' as 'expr->op' - either '+' or '-' */
279 static struct symbol
*evaluate_add(struct expression
*expr
)
281 struct expression
*left
= expr
->left
, *right
= expr
->right
;
282 struct symbol
*ltype
= left
->ctype
, *rtype
= right
->ctype
;
284 if (is_ptr_type(ltype
))
285 return evaluate_ptr_add(expr
, left
, right
);
287 if (is_ptr_type(rtype
))
288 return evaluate_ptr_add(expr
, right
, left
);
290 // FIXME! FP promotion
291 return evaluate_int_binop(expr
);
294 #define MOD_SIZE (MOD_CHAR | MOD_SHORT | MOD_LONG | MOD_LONGLONG)
295 #define MOD_IGNORE (MOD_TOPLEVEL | MOD_STORAGE | MOD_ADDRESSABLE | MOD_SIGNED | MOD_UNSIGNED | MOD_ASSIGNED | MOD_USERTYPE | MOD_FORCE)
297 const char * type_difference(struct symbol
*target
, struct symbol
*source
,
298 unsigned long target_mod_ignore
, unsigned long source_mod_ignore
)
301 unsigned long mod1
, mod2
, diff
;
302 unsigned long as1
, as2
;
304 struct symbol
*base1
, *base2
;
306 if (target
== source
)
308 if (!target
|| !source
)
309 return "different types";
311 * Peel of per-node information.
312 * FIXME! Check alignment and context too here!
314 mod1
= target
->ctype
.modifiers
;
315 as1
= target
->ctype
.as
;
316 mod2
= source
->ctype
.modifiers
;
317 as2
= source
->ctype
.as
;
318 if (target
->type
== SYM_NODE
) {
319 target
= target
->ctype
.base_type
;
322 if (target
->type
== SYM_PTR
) {
326 mod1
|= target
->ctype
.modifiers
;
327 as1
|= target
->ctype
.as
;
329 if (source
->type
== SYM_NODE
) {
330 source
= source
->ctype
.base_type
;
333 if (source
->type
== SYM_PTR
) {
337 mod2
|= source
->ctype
.modifiers
;
338 as2
|= source
->ctype
.as
;
341 if (target
== source
)
343 if (!target
|| !source
)
344 return "different types";
346 type1
= target
->type
;
347 base1
= target
->ctype
.base_type
;
349 type2
= source
->type
;
350 base2
= source
->ctype
.base_type
;
353 * Pointers to functions compare as the function itself
355 if (type1
== SYM_PTR
&& base1
) {
356 switch (base1
->type
) {
360 base1
= base1
->ctype
.base_type
;
365 if (type2
== SYM_PTR
&& base2
) {
366 switch (base2
->type
) {
370 base2
= base2
->ctype
.base_type
;
376 /* Arrays degenerate to pointers for type comparisons */
377 type1
= (type1
== SYM_ARRAY
) ? SYM_PTR
: type1
;
378 type2
= (type2
== SYM_ARRAY
) ? SYM_PTR
: type2
;
381 return "different base types";
383 /* Must be same address space to be comparable */
385 return "different address spaces";
387 /* Ignore differences in storage types, sign, or addressability */
388 diff
= (mod1
^ mod2
) & ~MOD_IGNORE
;
390 mod1
&= diff
& ~target_mod_ignore
;
391 mod2
&= diff
& ~source_mod_ignore
;
393 if ((mod1
| mod2
) & MOD_SIZE
)
394 return "different type sizes";
395 return "different modifiers";
399 if (type1
== SYM_FN
) {
401 struct symbol
*arg1
, *arg2
;
402 if (base1
->variadic
!= base2
->variadic
)
403 return "incompatible variadic arguments";
404 PREPARE_PTR_LIST(target
->arguments
, arg1
);
405 PREPARE_PTR_LIST(source
->arguments
, arg2
);
409 diff
= type_difference(arg1
, arg2
, 0, 0);
411 static char argdiff
[80];
412 sprintf(argdiff
, "incompatible argument %d (%s)", i
, diff
);
421 FINISH_PTR_LIST(arg2
);
422 FINISH_PTR_LIST(arg1
);
431 static struct symbol
*common_ptr_type(struct expression
*l
, struct expression
*r
)
433 /* NULL expression? Just return the type of the "other side" */
434 if (r
->type
== EXPR_VALUE
&& !r
->value
)
436 if (l
->type
== EXPR_VALUE
&& !l
->value
)
442 * Ignore differences in "volatile" and "const"ness when
443 * subtracting pointers
445 #define MOD_IGN (MOD_VOLATILE | MOD_CONST)
447 static struct symbol
*evaluate_ptr_sub(struct expression
*expr
, struct expression
*l
, struct expression
*r
)
449 const char *typediff
;
450 struct symbol
*ctype
;
451 struct symbol
*ltype
, *rtype
;
453 ltype
= degenerate(l
);
454 rtype
= degenerate(r
);
457 * If it is an integer subtract: the ptr add case will do the
460 if (!is_ptr_type(rtype
))
461 return evaluate_ptr_add(expr
, l
, r
);
464 typediff
= type_difference(ltype
, rtype
, ~MOD_SIZE
, ~MOD_SIZE
);
466 ctype
= common_ptr_type(l
, r
);
468 warn(expr
->pos
, "subtraction of different types can't work (%s)", typediff
);
472 examine_symbol_type(ctype
);
474 /* Figure out the base type we point to */
475 if (ctype
->type
== SYM_NODE
)
476 ctype
= ctype
->ctype
.base_type
;
477 if (ctype
->type
!= SYM_PTR
&& ctype
->type
!= SYM_ARRAY
) {
478 warn(expr
->pos
, "subtraction of functions? Share your drugs");
481 ctype
= ctype
->ctype
.base_type
;
483 expr
->ctype
= ssize_t_ctype
;
484 if (ctype
->bit_size
> bits_in_char
) {
485 struct expression
*sub
= alloc_expression(expr
->pos
, EXPR_BINOP
);
486 struct expression
*div
= expr
;
487 struct expression
*val
= alloc_expression(expr
->pos
, EXPR_VALUE
);
489 val
->ctype
= size_t_ctype
;
490 val
->value
= ctype
->bit_size
>> 3;
493 sub
->ctype
= ssize_t_ctype
;
502 return ssize_t_ctype
;
505 static struct symbol
*evaluate_sub(struct expression
*expr
)
507 struct expression
*left
= expr
->left
, *right
= expr
->right
;
508 struct symbol
*ltype
= left
->ctype
;
510 if (is_ptr_type(ltype
))
511 return evaluate_ptr_sub(expr
, left
, right
);
513 // FIXME! FP promotion
514 return evaluate_int_binop(expr
);
517 #define is_safe_type(type) ((type)->ctype.modifiers & MOD_SAFE)
519 static struct symbol
*evaluate_conditional(struct expression
*expr
)
521 struct symbol
*ctype
;
526 if (expr
->type
== EXPR_ASSIGNMENT
)
527 warn(expr
->pos
, "assignment expression in conditional");
529 ctype
= evaluate_expression(expr
);
530 if (ctype
&& is_safe_type(ctype
))
531 warn(expr
->pos
, "testing a 'safe expression'");
536 static struct symbol
*evaluate_logical(struct expression
*expr
)
538 if (!evaluate_conditional(expr
->left
))
540 if (!evaluate_conditional(expr
->right
))
543 expr
->ctype
= &bool_ctype
;
547 static struct symbol
*evaluate_arithmetic(struct expression
*expr
)
549 // FIXME! Floating-point promotion!
550 return evaluate_int_binop(expr
);
553 static struct symbol
*evaluate_binop(struct expression
*expr
)
556 // addition can take ptr+int, fp and int
558 return evaluate_add(expr
);
560 // subtraction can take ptr-ptr, fp and int
562 return evaluate_sub(expr
);
564 // Arithmetic operations can take fp and int
565 case '*': case '/': case '%':
566 return evaluate_arithmetic(expr
);
568 // The rest are integer operations (bitops)
569 // SPECIAL_LEFTSHIFT, SPECIAL_RIGHTSHIFT
572 return evaluate_int_binop(expr
);
576 static struct symbol
*evaluate_comma(struct expression
*expr
)
578 expr
->ctype
= expr
->right
->ctype
;
582 static struct symbol
*evaluate_compare(struct expression
*expr
)
584 struct expression
*left
= expr
->left
, *right
= expr
->right
;
585 struct symbol
*ltype
= left
->ctype
, *rtype
= right
->ctype
;
586 struct symbol
*ctype
;
589 if (is_type_type(ltype
) && is_type_type(rtype
)) {
590 expr
->ctype
= &bool_ctype
;
594 if (is_safe_type(ltype
) || is_safe_type(rtype
))
595 warn(expr
->pos
, "testing a 'safe expression'");
598 if (is_ptr_type(ltype
) || is_ptr_type(rtype
)) {
599 expr
->ctype
= &bool_ctype
;
600 // FIXME! Check the types for compatibility
604 ctype
= compatible_integer_binop(expr
, &expr
->left
, &expr
->right
);
606 expr
->ctype
= &bool_ctype
;
610 return bad_expr_type(expr
);
613 static int compatible_integer_types(struct symbol
*ltype
, struct symbol
*rtype
)
615 /* Integer promotion? */
616 if (ltype
->type
== SYM_NODE
)
617 ltype
= ltype
->ctype
.base_type
;
618 if (rtype
->type
== SYM_NODE
)
619 rtype
= rtype
->ctype
.base_type
;
620 if (ltype
->type
== SYM_ENUM
|| ltype
->type
== SYM_BITFIELD
)
622 if (rtype
->type
== SYM_ENUM
|| rtype
->type
== SYM_BITFIELD
)
624 return (is_int_type(ltype
) && is_int_type(rtype
));
627 static int is_null_ptr(struct expression
*expr
)
629 return (expr
->type
== EXPR_VALUE
&&
634 * FIXME!! This should do casts, array degeneration etc..
636 static struct symbol
*compatible_ptr_type(struct expression
*left
, struct expression
*right
)
638 struct symbol
*ltype
= left
->ctype
, *rtype
= right
->ctype
;
640 if (ltype
->type
== SYM_NODE
)
641 ltype
= ltype
->ctype
.base_type
;
643 if (rtype
->type
== SYM_NODE
)
644 rtype
= rtype
->ctype
.base_type
;
646 if (ltype
->type
== SYM_PTR
) {
647 if (is_null_ptr(right
) || rtype
->ctype
.base_type
== &void_ctype
)
651 if (rtype
->type
== SYM_PTR
) {
652 if (is_null_ptr(left
) || ltype
->ctype
.base_type
== &void_ctype
)
658 static struct symbol
* evaluate_conditional_expression(struct expression
*expr
)
660 struct expression
*cond
, *true, *false;
661 struct symbol
*ctype
, *ltype
, *rtype
;
662 const char * typediff
;
664 ctype
= degenerate(expr
->conditional
);
665 cond
= expr
->conditional
;
669 if (expr
->cond_true
) {
670 ltype
= degenerate(expr
->cond_true
);
671 true = expr
->cond_true
;
674 rtype
= degenerate(expr
->cond_false
);
675 false = expr
->cond_false
;
678 typediff
= type_difference(ltype
, rtype
, MOD_IGN
, MOD_IGN
);
680 ctype
= compatible_integer_binop(expr
, &true, &expr
->cond_false
);
682 ctype
= compatible_ptr_type(true, expr
->cond_false
);
684 warn(expr
->pos
, "incompatible types in conditional expression (%s)", typediff
);
694 static int compatible_assignment_types(struct expression
*expr
, struct symbol
*target
,
695 struct expression
**rp
, struct symbol
*source
, const char *where
)
697 const char *typediff
;
701 /* It's ok if the target is more volatile or const than the source */
702 typediff
= type_difference(target
, source
, MOD_VOLATILE
| MOD_CONST
, 0);
706 if (compatible_integer_types(target
, source
)) {
707 if (target
->bit_size
!= source
->bit_size
)
708 *rp
= cast_to(*rp
, target
);
712 /* Pointer destination? */
714 target_as
= t
->ctype
.as
;
715 if (t
->type
== SYM_NODE
) {
716 t
= t
->ctype
.base_type
;
717 target_as
|= t
->ctype
.as
;
719 if (t
->type
== SYM_PTR
|| t
->type
== SYM_FN
|| t
->type
== SYM_ARRAY
) {
720 struct expression
*right
= *rp
;
721 struct symbol
*s
= source
;
724 // NULL pointer is always ok
725 if (right
->type
== EXPR_VALUE
&& !right
->value
)
728 /* "void *" matches anything as long as the address space is ok */
729 source_as
= s
->ctype
.as
;
730 if (s
->type
== SYM_NODE
) {
731 s
= s
->ctype
.base_type
;
732 source_as
|= s
->ctype
.as
;
734 if (source_as
== target_as
&& (s
->type
== SYM_PTR
|| s
->type
== SYM_ARRAY
)) {
735 s
= s
->ctype
.base_type
;
736 t
= t
->ctype
.base_type
;
737 if (s
== &void_ctype
|| t
== &void_ctype
)
743 warn(expr
->pos
, "incorrect type in %s (%s)", where
, typediff
);
744 info(expr
->pos
, " expected %s", show_typename(target
));
745 info(expr
->pos
, " got %s", show_typename(source
));
750 * FIXME!! This is wrong from a double evaluation standpoint. We can't
751 * just expand the expression twice, that would make any side effects
754 static struct symbol
*evaluate_binop_assignment(struct expression
*expr
, struct expression
*left
, struct expression
*right
)
757 struct expression
*subexpr
= alloc_expression(expr
->pos
, EXPR_BINOP
);
758 static const int op_trans
[] = {
759 [SPECIAL_ADD_ASSIGN
- SPECIAL_BASE
] = '+',
760 [SPECIAL_SUB_ASSIGN
- SPECIAL_BASE
] = '-',
761 [SPECIAL_MUL_ASSIGN
- SPECIAL_BASE
] = '*',
762 [SPECIAL_DIV_ASSIGN
- SPECIAL_BASE
] = '/',
763 [SPECIAL_MOD_ASSIGN
- SPECIAL_BASE
] = '%',
764 [SPECIAL_SHL_ASSIGN
- SPECIAL_BASE
] = SPECIAL_LEFTSHIFT
,
765 [SPECIAL_SHR_ASSIGN
- SPECIAL_BASE
] = SPECIAL_RIGHTSHIFT
,
766 [SPECIAL_AND_ASSIGN
- SPECIAL_BASE
] = '&',
767 [SPECIAL_OR_ASSIGN
- SPECIAL_BASE
] = '|',
768 [SPECIAL_XOR_ASSIGN
- SPECIAL_BASE
] = '^'
771 subexpr
->left
= left
;
772 subexpr
->right
= right
;
773 subexpr
->op
= op_trans
[op
- SPECIAL_BASE
];
775 expr
->right
= subexpr
;
776 return evaluate_binop(subexpr
);
779 static struct symbol
*evaluate_assignment(struct expression
*expr
)
781 struct expression
*left
= expr
->left
, *right
= expr
->right
;
782 struct symbol
*ltype
, *rtype
;
785 rtype
= right
->ctype
;
786 if (expr
->op
!= '=') {
787 rtype
= evaluate_binop_assignment(expr
, left
, right
);
793 if (!lvalue_expression(left
)) {
794 warn(expr
->pos
, "not an lvalue");
798 rtype
= degenerate(right
);
800 if (!compatible_assignment_types(expr
, ltype
, &expr
->right
, rtype
, "assignment"))
803 if (ltype
->type
== SYM_NODE
)
804 ltype
->ctype
.modifiers
|= MOD_ASSIGNED
;
810 static struct symbol
*convert_to_as_mod(struct symbol
*sym
, int as
, int mod
)
812 if (sym
->ctype
.as
!= as
|| sym
->ctype
.modifiers
!= mod
) {
813 struct symbol
*newsym
= alloc_symbol(sym
->pos
, SYM_NODE
);
815 newsym
->ctype
.as
= as
;
816 newsym
->ctype
.modifiers
= mod
;
822 static struct symbol
*create_pointer(struct expression
*expr
, struct symbol
*sym
, int degenerate
)
824 struct symbol
*node
= alloc_symbol(expr
->pos
, SYM_NODE
);
825 struct symbol
*ptr
= alloc_symbol(expr
->pos
, SYM_PTR
);
827 node
->ctype
.base_type
= ptr
;
828 ptr
->bit_size
= bits_in_pointer
;
829 ptr
->ctype
.alignment
= pointer_alignment
;
831 node
->bit_size
= bits_in_pointer
;
832 node
->ctype
.alignment
= pointer_alignment
;
834 sym
->ctype
.modifiers
|= MOD_ADDRESSABLE
;
835 if (sym
->ctype
.modifiers
& MOD_REGISTER
) {
836 warn(expr
->pos
, "taking address of 'register' variable '%s'", show_ident(sym
->ident
));
837 sym
->ctype
.modifiers
&= ~MOD_REGISTER
;
839 if (sym
->type
== SYM_NODE
) {
840 ptr
->ctype
.as
|= sym
->ctype
.as
;
841 ptr
->ctype
.modifiers
|= sym
->ctype
.modifiers
;
842 sym
= sym
->ctype
.base_type
;
844 if (degenerate
&& sym
->type
== SYM_ARRAY
) {
845 ptr
->ctype
.as
|= sym
->ctype
.as
;
846 ptr
->ctype
.modifiers
|= sym
->ctype
.modifiers
;
847 sym
= sym
->ctype
.base_type
;
849 ptr
->ctype
.base_type
= sym
;
854 /* Arrays degenerate into pointers on pointer arithmetic */
855 static struct symbol
*degenerate(struct expression
*expr
)
857 struct symbol
*ctype
, *base
;
865 if (ctype
->type
== SYM_NODE
)
866 base
= ctype
->ctype
.base_type
;
868 * Arrays degenerate into pointers to the entries, while
869 * functions degenerate into pointers to themselves
871 switch (base
->type
) {
874 if (expr
->op
!= '*' || expr
->type
!= EXPR_PREOP
) {
875 warn(expr
->pos
, "strange non-value function or array");
879 ctype
= create_pointer(expr
, ctype
, 1);
887 static struct symbol
*evaluate_addressof(struct expression
*expr
)
889 struct expression
*op
= expr
->unop
;
890 struct symbol
*ctype
;
892 if (op
->op
!= '*' || op
->type
!= EXPR_PREOP
) {
893 warn(expr
->pos
, "not addressable");
900 * symbol expression evaluation is lazy about the type
901 * of the sub-expression, so we may have to generate
902 * the type here if so..
905 ctype
= create_pointer(expr
, ctype
, 0);
912 static struct symbol
*evaluate_dereference(struct expression
*expr
)
914 struct expression
*op
= expr
->unop
;
915 struct symbol
*ctype
= op
->ctype
, *node
, *target
;
917 /* Simplify: *&(expr) => (expr) */
918 if (op
->type
== EXPR_PREOP
&& op
->op
== '&') {
923 /* Dereferencing a node drops all the node information. */
924 if (ctype
->type
== SYM_NODE
)
925 ctype
= ctype
->ctype
.base_type
;
927 node
= alloc_symbol(expr
->pos
, SYM_NODE
);
928 target
= ctype
->ctype
.base_type
;
930 switch (ctype
->type
) {
932 warn(expr
->pos
, "cannot derefence this type");
935 merge_type(node
, ctype
);
936 if (ctype
->type
!= SYM_ARRAY
)
939 * Dereferencing a pointer to an array results in a
940 * degenerate dereference: the expression becomes
941 * just a pointer to the entry, and the derefence
946 target
= alloc_symbol(expr
->pos
, SYM_PTR
);
947 target
->bit_size
= bits_in_pointer
;
948 target
->ctype
.alignment
= pointer_alignment
;
949 merge_type(target
, ctype
->ctype
.base_type
);
954 * When an array is dereferenced, we need to pick
955 * up the attributes of the original node too..
957 merge_type(node
, op
->ctype
);
958 merge_type(node
, ctype
);
962 node
->bit_size
= target
->bit_size
;
963 node
->array_size
= target
->array_size
;
970 * Unary post-ops: x++ and x--
972 static struct symbol
*evaluate_postop(struct expression
*expr
)
974 struct expression
*op
= expr
->unop
;
975 struct symbol
*ctype
= op
->ctype
;
977 if (!lvalue_expression(expr
->unop
)) {
978 warn(expr
->pos
, "need lvalue expression for ++/--");
982 if (ctype
->type
== SYM_NODE
)
983 ctype
->ctype
.modifiers
|= MOD_ASSIGNED
;
989 static struct symbol
*evaluate_preop(struct expression
*expr
)
991 struct symbol
*ctype
= expr
->unop
->ctype
;
1000 return evaluate_dereference(expr
);
1003 return evaluate_addressof(expr
);
1005 case SPECIAL_INCREMENT
:
1006 case SPECIAL_DECREMENT
:
1008 * From a type evaluation standpoint the pre-ops are
1009 * the same as the postops
1011 return evaluate_postop(expr
);
1014 if (is_safe_type(ctype
))
1015 warn(expr
->pos
, "testing a 'safe expression'");
1016 ctype
= &bool_ctype
;
1022 expr
->ctype
= ctype
;
1026 struct symbol
*find_identifier(struct ident
*ident
, struct symbol_list
*_list
, int *offset
)
1028 struct ptr_list
*head
= (struct ptr_list
*)_list
;
1029 struct ptr_list
*list
= head
;
1035 for (i
= 0; i
< list
->nr
; i
++) {
1036 struct symbol
*sym
= (struct symbol
*) list
->list
[i
];
1038 if (sym
->ident
!= ident
)
1040 *offset
= sym
->offset
;
1043 struct symbol
*ctype
= sym
->ctype
.base_type
;
1047 if (ctype
->type
!= SYM_UNION
&& ctype
->type
!= SYM_STRUCT
)
1049 sub
= find_identifier(ident
, ctype
->symbol_list
, offset
);
1052 *offset
+= sym
->offset
;
1056 } while ((list
= list
->next
) != head
);
1060 static struct expression
*evaluate_offset(struct expression
*expr
, unsigned long offset
)
1062 struct expression
*add
;
1066 /* Create a new add-expression */
1067 add
= alloc_expression(expr
->pos
, EXPR_BINOP
);
1070 add
->right
= alloc_expression(expr
->pos
, EXPR_VALUE
);
1071 add
->right
->ctype
= &int_ctype
;
1072 add
->right
->value
= offset
;
1076 * The ctype of the pointer will be lazily evaluated if
1077 * we ever take the address of this member dereference..
1083 /* structure/union dereference */
1084 static struct symbol
*evaluate_member_dereference(struct expression
*expr
)
1087 struct symbol
*ctype
, *member
;
1088 struct expression
*deref
= expr
->deref
, *add
;
1089 struct ident
*ident
= expr
->member
;
1093 if (!evaluate_expression(deref
))
1096 warn(expr
->pos
, "bad member name");
1100 ctype
= deref
->ctype
;
1101 address_space
= ctype
->ctype
.as
;
1102 mod
= ctype
->ctype
.modifiers
;
1103 if (ctype
->type
== SYM_NODE
) {
1104 ctype
= ctype
->ctype
.base_type
;
1105 address_space
|= ctype
->ctype
.as
;
1106 mod
|= ctype
->ctype
.modifiers
;
1108 if (!lvalue_expression(deref
)) {
1109 warn(deref
->pos
, "expected lvalue for member dereference");
1112 deref
= deref
->unop
;
1113 expr
->deref
= deref
;
1114 if (!ctype
|| (ctype
->type
!= SYM_STRUCT
&& ctype
->type
!= SYM_UNION
)) {
1115 warn(expr
->pos
, "expected structure or union");
1119 member
= find_identifier(ident
, ctype
->symbol_list
, &offset
);
1121 const char *type
= ctype
->type
== SYM_STRUCT
? "struct" : "union";
1122 const char *name
= "<unnamed>";
1125 name
= ctype
->ident
->name
;
1126 namelen
= ctype
->ident
->len
;
1128 warn(expr
->pos
, "no member '%s' in %s %.*s",
1129 show_ident(ident
), type
, namelen
, name
);
1134 * The member needs to take on the address space and modifiers of
1135 * the "parent" type.
1137 member
= convert_to_as_mod(member
, address_space
, mod
);
1138 add
= evaluate_offset(deref
, offset
);
1140 ctype
= member
->ctype
.base_type
;
1141 if (ctype
->type
== SYM_BITFIELD
) {
1142 expr
->type
= EXPR_BITFIELD
;
1143 expr
->bitpos
= member
->bit_offset
;
1144 expr
->nrbits
= member
->fieldwidth
;
1145 expr
->address
= add
;
1147 expr
->type
= EXPR_PREOP
;
1152 expr
->ctype
= member
;
1156 static struct symbol
*evaluate_sizeof(struct expression
*expr
)
1160 if (expr
->cast_type
) {
1161 examine_symbol_type(expr
->cast_type
);
1162 size
= expr
->cast_type
->bit_size
;
1164 if (!evaluate_expression(expr
->cast_expression
))
1166 size
= expr
->cast_expression
->ctype
->bit_size
;
1169 warn(expr
->pos
, "cannot size expression");
1172 expr
->type
= EXPR_VALUE
;
1173 expr
->value
= size
>> 3;
1174 expr
->ctype
= size_t_ctype
;
1175 return size_t_ctype
;
1178 static int context_clash(struct symbol
*sym1
, struct symbol
*sym2
)
1180 unsigned long clash
= (sym1
->ctype
.context
^ sym2
->ctype
.context
);
1181 clash
&= (sym1
->ctype
.contextmask
& sym2
->ctype
.contextmask
);
1185 static int evaluate_arguments(struct symbol
*f
, struct symbol
*fn
, struct expression_list
*head
)
1187 struct expression
*expr
;
1188 struct symbol_list
*argument_types
= fn
->arguments
;
1189 struct symbol
*argtype
;
1192 PREPARE_PTR_LIST(argument_types
, argtype
);
1193 FOR_EACH_PTR (head
, expr
) {
1194 struct expression
**p
= THIS_ADDRESS(expr
);
1195 struct symbol
*ctype
, *target
;
1196 ctype
= evaluate_expression(expr
);
1201 if (context_clash(f
, ctype
))
1202 warn(expr
->pos
, "argument %d used in wrong context", i
);
1204 ctype
= degenerate(expr
);
1207 if (!target
&& ctype
->bit_size
< bits_in_int
)
1208 target
= &int_ctype
;
1210 static char where
[30];
1211 examine_symbol_type(target
);
1212 sprintf(where
, "argument %d", i
);
1213 compatible_assignment_types(expr
, target
, p
, ctype
, where
);
1217 NEXT_PTR_LIST(argtype
);
1219 FINISH_PTR_LIST(argtype
);
1223 static int evaluate_initializer(struct symbol
*ctype
, struct expression
**ep
, unsigned long offset
);
1224 static int evaluate_array_initializer(struct symbol
*ctype
, struct expression
*expr
, unsigned long offset
)
1226 struct expression
*entry
;
1230 FOR_EACH_PTR(expr
->expr_list
, entry
) {
1231 struct expression
**p
= THIS_ADDRESS(entry
);
1233 if (entry
->type
== EXPR_INDEX
) {
1234 current
= entry
->idx_to
;
1237 evaluate_initializer(ctype
, p
, offset
+ current
*(ctype
->bit_size
>>3));
1245 static int evaluate_struct_or_union_initializer(struct symbol
*ctype
, struct expression
*expr
, int multiple
, unsigned long offset
)
1247 struct expression
*entry
;
1250 PREPARE_PTR_LIST(ctype
->symbol_list
, sym
);
1251 FOR_EACH_PTR(expr
->expr_list
, entry
) {
1252 struct expression
**p
= THIS_ADDRESS(entry
);
1254 if (entry
->type
== EXPR_IDENTIFIER
) {
1255 struct ident
*ident
= entry
->expr_ident
;
1256 /* We special-case the "already right place" case */
1257 if (sym
&& sym
->ident
== ident
)
1259 RESET_PTR_LIST(sym
);
1262 warn(entry
->pos
, "unknown named initializer '%s'", show_ident(ident
));
1265 if (sym
->ident
== ident
)
1273 warn(expr
->pos
, "too many initializers for struct/union");
1277 evaluate_initializer(sym
, p
, offset
+ sym
->offset
);
1281 FINISH_PTR_LIST(sym
);
1287 * Initializers are kind of like assignments. Except
1288 * they can be a hell of a lot more complex.
1290 static int evaluate_initializer(struct symbol
*ctype
, struct expression
**ep
, unsigned long offset
)
1292 struct expression
*expr
= *ep
;
1295 * Simple non-structure/array initializers are the simple
1296 * case, and look (and parse) largely like assignments.
1298 if (expr
->type
!= EXPR_INITIALIZER
) {
1300 struct symbol
*rtype
= evaluate_expression(expr
);
1302 struct expression
*pos
;
1304 // FIXME! char array[] = "string" special case
1305 // should _not_ degenerate.
1306 rtype
= degenerate(expr
);
1307 compatible_assignment_types(expr
, ctype
, ep
, rtype
, "initializer");
1308 /* strings are special: char arrays */
1309 if (rtype
->type
== SYM_ARRAY
)
1310 size
= get_expression_value(rtype
->array_size
);
1312 * Don't bother creating a position expression for
1313 * the simple initializer cases that don't need it.
1315 * We need a position if the initializer has a byte
1316 * offset, _or_ if we're initializing a bitfield.
1318 if (offset
|| ctype
->fieldwidth
) {
1319 pos
= alloc_expression(expr
->pos
, EXPR_POS
);
1320 pos
->init_offset
= offset
;
1321 pos
->init_sym
= ctype
;
1322 pos
->init_expr
= *ep
;
1323 pos
->ctype
= expr
->ctype
;
1330 expr
->ctype
= ctype
;
1331 if (ctype
->type
== SYM_NODE
)
1332 ctype
= ctype
->ctype
.base_type
;
1334 switch (ctype
->type
) {
1337 return evaluate_array_initializer(ctype
->ctype
.base_type
, expr
, offset
);
1339 return evaluate_struct_or_union_initializer(ctype
, expr
, 0, offset
);
1341 return evaluate_struct_or_union_initializer(ctype
, expr
, 1, offset
);
1345 warn(expr
->pos
, "unexpected compound initializer");
1349 static int get_as(struct symbol
*sym
)
1357 mod
= sym
->ctype
.modifiers
;
1358 if (sym
->type
== SYM_NODE
) {
1359 sym
= sym
->ctype
.base_type
;
1360 as
|= sym
->ctype
.as
;
1361 mod
|= sym
->ctype
.modifiers
;
1364 * You can always throw a value away by casting to
1365 * "void" - that's an implicit "force". Note that
1366 * the same is _not_ true of "void *".
1368 if (sym
== &void_ctype
)
1372 * At least for now, allow casting to a "unsigned long".
1373 * That's how we do things like pointer arithmetic and
1374 * store pointers to registers.
1376 if (sym
== &ulong_ctype
)
1379 if (sym
&& sym
->type
== SYM_PTR
) {
1380 sym
= sym
->ctype
.base_type
;
1381 as
|= sym
->ctype
.as
;
1382 mod
|= sym
->ctype
.modifiers
;
1384 if (mod
& MOD_FORCE
)
1389 static struct symbol
*evaluate_cast(struct expression
*expr
)
1391 struct expression
*target
= expr
->cast_expression
;
1392 struct symbol
*ctype
= examine_symbol_type(expr
->cast_type
);
1394 expr
->ctype
= ctype
;
1395 expr
->cast_type
= ctype
;
1398 * Special case: a cast can be followed by an
1399 * initializer, in which case we need to pass
1400 * the type value down to that initializer rather
1401 * than trying to evaluate it as an expression
1403 * A more complex case is when the initializer is
1404 * dereferenced as part of a post-fix expression.
1405 * We need to produce an expression that can be dereferenced.
1407 if (target
->type
== EXPR_INITIALIZER
) {
1408 struct symbol
*sym
= alloc_symbol(expr
->pos
, SYM_NODE
);
1409 struct expression
*addr
= alloc_expression(expr
->pos
, EXPR_SYMBOL
);
1411 sym
->ctype
.base_type
= ctype
;
1412 sym
->initializer
= expr
->cast_expression
;
1413 evaluate_symbol(sym
);
1415 addr
->ctype
= NULL
; /* Lazy eval */
1418 expr
->type
= EXPR_PREOP
;
1421 expr
->ctype
= ctype
;
1425 evaluate_expression(target
);
1428 if (!get_as(ctype
) && get_as(target
->ctype
) > 0)
1429 warn(expr
->pos
, "cast removes address space of expression");
1432 * Casts of constant values are special: they
1433 * can be NULL, and thus need to be simplified
1436 if (target
->type
== EXPR_VALUE
)
1437 cast_value(expr
, ctype
, target
, target
->ctype
);
1443 * Evaluate a call expression with a symbol. This
1444 * should expand inline functions, and evaluate
1447 static int evaluate_symbol_call(struct expression
*expr
)
1449 struct expression
*fn
= expr
->fn
;
1450 struct symbol
*ctype
= fn
->ctype
;
1452 if (fn
->type
!= EXPR_PREOP
)
1455 if (ctype
->op
&& ctype
->op
->evaluate
)
1456 return ctype
->op
->evaluate(expr
);
1458 if (ctype
->ctype
.modifiers
& MOD_INLINE
) {
1460 struct symbol
*curr
= current_fn
;
1461 unsigned long context
= current_context
;
1462 unsigned long mask
= current_contextmask
;
1464 current_context
|= ctype
->ctype
.context
;
1465 current_contextmask
|= ctype
->ctype
.contextmask
;
1466 current_fn
= ctype
->ctype
.base_type
;
1467 ret
= inline_function(expr
, ctype
);
1469 /* restore the old function context */
1471 current_context
= context
;
1472 current_contextmask
= mask
;
1479 static struct symbol
*evaluate_call(struct expression
*expr
)
1482 struct symbol
*ctype
, *sym
;
1483 struct expression
*fn
= expr
->fn
;
1484 struct expression_list
*arglist
= expr
->args
;
1486 if (!evaluate_expression(fn
))
1488 sym
= ctype
= fn
->ctype
;
1489 if (ctype
->type
== SYM_NODE
)
1490 ctype
= ctype
->ctype
.base_type
;
1491 if (ctype
->type
== SYM_PTR
|| ctype
->type
== SYM_ARRAY
)
1492 ctype
= ctype
->ctype
.base_type
;
1493 if (!evaluate_arguments(sym
, ctype
, arglist
))
1495 if (ctype
->type
!= SYM_FN
) {
1496 warn(expr
->pos
, "not a function %s", show_ident(sym
->ident
));
1499 args
= expression_list_size(expr
->args
);
1500 fnargs
= symbol_list_size(ctype
->arguments
);
1502 warn(expr
->pos
, "not enough arguments for function %s", show_ident(sym
->ident
));
1503 if (args
> fnargs
&& !ctype
->variadic
)
1504 warn(expr
->pos
, "too many arguments for function %s", show_ident(sym
->ident
));
1505 if (sym
->type
== SYM_NODE
) {
1506 if (evaluate_symbol_call(expr
))
1509 expr
->ctype
= ctype
->ctype
.base_type
;
1513 struct symbol
*evaluate_expression(struct expression
*expr
)
1520 switch (expr
->type
) {
1522 warn(expr
->pos
, "value expression without a type");
1525 return evaluate_string(expr
);
1527 return evaluate_symbol_expression(expr
);
1529 if (!evaluate_expression(expr
->left
))
1531 if (!evaluate_expression(expr
->right
))
1533 return evaluate_binop(expr
);
1535 return evaluate_logical(expr
);
1537 if (!evaluate_expression(expr
->left
))
1539 if (!evaluate_expression(expr
->right
))
1541 return evaluate_comma(expr
);
1543 if (!evaluate_expression(expr
->left
))
1545 if (!evaluate_expression(expr
->right
))
1547 return evaluate_compare(expr
);
1548 case EXPR_ASSIGNMENT
:
1549 if (!evaluate_expression(expr
->left
))
1551 if (!evaluate_expression(expr
->right
))
1553 return evaluate_assignment(expr
);
1555 if (!evaluate_expression(expr
->unop
))
1557 return evaluate_preop(expr
);
1559 if (!evaluate_expression(expr
->unop
))
1561 return evaluate_postop(expr
);
1563 return evaluate_cast(expr
);
1565 return evaluate_sizeof(expr
);
1567 return evaluate_member_dereference(expr
);
1569 return evaluate_call(expr
);
1571 warn(expr
->pos
, "bitfield generated by parser");
1573 case EXPR_CONDITIONAL
:
1574 if (!evaluate_conditional(expr
->conditional
))
1576 if (!evaluate_expression(expr
->cond_false
))
1578 if (expr
->cond_true
&& !evaluate_expression(expr
->cond_true
))
1580 return evaluate_conditional_expression(expr
);
1581 case EXPR_STATEMENT
:
1582 expr
->ctype
= evaluate_statement(expr
->statement
);
1586 expr
->ctype
= &ptr_ctype
;
1590 /* Evaluate the type of the symbol .. */
1591 evaluate_symbol(expr
->symbol
);
1592 /* .. but the type of the _expression_ is a "type" */
1593 expr
->ctype
= &type_ctype
;
1596 /* These can not exist as stand-alone expressions */
1597 case EXPR_INITIALIZER
:
1598 case EXPR_IDENTIFIER
:
1601 warn(expr
->pos
, "internal front-end error: initializer in expression");
1607 void check_duplicates(struct symbol
*sym
)
1609 struct symbol
*next
= sym
;
1611 while ((next
= next
->same_symbol
) != NULL
) {
1612 const char *typediff
;
1613 evaluate_symbol(next
);
1614 typediff
= type_difference(sym
, next
, 0, 0);
1616 warn(sym
->pos
, "symbol '%s' redeclared with different type (originally declared at %s:%d) - %s",
1617 show_ident(sym
->ident
),
1618 input_streams
[next
->pos
.stream
].name
, next
->pos
.line
, typediff
);
1624 struct symbol
*evaluate_symbol(struct symbol
*sym
)
1626 struct symbol
*base_type
;
1631 sym
= examine_symbol_type(sym
);
1632 base_type
= sym
->ctype
.base_type
;
1636 /* Evaluate the initializers */
1637 if (sym
->initializer
) {
1638 int count
= evaluate_initializer(sym
, &sym
->initializer
, 0);
1639 if (base_type
->type
== SYM_ARRAY
&& !base_type
->array_size
) {
1640 int bit_size
= count
* base_type
->ctype
.base_type
->bit_size
;
1641 base_type
->array_size
= alloc_const_expression(sym
->pos
, count
);
1642 base_type
->bit_size
= bit_size
;
1643 sym
->array_size
= base_type
->array_size
;
1644 sym
->bit_size
= bit_size
;
1648 /* And finally, evaluate the body of the symbol too */
1649 if (base_type
->type
== SYM_FN
) {
1652 FOR_EACH_PTR(base_type
->arguments
, s
) {
1656 if (base_type
->stmt
) {
1657 current_fn
= base_type
;
1658 current_contextmask
= sym
->ctype
.contextmask
;
1659 current_context
= sym
->ctype
.context
;
1660 evaluate_statement(base_type
->stmt
);
1667 struct symbol
*evaluate_return_expression(struct statement
*stmt
)
1669 struct expression
*expr
= stmt
->expression
;
1670 struct symbol
*ctype
, *fntype
;
1672 fntype
= current_fn
->ctype
.base_type
;
1673 if (!fntype
|| fntype
== &void_ctype
) {
1675 warn(expr
->pos
, "return expression in %s function", fntype
?"void":"typeless");
1680 warn(stmt
->pos
, "return with no return value");
1683 ctype
= evaluate_expression(expr
);
1686 ctype
= degenerate(expr
);
1687 expr
->ctype
= ctype
;
1688 compatible_assignment_types(expr
, fntype
, &expr
, ctype
, "return expression");
1689 stmt
->expression
= expr
;
1693 static void evaluate_if_statement(struct statement
*stmt
)
1695 struct expression
*expr
= stmt
->if_conditional
;
1696 struct symbol
*ctype
;
1701 ctype
= evaluate_conditional(expr
);
1705 evaluate_statement(stmt
->if_true
);
1706 evaluate_statement(stmt
->if_false
);
1709 struct symbol
*evaluate_statement(struct statement
*stmt
)
1714 switch (stmt
->type
) {
1716 return evaluate_return_expression(stmt
);
1718 case STMT_EXPRESSION
:
1719 evaluate_expression(stmt
->expression
);
1720 return degenerate(stmt
->expression
);
1722 case STMT_COMPOUND
: {
1723 struct statement
*s
;
1724 struct symbol
*type
= NULL
;
1727 /* Evaluate each symbol in the compound statement */
1728 FOR_EACH_PTR(stmt
->syms
, sym
) {
1729 evaluate_symbol(sym
);
1731 evaluate_symbol(stmt
->ret
);
1734 * Then, evaluate each statement, making the type of the
1735 * compound statement be the type of the last statement
1738 FOR_EACH_PTR(stmt
->stmts
, s
) {
1739 type
= evaluate_statement(s
);
1744 evaluate_if_statement(stmt
);
1747 evaluate_conditional(stmt
->iterator_pre_condition
);
1748 evaluate_conditional(stmt
->iterator_post_condition
);
1749 evaluate_statement(stmt
->iterator_pre_statement
);
1750 evaluate_statement(stmt
->iterator_statement
);
1751 evaluate_statement(stmt
->iterator_post_statement
);
1754 evaluate_expression(stmt
->switch_expression
);
1755 evaluate_statement(stmt
->switch_statement
);
1758 evaluate_expression(stmt
->case_expression
);
1759 evaluate_expression(stmt
->case_to
);
1760 evaluate_statement(stmt
->case_statement
);
1763 evaluate_statement(stmt
->label_statement
);
1766 evaluate_expression(stmt
->goto_expression
);
1771 /* FIXME! Do the asm parameter evaluation! */