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 5 6 #if __cplusplus >= 201103L 7 // CHECK-CXX11: @_ZZ15InitRefWithListvE1r = internal constant ptr @_ZGRZ15InitRefWithListvE1r_ 8 // CHECK-CXX11: @_ZGRZ15InitRefWithListvE1r_ = internal constant i32 123 InitRefWithList()9int InitRefWithList() { static const int &r = {123}; return r; } 10 #endif 11 12 struct XPTParamDescriptor {}; 13 struct nsXPTParamInfo { 14 nsXPTParamInfo(const XPTParamDescriptor& desc); 15 }; a(XPTParamDescriptor * params)16void a(XPTParamDescriptor *params) { 17 const nsXPTParamInfo& paramInfo = params[0]; 18 } 19 20 // CodeGen of reference initialized const arrays. 21 namespace PR5911 { f(const T (& a)[N])22 template <typename T, int N> int f(const T (&a)[N]) { return N; } 23 int iarr[] = { 1 }; test()24 int test() { return f(iarr); } 25 } 26 27 struct Foo { int foo; }; 28 Foo& ignoreSetMutex = *(new Foo); 29 30 // Binding to a bit-field that requires a temporary. 31 struct { int bitfield : 3; } s = { 3 }; 32 const int &s2 = s.bitfield; 33 34 // In C++98, this forms a reference to itself. In C++11 onwards, this performs 35 // copy-construction. 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 42