Debian Codegraph @

gcc/testsuite/g++.dg/spellcheck-pr77829.C

raw
1 // { dg-options "-fdiagnostics-show-caret" }
2
3 /* Various tests of name lookup within a namespace, both within an explicitly
4 given namespace, or implicitly. */
5
6 namespace detail {
7 /* Various things to look for. */
8
9 typedef int some_typedef;
10
11 int _foo(int i) { return i; }
12
13 template <typename T>
14 T something_else (T i) { return i; }
15 }
16
17 /* Tests of lookup of a typedef. */
18
19 void fn_1_explicit ()
20 {
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 "" } */
27 }
28
29 namespace detail {
30
31 void fn_1_implicit ()
32 {
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 "" } */
39 }
40
41 } // namespace detail
42
43
44 /* Tests of lookup of a function. */
45
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 "" } */
53 }
54
55 namespace detail {
56
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 "" } */
64 }
65
66 } // namespace detail
67
68
69 /* Examples using a template. */
70
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 "" } */
78 }
79
80 namespace detail {
81
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 "" } */
89 }
90
91 } // namespace detail
92
93
94 /* Tests of lookup for which no hint is available. */
95
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 "" } */
102 }
103
104 namespace detail {
105
106 void fn_4_implicit (int i)
107 {
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 "" } */
113 }
114
115 } // namespace detail
116
117
118 /* Test for failed lookup explicitly within global namespace. */
119
120 typedef int another_typedef;
121
122 void fn_5 ()
123 {
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 "" } */
130 }