Merge commit '556c60f4f27e2a3bfde6a47acf876716ea8d5795'
* commit '556c60f4f27e2a3bfde6a47acf876716ea8d5795':
Correctly compute the type of an assignment expression.
This change enables following types of statements to work correctly:
a = b = 3;
if ((a = getchar()) < 0) { ... }
This fixes 2232082 acc: assignment in comparison segfaults
Now you can say:
#define A B
#define B C
#define C 4
int x = A;
And it will work as expected.
Print an error message rather than assert when we're expecting a
function value, but don't find one.
We had been arbitrarily swallowing the next token, even if it wasn't
the one we were expecting. Now we only swallow it if it _is_ the one
we were expecting.
Implement some optimizations:
+ performing arithmetic by a small constant is 3 instructions shorter.
+ reading a local variables is 1 instruction shorter.
+ constant array indexing (e.g. p[5]) is 5 instructions shorter.
Until now the address operator only worked with simple variables.
Now it works with arbitrary expressions (that are lvalues or function
names). So for example this now works:
struct S { int a[10]};
int f(struct S* p) {
return &p->a[3];
}
For example, this now works:
#define A (1 + 2)
Note that we still don't support defines with argument lists, so this is
still illegal:
#define A(X) (X + 2)
Also in this change: The compiler test script allows command-line
arguments to disable testing on ARM and to disable testing the output
of the old OTCC compiler.
Disabling testing on ARM is handy for developing front-end code when no
device or emulator is available.
Disabling testing OTCC output is handy for some 64-bit Linux environments,
because the original OTCC needs some tweaking to be fully compatible, and
I don't have time to investigate this problem right now.
This is another step towards being able to handle lval / rvals.
Improved storeR0ToTOS to convert R0 to the proper type to store into
*TOS. (This is something that storeR0 was already doing.)
Removed storeR0 as it is no longer being used.
This makes it easier to generate frame-pointer-relative addresses for ARM.
Prior to this we had stored char sized local variables in the highest
address of the 4-byte stack allocation. Now we store "char"s in the
lowest address of the 4-byte stack allocation, just like chars are
passed as arguments.
We now store global chars on byte boundaries.
This means we don't have to pass it around as an argument.
This change was made because I'm about to start creating pointer types
during expression evaluation, and I didn't want to add an arena
argument to all the expression functions.
Factor ARM integer binary operation setup code into a function.
Don't pass redundant pType information into loadR0FromR0, storeR0ToTOS,
gcmp, gUnaryCmp, li
Separate inc/dec from variable loading. Generates worse code, but now
we handle pointer inc/dec and char inc/dec.