blob: 38c8829347c2d32af6b0900b5d4bdf1de80c8d99 [file] [log] [blame]
John McCalla8f28da2010-08-25 02:50:31 +00001// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2
3// Check that IR gen doesn't try to do an lvalue-to-rvalue conversion
4// on a volatile reference result. rdar://problem/8338198
5namespace test0 {
6 struct A {
7 A(const A& t);
8 A& operator=(const A& t);
9 volatile A& operator=(const volatile A& t) volatile;
10 };
11
12 volatile A *array;
13
Stephen Lin93ab6bf2013-08-15 06:47:53 +000014 // CHECK-LABEL: define void @_ZN5test04testENS_1AE(
John McCalla8f28da2010-08-25 02:50:31 +000015 void test(A t) {
16 // CHECK: [[ARR:%.*]] = load [[A:%.*]]** @_ZN5test05arrayE, align 8
17 // CHECK-NEXT: [[IDX:%.*]] = getelementptr inbounds [[A]]* [[ARR]], i64 0
18 // CHECK-NEXT: [[TMP:%.*]] = call [[A]]* @_ZNV5test01AaSERVKS0_([[A]]* [[IDX]], [[A]]* [[T:%.*]])
19 // CHECK-NEXT: ret void
20 array[0] = t;
21 }
22}
23
24namespace test1 {
25 volatile int *x;
26
Stephen Lin93ab6bf2013-08-15 06:47:53 +000027 // CHECK-LABEL: define void @_ZN5test14testEv()
John McCalla8f28da2010-08-25 02:50:31 +000028 void test() {
29 // CHECK: [[TMP:%.*]] = load i32** @_ZN5test11xE, align 8
John McCalla8f28da2010-08-25 02:50:31 +000030 // CHECK-NEXT: ret void
31 *x;
32 }
33}