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

2021-09-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. In D103938#3007708 , @ychen wrote: > In D103938#3006540 , @aaron.ballman > wrote: > >> There w

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

2021-09-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment. Thanks for the review. Comment at: clang/test/Sema/exprs.c:19 if (0) { -0 / (0 ? 1 : 0); // expected-warning {{expression result unused}} } ychen wrote: > aaron.ballman wrote: > > Why did we lose this diagnostic (and the above c

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

2021-09-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 373390. ychen added a comment. - Restore an useful comment. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103938/new/ https://reviews.llvm.org/D103938 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td

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

2021-09-17 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment. In 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 expres

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

2021-09-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. 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

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

2021-09-16 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment. ping? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103938/new/ https://reviews.llvm.org/D103938 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-

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

2021-09-07 Thread Yuanfang Chen via Phabricator via cfe-commits
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}} \ + /

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

2021-09-07 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 371221. ychen added a comment. Herald added a subscriber: jdoerfert. - Use more specific diagnoses "left operand of comma operator has no effect" when left operand of comma operator has no effect instead of "expression result is unused". Repository: rG LL

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

2021-07-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman 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}} \ +

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

2021-07-21 Thread Yuanfang Chen via Phabricator via cfe-commits
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}} \ + /

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

2021-07-21 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 360514. ychen marked an inline comment as done. ychen added a comment. - fix comment Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103938/new/ https://reviews.llvm.org/D103938 Files: clang/include/clang/Sema/S

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

2021-07-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang/include/clang/Sema/Sema.h:5077 + /// Conditionally issue a diagnostic based on the statements reachability + /// analysis evaluation context. Comment at: clang/test/Sema/i-c-e.c:77-78

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

2021-07-14 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment. ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103938/new/ https://reviews.llvm.org/D103938 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-b

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

2021-07-07 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment. ping.. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103938/new/ https://reviews.llvm.org/D103938 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi

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

2021-06-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment. In D103938#2836470 , @rsmith wrote: > I've given this some more thought, and I think it's only the "constant > evaluated" check that we want to bypass in this case. It's common to use > `sizeof` or `decltype` with a comma operator

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

2021-06-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 355054. ychen added a comment. - Add test case for 'constexpr if' Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103938/new/ https://reviews.llvm.org/D103938 Files: clang/include/clang/Sema/Sema.h clang/lib/S

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

2021-06-23 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment. I've given this some more thought, and I think it's only the "constant evaluated" check that we want to bypass in this case. It's common to use `sizeof` or `decltype` with a comma operator in order to put an expression in a SFINAE context, and I don't think we should war

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

2021-06-23 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment. ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103938/new/ https://reviews.llvm.org/D103938 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-b

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

2021-06-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment. In D103938#2806885 , @rsmith wrote: > This will diagnose unused values in unreachable code in constant-evaluated > contexts; that doesn't seem quite right. For example, in: > > void f() { > new double[false ? (1, 2) : 3][fals

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

2021-06-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 351343. ychen added a comment. - Add `DiagIfReachable` and use it in `Sema::DiagnoseUnusedExprResult`. - Update tests. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103938/new/ https://reviews.llvm.org/D103938 F

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

2021-06-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment. This will diagnose unused values in unreachable code in constant-evaluated contexts; that doesn't seem quite right. For example, in: void f() { new double[false ? (1, 2) : 3][false ? (1, 2) : 3]; } ... we'll diagnose that the `1` is unused in only one of the two

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

2021-06-08 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision. ychen added reviewers: aaron.ballman, rsmith. ychen requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. GCC/MSVC diagnoses in such cases, probably it makes sense to do the same for Clang. https://godbolt.org/z/7zxb8