From 3a2a27971487769c4581c876ea379854a4fe997a Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Wed, 29 Jun 2022 14:38:15 +0000 Subject: [PATCH] Fixup various warnings in Tint which were accidentally suppressed. When enabling the SPIR-V reader or SPIR-V writer we were suppressing -Wnewline-eof, -Wold-style-cast, -Wsign-conversion, and -Wweak-vtables for the `libtint` cmake target and anything that depended on that target. Because we'd build all readers/ writers by default this caused us to never hit those warnings. A recent change to the cmake build sets the Tint backend based on the Dawn backend. So, there is a much higher chance of not building the SPIR-V support if you're on a Mac or Windows machine. This CL removes the suppression of the warnings, adds specific pragmas into the SPIR-V reader code which imports the SPIRV-Tools headers and fixes up the warnings which were then firing due to checking for the new warnings. Change-Id: I0d0be6aa3d0b692e939ce8ff924dfb82c82792fc Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94901 Reviewed-by: Ben Clayton Auto-Submit: Dan Sinclair Commit-Queue: Ben Clayton --- src/tint/CMakeLists.txt | 12 -- src/tint/ast/array_test.cc | 2 +- src/tint/ast/binding_attribute_test.cc | 2 +- src/tint/ast/builtin_texture_helper_test.cc | 8 +- src/tint/ast/group_attribute_test.cc | 2 +- src/tint/ast/id_attribute_test.cc | 2 +- src/tint/ast/location_attribute_test.cc | 2 +- src/tint/ast/matrix_test.cc | 6 +- src/tint/ast/stride_attribute_test.cc | 4 +- .../ast/struct_member_align_attribute_test.cc | 2 +- .../struct_member_offset_attribute_test.cc | 2 +- .../ast/struct_member_size_attribute_test.cc | 2 +- src/tint/ast/variable_test.cc | 12 +- src/tint/ast/vector_test.cc | 4 +- src/tint/castable.cc | 4 + src/tint/castable.h | 6 +- src/tint/clone_context.cc | 4 + src/tint/clone_context.h | 7 ++ src/tint/demangler.cc | 2 +- src/tint/inspector/inspector.cc | 4 +- src/tint/inspector/inspector_test.cc | 2 +- src/tint/inspector/test_inspector_builder.cc | 4 +- src/tint/reader/spirv/function.cc | 38 ++++--- src/tint/reader/spirv/parser_impl.cc | 10 +- src/tint/reader/spirv/parser_impl.h | 10 ++ .../reader/spirv/parser_impl_test_helper.h | 10 ++ src/tint/reader/spirv/parser_type.cc | 6 + src/tint/reader/spirv/parser_type.h | 9 ++ src/tint/reader/spirv/usage_test.cc | 6 +- src/tint/reader/wgsl/lexer.cc | 4 +- .../resolver/assignment_validation_test.cc | 20 ++-- src/tint/resolver/atomics_test.cc | 4 +- .../resolver/attribute_validation_test.cc | 48 ++++---- src/tint/resolver/builtin_test.cc | 8 +- src/tint/resolver/builtin_validation_test.cc | 4 +- src/tint/resolver/function_validation_test.cc | 6 +- .../host_shareable_validation_test.cc | 20 ++-- src/tint/resolver/intrinsic_table.cc | 4 +- src/tint/resolver/ptr_ref_test.cc | 8 +- src/tint/resolver/ptr_ref_validation_test.cc | 4 +- src/tint/resolver/resolver.cc | 13 ++- src/tint/resolver/resolver_test.cc | 24 ++-- .../resolver/storage_class_validation_test.cc | 68 ++++++------ .../resolver/struct_storage_class_use_test.cc | 8 +- .../type_constructor_validation_test.cc | 104 +++++++++--------- src/tint/resolver/type_validation_test.cc | 4 +- src/tint/resolver/validation_test.cc | 8 +- src/tint/resolver/validator.cc | 5 +- src/tint/resolver/variable_test.cc | 20 ++-- src/tint/resolver/variable_validation_test.cc | 17 +-- src/tint/sem/variable.cc | 2 + src/tint/sem/variable.h | 1 + src/tint/transform/combine_samplers.cc | 10 +- src/tint/transform/decompose_memory_access.cc | 6 +- .../decompose_strided_matrix_test.cc | 40 +++---- src/tint/transform/robustness.cc | 12 +- src/tint/utils/block_allocator_test.cc | 4 +- src/tint/utils/compiler_macros.h | 13 +++ src/tint/writer/append_vector.cc | 2 +- src/tint/writer/float_to_string_test.cc | 2 +- src/tint/writer/glsl/generator_impl.cc | 6 +- .../glsl/generator_impl_function_test.cc | 36 +++--- .../generator_impl_member_accessor_test.cc | 4 +- .../glsl/generator_impl_sanitizer_test.cc | 12 +- .../generator_impl_storage_buffer_test.cc | 4 +- .../writer/glsl/generator_impl_type_test.cc | 16 +-- src/tint/writer/hlsl/generator_impl.cc | 4 +- .../writer/hlsl/generator_impl_case_test.cc | 2 +- .../hlsl/generator_impl_function_test.cc | 36 +++--- .../generator_impl_member_accessor_test.cc | 4 +- .../hlsl/generator_impl_sanitizer_test.cc | 20 ++-- .../writer/hlsl/generator_impl_type_test.cc | 16 +-- src/tint/writer/msl/generator_impl.cc | 4 +- .../msl/generator_impl_function_test.cc | 24 ++-- .../msl/generator_impl_sanitizer_test.cc | 28 ++--- .../writer/msl/generator_impl_type_test.cc | 28 ++--- src/tint/writer/spirv/builder.cc | 4 +- src/tint/writer/spirv/builder_builtin_test.cc | 48 ++++---- .../writer/spirv/builder_function_test.cc | 4 +- .../spirv/builder_global_variable_test.cc | 36 +++--- src/tint/writer/spirv/builder_type_test.cc | 36 +++--- src/tint/writer/text_generator.cc | 5 +- src/tint/writer/wgsl/generator_impl.cc | 2 +- .../wgsl/generator_impl_function_test.cc | 4 +- .../wgsl/generator_impl_global_decl_test.cc | 8 +- .../wgsl/generator_impl_literal_test.cc | 2 +- .../writer/wgsl/generator_impl_type_test.cc | 4 +- .../wgsl/generator_impl_variable_test.cc | 16 +-- 88 files changed, 577 insertions(+), 513 deletions(-) diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 50f586e801..755d4a30ef 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -22,18 +22,6 @@ function(tint_spvtools_compile_options TARGET) ${spirv-tools_SOURCE_DIR} ${spirv-tools_BINARY_DIR} ) - - if (${CMAKE_CXX_COMPILER_ID} MATCHES Clang) - # The SPIRV-Tools code is conditioned against C++ and an older version of Clang. - # Suppress warnings triggered in our current compilation environment. - # TODO(dneto): Fix the issues upstream. - target_compile_options(${TARGET} PRIVATE - -Wno-newline-eof - -Wno-sign-conversion - -Wno-old-style-cast - -Wno-weak-vtables - ) - endif() endfunction() ## Tint diagnostic utilities. Used by libtint and tint_utils_io. diff --git a/src/tint/ast/array_test.cc b/src/tint/ast/array_test.cc index baed0791e7..f396e0c79d 100644 --- a/src/tint/ast/array_test.cc +++ b/src/tint/ast/array_test.cc @@ -62,7 +62,7 @@ TEST_F(AstArrayTest, FriendlyName_ConstantSized) { TEST_F(AstArrayTest, FriendlyName_WithStride) { auto* i32 = create(); - auto* arr = create(i32, Expr(5_u), AttributeList{create(32)}); + auto* arr = create(i32, Expr(5_u), AttributeList{create(32u)}); EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(32) array"); } diff --git a/src/tint/ast/binding_attribute_test.cc b/src/tint/ast/binding_attribute_test.cc index f51fc25c27..800093360d 100644 --- a/src/tint/ast/binding_attribute_test.cc +++ b/src/tint/ast/binding_attribute_test.cc @@ -20,7 +20,7 @@ namespace { using BindingAttributeTest = TestHelper; TEST_F(BindingAttributeTest, Creation) { - auto* d = create(2); + auto* d = create(2u); EXPECT_EQ(2u, d->value); } diff --git a/src/tint/ast/builtin_texture_helper_test.cc b/src/tint/ast/builtin_texture_helper_test.cc index 3d23808e88..ad42267674 100644 --- a/src/tint/ast/builtin_texture_helper_test.cc +++ b/src/tint/ast/builtin_texture_helper_test.cc @@ -142,8 +142,8 @@ const ast::Type* TextureOverloadCase::BuildResultVectorComponentType(ProgramBuil const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b) const { AttributeList attrs = { - b->create(0), - b->create(0), + b->create(0u), + b->create(0u), }; switch (texture_kind) { case ast::builtin::test::TextureKind::kRegular: @@ -176,8 +176,8 @@ const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b const ast::Variable* TextureOverloadCase::BuildSamplerVariable(ProgramBuilder* b) const { AttributeList attrs = { - b->create(0), - b->create(1), + b->create(0u), + b->create(1u), }; return b->GlobalVar("sampler", b->ty.sampler(sampler_kind), attrs); } diff --git a/src/tint/ast/group_attribute_test.cc b/src/tint/ast/group_attribute_test.cc index 53167bbb7a..4a6dd1dd28 100644 --- a/src/tint/ast/group_attribute_test.cc +++ b/src/tint/ast/group_attribute_test.cc @@ -20,7 +20,7 @@ namespace { using GroupAttributeTest = TestHelper; TEST_F(GroupAttributeTest, Creation) { - auto* d = create(2); + auto* d = create(2u); EXPECT_EQ(2u, d->value); } diff --git a/src/tint/ast/id_attribute_test.cc b/src/tint/ast/id_attribute_test.cc index 6957d66b63..ad05c58ab5 100644 --- a/src/tint/ast/id_attribute_test.cc +++ b/src/tint/ast/id_attribute_test.cc @@ -22,7 +22,7 @@ namespace { using IdAttributeTest = TestHelper; TEST_F(IdAttributeTest, Creation) { - auto* d = create(12); + auto* d = create(12u); EXPECT_EQ(12u, d->value); } diff --git a/src/tint/ast/location_attribute_test.cc b/src/tint/ast/location_attribute_test.cc index a1562d561a..e0bcb39c7f 100644 --- a/src/tint/ast/location_attribute_test.cc +++ b/src/tint/ast/location_attribute_test.cc @@ -20,7 +20,7 @@ namespace { using LocationAttributeTest = TestHelper; TEST_F(LocationAttributeTest, Creation) { - auto* d = create(2); + auto* d = create(2u); EXPECT_EQ(2u, d->value); } diff --git a/src/tint/ast/matrix_test.cc b/src/tint/ast/matrix_test.cc index 66ea84de9f..dbb88e38f8 100644 --- a/src/tint/ast/matrix_test.cc +++ b/src/tint/ast/matrix_test.cc @@ -34,7 +34,7 @@ using AstMatrixTest = TestHelper; TEST_F(AstMatrixTest, Creation) { auto* i32 = create(); - auto* m = create(i32, 2, 4); + auto* m = create(i32, 2u, 4u); EXPECT_EQ(m->type, i32); EXPECT_EQ(m->rows, 2u); EXPECT_EQ(m->columns, 4u); @@ -42,12 +42,12 @@ TEST_F(AstMatrixTest, Creation) { TEST_F(AstMatrixTest, FriendlyName) { auto* i32 = create(); - auto* m = create(i32, 3, 2); + auto* m = create(i32, 3u, 2u); EXPECT_EQ(m->FriendlyName(Symbols()), "mat2x3"); } TEST_F(AstMatrixTest, FriendlyName_WithoutType) { - auto* m = create(nullptr, 3, 2); + auto* m = create(nullptr, 3u, 2u); EXPECT_EQ(m->FriendlyName(Symbols()), "mat2x3"); } diff --git a/src/tint/ast/stride_attribute_test.cc b/src/tint/ast/stride_attribute_test.cc index 61c4fb5dad..eb190341c6 100644 --- a/src/tint/ast/stride_attribute_test.cc +++ b/src/tint/ast/stride_attribute_test.cc @@ -20,13 +20,13 @@ namespace { using StrideAttributeTest = TestHelper; TEST_F(StrideAttributeTest, Creation) { - auto* d = create(2); + auto* d = create(2u); EXPECT_EQ(2u, d->stride); } TEST_F(StrideAttributeTest, Source) { auto* d = create( - Source{Source::Range{Source::Location{1, 2}, Source::Location{3, 4}}}, 2); + Source{Source::Range{Source::Location{1, 2}, Source::Location{3, 4}}}, 2u); EXPECT_EQ(d->source.range.begin.line, 1u); EXPECT_EQ(d->source.range.begin.column, 2u); EXPECT_EQ(d->source.range.end.line, 3u); diff --git a/src/tint/ast/struct_member_align_attribute_test.cc b/src/tint/ast/struct_member_align_attribute_test.cc index 5b4ff487a3..ba4d1bbb09 100644 --- a/src/tint/ast/struct_member_align_attribute_test.cc +++ b/src/tint/ast/struct_member_align_attribute_test.cc @@ -22,7 +22,7 @@ namespace { using StructMemberAlignAttributeTest = TestHelper; TEST_F(StructMemberAlignAttributeTest, Creation) { - auto* d = create(2); + auto* d = create(2u); EXPECT_EQ(2u, d->align); } diff --git a/src/tint/ast/struct_member_offset_attribute_test.cc b/src/tint/ast/struct_member_offset_attribute_test.cc index 3c0eb41c02..9d81ffb1c4 100644 --- a/src/tint/ast/struct_member_offset_attribute_test.cc +++ b/src/tint/ast/struct_member_offset_attribute_test.cc @@ -20,7 +20,7 @@ namespace { using StructMemberOffsetAttributeTest = TestHelper; TEST_F(StructMemberOffsetAttributeTest, Creation) { - auto* d = create(2); + auto* d = create(2u); EXPECT_EQ(2u, d->offset); } diff --git a/src/tint/ast/struct_member_size_attribute_test.cc b/src/tint/ast/struct_member_size_attribute_test.cc index a9d4637510..a82d53a0b0 100644 --- a/src/tint/ast/struct_member_size_attribute_test.cc +++ b/src/tint/ast/struct_member_size_attribute_test.cc @@ -22,7 +22,7 @@ namespace { using StructMemberSizeAttributeTest = TestHelper; TEST_F(StructMemberSizeAttributeTest, Creation) { - auto* d = create(2); + auto* d = create(2u); EXPECT_EQ(2u, d->size); } diff --git a/src/tint/ast/variable_test.cc b/src/tint/ast/variable_test.cc index e62ec1eb05..025fa6b3b7 100644 --- a/src/tint/ast/variable_test.cc +++ b/src/tint/ast/variable_test.cc @@ -94,9 +94,9 @@ TEST_F(VariableTest, Assert_DifferentProgramID_Constructor) { TEST_F(VariableTest, WithAttributes) { auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr, AttributeList{ - create(1), + create(1u), create(Builtin::kPosition), - create(1200), + create(1200u), }); auto& attributes = var->attributes; @@ -112,8 +112,8 @@ TEST_F(VariableTest, WithAttributes) { TEST_F(VariableTest, BindingPoint) { auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr, AttributeList{ - create(2), - create(1), + create(2u), + create(1u), }); EXPECT_TRUE(var->BindingPoint()); ASSERT_NE(var->BindingPoint().binding, nullptr); @@ -132,7 +132,7 @@ TEST_F(VariableTest, BindingPointAttributes) { TEST_F(VariableTest, BindingPointMissingGroupAttribute) { auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr, AttributeList{ - create(2), + create(2u), }); EXPECT_FALSE(var->BindingPoint()); ASSERT_NE(var->BindingPoint().binding, nullptr); @@ -142,7 +142,7 @@ TEST_F(VariableTest, BindingPointMissingGroupAttribute) { TEST_F(VariableTest, BindingPointMissingBindingAttribute) { auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr, - AttributeList{create(1)}); + AttributeList{create(1u)}); EXPECT_FALSE(var->BindingPoint()); ASSERT_NE(var->BindingPoint().group, nullptr); EXPECT_EQ(var->BindingPoint().group->value, 1u); diff --git a/src/tint/ast/vector_test.cc b/src/tint/ast/vector_test.cc index a701852df5..da2ad1f3de 100644 --- a/src/tint/ast/vector_test.cc +++ b/src/tint/ast/vector_test.cc @@ -24,14 +24,14 @@ using AstVectorTest = TestHelper; TEST_F(AstVectorTest, Creation) { auto* i32 = create(); - auto* v = create(i32, 2); + auto* v = create(i32, 2u); EXPECT_EQ(v->type, i32); EXPECT_EQ(v->width, 2u); } TEST_F(AstVectorTest, FriendlyName) { auto* f32 = create(); - auto* v = create(f32, 3); + auto* v = create(f32, 3u); EXPECT_EQ(v->FriendlyName(Symbols()), "vec3"); } diff --git a/src/tint/castable.cc b/src/tint/castable.cc index cff430ecb2..40c32da64a 100644 --- a/src/tint/castable.cc +++ b/src/tint/castable.cc @@ -26,4 +26,8 @@ const TypeInfo detail::TypeInfoOf::info{ tint::TypeInfo::FullHashCodeOf(), }; +CastableBase::CastableBase(const CastableBase&) = default; + +CastableBase::~CastableBase() = default; + } // namespace tint diff --git a/src/tint/castable.h b/src/tint/castable.h index 048d1e5258..c7b8608084 100644 --- a/src/tint/castable.h +++ b/src/tint/castable.h @@ -320,10 +320,10 @@ inline const TO* As(const FROM* obj) { class CastableBase { public: /// Copy constructor - CastableBase(const CastableBase&) = default; + CastableBase(const CastableBase&); /// Destructor - virtual ~CastableBase() = default; + virtual ~CastableBase(); /// Copy assignment /// @param other the CastableBase to copy @@ -626,7 +626,7 @@ inline void SwitchCases(T* object, RETURN_TYPE* result, std::tuple&& c // Static assertions static constexpr bool kDefaultIsOK = - kDefaultIndex == -1 || kDefaultIndex == std::tuple_size_v - 1; + kDefaultIndex == -1 || kDefaultIndex == static_cast(std::tuple_size_v - 1); static constexpr bool kReturnIsOK = kHasDefaultCase || !kHasReturnType || std::is_constructible_v; static_assert(kDefaultIsOK, "Default case must be last in Switch()"); diff --git a/src/tint/clone_context.cc b/src/tint/clone_context.cc index 0a9e606742..513c7103af 100644 --- a/src/tint/clone_context.cc +++ b/src/tint/clone_context.cc @@ -23,6 +23,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::Cloneable); namespace tint { +Cloneable::Cloneable() = default; +Cloneable::Cloneable(Cloneable&&) = default; +Cloneable::~Cloneable() = default; + CloneContext::ListTransforms::ListTransforms() = default; CloneContext::ListTransforms::~ListTransforms() = default; diff --git a/src/tint/clone_context.h b/src/tint/clone_context.h index 887d628fe8..e8e197f068 100644 --- a/src/tint/clone_context.h +++ b/src/tint/clone_context.h @@ -48,6 +48,13 @@ ProgramID ProgramIDOf(const ProgramBuilder*); /// Cloneable is the base class for all objects that can be cloned class Cloneable : public Castable { public: + /// Constructor + Cloneable(); + /// Move constructor + Cloneable(Cloneable&&); + /// Destructor + ~Cloneable() override; + /// Performs a deep clone of this object using the CloneContext `ctx`. /// @param ctx the clone context /// @return the newly cloned object diff --git a/src/tint/demangler.cc b/src/tint/demangler.cc index 0116be0ad4..d68a62a825 100644 --- a/src/tint/demangler.cc +++ b/src/tint/demangler.cc @@ -49,7 +49,7 @@ std::string Demangler::Demangle(const SymbolTable& symbols, const std::string& s auto len = end_idx - start_idx; auto id = str.substr(start_idx, len); - Symbol sym(std::stoi(id), symbols.ProgramID()); + Symbol sym(static_cast(std::stoi(id)), symbols.ProgramID()); out << symbols.NameFor(sym); pos = end_idx; diff --git a/src/tint/inspector/inspector.cc b/src/tint/inspector/inspector.cc index bef9195d67..c5b3eb797f 100644 --- a/src/tint/inspector/inspector.cc +++ b/src/tint/inspector/inspector.cc @@ -815,8 +815,8 @@ void Inspector::GenerateSamplerTargets() { continue; } - auto* t = c->args[texture_index]; - auto* s = c->args[sampler_index]; + auto* t = c->args[static_cast(texture_index)]; + auto* s = c->args[static_cast(sampler_index)]; GetOriginatingResources( std::array{t, s}, diff --git a/src/tint/inspector/inspector_test.cc b/src/tint/inspector/inspector_test.cc index fb09522ef6..4e369d5e68 100644 --- a/src/tint/inspector/inspector_test.cc +++ b/src/tint/inspector/inspector_test.cc @@ -3048,7 +3048,7 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, StructAlignment) { // here the struct is expected to occupy 1024 bytes of workgroup storage. const auto* wg_struct_type = MakeStructTypeFromMembers( "WgStruct", - {MakeStructMember(0, ty.f32(), {create(1024)})}); + {MakeStructMember(0, ty.f32(), {create(1024u)})}); AddWorkgroupStorage("wg_struct_var", ty.Of(wg_struct_type)); MakeStructVariableReferenceBodyFunction("wg_struct_func", "wg_struct_var", {{0, ty.f32()}}); diff --git a/src/tint/inspector/test_inspector_builder.cc b/src/tint/inspector/test_inspector_builder.cc index f97f474140..23b473ce61 100644 --- a/src/tint/inspector/test_inspector_builder.cc +++ b/src/tint/inspector/test_inspector_builder.cc @@ -285,11 +285,11 @@ const ast::Type* InspectorBuilder::GetCoordsType(ast::TextureDimension dim, return scalar; case ast::TextureDimension::k2d: case ast::TextureDimension::k2dArray: - return create(scalar, 2); + return create(scalar, 2u); case ast::TextureDimension::k3d: case ast::TextureDimension::kCube: case ast::TextureDimension::kCubeArray: - return create(scalar, 3); + return create(scalar, 3u); default: [=]() { FAIL() << "Unsupported texture dimension: " << dim; }(); } diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc index 3b333df808..2bcae95368 100644 --- a/src/tint/reader/spirv/function.cc +++ b/src/tint/reader/spirv/function.cc @@ -1024,11 +1024,13 @@ bool FunctionEmitter::EmitPipelineInput(std::string var_name, [&](const Struct* struct_type) -> bool { const auto& members = struct_type->members; index_prefix.push_back(0); - for (int i = 0; i < static_cast(members.size()); ++i) { - index_prefix.back() = i; + for (size_t i = 0; i < members.size(); ++i) { + index_prefix.back() = static_cast(i); ast::AttributeList member_attrs(*attrs); if (!parser_impl_.ConvertPipelineDecorations( - struct_type, parser_impl_.GetMemberPipelineDecorations(*struct_type, i), + struct_type, + parser_impl_.GetMemberPipelineDecorations(*struct_type, + static_cast(i)), &member_attrs)) { return false; } @@ -1078,7 +1080,7 @@ bool FunctionEmitter::EmitPipelineInput(std::string var_name, store_dest = builder_.MemberAccessor( store_dest, builder_.Expr(parser_impl_.GetMemberName(*struct_type, index))); - current_type = struct_type->members[index]; + current_type = struct_type->members[static_cast(index)]; }); } @@ -1174,8 +1176,9 @@ bool FunctionEmitter::EmitPipelineOutput(std::string var_name, &member_attrs)) { return false; } - if (!EmitPipelineOutput(var_name, var_type, &member_attrs, index_prefix, members[i], - forced_member_type, return_members, return_exprs)) { + if (!EmitPipelineOutput(var_name, var_type, &member_attrs, index_prefix, + members[static_cast(i)], forced_member_type, + return_members, return_exprs)) { return false; } // Copy the location as updated by nested expansion of the member. @@ -1223,7 +1226,7 @@ bool FunctionEmitter::EmitPipelineOutput(std::string var_name, load_source = builder_.MemberAccessor( load_source, builder_.Expr(parser_impl_.GetMemberName(*struct_type, index))); - current_type = struct_type->members[index]; + current_type = struct_type->members[static_cast(index)]; }); } @@ -1825,7 +1828,7 @@ bool FunctionEmitter::LabelControlFlowConstructs() { // The current block is a header. const auto header = block_id; const auto* header_info = block_info; - const auto depth = 1 + top->depth; + const auto depth = static_cast(1 + top->depth); const auto ct = header_info->continue_for_header; if (ct != 0) { // The current block is a loop header. @@ -4310,7 +4313,7 @@ TypedExpression FunctionEmitter::MakeCompositeExtract(const spvtools::opt::Instr // This is structurally similar to creating an access chain, but // the SPIR-V instruction has literal indices instead of IDs for indices. - auto composite_index = 0; + auto composite_index = 0u; auto first_index_position = 1; TypedExpression current_expr(MakeOperand(inst, composite_index)); if (!current_expr) { @@ -4354,13 +4357,14 @@ TypedExpression FunctionEmitter::MakeCompositeValueDecomposition( // hierarchy, maintaining |current_type_id| as the SPIR-V ID of the type of // the object pointed to after processing the previous indices. const auto num_in_operands = inst.NumInOperands(); - for (uint32_t index = index_start; index < num_in_operands; ++index) { + for (uint32_t index = static_cast(index_start); index < num_in_operands; ++index) { const uint32_t index_val = inst.GetSingleWordInOperand(index); const auto* current_type_inst = def_use_mgr_->GetDef(current_type_id); if (!current_type_inst) { Fail() << "composite type %" << current_type_id << " is invalid after following " - << (index - index_start) << " indices: " << inst.PrettyPrint(); + << (index - static_cast(index_start)) + << " indices: " << inst.PrettyPrint(); return {}; } const char* operation_name = nullptr; @@ -4650,7 +4654,7 @@ void FunctionEmitter::FindValuesNeedingNamedOrHoistedDefinition() { // but only if they are defined in this function as well. auto require_named_const_def = [&](const spvtools::opt::Instruction& inst, int in_operand_index) { - const auto id = inst.GetSingleWordInOperand(in_operand_index); + const auto id = inst.GetSingleWordInOperand(static_cast(in_operand_index)); auto* const operand_def = GetDefInfo(id); if (operand_def) { operand_def->requires_named_const_def = true; @@ -4918,7 +4922,7 @@ bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) { bool FunctionEmitter::EmitControlBarrier(const spvtools::opt::Instruction& inst) { uint32_t operands[3]; - for (int i = 0; i < 3; i++) { + for (uint32_t i = 0; i < 3; i++) { auto id = inst.GetSingleWordInOperand(i); if (auto* constant = constant_mgr_->FindDeclaredConstant(id)) { operands[i] = constant->GetU32(); @@ -4936,7 +4940,7 @@ bool FunctionEmitter::EmitControlBarrier(const spvtools::opt::Instruction& inst) << "expected Workgroup (2), got: " << execution; } if (semantics & SpvMemorySemanticsAcquireReleaseMask) { - semantics &= ~SpvMemorySemanticsAcquireReleaseMask; + semantics &= ~static_cast(SpvMemorySemanticsAcquireReleaseMask); } else { return Fail() << "control barrier semantics requires acquire and release"; } @@ -4945,14 +4949,14 @@ bool FunctionEmitter::EmitControlBarrier(const spvtools::opt::Instruction& inst) return Fail() << "workgroupBarrier requires workgroup memory scope"; } AddStatement(create(builder_.Call("workgroupBarrier"))); - semantics &= ~SpvMemorySemanticsWorkgroupMemoryMask; + semantics &= ~static_cast(SpvMemorySemanticsWorkgroupMemoryMask); } if (semantics & SpvMemorySemanticsUniformMemoryMask) { if (memory != SpvScopeDevice) { return Fail() << "storageBarrier requires device memory scope"; } AddStatement(create(builder_.Call("storageBarrier"))); - semantics &= ~SpvMemorySemanticsUniformMemoryMask; + semantics &= ~static_cast(SpvMemorySemanticsUniformMemoryMask); } if (semantics) { return Fail() << "unsupported control barrier semantics: " << semantics; @@ -5600,7 +5604,7 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess( } ast::TextureDimension dim = texture_type->dims; // Number of regular coordinates. - uint32_t num_axes = ast::NumCoordinateAxes(dim); + uint32_t num_axes = static_cast(ast::NumCoordinateAxes(dim)); bool is_arrayed = ast::IsTextureArray(dim); if ((num_axes == 0) || (num_axes > 3)) { Fail() << "unsupported image dimensionality for " << texture_type->TypeInfo().name diff --git a/src/tint/reader/spirv/parser_impl.cc b/src/tint/reader/spirv/parser_impl.cc index 1ebf0b9770..b34f66b671 100644 --- a/src/tint/reader/spirv/parser_impl.cc +++ b/src/tint/reader/spirv/parser_impl.cc @@ -816,7 +816,7 @@ bool ParserImpl::RegisterWorkgroupSizeBuiltin() { /// Returns false and emits a diagnostic on error. auto set_param = [this, composite_def](uint32_t* id_ptr, uint32_t* value_ptr, int index) -> bool { - const auto id = composite_def->GetSingleWordInOperand(index); + const auto id = composite_def->GetSingleWordInOperand(static_cast(index)); const auto* def = def_use_mgr_->GetDef(id); if (!def || (def->opcode() != SpvOpSpecConstant && def->opcode() != SpvOpConstant) || (def->NumInOperands() != 1)) { @@ -1336,7 +1336,7 @@ bool ParserImpl::EmitScalarSpecConstants() { }, [&](const U32*) { return create( - Source{}, static_cast(literal_value), + Source{}, static_cast(literal_value), ast::IntLiteralExpression::Suffix::kU); }, [&](const F32*) { @@ -1715,8 +1715,8 @@ DecorationList ParserImpl::GetMemberPipelineDecorations(const Struct& struct_typ int member_index) { // Yes, I could have used std::copy_if or std::copy_if. DecorationList result; - for (const auto& deco : - GetDecorationsForMember(struct_id_for_symbol_[struct_type.name], member_index)) { + for (const auto& deco : GetDecorationsForMember(struct_id_for_symbol_[struct_type.name], + static_cast(member_index))) { if (IsPipelineDecoration(deco)) { result.emplace_back(deco); } @@ -2721,7 +2721,7 @@ std::string ParserImpl::GetMemberName(const Struct& struct_type, int member_inde Fail() << "no structure type registered for symbol"; return ""; } - return namer_.GetMemberName(where->second, member_index); + return namer_.GetMemberName(where->second, static_cast(member_index)); } WorkgroupSizeInfo::WorkgroupSizeInfo() = default; diff --git a/src/tint/reader/spirv/parser_impl.h b/src/tint/reader/spirv/parser_impl.h index 6addf6c412..ce790d3c75 100644 --- a/src/tint/reader/spirv/parser_impl.h +++ b/src/tint/reader/spirv/parser_impl.h @@ -22,8 +22,18 @@ #include #include +#include "src/tint/utils/compiler_macros.h" + #if TINT_BUILD_SPV_READER +TINT_BEGIN_DISABLE_WARNING(NEWLINE_EOF); +TINT_BEGIN_DISABLE_WARNING(OLD_STYLE_CAST); +TINT_BEGIN_DISABLE_WARNING(SIGN_CONVERSION); +TINT_BEGIN_DISABLE_WARNING(WEAK_VTABLES); #include "source/opt/ir_context.h" +TINT_END_DISABLE_WARNING(WEAK_VTABLES); +TINT_END_DISABLE_WARNING(SIGN_CONVERSION); +TINT_END_DISABLE_WARNING(OLD_STYLE_CAST); +TINT_END_DISABLE_WARNING(NEWLINE_EOF); #endif #include "src/tint/program_builder.h" diff --git a/src/tint/reader/spirv/parser_impl_test_helper.h b/src/tint/reader/spirv/parser_impl_test_helper.h index 7362a2d75e..f2c2dfeeb9 100644 --- a/src/tint/reader/spirv/parser_impl_test_helper.h +++ b/src/tint/reader/spirv/parser_impl_test_helper.h @@ -21,8 +21,18 @@ #include #include +#include "src/tint/utils/compiler_macros.h" + #if TINT_BUILD_SPV_READER +TINT_BEGIN_DISABLE_WARNING(NEWLINE_EOF); +TINT_BEGIN_DISABLE_WARNING(OLD_STYLE_CAST); +TINT_BEGIN_DISABLE_WARNING(SIGN_CONVERSION); +TINT_BEGIN_DISABLE_WARNING(WEAK_VTABLES); #include "source/opt/ir_context.h" +TINT_END_DISABLE_WARNING(WEAK_VTABLES); +TINT_END_DISABLE_WARNING(SIGN_CONVERSION); +TINT_END_DISABLE_WARNING(OLD_STYLE_CAST); +TINT_END_DISABLE_WARNING(NEWLINE_EOF); #endif #include "gtest/gtest.h" diff --git a/src/tint/reader/spirv/parser_type.cc b/src/tint/reader/spirv/parser_type.cc index 3332cd4f74..db8c01b5c1 100644 --- a/src/tint/reader/spirv/parser_type.cc +++ b/src/tint/reader/spirv/parser_type.cc @@ -163,6 +163,12 @@ const ast::Type* I32::Build(ProgramBuilder& b) const { return b.ty.i32(); } +Type::Type() = default; +Type::Type(const Type&) = default; +Type::~Type() = default; + +Texture::~Texture() = default; + Pointer::Pointer(const Type* t, ast::StorageClass s) : type(t), storage_class(s) {} Pointer::Pointer(const Pointer&) = default; diff --git a/src/tint/reader/spirv/parser_type.h b/src/tint/reader/spirv/parser_type.h index 605ac9b0b6..9543b51cc4 100644 --- a/src/tint/reader/spirv/parser_type.h +++ b/src/tint/reader/spirv/parser_type.h @@ -40,6 +40,13 @@ namespace tint::reader::spirv { /// Type is the base class for all types class Type : public Castable { public: + /// Constructor + Type(); + /// Copy constructor + Type(const Type&); + /// Destructor + ~Type() override; + /// @param b the ProgramBuilder used to construct the AST types /// @returns the constructed ast::Type node for the given type virtual const ast::Type* Build(ProgramBuilder& b) const = 0; @@ -314,6 +321,8 @@ struct Sampler final : public Castable { /// Base class for texture types struct Texture : public Castable { + ~Texture() override; + /// Constructor /// @param d the texture dimensions explicit Texture(ast::TextureDimension d); diff --git a/src/tint/reader/spirv/usage_test.cc b/src/tint/reader/spirv/usage_test.cc index d01d1a264e..bb64bb35e7 100644 --- a/src/tint/reader/spirv/usage_test.cc +++ b/src/tint/reader/spirv/usage_test.cc @@ -45,7 +45,7 @@ TEST_F(SpvParserTest, Usage_Trivial_Output) { } TEST_F(SpvParserTest, Usage_Equality_OneDifference) { - const int num_usages = 9; + const size_t num_usages = 9u; std::vector usages(num_usages); usages[1].AddSampler(); usages[2].AddComparisonSampler(); @@ -55,8 +55,8 @@ TEST_F(SpvParserTest, Usage_Equality_OneDifference) { usages[6].AddDepthTexture(); usages[7].AddStorageReadTexture(); usages[8].AddStorageWriteTexture(); - for (int i = 0; i < num_usages; ++i) { - for (int j = 0; j < num_usages; ++j) { + for (size_t i = 0; i < num_usages; ++i) { + for (size_t j = 0; j < num_usages; ++j) { const auto& lhs = usages[i]; const auto& rhs = usages[j]; if (i == j) { diff --git a/src/tint/reader/wgsl/lexer.cc b/src/tint/reader/wgsl/lexer.cc index a3eaa6d1e3..ade723cb09 100644 --- a/src/tint/reader/wgsl/lexer.cc +++ b/src/tint/reader/wgsl/lexer.cc @@ -412,7 +412,7 @@ Token Lexer::try_hex_float() { // clang-format on // -? - int64_t sign_bit = 0; + uint64_t sign_bit = 0; if (matches(end, "-")) { sign_bit = 1; end++; @@ -794,7 +794,7 @@ Token Lexer::build_token_from_int_if_possible(Source source, size_t start, int32 const bool overflow = errno == ERANGE; if (end_ptr) { - advance(end_ptr - start_ptr); + advance(static_cast(end_ptr - start_ptr)); } if (matches(pos(), "u")) { diff --git a/src/tint/resolver/assignment_validation_test.cc b/src/tint/resolver/assignment_validation_test.cc index 1ae9895eff..e204a62bb8 100644 --- a/src/tint/resolver/assignment_validation_test.cc +++ b/src/tint/resolver/assignment_validation_test.cc @@ -32,8 +32,8 @@ TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) { auto* s = Structure("S", {Member("m", ty.i32())}); GlobalVar(Source{{12, 34}}, "a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i)); @@ -237,13 +237,13 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) { GlobalVar("a", make_type(), ast::StorageClass::kNone, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GlobalVar("b", make_type(), ast::StorageClass::kNone, ast::AttributeList{ - create(1), - create(0), + create(1u), + create(0u), }); WrapInFunction(Assign(Source{{56, 78}}, "a", "b")); @@ -260,8 +260,8 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) { auto* s = Structure("S", {Member("a", ty.atomic(ty.i32()))}); GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); @@ -278,8 +278,8 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) { auto* s = Structure("S", {Member("a", ty.array(ty.f32()))}); GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); diff --git a/src/tint/resolver/atomics_test.cc b/src/tint/resolver/atomics_test.cc index 0e86599eb3..09ca0bacbe 100644 --- a/src/tint/resolver/atomics_test.cc +++ b/src/tint/resolver/atomics_test.cc @@ -48,8 +48,8 @@ TEST_F(ResolverAtomicTest, GlobalStorageStruct) { auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}); auto* g = GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); EXPECT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/attribute_validation_test.cc b/src/tint/resolver/attribute_validation_test.cc index c46271791b..5f69277f9a 100644 --- a/src/tint/resolver/attribute_validation_test.cc +++ b/src/tint/resolver/attribute_validation_test.cc @@ -508,8 +508,8 @@ TEST_F(EntryPointParameterAttributeTest, DuplicateAttribute) { TEST_F(EntryPointParameterAttributeTest, DuplicateInternalAttribute) { auto* s = Param("s", ty.sampler(ast::SamplerKind::kSampler), ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), Disable(ast::DisabledValidation::kBindingPointCollision), Disable(ast::DisabledValidation::kEntryPointParameter), }); @@ -745,9 +745,9 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest, TEST_F(VariableAttributeTest, DuplicateAttribute) { GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), ast::AttributeList{ - create(Source{{12, 34}}, 2), - create(2), - create(Source{{56, 78}}, 3), + create(Source{{12, 34}}, 2u), + create(2u), + create(Source{{56, 78}}, 3u), }); WrapInFunction(); @@ -761,7 +761,7 @@ TEST_F(VariableAttributeTest, DuplicateAttribute) { TEST_F(VariableAttributeTest, LocalVariable) { auto* v = Var("a", ty.f32(), ast::AttributeList{ - create(Source{{12, 34}}, 2), + create(Source{{12, 34}}, 2u), }); WrapInFunction(v); @@ -807,8 +807,8 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest, TEST_F(ConstantAttributeTest, DuplicateAttribute) { GlobalConst("a", ty.f32(), Expr(1.23_f), ast::AttributeList{ - create(Source{{12, 34}}, 0), - create(Source{{56, 78}}, 1), + create(Source{{12, 34}}, 0u), + create(Source{{56, 78}}, 1u), }); WrapInFunction(); @@ -854,8 +854,8 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest, TEST_F(OverrideAttributeTest, DuplicateAttribute) { Override("a", ty.f32(), Expr(1.23_f), ast::AttributeList{ - create(Source{{12, 34}}, 0), - create(Source{{56, 78}}, 1), + create(Source{{12, 34}}, 0u), + create(Source{{56, 78}}, 1u), }); WrapInFunction(); @@ -976,8 +976,8 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest, TEST_F(ArrayStrideTest, DuplicateAttribute) { auto* arr = ty.array(Source{{12, 34}}, ty.i32(), 4_u, { - create(Source{{12, 34}}, 4_i), - create(Source{{56, 78}}, 4_i), + create(Source{{12, 34}}, 4u), + create(Source{{56, 78}}, 4u), }); GlobalVar("myarray", arr, ast::StorageClass::kPrivate); @@ -1035,7 +1035,7 @@ TEST_F(ResourceAttributeTest, BindingPairMissingBinding) { GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, ast::AttributeList{ - create(1), + create(1u), }); EXPECT_FALSE(r()->Resolve()); @@ -1047,7 +1047,7 @@ TEST_F(ResourceAttributeTest, BindingPairMissingGroup) { GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, ast::AttributeList{ - create(1), + create(1u), }); EXPECT_FALSE(r()->Resolve()); @@ -1059,14 +1059,14 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) { GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), ast::StorageClass::kNone, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), ast::StorageClass::kNone, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("F", {}, ty.void_(), @@ -1091,14 +1091,14 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) { GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), ast::StorageClass::kNone, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), ast::StorageClass::kNone, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("F_A", {}, ty.void_(), @@ -1124,8 +1124,8 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) { TEST_F(ResourceAttributeTest, BindingPointOnNonResource) { GlobalVar(Source{{12, 34}}, "G", ty.f32(), ast::StorageClass::kPrivate, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index 5bb6810a99..38f562010d 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -187,8 +187,8 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParamIsAnyOf()) { GlobalVar(name, type, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); } else { @@ -618,8 +618,8 @@ TEST_F(ResolverBuiltinDataTest, ArrayLength_Vector) { auto* str = Structure("S", {Member("x", ary)}); GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x"))); diff --git a/src/tint/resolver/builtin_validation_test.cc b/src/tint/resolver/builtin_validation_test.cc index 72c5596cfc..3737ae01a8 100644 --- a/src/tint/resolver/builtin_validation_test.cc +++ b/src/tint/resolver/builtin_validation_test.cc @@ -257,11 +257,11 @@ TEST_P(BuiltinTextureConstExprArgValidationTest, Immediate) { err << "12:34 error: each component of the " << param.name << " argument must be at least " << param.min << " and at most " << param.max << ". " << param.name << " component " << expr.invalid_index << " is " - << std::to_string(expr.values[expr.invalid_index]); + << std::to_string(expr.values[static_cast(expr.invalid_index)]); } else { err << "12:34 error: the " << param.name << " argument must be at least " << param.min << " and at most " << param.max << ". " << param.name << " is " - << std::to_string(expr.values[expr.invalid_index]); + << std::to_string(expr.values[static_cast(expr.invalid_index)]); } EXPECT_EQ(r()->error(), err.str()); } diff --git a/src/tint/resolver/function_validation_test.cc b/src/tint/resolver/function_validation_test.cc index 39d05d9340..e11384e605 100644 --- a/src/tint/resolver/function_validation_test.cc +++ b/src/tint/resolver/function_validation_test.cc @@ -754,7 +754,7 @@ TEST_F(ResolverFunctionValidationTest, ParametersOverLimit) { TEST_F(ResolverFunctionValidationTest, ParameterVectorNoType) { // fn f(p : vec3) {} - Func(Source{{12, 34}}, "f", {Param("p", create(Source{{12, 34}}, nullptr, 3))}, + Func(Source{{12, 34}}, "f", {Param("p", create(Source{{12, 34}}, nullptr, 3u))}, ty.void_(), {}); EXPECT_FALSE(r()->Resolve()); @@ -764,8 +764,8 @@ TEST_F(ResolverFunctionValidationTest, ParameterVectorNoType) { TEST_F(ResolverFunctionValidationTest, ParameterMatrixNoType) { // fn f(p : vec3) {} - Func(Source{{12, 34}}, "f", {Param("p", create(Source{{12, 34}}, nullptr, 3, 3))}, - ty.void_(), {}); + Func(Source{{12, 34}}, "f", + {Param("p", create(Source{{12, 34}}, nullptr, 3u, 3u))}, ty.void_(), {}); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type"); diff --git a/src/tint/resolver/host_shareable_validation_test.cc b/src/tint/resolver/host_shareable_validation_test.cc index 13a04c9acb..d50057c3c7 100644 --- a/src/tint/resolver/host_shareable_validation_test.cc +++ b/src/tint/resolver/host_shareable_validation_test.cc @@ -28,8 +28,8 @@ TEST_F(ResolverHostShareableValidationTest, BoolMember) { GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -46,8 +46,8 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) { GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -65,8 +65,8 @@ TEST_F(ResolverHostShareableValidationTest, Aliases) { auto* a2 = Alias("a2", ty.Of(s)); GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -87,8 +87,8 @@ TEST_F(ResolverHostShareableValidationTest, NestedStructures) { GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -129,8 +129,8 @@ TEST_F(ResolverHostShareableValidationTest, NoError) { GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); WrapInFunction(); diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc index 2005a42ac1..d746a6c2fb 100644 --- a/src/tint/resolver/intrinsic_table.cc +++ b/src/tint/resolver/intrinsic_table.cc @@ -1300,8 +1300,8 @@ const sem::CallTarget* Impl::Lookup(CtorConvIntrinsic type, // Conversion. return utils::GetOrCreate(converters, match, [&]() { auto param = builder.create( - nullptr, 0, match.parameters[0].type, ast::StorageClass::kNone, ast::Access::kUndefined, - match.parameters[0].usage); + nullptr, 0u, match.parameters[0].type, ast::StorageClass::kNone, + ast::Access::kUndefined, match.parameters[0].usage); return builder.create(match.return_type, param); }); } diff --git a/src/tint/resolver/ptr_ref_test.cc b/src/tint/resolver/ptr_ref_test.cc index c02ab5dda3..037c6ff194 100644 --- a/src/tint/resolver/ptr_ref_test.cc +++ b/src/tint/resolver/ptr_ref_test.cc @@ -63,13 +63,13 @@ TEST_F(ResolverPtrRefTest, DefaultPtrStorageClass) { auto* workgroup = GlobalVar("w", ty.i32(), ast::StorageClass::kWorkgroup); auto* uniform = GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, ast::AttributeList{ - create(1), - create(0), + create(1u), + create(0u), }); auto* function_ptr = diff --git a/src/tint/resolver/ptr_ref_validation_test.cc b/src/tint/resolver/ptr_ref_validation_test.cc index d2f8d01e20..768783bbf2 100644 --- a/src/tint/resolver/ptr_ref_validation_test.cc +++ b/src/tint/resolver/ptr_ref_validation_test.cc @@ -145,8 +145,8 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) { auto* buf = Structure("S", {Member("inner", ty.Of(inner))}); auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i); diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 6794921b83..e6cad77247 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -857,7 +857,7 @@ sem::Function* Resolver::Function(const ast::Function* decl) { bool Resolver::WorkgroupSize(const ast::Function* func) { // Set work-group size defaults. sem::WorkgroupSize ws; - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { ws[i].value = 1; ws[i].overridable_const = nullptr; } @@ -876,7 +876,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) { "workgroup_size argument must be either a literal, constant, or overridable of type " "abstract-integer, i32 or u32"; - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { // Each argument to this attribute can either be a literal, an identifier for a module-scope // constants, or nullptr if not specified. auto* value = values[i]; @@ -1731,12 +1731,13 @@ void Resolver::CollectTextureSamplerPairs(const sem::Builtin* builtin, if (texture_index == -1) { TINT_ICE(Resolver, diagnostics_) << "texture builtin without texture parameter"; } - auto* texture = args[texture_index]->As()->Variable(); + auto* texture = args[static_cast(texture_index)]->As()->Variable(); if (!texture->Type()->UnwrapRef()->Is()) { int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler); const sem::Variable* sampler = - sampler_index != -1 ? args[sampler_index]->As()->Variable() - : nullptr; + sampler_index != -1 + ? args[static_cast(sampler_index)]->As()->Variable() + : nullptr; current_function_->AddTextureSamplerPair(texture, sampler); } } @@ -2247,7 +2248,7 @@ sem::Array* Resolver::Array(const ast::Array* arr) { } } - auto size = std::max(count, 1u) * stride; + auto size = std::max(static_cast(count), 1u) * stride; if (size > std::numeric_limits::max()) { std::stringstream msg; msg << "array size (0x" << std::hex << size << ") must not exceed 0xffffffff bytes"; diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc index 2f0992ce78..9b56c31b20 100644 --- a/src/tint/resolver/resolver_test.cc +++ b/src/tint/resolver/resolver_test.cc @@ -779,8 +779,8 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables) { auto* sb_var = GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* wg_var = GlobalVar("wg_var", ty.f32(), ast::StorageClass::kWorkgroup); auto* priv_var = GlobalVar("priv_var", ty.f32(), ast::StorageClass::kPrivate); @@ -812,8 +812,8 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) { auto* sb_var = GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* wg_var = GlobalVar("wg_var", ty.f32(), ast::StorageClass::kWorkgroup); auto* priv_var = GlobalVar("priv_var", ty.f32(), ast::StorageClass::kPrivate); @@ -1737,8 +1737,8 @@ TEST_F(ResolverTest, StorageClass_SetForSampler) { auto* t = ty.sampler(ast::SamplerKind::kSampler); auto* var = GlobalVar("var", t, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1750,8 +1750,8 @@ TEST_F(ResolverTest, StorageClass_SetForTexture) { auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); auto* var = GlobalVar("var", t, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1775,8 +1775,8 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) { auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}); auto* var = GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1789,10 +1789,10 @@ TEST_F(ResolverTest, BindingPoint_SetForResources) { // @group(3) @binding(4) var s2 : sampler; auto* s1 = GlobalVar( Sym(), ty.sampler(ast::SamplerKind::kSampler), - ast::AttributeList{create(1), create(2)}); + ast::AttributeList{create(1u), create(2u)}); auto* s2 = GlobalVar( Sym(), ty.sampler(ast::SamplerKind::kSampler), - ast::AttributeList{create(3), create(4)}); + ast::AttributeList{create(3u), create(4u)}); EXPECT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/storage_class_validation_test.cc b/src/tint/resolver/storage_class_validation_test.cc index 1f5f0245c7..0e2be29d18 100644 --- a/src/tint/resolver/storage_class_validation_test.cc +++ b/src/tint/resolver/storage_class_validation_test.cc @@ -87,8 +87,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBool) { // var g : bool; GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kStorage, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -104,8 +104,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferPointer) { GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate), ast::StorageClass::kStorage, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -120,8 +120,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferIntScalar) { // var g : i32; GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kStorage, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -131,8 +131,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferVector) { // var g : vec4; GlobalVar(Source{{56, 78}}, "g", ty.vec4(), ast::StorageClass::kStorage, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -144,8 +144,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferArray) { auto* a = ty.array(ty.Of(s), 3_u); GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -157,8 +157,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBoolAlias) { auto* a = Alias("a", ty.bool_()); GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kStorage, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -186,8 +186,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Basic) { auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}); GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_TRUE(r()->Resolve()); @@ -202,8 +202,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Aliases) { auto* a2 = Alias("a2", ty.Of(a1)); GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_TRUE(r()->Resolve()); @@ -217,8 +217,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBuffer_Struct_Runtime) { GlobalVar(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -232,8 +232,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferBool) { // var g : bool; GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -249,8 +249,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferPointer) { GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -265,8 +265,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferIntScalar) { // var g : i32; GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -276,8 +276,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferVector) { // var g : vec4; GlobalVar(Source{{56, 78}}, "g", ty.vec4(), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -292,8 +292,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferArray) { auto* a = ty.array(ty.Of(s), 3_u); GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -305,8 +305,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferBoolAlias) { auto* a = Alias("a", ty.bool_()); GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_FALSE(r()->Resolve()); @@ -323,8 +323,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Basic) { auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}); GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -338,8 +338,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Aliases) { auto* a1 = Alias("a1", ty.Of(s)); GlobalVar(Source{{56, 78}}, "g", ty.Of(a1), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/struct_storage_class_use_test.cc b/src/tint/resolver/struct_storage_class_use_test.cc index c524f71236..5a929a5c09 100644 --- a/src/tint/resolver/struct_storage_class_use_test.cc +++ b/src/tint/resolver/struct_storage_class_use_test.cc @@ -161,13 +161,13 @@ TEST_F(ResolverStorageClassUseTest, StructMultipleStorageClassUses) { auto* s = Structure("S", {Member("a", ty.f32())}); GlobalVar("x", ty.Of(s), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GlobalVar("y", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(0), + create(1u), + create(0u), }); WrapInFunction(Var("g", ty.Of(s))); diff --git a/src/tint/resolver/type_constructor_validation_test.cc b/src/tint/resolver/type_constructor_validation_test.cc index 5b0023d5dc..1c857cdc1e 100644 --- a/src/tint/resolver/type_constructor_validation_test.cc +++ b/src/tint/resolver/type_constructor_validation_test.cc @@ -1856,11 +1856,11 @@ TEST_F(ResolverTypeConstructorValidationTest, TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromScalars) { Enable(ast::Extension::kF16); - auto* vec2_bool = Construct(create(nullptr, 2), Expr(true), Expr(false)); - auto* vec2_i32 = Construct(create(nullptr, 2), Expr(1_i), Expr(2_i)); - auto* vec2_u32 = Construct(create(nullptr, 2), Expr(1_u), Expr(2_u)); - auto* vec2_f32 = Construct(create(nullptr, 2), Expr(1_f), Expr(2_f)); - auto* vec2_f16 = Construct(create(nullptr, 2), Expr(1_h), Expr(2_h)); + auto* vec2_bool = Construct(create(nullptr, 2u), Expr(true), Expr(false)); + auto* vec2_i32 = Construct(create(nullptr, 2u), Expr(1_i), Expr(2_i)); + auto* vec2_u32 = Construct(create(nullptr, 2u), Expr(1_u), Expr(2_u)); + auto* vec2_f32 = Construct(create(nullptr, 2u), Expr(1_f), Expr(2_f)); + auto* vec2_f16 = Construct(create(nullptr, 2u), Expr(1_h), Expr(2_h)); WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32, vec2_f16); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -1890,11 +1890,11 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromScalars) { TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromVec2) { Enable(ast::Extension::kF16); - auto* vec2_bool = Construct(create(nullptr, 2), vec2(true, false)); - auto* vec2_i32 = Construct(create(nullptr, 2), vec2(1_i, 2_i)); - auto* vec2_u32 = Construct(create(nullptr, 2), vec2(1_u, 2_u)); - auto* vec2_f32 = Construct(create(nullptr, 2), vec2(1_f, 2_f)); - auto* vec2_f16 = Construct(create(nullptr, 2), vec2(1_h, 2_h)); + auto* vec2_bool = Construct(create(nullptr, 2u), vec2(true, false)); + auto* vec2_i32 = Construct(create(nullptr, 2u), vec2(1_i, 2_i)); + auto* vec2_u32 = Construct(create(nullptr, 2u), vec2(1_u, 2_u)); + auto* vec2_f32 = Construct(create(nullptr, 2u), vec2(1_f, 2_f)); + auto* vec2_f16 = Construct(create(nullptr, 2u), vec2(1_h, 2_h)); WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32, vec2_f16); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -1925,11 +1925,11 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalars) { Enable(ast::Extension::kF16); auto* vec3_bool = - Construct(create(nullptr, 3), Expr(true), Expr(false), Expr(true)); - auto* vec3_i32 = Construct(create(nullptr, 3), Expr(1_i), Expr(2_i), Expr(3_i)); - auto* vec3_u32 = Construct(create(nullptr, 3), Expr(1_u), Expr(2_u), Expr(3_u)); - auto* vec3_f32 = Construct(create(nullptr, 3), Expr(1_f), Expr(2_f), Expr(3_f)); - auto* vec3_f16 = Construct(create(nullptr, 3), Expr(1_h), Expr(2_h), Expr(3_h)); + Construct(create(nullptr, 3u), Expr(true), Expr(false), Expr(true)); + auto* vec3_i32 = Construct(create(nullptr, 3u), Expr(1_i), Expr(2_i), Expr(3_i)); + auto* vec3_u32 = Construct(create(nullptr, 3u), Expr(1_u), Expr(2_u), Expr(3_u)); + auto* vec3_f32 = Construct(create(nullptr, 3u), Expr(1_f), Expr(2_f), Expr(3_f)); + auto* vec3_f16 = Construct(create(nullptr, 3u), Expr(1_h), Expr(2_h), Expr(3_h)); WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32, vec3_f16); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -1959,11 +1959,11 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalars) { TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromVec3) { Enable(ast::Extension::kF16); - auto* vec3_bool = Construct(create(nullptr, 3), vec3(true, false, true)); - auto* vec3_i32 = Construct(create(nullptr, 3), vec3(1_i, 2_i, 3_i)); - auto* vec3_u32 = Construct(create(nullptr, 3), vec3(1_u, 2_u, 3_u)); - auto* vec3_f32 = Construct(create(nullptr, 3), vec3(1_f, 2_f, 3_f)); - auto* vec3_f16 = Construct(create(nullptr, 3), vec3(1_h, 2_h, 3_h)); + auto* vec3_bool = Construct(create(nullptr, 3u), vec3(true, false, true)); + auto* vec3_i32 = Construct(create(nullptr, 3u), vec3(1_i, 2_i, 3_i)); + auto* vec3_u32 = Construct(create(nullptr, 3u), vec3(1_u, 2_u, 3_u)); + auto* vec3_f32 = Construct(create(nullptr, 3u), vec3(1_f, 2_f, 3_f)); + auto* vec3_f16 = Construct(create(nullptr, 3u), vec3(1_h, 2_h, 3_h)); WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32, vec3_f16); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -1994,11 +1994,11 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalarAndV Enable(ast::Extension::kF16); auto* vec3_bool = - Construct(create(nullptr, 3), Expr(true), vec2(false, true)); - auto* vec3_i32 = Construct(create(nullptr, 3), Expr(1_i), vec2(2_i, 3_i)); - auto* vec3_u32 = Construct(create(nullptr, 3), Expr(1_u), vec2(2_u, 3_u)); - auto* vec3_f32 = Construct(create(nullptr, 3), Expr(1_f), vec2(2_f, 3_f)); - auto* vec3_f16 = Construct(create(nullptr, 3), Expr(1_h), vec2(2_h, 3_h)); + Construct(create(nullptr, 3u), Expr(true), vec2(false, true)); + auto* vec3_i32 = Construct(create(nullptr, 3u), Expr(1_i), vec2(2_i, 3_i)); + auto* vec3_u32 = Construct(create(nullptr, 3u), Expr(1_u), vec2(2_u, 3_u)); + auto* vec3_f32 = Construct(create(nullptr, 3u), Expr(1_f), vec2(2_f, 3_f)); + auto* vec3_f16 = Construct(create(nullptr, 3u), Expr(1_h), vec2(2_h, 3_h)); WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32, vec3_f16); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -2028,16 +2028,16 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalarAndV TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalars) { Enable(ast::Extension::kF16); - auto* vec4_bool = Construct(create(nullptr, 4), Expr(true), Expr(false), + auto* vec4_bool = Construct(create(nullptr, 4u), Expr(true), Expr(false), Expr(true), Expr(false)); auto* vec4_i32 = - Construct(create(nullptr, 4), Expr(1_i), Expr(2_i), Expr(3_i), Expr(4_i)); + Construct(create(nullptr, 4u), Expr(1_i), Expr(2_i), Expr(3_i), Expr(4_i)); auto* vec4_u32 = - Construct(create(nullptr, 4), Expr(1_u), Expr(2_u), Expr(3_u), Expr(4_u)); + Construct(create(nullptr, 4u), Expr(1_u), Expr(2_u), Expr(3_u), Expr(4_u)); auto* vec4_f32 = - Construct(create(nullptr, 4), Expr(1_f), Expr(2_f), Expr(3_f), Expr(4_f)); + Construct(create(nullptr, 4u), Expr(1_f), Expr(2_f), Expr(3_f), Expr(4_f)); auto* vec4_f16 = - Construct(create(nullptr, 4), Expr(1_h), Expr(2_h), Expr(3_h), Expr(4_h)); + Construct(create(nullptr, 4u), Expr(1_h), Expr(2_h), Expr(3_h), Expr(4_h)); WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32, vec4_f16); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -2068,11 +2068,11 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec4) { Enable(ast::Extension::kF16); auto* vec4_bool = - Construct(create(nullptr, 4), vec4(true, false, true, false)); - auto* vec4_i32 = Construct(create(nullptr, 4), vec4(1_i, 2_i, 3_i, 4_i)); - auto* vec4_u32 = Construct(create(nullptr, 4), vec4(1_u, 2_u, 3_u, 4_u)); - auto* vec4_f32 = Construct(create(nullptr, 4), vec4(1_f, 2_f, 3_f, 4_f)); - auto* vec4_f16 = Construct(create(nullptr, 4), vec4(1_h, 2_h, 3_h, 4_h)); + Construct(create(nullptr, 4u), vec4(true, false, true, false)); + auto* vec4_i32 = Construct(create(nullptr, 4u), vec4(1_i, 2_i, 3_i, 4_i)); + auto* vec4_u32 = Construct(create(nullptr, 4u), vec4(1_u, 2_u, 3_u, 4_u)); + auto* vec4_f32 = Construct(create(nullptr, 4u), vec4(1_f, 2_f, 3_f, 4_f)); + auto* vec4_f16 = Construct(create(nullptr, 4u), vec4(1_h, 2_h, 3_h, 4_h)); WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32, vec4_f16); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -2103,15 +2103,15 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalarAndV Enable(ast::Extension::kF16); auto* vec4_bool = - Construct(create(nullptr, 4), Expr(true), vec3(false, true, false)); + Construct(create(nullptr, 4u), Expr(true), vec3(false, true, false)); auto* vec4_i32 = - Construct(create(nullptr, 4), Expr(1_i), vec3(2_i, 3_i, 4_i)); + Construct(create(nullptr, 4u), Expr(1_i), vec3(2_i, 3_i, 4_i)); auto* vec4_u32 = - Construct(create(nullptr, 4), Expr(1_u), vec3(2_u, 3_u, 4_u)); + Construct(create(nullptr, 4u), Expr(1_u), vec3(2_u, 3_u, 4_u)); auto* vec4_f32 = - Construct(create(nullptr, 4), Expr(1_f), vec3(2_f, 3_f, 4_f)); + Construct(create(nullptr, 4u), Expr(1_f), vec3(2_f, 3_f, 4_f)); auto* vec4_f16 = - Construct(create(nullptr, 4), Expr(1_h), vec3(2_h, 3_h, 4_h)); + Construct(create(nullptr, 4u), Expr(1_h), vec3(2_h, 3_h, 4_h)); WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32, vec4_f16); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -2141,16 +2141,16 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalarAndV TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec2AndVec2) { Enable(ast::Extension::kF16); - auto* vec4_bool = Construct(create(nullptr, 4), vec2(true, false), + auto* vec4_bool = Construct(create(nullptr, 4u), vec2(true, false), vec2(true, false)); auto* vec4_i32 = - Construct(create(nullptr, 4), vec2(1_i, 2_i), vec2(3_i, 4_i)); + Construct(create(nullptr, 4u), vec2(1_i, 2_i), vec2(3_i, 4_i)); auto* vec4_u32 = - Construct(create(nullptr, 4), vec2(1_u, 2_u), vec2(3_u, 4_u)); + Construct(create(nullptr, 4u), vec2(1_u, 2_u), vec2(3_u, 4_u)); auto* vec4_f32 = - Construct(create(nullptr, 4), vec2(1_f, 2_f), vec2(3_f, 4_f)); + Construct(create(nullptr, 4u), vec2(1_f, 2_f), vec2(3_f, 4_f)); auto* vec4_f16 = - Construct(create(nullptr, 4), vec2(1_h, 2_h), vec2(3_h, 4_h)); + Construct(create(nullptr, 4u), vec2(1_h, 2_h), vec2(3_h, 4_h)); WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32, vec4_f16); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -2178,14 +2178,14 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec2AndVec } TEST_F(ResolverTypeConstructorValidationTest, CannotInferVectorElementTypeWithoutArgs) { - WrapInFunction(Construct(Source{{12, 34}}, create(nullptr, 3))); + WrapInFunction(Construct(Source{{12, 34}}, create(nullptr, 3u))); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for vec3()")); } TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec2ElementTypeFromScalarsMismatch) { - WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 2), + WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 2u), Expr(Source{{1, 2}}, 1_i), // Expr(Source{{1, 3}}, 2_u))); @@ -2194,7 +2194,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec2ElementTypeFromScal } TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScalarsMismatch) { - WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 3), + WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 3u), Expr(Source{{1, 2}}, 1_i), // Expr(Source{{1, 3}}, 2_u), // Expr(Source{{1, 4}}, 3_i))); @@ -2205,7 +2205,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScal } TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScalarAndVec2Mismatch) { - WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 3), + WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 3u), Expr(Source{{1, 2}}, 1_i), // Construct(Source{{1, 3}}, ty.vec2(), 2_f, 3_f))); @@ -2215,7 +2215,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScal } TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScalarsMismatch) { - WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 4), + WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 4u), Expr(Source{{1, 2}}, 1_i), // Expr(Source{{1, 3}}, 2_i), // Expr(Source{{1, 4}}, 3_f), // @@ -2227,7 +2227,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScal } TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScalarAndVec3Mismatch) { - WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 4), + WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 4u), Expr(Source{{1, 2}}, 1_i), // Construct(Source{{1, 3}}, ty.vec3(), 2_u, 3_u, 4_u))); @@ -2237,7 +2237,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScal } TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromVec2AndVec2Mismatch) { - WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 4), + WrapInFunction(Construct(Source{{1, 1}}, create(nullptr, 4u), Construct(Source{{1, 2}}, ty.vec2(), 3_i, 4_i), // Construct(Source{{1, 3}}, ty.vec2(), 3_u, 4_u))); diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc index 602cb6e3e5..e746e5160e 100644 --- a/src/tint/resolver/type_validation_test.cc +++ b/src/tint/resolver/type_validation_test.cc @@ -402,7 +402,7 @@ TEST_F(ResolverTypeValidationTest, Struct_Member_VectorNoType) { // a: vec3; // }; - Structure("S", {Member("a", create(Source{{12, 34}}, nullptr, 3))}); + Structure("S", {Member("a", create(Source{{12, 34}}, nullptr, 3u))}); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: missing vector element type"); @@ -412,7 +412,7 @@ TEST_F(ResolverTypeValidationTest, Struct_Member_MatrixNoType) { // struct S { // a: mat3x3; // }; - Structure("S", {Member("a", create(Source{{12, 34}}, nullptr, 3, 3))}); + Structure("S", {Member("a", create(Source{{12, 34}}, nullptr, 3u, 3u))}); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type"); diff --git a/src/tint/resolver/validation_test.cc b/src/tint/resolver/validation_test.cc index 18ef8c74ef..20cf1ea833 100644 --- a/src/tint/resolver/validation_test.cc +++ b/src/tint/resolver/validation_test.cc @@ -326,8 +326,8 @@ TEST_F(ResolverValidationTest, StorageClass_SamplerExplicitStorageClass) { auto* t = ty.sampler(ast::SamplerKind::kSampler); GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); EXPECT_FALSE(r()->Resolve()); @@ -340,8 +340,8 @@ TEST_F(ResolverValidationTest, StorageClass_TextureExplicitStorageClass) { auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); EXPECT_FALSE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index 87bf529904..0048d741b0 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -1609,7 +1609,7 @@ bool Validator::TextureBuiltinFunction(const sem::Call* call) const { return true; } std::string name = sem::str(usage); - auto* arg = call->Arguments()[index]; + auto* arg = call->Arguments()[static_cast(index)]; if (auto values = arg->ConstantValue()) { // Assert that the constant values are of the expected type. if (!values.Type()->IsAnyOf() || @@ -1631,7 +1631,8 @@ bool Validator::TextureBuiltinFunction(const sem::Call* call) const { return ast::TraverseAction::Stop; }); if (is_const_expr) { - auto vector = builtin->Parameters()[index]->Type()->Is(); + auto vector = + builtin->Parameters()[static_cast(index)]->Type()->Is(); for (size_t i = 0, n = values.ElementCount(); i < n; i++) { auto value = values.Element(i).value; if (value < min || value > max) { diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc index f5622c7ab8..2ee597944a 100644 --- a/src/tint/resolver/variable_test.cc +++ b/src/tint/resolver/variable_test.cc @@ -472,8 +472,8 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) { auto* buf = Structure("S", {Member("inner", ty.Of(inner))}); auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 4_i); @@ -1049,18 +1049,18 @@ TEST_F(ResolverVariableTest, GlobalVar_StorageClass) { auto* workgroup = GlobalVar("w", ty.i32(), ast::StorageClass::kWorkgroup); auto* uniform = GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, ast::AttributeList{ - create(1), - create(0), + create(1u), + create(0u), }); auto* handle = GlobalVar("h", ty.depth_texture(ast::TextureDimension::k2d), ast::AttributeList{ - create(2), - create(0), + create(2u), + create(0u), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -1085,8 +1085,8 @@ TEST_F(ResolverVariableTest, GlobalVar_ExplicitStorageClass) { auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(1), - create(0), + create(1u), + create(0u), }); ASSERT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/variable_validation_test.cc b/src/tint/resolver/variable_validation_test.cc index 51b430f66e..79b269c9d8 100644 --- a/src/tint/resolver/variable_validation_test.cc +++ b/src/tint/resolver/variable_validation_test.cc @@ -245,8 +245,8 @@ TEST_F(ResolverVariableValidationTest, InferredPtrStorageAccessMismatch) { auto* buf = Structure("S", {Member("inner", ty.Of(inner))}); auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i); @@ -318,7 +318,7 @@ TEST_F(ResolverVariableValidationTest, InvalidStorageClassForInitializer) { TEST_F(ResolverVariableValidationTest, VectorConstNoType) { // const a : mat3x3 = mat3x3(); - WrapInFunction(Const("a", create(Source{{12, 34}}, nullptr, 3), vec3())); + WrapInFunction(Const("a", create(Source{{12, 34}}, nullptr, 3u), vec3())); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: missing vector element type"); @@ -326,7 +326,7 @@ TEST_F(ResolverVariableValidationTest, VectorConstNoType) { TEST_F(ResolverVariableValidationTest, VectorLetNoType) { // let a : mat3x3 = mat3x3(); - WrapInFunction(Let("a", create(Source{{12, 34}}, nullptr, 3), vec3())); + WrapInFunction(Let("a", create(Source{{12, 34}}, nullptr, 3u), vec3())); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: missing vector element type"); @@ -334,7 +334,7 @@ TEST_F(ResolverVariableValidationTest, VectorLetNoType) { TEST_F(ResolverVariableValidationTest, VectorVarNoType) { // var a : mat3x3; - WrapInFunction(Var("a", create(Source{{12, 34}}, nullptr, 3))); + WrapInFunction(Var("a", create(Source{{12, 34}}, nullptr, 3u))); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: missing vector element type"); @@ -342,7 +342,8 @@ TEST_F(ResolverVariableValidationTest, VectorVarNoType) { TEST_F(ResolverVariableValidationTest, MatrixConstNoType) { // const a : mat3x3 = mat3x3(); - WrapInFunction(Const("a", create(Source{{12, 34}}, nullptr, 3, 3), mat3x3())); + WrapInFunction( + Const("a", create(Source{{12, 34}}, nullptr, 3u, 3u), mat3x3())); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type"); @@ -350,7 +351,7 @@ TEST_F(ResolverVariableValidationTest, MatrixConstNoType) { TEST_F(ResolverVariableValidationTest, MatrixLetNoType) { // let a : mat3x3 = mat3x3(); - WrapInFunction(Let("a", create(Source{{12, 34}}, nullptr, 3, 3), mat3x3())); + WrapInFunction(Let("a", create(Source{{12, 34}}, nullptr, 3u, 3u), mat3x3())); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type"); @@ -358,7 +359,7 @@ TEST_F(ResolverVariableValidationTest, MatrixLetNoType) { TEST_F(ResolverVariableValidationTest, MatrixVarNoType) { // var a : mat3x3; - WrapInFunction(Var("a", create(Source{{12, 34}}, nullptr, 3, 3))); + WrapInFunction(Var("a", create(Source{{12, 34}}, nullptr, 3u, 3u))); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type"); diff --git a/src/tint/sem/variable.cc b/src/tint/sem/variable.cc index 841d96afb2..5439600448 100644 --- a/src/tint/sem/variable.cc +++ b/src/tint/sem/variable.cc @@ -91,4 +91,6 @@ VariableUser::VariableUser(const ast::IdentifierExpression* declaration, } } +VariableUser::~VariableUser() = default; + } // namespace tint::sem diff --git a/src/tint/sem/variable.h b/src/tint/sem/variable.h index 6d9586565a..3b5bd0cc09 100644 --- a/src/tint/sem/variable.h +++ b/src/tint/sem/variable.h @@ -226,6 +226,7 @@ class VariableUser final : public Castable { VariableUser(const ast::IdentifierExpression* declaration, Statement* statement, sem::Variable* variable); + ~VariableUser() override; /// @returns the variable that this expression refers to const sem::Variable* Variable() const { return variable_; } diff --git a/src/tint/transform/combine_samplers.cc b/src/tint/transform/combine_samplers.cc index 5f711de425..4e31789434 100644 --- a/src/tint/transform/combine_samplers.cc +++ b/src/tint/transform/combine_samplers.cc @@ -225,19 +225,21 @@ struct CombineSamplers::State { // Replace all texture builtin calls. if (auto* builtin = call->Target()->As()) { const auto& signature = builtin->Signature(); - int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler); - int texture_index = signature.IndexOf(sem::ParameterUsage::kTexture); + auto sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler); + auto texture_index = signature.IndexOf(sem::ParameterUsage::kTexture); if (texture_index == -1) { return nullptr; } - const sem::Expression* texture = call->Arguments()[texture_index]; + const sem::Expression* texture = + call->Arguments()[static_cast(texture_index)]; // We don't want to combine storage textures with anything, since // they never have associated samplers in GLSL. if (texture->Type()->UnwrapRef()->Is()) { return nullptr; } const sem::Expression* sampler = - sampler_index != -1 ? call->Arguments()[sampler_index] : nullptr; + sampler_index != -1 ? call->Arguments()[static_cast(sampler_index)] + : nullptr; auto* texture_var = texture->As()->Variable(); auto* sampler_var = sampler ? sampler->As()->Variable() : nullptr; diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc index 32ad153bbe..48dae278e5 100644 --- a/src/tint/transform/decompose_memory_access.cc +++ b/src/tint/transform/decompose_memory_access.cc @@ -377,10 +377,10 @@ struct DecomposeMemoryAccess::State { auto* lhs_lit = tint::As(lhs); auto* rhs_lit = tint::As(rhs); if (lhs_lit && lhs_lit->literal == 0) { - return offsets_.Create(0); + return offsets_.Create(0u); } if (rhs_lit && rhs_lit->literal == 0) { - return offsets_.Create(0); + return offsets_.Create(0u); } if (lhs_lit && lhs_lit->literal == 1) { return rhs; @@ -831,7 +831,7 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) con if (swizzle->Indices().size() == 1) { if (auto access = state.TakeAccess(accessor->structure)) { auto* vec_ty = access.type->As(); - auto* offset = state.Mul(vec_ty->type()->Size(), swizzle->Indices()[0]); + auto* offset = state.Mul(vec_ty->type()->Size(), swizzle->Indices()[0u]); state.AddAccess(accessor, { access.var, state.Add(access.offset, offset), diff --git a/src/tint/transform/decompose_strided_matrix_test.cc b/src/tint/transform/decompose_strided_matrix_test.cc index a2bf26d776..daff16f028 100644 --- a/src/tint/transform/decompose_strided_matrix_test.cc +++ b/src/tint/transform/decompose_strided_matrix_test.cc @@ -71,8 +71,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix) { "S", { b.Member("m", b.ty.mat2x2(), { - b.create(16), - b.create(32), + b.create(16u), + b.create(32u), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); @@ -127,8 +127,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformColumn) { "S", { b.Member("m", b.ty.mat2x2(), { - b.create(16), - b.create(32), + b.create(16u), + b.create(32u), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); @@ -180,8 +180,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix_DefaultStride) { "S", { b.Member("m", b.ty.mat2x2(), { - b.create(16), - b.create(8), + b.create(16u), + b.create(8u), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); @@ -233,8 +233,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) { "S", { b.Member("m", b.ty.mat2x2(), { - b.create(8), - b.create(32), + b.create(8u), + b.create(32u), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); @@ -290,8 +290,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) { "S", { b.Member("m", b.ty.mat2x2(), { - b.create(16), - b.create(32), + b.create(16u), + b.create(32u), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); @@ -344,8 +344,8 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) { "S", { b.Member("m", b.ty.mat2x2(), { - b.create(8), - b.create(32), + b.create(8u), + b.create(32u), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); @@ -402,8 +402,8 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) { "S", { b.Member("m", b.ty.mat2x2(), { - b.create(8), - b.create(32), + b.create(8u), + b.create(32u), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); @@ -461,8 +461,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) { "S", { b.Member("m", b.ty.mat2x2(), { - b.create(8), - b.create(32), + b.create(8u), + b.create(32u), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); @@ -532,8 +532,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadPrivateMatrix) { "S", { b.Member("m", b.ty.mat2x2(), { - b.create(8), - b.create(32), + b.create(8u), + b.create(32u), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); @@ -585,8 +585,8 @@ TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) { "S", { b.Member("m", b.ty.mat2x2(), { - b.create(8), - b.create(32), + b.create(8u), + b.create(32u), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); diff --git a/src/tint/transform/robustness.cc b/src/tint/transform/robustness.cc index aab1e0cc00..2e1cc40710 100644 --- a/src/tint/transform/robustness.cc +++ b/src/tint/transform/robustness.cc @@ -223,9 +223,9 @@ struct Robustness::State { auto array_idx = signature.IndexOf(sem::ParameterUsage::kArrayIndex); auto level_idx = signature.IndexOf(sem::ParameterUsage::kLevel); - auto* texture_arg = expr->args[texture_idx]; - auto* coords_arg = expr->args[coords_idx]; - auto* coords_ty = builtin->Parameters()[coords_idx]->Type(); + auto* texture_arg = expr->args[static_cast(texture_idx)]; + auto* coords_arg = expr->args[static_cast(coords_idx)]; + auto* coords_ty = builtin->Parameters()[static_cast(coords_idx)]->Type(); // If the level is provided, then we need to clamp this. As the level is // used by textureDimensions() and the texture[Load|Store]() calls, we need @@ -235,7 +235,7 @@ struct Robustness::State { std::function level_arg; if (level_idx >= 0) { level_arg = [&] { - auto* arg = expr->args[level_idx]; + auto* arg = expr->args[static_cast(level_idx)]; auto* num_levels = b.Call("textureNumLevels", ctx.Clone(texture_arg)); auto* zero = b.Expr(0_i); auto* max = ctx.dst->Sub(num_levels, 1_i); @@ -258,7 +258,7 @@ struct Robustness::State { // Clamp the array_index argument, if provided if (array_idx >= 0) { - auto* arg = expr->args[array_idx]; + auto* arg = expr->args[static_cast(array_idx)]; auto* num_layers = b.Call("textureNumLayers", ctx.Clone(texture_arg)); auto* zero = b.Expr(0_i); auto* max = ctx.dst->Sub(num_layers, 1_i); @@ -268,7 +268,7 @@ struct Robustness::State { // Clamp the level argument, if provided if (level_idx >= 0) { - auto* arg = expr->args[level_idx]; + auto* arg = expr->args[static_cast(level_idx)]; ctx.Replace(arg, level_arg ? level_arg() : ctx.dst->Expr(0_i)); } diff --git a/src/tint/utils/block_allocator_test.cc b/src/tint/utils/block_allocator_test.cc index 600019c4e9..77ea3e3a57 100644 --- a/src/tint/utils/block_allocator_test.cc +++ b/src/tint/utils/block_allocator_test.cc @@ -67,7 +67,7 @@ TEST_F(BlockAllocatorTest, ObjectLifetime) { TEST_F(BlockAllocatorTest, MoveConstruct) { using Allocator = BlockAllocator; - for (size_t n : {0, 1, 10, 16, 20, 32, 50, 64, 100, 256, 300, 512, 500, 512}) { + for (size_t n : {0u, 1u, 10u, 16u, 20u, 32u, 50u, 64u, 100u, 256u, 300u, 512u, 500u, 512u}) { size_t count = 0; { Allocator allocator_a; @@ -87,7 +87,7 @@ TEST_F(BlockAllocatorTest, MoveConstruct) { TEST_F(BlockAllocatorTest, MoveAssign) { using Allocator = BlockAllocator; - for (size_t n : {0, 1, 10, 16, 20, 32, 50, 64, 100, 256, 300, 512, 500, 512}) { + for (size_t n : {0u, 1u, 10u, 16u, 20u, 32u, 50u, 64u, 100u, 256u, 300u, 512u, 500u, 512u}) { size_t count_a = 0; size_t count_b = 0; diff --git a/src/tint/utils/compiler_macros.h b/src/tint/utils/compiler_macros.h index 34965c672a..b3cca3cb11 100644 --- a/src/tint/utils/compiler_macros.h +++ b/src/tint/utils/compiler_macros.h @@ -25,7 +25,11 @@ //////////////////////////////////////////////////////////////////////////////// #define TINT_DISABLE_WARNING_CONSTANT_OVERFLOW __pragma(warning(disable : 4756)) #define TINT_DISABLE_WARNING_MAYBE_UNINITIALIZED /* currently no-op */ +#define TINT_DISABLE_WARNING_NEWLINE_EOF /* currently no-op */ +#define TINT_DISABLE_WARNING_OLD_STYLE_CAST /* currently no-op */ +#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 */ // clang-format off #define TINT_BEGIN_DISABLE_WARNING(name) \ @@ -42,7 +46,12 @@ //////////////////////////////////////////////////////////////////////////////// #define TINT_DISABLE_WARNING_CONSTANT_OVERFLOW /* currently no-op */ #define TINT_DISABLE_WARNING_MAYBE_UNINITIALIZED /* currently no-op */ +#define TINT_DISABLE_WARNING_NEWLINE_EOF _Pragma("clang diagnostic ignored \"-Wnewline-eof\"") +#define TINT_DISABLE_WARNING_OLD_STYLE_CAST _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") +#define TINT_DISABLE_WARNING_SIGN_CONVERSION \ + _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\"") // clang-format off #define TINT_BEGIN_DISABLE_WARNING(name) \ @@ -60,7 +69,11 @@ #define TINT_DISABLE_WARNING_CONSTANT_OVERFLOW /* currently no-op */ #define TINT_DISABLE_WARNING_MAYBE_UNINITIALIZED \ _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +#define TINT_DISABLE_WARNING_NEWLINE_EOF /* currently no-op */ +#define TINT_DISABLE_WARNING_OLD_STYLE_CAST /* currently no-op */ +#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 */ // clang-format off #define TINT_BEGIN_DISABLE_WARNING(name) \ diff --git a/src/tint/writer/append_vector.cc b/src/tint/writer/append_vector.cc index bc89d1f0d8..7755ae3465 100644 --- a/src/tint/writer/append_vector.cc +++ b/src/tint/writer/append_vector.cc @@ -135,7 +135,7 @@ const sem::Call* AppendVector(ProgramBuilder* b, auto* scalar_cast_ast = b->Construct(packed_el_ast_ty, scalar_ast); auto* scalar_cast_target = b->create( packed_el_sem_ty, - b->create(nullptr, 0, scalar_sem->Type()->UnwrapRef(), + b->create(nullptr, 0u, scalar_sem->Type()->UnwrapRef(), ast::StorageClass::kNone, ast::Access::kUndefined)); auto* scalar_cast_sem = b->create( scalar_cast_ast, scalar_cast_target, std::vector{scalar_sem}, diff --git a/src/tint/writer/float_to_string_test.cc b/src/tint/writer/float_to_string_test.cc index 2596be7998..b629b50dc7 100644 --- a/src/tint/writer/float_to_string_test.cc +++ b/src/tint/writer/float_to_string_test.cc @@ -27,7 +27,7 @@ namespace { // - 0 sign if sign is 0, 1 otherwise // - 'exponent_bits' is placed in the exponent space. // So, the exponent bias must already be included. -float MakeFloat(int sign, int biased_exponent, int mantissa) { +float MakeFloat(uint32_t sign, uint32_t biased_exponent, uint32_t mantissa) { const uint32_t sign_bit = sign ? 0x80000000u : 0u; // The binary32 exponent is 8 bits, just below the sign. const uint32_t exponent_bits = (biased_exponent & 0xffu) << 23; diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index 3935fe39d8..022db4b6d4 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -1349,8 +1349,8 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, // Returns the argument with the given usage auto arg = [&](Usage usage) { - int idx = signature.IndexOf(usage); - return (idx >= 0) ? arguments[idx] : nullptr; + auto idx = signature.IndexOf(usage); + return (idx >= 0) ? arguments[static_cast(idx)] : nullptr; }; auto* texture = arg(Usage::kTexture); @@ -2138,7 +2138,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { // Emit the layout(local_size) attributes. auto wgsize = func_sem->WorkgroupSize(); out << "layout("; - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { if (i > 0) { out << ", "; } diff --git a/src/tint/writer/glsl/generator_impl_function_test.cc b/src/tint/writer/glsl/generator_impl_function_test.cc index a25d0232a0..a70e238e8f 100644 --- a/src/tint/writer/glsl/generator_impl_function_test.cc +++ b/src/tint/writer/glsl/generator_impl_function_test.cc @@ -351,8 +351,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4())}); auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); Func("sub_func", @@ -405,8 +405,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStr GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, @@ -450,8 +450,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -500,8 +500,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -551,8 +551,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); Func("frag_main", {}, ty.void_(), @@ -599,8 +599,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); Func("frag_main", {}, ty.void_(), @@ -643,8 +643,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_ auto* s = Structure("S", {Member("x", ty.f32())}); GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); Func("sub_func", {Param("param", ty.f32())}, ty.f32(), @@ -692,8 +692,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_ auto* s = Structure("S", {Member("x", ty.f32())}); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); Func("sub_func", {Param("param", ty.f32())}, ty.f32(), @@ -921,8 +921,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); { diff --git a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc index 11e0e38c22..875d211c25 100644 --- a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc @@ -93,8 +93,8 @@ class GlslGeneratorImplTest_MemberAccessorBase : public BASE { b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - b.create(0), - b.create(1), + b.create(0u), + b.create(1u), }); } diff --git a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc index 13f2762296..ae1b0ba4b5 100644 --- a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc @@ -28,8 +28,8 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -71,8 +71,8 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -113,8 +113,8 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); auto* p = Let("p", nullptr, AddressOf("b")); diff --git a/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc b/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc index e2a6f97c65..7a13b66c49 100644 --- a/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc +++ b/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc @@ -37,8 +37,8 @@ void TestAlign(ProgramBuilder* ctx) { }); ctx->GlobalVar("nephews", ctx->ty.Of(nephews), ast::StorageClass::kStorage, ast::AttributeList{ - ctx->create(0), - ctx->create(0), + ctx->create(0u), + ctx->create(0u), }); } diff --git a/src/tint/writer/glsl/generator_impl_type_test.cc b/src/tint/writer/glsl/generator_impl_type_test.cc index 42423688b6..acf28ff131 100644 --- a/src/tint/writer/glsl/generator_impl_type_test.cc +++ b/src/tint/writer/glsl/generator_impl_type_test.cc @@ -272,8 +272,8 @@ TEST_P(GlslDepthTexturesTest, Emit) { GlobalVar("tex", t, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, @@ -299,8 +299,8 @@ TEST_F(GlslDepthMultisampledTexturesTest, Emit) { GlobalVar("tex", t, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, @@ -342,8 +342,8 @@ TEST_P(GlslSampledTexturesTest, Emit) { GlobalVar("tex", t, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, @@ -476,8 +476,8 @@ TEST_P(GlslStorageTexturesTest, Emit) { GlobalVar("tex", t, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index fd502d1242..3e4352b634 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -2107,7 +2107,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, // Returns the argument with the given usage auto arg = [&](Usage usage) { int idx = signature.IndexOf(usage); - return (idx >= 0) ? arguments[idx] : nullptr; + return (idx >= 0) ? arguments[static_cast(idx)] : nullptr; }; auto* texture = arg(Usage::kTexture); @@ -3039,7 +3039,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { // Emit the workgroup_size attribute. auto wgsize = func_sem->WorkgroupSize(); out << "[numthreads("; - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { if (i > 0) { out << ", "; } diff --git a/src/tint/writer/hlsl/generator_impl_case_test.cc b/src/tint/writer/hlsl/generator_impl_case_test.cc index ee3acfcc06..5c7e427aa2 100644 --- a/src/tint/writer/hlsl/generator_impl_case_test.cc +++ b/src/tint/writer/hlsl/generator_impl_case_test.cc @@ -99,7 +99,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_Default) { gen.increment_indent(); - ASSERT_TRUE(gen.EmitCase(s, 0_i)) << gen.error(); + ASSERT_TRUE(gen.EmitCase(s, 0u)) << gen.error(); EXPECT_EQ(gen.result(), R"( default: { break; } diff --git a/src/tint/writer/hlsl/generator_impl_function_test.cc b/src/tint/writer/hlsl/generator_impl_function_test.cc index b0e1495b2c..85647a5b45 100644 --- a/src/tint/writer/hlsl/generator_impl_function_test.cc +++ b/src/tint/writer/hlsl/generator_impl_function_test.cc @@ -348,8 +348,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4())}); auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); Func("sub_func", @@ -395,8 +395,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStr GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, @@ -433,8 +433,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -469,8 +469,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -505,8 +505,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); Func("frag_main", {}, ty.void_(), @@ -539,8 +539,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); Func("frag_main", {}, ty.void_(), @@ -569,8 +569,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_ auto* s = Structure("S", {Member("x", ty.f32())}); GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); Func("sub_func", @@ -615,8 +615,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_ auto* s = Structure("S", {Member("x", ty.f32())}); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(1), + create(0u), + create(1u), }); Func("sub_func", @@ -861,8 +861,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); { diff --git a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc index 3114174536..8149b7f6cc 100644 --- a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc @@ -93,8 +93,8 @@ class HlslGeneratorImplTest_MemberAccessorBase : public BASE { b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - b.create(0), - b.create(1), + b.create(0u), + b.create(1u), }); } diff --git a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc index a9f6617144..3bb1cec88f 100644 --- a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc @@ -28,8 +28,8 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -66,8 +66,8 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -102,8 +102,8 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); auto* p = Let("p", nullptr, AddressOf("b")); @@ -142,13 +142,13 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(2), - create(2), + create(2u), + create(2u), }); Func("a_func", {}, ty.void_(), diff --git a/src/tint/writer/hlsl/generator_impl_type_test.cc b/src/tint/writer/hlsl/generator_impl_type_test.cc index 43825a980d..614d8f1cbc 100644 --- a/src/tint/writer/hlsl/generator_impl_type_test.cc +++ b/src/tint/writer/hlsl/generator_impl_type_test.cc @@ -155,8 +155,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) { }); GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -289,8 +289,8 @@ TEST_P(HlslDepthTexturesTest, Emit) { GlobalVar("tex", t, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, @@ -319,8 +319,8 @@ TEST_F(HlslDepthMultisampledTexturesTest, Emit) { GlobalVar("tex", t, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, @@ -362,8 +362,8 @@ TEST_P(HlslSampledTexturesTest, Emit) { GlobalVar("tex", t, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index c649090c6f..f5ffa6c615 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -759,7 +759,7 @@ bool GeneratorImpl::EmitTypeConstructor(std::ostream& out, return false; } - int i = 0; + size_t i = 0; for (auto* arg : call->Arguments()) { if (i > 0) { out << ", "; @@ -920,7 +920,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out, // Returns the argument with the given usage auto arg = [&](Usage usage) { int idx = signature.IndexOf(usage); - return (idx >= 0) ? arguments[idx] : nullptr; + return (idx >= 0) ? arguments[static_cast(idx)] : nullptr; }; auto* texture = arg(Usage::kTexture)->Declaration(); diff --git a/src/tint/writer/msl/generator_impl_function_test.cc b/src/tint/writer/msl/generator_impl_function_test.cc index e3bfd7fa23..e520d7aa9e 100644 --- a/src/tint/writer/msl/generator_impl_function_test.cc +++ b/src/tint/writer/msl/generator_impl_function_test.cc @@ -337,8 +337,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RW_StorageBu GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -379,8 +379,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RO_StorageBu GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -417,8 +417,8 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_Called_By_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4())}); auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); Func("sub_func", @@ -471,8 +471,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RW GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); Func("sub_func", @@ -526,8 +526,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RO GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); Func("sub_func", @@ -667,8 +667,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_ModuleV GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); { diff --git a/src/tint/writer/msl/generator_impl_sanitizer_test.cc b/src/tint/writer/msl/generator_impl_sanitizer_test.cc index 96e947322b..1514373c90 100644 --- a/src/tint/writer/msl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/msl/generator_impl_sanitizer_test.cc @@ -29,8 +29,8 @@ TEST_F(MslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -87,8 +87,8 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -144,8 +144,8 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); auto* p = Let("p", nullptr, AddressOf("b")); @@ -204,13 +204,13 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(0), + create(1u), + create(0u), }); GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(2), - create(0), + create(2u), + create(0u), }); Func("a_func", {}, ty.void_(), @@ -269,13 +269,13 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniformMissingBinding) auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(0), + create(1u), + create(0u), }); GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(2), - create(0), + create(2u), + create(0u), }); Func("a_func", {}, ty.void_(), diff --git a/src/tint/writer/msl/generator_impl_type_test.cc b/src/tint/writer/msl/generator_impl_type_test.cc index 38a6ef7167..070b1bb51a 100644 --- a/src/tint/writer/msl/generator_impl_type_test.cc +++ b/src/tint/writer/msl/generator_impl_type_test.cc @@ -249,8 +249,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) { GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -358,8 +358,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_Structures) { GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -452,8 +452,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) { GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -538,8 +538,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayVec3DefaultStride) { GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -602,8 +602,8 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) { GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -663,8 +663,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) { GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -830,8 +830,8 @@ TEST_P(MslStorageTexturesTest, Emit) { auto* s = ty.storage_texture(params.dim, ast::TexelFormat::kR32Float, ast::Access::kWrite); GlobalVar("test_var", s, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index be33426020..fea7a14506 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -533,7 +533,7 @@ bool Builder::GenerateExecutionModes(const ast::Function* func, uint32_t id) { wgsize_ops.push_back(wgsize_result); // Generate OpConstant instructions for each dimension. - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { auto constant = ScalarConstant::U32(wgsize[i].value); if (wgsize[i].overridable_const) { // Make the constant specializable. @@ -2688,7 +2688,7 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call, // Returns the argument with the given usage auto arg = [&](Usage usage) { int idx = signature.IndexOf(usage); - return (idx >= 0) ? arguments[idx] : nullptr; + return (idx >= 0) ? arguments[static_cast(idx)] : nullptr; }; // Generates the argument with the given usage, returning the operand ID diff --git a/src/tint/writer/spirv/builder_builtin_test.cc b/src/tint/writer/spirv/builder_builtin_test.cc index 36c152e370..c4bf27e5ff 100644 --- a/src/tint/writer/spirv/builder_builtin_test.cc +++ b/src/tint/writer/spirv/builder_builtin_test.cc @@ -453,14 +453,14 @@ TEST_F(BuiltinBuilderTest, Call_TextureSampleCompare_Twice) { auto* tex = GlobalVar("texture", t, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* sampler = GlobalVar("sampler", s, ast::AttributeList{ - create(1), - create(0), + create(1u), + create(0u), }); auto* expr1 = Call("textureSampleCompare", "texture", "sampler", vec2(1_f, 2_f), 2_f); @@ -1587,8 +1587,8 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength) { auto* s = Structure("my_struct", {Member("a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); @@ -1634,8 +1634,8 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_OtherMembersInStruct) { }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); @@ -1678,8 +1678,8 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", {Member("a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); auto* p = Let("p", nullptr, AddressOf("b")); @@ -1738,8 +1738,8 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) { auto* s = Structure("my_struct", {Member("a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); auto* p = Let("p", nullptr, AddressOf(Deref(AddressOf("b")))); @@ -1803,8 +1803,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicLoad) { }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -1867,8 +1867,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicStore) { }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -1939,8 +1939,8 @@ TEST_P(Builtin_Builtin_AtomicRMW_i32, Test) { }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -2012,8 +2012,8 @@ TEST_P(Builtin_Builtin_AtomicRMW_u32, Test) { }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -2087,8 +2087,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicExchange) { }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), @@ -2163,8 +2163,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) { }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); Func("a_func", {}, ty.void_(), diff --git a/src/tint/writer/spirv/builder_function_test.cc b/src/tint/writer/spirv/builder_function_test.cc index b374a6c9df..91fa71a4e4 100644 --- a/src/tint/writer/spirv/builder_function_test.cc +++ b/src/tint/writer/spirv/builder_function_test.cc @@ -200,8 +200,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); { diff --git a/src/tint/writer/spirv/builder_global_variable_test.cc b/src/tint/writer/spirv/builder_global_variable_test.cc index 9e9913ca8d..05f6929e13 100644 --- a/src/tint/writer/spirv/builder_global_variable_test.cc +++ b/src/tint/writer/spirv/builder_global_variable_test.cc @@ -206,8 +206,8 @@ TEST_F(BuilderTest, GlobalVar_WithBindingAndGroup) { auto* v = GlobalVar("var", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr, ast::AttributeList{ - create(2), - create(3), + create(2u), + create(3u), }); spirv::Builder& b = Build(); @@ -450,8 +450,8 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = SanitizeAndBuild(); @@ -491,8 +491,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { auto* B = Alias("B", ty.Of(A)); GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = SanitizeAndBuild(); @@ -530,8 +530,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { auto* B = Alias("B", ty.Of(A)); GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = SanitizeAndBuild(); @@ -568,13 +568,13 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { auto* A = Structure("A", {Member("a", ty.i32())}); GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GlobalVar("c", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(1), - create(0), + create(1u), + create(0u), }); spirv::Builder& b = SanitizeAndBuild(); @@ -614,8 +614,8 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) { auto* var_a = GlobalVar("a", type, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = Build(); @@ -645,16 +645,16 @@ TEST_F(BuilderTest, DISABLED_GlobalVar_TextureStorageWithDifferentAccess) { ast::Access::kReadWrite); auto* var_a = GlobalVar("a", type_a, ast::StorageClass::kNone, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); auto* type_b = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ast::Access::kWrite); auto* var_b = GlobalVar("b", type_b, ast::StorageClass::kNone, ast::AttributeList{ - create(1), - create(0), + create(1u), + create(0u), }); spirv::Builder& b = Build(); diff --git a/src/tint/writer/spirv/builder_type_test.cc b/src/tint/writer/spirv/builder_type_test.cc index 44d6374b84..b4bff9ba16 100644 --- a/src/tint/writer/spirv/builder_type_test.cc +++ b/src/tint/writer/spirv/builder_type_test.cc @@ -30,8 +30,8 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) { auto* str = Structure("S", {Member("x", ary)}); GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = Build(); @@ -50,8 +50,8 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { auto* str = Structure("S", {Member("x", ary)}); GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = Build(); @@ -783,8 +783,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) { GlobalVar("test_var", s, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = Build(); @@ -802,8 +802,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) { GlobalVar("test_var", s, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = Build(); @@ -821,8 +821,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) { GlobalVar("test_var", s, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = Build(); @@ -840,8 +840,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) { GlobalVar("test_var", s, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = Build(); @@ -859,8 +859,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32floa GlobalVar("test_var", s, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = Build(); @@ -878,8 +878,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint) GlobalVar("test_var", s, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = Build(); @@ -897,8 +897,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeUint_Format_r32uint) GlobalVar("test_var", s, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); spirv::Builder& b = Build(); diff --git a/src/tint/writer/text_generator.cc b/src/tint/writer/text_generator.cc index 5e4e93f801..1a1fa5abc2 100644 --- a/src/tint/writer/text_generator.cc +++ b/src/tint/writer/text_generator.cc @@ -84,7 +84,7 @@ void TextGenerator::TextBuffer::Insert(const std::string& line, size_t before, u << " lines.size(): " << lines.size(); return; } - lines.insert(lines.begin() + before, Line{indent, line}); + lines.insert(lines.begin() + static_cast(before), Line{indent, line}); } void TextGenerator::TextBuffer::Append(const TextBuffer& tb) { @@ -105,7 +105,8 @@ void TextGenerator::TextBuffer::Insert(const TextBuffer& tb, size_t before, uint size_t idx = 0; for (auto& line : tb.lines) { // TODO(bclayton): inefficent, consider optimizing - lines.insert(lines.begin() + before + idx, Line{indent + line.indent, line.content}); + lines.insert(lines.begin() + static_cast(before + idx), + Line{indent + line.indent, line.content}); idx++; } } diff --git a/src/tint/writer/wgsl/generator_impl.cc b/src/tint/writer/wgsl/generator_impl.cc index a448827aff..26e0a294df 100644 --- a/src/tint/writer/wgsl/generator_impl.cc +++ b/src/tint/writer/wgsl/generator_impl.cc @@ -714,7 +714,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out, const ast::AttributeList& [&](const ast::WorkgroupAttribute* workgroup) { auto values = workgroup->Values(); out << "workgroup_size("; - for (int i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { if (values[i]) { if (i > 0) { out << ", "; diff --git a/src/tint/writer/wgsl/generator_impl_function_test.cc b/src/tint/writer/wgsl/generator_impl_function_test.cc index 17439c7682..06738580fd 100644 --- a/src/tint/writer/wgsl/generator_impl_function_test.cc +++ b/src/tint/writer/wgsl/generator_impl_function_test.cc @@ -162,8 +162,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_Module GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); { diff --git a/src/tint/writer/wgsl/generator_impl_global_decl_test.cc b/src/tint/writer/wgsl/generator_impl_global_decl_test.cc index 78b5d52e03..ef9e11c006 100644 --- a/src/tint/writer/wgsl/generator_impl_global_decl_test.cc +++ b/src/tint/writer/wgsl/generator_impl_global_decl_test.cc @@ -103,8 +103,8 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) { GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -119,8 +119,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) { auto* st = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); GlobalVar("t", st, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/wgsl/generator_impl_literal_test.cc b/src/tint/writer/wgsl/generator_impl_literal_test.cc index dd715d4fbe..78d70f6be7 100644 --- a/src/tint/writer/wgsl/generator_impl_literal_test.cc +++ b/src/tint/writer/wgsl/generator_impl_literal_test.cc @@ -25,7 +25,7 @@ namespace { // - 0 sign if sign is 0, 1 otherwise // - 'exponent_bits' is placed in the exponent space. // So, the exponent bias must already be included. -f32 MakeFloat(int sign, int biased_exponent, int mantissa) { +f32 MakeFloat(uint32_t sign, uint32_t biased_exponent, uint32_t mantissa) { const uint32_t sign_bit = sign ? 0x80000000u : 0u; // The binary32 exponent is 8 bits, just below the sign. const uint32_t exponent_bits = (biased_exponent & 0xffu) << 23; diff --git a/src/tint/writer/wgsl/generator_impl_type_test.cc b/src/tint/writer/wgsl/generator_impl_type_test.cc index 108e0d5196..b6ae9c5660 100644 --- a/src/tint/writer/wgsl/generator_impl_type_test.cc +++ b/src/tint/writer/wgsl/generator_impl_type_test.cc @@ -422,8 +422,8 @@ TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) { auto* t = ty.storage_texture(param.dim, param.fmt, param.access); GlobalVar("g", t, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/wgsl/generator_impl_variable_test.cc b/src/tint/writer/wgsl/generator_impl_variable_test.cc index a117459d32..a02aed8789 100644 --- a/src/tint/writer/wgsl/generator_impl_variable_test.cc +++ b/src/tint/writer/wgsl/generator_impl_variable_test.cc @@ -45,8 +45,8 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) { auto* s = Structure("S", {Member("a", ty.i32())}); auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -60,8 +60,8 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Write) { auto* s = Structure("S", {Member("a", ty.i32())}); auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -75,8 +75,8 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_ReadWrite) { auto* s = Structure("S", {Member("a", ty.i32())}); auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, ast::AttributeList{ - create(0), - create(0), + create(0u), + create(0u), }); GeneratorImpl& gen = Build(); @@ -90,8 +90,8 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) { auto* v = GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr, ast::AttributeList{ - create(1), - create(2), + create(1u), + create(2u), }); GeneratorImpl& gen = Build();