Home | History | Annotate | Download | only in namespace.udecl
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 
      3 // C++03 [namespace.udecl]p3:
      4 //   For the purpose of overload resolution, the functions which are
      5 //   introduced by a using-declaration into a derived class will be
      6 //   treated as though they were members of the derived class. In
      7 //   particular, the implicit this parameter shall be treated as if it
      8 //   were a pointer to the derived class rather than to the base
      9 //   class. This has no effect on the type of the function, and in all
     10 //   other respects the function remains a member of the base class.
     11 
     12 namespace test0 {
     13   struct Opaque0 {};
     14   struct Opaque1 {};
     15 
     16   struct Base {
     17     Opaque0 test0(int*);
     18     Opaque0 test1(const int*);
     19     Opaque0 test2(int*);
     20     Opaque0 test3(int*) const;
     21   };
     22 
     23   struct Derived : Base {
     24     using Base::test0;
     25     Opaque1 test0(const int*);
     26 
     27     using Base::test1;
     28     Opaque1 test1(int*);
     29 
     30     using Base::test2;
     31     Opaque1 test2(int*) const;
     32 
     33     using Base::test3;
     34     Opaque1 test3(int*);
     35   };
     36 
     37   void test0() {
     38     Opaque0 a = Derived().test0((int*) 0);
     39     Opaque1 b = Derived().test0((const int*) 0);
     40   }
     41 
     42   void test1() {
     43     Opaque1 a = Derived().test1((int*) 0);
     44     Opaque0 b = Derived().test1((const int*) 0);
     45   }
     46 
     47   void test2() {
     48     Opaque0 a = ((Derived*) 0)->test2((int*) 0);
     49     Opaque1 b = ((const Derived*) 0)->test2((int*) 0);
     50   }
     51 
     52   void test3() {
     53     Opaque1 a = ((Derived*) 0)->test3((int*) 0);
     54     Opaque0 b = ((const Derived*) 0)->test3((int*) 0);
     55   }
     56 }
     57 
     58 // Typedef redeclaration.
     59 namespace rdar8018262 {
     60   typedef void (*fp)();
     61 
     62   namespace N {
     63     typedef void (*fp)();
     64   }
     65 
     66   using N::fp;
     67 
     68   fp fp_1;
     69 }
     70 
     71 // Things to test:
     72 //   member operators
     73 //   conversion operators
     74 //   call operators
     75 //   call-surrogate conversion operators
     76 //   everything, but in dependent contexts
     77