Debian Codegraph @

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

raw
1 // PR c++/84994
2 /* Ensure that fix-it hints are offered at every optimization level, even when
3 "-g" is enabled (coverage for every optimization level without -g is given
4 by the other cases within g++.dg/torture/accessor-fixits-*.C). */
5 // { dg-additional-options "-g" }
6
7 class foo
8 {
9 public:
10 double get_ratio() const { return m_ratio; }
11
12 private:
13 double m_ratio; // { dg-line field_decl }
14 };
15
16 void test(foo *ptr)
17 {
18 if (ptr->m_ratio >= 0.5) // { dg-error "'double foo::m_ratio' is private within this context" }
19 ;
20 // { dg-message "declared private here" "" { target *-*-* } field_decl }
21 // { dg-message "'double foo::m_ratio' can be accessed via 'double foo::get_ratio\\(\\) const'" "" { target *-*-* } .-3 }
22 }