mescc: Tinycc support: pointer arithmetic with &variable.

* module/language/c99/compiler.mes (expr->pointer): Handle ref.
* scaffold/tests/76-pointer-arithmetic.c: Test it.
This commit is contained in:
Jan Nieuwenhuizen 2017-08-25 06:58:15 +02:00
parent 0875ce655a
commit 8649f7a923
2 changed files with 4 additions and 0 deletions

View file

@ -1736,6 +1736,7 @@
((pre-dec ,a) (expr->pointer info a))
((post-inc ,a) (expr->pointer info a))
((post-dec ,a) (expr->pointer info a))
((ref-to ,expr) (1+ (expr->pointer info expr)))
((array-ref ,index ,array)
(1- (expr->pointer info array)))

View file

@ -75,6 +75,7 @@ test ()
if (pfoo != 12) return 17;
int one = 1;
int two = 2;
pfoo = pfoo - one;
eputs ("pfoo="); eputs (itoa (pfoo)); eputs ("\n");
if (pfoo) return 18;
@ -91,5 +92,7 @@ test ()
eputs ("pfoo="); eputs (itoa (pfoo)); eputs ("\n");
if (pfoo != 12) return 21;
if (&one - 1 != &two) return 22;
return 0;
}