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 | namespace A { |
6 | class A { |
7 | friend void func(A); |
8 | friend A operator+(A,A); |
9 | }; |
10 | } |
11 | |
12 | namespace B { |
13 | class B { |
14 | static void func(B); |
15 | }; |
16 | B operator+(B,B); |
17 | } |
18 | |
19 | namespace D { |
20 | class D {}; |
21 | } |
22 | |
23 | namespace C { |
24 | class C {}; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'B::B' to 'const C::C &' for 1st argument}} |
25 | #if __cplusplus >= 201103L // C++11 or later |
26 | // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'B::B' to 'C::C &&' for 1st argument}} |
27 | #endif |
28 | void func(C); // expected-note {{'C::func' declared here}} \ |
29 | // expected-note {{passing argument to parameter here}} |
30 | C operator+(C,C); |
31 | D::D operator+(D::D,D::D); |
32 | } |
33 | |
34 | namespace D { |
35 | using namespace C; |
36 | } |
37 | |
38 | namespace Test { |
39 | void test() { |
40 | func(A::A()); |
41 | // FIXME: namespace-aware typo correction causes an extra, misleading |
42 | // message in this case; some form of backtracking, diagnostic message |
43 | // delaying, or argument checking before emitting diagnostics is needed to |
44 | // avoid accepting and printing out a typo correction that proves to be |
45 | // incorrect once argument-dependent lookup resolution has occurred. |
46 | func(B::B()); // expected-error {{use of undeclared identifier 'func'; did you mean 'C::func'?}} \ |
47 | // expected-error {{no viable conversion from 'B::B' to 'C::C'}} |
48 | func(C::C()); |
49 | A::A() + A::A(); |
50 | B::B() + B::B(); |
51 | C::C() + C::C(); |
52 | D::D() + D::D(); // expected-error {{invalid operands to binary expression ('D::D' and 'D::D')}} |
53 | } |
54 | } |
55 | |
56 | // PR6716 |
57 | namespace test1 { |
58 | template <class T> class A { |
59 | template <class U> friend void foo(A &, U); // expected-note {{not viable: 1st argument ('const A<int>') would lose const qualifier}} |
60 | |
61 | public: |
62 | A(); |
63 | }; |
64 | |
65 | void test() { |
66 | const A<int> a; |
67 | foo(a, 10); // expected-error {{no matching function for call to 'foo'}} |
68 | } |
69 | } |
70 | |