1 // RUN: %clang_cc1 -triple %itanium_abi_triple -verify %s
2 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - -std=c++98 | FileCheck %s --check-prefix=CHECK-CXX98
3 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - -std=c++11 | FileCheck %s --check-prefix=CHECK-CXX11
4 // expected-no-diagnostics
6 #if __cplusplus >= 201103L
7 // CHECK-CXX11: @_ZZ15InitRefWithListvE1r = internal constant ptr @_ZGRZ15InitRefWithListvE1r_
8 // CHECK-CXX11: @_ZGRZ15InitRefWithListvE1r_ = internal constant i32 123
9 int InitRefWithList() { static const int &r
= {123}; return r
; }
12 struct XPTParamDescriptor
{};
13 struct nsXPTParamInfo
{
14 nsXPTParamInfo(const XPTParamDescriptor
& desc
);
16 void a(XPTParamDescriptor
*params
) {
17 const nsXPTParamInfo
& paramInfo
= params
[0];
20 // CodeGen of reference initialized const arrays.
22 template <typename T
, int N
> int f(const T (&a
)[N
]) { return N
; }
24 int test() { return f(iarr
); }
27 struct Foo
{ int foo
; };
28 Foo
& ignoreSetMutex
= *(new Foo
);
30 // Binding to a bit-field that requires a temporary.
31 struct { int bitfield
: 3; } s
= { 3 };
32 const int &s2
= s
.bitfield
;
34 // In C++98, this forms a reference to itself. In C++11 onwards, this performs
36 struct SelfReference
{ SelfReference
&r
; };
37 extern SelfReference self_reference_1
;
38 SelfReference self_reference_2
= {self_reference_1
};
39 // CHECK-CXX98: @self_reference_2 = {{.*}}global %[[SELF_REF:.*]] { ptr @self_reference_1 }
40 // CHECK-CXX11: @self_reference_2 = {{(dso_local )?}}global %[[SELF_REF:.*]] zeroinitializer
41 // CHECK-CXX11: call {{.*}}memcpy{{.*}} @self_reference_2, {{.*}} @self_reference_1