1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
2 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s |
3 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
4 | |
5 | // We have to avoid ADL for this test. |
6 | |
7 | template <unsigned N> class test {}; |
8 | |
9 | class foo {}; // expected-note {{candidate constructor (the implicit copy constructor) not viable}} |
10 | #if __cplusplus >= 201103L // C++11 or later |
11 | // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} |
12 | #endif |
13 | test<0> foo(foo); // expected-note {{candidate}} |
14 | |
15 | namespace Test0 { |
16 | class foo { int x; }; |
17 | test<1> foo(class foo); |
18 | |
19 | namespace A { |
20 | test<2> foo(class ::foo); // expected-note {{candidate}} \ |
21 | // expected-note{{passing argument to parameter here}} |
22 | |
23 | void test0() { |
24 | using ::foo; |
25 | |
26 | class foo a; |
27 | test<0> _ = (foo)(a); |
28 | } |
29 | |
30 | void test1() { |
31 | using Test0::foo; |
32 | |
33 | class foo a; |
34 | test<1> _ = (foo)(a); |
35 | }; |
36 | |
37 | void test2() { |
38 | class ::foo a; |
39 | |
40 | // Argument-dependent lookup is ambiguous between B:: and ::. |
41 | test<0> _0 = foo(a); // expected-error {{call to 'foo' is ambiguous}} |
42 | |
43 | // But basic unqualified lookup is not. |
44 | test<2> _1 = (foo)(a); |
45 | |
46 | class Test0::foo b; |
47 | test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class ::foo'}} |
48 | } |
49 | } |
50 | } |
51 | |
52 | namespace Test1 { |
53 | namespace A { |
54 | class a {}; |
55 | } |
56 | |
57 | namespace B { |
58 | typedef class {} b; |
59 | } |
60 | |
61 | namespace C { |
62 | int c(); // expected-note {{target of using declaration}} |
63 | } |
64 | |
65 | namespace D { |
66 | using typename A::a; |
67 | using typename B::b; |
68 | using typename C::c; // expected-error {{'typename' keyword used on a non-type}} |
69 | |
70 | a _1 = A::a(); |
71 | b _2 = B::b(); |
72 | } |
73 | } |
74 | |
75 | namespace test2 { |
76 | class A { |
77 | protected: |
78 | operator int(); |
79 | operator bool(); |
80 | }; |
81 | |
82 | class B : private A { |
83 | protected: |
84 | using A::operator int; // expected-note {{declared protected here}} |
85 | public: |
86 | using A::operator bool; |
87 | }; |
88 | |
89 | int test() { |
90 | bool b = B(); |
91 | return B(); // expected-error {{'operator int' is a protected member of 'test2::B'}} |
92 | } |
93 | } |
94 | |
95 | namespace test3 { |
96 | class A { |
97 | public: |
98 | ~A(); |
99 | }; |
100 | |
101 | class B { |
102 | friend class C; |
103 | private: |
104 | operator A*(); |
105 | }; |
106 | |
107 | class C : public B { |
108 | public: |
109 | using B::operator A*; |
110 | }; |
111 | |
112 | void test() { |
113 | delete C(); |
114 | } |
115 | } |
116 | |