summaryrefslogtreecommitdiff
path: root/sys/src/cmd/cc/com.c
AgeCommit message (Collapse)Author
2021-01-23[9front] cc: fix comparison warning with constant LHSMichael Forney
This prevents an incorrect warning for a comparison such as `0 < x`, where x is an unsigned type. Previously, this would get normalized as `x >= 0` rather than `x > 0` when checking the comparison.
2021-01-23[9front] cc: remove unnecessary 128-bit add functionMichael Forney
Instead, just change the comparisons from <=/>= to </>.
2020-03-15fix ccom idempotencyOri Bernstein
ccom may be called multiple times on the same node, via 'goto loop' calls from the commute label, OADD, and a few other places. Casts to void could null out the LHS of the node, which would cause the compiler to crash if the cast was revisited due to one of these cases, because we tried frobbing n->left. Now, if n->left is nil, we just return.w
2020-02-27fix special case for null pointer constants in cond expressionsOri Bernstein
Section 6.5.15 of the C99 spec requires that if one argument of a ?: expression is a null pointer constant, and the other has a pointer type T*, then the type of the expression is T*. We were attempting to follow this rule, however, we only handled literal expressions when checking for null pointers. This change looks through casts, so 'nil' and 'NULL', and their expansion '(void*)0' are all detected as null pointer constants.
2019-09-07cc: fix void cast crashcinap_lenrek
the following code reproduces the crash: void foo(void) { } void main(int argc, char **argv) { (void)(1 ? (void)0 : foo()); } the problem is that side() gives a false positive on the OCOND with later constant folding eleminating the acutal side effect and OCAST ending up with two nested OCATS with the nested one being zapped (type == T).
2019-06-19cc: remove nullwarn() from OCAST codegen, zap void castscinap_lenrek
implicit casts would cause spurious "result of operation not used" warnings such as ape's stdio putc() macro. make (void) casts non-ops when the casted expression has no side effects. this avoid spurious warning with ape's assert() macro.
2019-06-18Import compiler warnings and bugfixes from Charles.Ori Bernstein
This change imports a few warnings and minor fixes from Charles branch here: https://bitbucket.org/plan9-from-bell-labs/plan9. The changes included here: changeset: 1374:9185dc017be0 summary: declare castucom; move a declaration into order; use cast instead of ULL suffix changeset: 1353:5fe8380b1818 summary: supporting functions: 1. castucom to match unlikely mask operation; 2. be sure to snap both sides of pointer subtraction completely; 3. add extra operators as side-effect free changeset: 1352:90058c092d66 summary: 1. correct result type for mixed-mode assignment operators 2. detect divide by zero (erik); 3. detect masks misformed by sign-extension; 4. diagnose mixed old/new prototypes
2018-12-02kencc: make "function not declared" a warning unless compiling with -Taiju
2018-12-01kencc: turn "function args not checked" warning into "function not declared" ↵aiju
error if appropriate
2018-11-18cc: fix wrong "useless or misleading comparison" warningcinap_lenrek
to reproduce: u8int x, y; x = 0xff; y = 0xc0; if((s8int)(x & y) >= 0) print("help\n"); compiles correctly but prints a warning warning: test.c:11 useless or misleading comparison: UINT >= 0 the issue is that compar() unconditionally skipped over all left casts ignoring the case when a cast would sign extend the value. the new code only skips over the cast when the original type with is smaller than the cast result or when they are equal width and types have same signedness. so the effective left hand side type is the last truncation or sign extension.
2015-10-04cc/6c: fix return type of mixed asop expressions, preserve type for moves so ↵cinap_lenrek
fixed<->float conversions work correctly
2014-05-06cc: fix spurious warning on comparsion with scope redeclared variable ↵cinap_lenrek
(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 <u.h> #include <libc.h> 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.
2012-12-31fix utf and rune handling in preparation for 32bit runescinap_lenrek
2012-07-30import updated compilers from sourcescinap_lenrek
2011-03-30Import sources from 2011-03-30 iso image - libTaru Karttunen
2011-03-30Import sources from 2011-03-30 iso imageTaru Karttunen