2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / torture / accessor-fixits-4.C
blobc03dd4ea487e8cb7693462265105ad9a67d26d0a
1 // { dg-options "-fdiagnostics-show-caret" }
3 class t1
5 public:
6   int& get_color () { return m_color; }
7   int& get_shape () { return m_shape; }
9 private:
10   int m_color; // { dg-line color_decl }
11   int m_shape; // { dg-line shape_decl }
14 int test_const_ptr (const t1 *ptr)
16   return ptr->m_color; // { dg-error ".int t1::m_color. is private within this context" }
17   /* { dg-begin-multiline-output "" }
18    return ptr->m_color;
19                ^~~~~~~
20      { dg-end-multiline-output "" } */
22   // { dg-message "declared private here" "" { target *-*-* } color_decl }
23   /* { dg-begin-multiline-output "" }
24    int m_color;
25        ^~~~~~~
26      { dg-end-multiline-output "" } */
28   /* We shouldn't issue a suggestion: the accessor is non-const, and we
29      only have a const ptr.  */
32 int test_const_reference (const t1 &ref)
34   return ref.m_shape; // { dg-error ".int t1::m_shape. is private within this context" }
35   /* { dg-begin-multiline-output "" }
36    return ref.m_shape;
37               ^~~~~~~
38      { dg-end-multiline-output "" } */
40   // { dg-message "declared private here" "" { target *-*-* } shape_decl }
41   /* { dg-begin-multiline-output "" }
42    int m_shape;
43        ^~~~~~~
44      { dg-end-multiline-output "" } */
46   /* We shouldn't issue a suggestion: the accessor is non-const, and we
47      only have a const ptr.  */