1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s 2*f4a2713aSLionel Sambuc struct X { 3*f4a2713aSLionel Sambuc X(); 4*f4a2713aSLionel Sambuc ~X(); 5*f4a2713aSLionel Sambuc }; 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc struct Y { 8*f4a2713aSLionel Sambuc Y(); 9*f4a2713aSLionel Sambuc ~Y(); 10*f4a2713aSLionel Sambuc }; 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z1fiPPKc( f(int argc,const char * argv[])13*f4a2713aSLionel Sambucvoid f(int argc, const char* argv[]) { 14*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1XC1Ev 15*f4a2713aSLionel Sambuc X x; 16*f4a2713aSLionel Sambuc // CHECK: call i8* @llvm.stacksave( 17*f4a2713aSLionel Sambuc const char *argv2[argc]; 18*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1YC1Ev 19*f4a2713aSLionel Sambuc Y y; 20*f4a2713aSLionel Sambuc for (int i = 0; i != argc; ++i) 21*f4a2713aSLionel Sambuc argv2[i] = argv[i]; 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1YD1Ev 24*f4a2713aSLionel Sambuc // CHECK: call void @llvm.stackrestore 25*f4a2713aSLionel Sambuc // CHECK: call void @_ZN1XD1Ev 26*f4a2713aSLionel Sambuc // CHECK: ret void 27*f4a2713aSLionel Sambuc } 28*f4a2713aSLionel Sambuc 29*f4a2713aSLionel Sambuc namespace PR11744 { 30*f4a2713aSLionel Sambuc // Make sure this doesn't crash; there was a use-after-free issue 31*f4a2713aSLionel Sambuc // for this testcase. f(int n)32*f4a2713aSLionel Sambuc template<typename T> int f(int n) { 33*f4a2713aSLionel Sambuc T arr[3][n]; 34*f4a2713aSLionel Sambuc return 3; 35*f4a2713aSLionel Sambuc } 36*f4a2713aSLionel Sambuc int test = f<int>(0); 37*f4a2713aSLionel Sambuc } 38