strub: enable conditional support
[official-gcc.git] / gcc / testsuite / g++.dg / torture / accessor-fixits-2.C
blobe1a2b7865b56c95d2533792c2261eef17fca6759
1 // { dg-options "-fdiagnostics-show-caret" }
3 /* Test of accessors that return references.  */
5 class t1
7 public:
8   int& get_color () { return m_color; }
9   int& get_shape () { return m_shape; }
11 private:
12   int m_color;
14 protected:
15   int m_shape;
18 int test_access_t1_color (t1 &ref)
20   return ref.m_color; // { dg-error ".int t1::m_color. is private within this context" }
21   /* { dg-begin-multiline-output "" }
22    return ref.m_color;
23               ^~~~~~~
24      { dg-end-multiline-output "" } */
26   // { dg-message "declared private here" "" { target *-*-* } 12 }
27   /* { dg-begin-multiline-output "" }
28    int m_color;
29        ^~~~~~~
30      { dg-end-multiline-output "" } */
32   // { dg-message "field .int t1::m_color. can be accessed via .int& t1::get_color\\(\\)." "" { target *-*-* } .-12 }
33   /* { dg-begin-multiline-output "" }
34    return ref.m_color;
35               ^~~~~~~
36               get_color()
37      { dg-end-multiline-output "" } */
40 int test_access_t1_shape (t1 &ref)
42   return ref.m_shape; // { dg-error ".int t1::m_shape. is protected within this context" }
43   /* { dg-begin-multiline-output "" }
44    return ref.m_shape;
45               ^~~~~~~
46      { dg-end-multiline-output "" } */
48   // { dg-message "declared protected here" "" { target *-*-* } 15 }
49   /* { dg-begin-multiline-output "" }
50    int m_shape;
51        ^~~~~~~
52      { dg-end-multiline-output "" } */
54   // { dg-message "field .int t1::m_shape. can be accessed via .int& t1::get_shape\\(\\)." "" { target *-*-* } .-12 }
55   /* { dg-begin-multiline-output "" }
56    return ref.m_shape;
57               ^~~~~~~
58               get_shape()
59      { dg-end-multiline-output "" } */
62 int test_deref_t1_color (t1 *ptr)
64   return ptr->m_color; // { dg-error ".int t1::m_color. is private within this context" }
65   /* { dg-begin-multiline-output "" }
66    return ptr->m_color;
67                ^~~~~~~
68      { dg-end-multiline-output "" } */
71   /* { dg-begin-multiline-output "" }
72    int m_color;
73        ^~~~~~~
74      { dg-end-multiline-output "" } */
76   // { dg-message "field .int t1::m_color. can be accessed via .int& t1::get_color\\(\\)." "" { target *-*-* } .-12 }
77   /* { dg-begin-multiline-output "" }
78    return ptr->m_color;
79                ^~~~~~~
80                get_color()
81      { dg-end-multiline-output "" } */
84 int test_deref_t1_shape (t1 *ptr)
86   return ptr->m_shape; // { dg-error ".int t1::m_shape. is protected within this context" }
87   /* { dg-begin-multiline-output "" }
88    return ptr->m_shape;
89                ^~~~~~~
90      { dg-end-multiline-output "" } */
93   /* { dg-begin-multiline-output "" }
94    int m_shape;
95        ^~~~~~~
96      { dg-end-multiline-output "" } */
98   // { dg-message "field .int t1::m_shape. can be accessed via .int& t1::get_shape\\(\\)." "" { target *-*-* } .-12 }
99   /* { dg-begin-multiline-output "" }
100    return ptr->m_shape;
101                ^~~~~~~
102                get_shape()
103      { dg-end-multiline-output "" } */