Minor: fix msvc warning "not all control paths return a value" (#5650)
When building with /Od - default cmake debug build for me, the __assume(false); trick does not work to get rid of the C4714 warnings https://godbolt.org/z/a6xGnfP7d D:\tmp\cppcheck\lib\keywords.cpp(205): warning C4715: 'Keywords::getOnly': not all control paths return a value D:\tmp\cppcheck\lib\keywords.cpp(226): warning C4715: 'Keywords::getOnly': not all control paths return a value D:\tmp\cppcheck\lib\keywords.cpp(168): warning C4715: 'Keywords::getAll': not all control paths return a value D:\tmp\cppcheck\lib\keywords.cpp(188): warning C4715: 'Keywords::getAll': not all control paths return a value Proposed fix: also define NORETURN to [[noreturn]] when according to __has_cpp_attribute [[noreturn]] is supported https://en.cppreference.com/w/cpp/feature_test (For previous discussion see also https://github.com/danmar/cppcheck/pull/5497)
This commit is contained in:
parent
b201ef26cb
commit
d3520943ad
19
lib/config.h
19
lib/config.h
|
@ -51,14 +51,21 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// C++11 noreturn
|
// C++11 noreturn
|
||||||
#if (defined(__GNUC__) && (__GNUC__ >= 5)) \
|
#if defined __has_cpp_attribute
|
||||||
|
# if __has_cpp_attribute (noreturn)
|
||||||
|
# define NORETURN [[noreturn]]
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if !defined(NORETURN)
|
||||||
|
# if (defined(__GNUC__) && (__GNUC__ >= 5)) \
|
||||||
|| defined(__clang__) \
|
|| defined(__clang__) \
|
||||||
|| defined(__CPPCHECK__)
|
|| defined(__CPPCHECK__)
|
||||||
# define NORETURN [[noreturn]]
|
# define NORETURN [[noreturn]]
|
||||||
#elif defined(__GNUC__)
|
# elif defined(__GNUC__)
|
||||||
# define NORETURN __attribute__((noreturn))
|
# define NORETURN __attribute__((noreturn))
|
||||||
#else
|
# else
|
||||||
# define NORETURN
|
# define NORETURN
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// fallthrough
|
// fallthrough
|
||||||
|
|
Loading…
Reference in New Issue