xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/cxx1y-variable-template.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++1y -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // Check that we keep the 'extern' when we instantiate the definition of this
4*f4a2713aSLionel Sambuc // variable template specialization.
5*f4a2713aSLionel Sambuc template<typename T> extern const int extern_redecl;
6*f4a2713aSLionel Sambuc template<typename T> const int extern_redecl = 5;
7*f4a2713aSLionel Sambuc template const int extern_redecl<int>;
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc // CHECK: @_Z13extern_redeclIiE = weak_odr constant
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc template<typename T> struct Outer {
12*f4a2713aSLionel Sambuc   template<typename U> struct Inner {
13*f4a2713aSLionel Sambuc     template<typename V> static int arr[];
14*f4a2713aSLionel Sambuc   };
15*f4a2713aSLionel Sambuc };
16*f4a2713aSLionel Sambuc Outer<char[100]> outer_int;
17*f4a2713aSLionel Sambuc int init_arr();
18*f4a2713aSLionel Sambuc template<typename T> template<typename U> template<typename V> int Outer<T>::Inner<U>::arr[sizeof(T) + sizeof(U) + sizeof(V)] = { init_arr() };
19*f4a2713aSLionel Sambuc int *p = Outer<char[100]>::Inner<char[20]>::arr<char[3]>;
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc // CHECK: @_ZN5OuterIA100_cE5InnerIA20_cE3arrIA3_cEE = weak_odr global [123 x i32] zeroinitializer
22*f4a2713aSLionel Sambuc // CHECK: @_ZGVN5OuterIA100_cE5InnerIA20_cE3arrIA3_cEE = weak_odr global
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc // CHECK: call {{.*}}@_Z8init_arrv
25