-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
Description
clang-tidy v21.1.5 fails on macOS (Homebrew version) when modernize diagnostics are set and standard is more recent than C++17.
Let's consider this hello.cpp:
#include <cstddef>
#include <iostream>
int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
{
std::cout << "Hello world!" << std::endl;
return EXIT_SUCCESS;
}With C++ 17 it works:
➜ clang-tidy hello.cpp -checks="-*,modernize-*" -- -std=c++17 -x c++
11204 warnings generated.
/Users/sgilles/Codes/Sandbox/hello.cpp:3:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
3 | int main(int argc, char** argv)
| ~~~ ^
| auto -> int
Suppressed 11204 warnings (11203 in non-user code, 1 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.but it fails with more recent standards:
➜ clang-tidy hello.cpp -checks="-*,modernize-*" -- -std=c++20 -x c++
13289 warnings and 10 errors generated.
Error while processing /Users/sgilles/Codes/Sandbox/hello.cpp.
error: missing '(' after '__has_feature' [clang-diagnostic-error]
/Users/sgilles/Codes/Sandbox/hello.cpp:3:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
3 | int main(int argc, char** argv)
| ~~~ ^
| auto -> int
Suppressed 13290 warnings (13288 in non-user code, 2 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).This is recent (the exact same code worked with the diagnostic and C++ 23 standard few months ago) and it is related specifically to modernize diagnostics.