]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/c2x-attr-maybe_unused-2.c
testsuite: Refer more consistently to C23 not C2X
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / c2x-attr-maybe_unused-2.c
CommitLineData
54bac0ce 1/* Test C23 maybe_unused attribute: invalid contexts. */
97cc1187 2/* { dg-do compile } */
54bac0ce 3/* { dg-options "-std=c23 -pedantic-errors" } */
97cc1187
JM
4
5/* This attribute is not valid in most cases on types other than their
6 definitions, or on statements, or as an attribute-declaration. */
7
192961ff 8[[maybe_unused]]; /* { dg-error "ignored" } */
97cc1187 9
8c5b727a 10int [[maybe_unused]] var; /* { dg-error "ignored" } */
97cc1187 11
8c5b727a 12int array_with_dep_type[2] [[maybe_unused]]; /* { dg-error "ignored" } */
97cc1187 13
8c5b727a
JM
14void fn_with_dep_type () [[maybe_unused]]; /* { dg-error "ignored" } */
15
16int z = sizeof (int [[__maybe_unused__]]); /* { dg-error "ignored" } */
97cc1187
JM
17
18void
19f (void)
20{
21 int a;
192961ff
JM
22 [[maybe_unused]]; /* { dg-error "ignored" } */
23 [[maybe_unused]] a = 1; /* { dg-error "ignored" } */
97cc1187 24}