]> granicus.if.org Git - clang/commitdiff
Fix diagnostic message for member function pointer mismatches where one of the
authorRichard Trieu <rtrieu@google.com>
Tue, 20 May 2014 04:10:24 +0000 (04:10 +0000)
committerRichard Trieu <rtrieu@google.com>
Tue, 20 May 2014 04:10:24 +0000 (04:10 +0000)
classes is a template argument.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209190 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/err_init_conversion_failed.cpp

index af7aeae30329c25b1daf1a20dba02bbd48f9cc5f..3ea939f4cdc5dfb42fe2e11142ca6d529c47774d 100644 (file)
@@ -2526,7 +2526,8 @@ void Sema::HandleFunctionTypeMismatch(PartialDiagnostic &PDiag,
   if (FromType->isMemberPointerType() && ToType->isMemberPointerType()) {
     const MemberPointerType *FromMember = FromType->getAs<MemberPointerType>(),
                             *ToMember = ToType->getAs<MemberPointerType>();
-    if (FromMember->getClass() != ToMember->getClass()) {
+    if (FromMember->getClass()->getCanonicalTypeInternal() !=
+        ToMember->getClass()->getCanonicalTypeInternal()) {
       PDiag << ft_different_class << QualType(ToMember->getClass(), 0)
             << QualType(FromMember->getClass(), 0);
       return;
index 0652e7a9ea6afc3b2951222bda895f54fbfea55d..14d49547438e941260ee2d606b7faf1d12abcad4 100644 (file)
@@ -43,3 +43,19 @@ void test14(const float2 in, const float2 out) {
   const float4 V = (float4){ in, out };
   // expected-error@-1{{cannot initialize a compound literal initializer}}
 }
+
+namespace template_test {
+class S {
+public:
+   void foo(int);
+};
+
+template <class P> struct S2 {
+  void (P::*a)(const int &);
+};
+
+void test_15() {
+  S2<S> X = {&S::foo};
+  // expected-error@-1{{cannot initialize a member subobject of type 'void (template_test::S::*)(const int &)' with an rvalue of type 'void (template_test::S::*)(int)': type mismatch at 1st parameter ('const int &' vs 'int')}}
+}
+}