[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: |
Jose E. Marchesi |
Subject: |
Re: [PATCH] libpoke,etc: Re-write `ASTREF`/`ASTDEREF` as an inline function |
Date: |
Sun, 29 Nov 2020 11:28:07 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> 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`.
Yeah I know.
Ok, lets put this in. It is certainly better than the previous macros.
Thanks.