PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / g++.dg / spellcheck-pr77829.C
blob2f75779a1b426e6acf51753ce8d48109c030d718
1 // { dg-options "-fdiagnostics-show-caret" }
3 /* Various tests of name lookup within a namespace, both within an explicitly
4    given namespace, or implicitly.  */
6 namespace detail {
7   /* Various things to look for.  */
9   typedef int some_typedef;
11   int _foo(int i) { return i; }
13   template <typename T>
14   T something_else (T i) { return i; }
17 /* Tests of lookup of a typedef.  */
19 void fn_1_explicit ()
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 "" }
24    detail::some_type i;
25            ^~~~~~~~~
26      { dg-end-multiline-output "" } */
27   /* { dg-begin-multiline-output "" }
28    detail::some_type i;
29            ^~~~~~~~~
30            some_typedef
31      { dg-end-multiline-output "" } */
34 namespace detail {
36 void fn_1_implicit ()
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 "" }
41    some_type i;
42    ^~~~~~~~~
43      { dg-end-multiline-output "" } */
44   /* { dg-begin-multiline-output "" }
45    some_type i;
46    ^~~~~~~~~
47    some_typedef
48      { dg-end-multiline-output "" } */
51 } // namespace detail
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 "" }
60    detail::foo(i);
61            ^~~
62      { dg-end-multiline-output "" } */
63   /* { dg-begin-multiline-output "" }
64    detail::foo(i);
65            ^~~
66            _foo
67      { dg-end-multiline-output "" } */
70 namespace detail {
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 "" }
76    foo(i);
77    ^~~
78      { dg-end-multiline-output "" } */
79   /* { dg-begin-multiline-output "" }
80    foo(i);
81    ^~~
82    _foo
83      { dg-end-multiline-output "" } */
86 } // namespace detail
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);
96            ^~~~~~~~~~~~~
97      { dg-end-multiline-output "" } */
99   /* { dg-begin-multiline-output "" }
100    detail::something_els(i);
101            ^~~~~~~~~~~~~
102            something_else
103      { dg-end-multiline-output "" } */
106 namespace detail {
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 "" }
112    something_els(i);
113    ^~~~~~~~~~~~~
114      { dg-end-multiline-output "" } */
116   /* { dg-begin-multiline-output "" }
117    something_els(i);
118    ^~~~~~~~~~~~~
119    something_else
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);
132            ^~~~~~~~~~~~~~
133      { dg-end-multiline-output "" } */
136 namespace detail {
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 "" }
142    not_recognized(i);
143    ^~~~~~~~~~~~~~
144      { dg-end-multiline-output "" } */
147 } // namespace detail
150 /* Test for failed lookup explicitly within global namespace.  */
152 typedef int another_typedef;
154 void fn_5 ()
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 "" }
159    ::another_type i;
160      ^~~~~~~~~~~~
161      { dg-end-multiline-output "" } */
162   /* { dg-begin-multiline-output "" }
163    ::another_type i;
164      ^~~~~~~~~~~~
165      another_typedef
166      { dg-end-multiline-output "" } */