2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 /* $Id: l_ev_ord.c,v 1.5 1994/06/27 08:00:49 ceriel Exp $ */
6 /* Lint evaluation order checking */
12 #include <alloc.h> /* for st_free */
13 #include "interface.h"
16 #include <flt_arith.h>
18 #include "arith.h" /* definition arith */
19 #include "label.h" /* definition label */
23 #include "code.h" /* RVAL etc */
32 extern char *symbol2str();
34 PRIVATE check_ev_order();
36 check_and_merge(expr, espp, esp)
38 struct expr_state **espp, *esp;
40 /* Checks for undefined evaluation orders in case of a non-sequencing operator.
41 * In addition the sets of used and set variables of both expressions are
43 * *espp will be pointing to this new list. esp is used for this list.
45 register struct expr_state **pp, *p1, *p2;
46 int oper = expr->OP_OPER;
48 (oper == '?' || oper == OR || oper == AND || oper ==',');
50 for (p1 = *espp; p1; p1 = p1->next) {
51 /* scan the list esp for the same variable */
55 if ( /* p1 and p2 refer to the same location */
56 p1->es_idf == p2->es_idf
57 && p1->es_offset == p2->es_offset
61 check_ev_order(p1, p2, expr);
64 p1->es_used |= p2->es_used;
65 p1->es_referred |= p2->es_referred;
66 p1->es_set |= p2->es_set;
68 /* and remove the entry from esp */
74 /* skip over the entry in esp */
80 /* If there is anything left in the list esp, this is put in
81 front of the list *espp is now pointing to, and *espp will be
82 left pointing to this new list.
94 check_ev_order(esp1, esp2, expr)
95 struct expr_state *esp1, *esp2;
98 if ( (esp1->es_used && esp2->es_set)
99 || (esp1->es_set && esp2->es_used)
100 || (esp1->es_set && esp2->es_set)
103 "result of %s depends on evaluation order on %s",
104 symbol2str(expr->OP_OPER),
105 esp1->es_idf->id_text);