blob: 351ca9e35ac72310f9cc15a088c2a82bb3b0b7c3 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -emit-llvm -o - -triple i386-linux-gnu %s | FileCheck %s
Anders Carlsson98883e12008-12-03 05:51:23 +00002
3// This checks that the global won't be marked as common.
4// (It shouldn't because it's being initialized).
5
6int a;
7int a = 242;
Chris Lattner309457d2009-08-05 04:56:58 +00008// CHECK: @a = global i32 242
9
Chris Lattnere78b86f2009-08-05 05:20:29 +000010// This should get normal weak linkage.
11int c __attribute__((weak))= 0;
12// CHECK: @c = weak global i32 0
13
14
Chris Lattnere78b86f2009-08-05 05:20:29 +000015// Since this is marked const, it should get weak_odr linkage, since all
16// definitions have to be the same.
17// CHECK: @d = weak_odr constant i32 0
18const int d __attribute__((weak))= 0;
19
Nuno Lopescdb30b42010-04-16 20:56:35 +000020// PR6168 "too many undefs"
21struct ManyFields {
22 int a;
23 int b;
24 int c;
25 char d;
26 int e;
27 int f;
28};
29
30// CHECK: global %0 { i32 1, i32 2, i32 0, i8 0, i32 0, i32 0 }
31struct ManyFields FewInits = {1, 2};
Chris Lattnere78b86f2009-08-05 05:20:29 +000032
33
Nuno Lopesa75b71f2010-04-18 19:06:43 +000034// PR6766
35// CHECK: @l = global %1 { [24 x i8] c"f\00\00\00o\00\00\00o\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", i32 1 }
36typedef __WCHAR_TYPE__ wchar_t;
37struct K {
38 wchar_t L[6];
39 int M;
40} l = { { L"foo" }, 1 };
41
42
43// CHECK: @yuv_types = global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", [6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"]
44char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
45
46
Chris Lattnere78b86f2009-08-05 05:20:29 +000047// NOTE: tentative definitions are processed at the end of the translation unit.
48
Chris Lattner309457d2009-08-05 04:56:58 +000049// This shouldn't be emitted as common because it has an explicit section.
50// rdar://7119244
Chris Lattner309457d2009-08-05 04:56:58 +000051// CHECK: @b = global i32 0, section "foo"
Nuno Lopescdb30b42010-04-16 20:56:35 +000052int b __attribute__((section("foo")));