aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/nodiscard9.C
blob: 1315ccdbf7c7ea8b2cbcbdbce6b923c19294729a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// PR c++/100666
// { dg-do compile { target c++11 } }

struct S {};
[[nodiscard]] S bar ();
struct U { S s; };
[[nodiscard]] U corge ();
extern void foo (...);
template <typename T> void qux (T);

void
baz ()
{
  foo (bar ());		// { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
  bar ();		// { dg-warning "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
  auto x = bar ();	// { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
  qux (bar ());		// { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
  foo (corge ());	// { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
  corge ();		// { dg-warning "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
  auto y = corge ();	// { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
  qux (corge ());	// { dg-bogus "ignoring return value of '\[^\n\r]*', declared with attribute 'nodiscard'" }
}