Hi Joseph, On Wed, May 21, 2025 at 04:26:46PM +0000, Joseph Myers wrote: > 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.
Makes sense. I'm unsure where exactly I should put it. Is this okay? diff --git i/gcc/c/c-parser.cc w/gcc/c/c-parser.cc index 87700339394b..08350a216dd8 100644 --- i/gcc/c/c-parser.cc +++ w/gcc/c/c-parser.cc @@ -10456,20 +10456,22 @@ c_parser_cast_expression (c_parser *parser, struct c_expr *after) return c_parser_unary_expression (parser); } /* Parse an unary expression (C90 6.3.3, C99 6.5.3, C11 6.5.3). unary-expression: postfix-expression ++ unary-expression -- unary-expression unary-operator cast-expression + _Countof unary-expression + _Countof ( type-name ) sizeof unary-expression sizeof ( type-name ) unary-operator: one of & * + - ~ ! GNU extensions: unary-expression: __alignof__ unary-expression > > 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). Makes sense (and likewise for the below). When you confirm the above, I'll send v24 your way. Thanks for the review! Have a lovely day! Alex > > > 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 > josmy...@redhat.com > -- <https://www.alejandro-colomar.es/>
signature.asc
Description: PGP signature