2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / torture / accessor-fixits-8.C
blob1338b7d13498e779bccd0e4ffcd3bac5df76f413
1 // { dg-options "-fdiagnostics-show-caret" }
3 class t1
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 () { }
12 private:
13   int m_field; // { dg-line field_decl }
16 int test (t1 *ptr)
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 "" } */
24   // { dg-message "declared private here" "" { target *-*-* } field_decl }
25   /* { dg-begin-multiline-output "" }
26    int m_field;
27        ^~~~~~~
28      { dg-end-multiline-output "" } */
30   /* We shouldn't issue a suggestion: none of the member functions are suitable returns.  */