From 919cbebac4a66dfde36aa2accd84abdba2909080 Mon Sep 17 00:00:00 2001 From: lemon Date: Fri, 17 Apr 2026 20:06:51 +0200 Subject: c: fix using array as condition value Decays to pointer --- src/c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/c.c b/src/c.c index 21deb20..20c53ff 100644 --- a/src/c.c +++ b/src/c.c @@ -1267,7 +1267,7 @@ Unary: Expr *sub; span.sl = tk.span.sl; span.ex = ex.span.ex; - if (!isscalar(ex.ty) && !isptrcvt(ex.ty)) + if (!isptrcvt(ex.ty) && !isscalar(ex.ty)) error(&ex.span, "?: condition is not a scalar type: '%ty'", ex.ty); tmp = commaexpr(cm); joinspan(&tk.span.ex, tmp.span.ex); @@ -4462,7 +4462,7 @@ stmt(CComp *cm, Function *fn) expect(cm, '(', NULL); ex = commaexpr(cm); expect(cm, ')', NULL); - if (!isscalar(ex.ty)) + if (!isptrcvt(ex.ty) && !isscalar(ex.ty)) error(&ex.span, "'if' condition is not a scalar '%ty'", ex.ty); tr = fl = end = NULL; EMITS { -- cgit v1.2.3