Debian Codegraph @

gcc/testsuite/g++.dg/cpp1z/nodiscard9.C

raw
1 // PR c++/100666
2 // { dg-do compile { target c++11 } }
3
4 struct S {};
5 [[nodiscard]] S bar ();
6 struct U { S s; };
7 [[nodiscard]] U corge ();
8 extern void foo (...);
9 template <typename T> void qux (T);
10
11 void
12 baz ()
13 {
14 foo (bar ()); // { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
15 bar (); // { dg-warning "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
16 auto x = bar (); // { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
17 qux (bar ()); // { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
18 foo (corge ()); // { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
19 corge (); // { dg-warning "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
20 auto y = corge (); // { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
21 qux (corge ()); // { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
22 }