aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/countof-stdcountof.c
blob: 2fb0c6306ef08e9273b3aad20a5a961831213ec1 (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
/* { dg-do run } */
/* { dg-options "-std=c2y -pedantic-errors" } */

#include <stdcountof.h>

#define assert(e)  ((e) ? (void) 0 : __builtin_abort ())

extern int strcmp (const char *, const char *);

#ifndef countof
#error "countof not defined"
#endif

int a[3];
int b[countof a];

#define str(x) #x
#define xstr(x) str(x)

int
main (void)
{
  assert (strcmp (xstr(countof), "_Countof") == 0);
}