blob: ff531255bba935f998e5c8c2d1b1520ee85bc1ed [file] [log] [blame]
Aaron Ballman6c60c8d2012-02-22 03:04:13 +00001// For MSVC ABI compatibility, all structures returned by value using the
2// thiscall calling convention must use the hidden parameter.
3//
4// RUN: %clang_cc1 -triple i386-PC-Win32 %s -fms-compatibility -O0 -emit-llvm -o - | FileCheck %s
5
6// This structure would normally be returned via EAX
7struct S {
8 int i;
9};
10
11// This structure would normally be returned via EAX/EDX
12struct M {
13 int i;
14 int j;
15};
16
17class C {
18public:
19 C() {}
20
21 struct S __attribute__((thiscall)) Small() const {
22 struct S s = { 0 };
23 return s;
24 }
25
26 struct M __attribute__((thiscall)) Medium() const {
27 struct M m = { 0 };
28 return m;
29 }
30};
31
32// CHECK: define void @_Z4testv()
33void test( void ) {
NAKAMURA Takumide40d3b2012-02-22 03:36:54 +000034// CHECK: call void @_ZN1CC1Ev(%class.C* [[C:%.+]])
Aaron Ballman6c60c8d2012-02-22 03:04:13 +000035 C c;
36
NAKAMURA Takumide40d3b2012-02-22 03:36:54 +000037// CHECK: call x86_thiscallcc void @_ZNK1C5SmallEv(%struct.S* sret %{{.+}}, %class.C* [[C]])
Aaron Ballman6c60c8d2012-02-22 03:04:13 +000038 (void)c.Small();
NAKAMURA Takumide40d3b2012-02-22 03:36:54 +000039// CHECK: call x86_thiscallcc void @_ZNK1C6MediumEv(%struct.M* sret %{{.+}}, %class.C* [[C]])
Aaron Ballman6c60c8d2012-02-22 03:04:13 +000040 (void)c.Medium();
41}