diff options
| author | Michael Matz <matz@suse.de> | 2016-09-03 23:55:54 +0200 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2016-12-15 17:47:11 +0100 |
| commit | 9656560f144380bcebade03a6c10b8c186ad3874 (patch) | |
| tree | 69e88dc202528dbb86a2ad652478bc6f3d47eead /tests | |
| parent | 49bb5a7e06049c771a28a2cc507c7789dc54a88b (diff) | |
| download | tinycc-9656560f144380bcebade03a6c10b8c186ad3874.tar.gz tinycc-9656560f144380bcebade03a6c10b8c186ad3874.tar.bz2 | |
Fix sizeof(char[a])
The sizes of VLAs need to be evaluated even inside sizeof,
i.e. when nocode_wanted is set.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/tcctest.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/tcctest.c b/tests/tcctest.c index daf788c..4e51ea1 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -2456,6 +2456,16 @@ void sizeof_test(void) printf("__alignof__(char) = %d\n", __alignof__(char)); printf("__alignof__(unsigned char) = %d\n", __alignof__(unsigned char)); printf("__alignof__(func) = %d\n", __alignof__ sizeof_test()); + + /* sizes of VLAs need to be evaluated even inside sizeof: */ + a = 2; + printf("sizeof(char[1+2*a]) = %d\n", sizeof(char[1+2*a])); + /* And checking if sizeof compound literal works. Parenthesized: */ + printf("sizeof( (struct {int i; int j;}){4,5} ) = %d\n", + sizeof( (struct {int i; int j;}){4,5} )); + /* And as direct sizeof argument (as unary expression): */ + printf("sizeof (struct {short i; short j;}){4,5} = %d\n", + sizeof (struct {short i; short j;}){4,5} ); } void typeof_test(void) |
