Debian Codegraph @

gcc/testsuite/g++.dg/torture/accessor-fixits-5.C

raw
1 // PR c++/84892
2 // { dg-options "-fdiagnostics-show-caret" }
3
4 class S {
5 private:
6 bool field;
7
8 public:
9 bool get_field() const {
10 return field;
11 }
12 };
13
14 bool thingy(const S & s) {
15 return s.field; // { dg-error "'bool S::field' is private within this context" }
16 /* { dg-begin-multiline-output "" }
17 return s.field;
18 ^~~~~
19 { dg-end-multiline-output "" } */
20
21 // { dg-message "declared private here" "" { target *-*-* } 6 }
22 /* { dg-begin-multiline-output "" }
23 bool field;
24 ^~~~~
25 { dg-end-multiline-output "" } */
26
27 // { dg-message "field 'bool S::field' can be accessed via 'bool S::get_field\\(\\) const'" "" { target *-*-* } .-12 }
28 /* { dg-begin-multiline-output "" }
29 return s.field;
30 ^~~~~
31 get_field()
32 { dg-end-multiline-output "" } */
33 }