p4.cpp revision b1a56e767cfb645fcb25027ab728dd5824d92615
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3namespace A {
4  class A {
5    friend void func(A);
6    friend A operator+(A,A);
7  };
8}
9
10namespace B {
11  class B {
12    static void func(B);
13  };
14  B operator+(B,B);
15}
16
17namespace D {
18  class D {};
19}
20
21namespace C {
22  class C {};
23  void func(C);
24  C operator+(C,C);
25  D::D operator+(D::D,D::D);
26}
27
28namespace D {
29  using namespace C;
30}
31
32namespace Test {
33  void test() {
34    func(A::A());
35    func(B::B()); // expected-error {{use of undeclared identifier 'func'}}
36    func(C::C());
37    A::A() + A::A();
38    B::B() + B::B();
39    C::C() + C::C();
40    D::D() + D::D(); // expected-error {{ invalid operands to binary expression ('D::D' and 'D::D') }}
41  }
42}
43
44// PR6716
45namespace test1 {
46  template <class T> class A {
47    template <class U> friend void foo(A &, U); // expected-note {{not viable: 1st argument ('A<int> const') would lose const qualifier}}
48  };
49
50  void test() {
51    const A<int> a;
52    foo(a, 10); // expected-error {{no matching function for call to 'foo'}}
53  }
54}
55