r305126 - 27037: Use correct CVR qualifier on an upcast on method pointer call
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 9 15:25:31 PDT 2017
Author: rsmith
Date: Fri Jun 9 17:25:28 2017
New Revision: 305126
URL: http://llvm.org/viewvc/llvm-project?rev=305126&view=rev
Log:
27037: Use correct CVR qualifier on an upcast on method pointer call
Patch by Taiju Tsuiki!
Differential Revision: https://reviews.llvm.org/D33875
Added:
cfe/trunk/test/SemaCXX/PR27037.cpp
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=305126&r1=305125&r2=305126&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Jun 9 17:25:28 2017
@@ -5106,7 +5106,9 @@ QualType Sema::CheckPointerToMemberOpera
return QualType();
// Cast LHS to type of use.
- QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
+ QualType UseType = Context.getQualifiedType(Class, LHSType.getQualifiers());
+ if (isIndirect)
+ UseType = Context.getPointerType(UseType);
ExprValueKind VK = isIndirect ? VK_RValue : LHS.get()->getValueKind();
LHS = ImpCastExprToType(LHS.get(), UseType, CK_DerivedToBase, VK,
&BasePath);
Added: cfe/trunk/test/SemaCXX/PR27037.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR27037.cpp?rev=305126&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/PR27037.cpp (added)
+++ cfe/trunk/test/SemaCXX/PR27037.cpp Fri Jun 9 17:25:28 2017
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A {
+ void f();
+};
+
+struct B : A {};
+
+void m() {
+ const B b;
+ (b.*&B::f)(); // expected-error{{drops 'const' qualifier}}
+ ((&b)->*&B::f)(); // expected-error{{drops 'const' qualifier}}
+}
More information about the cfe-commits
mailing list