summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c2x-attr-maybe_unused-2.c
blob: a749639192e8bfb2e61345e665d815c6d22bd1c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Test C2x maybe_unused attribute: invalid contexts.  */
/* { dg-do compile } */
/* { dg-options "-std=c2x -pedantic-errors" } */

/* This attribute is not valid in most cases on types other than their
   definitions, or on statements, or as an attribute-declaration.  */

[[maybe_unused]]; /* { dg-error "ignored" } */

int [[maybe_unused]] var; /* { dg-error "ignored" } */

int array_with_dep_type[2] [[maybe_unused]]; /* { dg-error "ignored" } */

void fn_with_dep_type () [[maybe_unused]]; /* { dg-error "ignored" } */

int z = sizeof (int [[__maybe_unused__]]); /* { dg-error "ignored" } */

void
f (void)
{
  int a;
  [[maybe_unused]]; /* { dg-error "ignored" } */
  [[maybe_unused]] a = 1; /* { dg-error "ignored" } */
}