blob: 924cf077b63f01f144d1e1b29a672b7360454f24 [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Douglas Gregor2a3009a2009-02-03 19:21:40 +00002
3namespace A {
Douglas Gregor31a19b62009-04-01 21:51:26 +00004 short i; // expected-note 2{{candidate found by name lookup is 'A::i'}}
Douglas Gregor2a3009a2009-02-03 19:21:40 +00005 namespace B {
6 long i; // expected-note{{candidate found by name lookup is 'A::B::i'}}
7 void f() {} // expected-note{{candidate function}}
8 int k;
9 namespace E {} // \
10 expected-note{{candidate found by name lookup is 'A::B::E'}}
11 }
12
13 namespace E {} // expected-note{{candidate found by name lookup is 'A::E'}}
14
15 namespace C {
16 using namespace B;
17 namespace E {} // \
18 expected-note{{candidate found by name lookup is 'A::C::E'}}
19 }
20
21 void f() {} // expected-note{{candidate function}}
22
23 class K1 {
24 void foo();
25 };
26
27 void local_i() {
28 char i;
29 using namespace A;
30 using namespace B;
31 int a[sizeof(i) == sizeof(char)? 1 : -1]; // okay
32 }
33 namespace B {
34 int j;
35 }
36
37 void ambig_i() {
38 using namespace A;
39 using namespace A::B;
40 (void) i; // expected-error{{reference to 'i' is ambiguous}}
41 f(); // expected-error{{call to 'f' is ambiguous}}
42 (void) j; // okay
43 using namespace C;
44 (void) k; // okay
45 using namespace E; // expected-error{{reference to 'E' is ambiguous}}
46 }
47
48 struct K2 {}; // expected-note{{candidate found by name lookup is 'A::K2'}}
49}
50
51struct K2 {}; // expected-note{{candidate found by name lookup is 'K2'}}
52
53using namespace A;
54
55void K1::foo() {} // okay
56
57// FIXME: Do we want err_ovl_no_viable_function_in_init here?
58struct K2 k2; // expected-error{{reference to 'K2' is ambiguous}} \
Douglas Gregor31a19b62009-04-01 21:51:26 +000059 expected-error{{incomplete type}}
Douglas Gregor2a3009a2009-02-03 19:21:40 +000060
61// FIXME: This case is incorrectly diagnosed!
62//K2 k3;
63
64
Douglas Gregor7dda67d2009-02-05 19:25:20 +000065class X { // expected-note{{candidate found by name lookup is 'X'}}
Douglas Gregor2a3009a2009-02-03 19:21:40 +000066 // FIXME: produce a suitable error message for this
Douglas Gregor31a19b62009-04-01 21:51:26 +000067 using namespace A; // expected-error{{expected member name or}}
Douglas Gregor2a3009a2009-02-03 19:21:40 +000068};
69
70namespace N {
Douglas Gregore2c565d2009-02-03 19:26:08 +000071 struct K2;
72 struct K2 { };
Douglas Gregor2a3009a2009-02-03 19:21:40 +000073}
Douglas Gregor7dda67d2009-02-05 19:25:20 +000074
75namespace Ni {
76 int i(); // expected-note{{candidate found by name lookup is 'Ni::i'}}
77}
78
79namespace NiTest {
80 using namespace A;
81 using namespace Ni;
82
83 int test() {
84 return i; // expected-error{{reference to 'i' is ambiguous}}
85 }
86}
87
88namespace OneTag {
89 struct X; // expected-note{{candidate found by name lookup is 'OneTag::X'}}
90}
91
92namespace OneFunction {
93 void X(); // expected-note{{candidate found by name lookup is 'OneFunction::X'}}
94}
95
96namespace TwoTag {
Douglas Gregor841b53c2009-04-13 15:14:38 +000097 struct X; // expected-note{{candidate found by name lookup is 'TwoTag::X'}}
Douglas Gregor7dda67d2009-02-05 19:25:20 +000098}
99
100namespace FuncHidesTagAmbiguity {
101 using namespace OneTag;
102 using namespace OneFunction;
103 using namespace TwoTag;
104
105 void test() {
Douglas Gregor841b53c2009-04-13 15:14:38 +0000106 (void)X(); // expected-error{{reference to 'X' is ambiguous}}
Douglas Gregor7dda67d2009-02-05 19:25:20 +0000107 }
108}