diff options
| author | 2026-04-17 20:06:51 +0200 | |
|---|---|---|
| committer | 2026-04-17 20:06:51 +0200 | |
| commit | 919cbebac4a66dfde36aa2accd84abdba2909080 (patch) | |
| tree | d3b875fbd6c09d27a254a063580f187231782020 | |
| parent | 5293b3cc8876cbc775875974e0c1b7e32952b140 (diff) | |
c: fix using array as condition value
Decays to pointer
| -rw-r--r-- | src/c.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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 { |