summaryrefslogtreecommitdiff
path: root/clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
blob: bf30ee74a567659816813b0b85423a70963b003a (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// RUN: %clang_cc1 -fsyntax-only -verify %s

// We have to avoid ADL for this test.

template <unsigned N> class test {};

class foo {};	// expected-note {{candidate}}
test<0> foo(foo); // expected-note {{candidate}}

namespace Test0 {
  class foo { int x; };
  test<1> foo(class foo);

  namespace A {
    test<2> foo(class ::foo); // expected-note {{candidate}} \
    // expected-note{{passing argument to parameter here}}

    void test0() {
      using ::foo;

      class foo a;
      test<0> _ = (foo)(a);
    }

    void test1() {
      using Test0::foo;

      class foo a;
      test<1> _ = (foo)(a);
    };

    void test2() {
      class ::foo a;
      
      // Argument-dependent lookup is ambiguous between B:: and ::.
      test<0> _0 = foo(a); // expected-error {{call to 'foo' is ambiguous}}

      // But basic unqualified lookup is not.
      test<2> _1 = (foo)(a);

      class Test0::foo b;
      test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class ::foo'}}
    }
  }
}

namespace Test1 {
  namespace A {
    class a {};
  }

  namespace B {
    typedef class {} b;
  }

  namespace C {
    int c(); // expected-note {{target of using declaration}}
  }

  namespace D {
    using typename A::a;
    using typename B::b;
    using typename C::c; // expected-error {{'typename' keyword used on a non-type}}

    a _1 = A::a();
    b _2 = B::b();
  }
}

namespace test2 {
  class A {
  protected:
    operator int();
    operator bool();
  };

  class B : private A {
  protected:
    using A::operator int; // expected-note {{declared protected here}}
  public:
    using A::operator bool;
  };

  int test() {
    bool b = B();
    return B(); // expected-error {{'operator int' is a protected member of 'test2::B'}}
  }
}

namespace test3 {
  class A {
  public:
    ~A();
  };

  class B {
    friend class C;
  private:
    operator A*();
  };

  class C : public B {
  public:
    using B::operator A*;
  };

  void test() {
    delete C();
  }
}