Allow declaring a parameter UNUSED - #24674
Conversation
0bbbe01 to
1a875a3
Compare
|
Commit message:
I'm not sure how:
and
are connected. asserts() are also statements in these macros (expression statements), which is why so much older code has the |
1a875a3 to
d8f3ec5
Compare
That was a thinko on my part. The commit message is rewritten |
|
This new version wants you to say UNUSED in both embed.fnc and the function definition. If the system recognizes the unused attribute compiler directive, the PERL_UNUSED_ARG is dispensed with completely. |
| /* When we have the attribute available, skip doing the runtime check | ||
| * (though likely it's optimized out */ |
There was a problem hiding this comment.
It's not a check, it's a suppression (by trivially using the name), and the actual suppression happens at compile-time.
It's also not an assertion.
There was a problem hiding this comment.
PERL_ARGS_ASSERT_UNUSED is still not an assertion even though the name suggests it is.
There was a problem hiding this comment.
I didn't catch your drift, because it hadn't occurred to me that this name would imply that it was an assertion. I was trying to convey that this macro is designed for use (solely) by the PERL_ARGS_ASSERT macros (which no longer are just assertions, but I don't think we should change their names). PERL_UNUSED_ARG_FOR_ARGS_ASSERT would be a bit better. And this name should never be typed by a person, since it is generated, so a long name shouldn't be a problem except to readers. But better long than confusing. Suggestions welcome!
There was a problem hiding this comment.
PERL_UNUSED_ARG_FOR_ARGS_ASSERT is as good as any I can think of right now.
ece385b to
1f548d4
Compare
The components of this will shortly be more than asserts. The new name reflects this
This loop is now changed so that a new array for it to handle can trivially be added.
This was folding, but not taking into consideration a semicolon and the continuation character. (Or maybe the intent was 80 columns, but because of pagers consuming columns, 78 is a better goal anyway.) I also find it more legible to have two blanks before the continuation
This is better practice when multiple statements are involved. For most of its history, the expansion of PERL_ARGS_ASSERT macros was one or more assert()s, and that worked without the STMT_START, STMT_END wrappers. But now more complex expansions are about to be added, so it seems better to add the wrapping.
This allows removing many PERL_UNUSED_ARG statements in the code. (The ones that are conditionally compiled should not be removed this way.) And this commit does the removal of one such statement, to show how it works. This is enabled only for core perl and extensions. To use this capability, the symbol UNUSED is added after the parameter name in *both* its embed.fnc entry and its definition. On systems that allow declaring an unused attribute for a parameter, the code in regen.pl arranges for that to happen in the function's prototype declaration. On my gcc, that actually gets ignored, and hence doing it in the function definition is also required. It may be that other compilers or a future change to gcc will note the attribute in the prototype, so the second usage won't be required. On systems without this capability, regen/embed.pl arranges for the PERL_ARGS_ASSERT macro for the function to expand to do a PERL_UNUSED_ARG() on the unused parameter.
1f548d4 to
ea839ba
Compare
This allows removing many PERL_UNUSED_ARG statements in the code. (The ones that are conditionally compiled cannot be removed this way.)
One exemplar statement is removed.