mescc: Tinycc support: bugfix struct pointer.

* module/language/c99/compiler.mes (decl->info): Only set non-pointer struct to -1.
* scaffold/tests/23-pointer.c (test): Test it.
This commit is contained in:
Jan Nieuwenhuizen 2017-07-25 17:01:37 +02:00
parent 10e65b35ce
commit d2f701b825
2 changed files with 11 additions and 1 deletions

View file

@ -1925,7 +1925,7 @@
(info (append-text info (ast->comment o)))
(globals (append globals initzer-globals))
(info (clone info #:globals globals))
(pointer (if (and (pair? type) (equal? (car type) "tag")) -1 pointer))
(pointer (if (and (zero? pointer) (pair? type) (equal? (car type) "tag")) -1 pointer))
(size (if (zero? pointer) (ast-type->size info type)
4)))
(if (.function info)

View file

@ -23,6 +23,12 @@
char g_arena[4] = "XXX";
char *g_chars = g_arena;
struct foo {
int fd;
};
struct foo *file;
int
test ()
{
@ -46,5 +52,9 @@ test ()
char **pp2 = *ppp;
if (**pp2 != 'X') return 8;
struct foo *f = 0;
if (f) return 9;
if (file) return 10;
return 0;
}