[PATCH] D147844: [clang][Sema]Print diagnostic warning about precedence when integer expression is used without parentheses in an conditional operator expression

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 27 07:55:36 PDT 2023


erichkeane added a comment.

In D147844#4651113 <https://reviews.llvm.org/D147844#4651113>, @chaitanyav wrote:

> Bootstrapping build failed due to -werror flag (https://buildkite.com/llvm-project/libcxx-ci/builds/30031)
>
>    | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-4613821dc47f-1/llvm-project/libcxx-ci/libcxx/test/std/containers/unord/unord.multiset/eq.different_hash.pass.cpp:43:18: error: operator '?:' has lower precedence than '&'; '&' will be evaluated first [-Werror,-Wbitwise-conditional-parentheses]
>   # |    43 |   return val & 1 ? 1 : 0;
>   # |       |          ~~~~~~~ ^
>   
>   
>   # | /home/libcxx-builder/.buildkite-agent/builds/google-libcxx-builder-4613821dc47f-1/llvm-project/libcxx-ci/libcxx/test/std/containers/unord/unord.multiset/eq.different_hash.pass.cpp:64:19: error: operator '?:' has lower precedence than '&'; '&' will be evaluated first [-Werror,-Wbitwise-conditional-parentheses]
>   # |    64 |   return *val & 1 ? 1 : 0;
>   # |       |          ~~~~~~~~ ^

That looks like it is just in a test in libcxx, so at least that is a fairly simple thing to fix.  I'd suggest just adding the parens in there (and I'm sure that is something that @ldionne would have no problem with), or adding the -Wno flag to the tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147844/new/

https://reviews.llvm.org/D147844



More information about the cfe-commits mailing list