diff options
| author | Michael Matz <matz@suse.de> | 2016-10-08 02:44:17 +0200 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2016-12-15 17:49:53 +0100 |
| commit | ddd461dcc866d17f1c89137dc275ce1da95e7be2 (patch) | |
| tree | 1585ee439f895aeb049e8d3792748451ca768d86 /tests/tests2 | |
| parent | f081acbfba84ffdf1e479f932906bf10f88cd1c2 (diff) | |
| download | tinycc-ddd461dcc866d17f1c89137dc275ce1da95e7be2.tar.gz tinycc-ddd461dcc866d17f1c89137dc275ce1da95e7be2.tar.bz2 | |
Fix initializing members multiple times
When intializing members where the initializer needs relocations
and the member is initialized multiple times we can't allow
that to lead to multiple relocations to the same place. The last
one must win.
Diffstat (limited to 'tests/tests2')
| -rw-r--r-- | tests/tests2/86-struct-init.c | 20 | ||||
| -rw-r--r-- | tests/tests2/86-struct-init.expect | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/tests2/86-struct-init.c b/tests/tests2/86-struct-init.c index 8d27719..fd212ba 100644 --- a/tests/tests2/86-struct-init.c +++ b/tests/tests2/86-struct-init.c @@ -199,6 +199,25 @@ void test_compound_with_relocs (void) p = local_wrap[1].func; p(); } +void sys_ni(void) { printf("ni\n"); } +void sys_one(void) { printf("one\n"); } +void sys_two(void) { printf("two\n"); } +void sys_three(void) { printf("three\n"); } +typedef void (*fptr)(void); +const fptr table[3] = { + [0 ... 2] = &sys_ni, + [0] = sys_one, + [1] = sys_two, + [2] = sys_three, +}; + +void test_multi_relocs(void) +{ + int i; + for (i = 0; i < sizeof(table)/sizeof(table[0]); i++) + table[i](); +} + int main() { print(ce); @@ -224,5 +243,6 @@ int main() foo(&gw, &phdr); //printf("q: %s\n", q); test_compound_with_relocs(); + test_multi_relocs(); return 0; } diff --git a/tests/tests2/86-struct-init.expect b/tests/tests2/86-struct-init.expect index 1498a3d..adda76d 100644 --- a/tests/tests2/86-struct-init.expect +++ b/tests/tests2/86-struct-init.expect @@ -35,3 +35,6 @@ lv2: 1 2 3 4 68 69 68 69 0 0 0 0 0 0 0 0 0 0 0 0 2f 30 lv3: 7 8 9 a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 lt2: 0 9 9 9 43 43 43 43 42 42 42 0 0 0 0 0 1 flow: 9 8 7 6 0 0 0 0 0 0 0 0 0 0 0 0 6 5 4 3 0 0 0 0 0 0 0 0 0 0 0 0 +one +two +three |
