From a789626b303f7d0fea7f6b780538baaf43806dcc Mon Sep 17 00:00:00 2001 From: lufia Date: Mon, 24 May 2021 09:58:08 +0900 Subject: [PATCH 1/2] sys/src/cmd/cc: add -u option --- sys/src/cmd/cc/dcl.c | 21 +++++++++++++++++++++ sys/src/cmd/cc/lex.c | 1 + 2 files changed, 22 insertions(+) diff --git a/sys/src/cmd/cc/dcl.c b/sys/src/cmd/cc/dcl.c index 125c824c..eb3af81e 100644 --- a/sys/src/cmd/cc/dcl.c +++ b/sys/src/cmd/cc/dcl.c @@ -934,10 +934,21 @@ sametype(Type *t1, Type *t2) return rsametype(t1, t2, 5, 1); } +long typesign[] = +{ + BCHAR|BUCHAR, + BSHORT|BUSHORT, + BINT|BUINT, + BLONG|BULONG, + BVLONG|BUVLONG, + 0, +}; + int rsametype(Type *t1, Type *t2, int n, int f) { int et; + long b1, b2, *p; n--; for(;;) { @@ -1007,6 +1018,16 @@ rsametype(Type *t1, Type *t2, int n, int f) if(t2 != T && t2->etype == TVOID) return 1; } + if(debug['u'] && et == TIND) { + b1 = b2 = ~0; + if(t1 != T) + b1 = 1L<etype; + if(t2 != T) + b2 = 1L<etype; + for(p = typesign; *p; p++) + if(((b1|b2) & ~*p) == 0) + return 1; + } } } diff --git a/sys/src/cmd/cc/lex.c b/sys/src/cmd/cc/lex.c index 7c127162..dcc3d420 100644 --- a/sys/src/cmd/cc/lex.c +++ b/sys/src/cmd/cc/lex.c @@ -26,6 +26,7 @@ * -s print structure offsets (with -a or -aa) * -S print assembly * -t print type trees + * -u enable implicit conversion between type* and utype* * -V enable void* conversion warnings * -v verbose printing * -w print warnings From 4ea59e32adf9fdff147b3d0ef35e374e50f14840 Mon Sep 17 00:00:00 2001 From: lufia Date: Mon, 24 May 2021 10:31:26 +0900 Subject: [PATCH 2/2] sys/src/cmd/pcc: add -u option --- sys/src/cmd/pcc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/src/cmd/pcc.c b/sys/src/cmd/pcc.c index 5ff7672b..0f050f4f 100644 --- a/sys/src/cmd/pcc.c +++ b/sys/src/cmd/pcc.c @@ -79,6 +79,7 @@ main(int argc, char *argv[]) if(!oname) fatal("no -o argument"); break; + case 'u': case 'w': case 'B': case 'F':