Lines Matching refs:n
6 int n; member
15 complex(Node *n) in complex() argument
18 if(n == Z) in complex()
21 nearln = n->lineno; in complex()
23 if(n->op != OCONST) in complex()
24 prtree(n, "pre complex"); in complex()
25 if(tcom(n)) in complex()
28 comma(n); in complex()
30 if(n->op != OCONST) in complex()
31 prtree(n, "t complex"); in complex()
32 ccom(n); in complex()
34 if(n->op != OCONST) in complex()
35 prtree(n, "c complex"); in complex()
36 acom(n); in complex()
38 if(n->op != OCONST) in complex()
39 prtree(n, "a complex"); in complex()
40 xcom(n); in complex()
42 if(n->op != OCONST) in complex()
43 prtree(n, "x complex"); in complex()
58 tcom(Node *n) in tcom() argument
61 return tcomo(n, ADDROF); in tcom()
65 tcomo(Node *n, int f) in tcomo() argument
72 if(n == Z) { in tcomo()
76 n->addable = 0; in tcomo()
77 l = n->left; in tcomo()
78 r = n->right; in tcomo()
80 switch(n->op) { in tcomo()
82 diag(n, "unknown op in type complex: %O", n->op); in tcomo()
89 *n = *n->left; in tcomo()
90 if(n->type == T) in tcomo()
95 if(n->type == T) in tcomo()
97 if(n->type->width == types[TLONG]->width) { in tcomo()
103 if(isfunct(n)) in tcomo()
105 if(tcompat(n, l->type, n->type, tcast)) in tcomo()
111 if(n->type->etype != TVOID) in tcomo()
112 warn(n, "null return of a typed function"); in tcomo()
117 typeext(n->type, l); in tcomo()
118 if(tcompat(n, n->type, l->type, tasign)) in tcomo()
120 constas(n, n->type, l->type); in tcomo()
121 if(!sametype(n->type, l->type)) { in tcomo()
123 l->type = n->type; in tcomo()
124 n->left = l; in tcomo()
129 n->op = OAS; in tcomo()
135 if(tlvalue(l) || tcompat(n, l->type, r->type, tasign)) in tcomo()
140 n->right = r; in tcomo()
142 n->type = l->type; in tcomo()
151 if(isfunct(n)) in tcomo()
154 if(tcompat(n, l->type, r->type, tasign)) in tcomo()
156 constas(n, l->type, r->type); in tcomo()
160 n->right = r; in tcomo()
162 n->type = l->type; in tcomo()
172 if(isfunct(n)) in tcomo()
175 if(tcompat(n, l->type, r->type, tasadd)) in tcomo()
177 constas(n, l->type, r->type); in tcomo()
179 arith(n, 0); in tcomo()
180 while(n->left->op == OCAST) in tcomo()
181 n->left = n->left->left; in tcomo()
182 if(!sametype(t, n->type) && !mixedasop(t, n->type)) { in tcomo()
183 r = new1(OCAST, n->right, Z); in tcomo()
185 n->right = r; in tcomo()
186 n->type = t; in tcomo()
199 if(isfunct(n)) in tcomo()
202 if(tcompat(n, l->type, r->type, tmul)) in tcomo()
204 constas(n, l->type, r->type); in tcomo()
206 arith(n, 0); in tcomo()
207 while(n->left->op == OCAST) in tcomo()
208 n->left = n->left->left; in tcomo()
209 if(!sametype(t, n->type) && !mixedasop(t, n->type)) { in tcomo()
210 r = new1(OCAST, n->right, Z); in tcomo()
212 n->right = r; in tcomo()
213 n->type = t; in tcomo()
215 if(typeu[n->type->etype]) { in tcomo()
216 if(n->op == OASDIV) in tcomo()
217 n->op = OASLDIV; in tcomo()
218 if(n->op == OASMUL) in tcomo()
219 n->op = OASLMUL; in tcomo()
231 if(isfunct(n)) in tcomo()
233 if(tcompat(n, l->type, r->type, tand)) in tcomo()
235 n->type = l->type; in tcomo()
236 n->right = new1(OCAST, r, Z); in tcomo()
237 n->right->type = types[TINT]; in tcomo()
238 if(typeu[n->type->etype]) { in tcomo()
239 if(n->op == OASASHR) in tcomo()
240 n->op = OASLSHR; in tcomo()
254 if(isfunct(n)) in tcomo()
256 if(tcompat(n, l->type, r->type, tand)) in tcomo()
259 arith(n, 0); in tcomo()
260 while(n->left->op == OCAST) in tcomo()
261 n->left = n->left->left; in tcomo()
262 if(!sametype(t, n->type) && !mixedasop(t, n->type)) { in tcomo()
263 r = new1(OCAST, n->right, Z); in tcomo()
265 n->right = r; in tcomo()
266 n->type = t; in tcomo()
268 if(typeu[n->type->etype]) { in tcomo()
269 if(n->op == OASMOD) in tcomo()
270 n->op = OASLMOD; in tcomo()
282 if(isfunct(n)) in tcomo()
284 if(tcompat(n, l->type, types[TINT], tadd)) in tcomo()
286 n->type = l->type; in tcomo()
287 if(n->type->etype == TIND) in tcomo()
288 if(n->type->link->width < 1) { in tcomo()
289 snap(n->type->link); in tcomo()
290 if(n->type->link->width < 1) in tcomo()
291 diag(n, "inc/dec of a void pointer"); in tcomo()
300 if(isfunct(n)) in tcomo()
304 if(tcompat(n, l->type, r->type, trel)) in tcomo()
306 arith(n, 0); in tcomo()
307 n->type = types[TINT]; in tcomo()
317 if(isfunct(n)) in tcomo()
321 if(tcompat(n, l->type, r->type, trel)) in tcomo()
323 arith(n, 0); in tcomo()
324 if(typeu[n->type->etype]) in tcomo()
325 n->op = logrel[relindex(n->op)]; in tcomo()
326 n->type = types[TINT]; in tcomo()
344 n->type = r->type; in tcomo()
350 n->type = r->type; in tcomo()
357 if(isfunct(n)) in tcomo()
359 if(tcompat(n, l->type, r->type, tadd)) in tcomo()
361 arith(n, 1); in tcomo()
368 if(isfunct(n)) in tcomo()
370 if(tcompat(n, l->type, r->type, tsub)) in tcomo()
372 arith(n, 1); in tcomo()
382 if(isfunct(n)) in tcomo()
384 if(tcompat(n, l->type, r->type, tmul)) in tcomo()
386 arith(n, 1); in tcomo()
387 if(typeu[n->type->etype]) { in tcomo()
388 if(n->op == ODIV) in tcomo()
389 n->op = OLDIV; in tcomo()
390 if(n->op == OMUL) in tcomo()
391 n->op = OLMUL; in tcomo()
401 if(isfunct(n)) in tcomo()
403 if(tcompat(n, l->type, r->type, tand)) in tcomo()
405 n->right = Z; in tcomo()
406 arith(n, 1); in tcomo()
407 n->right = new1(OCAST, r, Z); in tcomo()
408 n->right->type = types[TINT]; in tcomo()
409 if(typeu[n->type->etype]) in tcomo()
410 if(n->op == OASHR) in tcomo()
411 n->op = OLSHR; in tcomo()
420 if(isfunct(n)) in tcomo()
422 if(tcompat(n, l->type, r->type, tand)) in tcomo()
424 arith(n, 1); in tcomo()
432 if(isfunct(n)) in tcomo()
434 if(tcompat(n, l->type, r->type, tand)) in tcomo()
436 arith(n, 1); in tcomo()
437 if(typeu[n->type->etype]) in tcomo()
438 n->op = OLMOD; in tcomo()
444 if(isfunct(n)) in tcomo()
451 n->op = OADD; in tcomo()
452 n->right = r; in tcomo()
453 n->left = l; in tcomo()
457 if(tcompat(n, l->type, r->type, tsub)) in tcomo()
459 arith(n, 1); in tcomo()
465 if(isfunct(n)) in tcomo()
468 if(!machcap(n)) { in tcomo()
473 n->op = OSUB; in tcomo()
474 n->right = r; in tcomo()
475 n->left = l; in tcomo()
479 if(tcompat(n, l->type, r->type, tsub)) in tcomo()
482 arith(n, 1); in tcomo()
488 if(isfunct(n)) in tcomo()
491 if(!machcap(n)) { in tcomo()
496 n->op = OXOR; in tcomo()
497 n->right = r; in tcomo()
498 n->left = l; in tcomo()
502 if(tcompat(n, l->type, r->type, tand)) in tcomo()
505 arith(n, 1); in tcomo()
511 if(isfunct(n)) in tcomo()
513 if(tcompat(n, T, l->type, tnot)) in tcomo()
515 n->type = types[TINT]; in tcomo()
523 if(tcompat(n, T, l->type, tnot) | in tcomo()
524 tcompat(n, T, r->type, tnot)) in tcomo()
526 n->type = types[TINT]; in tcomo()
533 n->type = r->type; in tcomo()
543 diag(n, "signof bitfield"); in tcomo()
546 n->type = l->type; in tcomo()
548 if(n->type == T) in tcomo()
550 if(n->type->width < 0) { in tcomo()
551 diag(n, "signof undefined type"); in tcomo()
554 n->op = OCONST; in tcomo()
555 n->left = Z; in tcomo()
556 n->right = Z; in tcomo()
557 n->vconst = convvtox(signature(n->type), TULONG); in tcomo()
558 n->type = types[TULONG]; in tcomo()
567 diag(n, "sizeof bitfield"); in tcomo()
570 n->type = l->type; in tcomo()
572 if(n->type == T) in tcomo()
574 if(n->type->width <= 0) { in tcomo()
575 diag(n, "sizeof undefined type"); in tcomo()
578 if(n->type->etype == TFUNC) { in tcomo()
579 diag(n, "sizeof function"); in tcomo()
582 n->op = OCONST; in tcomo()
583 n->left = Z; in tcomo()
584 n->right = Z; in tcomo()
585 n->vconst = convvtox(n->type->width, TINT); in tcomo()
586 n->type = types[TINT]; in tcomo()
596 n->left = l; in tcomo()
598 if(tcompat(n, T, l->type, tfunct)) in tcomo()
602 n->type = l->type->link; in tcomo()
606 diag(n, "function args not checked: %F", l); in tcomo()
608 dpcheck(n); in tcomo()
612 if(n->type == T) { in tcomo()
613 diag(n, "name not declared: %F", n); in tcomo()
616 if(n->type->etype == TENUM) { in tcomo()
617 n->op = OCONST; in tcomo()
618 n->type = n->sym->tenum; in tcomo()
619 if(!typefd[n->type->etype]) in tcomo()
620 n->vconst = n->sym->vconst; in tcomo()
622 n->fconst = n->sym->fconst; in tcomo()
625 n->addable = 1; in tcomo()
626 if(n->class == CEXREG) { in tcomo()
627 n->op = OREGISTER; in tcomo()
629 n->op = OEXREG; in tcomo()
630 n->reg = n->sym->offset; in tcomo()
631 n->xoffset = 0; in tcomo()
637 if(n->type->link != types[TRUNE]) { in tcomo()
644 n->op = ONAME; in tcomo()
645 n->xoffset = outlstring(n->rstring, n->type->width); in tcomo()
646 n->addable = 1; in tcomo()
650 if(n->type->link != types[TCHAR]) { in tcomo()
657 n->op = ONAME; in tcomo()
658 n->xoffset = outstring(n->cstring, n->type->width); in tcomo()
659 n->addable = 1; in tcomo()
668 if(tcompat(n, T, l->type, tdot)) in tcomo()
670 if(tcomd(n)) in tcomo()
680 diag(n, "address of a bit field"); in tcomo()
684 diag(n, "address of a register"); in tcomo()
687 n->type = typ(TIND, l->type); in tcomo()
688 n->type->width = types[TIND]->width; in tcomo()
694 if(tcompat(n, T, l->type, tindir)) in tcomo()
696 n->type = l->type->link; in tcomo()
697 n->addable = 1; in tcomo()
701 if(tcomx(n)) in tcomo()
705 t = n->type; in tcomo()
712 diag(n, "structure not fully declared %s", t->tag->name); in tcomo()
714 diag(n, "structure not fully declared"); in tcomo()
722 warn(n, "address of array/func ignored"); in tcomo()
727 if(tlvalue(n)) in tcomo()
730 *l = *n; in tcomo()
731 n->op = OADDR; in tcomo()
734 n->left = l; in tcomo()
735 n->right = Z; in tcomo()
736 n->addable = 0; in tcomo()
737 n->type = typ(TIND, l->type); in tcomo()
738 n->type->width = types[TIND]->width; in tcomo()
742 n->type = T; in tcomo()
747 tcoma(Node *l, Node *n, Type *t, int f) in tcoma() argument
755 if(n == Z) { in tcoma()
757 diag(n, "not enough function arguments: %F", l); in tcoma()
762 if(n->op == OLIST) { in tcoma()
763 o = tcoma(l, n->left, t, 0); in tcoma()
769 return o | tcoma(l, n->right, t, 1); in tcoma()
773 if(tcom(n) || tcompat(n, T, n->type, targ)) in tcoma()
776 diag(n, "too many function arguments: %F", l); in tcoma()
780 typeext(t, n); in tcoma()
781 if(stcompat(nodproto, t, n->type, tasign)) { in tcoma()
783 n->type, t, l); in tcoma()
798 switch(n->type->etype) in tcoma()
813 if(t != T && !sametype(t, n->type)) { in tcoma()
815 *n1 = *n; in tcoma()
816 n->op = OCAST; in tcoma()
817 n->left = n1; in tcoma()
818 n->right = Z; in tcoma()
819 n->type = t; in tcoma()
820 n->addable = 0; in tcoma()
826 tcomd(Node *n) in tcomd() argument
832 t = dotsearch(n->sym, n->left->type->link, n, &o); in tcomd()
834 diag(n, "not a member of struct/union: %F", n); in tcomd()
837 makedot(n, t, o); in tcomd()
842 tcomx(Node *n) in tcomx() argument
849 if(n->type->etype != TSTRUCT) { in tcomx()
850 diag(n, "constructor must be a structure"); in tcomx()
853 l = invert(n->left); in tcomx()
854 n->left = l; in tcomx()
855 al = &n->left; in tcomx()
856 for(t = n->type->link; t != T; t = t->down) { in tcomx()
858 diag(n, "constructor list too short"); in tcomx()
874 if(tcompat(n, t, r->type, tasign)) in tcomx()
876 constas(n, t, r->type); in tcomx()
884 diag(n, "constructor list too long"); in tcomx()
891 tlvalue(Node *n) in tlvalue() argument
894 if(!n->addable) { in tlvalue()
895 diag(n, "not an l-value"); in tlvalue()
909 comargs(Com *com, Node *n) in comargs() argument
911 if(n != Z && n->op == OLIST){ in comargs()
912 n->left = comargs(com, n->left); in comargs()
913 n->right = comargs(com, n->right); in comargs()
915 return commas(com, n); in comargs()
919 commas(Com *com, Node *n) in commas() argument
923 if(n == Z) in commas()
924 return n; in commas()
925 switch(n->op){ in commas()
932 return n; in commas()
935 t = commas(com, n->left); in commas()
936 if(com->n >= nelem(com->t)) in commas()
937 fatal(n, "comma list overflow"); in commas()
938 com->t[com->n++] = t; in commas()
939 return commas(com, n->right); in commas()
942 n->left = commas(com, n->left); in commas()
943 n->right = comargs(com, n->right); in commas()
944 return n; in commas()
947 n->left = commas(com, n->left); in commas()
948 comma(n->right->left); in commas()
949 comma(n->right->right); in commas()
950 return n; in commas()
954 n->left = commas(com, n->left); in commas()
955 comma(n->right); in commas()
956 return n; in commas()
959 comma(n->left); in commas()
960 return n; in commas()
962 n->left = commas(com, n->left); in commas()
963 if(n->right != Z) in commas()
964 n->right = commas(com, n->right); in commas()
965 return n; in commas()
969 comma(Node *n) in comma() argument
974 com.n = 0; in comma()
975 nn = commas(&com, n); in comma()
976 if(com.n > 0){ in comma()
977 if(debug['y'])print("n=%d\n", com.n); in comma()
979 if(nn != n) in comma()
980 *n = *nn; in comma()
981 while(com.n > 0){ in comma()
982 if(debug['y']) prtree(com.t[com.n-1], "tree"); in comma()
984 *nn = *n; in comma()
985 n->op = OCOMMA; in comma()
986 n->type = nn->type; in comma()
987 n->left = com.t[--com.n]; in comma()
988 n->right = nn; in comma()
989 n->lineno = n->left->lineno; in comma()
991 if(debug['y']) prtree(n, "final"); in comma()
992 }else if(n != nn) in comma()
993 fatal(n, "odd tree"); in comma()
1005 ccom(Node *n) in ccom() argument
1011 if(n == Z) in ccom()
1013 l = n->left; in ccom()
1014 r = n->right; in ccom()
1015 switch(n->op) { in ccom()
1034 if(n->op == OASLSHR || n->op == OASASHR || n->op == OASASHL) in ccom()
1036 t = n->type->width * 8; /* bits per byte */ in ccom()
1038 warn(n, "stupid shift: %lld", r->vconst); in ccom()
1045 evconst(n); in ccom()
1046 if(n->op == OCONST) in ccom()
1049 if(nocast(l->type, n->type) && in ccom()
1050 (!typefd[l->type->etype] || typeu[l->type->etype] && typeu[n->type->etype])) { in ccom()
1051 l->type = n->type; in ccom()
1052 *n = *l; in ccom()
1061 *n = *r->right; in ccom()
1063 *n = *r->left; in ccom()
1076 l->left->type = n->type; in ccom()
1077 *n = *l->left; in ccom()
1085 l->left->type = n->type; in ccom()
1086 *n = *l->left; in ccom()
1105 if(compar(n, 0) || compar(n, 1)) in ccom()
1116 *n = *l; in ccom()
1121 *n = *l; in ccom()
1125 t = n->type->width * 8; /* bits per byte */ in ccom()
1127 warn(n, "stupid shift: %lld", r->vconst); in ccom()
1136 *n = *l; in ccom()
1140 *n = *r; in ccom()
1146 *n = *r; in ccom()
1150 *n = *l; in ccom()
1159 *n = *l; in ccom()
1165 diag(n, "divide check"); in ccom()
1166 *n = *r; in ccom()
1170 *n = *l; in ccom()
1179 n->op = OADD; in ccom()
1183 n->op = OADD; in ccom()
1196 *n = *r; in ccom()
1201 *n = *l; in ccom()
1210 *n = *l; in ccom()
1214 *n = *r; in ccom()
1221 if(l->op == n->op) { in ccom()
1223 n->right = l->right; in ccom()
1228 n->right = l->left; in ccom()
1235 if(r->op == n->op) { in ccom()
1237 n->left = r->right; in ccom()
1242 n->left = r->left; in ccom()
1253 *n = *l; in ccom()
1262 *n = *l; in ccom()
1263 n->vconst = 1; in ccom()
1281 evconst(n); in ccom()
1338 compar(Node *n, int reverse) in compar() argument
1356 r = n->left; in compar()
1357 l = n->right; in compar()
1358 op = comrel[relindex(n->op)]; in compar()
1360 l = n->left; in compar()
1361 r = n->right; in compar()
1362 op = n->op; in compar()
1454 xbuf, cmps[relindex(n->op)], lt); in compar()
1457 lt, cmps[relindex(n->op)], xbuf); in compar()
1458 if(debug['y']) prtree(n, "strange"); in compar()
1459 warn(n, "useless or misleading comparison: %s", cmpbuf); in compar()