[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] libpoke,etc: Re-write `ASTREF`/`ASTDEREF` as an inline funct
From: |
Mohammad-Reza Nabipoor |
Subject: |
Re: [PATCH] libpoke,etc: Re-write `ASTREF`/`ASTDEREF` as an inline function |
Date: |
Sun, 29 Nov 2020 13:26:41 +0330 |
Hi, Jose.
On Sun, Nov 29, 2020 at 10:18:18AM +0100, Jose E. Marchesi wrote:
>
> > @@ -1894,6 +1888,22 @@ union pkl_ast_node
> > struct pkl_ast_print_stmt_arg print_stmt_arg;
> > };
> >
> > +static inline pkl_ast_node __attribute__ ((always_inline,
> > warn_unused_result))
> > +ASTREF (pkl_ast_node ast)
> > +{
> > + if (ast)
> > + ++ast->common.refcount;
> > + return ast;
> > +}
> > +
> > +static inline pkl_ast_node __attribute__ ((always_inline,
> > warn_unused_result))
> > +ASTDEREF (pkl_ast_node ast)
> > +{
> > + if (ast)
> > + --ast->common.refcount;
> > + return ast;
> > +}
> > +
>
> Hm, I'm unsure regarding warn_unused_result and the next thunks in your
> patch. Sometimes ASTREF/ASTDEREF are called only for their side effect,
> as you have found. Forcing using an assignment in these cases is a bit
> ugly...
>
I admit the ugliness, but I didn't find another way to enforce the `ast`
to be a l-value.
These are a few cases and maybe we can accept this ugliness.
Or finding another way to ensure the l-valueness of `ast`.
Regards,
Mohammad-Reza