aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c2y-static-assert-2.c
blob: 81cdd9dd3c676f420c5af0267b622e8efd220f59 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* Test C2y static assertions in expressions.  */
/* { dg-do compile } */
/* { dg-options "-std=c2y -pedantic-errors" } */

/* Old forms of static assertion still valid.  */
static_assert (1);
static_assert (2, "message" );
struct s { int a; static_assert (3); };

void
f ()
{
  static_assert (4);
 label:
  static_assert (5);
  for (static_assert (6);;)
    ;
}

/* Test new forms of static assertion.  */
void
g ()
{
  (void) 0, static_assert (7), (void) 0;
  extern typeof (static_assert (8)) f ();
  1 ? static_assert (9) : static_assert (10);
  if (1)
    static_assert (11);
  else
    static_assert (12);
  for (;;)
    static_assert (13);
  while (true)
    static_assert (14);
  do
    static_assert (15);
  while (false);
  switch (16)
    static_assert (17);
  (void) static_assert (18);
  (static_assert (19));
}

void
g2 ()
{
  (void) 0, static_assert (7, "message"), (void) 0;
  extern typeof (static_assert (8, "message")) f ();
  1 ? static_assert (9, "message") : static_assert (10, "message");
  if (1)
    static_assert (11, "message");
  else
    static_assert (12, "message");
  for (;;)
    static_assert (13, "message");
  while (true)
    static_assert (14, "message");
  do
    static_assert (15, "message");
  while (false);
  switch (16)
    static_assert (17, "message");
  (void) static_assert (18, "message");
  (static_assert (19, "message"));
}