summaryrefslogtreecommitdiff
path: root/sys/src/cmd/cc
AgeCommit message (Collapse)Author
2023-03-20cc: fndecls: always ignore non-function typesSigrid Solveig Haflínudóttir
2023-03-17cc: fndecls: use current fn node directlySigrid Solveig Haflínudóttir
2023-03-17cc: fix suicide with undefined function argumentsJacob Moody
_Noreturn change introduced a check on the type for OFUNC. This will be nil in the event that a symbol given as a function argument is undefined.
2023-03-17cc: add __func__ supportSigrid Solveig Haflínudóttir
2023-03-17cc: NORET -> _NoreturnJacob Moody
The committee has spoken
2023-03-16cc: add NORETJacob Moody
2022-12-03cc: fix vlong->VOID cast (thanks cosa)cinap_lenrek
void main() { unsigned long long a; long long b; (void)(a=b);} a.c:1 unknown vlong->VOID cast with patch: term% /sys/src/cmd/5c/6.out -S a.c TEXT main+0(SB),0,$16 MOVW b-16(SP),R1 MOVW b-12(SP),R2 MOVW R1,a-8(SP) MOVW R2,a-4(SP) RET , END ,
2022-11-27c99: update dead web linkNoam Preil
2022-11-04cc: do not wait for cpp to finish if there were errorsSigrid Solveig Haflínudóttir
2022-11-04cc: wait for cpp to report whether it was a successSigrid Solveig Haflínudóttir
2022-10-01cc: take our pickle out of the peepholeAnthony Martin
The -P flag is used to debug the peephole optimizer. The -Z flag is used to output pickling code for various types. Don't confuse the two. The pickling code was added in the third edition. It mistakenly reused the -P flag which was later partially corrected to use the -Z flag in 2004. That change updated lex.c but missed the code in pickle.c.
2022-01-23cc: fix incorrect octal range condition in mpatovMichael Forney
This does not have any adverse effect, since yylex never calls mpatov with a string with leading 0 (and not 0x) that contains non-octal digits, but the condition was wrong regardless.
2021-10-12cc: do not expand function-like macros for non-function invocationscinap_lenrek
It is a bit of a annoyance that kenc will try to expand function like macros on any symbol with the same name and then complain when it doesnt see the '(' in the invocation. test case below: void foo(int) { } struct Bar { int baz; /* <- should not conflict */ }; void main(void) { baz(123); }
2021-06-24cc: create .$O files with DMTMPJacob Moody
2021-01-24cc: mk clean should delete cc.a$OOri Bernstein
It's surprising when 'mk clean' doesn't actually do a clean build in cc -- fix this.
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-12-29cc: add a couple notes to the comments regarding flagsBurnZeZ
2020-08-08cc: promote integer constants according to c99 spec.Ori Bernstein
C99 integer constants with no type suffix promote differently depending on the way that they're written: hex and oct consts promote as int => uint => long => ulong => vlong => uvlong. Decimal constants are always signed. We used to promote all values to uint on overflow, and never went wider. This change fixes that, and adds a warning when a decimal constant that would have been promoted to uint in the past gets promoted to int.
2020-05-12cc: dont export gethunk(), hunk, nhunk and thunkcinap_lenrek
2020-05-12cc: get rid of hunk pointer fiddling and just use alloc()cinap_lenrek
2020-04-25cc: simplify macexpand() and off-by-one errorcinap_lenrek
the caller of macexpand() needs one more byte in the buffer to append peekc. make macexpand() actually check for buffer overflow. just use strdup() to duplicate include file name instead of the hunk dance. move GETC() macro in cc.h
2020-04-19?a, ?c: fix macro debug printscinap_lenrek
2020-04-19?c: get rid of sprint(), strcpy() and strcat()/strncat(), cleanupcinap_lenrek
2020-04-19cc: cc.h changes needed by previous commitcinap_lenrek
2020-04-19?a, cc: fix buffer overflows in built-in preprocessor (macbody)cinap_lenrek
add a buffer size argument to macexpand() and check for overflow. check for overflow when parsing #include directives.
2020-04-19?a: catch symb[NSYMB] buffer overflow in lexer, cleanup, assume thechar is a ↵cinap_lenrek
rune
2020-04-19cc: get rid of sprint() and temporary buffer for type conversion fuctioncinap_lenrek
slookup() copies to symb, so use the symb[NSYMB] buffer directly to declare type conversion functions and get rid of the arbitrary sized local buffer. replace sprint() with snprint().
2020-04-11cc: remove mysbrk(), exponentially increase gethunk() allocation deltacinap_lenrek
mysbrk() was only used in gethunk() and should not be called by anyone, so dont export the symbol. simplify gethunk() using brk(). double allocation size on each call until we reach 1000*NHUNK. use signed long for nhunk as alignment rountin might make it negative and handle that case.
2020-04-11cc, ?[acl]: fix gethunk() and move common memory allocator code to cc/compatcinap_lenrek
for gethunk() to work, all allocators have to use it, including allocations done by libc thru malloc(), so the fake allocation functions are mandatory for everyone. to avoid duplication the code is moved to cc/compat and prototypes provided in new cc/compat.h header.
2020-04-11backout the gethunk() again, as that breaks the assemblerscinap_lenrek
the assemblers share gethunk() cc/macbody but are compiled without compat.c, so calls such as getenv() trigger malloc() which does its own sbrk() calls, breaking the continuity of the hunk. so this change needs another revision. until then, this is backed out.
2020-04-10cc, ?l: fix gethunk() to actually grow allocationcinap_lenrek
the compilers and linkers use ther own memory allocator. free memory is between hunk and hunk+nhunk. allocation works by checking if nhunk is bigger or equal to the amount needed, and if not, repeatedly call gethunk() until there is. after that, the allocated amount is added from hunk and subtracted from nhunk by the user. the problem was when the needed amount was bigger than the default NHUNK size gethunk() allocates per call. gethunk() would not actually grow nhunk, but instead just set hunk and nhunk variables to the last allocated block. this resulted in a infinite loop of calls to gethunk() until sbrk() would hit the maximum size for the BSS segment. this change makes gethunk() actually grow the hunk space, increasing nhunk, and only updating hunk when nhunk was previously zero. we assume that mysbrk() retuns increasing addresses and that the space between the previous hunk+nhunk and the new block base returned by mysbrk() is usable.
2020-04-10mergecinap_lenrek
2020-04-10cc: backout gethunk() changecinap_lenrek
the real problem is that gethunk() does not grow the allocation but just allocates a new hunk, so repeated calls to gethunk() wont make nhunk grow to satisfy the allocation. this will be fixed in a upcoming commit.
2020-04-10cc, ?a, ?l: change thunk type to uintptrSigrid
2020-04-10cc: sbrk in bigger chunks as it grows, so it gets a chance to use the ↵Sigrid
ram/swap available
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-07Allow address expressions in ?c after int casts.Ori Bernstein
This fixes ocaml on non-x86 architectures, where we have code that looks like: #define Fl_head ((uintptr_t)(&sentinel.first_field)) Without this change, we get an error about a non-constant initializer. This change takes the checks for pointers and makes them apply to all expressions. It also makes the checks stricter, preventing the following from compiling to junk: int x; int y = 42; int *p = &x + y
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-08-12cc: use 7 octal digits for 21 bit runescinap_lenrek
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
2019-02-25cc: fix %.*s format usage in lexer "token too long" errorcinap_lenrek
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.
2017-05-26?a: getc() needs to increment lineno if it gets \n from peekcaiju
2017-03-22[012568kqv]a: correctly lex full range of integers in the assemblers (thanks ↵spew
Ori_B) The Plan 9 assemblers use strtoll to parse the integer literals in their input. It turns out that this is almost correct, but VLONG_MIN is clamped. This patch changes to use strtoull in order to allow the full range of integers.
2016-06-26cc: add OROL op to side effect free op listcinap_lenrek