2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / torture / accessor-fixits-5.C
blobcf72d784330c01759a8e7eca43ef834e9f55959d
1 // PR c++/84892
2 // { dg-options "-fdiagnostics-show-caret" }
4 class S {
5 private:
6   bool field;
8 public:
9   bool get_field() const {
10     return field;
11   }
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 "" } */
21   // { dg-message "declared private here" "" { target *-*-* } 6 }
22   /* { dg-begin-multiline-output "" }
23    bool field;
24         ^~~~~
25      { dg-end-multiline-output "" } */
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 "" } */