Duncan Sands | 54221ad | 2008-02-15 19:42:13 +0000 | [diff] [blame] | 1 | // RUN: %llvmgxx -S -O0 -emit-llvm %s -o - | grep {retval\\|memtmp} | grep S242 | \ |
Dale Johannesen | 3910c57 | 2008-02-15 22:05:15 +0000 | [diff] [blame^] | 2 | // RUN: grep {i32 1} | count 1 |
Dale Johannesen | 91ff7c0 | 2008-02-13 18:36:48 +0000 | [diff] [blame] | 3 | |
Dale Johannesen | 3910c57 | 2008-02-15 22:05:15 +0000 | [diff] [blame^] | 4 | // Test that all 8 bytes of ret in check242 are copied, and only 4 bytes of |
| 5 | // ret in check93 are copied (the same LLVM struct is used for both). |
| 6 | |
Dale Johannesen | 91ff7c0 | 2008-02-13 18:36:48 +0000 | [diff] [blame] | 7 | typedef __builtin_va_list va_list; |
| 8 | typedef unsigned long size_t; |
| 9 | void *memset(void *, int, size_t); |
| 10 | struct S92 { int a:14; } ; |
| 11 | extern struct S92 s92; |
| 12 | |
| 13 | struct S92 check92 () { struct S92 ret; |
| 14 | memset (&ret, 0, sizeof (ret)); |
| 15 | ret.a = s92.a; |
| 16 | return ret; } |
| 17 | |
| 18 | struct S93 { __attribute__((aligned (8))) void * a; } ; |
| 19 | extern struct S93 s93; |
| 20 | struct S93 check93 () { |
| 21 | struct S93 ret; |
| 22 | memset (&ret, 0, sizeof (ret)); |
| 23 | ret.a = s93.a; |
| 24 | return ret; } |
| 25 | |
| 26 | struct S242 { char * a;int b[1]; } ; |
| 27 | extern struct S242 s242; |
| 28 | |
| 29 | struct S242 check242 () { |
| 30 | struct S242 ret; |
| 31 | memset (&ret, 0, sizeof (ret)); |
| 32 | ret.a = s242.a; |
| 33 | ret.b[0] = s242.b[0]; |
| 34 | return ret; } |
| 35 | |
| 36 | void check93va (int z, ...) { |
| 37 | struct S93 arg; |
| 38 | va_list ap; |
| 39 | __builtin_va_start(ap,z); |
| 40 | arg = __builtin_va_arg(ap,struct S93); |
| 41 | __builtin_va_end(ap); } |
| 42 | |
| 43 | void check242va (int z, ...) { |
| 44 | struct S242 arg; |
| 45 | va_list ap; |
| 46 | __builtin_va_start(ap,z); |
| 47 | arg = __builtin_va_arg(ap,struct S242); |
| 48 | __builtin_va_end(ap); } |
| 49 | |