xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/stack-protector.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -check-prefix=NOSSP %s
2f4a2713aSLionel Sambuc // NOSSP: define void @test1(i8* %msg) #0 {
3f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -check-prefix=WITHSSP %s
4f4a2713aSLionel Sambuc // WITHSSP: define void @test1(i8* %msg) #0 {
5*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -check-prefix=SSPSTRONG %s
6*0a6a1f1dSLionel Sambuc // SSPSTRONG: define void @test1(i8* %msg) #0 {
7*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 3 | FileCheck -check-prefix=SSPREQ %s
8f4a2713aSLionel Sambuc // SSPREQ: define void @test1(i8* %msg) #0 {
9f4a2713aSLionel Sambuc 
10f4a2713aSLionel Sambuc typedef __SIZE_TYPE__ size_t;
11f4a2713aSLionel Sambuc 
12f4a2713aSLionel Sambuc int printf(const char * _Format, ...);
13f4a2713aSLionel Sambuc size_t strlen(const char *s);
14f4a2713aSLionel Sambuc char *strcpy(char *s1, const char *s2);
15f4a2713aSLionel Sambuc 
test1(const char * msg)16f4a2713aSLionel Sambuc void test1(const char *msg) {
17f4a2713aSLionel Sambuc   char a[strlen(msg) + 1];
18f4a2713aSLionel Sambuc   strcpy(a, msg);
19f4a2713aSLionel Sambuc   printf("%s\n", a);
20f4a2713aSLionel Sambuc }
21f4a2713aSLionel Sambuc 
22f4a2713aSLionel Sambuc // NOSSP: attributes #{{.*}} = { nounwind{{.*}} }
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc // WITHSSP: attributes #{{.*}} = { nounwind ssp{{.*}} }
25f4a2713aSLionel Sambuc 
26*0a6a1f1dSLionel Sambuc // SSPSTRONG: attributes #{{.*}} = { nounwind sspstrong{{.*}} }
27*0a6a1f1dSLionel Sambuc 
28f4a2713aSLionel Sambuc // SSPREQ: attributes #{{.*}} = { nounwind sspreq{{.*}} }
29