diff options
| author | Michael Matz <matz@suse.de> | 2016-10-03 19:21:10 +0200 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2016-12-15 17:47:12 +0100 |
| commit | 7ab35c6265425a81c14bc313eb4c834985a73ddb (patch) | |
| tree | 6d7a57c36b357befa9e9ae71856f529aa640674c /tests/tests2 | |
| parent | 0bca6cab06405ede5343bc22f8571b1a88aa8c22 (diff) | |
| download | tinycc-7ab35c6265425a81c14bc313eb4c834985a73ddb.tar.gz tinycc-7ab35c6265425a81c14bc313eb4c834985a73ddb.tar.bz2 | |
struct-init: Copy relocs for compound literals
When copying the content of compound literals we must
include relocations as well.
Diffstat (limited to 'tests/tests2')
| -rw-r--r-- | tests/tests2/86-struct-init.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/tests2/86-struct-init.c b/tests/tests2/86-struct-init.c index 3cf25c7..8d27719 100644 --- a/tests/tests2/86-struct-init.c +++ b/tests/tests2/86-struct-init.c @@ -109,6 +109,21 @@ struct pkthdr { struct in6_addr daddr, saddr; }; struct pkthdr phdr = { { { 6,5,4,3 } }, { { 9,8,7,6 } } }; + +struct Wrap { + void *func; +}; +int global; +void inc_global (void) +{ + global++; +} + +struct Wrap global_wrap[] = { + ((struct Wrap) {inc_global}), + inc_global, +}; + #include <stdio.h> void print_ (const char *name, const u8 *p, long size) { @@ -171,6 +186,19 @@ void foo (struct W *w, struct pkthdr *phdr_) } #endif +void test_compound_with_relocs (void) +{ + struct Wrap local_wrap[] = { + ((struct Wrap) {inc_global}), + inc_global, + }; + void (*p)(void); + p = global_wrap[0].func; p(); + p = global_wrap[1].func; p(); + p = local_wrap[0].func; p(); + p = local_wrap[1].func; p(); +} + int main() { print(ce); @@ -195,5 +223,6 @@ int main() print(phdr); foo(&gw, &phdr); //printf("q: %s\n", q); + test_compound_with_relocs(); return 0; } |
