2009-12-15 20:14:24 +00:00
|
|
|
// RUN: %clang_cc1 -emit-llvm -o - -triple i386-linux-gnu %s | FileCheck %s
|
2008-12-03 05:51:23 +00:00
|
|
|
|
|
|
|
// This checks that the global won't be marked as common.
|
|
|
|
// (It shouldn't because it's being initialized).
|
|
|
|
|
|
|
|
int a;
|
|
|
|
int a = 242;
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK: @a ={{.*}} global i32 242
|
2009-08-05 04:56:58 +00:00
|
|
|
|
2009-08-05 05:20:29 +00:00
|
|
|
// This should get normal weak linkage.
|
|
|
|
int c __attribute__((weak))= 0;
|
2022-05-24 21:46:32 +02:00
|
|
|
// CHECK: @c = weak global i32 0
|
2009-08-05 05:20:29 +00:00
|
|
|
|
2022-05-24 21:46:32 +02:00
|
|
|
// Even though is marked const, it should get still get "weak"
|
|
|
|
// linkage, not "weak_odr" as the weak attribute makes it possible
|
|
|
|
// that there is a strong definition that changes the value linktime,
|
|
|
|
// so the value must not be considered constant.
|
|
|
|
// CHECK: @d = weak constant i32 0
|
2009-08-05 05:20:29 +00:00
|
|
|
const int d __attribute__((weak))= 0;
|
|
|
|
|
2022-05-24 21:46:32 +02:00
|
|
|
// However, "selectany" is similar to "weak", but isn't interposable
|
|
|
|
// by a strong definition, and should appear as weak_odr.
|
|
|
|
// CHECK: @e = weak_odr constant i32 17
|
|
|
|
const int e __attribute__((selectany)) = 17;
|
|
|
|
|
2010-04-16 20:56:35 +00:00
|
|
|
// PR6168 "too many undefs"
|
|
|
|
struct ManyFields {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
int c;
|
|
|
|
char d;
|
|
|
|
int e;
|
|
|
|
int f;
|
|
|
|
};
|
|
|
|
|
2011-06-20 04:01:35 +00:00
|
|
|
// CHECK: global %struct.ManyFields { i32 1, i32 2, i32 0, i8 0, i32 0, i32 0 }
|
2010-04-16 20:56:35 +00:00
|
|
|
struct ManyFields FewInits = {1, 2};
|
2009-08-05 05:20:29 +00:00
|
|
|
|
|
|
|
|
2010-04-18 19:06:43 +00:00
|
|
|
// PR6766
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK: @l ={{.*}} global %struct.K { [6 x i32] [i32 102, i32 111, i32 111, i32 0, i32 0, i32 0], i32 1 }
|
2010-04-18 19:06:43 +00:00
|
|
|
typedef __WCHAR_TYPE__ wchar_t;
|
|
|
|
struct K {
|
|
|
|
wchar_t L[6];
|
|
|
|
int M;
|
|
|
|
} l = { { L"foo" }, 1 };
|
|
|
|
|
|
|
|
|
2020-12-31 00:27:11 -08:00
|
|
|
// 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"]
|
2010-04-18 19:06:43 +00:00
|
|
|
char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
|
|
|
|
|
2023-08-07 14:51:44 -07:00
|
|
|
unsigned long long x = -1000;
|
|
|
|
// CHECK: @x ={{.*}} global i64 -1000
|
|
|
|
unsigned long long uint_max = 4294967295u;
|
|
|
|
// CHECK: @uint_max ={{.*}} global i64 4294967295
|
|
|
|
|
2010-04-18 19:06:43 +00:00
|
|
|
|
2009-08-05 05:20:29 +00:00
|
|
|
// NOTE: tentative definitions are processed at the end of the translation unit.
|
|
|
|
|
2009-08-05 04:56:58 +00:00
|
|
|
// This shouldn't be emitted as common because it has an explicit section.
|
2020-12-31 00:27:11 -08:00
|
|
|
// CHECK: @b ={{.*}} global i32 0, section "foo"
|
2010-04-16 20:56:35 +00:00
|
|
|
int b __attribute__((section("foo")));
|