diff --git a/.github/workflows/lint-build.yml b/.github/workflows/lint-build.yml index f3e52d5..eb9ade3 100644 --- a/.github/workflows/lint-build.yml +++ b/.github/workflows/lint-build.yml @@ -21,8 +21,8 @@ jobs: - name: Invoke clang shell: bash run: >+ - clang++ -DVERSION=0.0.0 -DNDEBUG -WCL4 -Wnon-gcc -Wno-nullability-completeness -Werror -std=c++14 -o - /dev/null src/*.cpp + clang++ -DVERSION=0.0.0 -DNDEBUG -WCL4 -Wnon-gcc -Wimplicit-fallthrough -Werror -std=c++14 -o /dev/null + src/*.cpp lint-npm: if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} runs-on: ubuntu-latest diff --git a/src/compat.hh b/src/compat.hh index bc586f3..574aed1 100644 --- a/src/compat.hh +++ b/src/compat.hh @@ -4,7 +4,7 @@ #include #ifdef __has_include -#if __has_include() +#if __has_include() && !defined(__clang__) #include #endif @@ -35,6 +35,15 @@ constexpr int EX_NOINPUT = 66; #endif +#if !defined(__GNUC__) && defined(_MSC_VER) +// 1 if the compiler is really MSVC, and not clang pretending to be MSVC. 0 for clang and GCC. +#define REALLY_MSVC 1 +#else +// 1 if the compiler is really MSVC, and not clang pretending to be MSVC. 0 for clang and GCC. +#define REALLY_MSVC 0 +#endif + + #ifdef __cpp_constinit // constinit, constexpr, or just const, depending on where lambdas are allowed #define CONSTINIT_LAMBDA constinit const @@ -108,7 +117,7 @@ constexpr int EX_NOINPUT = 66; #define FALLTHROUGH [[fallthrough]]; #endif -#if !defined(__GNUC__) && defined(_MSC_VER) +#if REALLY_MSVC #if _MSC_VER >= 1929 // mark that the padding of this member can be used for other members #define NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] @@ -160,7 +169,7 @@ constexpr int EX_NOINPUT = 66; #endif -#if !defined(__GNUC__) && defined(_MSC_VER) +#if REALLY_MSVC #define __builtin_unreachable() __assume(0) #endif @@ -172,6 +181,7 @@ constexpr int EX_NOINPUT = 66; #ifdef __clang__ +#pragma clang diagnostic ignored "-Wnullability-completeness" // A non-nullable pointer to the specified type. #define NONNULL_PTR(...) __VA_ARGS__* _Nonnull #elif defined(_Notnull_) @@ -184,7 +194,7 @@ constexpr int EX_NOINPUT = 66; #endif -#if (defined(__x86_64__) || defined(_M_X64)) && (defined(__GNUC__) || defined(__clang__)) +#if (defined(__x86_64__) || defined(_M_X64)) && !REALLY_MSVC // 1 on gcc or clang for x86-64, where asm blocks are used. 0 otherwise. #define ASM_ALLOWED 1 #else diff --git a/src/disassembler.cpp b/src/disassembler.cpp index 317153b..eec038b 100644 --- a/src/disassembler.cpp +++ b/src/disassembler.cpp @@ -114,6 +114,7 @@ void disassembler::build_state() { case PSI: case PSC: program_walker::advance(ip, m_program->side_length()); + break; default: break; } diff --git a/src/program_walker.hh b/src/program_walker.hh index d05ee4e..42609c7 100644 --- a/src/program_walker.hh +++ b/src/program_walker.hh @@ -97,7 +97,7 @@ public: } } -#ifdef _MSC_VER +#if REALLY_MSVC #pragma warning(push) #pragma warning(disable : 4702) // C4702 is unreachable code, which it complains about when constant-folding the template instantiation @@ -290,7 +290,7 @@ public: } } -#ifdef _MSC_VER +#if REALLY_MSVC #pragma warning(pop) #endif protected: diff --git a/wasm/build_wasm.sh b/wasm/build_wasm.sh index 3b37658..4f74ce0 100755 --- a/wasm/build_wasm.sh +++ b/wasm/build_wasm.sh @@ -2,7 +2,7 @@ set -e -common_emcc_args=(-WCL4 -Wnon-gcc -Wno-nullability-completeness +common_emcc_args=(-WCL4 -Wnon-gcc -Wimplicit-fallthrough -fno-rtti -fno-exceptions -sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY -sASYNCIFY_IMPORTS='send_debug_info' -o worker.js