Modify test to expect improved code.
[oota-llvm.git] / test / C++Frontend / 2008-02-13-sret.cpp
1 // RUN: %llvmgxx -S -O0 -emit-llvm %s -o - | grep {retval\\|memtmp} | grep S242 | \
2 // RUN:   grep {i32 1} | count 1
3
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
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