1 // { dg-options "-fdiagnostics-show-caret" }
3 /* Test of accessors that return references. */
8 int& get_color () { return m_color; }
9 int& get_shape () { return 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 "" }
24 { dg-end-multiline-output "" } */
26 // { dg-message "declared private here" "" { target *-*-* } 12 }
27 /* { dg-begin-multiline-output "" }
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 "" }
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 "" }
46 { dg-end-multiline-output "" } */
48 // { dg-message "declared protected here" "" { target *-*-* } 15 }
49 /* { dg-begin-multiline-output "" }
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 "" }
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 "" }
68 { dg-end-multiline-output "" } */
71 /* { dg-begin-multiline-output "" }
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 "" }
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 "" }
90 { dg-end-multiline-output "" } */
93 /* { dg-begin-multiline-output "" }
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 "" }
103 { dg-end-multiline-output "" } */