blob: 17071345d3fb0ddc96eaa4a26a637065276e80b8 (
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
// { dg-options "-fdiagnostics-show-caret" }
/* Various tests of name lookup within a namespace, both within an explicitly
given namespace, or implicitly. */
namespace detail {
/* Various things to look for. */
typedef int some_typedef;
int _foo(int i) { return i; }
template <typename T>
T something_else (T i) { return i; }
}
/* Tests of lookup of a typedef. */
void fn_1_explicit ()
{
detail::some_type i; // { dg-error ".some_type. is not a member of .detail.; did you mean 'some_typedef'\\?" }
/* { dg-begin-multiline-output "" }
detail::some_type i;
^~~~~~~~~
some_typedef
{ dg-end-multiline-output "" } */
}
namespace detail {
void fn_1_implicit ()
{
some_type i; // { dg-error ".some_type. was not declared in this scope; did you mean 'some_typedef'\\?" }
/* { dg-begin-multiline-output "" }
some_type i;
^~~~~~~~~
some_typedef
{ dg-end-multiline-output "" } */
}
} // namespace detail
/* Tests of lookup of a function. */
void fn_2_explicit (int i) {
detail::foo(i); // { dg-error ".foo. is not a member of .detail.; did you mean '_foo'\\?" }
/* { dg-begin-multiline-output "" }
detail::foo(i);
^~~
_foo
{ dg-end-multiline-output "" } */
}
namespace detail {
void fn_2_implicit (int i) {
foo(i); // { dg-error ".foo. was not declared in this scope; did you mean '_foo'\\?" }
/* { dg-begin-multiline-output "" }
foo(i);
^~~
_foo
{ dg-end-multiline-output "" } */
}
} // namespace detail
/* Examples using a template. */
void fn_3_explicit (int i) {
detail::something_els(i); // { dg-error ".something_els. is not a member of .detail.; did you mean 'something_else'\\?" }
/* { dg-begin-multiline-output "" }
detail::something_els(i);
^~~~~~~~~~~~~
something_else
{ dg-end-multiline-output "" } */
}
namespace detail {
void fn_3_implicit (int i) {
something_els(i); // { dg-error ".something_els. was not declared in this scope; did you mean 'something_else'\\?" }
/* { dg-begin-multiline-output "" }
something_els(i);
^~~~~~~~~~~~~
something_else
{ dg-end-multiline-output "" } */
}
} // namespace detail
/* Tests of lookup for which no hint is available. */
void fn_4_explicit (int i) {
detail::not_recognized(i); // { dg-error ".not_recognized. is not a member of .detail." }
/* { dg-begin-multiline-output "" }
detail::not_recognized(i);
^~~~~~~~~~~~~~
{ dg-end-multiline-output "" } */
}
namespace detail {
void fn_4_implicit (int i)
{
not_recognized(i); // { dg-error ".not_recognized. was not declared in this scope" }
/* { dg-begin-multiline-output "" }
not_recognized(i);
^~~~~~~~~~~~~~
{ dg-end-multiline-output "" } */
}
} // namespace detail
/* Test for failed lookup explicitly within global namespace. */
typedef int another_typedef;
void fn_5 ()
{
::another_type i; // { dg-error ".::another_type. has not been declared; did you mean 'another_typedef'\\?" }
/* { dg-begin-multiline-output "" }
::another_type i;
^~~~~~~~~~~~
another_typedef
{ dg-end-multiline-output "" } */
}
|