Skip to content

Commit 01e4a7f

Browse files
committedJun 9, 2017
27037: Use correct CVR qualifier on an upcast on method pointer call
Patch by Taiju Tsuiki! Differential Revision: https://reviews.llvm.org/D33875 llvm-svn: 305126
1 parent c4c33ce commit 01e4a7f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
 

‎clang/lib/Sema/SemaExprCXX.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -5106,7 +5106,9 @@ QualType Sema::CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS,
51065106
return QualType();
51075107

51085108
// Cast LHS to type of use.
5109-
QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
5109+
QualType UseType = Context.getQualifiedType(Class, LHSType.getQualifiers());
5110+
if (isIndirect)
5111+
UseType = Context.getPointerType(UseType);
51105112
ExprValueKind VK = isIndirect ? VK_RValue : LHS.get()->getValueKind();
51115113
LHS = ImpCastExprToType(LHS.get(), UseType, CK_DerivedToBase, VK,
51125114
&BasePath);

‎clang/test/SemaCXX/PR27037.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
2+
3+
struct A {
4+
void f();
5+
};
6+
7+
struct B : A {};
8+
9+
void m() {
10+
const B b;
11+
(b.*&B::f)(); // expected-error{{drops 'const' qualifier}}
12+
((&b)->*&B::f)(); // expected-error{{drops 'const' qualifier}}
13+
}

0 commit comments

Comments
 (0)