c-strings.c revision b8409215523e5478b8b0aa9cdcd10038cf7651fe
1// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s 2 3// Should be 3 hello strings, two global (of different sizes), the rest are 4// shared. 5 6// CHECK: @align = global i8 [[ALIGN:[0-9]+]] 7// CHECK: @.str = private unnamed_addr constant [6 x i8] c"hello\00" 8// CHECK: @f1.x = internal global i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0) 9// CHECK: @f2.x = internal global [6 x i8] c"hello\00", align [[ALIGN]] 10// CHECK: @f3.x = internal global [8 x i8] c"hello\00\00\00", align [[ALIGN]] 11// CHECK: @f4.x = internal global %struct.s { i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0) } 12// CHECK: @x = global [3 x i8] c"ola", align [[ALIGN]] 13 14#if defined(__s390x__) 15unsigned char align = 2; 16#else 17unsigned char align = 1; 18#endif 19 20void bar(const char *); 21 22// CHECK: define void @f0() 23void f0() { 24 bar("hello"); 25 // CHECK: call void @bar({{.*}} @.str 26} 27 28// CHECK: define void @f1() 29void f1() { 30 static char *x = "hello"; 31 bar(x); 32 // CHECK: [[T1:%.*]] = load i8** @f1.x 33 // CHECK: call void @bar(i8* [[T1:%.*]]) 34} 35 36// CHECK: define void @f2() 37void f2() { 38 static char x[] = "hello"; 39 bar(x); 40 // CHECK: call void @bar({{.*}} @f2.x 41} 42 43// CHECK: define void @f3() 44void f3() { 45 static char x[8] = "hello"; 46 bar(x); 47 // CHECK: call void @bar({{.*}} @f3.x 48} 49 50void gaz(void *); 51 52// CHECK: define void @f4() 53void f4() { 54 static struct s { 55 char *name; 56 } x = { "hello" }; 57 gaz(&x); 58 // CHECK: call void @gaz({{.*}} @f4.x 59} 60 61char x[3] = "ola"; 62 63