mescc: Tinycc support: ((unsigned char*)str)[i].

* module/language/c99/compiler.mes (expr->accu*): Consider size of
  expr array deref.
* scaffold/tests/7d-cast-char.c: Test it.
This commit is contained in:
Jan Nieuwenhuizen 2017-08-04 11:40:04 +02:00
parent 949e320622
commit d64a304a83
2 changed files with 8 additions and 1 deletions

View file

@ -1176,7 +1176,9 @@
((array-ref ,index ,array)
(let* ((info ((expr->accu info) index))
(size 4) ;; FIXME
(ptr (expr->pointer info array))
(size (if (= ptr 1) (expr->size info array)
4))
(info (append-text info (wrap-as (append (i386:accu->base)
(if (eq? size 1) '()
(append

View file

@ -29,5 +29,10 @@ test ()
int i = ((unsigned char *)s)[0];
if (i != 'i') return 2;
c = s[1];
if (c != 'n') return 3;
i = ((unsigned char *)s)[1];
if (i != 'n') return 3;
return 0;
}