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