Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -o - -triple i386-linux-gnu %s | FileCheck %s |
Anders Carlsson | 98883e1 | 2008-12-03 05:51:23 +0000 | [diff] [blame] | 2 | |
| 3 | // This checks that the global won't be marked as common. |
| 4 | // (It shouldn't because it's being initialized). |
| 5 | |
| 6 | int a; |
| 7 | int a = 242; |
Chris Lattner | 309457d | 2009-08-05 04:56:58 +0000 | [diff] [blame] | 8 | // CHECK: @a = global i32 242 |
| 9 | |
Chris Lattner | e78b86f | 2009-08-05 05:20:29 +0000 | [diff] [blame] | 10 | // This should get normal weak linkage. |
| 11 | int c __attribute__((weak))= 0; |
| 12 | // CHECK: @c = weak global i32 0 |
| 13 | |
| 14 | |
Chris Lattner | e78b86f | 2009-08-05 05:20:29 +0000 | [diff] [blame] | 15 | // 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 |
| 18 | const int d __attribute__((weak))= 0; |
| 19 | |
Nuno Lopes | cdb30b4 | 2010-04-16 20:56:35 +0000 | [diff] [blame] | 20 | // PR6168 "too many undefs" |
| 21 | struct 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 } |
| 31 | struct ManyFields FewInits = {1, 2}; |
Chris Lattner | e78b86f | 2009-08-05 05:20:29 +0000 | [diff] [blame] | 32 | |
| 33 | |
| 34 | // NOTE: tentative definitions are processed at the end of the translation unit. |
| 35 | |
Chris Lattner | 309457d | 2009-08-05 04:56:58 +0000 | [diff] [blame] | 36 | // This shouldn't be emitted as common because it has an explicit section. |
| 37 | // rdar://7119244 |
Chris Lattner | 309457d | 2009-08-05 04:56:58 +0000 | [diff] [blame] | 38 | // CHECK: @b = global i32 0, section "foo" |
Nuno Lopes | cdb30b4 | 2010-04-16 20:56:35 +0000 | [diff] [blame] | 39 | int b __attribute__((section("foo"))); |