]> granicus.if.org Git - clang/commitdiff
Make sure to grab CVR qualifiers from the canonical type. ARGH!
authorDouglas Gregor <dgregor@apple.com>
Thu, 5 Nov 2009 00:07:36 +0000 (00:07 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 5 Nov 2009 00:07:36 +0000 (00:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86079 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/overload-member-call.cpp
test/SemaTemplate/member-access-expr.cpp

index 946e28269eb6efd48b473c87b7de718a53fbaeef..dd009a062f009ab1b4c43c62358cbc5002705d7c 100644 (file)
@@ -2097,8 +2097,8 @@ Sema::TryObjectArgumentInitialization(Expr *From, CXXMethodDecl *Method) {
   // First check the qualifiers. We don't care about lvalue-vs-rvalue
   // with the implicit object parameter (C++ [over.match.funcs]p5).
   QualType FromTypeCanon = Context.getCanonicalType(FromType);
-  if (ImplicitParamType.getCVRQualifiers() != FromType.getCVRQualifiers() &&
-      !ImplicitParamType.isAtLeastAsQualifiedAs(FromType))
+  if (ImplicitParamType.getCVRQualifiers() != FromTypeCanon.getCVRQualifiers() &&
+      !ImplicitParamType.isAtLeastAsQualifiedAs(FromTypeCanon))
     return ICS;
 
   // Check that we have either the same type or a derived type. It
index 96e570da654b7b441b9cca3e31d50fd50acf63f5..937b65d633f9d8df9909b9249c5701488ce1050c 100644 (file)
@@ -54,3 +54,15 @@ void test(X x, const X xc, X* xp, const X* xcp, volatile X xv, volatile X* xvp)
   
   X::h(0); // expected-error{{call to non-static member function without an object argument}}
 }
+
+struct X1 {
+  int& member();
+  float& member() const;
+};
+
+struct X2 : X1 { };
+
+void test_X2(X2 *x2p, const X2 *cx2p) {
+  int &ir = x2p->member();
+  float &fr = cx2p->member();
+}
index 0a6a6bc0990e5f9233b860b2777b393542b6792f..ad0075f564b60ca4fe62ea826ef6c4b6c2ac65b0 100644 (file)
@@ -88,3 +88,20 @@ protected:
     (void)f0<0>();
   }
 };
+
+// Fun with template instantiation and conversions
+struct X4 {
+  int& member();
+  float& member() const;
+};
+
+template<typename T>
+struct X5 {
+  void f(T* ptr) { int& ir = ptr->member(); }
+  void g(T* ptr) { float& fr = ptr->member(); }
+};
+
+void test_X5(X5<X4> x5, X5<const X4> x5c, X4 *xp, const X4 *cxp) {
+  x5.f(xp);
+  x5c.g(cxp);
+}