summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/nodiscard-constructor.c
blob: a5c2c6514cf38658bf5d9f441529ed72485a02d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
/* nodiscard attribute tests  */
/* { dg-do compile { target c++2a } } */
/* { dg-options "-O -ftrack-macro-expansion=0" } */

struct A { [[nodiscard("bad constructor")]] A() {} };
struct B { [[nodiscard]] B() {} };

void
test (void)
{
  A{}; /* { dg-warning "(?n)nodiscard.*bad constructor" } */
  B{}; /* { dg-warning "(?n)nodiscard" } */
}