Krishna-13-cyber updated this revision to Diff 510909. Krishna-13-cyber added a comment.
- Updated with release note - I had tried adding more text to the `expected-error` but it already gives a diagnostic of `static assertion failed due to requirement` currently. If I try additions to `{{failed}}` then we get **error diagnostics expected but not seen**. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D146376/new/ https://reviews.llvm.org/D146376 Files: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/static-assert.cpp Index: clang/test/SemaCXX/static-assert.cpp =================================================================== --- clang/test/SemaCXX/static-assert.cpp +++ clang/test/SemaCXX/static-assert.cpp @@ -258,8 +258,14 @@ constexpr bool invert(bool b) { return !b; } + + static_assert(invert(true) || invert(true), ""); // expected-error {{failed}} static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \ // expected-note {{evaluates to 'false == true'}} + static_assert(true && false, ""); // expected-error {{failed}} + static_assert(invert(true) || invert(true) || false, ""); // expected-error {{failed}} + static_assert((true && invert(true)) || false, ""); // expected-error {{failed}} + static_assert(true && invert(false) && invert(true), ""); // expected-error {{failed}} /// No notes here since we compare a bool expression with a bool literal. static_assert(invert(true) == true, ""); // expected-error {{failed}} Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -16715,7 +16715,8 @@ /// Try to print more useful information about a failed static_assert /// with expression \E void Sema::DiagnoseStaticAssertDetails(const Expr *E) { - if (const auto *Op = dyn_cast<BinaryOperator>(E)) { + if (const auto *Op = dyn_cast<BinaryOperator>(E); + Op && Op->getOpcode() != BO_LOr) { const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts(); const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts(); Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -179,6 +179,9 @@ - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` statements previously issued from ``-Wunreachable-code`` and ``-Wunreachable-code-fallthrough`` by prioritizing ``-Wunreachable-code-fallthrough``. +- Clang now avoids unnecessary diagnostic warnings for obvious expressions in + the case of binary operators with logical OR operations. + (`#57906 <https://github.com/llvm/llvm-project/issues/57906>`_) Bug Fixes in This Version -------------------------
Index: clang/test/SemaCXX/static-assert.cpp =================================================================== --- clang/test/SemaCXX/static-assert.cpp +++ clang/test/SemaCXX/static-assert.cpp @@ -258,8 +258,14 @@ constexpr bool invert(bool b) { return !b; } + + static_assert(invert(true) || invert(true), ""); // expected-error {{failed}} static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \ // expected-note {{evaluates to 'false == true'}} + static_assert(true && false, ""); // expected-error {{failed}} + static_assert(invert(true) || invert(true) || false, ""); // expected-error {{failed}} + static_assert((true && invert(true)) || false, ""); // expected-error {{failed}} + static_assert(true && invert(false) && invert(true), ""); // expected-error {{failed}} /// No notes here since we compare a bool expression with a bool literal. static_assert(invert(true) == true, ""); // expected-error {{failed}} Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -16715,7 +16715,8 @@ /// Try to print more useful information about a failed static_assert /// with expression \E void Sema::DiagnoseStaticAssertDetails(const Expr *E) { - if (const auto *Op = dyn_cast<BinaryOperator>(E)) { + if (const auto *Op = dyn_cast<BinaryOperator>(E); + Op && Op->getOpcode() != BO_LOr) { const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts(); const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts(); Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -179,6 +179,9 @@ - Clang now avoids duplicate warnings on unreachable ``[[fallthrough]];`` statements previously issued from ``-Wunreachable-code`` and ``-Wunreachable-code-fallthrough`` by prioritizing ``-Wunreachable-code-fallthrough``. +- Clang now avoids unnecessary diagnostic warnings for obvious expressions in + the case of binary operators with logical OR operations. + (`#57906 <https://github.com/llvm/llvm-project/issues/57906>`_) Bug Fixes in This Version -------------------------
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits