using-directive.cpp revision d7d5f0223bd30dfd618762349c6209dd1d5ea3e6
1// RUN: clang-cc -fsyntax-only -verify %s
2// XFAIL
3// fails due to exact diagnostic matching
4
5namespace A {
6  short i; // expected-note{{candidate found by name lookup is 'A::i'}}
7  namespace B {
8    long i; // expected-note{{candidate found by name lookup is 'A::B::i'}}
9    void f() {} // expected-note{{candidate function}}
10    int k;
11    namespace E {} // \
12      expected-note{{candidate found by name lookup is 'A::B::E'}}
13  }
14
15  namespace E {} // expected-note{{candidate found by name lookup is 'A::E'}}
16
17  namespace C {
18    using namespace B;
19    namespace E {} // \
20      expected-note{{candidate found by name lookup is 'A::C::E'}}
21  }
22
23  void f() {} // expected-note{{candidate function}}
24
25  class K1 {
26    void foo();
27  };
28
29  void local_i() {
30    char i;
31    using namespace A;
32    using namespace B;
33    int a[sizeof(i) == sizeof(char)? 1 : -1]; // okay
34  }
35  namespace B {
36    int j;
37  }
38
39  void ambig_i() {
40    using namespace A;
41    using namespace A::B;
42    (void) i; // expected-error{{reference to 'i' is ambiguous}}
43    f(); // expected-error{{call to 'f' is ambiguous}}
44    (void) j; // okay
45    using namespace C;
46    (void) k; // okay
47    using namespace E; // expected-error{{reference to 'E' is ambiguous}}
48  }
49
50  struct K2 {}; // expected-note{{candidate found by name lookup is 'A::K2'}}
51}
52
53struct K2 {}; // expected-note{{candidate found by name lookup is 'K2'}}
54
55using namespace A;
56
57void K1::foo() {} // okay
58
59// FIXME: Do we want err_ovl_no_viable_function_in_init here?
60struct K2 k2; // expected-error{{reference to 'K2' is ambiguous}} \
61                 expected-error{{no matching constructor}}
62
63// FIXME: This case is incorrectly diagnosed!
64//K2 k3;
65
66
67class X { // expected-note{{candidate found by name lookup is 'X'}}
68  // FIXME: produce a suitable error message for this
69  using namespace A; // expected-error{{expected unqualified-id}}
70};
71
72namespace N {
73  struct K2;
74  struct K2 { };
75}
76
77namespace Ni {
78 int i(); // expected-note{{candidate found by name lookup is 'Ni::i'}}
79}
80
81namespace NiTest {
82 using namespace A;
83 using namespace Ni;
84
85 int test() {
86   return i; // expected-error{{reference to 'i' is ambiguous}}
87 }
88}
89
90namespace OneTag {
91  struct X; // expected-note{{candidate found by name lookup is 'OneTag::X'}}
92}
93
94namespace OneFunction {
95  void X(); // expected-note{{candidate found by name lookup is 'OneFunction::X'}}
96}
97
98namespace TwoTag {
99  struct X; // expected-note{{candidate found by name lookup is 'TwoTag::X'}}
100}
101
102namespace FuncHidesTagAmbiguity {
103  using namespace OneTag;
104  using namespace OneFunction;
105  using namespace TwoTag;
106
107  void test() {
108    (void)X(); // expected-error{{reference to 'X' is ambiguous}}
109  }
110}
111