[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context
Yuanfang Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 7 17:21:04 PDT 2021
ychen added inline comments.
================
Comment at: clang/test/Sema/i-c-e.c:77-78
+ // expected-warning {{expression result unused}}
+int comma3[(1, 2)]; // expected-warning {{variable length array folded to constant array as an extension}} \
+ // expected-warning {{expression result unused}}
----------------
aaron.ballman wrote:
> ychen wrote:
> > aaron.ballman wrote:
> > > I think this diagnostic is kind of unfortunate because it increases my confusion -- the expression result is most assuredly *not* unused in these cases because it's used in the definition of the type.
> > > the expression result is most assuredly *not* unused in these cases because it's used in the definition of the type.
> >
> > Do you mean "1" is used in the definition of the type? The warning is for "1" in this case. If I change `1` to any other number, the type of `comma3` should not change, I think that means `1` is not used.
> > Do you mean "1" is used in the definition of the type? The warning is for "1" in this case. If I change 1 to any other number, the type of comma3 should not change, I think that means 1 is not used.
>
> I agree that the `1` is unused.
>
> The trouble is that the diagnostic doesn't make that clear -- it just says the expression result is unused, which makes it sound like the entire comma expression result value is unused (which is not the case). I think the diagnostic should more clearly specify *what* is unused in this case, otherwise users may think the diagnostic is a false positive.
Sounds good to me. I've used "left operand of comma operator has no effect" which is what GCC uses for this.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103938/new/
https://reviews.llvm.org/D103938
More information about the cfe-commits
mailing list