Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -emit-llvm -o - -triple i386-linux-gnu %s | FileCheck %s
      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;
      8 // CHECK: @a = global i32 242
      9 
     10 // This should get normal weak linkage.
     11 int c __attribute__((weak))= 0;
     12 // CHECK: @c = weak global i32 0
     13 
     14 
     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 
     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 %struct.ManyFields { i32 1, i32 2, i32 0, i8 0, i32 0, i32 0 }
     31 struct ManyFields FewInits = {1, 2};
     32 
     33 
     34 // PR6766
     35 // CHECK: @l = global %struct.K { [6 x i32] [i32 102, i32 111, i32 111, i32 0, i32 0, i32 0], i32 1 }
     36 typedef __WCHAR_TYPE__ wchar_t;
     37 struct 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"]
     44 char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
     45 
     46 
     47 // NOTE: tentative definitions are processed at the end of the translation unit.
     48 
     49 // This shouldn't be emitted as common because it has an explicit section.
     50 // rdar://7119244
     51 // CHECK: @b = global i32 0, section "foo"
     52 int b __attribute__((section("foo")));
     53