Fix VS clang-cl build * Disable "undefined-var-template" in code, rather than in build files * Add back some missing headers required when building in this context * Make sure gtest/gmock do not override the default runtime library Change-Id: I12c05943fc1d2dee4733ae70db7da026f67e0dad Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44180 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/castable.h b/src/castable.h index c5d88c3..956f4f6 100644 --- a/src/castable.h +++ b/src/castable.h
@@ -17,6 +17,26 @@ #include <utility> +#if defined(__clang__) +/// Temporarily disable certain warnings when using Castable API +#define TINT_CASTABLE_PUSH_DISABLE_WARNINGS() \ + _Pragma("clang diagnostic push") /**/ \ + _Pragma("clang diagnostic ignored \"-Wundefined-var-template\"") /**/ \ + static_assert(true, "require extra semicolon") + +/// Restore disabled warnings +#define TINT_CASTABLE_POP_DISABLE_WARNINGS() \ + _Pragma("clang diagnostic pop") /**/ \ + static_assert(true, "require extra semicolon") +#else +#define TINT_CASTABLE_PUSH_DISABLE_WARNINGS() \ + static_assert(true, "require extra semicolon") +#define TINT_CASTABLE_POP_DISABLE_WARNINGS() \ + static_assert(true, "require extra semicolon") +#endif + +TINT_CASTABLE_PUSH_DISABLE_WARNINGS(); + namespace tint { namespace detail { @@ -25,11 +45,14 @@ } // namespace detail /// Helper macro to instantiate the TypeInfo<T> template for `CLASS`. -#define TINT_INSTANTIATE_TYPEINFO(CLASS) \ - template <> \ - const tint::TypeInfo tint::detail::TypeInfoOf<CLASS>::info { \ - &tint::detail::TypeInfoOf<CLASS::TrueBase>::info, #CLASS, \ - } +#define TINT_INSTANTIATE_TYPEINFO(CLASS) \ + TINT_CASTABLE_PUSH_DISABLE_WARNINGS(); \ + template <> \ + const tint::TypeInfo tint::detail::TypeInfoOf<CLASS>::info{ \ + &tint::detail::TypeInfoOf<CLASS::TrueBase>::info, \ + #CLASS, \ + }; \ + TINT_CASTABLE_POP_DISABLE_WARNINGS() /// TypeInfo holds type information for a Castable type. struct TypeInfo { @@ -197,4 +220,6 @@ } // namespace tint +TINT_CASTABLE_POP_DISABLE_WARNINGS(); + #endif // SRC_CASTABLE_H_
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index 729e33d..b694b6d 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc
@@ -15,6 +15,7 @@ #include "src/reader/spirv/parser_impl.h" #include <limits> +#include <locale> #include "source/opt/build_module.h" #include "src/ast/bitcast_expression.h"
diff --git a/src/source.h b/src/source.h index f56953c..416a30e 100644 --- a/src/source.h +++ b/src/source.h
@@ -16,6 +16,7 @@ #ifndef SRC_SOURCE_H_ #define SRC_SOURCE_H_ +#include <iostream> #include <string> #include <vector>
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index b14613c..734ebca 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt
@@ -13,6 +13,7 @@ # limitations under the License. if (${TINT_BUILD_TESTS} AND NOT TARGET gmock) + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL) endif()