C++: simplify output from suggest_alternatives_for
[official-gcc.git] / gcc / testsuite / g++.dg / spellcheck-pr77829.C
blob17071345d3fb0ddc96eaa4a26a637065276e80b8
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.; did you mean 'some_typedef'\\?" }
22   /* { dg-begin-multiline-output "" }
23    detail::some_type i;
24            ^~~~~~~~~
25            some_typedef
26      { dg-end-multiline-output "" } */
29 namespace detail {
31 void fn_1_implicit ()
33   some_type i; // { dg-error ".some_type. was not declared in this scope; did you mean 'some_typedef'\\?" }
34   /* { dg-begin-multiline-output "" }
35    some_type i;
36    ^~~~~~~~~
37    some_typedef
38      { dg-end-multiline-output "" } */
41 } // namespace detail
44 /* Tests of lookup of a function.  */
46 void fn_2_explicit (int i) {
47   detail::foo(i); // { dg-error ".foo. is not a member of .detail.; did you mean '_foo'\\?" }
48   /* { dg-begin-multiline-output "" }
49    detail::foo(i);
50            ^~~
51            _foo
52      { dg-end-multiline-output "" } */
55 namespace detail {
57 void fn_2_implicit (int i) {
58   foo(i); // { dg-error ".foo. was not declared in this scope; did you mean '_foo'\\?" }
59   /* { dg-begin-multiline-output "" }
60    foo(i);
61    ^~~
62    _foo
63      { dg-end-multiline-output "" } */
66 } // namespace detail
69 /* Examples using a template.  */
71 void fn_3_explicit (int i) {
72   detail::something_els(i); // { dg-error ".something_els. is not a member of .detail.; did you mean 'something_else'\\?" }
73   /* { dg-begin-multiline-output "" }
74    detail::something_els(i);
75            ^~~~~~~~~~~~~
76            something_else
77      { dg-end-multiline-output "" } */
80 namespace detail {
82 void fn_3_implicit (int i) {
83   something_els(i); // { dg-error ".something_els. was not declared in this scope; did you mean 'something_else'\\?" }
84   /* { dg-begin-multiline-output "" }
85    something_els(i);
86    ^~~~~~~~~~~~~
87    something_else
88      { dg-end-multiline-output "" } */
91 } // namespace detail
94 /* Tests of lookup for which no hint is available.  */
96 void fn_4_explicit (int i) {
97   detail::not_recognized(i); // { dg-error ".not_recognized. is not a member of .detail." }
98   /* { dg-begin-multiline-output "" }
99    detail::not_recognized(i);
100            ^~~~~~~~~~~~~~
101      { dg-end-multiline-output "" } */
104 namespace detail {
106 void fn_4_implicit (int i)
108   not_recognized(i); // { dg-error ".not_recognized. was not declared in this scope" }
109   /* { dg-begin-multiline-output "" }
110    not_recognized(i);
111    ^~~~~~~~~~~~~~
112      { dg-end-multiline-output "" } */
115 } // namespace detail
118 /* Test for failed lookup explicitly within global namespace.  */
120 typedef int another_typedef;
122 void fn_5 ()
124   ::another_type i; // { dg-error ".::another_type. has not been declared; did you mean 'another_typedef'\\?" }
125   /* { dg-begin-multiline-output "" }
126    ::another_type i;
127      ^~~~~~~~~~~~
128      another_typedef
129      { dg-end-multiline-output "" } */