File tree 2 files changed +35
-2
lines changed 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -2711,6 +2711,20 @@ Sema::PerformObjectMemberConversion(Expr *From,
2711
2711
FromRecordType = FromType;
2712
2712
DestType = DestRecordType;
2713
2713
}
2714
+
2715
+ LangAS FromAS = FromRecordType.getAddressSpace();
2716
+ LangAS DestAS = DestRecordType.getAddressSpace();
2717
+ if (FromAS != DestAS) {
2718
+ QualType FromRecordTypeWithoutAS =
2719
+ Context.removeAddrSpaceQualType(FromRecordType);
2720
+ QualType FromTypeWithDestAS =
2721
+ Context.getAddrSpaceQualType(FromRecordTypeWithoutAS, DestAS);
2722
+ if (PointerConversions)
2723
+ FromTypeWithDestAS = Context.getPointerType(FromTypeWithDestAS);
2724
+ From = ImpCastExprToType(From, FromTypeWithDestAS,
2725
+ CK_AddressSpaceConversion, From->getValueKind())
2726
+ .get();
2727
+ }
2714
2728
} else {
2715
2729
// No conversion necessary.
2716
2730
return From;
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ void foo() {
28
28
class B2 {
29
29
public :
30
30
void baseMethod () const { }
31
+ int &getRef () { return bb ; }
31
32
int bb ;
32
33
};
33
34
@@ -46,7 +47,25 @@ void pr43145(const Derived *argDerived) {
46
47
47
48
void pr43145_2 (B *argB ) {
48
49
Derived *x = (Derived *)argB ;
50
+ // CHECK -LABEL : @_Z9pr43145_2
51
+ // CHECK : bitcast %struct .B addrspace (4 )* %0 to %class .Derived addrspace (4 )*
49
52
}
50
53
51
- // CHECK -LABEL : @_Z9pr43145_2
52
- // CHECK : bitcast %struct .B addrspace (4 )* %0 to %class .Derived addrspace (4 )*
54
+ // Assigning to reference returned by base class method through derived class .
55
+
56
+ void pr43145_3 (int n ) {
57
+ Derived d ;
58
+ d .getRef () = n ;
59
+
60
+ // CHECK -LABEL : @_Z9pr43145_3
61
+ // CHECK : addrspacecast %class .Derived * %d to %class .Derived addrspace (4 )*
62
+ // CHECK : bitcast i8 addrspace (4 )* %add .ptr to %class .B2 addrspace (4 )*
63
+ // CHECK : call {{.*}} @_ZNU3AS42B26getRefEv
64
+
65
+ private Derived *pd = &d ;
66
+ pd ->getRef () = n ;
67
+
68
+ // CHECK : addrspacecast %class .Derived * %4 to %class .Derived addrspace (4 )*
69
+ // CHECK : bitcast i8 addrspace (4 )* %add .ptr1 to %class .B2 addrspace (4 )*
70
+ // CHECK : call {{.*}} @_ZNU3AS42B26getRefEv
71
+ }
You can’t perform that action at this time.
0 commit comments