xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/default-destructor-synthesis.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O2 -o - | FileCheck %s
2*f4a2713aSLionel Sambuc static int count = 0;
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc struct S {
SS5*f4a2713aSLionel Sambuc   S() { count++; }
~SS6*f4a2713aSLionel Sambuc   ~S() { count--; }
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc struct P {
PP10*f4a2713aSLionel Sambuc   P() { count++; }
~PP11*f4a2713aSLionel Sambuc   ~P() { count--; }
12*f4a2713aSLionel Sambuc };
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc struct Q {
QQ15*f4a2713aSLionel Sambuc   Q() { count++; }
~QQ16*f4a2713aSLionel Sambuc   ~Q() { count--; }
17*f4a2713aSLionel Sambuc };
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc struct M : Q, P {
20*f4a2713aSLionel Sambuc   S s;
21*f4a2713aSLionel Sambuc   Q q;
22*f4a2713aSLionel Sambuc   P p;
23*f4a2713aSLionel Sambuc   P p_arr[3];
24*f4a2713aSLionel Sambuc   Q q_arr[2][3];
25*f4a2713aSLionel Sambuc };
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc // CHECK: define i32 @_Z1fv() [[NUW:#[0-9]+]]
f()28*f4a2713aSLionel Sambuc int f() {
29*f4a2713aSLionel Sambuc   {
30*f4a2713aSLionel Sambuc     count = 1;
31*f4a2713aSLionel Sambuc     M a;
32*f4a2713aSLionel Sambuc   }
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc   // CHECK: ret i32 1
35*f4a2713aSLionel Sambuc   return count;
36*f4a2713aSLionel Sambuc }
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc // CHECK: attributes [[NUW]] = { nounwind{{.*}} }
39