exprtk
exprtk copied to clipboard
Disable fallthrough warnings for clang compiler
When compiling an application that includes exprtk.hpp using Clang (Version Apple clang version 12.0.5 (clang-1205.0.22.9) tested using Mac) with the flags -Wimplicit-fallthrough -Werror our compile fails because of the implicit fallthroughs. I suppose the same should happen under Linux when compiling with Clang.
This patch applies the same ignore mechanism that is used for GCC for Clang.
I've tested to work the change on the following Plattforms:
- Intel MacOS: Apple clang version 12.0.5 (clang-1205.0.22.9)
- M1 MacOS: clang version 14.0.0 (clang-1400.0.29.102)
- amd64 Debian: g++ 12.2.0
- amd64 Debian: clang 9.0.1-20+b1
- amd64 Debian: clang 11.1.0-6+b2
- amd64 Debian: clang 13.0.1-7
- amd64 Debian: clang 14.0.6-2
Isn't a better way to silence these warnings on these newer compilers to use [[fallthrough]] at the appropriate source locations where fallthrough is expected? Some macros might be needed for older compilers, but that seems not terrible.
Edit: Sorry for not reading properly. I see now that you're amending the existing fallthrough disable macros for clang. I still suspect that it would be an improvement to replace the existing pragmas with more standard fallthrough attribute when possible. https://en.cppreference.com/w/cpp/language/attributes/fallthrough
@belgoking and @eric-norige : I am planning on doing a simple upgrade of the library to c++17, as part of that I'll be looking at closing these issues.