Hi Jakub, On Wed, May 21, 2025 at 11:31:05PM +0200, Alejandro Colomar wrote: > > > +#define c_parser_sizeof_expression(parser) > > > \ > > > +( > > > \ > > > + c_parser_sizeof_or_countof_expression (parser, RID_SIZEOF) > > > \ > > > +) > > > > > > +#define c_parser_countof_expression(parser) > > > \ > > > +( > > > \ > > > + c_parser_sizeof_or_countof_expression (parser, RID_COUNTOF) > > > \ > > > +) > > > > Up to Joseph, but I'd say these should just be inline functions, not macros, > > and defined after the declarations. > > I don't mind, so yeah, I'm okay with changing these to be inline.
Does this sound good? diff --git i/gcc/c/c-parser.cc w/gcc/c/c-parser.cc index faa03c4903a2..733cb312341e 100644 --- i/gcc/c/c-parser.cc +++ w/gcc/c/c-parser.cc @@ -78,16 +78,6 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-ubsan.h" #include "gcc-urlifier.h" ^L -#define c_parser_sizeof_expression(parser) \ -( \ - c_parser_sizeof_or_countof_expression (parser, RID_SIZEOF) \ -) - -#define c_parser_countof_expression(parser) \ -( \ - c_parser_sizeof_or_countof_expression (parser, RID_COUNTOF) \ -) -^L /* We need to walk over decls with incomplete struct/union/enum types after parsing the whole translation unit. In finish_decl(), if the decl is static, has incomplete @@ -1747,6 +1737,8 @@ static struct c_expr c_parser_binary_expression (c_parser *, struct c_expr *, tree); static struct c_expr c_parser_cast_expression (c_parser *, struct c_expr *); static struct c_expr c_parser_unary_expression (c_parser *); +static inline struct c_expr c_parser_sizeof_expression (c_parser *); +static inline struct c_expr c_parser_countof_expression (c_parser *); static struct c_expr c_parser_sizeof_or_countof_expression (c_parser *, enum rid); static struct c_expr c_parser_alignof_expression (c_parser *); @@ -10627,6 +10619,22 @@ c_parser_unary_expression (c_parser *parser) /* Parse a sizeof expression. */ +static inline struct c_expr +c_parser_sizeof_expression (c_parser *parser) +{ + return c_parser_sizeof_or_countof_expression (parser, RID_SIZEOF); +} + +/* Parse a _Countof expression. */ + +static inline struct c_expr +c_parser_countof_expression (c_parser *parser) +{ + return c_parser_sizeof_or_countof_expression (parser, RID_COUNTOF); +} + +/* Parse a sizeof or _Countof expression. */ + static struct c_expr c_parser_sizeof_or_countof_expression (c_parser *parser, enum rid rid) { Cheers, Alex -- <https://www.alejandro-colomar.es/>
signature.asc
Description: PGP signature