blob: b4e20cd15df496b6d5fb07c5940bddb0e83a6a5c [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 0 | FileCheck -check-prefix=NOSSP %s
Bill Wendlingf7a9da02013-02-20 07:22:19 +00002// NOSSP: define void @test1(i8* %msg) #0 {
Daniel Dunbara5728872009-12-15 20:14:24 +00003// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 1 | FileCheck -check-prefix=WITHSSP %s
Bill Wendlingf7a9da02013-02-20 07:22:19 +00004// WITHSSP: define void @test1(i8* %msg) #0 {
Daniel Dunbara5728872009-12-15 20:14:24 +00005// RUN: %clang_cc1 -emit-llvm -o - %s -stack-protector 2 | FileCheck -check-prefix=SSPREQ %s
Bill Wendlingf7a9da02013-02-20 07:22:19 +00006// SSPREQ: define void @test1(i8* %msg) #0 {
Dmitri Gribenko97e948e2013-02-17 03:06:16 +00007
8typedef __SIZE_TYPE__ size_t;
Bill Wendling45483f72009-06-28 07:36:13 +00009
Mike Stump76bee4b2009-10-08 23:05:06 +000010int printf(const char * _Format, ...);
Dmitri Gribenko97e948e2013-02-17 03:06:16 +000011size_t strlen(const char *s);
12char *strcpy(char *s1, const char *s2);
Bill Wendling45483f72009-06-28 07:36:13 +000013
14void test1(const char *msg) {
15 char a[strlen(msg) + 1];
16 strcpy(a, msg);
17 printf("%s\n", a);
18}
Bill Wendlingf7a9da02013-02-20 07:22:19 +000019
20// NOSSP: attributes #0 = { nounwind "target-features"={{.*}} }
21// NOSSP: attributes #1 = { "target-features"={{.*}} }
22// NOSSP: attributes #2 = { nounwind }
23
24// WITHSSP: attributes #0 = { nounwind ssp "target-features"={{.*}} }
25// WITHSSP: attributes #1 = { "target-features"={{.*}} }
26// WITHSSP: attributes #2 = { nounwind }
27
28// SSPREQ: attributes #0 = { nounwind sspreq "target-features"={{.*}} }
29// SSPREQ: attributes #1 = { "target-features"={{.*}} }
30// SSPREQ: attributes #2 = { nounwind }