1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-STATIC-BL 2f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s -Dconstexpr= | FileCheck %s --check-prefix=CHECK-DYNAMIC-BL 3f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s -DUSE_END | FileCheck %s --check-prefix=CHECK-STATIC-BE 4f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -emit-llvm -o - %s -DUSE_END -Dconstexpr= | FileCheck %s --check-prefix=CHECK-DYNAMIC-BE 5f4a2713aSLionel Sambuc 6f4a2713aSLionel Sambuc namespace std { 7f4a2713aSLionel Sambuc typedef decltype(sizeof(int)) size_t; 8f4a2713aSLionel Sambuc 9f4a2713aSLionel Sambuc template <class _E> 10f4a2713aSLionel Sambuc class initializer_list 11f4a2713aSLionel Sambuc { 12f4a2713aSLionel Sambuc const _E* __begin_; 13f4a2713aSLionel Sambuc #ifdef USE_END 14f4a2713aSLionel Sambuc const _E* __end_; 15f4a2713aSLionel Sambuc #else 16f4a2713aSLionel Sambuc size_t __size_; 17f4a2713aSLionel Sambuc #endif 18f4a2713aSLionel Sambuc initializer_list(const _E * __b,size_t __s)19f4a2713aSLionel Sambuc constexpr initializer_list(const _E* __b, size_t __s) 20f4a2713aSLionel Sambuc : __begin_(__b), 21f4a2713aSLionel Sambuc #ifdef USE_END 22f4a2713aSLionel Sambuc __end_(__b + __s) 23f4a2713aSLionel Sambuc #else 24f4a2713aSLionel Sambuc __size_(__s) 25f4a2713aSLionel Sambuc #endif 26f4a2713aSLionel Sambuc {} 27f4a2713aSLionel Sambuc 28f4a2713aSLionel Sambuc public: 29f4a2713aSLionel Sambuc typedef _E value_type; 30f4a2713aSLionel Sambuc typedef const _E& reference; 31f4a2713aSLionel Sambuc typedef const _E& const_reference; 32f4a2713aSLionel Sambuc typedef size_t size_type; 33f4a2713aSLionel Sambuc 34f4a2713aSLionel Sambuc typedef const _E* iterator; 35f4a2713aSLionel Sambuc typedef const _E* const_iterator; 36f4a2713aSLionel Sambuc 37f4a2713aSLionel Sambuc #ifdef USE_END initializer_list()38f4a2713aSLionel Sambuc constexpr initializer_list() : __begin_(nullptr), __end_(nullptr) {} 39f4a2713aSLionel Sambuc size() const40f4a2713aSLionel Sambuc size_t size() const {return __end_ - __begin_;} begin() const41f4a2713aSLionel Sambuc const _E* begin() const {return __begin_;} end() const42f4a2713aSLionel Sambuc const _E* end() const {return __end_;} 43f4a2713aSLionel Sambuc #else initializer_list()44f4a2713aSLionel Sambuc constexpr initializer_list() : __begin_(nullptr), __size_(0) {} 45f4a2713aSLionel Sambuc size() const46f4a2713aSLionel Sambuc size_t size() const {return __size_;} begin() const47f4a2713aSLionel Sambuc const _E* begin() const {return __begin_;} end() const48f4a2713aSLionel Sambuc const _E* end() const {return __begin_ + __size_;} 49f4a2713aSLionel Sambuc #endif 50f4a2713aSLionel Sambuc }; 51f4a2713aSLionel Sambuc } 52f4a2713aSLionel Sambuc 53f4a2713aSLionel Sambuc constexpr int a = 2, b = 4, c = 6; 54f4a2713aSLionel Sambuc std::initializer_list<std::initializer_list<int>> nested = { 55f4a2713aSLionel Sambuc {1, a}, {3, b}, {5, c} 56f4a2713aSLionel Sambuc }; 57f4a2713aSLionel Sambuc 58*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BL: @_ZGR6nested0_ = private constant [2 x i32] [i32 1, i32 2], align 4 59*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BL: @_ZGR6nested1_ = private constant [2 x i32] [i32 3, i32 4], align 4 60*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BL: @_ZGR6nested2_ = private constant [2 x i32] [i32 5, i32 6], align 4 61*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BL: @_ZGR6nested_ = private constant [3 x {{.*}}] [ 62*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BL: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested0_, i32 0, i32 0), i64 2 }, 63*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BL: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1_, i32 0, i32 0), i64 2 }, 64*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BL: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2_, i32 0, i32 0), i64 2 } 65f4a2713aSLionel Sambuc // CHECK-STATIC-BL: ], align 8 66*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BL: @nested = global {{.*}} { {{.*}} getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i32 0, i32 0), i64 3 }, align 8 67f4a2713aSLionel Sambuc 68f4a2713aSLionel Sambuc // CHECK-DYNAMIC-BL: @nested = global 69*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: @_ZGR6nested_ = private global [3 x 70*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: @_ZGR6nested0_ = private global [2 x i32] zeroinitializer 71*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: @_ZGR6nested1_ = private global [2 x i32] zeroinitializer 72*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: @_ZGR6nested2_ = private global [2 x i32] zeroinitializer 73*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i32 1, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested0_, i64 0, i64 0) 74*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested0_, i64 0, i64 1) 75*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested0_, i64 0, i64 0), 76*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 0, i32 0), align 8 77*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i64 2, i64* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 0, i32 1), align 8 78*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i32 3, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1_, i64 0, i64 0) 79*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1_, i64 0, i64 1) 80*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1_, i64 0, i64 0), 81*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 1, i32 0), align 8 82*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i64 2, i64* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 1, i32 1), align 8 83*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i32 5, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2_, i64 0, i64 0) 84*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2_, i64 0, i64 1) 85*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2_, i64 0, i64 0), 86*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 2, i32 0), align 8 87*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store i64 2, i64* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 2, i32 1), align 8 88*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BL: store {{.*}}* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 0), 89f4a2713aSLionel Sambuc // CHECK-DYNAMIC-BL: {{.*}}** getelementptr inbounds ({{.*}}* @nested, i32 0, i32 0), align 8 90f4a2713aSLionel Sambuc // CHECK-DYNAMIC-BL: store i64 3, i64* getelementptr inbounds ({{.*}}* @nested, i32 0, i32 1), align 8 91f4a2713aSLionel Sambuc 92*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: @_ZGR6nested0_ = private constant [2 x i32] [i32 1, i32 2], align 4 93*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: @_ZGR6nested1_ = private constant [2 x i32] [i32 3, i32 4], align 4 94*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: @_ZGR6nested2_ = private constant [2 x i32] [i32 5, i32 6], align 4 95*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: @_ZGR6nested_ = private constant [3 x {{.*}}] [ 96*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested0_, i32 0, i32 0), 97*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: i32* bitcast (i8* getelementptr (i8* bitcast ([2 x i32]* @_ZGR6nested0_ to i8*), i64 8) to i32*) } 98*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1_, i32 0, i32 0), 99*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: i32* bitcast (i8* getelementptr (i8* bitcast ([2 x i32]* @_ZGR6nested1_ to i8*), i64 8) to i32*) } 100*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: {{.*}} { i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2_, i32 0, i32 0), 101*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: i32* bitcast (i8* getelementptr (i8* bitcast ([2 x i32]* @_ZGR6nested2_ to i8*), i64 8) to i32*) } 102f4a2713aSLionel Sambuc // CHECK-STATIC-BE: ], align 8 103*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: @nested = global {{.*}} { {{.*}} getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i32 0, i32 0), 104*0a6a1f1dSLionel Sambuc // CHECK-STATIC-BE: {{.*}} bitcast ({{.*}}* getelementptr (i8* bitcast ([3 x {{.*}}]* @_ZGR6nested_ to i8*), i64 48) to {{.*}}*) } 105f4a2713aSLionel Sambuc 106f4a2713aSLionel Sambuc // CHECK-DYNAMIC-BE: @nested = global 107*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: @_ZGR6nested_ = private global [3 x 108*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: @_ZGR6nested0_ = private global [2 x i32] zeroinitializer 109*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: @_ZGR6nested1_ = private global [2 x i32] zeroinitializer 110*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: @_ZGR6nested2_ = private global [2 x i32] zeroinitializer 111*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32 1, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested0_, i64 0, i64 0) 112*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested0_, i64 0, i64 1) 113*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested0_, i64 0, i64 0), 114*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 0, i32 0), align 8 115*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested0_, i64 1, i64 0), 116*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 0, i32 1), align 8 117*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32 3, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1_, i64 0, i64 0) 118*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1_, i64 0, i64 1) 119*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1_, i64 0, i64 0), 120*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 1, i32 0), align 8 121*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested1_, i64 1, i64 0), 122*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 1, i32 1), align 8 123*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32 5, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2_, i64 0, i64 0) 124*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32 {{.*}}, i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2_, i64 0, i64 1) 125*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2_, i64 0, i64 0), 126*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 2, i32 0), align 8 127*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store i32* getelementptr inbounds ([2 x i32]* @_ZGR6nested2_, i64 1, i64 0), 128*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: i32** getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 2, i32 1), align 8 129*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store {{.*}}* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 0, i64 0), 130f4a2713aSLionel Sambuc // CHECK-DYNAMIC-BE: {{.*}}** getelementptr inbounds ({{.*}}* @nested, i32 0, i32 0), align 8 131*0a6a1f1dSLionel Sambuc // CHECK-DYNAMIC-BE: store {{.*}}* getelementptr inbounds ([3 x {{.*}}]* @_ZGR6nested_, i64 1, i64 0), 132f4a2713aSLionel Sambuc // CHECK-DYNAMIC-BE: {{.*}}** getelementptr inbounds ({{.*}}* @nested, i32 0, i32 1), align 8 133