2 // { dg-options "-fdiagnostics-show-caret" }
4 /* Misspelling (by omitting a leading "m_") of a private member for which
5 there's a public accessor.
7 We expect a fix-it hint suggesting the accessor. */
12 int get_ratio () const { return m_ratio; }
20 return ptr_1->ratio; // { dg-error "'class t1' has no member named 'ratio'; did you mean 'int t1::m_ratio'\\? \\(accessible via 'int t1::get_ratio\\(\\) const'\\)" }
21 /* { dg-begin-multiline-output "" }
25 { dg-end-multiline-output "" } */
29 /* Misspelling of a private member for which there's a public accessor.
31 We expect a fix-it hint suggesting the accessor. */
36 int get_color () const { return m_color; }
44 return ptr_2->m_colour; // { dg-error "'class t2' has no member named 'm_colour'; did you mean 'int t2::m_color'\\? \\(accessible via 'int t2::get_color\\(\\) const'\\)" }
45 /* { dg-begin-multiline-output "" }
46 return ptr_2->m_colour;
49 { dg-end-multiline-output "" } */
53 /* Misspelling of a private member via a subclass pointer, for which there's
54 a public accessor in the base class.
56 We expect a fix-it hint suggesting the accessor. */
58 class t3 : public t2 {};
62 return ptr_3->m_colour; // { dg-error "'class t3' has no member named 'm_colour'; did you mean 'int t2::m_color'\\? \\(accessible via 'int t2::get_color\\(\\) const'\\)" }
63 /* { dg-begin-multiline-output "" }
64 return ptr_3->m_colour;
67 { dg-end-multiline-output "" } */
71 /* Misspelling of a protected member, for which there's isn't a public
74 We expect no fix-it hint; instead a message identifying where the
75 data member was declared. */
80 int m_color; // { dg-message "declared protected here" }
85 return ptr_4->m_colour; // { dg-error "'class t4' has no member named 'm_colour'; did you mean 'int t4::m_color'\\? \\(not accessible from this context\\)" }
86 /* { dg-begin-multiline-output "" }
87 return ptr_4->m_colour;
89 { dg-end-multiline-output "" } */
90 /* { dg-begin-multiline-output "" }
93 { dg-end-multiline-output "" } */
97 /* Misspelling of a private member, for which the accessor is also private.
99 We expect no fix-it hint; instead a message identifying where the
100 data member was declared. */
104 int get_color () const { return m_color; }
105 int m_color; // { dg-message "declared private here" }
110 return ptr_5->m_colour; // { dg-error "'class t5' has no member named 'm_colour'; did you mean 'int t5::m_color'\\? \\(not accessible from this context\\)" }
111 /* { dg-begin-multiline-output "" }
112 return ptr_5->m_colour;
114 { dg-end-multiline-output "" } */
115 /* { dg-begin-multiline-output "" }
118 { dg-end-multiline-output "" } */