blob: 651f7d809a0517fbebb056ce6603e2ed49c56907 [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
34// NOTE: tentative definitions are processed at the end of the translation unit.
35
Chris Lattner309457d2009-08-05 04:56:58 +000036// This shouldn't be emitted as common because it has an explicit section.
37// rdar://7119244
Chris Lattner309457d2009-08-05 04:56:58 +000038// CHECK: @b = global i32 0, section "foo"
Nuno Lopescdb30b42010-04-16 20:56:35 +000039int b __attribute__((section("foo")));