Skip to content

Commit 0be990d

Browse files
committed
Fixed to handle composite types in conditional expressions
1 parent 2c17b51 commit 0be990d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/enode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,17 +346,17 @@ Tree condtree(Tree e, Tree l, Tree r) {
346346
if (isarith(xty) && isarith(yty))
347347
ty = binary(xty, yty);
348348
else if (eqtype(xty, yty, 1))
349-
ty = unqual(xty);
349+
ty = compose(xty, yty);
350350
else if (isptr(xty) && isnullptr(r))
351351
ty = xty;
352352
else if (isnullptr(l) && isptr(yty))
353353
ty = yty;
354354
else if (isptr(xty) && !isfunc(xty->type) && isvoidptr(yty)
355355
|| isptr(yty) && !isfunc(yty->type) && isvoidptr(xty))
356356
ty = voidptype;
357-
else if ((isptr(xty) && isptr(yty)
358-
&& eqtype(unqual(xty->type), unqual(yty->type), 1)))
359-
ty = xty;
357+
else if (isptr(xty) && isptr(yty)
358+
&& eqtype(unqual(xty->type), unqual(yty->type), 1))
359+
ty = ptr(compose(unqual(xty->type), unqual(yty->type)));
360360
else {
361361
typeerror(COND, l, r);
362362
return consttree(0, inttype);

0 commit comments

Comments
 (0)