Debian Codegraph @

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

raw
1 // { dg-options "-fdiagnostics-show-caret" }
2
3 class t1
4 {
5 public:
6 int get_doubled_field () const { return m_field * 2; }
7 int get_guarded_field_1 () const { if (m_field) return m_field; else return 42; }
8 int get_guarded_field_2 () const { return m_field ? m_field : 42; }
9 int with_unreachable () const { __builtin_unreachable (); return m_field; }
10 void no_return () { }
11
12 private:
13 int m_field; // { dg-line field_decl }
14 };
15
16 int test (t1 *ptr)
17 {
18 return ptr->m_field; // { dg-error ".int t1::m_field. is private within this context" }
19 /* { dg-begin-multiline-output "" }
20 return ptr->m_field;
21 ^~~~~~~
22 { dg-end-multiline-output "" } */
23
24 // { dg-message "declared private here" "" { target *-*-* } field_decl }
25 /* { dg-begin-multiline-output "" }
26 int m_field;
27 ^~~~~~~
28 { dg-end-multiline-output "" } */
29
30 /* We shouldn't issue a suggestion: none of the member functions are suitable returns. */
31 }