Bug 1887580 - Disable some C++20 warnings that break the C++20 build or are too noisy. r=firefox-build-system-reviewers,glandium

1. Stop enabling -Wdeprecated-this-capture because it has no affect when compiling as C++17 and it's enabled by default with compiling as C++20.

2. Disable -Wdeprecated-this-capture warnings by changing "-Wno-error" to "-Wno". These warnings are enabled by default when compiling as C++20 and even just logging these warnings as non-fatal messages breaks the clang-plugin tests because the messages aren't in the tests' expected compiler output. We can't fix these warnings until after we default to -std=c++20 because the code change isn't backwards compatible with C++17.

3. Stop enabling -Wc++2a-compat because it causes build errors about valid C++20 code (that isn't backwards compatible with C++17) when compiling as C++20.

4. Remove -Wno-error=deprecated. I don't remember why it was needed to compile as C++20 when I added it two years ago (in bug 1781001), but it's no longer needed.

5. Disable -Wdeprecated-anon-enum-enum-conversion and -Wdeprecated-enum-enum-conversion warnings by changing "-Wno-error" to "-Wno". There are so many warnings in common shared header files, they overwhelm the compiler output. Fixing these warnings in bug 1791958 and bug 1791955, respectively, doesn't block defaulting to -std=c++20.

6. Remove -Wno-deprecated-pragma because it's not longer needed. It warns about C++20 deprecating ATOMIC_VAR_INIT in favor of std::atomic<int>. We used to have some warnings about ATOMIC_VAR_INIT, but I guess they've been fixed because we currently have no -Wdeprecated-pragma warnings.

Differential Revision: https://phabricator.services.mozilla.com/D205539
This commit is contained in:
Chris Peterson 2024-03-27 00:38:54 +00:00
parent 2ac0262f68
commit 90b77f1d03

View File

@ -36,9 +36,6 @@ add_warning("-W3", when=depends(c_compiler)(lambda c: c.type == "clang-cl"))
# catch implicit truncation of enum values assigned to smaller bit fields
check_and_add_warning("-Wbitfield-enum-conversion")
# catches deprecated implicit capture of `this` in lambdas.
check_and_add_warning("-Wdeprecated-this-capture", cxx_compiler)
# catches bugs, e.g. "if (c); foo();", few false positives
add_warning("-Wempty-body")
@ -98,19 +95,15 @@ check_and_add_warning("-Wno-range-loop-analysis")
# Enable some C++20 compat warnings. We can remove these flags after we compile
# as C++20 (bug 1768116), because they will be enabled by default:
check_and_add_warning("-Wc++2a-compat", cxx_compiler)
check_and_add_warning("-Wcomma-subscript", cxx_compiler)
check_and_add_warning("-Wenum-compare-conditional")
check_and_add_warning("-Wenum-float-conversion")
check_and_add_warning("-Wvolatile", cxx_compiler)
# Downgrade some C++20 warnings-as-errors to warnings that we can fix after we
# compile as C++20 (bug 1768116). They don't need to block upgrading to C++20.
check_and_add_warning("-Wno-error=deprecated", cxx_compiler)
check_and_add_warning("-Wno-error=deprecated-anon-enum-enum-conversion", cxx_compiler)
check_and_add_warning("-Wno-error=deprecated-enum-enum-conversion", cxx_compiler)
check_and_add_warning("-Wno-error=deprecated-pragma", cxx_compiler)
check_and_add_warning("-Wno-error=deprecated-this-capture", cxx_compiler)
# Disable some C++20 errors to be fixed in bugs 1791958, 1791955, and 1775161.
check_and_add_warning("-Wno-deprecated-anon-enum-enum-conversion", cxx_compiler)
check_and_add_warning("-Wno-deprecated-enum-enum-conversion", cxx_compiler)
check_and_add_warning("-Wno-deprecated-this-capture", cxx_compiler)
# catches possible misuse of the comma operator
check_and_add_warning("-Wcomma", cxx_compiler)