This revision was automatically updated to reflect the committed changes.
Closed by commit rL305126: 27037: Use correct CVR qualifier on an upcast on 
method pointer call (authored by rsmith).

Changed prior to commit:
  https://reviews.llvm.org/D33875?vs=101536&id=102081#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33875

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/SemaCXX/PR27037.cpp


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -5106,7 +5106,9 @@
       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);
Index: cfe/trunk/test/SemaCXX/PR27037.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/PR27037.cpp
+++ cfe/trunk/test/SemaCXX/PR27037.cpp
@@ -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}}
+}


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -5106,7 +5106,9 @@
       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);
Index: cfe/trunk/test/SemaCXX/PR27037.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/PR27037.cpp
+++ cfe/trunk/test/SemaCXX/PR27037.cpp
@@ -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}}
+}
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to