1 // { dg-options "-fdiagnostics-show-caret" }
3 /* Various tests of name lookup within a namespace, both within an explicitly
4 given namespace, or implicitly. */
7 /* Various things to look for. */
9 typedef int some_typedef;
11 int _foo(int i) { return i; }
14 T something_else (T i) { return i; }
17 /* Tests of lookup of a typedef. */
21 detail::some_type i; // { dg-error ".some_type. is not a member of .detail." }
22 // { dg-message "suggested alternative: .some_typedef." "" { target *-*-* } .-1 }
23 /* { dg-begin-multiline-output "" }
26 { dg-end-multiline-output "" } */
27 /* { dg-begin-multiline-output "" }
31 { dg-end-multiline-output "" } */
38 some_type i; // { dg-error ".some_type. was not declared in this scope" }
39 // { dg-message "suggested alternative: .some_typedef." "" { target *-*-* } .-1 }
40 /* { dg-begin-multiline-output "" }
43 { dg-end-multiline-output "" } */
44 /* { dg-begin-multiline-output "" }
48 { dg-end-multiline-output "" } */
54 /* Tests of lookup of a function. */
56 void fn_2_explicit (int i) {
57 detail::foo(i); // { dg-error ".foo. is not a member of .detail." }
58 // { dg-message "suggested alternative: ._foo." "" { target *-*-* } .-1 }
59 /* { dg-begin-multiline-output "" }
62 { dg-end-multiline-output "" } */
63 /* { dg-begin-multiline-output "" }
67 { dg-end-multiline-output "" } */
72 void fn_2_implicit (int i) {
73 foo(i); // { dg-error ".foo. was not declared in this scope" }
74 // { dg-message "suggested alternative: ._foo." "" { target *-*-* } .-1 }
75 /* { dg-begin-multiline-output "" }
78 { dg-end-multiline-output "" } */
79 /* { dg-begin-multiline-output "" }
83 { dg-end-multiline-output "" } */
89 /* Examples using a template. */
91 void fn_3_explicit (int i) {
92 detail::something_els(i); // { dg-error ".something_els. is not a member of .detail." }
93 // { dg-message "suggested alternative: .something_else." "" { target *-*-* } .-1 }
94 /* { dg-begin-multiline-output "" }
95 detail::something_els(i);
97 { dg-end-multiline-output "" } */
99 /* { dg-begin-multiline-output "" }
100 detail::something_els(i);
103 { dg-end-multiline-output "" } */
108 void fn_3_implicit (int i) {
109 something_els(i); // { dg-error ".something_els. was not declared in this scope" }
110 // { dg-message "suggested alternative: .something_else." "" { target *-*-* } .-1 }
111 /* { dg-begin-multiline-output "" }
114 { dg-end-multiline-output "" } */
116 /* { dg-begin-multiline-output "" }
120 { dg-end-multiline-output "" } */
123 } // namespace detail
126 /* Tests of lookup for which no hint is available. */
128 void fn_4_explicit (int i) {
129 detail::not_recognized(i); // { dg-error ".not_recognized. is not a member of .detail." }
130 /* { dg-begin-multiline-output "" }
131 detail::not_recognized(i);
133 { dg-end-multiline-output "" } */
138 void fn_4_implicit (int i)
140 not_recognized(i); // { dg-error ".not_recognized. was not declared in this scope" }
141 /* { dg-begin-multiline-output "" }
144 { dg-end-multiline-output "" } */
147 } // namespace detail
150 /* Test for failed lookup explicitly within global namespace. */
152 typedef int another_typedef;
156 ::another_type i; // { dg-error ".::another_type. has not been declared" }
157 // { dg-message "suggested alternative: .another_typedef." "" { target *-*-* } .-1 }
158 /* { dg-begin-multiline-output "" }
161 { dg-end-multiline-output "" } */
162 /* { dg-begin-multiline-output "" }
166 { dg-end-multiline-output "" } */