On Wed, 21 May 2025, Alejandro Colomar wrote:
> @@ -10572,6 +10583,8 @@ c_parser_unary_expression (c_parser *parser)
> case CPP_KEYWORD:
> switch (c_parser_peek_token (parser)->keyword)
> {
> + case RID_COUNTOF:
> + return c_parser_countof_expression (parser);
> case RID_SIZEOF:
> return c_parser_sizeof_expression (parser);
> case RID_ALIGNOF:
The comment above this function should be updated to include the _Countof
syntax for C2Y.
> diff --git a/gcc/testsuite/gcc.dg/countof-vmt.c
> b/gcc/testsuite/gcc.dg/countof-vmt.c
> new file mode 100644
> index 000000000000..cf4bfd1aa74e
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/countof-vmt.c
> @@ -0,0 +1,20 @@
> +/* { dg-do run } */
> +/* { dg-options "-std=c2y" } */
I think -std=gnu2y is more appropriate for tests such as this that are
concerned with GNU extensions (VLAs in structures, in this case).
> diff --git a/gcc/testsuite/gcc.dg/countof-zero-compile.c
> b/gcc/testsuite/gcc.dg/countof-zero-compile.c
> new file mode 100644
> index 000000000000..3dc60ce293bd
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/countof-zero-compile.c
> @@ -0,0 +1,38 @@
> +/* { dg-do compile } */
> +/* { dg-options "-std=c2y" } */
Likewise for this one using the extension of arrays with zero elements.
> diff --git a/gcc/testsuite/gcc.dg/countof-zero.c
> b/gcc/testsuite/gcc.dg/countof-zero.c
> new file mode 100644
> index 000000000000..678a08148a5c
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/countof-zero.c
> @@ -0,0 +1,31 @@
> +/* { dg-do run } */
> +/* { dg-options "-std=c2y" } */
Likewise for this one as well.
--
Joseph S. Myers
[email protected]