On 8/28/24 3:59 PM, Arsen Arsenović wrote:
Hm, maybe-unused-1.C should be moved into the previous patch. Could do
before pushing.
Let's combine these three into a single patch, they're all small and
closely related.
@@ -3147,7 +3147,13 @@ maybe_promote_temps (tree *stmt, void *d)
to run the initializer.
If the initializer is a conditional expression, we need to collect
and declare any promoted variables nested within it. DTORs for such
- variables must be run conditionally too. */
+ variables must be run conditionally too.
+
+ Since here we're synthetically processing code here, we've already
+ emitted any Wunused-result warnings.
If it's already been through convert_to_void for the warnings, why isn't
it already void?
This patch fixes a gcc-15 regression (PR116502) and an inelegance in my
earlier patch related to converting CO_AWAIT_EXPRs to void.
This wasn't noticed anywhere AFAICT, but it was a bit unfortunate.
The other two patches fix an actual regression as well as provide
handling for converting INDIRECT_REFs wrapping CO_AWAIT_EXPRs (which I
noticed was lacking while triaging the regression).
WRT INDIRECT_REFs, I've considered making convert_to_void recurse on the
INDIRECT_REF case, so that special handling doesn't need to be added
when some expression might end up getting wrapped in a INDIRECT_REF. Is
there a reason why we don't do that?
Primarily because that isn't what the language says. And for instance if I
have
int *volatile p;
*p;
I think just recursing will wrongly warn about not accessing the value of p.
Hmm, with the change in the OP I didn't get that warning, but that
reason is compelling enough for me.
On second thought, I think we should split the INDIRECT_REF handling
between REFERENCE_REF_P and actual * expressions, and recurse for
warnings in the reference case (but don't return the value of the
recursive call). And drop the warn_nodiscard from the * case; we
shouldn't ever get a nodiscard warning about *f();.
Jason