cc1: Extend cmpnode() to support floats - scc - simple c99 compiler
HTML git clone git://git.simple-cc.org/scc
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit c090b15bd2998ec3d1c51956dcbd3a9dc10e8328
DIR parent e233f10476a51629c1a70b0a16fdc01157059214
HTML Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Fri, 1 May 2026 11:25:00 +0200
cc1: Extend cmpnode() to support floats
Diffstat:
M src/cmd/scc-cc/cc1/expr.c | 8 ++++++++
1 file changed, 8 insertions(+), 0 deletions(-)
---
DIR diff --git a/src/cmd/scc-cc/cc1/expr.c b/src/cmd/scc-cc/cc1/expr.c
@@ -50,6 +50,14 @@ cmpnode(Node *np, unsigned long long val)
mask = (val > 1) ? ones(np->type->size) : -1;
nodeval = (tp->prop & TSIGNED) ? sym->u.i : sym->u.u;
return (nodeval & mask) == (val & mask);
+ case FLOAT:
+ if (tp == floattype)
+ return sym->u.f == val;
+ else if (tp == doubletype)
+ return sym->u.d == val;
+ else
+ return sym->u.d == val;
+ break;
default:
abort();
}