From 0fa5fb16bd4d54a7d8b3c26e76f9f03c55c8cfd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Eduardo=20Garc=C3=ADa=20Hern=C3=A1ndez?= Date: Wed, 4 Jan 2023 12:35:39 +0000 Subject: [PATCH] tint: fix clang-cl compilation * Disabling warnings was using the MSVC codepath * Required to disable a float comparison on lexer.cc for clang Change-Id: Ie3123593ebba2bffe34bff490ff76d5bdbd7d40d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116240 Reviewed-by: Ben Clayton Kokoro: Kokoro Commit-Queue: Ben Clayton --- src/tint/reader/wgsl/lexer.cc | 2 ++ src/tint/utils/compiler_macros.h | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tint/reader/wgsl/lexer.cc b/src/tint/reader/wgsl/lexer.cc index 16712cae40..9ebe5d8a9c 100644 --- a/src/tint/reader/wgsl/lexer.cc +++ b/src/tint/reader/wgsl/lexer.cc @@ -405,11 +405,13 @@ Token Lexer::try_float() { } } + TINT_BEGIN_DISABLE_WARNING(FLOAT_EQUAL); if (value == HUGE_VAL || -value == HUGE_VAL) { return {Token::Type::kError, source, "value cannot be represented as 'abstract-float'"}; } else { return {Token::Type::kFloatLiteral, source, value}; } + TINT_END_DISABLE_WARNING(FLOAT_EQUAL); } Token Lexer::try_hex_float() { diff --git a/src/tint/utils/compiler_macros.h b/src/tint/utils/compiler_macros.h index b0df241b68..1a0404283d 100644 --- a/src/tint/utils/compiler_macros.h +++ b/src/tint/utils/compiler_macros.h @@ -19,7 +19,7 @@ #define TINT_REQUIRE_SEMICOLON static_assert(true) -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(__clang__) //////////////////////////////////////////////////////////////////////////////// // MSVC //////////////////////////////////////////////////////////////////////////////// @@ -30,6 +30,7 @@ #define TINT_DISABLE_WARNING_SIGN_CONVERSION /* currently no-op */ #define TINT_DISABLE_WARNING_UNREACHABLE_CODE __pragma(warning(disable : 4702)) #define TINT_DISABLE_WARNING_WEAK_VTABLES /* currently no-op */ +#define TINT_DISABLE_WARNING_FLOAT_EQUAL /* currently no-op */ // clang-format off #define TINT_BEGIN_DISABLE_WARNING(name) \ @@ -52,6 +53,7 @@ _Pragma("clang diagnostic ignored \"-Wsign-conversion\"") #define TINT_DISABLE_WARNING_UNREACHABLE_CODE /* currently no-op */ #define TINT_DISABLE_WARNING_WEAK_VTABLES _Pragma("clang diagnostic ignored \"-Wweak-vtables\"") +#define TINT_DISABLE_WARNING_FLOAT_EQUAL _Pragma("clang diagnostic ignored \"-Wfloat-equal\"") // clang-format off #define TINT_BEGIN_DISABLE_WARNING(name) \ @@ -74,6 +76,7 @@ #define TINT_DISABLE_WARNING_SIGN_CONVERSION /* currently no-op */ #define TINT_DISABLE_WARNING_UNREACHABLE_CODE /* currently no-op */ #define TINT_DISABLE_WARNING_WEAK_VTABLES /* currently no-op */ +#define TINT_DISABLE_WARNING_FLOAT_EQUAL /* currently no-op */ // clang-format off #define TINT_BEGIN_DISABLE_WARNING(name) \