From 3426459ab5a5a41497a62d90cd9ccdc0458e205e Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 6 May 2014 21:36:28 +0200 Subject: cc: fix spurious warning on comparsion with scope redeclared variable (thanks aiju) > warning: a.c:9 useless or misleading comparison: UINT < 0 the error can be observed by compiling the following code with warnings enabled: #include #include uint r; void main(int argc, char *argv[]) { int r; if(r < 0){ exits(0); } } the offending code in the compiler is: - if(l->op == ONAME && l->sym->type){ - lt = l->sym->type; - if(lt->etype == TARRAY) - lt = lt->link; - } compiler handles scope by overwritin and reverting symbols while parsing. in the ccom phase, the nodes symbol (n->sym) is not in the right scope and we wrongly think r is uint instead of int. it is not clear to me what this code tried to accomplish in the first place nor could anyone answer me this question. the risk is small as this change doesnt affect the compiled program, only the warning, so removing the offending code. --- sys/src/cmd/cc/com.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sys/src/cmd/cc/com.c b/sys/src/cmd/cc/com.c index a957c3acd..c34b7156f 100644 --- a/sys/src/cmd/cc/com.c +++ b/sys/src/cmd/cc/com.c @@ -1370,11 +1370,6 @@ compar(Node *n, int reverse) if(l->op == OCONST) return 0; lt = l->type; - if(l->op == ONAME && l->sym->type){ - lt = l->sym->type; - if(lt->etype == TARRAY) - lt = lt->link; - } if(lt == T) return 0; if(lt->etype == TXXX || lt->etype > TUVLONG) -- cgit v1.2.3