diff options
author | Michael Matz <matz@suse.de> | 2005-06-27 06:42:32 +0000 |
---|---|---|
committer | Michael Matz <matz@gcc.gnu.org> | 2005-06-27 06:42:32 +0000 |
commit | 2bcf2e2bf17d13a20c587d056f3426fda0106379 (patch) | |
tree | 410a81c4c855a0b5a521307d6cd4acb20e8c510d | |
parent | dc9207b34e4911724605ac71fbe60e645921f16a (diff) | |
download | gcc-2bcf2e2bf17d13a20c587d056f3426fda0106379.zip gcc-2bcf2e2bf17d13a20c587d056f3426fda0106379.tar.gz gcc-2bcf2e2bf17d13a20c587d056f3426fda0106379.tar.bz2 |
test_struct_returning.c: Adjust as return slot is not merged if address escapes.
* gcc.target/x86_64/abi/test_struct_returning.c: Adjust as return
slot is not merged if address escapes.
From-SVN: r101347
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/x86_64/abi/test_struct_returning.c | 13 |
2 files changed, 16 insertions, 2 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fa0a562..c587b13 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-06-27 Michael Matz <matz@suse.de> + + * gcc.target/x86_64/abi/test_struct_returning.c: Adjust as return + slot is not merged if address escapes. + 2005-06-26 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> PR c/21911 diff --git a/gcc/testsuite/gcc.target/x86_64/abi/test_struct_returning.c b/gcc/testsuite/gcc.target/x86_64/abi/test_struct_returning.c index 09fe710..ef8d329 100644 --- a/gcc/testsuite/gcc.target/x86_64/abi/test_struct_returning.c +++ b/gcc/testsuite/gcc.target/x86_64/abi/test_struct_returning.c @@ -137,7 +137,7 @@ void check_400 (void) /* Structures which should be returned in MEM. */ void *struct_addr; #define D(I,MEMBERS) struct S_ ## I { MEMBERS ; }; Type class_ ## I = MEM; \ -struct S_ ## I f_ ## I (void) { struct S_ ## I s; memset (&s, 0, sizeof(s)); s.m1[0] = 42; return s; } +struct S_ ## I f_ ## I (void) { union {unsigned char c; struct S_ ## I s;} u; memset (&u.s, 0, sizeof(u.s)); u.c = 42; return u.s; } /* Too large. */ D(500,char m1[17]) @@ -184,7 +184,16 @@ void check_all (Type class, unsigned long size) case X87: assert (x87_regs[0]._ldouble == 42); break; case INT_SSE: check_300(); break; case SSE_INT: check_400(); break; - case MEM: assert (rax == (unsigned long)struct_addr && rdi == rax); break; + /* Ideally we would like to check that rax == struct_addr. + Unfortunately the address of the target struct escapes (for setting + struct_addr), so the return struct is a temporary one whose address + is given to the f_* functions, otherwise a conforming program + could notice the struct changing already before the function returns. + This temporary struct could be anywhere. For GCC it will be on + stack, but noone is forbidding that it could be a static variable + if there's no threading or proper locking. Nobody in his right mind + will not use the stack for that. */ + case MEM: assert (*(unsigned char*)struct_addr == 42 && rdi == rax); break; } } |