[PATCH] D103938: Diagnose -Wunused-value in constant evaluation context

Yuanfang Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 17 22:21:28 PDT 2021


ychen added a comment.

In D103938#3006540 <https://reviews.llvm.org/D103938#3006540>, @aaron.ballman wrote:

> There were a few behavioral changes to tests that I had questions about. Also, can you add an additional test case that shows the behavior when the left operand of the comma expression is volatile (or do we already have that covered and I missed it)? e.g.,
>
>   int func() {
>     volatile int *ip = (volatile int *)0xFEEDFACE;
>     return (*ip, 1);
>   }
>
> (In this case, we shouldn't diagnose that the left operand has no effect because reading a volatile variable is an operation with a side effect.)

It seems this is covered by svn157362.



================
Comment at: clang/test/CodeCompletion/pragma-macro-token-caching.c:15
     Outer(__extension__({ _Pragma(2) })); // expected-error {{_Pragma takes a parenthesized string literal}}
-    param; // expected-warning {{expression result unused}}
 }
----------------
aaron.ballman wrote:
> Why did we lose this diagnostic?
CFG analysis thinks it is unreachable, so it is not diagnosed.


================
Comment at: clang/test/Sema/exprs.c:19
   if (0) {
-    0 / (0 ? 1 : 0); // expected-warning {{expression result unused}}
   }
----------------
aaron.ballman wrote:
> Why did we lose this diagnostic (and the above comment about not changing the test)?
Because the behavior change here is that only reachable code is diagnosed. I should have kept the comment. 


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