blob: dab5a07d614f074acddd50e9e109ad842c10cc91 [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
Chris Lattnerc5cbb902011-06-20 04:01:35 +000030// CHECK: global %struct.ManyFields { i32 1, i32 2, i32 0, i8 0, i32 0, i32 0 }
Nuno Lopescdb30b42010-04-16 20:56:35 +000031struct ManyFields FewInits = {1, 2};
Chris Lattnere78b86f2009-08-05 05:20:29 +000032
33
Nuno Lopesa75b71f2010-04-18 19:06:43 +000034// PR6766
Eli Friedman64f45a22011-11-01 02:23:42 +000035// CHECK: @l = global %struct.K { [6 x i32] [i32 102, i32 111, i32 111, i32 0, i32 0, i32 0], i32 1 }
Nuno Lopesa75b71f2010-04-18 19:06:43 +000036typedef __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")));