Home | History | Annotate | Download | only in SemaCXX
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
      2 // expected-no-diagnostics
      3 
      4 // 13.3.3.2 Ranking implicit conversion sequences
      5 // conversion of A::* to B::* is better than conversion of A::* to C::*,
      6 struct A {
      7 int Ai;
      8 };
      9 
     10 struct B : public A {};
     11 struct C : public B {};
     12 
     13 const char * f(int C::*){ return ""; }
     14 int f(int B::*) { return 1; }
     15 
     16 struct D : public C {};
     17 
     18 const char * g(int B::*){ return ""; }
     19 int g(int D::*) { return 1; }
     20 
     21 void test()
     22 {
     23   int i = f(&A::Ai);
     24 
     25   const char * str = g(&A::Ai);
     26 }
     27 
     28 // conversion of B::* to C::* is better than conversion of A::* to C::*
     29 typedef void (A::*pmfa)();
     30 typedef void (B::*pmfb)();
     31 typedef void (C::*pmfc)();
     32 
     33 struct X {
     34 	operator pmfa();
     35 	operator pmfb();
     36 };
     37 
     38 
     39 void g(pmfc);
     40 
     41 void test2(X x)
     42 {
     43     g(x);
     44 }
     45 
     46