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 <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 50f586e..755d4a3 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -22,18 +22,6 @@
${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 baed079..f396e0c 100644
--- a/src/tint/ast/array_test.cc
+++ b/src/tint/ast/array_test.cc
@@ -62,7 +62,7 @@
TEST_F(AstArrayTest, FriendlyName_WithStride) {
auto* i32 = create<I32>();
- auto* arr = create<Array>(i32, Expr(5_u), AttributeList{create<StrideAttribute>(32)});
+ auto* arr = create<Array>(i32, Expr(5_u), AttributeList{create<StrideAttribute>(32u)});
EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(32) array<i32, 5>");
}
diff --git a/src/tint/ast/binding_attribute_test.cc b/src/tint/ast/binding_attribute_test.cc
index f51fc25..8000933 100644
--- a/src/tint/ast/binding_attribute_test.cc
+++ b/src/tint/ast/binding_attribute_test.cc
@@ -20,7 +20,7 @@
using BindingAttributeTest = TestHelper;
TEST_F(BindingAttributeTest, Creation) {
- auto* d = create<BindingAttribute>(2);
+ auto* d = create<BindingAttribute>(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 3d23808..ad42267 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::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b) const {
AttributeList attrs = {
- b->create<ast::GroupAttribute>(0),
- b->create<ast::BindingAttribute>(0),
+ b->create<ast::GroupAttribute>(0u),
+ b->create<ast::BindingAttribute>(0u),
};
switch (texture_kind) {
case ast::builtin::test::TextureKind::kRegular:
@@ -176,8 +176,8 @@
const ast::Variable* TextureOverloadCase::BuildSamplerVariable(ProgramBuilder* b) const {
AttributeList attrs = {
- b->create<ast::GroupAttribute>(0),
- b->create<ast::BindingAttribute>(1),
+ b->create<ast::GroupAttribute>(0u),
+ b->create<ast::BindingAttribute>(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 53167bb..4a6dd1d 100644
--- a/src/tint/ast/group_attribute_test.cc
+++ b/src/tint/ast/group_attribute_test.cc
@@ -20,7 +20,7 @@
using GroupAttributeTest = TestHelper;
TEST_F(GroupAttributeTest, Creation) {
- auto* d = create<GroupAttribute>(2);
+ auto* d = create<GroupAttribute>(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 6957d66..ad05c58 100644
--- a/src/tint/ast/id_attribute_test.cc
+++ b/src/tint/ast/id_attribute_test.cc
@@ -22,7 +22,7 @@
using IdAttributeTest = TestHelper;
TEST_F(IdAttributeTest, Creation) {
- auto* d = create<IdAttribute>(12);
+ auto* d = create<IdAttribute>(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 a1562d5..e0bcb39 100644
--- a/src/tint/ast/location_attribute_test.cc
+++ b/src/tint/ast/location_attribute_test.cc
@@ -20,7 +20,7 @@
using LocationAttributeTest = TestHelper;
TEST_F(LocationAttributeTest, Creation) {
- auto* d = create<LocationAttribute>(2);
+ auto* d = create<LocationAttribute>(2u);
EXPECT_EQ(2u, d->value);
}
diff --git a/src/tint/ast/matrix_test.cc b/src/tint/ast/matrix_test.cc
index 66ea84d..dbb88e3 100644
--- a/src/tint/ast/matrix_test.cc
+++ b/src/tint/ast/matrix_test.cc
@@ -34,7 +34,7 @@
TEST_F(AstMatrixTest, Creation) {
auto* i32 = create<I32>();
- auto* m = create<Matrix>(i32, 2, 4);
+ auto* m = create<Matrix>(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, FriendlyName) {
auto* i32 = create<I32>();
- auto* m = create<Matrix>(i32, 3, 2);
+ auto* m = create<Matrix>(i32, 3u, 2u);
EXPECT_EQ(m->FriendlyName(Symbols()), "mat2x3<i32>");
}
TEST_F(AstMatrixTest, FriendlyName_WithoutType) {
- auto* m = create<Matrix>(nullptr, 3, 2);
+ auto* m = create<Matrix>(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 61c4fb5..eb19034 100644
--- a/src/tint/ast/stride_attribute_test.cc
+++ b/src/tint/ast/stride_attribute_test.cc
@@ -20,13 +20,13 @@
using StrideAttributeTest = TestHelper;
TEST_F(StrideAttributeTest, Creation) {
- auto* d = create<StrideAttribute>(2);
+ auto* d = create<StrideAttribute>(2u);
EXPECT_EQ(2u, d->stride);
}
TEST_F(StrideAttributeTest, Source) {
auto* d = create<StrideAttribute>(
- 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 5b4ff48..ba4d1bb 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 @@
using StructMemberAlignAttributeTest = TestHelper;
TEST_F(StructMemberAlignAttributeTest, Creation) {
- auto* d = create<StructMemberAlignAttribute>(2);
+ auto* d = create<StructMemberAlignAttribute>(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 3c0eb41..9d81ffb 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 @@
using StructMemberOffsetAttributeTest = TestHelper;
TEST_F(StructMemberOffsetAttributeTest, Creation) {
- auto* d = create<StructMemberOffsetAttribute>(2);
+ auto* d = create<StructMemberOffsetAttribute>(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 a9d4637..a82d53a 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 @@
using StructMemberSizeAttributeTest = TestHelper;
TEST_F(StructMemberSizeAttributeTest, Creation) {
- auto* d = create<StructMemberSizeAttribute>(2);
+ auto* d = create<StructMemberSizeAttribute>(2u);
EXPECT_EQ(2u, d->size);
}
diff --git a/src/tint/ast/variable_test.cc b/src/tint/ast/variable_test.cc
index e62ec1e..025fa6b 100644
--- a/src/tint/ast/variable_test.cc
+++ b/src/tint/ast/variable_test.cc
@@ -94,9 +94,9 @@
TEST_F(VariableTest, WithAttributes) {
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
AttributeList{
- create<LocationAttribute>(1),
+ create<LocationAttribute>(1u),
create<BuiltinAttribute>(Builtin::kPosition),
- create<IdAttribute>(1200),
+ create<IdAttribute>(1200u),
});
auto& attributes = var->attributes;
@@ -112,8 +112,8 @@
TEST_F(VariableTest, BindingPoint) {
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
AttributeList{
- create<BindingAttribute>(2),
- create<GroupAttribute>(1),
+ create<BindingAttribute>(2u),
+ create<GroupAttribute>(1u),
});
EXPECT_TRUE(var->BindingPoint());
ASSERT_NE(var->BindingPoint().binding, nullptr);
@@ -132,7 +132,7 @@
TEST_F(VariableTest, BindingPointMissingGroupAttribute) {
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
AttributeList{
- create<BindingAttribute>(2),
+ create<BindingAttribute>(2u),
});
EXPECT_FALSE(var->BindingPoint());
ASSERT_NE(var->BindingPoint().binding, nullptr);
@@ -142,7 +142,7 @@
TEST_F(VariableTest, BindingPointMissingBindingAttribute) {
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
- AttributeList{create<GroupAttribute>(1)});
+ AttributeList{create<GroupAttribute>(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 a701852..da2ad1f 100644
--- a/src/tint/ast/vector_test.cc
+++ b/src/tint/ast/vector_test.cc
@@ -24,14 +24,14 @@
TEST_F(AstVectorTest, Creation) {
auto* i32 = create<I32>();
- auto* v = create<Vector>(i32, 2);
+ auto* v = create<Vector>(i32, 2u);
EXPECT_EQ(v->type, i32);
EXPECT_EQ(v->width, 2u);
}
TEST_F(AstVectorTest, FriendlyName) {
auto* f32 = create<F32>();
- auto* v = create<Vector>(f32, 3);
+ auto* v = create<Vector>(f32, 3u);
EXPECT_EQ(v->FriendlyName(Symbols()), "vec3<f32>");
}
diff --git a/src/tint/castable.cc b/src/tint/castable.cc
index cff430e..40c32da 100644
--- a/src/tint/castable.cc
+++ b/src/tint/castable.cc
@@ -26,4 +26,8 @@
tint::TypeInfo::FullHashCodeOf<CastableBase>(),
};
+CastableBase::CastableBase(const CastableBase&) = default;
+
+CastableBase::~CastableBase() = default;
+
} // namespace tint
diff --git a/src/tint/castable.h b/src/tint/castable.h
index 048d1e5..c7b8608 100644
--- a/src/tint/castable.h
+++ b/src/tint/castable.h
@@ -320,10 +320,10 @@
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 @@
// Static assertions
static constexpr bool kDefaultIsOK =
- kDefaultIndex == -1 || kDefaultIndex == std::tuple_size_v<Cases> - 1;
+ kDefaultIndex == -1 || kDefaultIndex == static_cast<int>(std::tuple_size_v<Cases> - 1);
static constexpr bool kReturnIsOK =
kHasDefaultCase || !kHasReturnType || std::is_constructible_v<RETURN_TYPE>;
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 0a9e606..513c710 100644
--- a/src/tint/clone_context.cc
+++ b/src/tint/clone_context.cc
@@ -23,6 +23,10 @@
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 887d628..e8e197f 100644
--- a/src/tint/clone_context.h
+++ b/src/tint/clone_context.h
@@ -48,6 +48,13 @@
/// Cloneable is the base class for all objects that can be cloned
class Cloneable : public Castable<Cloneable> {
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 0116be0..d68a62a 100644
--- a/src/tint/demangler.cc
+++ b/src/tint/demangler.cc
@@ -49,7 +49,7 @@
auto len = end_idx - start_idx;
auto id = str.substr(start_idx, len);
- Symbol sym(std::stoi(id), symbols.ProgramID());
+ Symbol sym(static_cast<uint32_t>(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 bef9195..c5b3eb7 100644
--- a/src/tint/inspector/inspector.cc
+++ b/src/tint/inspector/inspector.cc
@@ -815,8 +815,8 @@
continue;
}
- auto* t = c->args[texture_index];
- auto* s = c->args[sampler_index];
+ auto* t = c->args[static_cast<size_t>(texture_index)];
+ auto* s = c->args[static_cast<size_t>(sampler_index)];
GetOriginatingResources(
std::array<const ast::Expression*, 2>{t, s},
diff --git a/src/tint/inspector/inspector_test.cc b/src/tint/inspector/inspector_test.cc
index fb09522..4e369d5 100644
--- a/src/tint/inspector/inspector_test.cc
+++ b/src/tint/inspector/inspector_test.cc
@@ -3048,7 +3048,7 @@
// here the struct is expected to occupy 1024 bytes of workgroup storage.
const auto* wg_struct_type = MakeStructTypeFromMembers(
"WgStruct",
- {MakeStructMember(0, ty.f32(), {create<ast::StructMemberAlignAttribute>(1024)})});
+ {MakeStructMember(0, ty.f32(), {create<ast::StructMemberAlignAttribute>(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 f97f474..23b473c 100644
--- a/src/tint/inspector/test_inspector_builder.cc
+++ b/src/tint/inspector/test_inspector_builder.cc
@@ -285,11 +285,11 @@
return scalar;
case ast::TextureDimension::k2d:
case ast::TextureDimension::k2dArray:
- return create<ast::Vector>(scalar, 2);
+ return create<ast::Vector>(scalar, 2u);
case ast::TextureDimension::k3d:
case ast::TextureDimension::kCube:
case ast::TextureDimension::kCubeArray:
- return create<ast::Vector>(scalar, 3);
+ return create<ast::Vector>(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 3b333df..2bcae95 100644
--- a/src/tint/reader/spirv/function.cc
+++ b/src/tint/reader/spirv/function.cc
@@ -1024,11 +1024,13 @@
[&](const Struct* struct_type) -> bool {
const auto& members = struct_type->members;
index_prefix.push_back(0);
- for (int i = 0; i < static_cast<int>(members.size()); ++i) {
- index_prefix.back() = i;
+ for (size_t i = 0; i < members.size(); ++i) {
+ index_prefix.back() = static_cast<int>(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<int>(i)),
&member_attrs)) {
return false;
}
@@ -1078,7 +1080,7 @@
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<size_t>(index)];
});
}
@@ -1174,8 +1176,9 @@
&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<size_t>(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 @@
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<size_t>(index)];
});
}
@@ -1825,7 +1828,7 @@
// 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<size_t>(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 @@
// 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 @@
// 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<uint32_t>(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<uint32_t>(index_start))
+ << " indices: " << inst.PrettyPrint();
return {};
}
const char* operation_name = nullptr;
@@ -4650,7 +4654,7 @@
// 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<uint32_t>(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::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 @@
<< "expected Workgroup (2), got: " << execution;
}
if (semantics & SpvMemorySemanticsAcquireReleaseMask) {
- semantics &= ~SpvMemorySemanticsAcquireReleaseMask;
+ semantics &= ~static_cast<uint32_t>(SpvMemorySemanticsAcquireReleaseMask);
} else {
return Fail() << "control barrier semantics requires acquire and release";
}
@@ -4945,14 +4949,14 @@
return Fail() << "workgroupBarrier requires workgroup memory scope";
}
AddStatement(create<ast::CallStatement>(builder_.Call("workgroupBarrier")));
- semantics &= ~SpvMemorySemanticsWorkgroupMemoryMask;
+ semantics &= ~static_cast<uint32_t>(SpvMemorySemanticsWorkgroupMemoryMask);
}
if (semantics & SpvMemorySemanticsUniformMemoryMask) {
if (memory != SpvScopeDevice) {
return Fail() << "storageBarrier requires device memory scope";
}
AddStatement(create<ast::CallStatement>(builder_.Call("storageBarrier")));
- semantics &= ~SpvMemorySemanticsUniformMemoryMask;
+ semantics &= ~static_cast<uint32_t>(SpvMemorySemanticsUniformMemoryMask);
}
if (semantics) {
return Fail() << "unsupported control barrier semantics: " << semantics;
@@ -5600,7 +5604,7 @@
}
ast::TextureDimension dim = texture_type->dims;
// Number of regular coordinates.
- uint32_t num_axes = ast::NumCoordinateAxes(dim);
+ uint32_t num_axes = static_cast<uint32_t>(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 1ebf0b9..b34f66b 100644
--- a/src/tint/reader/spirv/parser_impl.cc
+++ b/src/tint/reader/spirv/parser_impl.cc
@@ -816,7 +816,7 @@
/// 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<uint32_t>(index));
const auto* def = def_use_mgr_->GetDef(id);
if (!def || (def->opcode() != SpvOpSpecConstant && def->opcode() != SpvOpConstant) ||
(def->NumInOperands() != 1)) {
@@ -1336,7 +1336,7 @@
},
[&](const U32*) {
return create<ast::IntLiteralExpression>(
- Source{}, static_cast<uint64_t>(literal_value),
+ Source{}, static_cast<int64_t>(literal_value),
ast::IntLiteralExpression::Suffix::kU);
},
[&](const F32*) {
@@ -1715,8 +1715,8 @@
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<uint32_t>(member_index))) {
if (IsPipelineDecoration(deco)) {
result.emplace_back(deco);
}
@@ -2721,7 +2721,7 @@
Fail() << "no structure type registered for symbol";
return "";
}
- return namer_.GetMemberName(where->second, member_index);
+ return namer_.GetMemberName(where->second, static_cast<uint32_t>(member_index));
}
WorkgroupSizeInfo::WorkgroupSizeInfo() = default;
diff --git a/src/tint/reader/spirv/parser_impl.h b/src/tint/reader/spirv/parser_impl.h
index 6addf6c..ce790d3 100644
--- a/src/tint/reader/spirv/parser_impl.h
+++ b/src/tint/reader/spirv/parser_impl.h
@@ -22,8 +22,18 @@
#include <utility>
#include <vector>
+#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 7362a2d..f2c2dfe 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 <utility>
#include <vector>
+#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 3332cd4..db8c01b 100644
--- a/src/tint/reader/spirv/parser_type.cc
+++ b/src/tint/reader/spirv/parser_type.cc
@@ -163,6 +163,12 @@
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 605ac9b..9543b51 100644
--- a/src/tint/reader/spirv/parser_type.h
+++ b/src/tint/reader/spirv/parser_type.h
@@ -40,6 +40,13 @@
/// Type is the base class for all types
class Type : public Castable<Type> {
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 @@
/// Base class for texture types
struct Texture : public Castable<Texture, Type> {
+ ~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 d01d1a2..bb64bb3 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_Equality_OneDifference) {
- const int num_usages = 9;
+ const size_t num_usages = 9u;
std::vector<Usage> usages(num_usages);
usages[1].AddSampler();
usages[2].AddComparisonSampler();
@@ -55,8 +55,8 @@
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 a3eaa6d..ade723c 100644
--- a/src/tint/reader/wgsl/lexer.cc
+++ b/src/tint/reader/wgsl/lexer.cc
@@ -412,7 +412,7 @@
// clang-format on
// -?
- int64_t sign_bit = 0;
+ uint64_t sign_bit = 0;
if (matches(end, "-")) {
sign_bit = 1;
end++;
@@ -794,7 +794,7 @@
const bool overflow = errno == ERANGE;
if (end_ptr) {
- advance(end_ptr - start_ptr);
+ advance(static_cast<size_t>(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 1ae9895..e204a62 100644
--- a/src/tint/resolver/assignment_validation_test.cc
+++ b/src/tint/resolver/assignment_validation_test.cc
@@ -32,8 +32,8 @@
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<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i));
@@ -237,13 +237,13 @@
GlobalVar("a", make_type(), ast::StorageClass::kNone,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GlobalVar("b", make_type(), ast::StorageClass::kNone,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(0u),
});
WrapInFunction(Assign(Source{{56, 78}}, "a", "b"));
@@ -260,8 +260,8 @@
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<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a")));
@@ -278,8 +278,8 @@
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<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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 0e86599..09ca0ba 100644
--- a/src/tint/resolver/atomics_test.cc
+++ b/src/tint/resolver/atomics_test.cc
@@ -48,8 +48,8 @@
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<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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 c462717..5f69277 100644
--- a/src/tint/resolver/attribute_validation_test.cc
+++ b/src/tint/resolver/attribute_validation_test.cc
@@ -508,8 +508,8 @@
TEST_F(EntryPointParameterAttributeTest, DuplicateInternalAttribute) {
auto* s = Param("s", ty.sampler(ast::SamplerKind::kSampler),
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
Disable(ast::DisabledValidation::kBindingPointCollision),
Disable(ast::DisabledValidation::kEntryPointParameter),
});
@@ -745,9 +745,9 @@
TEST_F(VariableAttributeTest, DuplicateAttribute) {
GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler),
ast::AttributeList{
- create<ast::BindingAttribute>(Source{{12, 34}}, 2),
- create<ast::GroupAttribute>(2),
- create<ast::BindingAttribute>(Source{{56, 78}}, 3),
+ create<ast::BindingAttribute>(Source{{12, 34}}, 2u),
+ create<ast::GroupAttribute>(2u),
+ create<ast::BindingAttribute>(Source{{56, 78}}, 3u),
});
WrapInFunction();
@@ -761,7 +761,7 @@
TEST_F(VariableAttributeTest, LocalVariable) {
auto* v = Var("a", ty.f32(),
ast::AttributeList{
- create<ast::BindingAttribute>(Source{{12, 34}}, 2),
+ create<ast::BindingAttribute>(Source{{12, 34}}, 2u),
});
WrapInFunction(v);
@@ -807,8 +807,8 @@
TEST_F(ConstantAttributeTest, DuplicateAttribute) {
GlobalConst("a", ty.f32(), Expr(1.23_f),
ast::AttributeList{
- create<ast::IdAttribute>(Source{{12, 34}}, 0),
- create<ast::IdAttribute>(Source{{56, 78}}, 1),
+ create<ast::IdAttribute>(Source{{12, 34}}, 0u),
+ create<ast::IdAttribute>(Source{{56, 78}}, 1u),
});
WrapInFunction();
@@ -854,8 +854,8 @@
TEST_F(OverrideAttributeTest, DuplicateAttribute) {
Override("a", ty.f32(), Expr(1.23_f),
ast::AttributeList{
- create<ast::IdAttribute>(Source{{12, 34}}, 0),
- create<ast::IdAttribute>(Source{{56, 78}}, 1),
+ create<ast::IdAttribute>(Source{{12, 34}}, 0u),
+ create<ast::IdAttribute>(Source{{56, 78}}, 1u),
});
WrapInFunction();
@@ -976,8 +976,8 @@
TEST_F(ArrayStrideTest, DuplicateAttribute) {
auto* arr = ty.array(Source{{12, 34}}, ty.i32(), 4_u,
{
- create<ast::StrideAttribute>(Source{{12, 34}}, 4_i),
- create<ast::StrideAttribute>(Source{{56, 78}}, 4_i),
+ create<ast::StrideAttribute>(Source{{12, 34}}, 4u),
+ create<ast::StrideAttribute>(Source{{56, 78}}, 4u),
});
GlobalVar("myarray", arr, ast::StorageClass::kPrivate);
@@ -1035,7 +1035,7 @@
GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler),
ast::StorageClass::kNone,
ast::AttributeList{
- create<ast::GroupAttribute>(1),
+ create<ast::GroupAttribute>(1u),
});
EXPECT_FALSE(r()->Resolve());
@@ -1047,7 +1047,7 @@
GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler),
ast::StorageClass::kNone,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
+ create<ast::BindingAttribute>(1u),
});
EXPECT_FALSE(r()->Resolve());
@@ -1059,14 +1059,14 @@
GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("F", {}, ty.void_(),
@@ -1091,14 +1091,14 @@
GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("F_A", {}, ty.void_(),
@@ -1124,8 +1124,8 @@
TEST_F(ResourceAttributeTest, BindingPointOnNonResource) {
GlobalVar(Source{{12, 34}}, "G", ty.f32(), ast::StorageClass::kPrivate,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
EXPECT_FALSE(r()->Resolve());
diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc
index 5bb6810..38f5620 100644
--- a/src/tint/resolver/builtin_test.cc
+++ b/src/tint/resolver/builtin_test.cc
@@ -187,8 +187,8 @@
if (type->IsAnyOf<ast::Texture, ast::Sampler>()) {
GlobalVar(name, type,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
} else {
@@ -618,8 +618,8 @@
auto* str = Structure("S", {Member("x", ary)});
GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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 72c5596..3737ae0 100644
--- a/src/tint/resolver/builtin_validation_test.cc
+++ b/src/tint/resolver/builtin_validation_test.cc
@@ -257,11 +257,11 @@
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<size_t>(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<size_t>(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 39d05d9..e11384e 100644
--- a/src/tint/resolver/function_validation_test.cc
+++ b/src/tint/resolver/function_validation_test.cc
@@ -754,7 +754,7 @@
TEST_F(ResolverFunctionValidationTest, ParameterVectorNoType) {
// fn f(p : vec3) {}
- Func(Source{{12, 34}}, "f", {Param("p", create<ast::Vector>(Source{{12, 34}}, nullptr, 3))},
+ Func(Source{{12, 34}}, "f", {Param("p", create<ast::Vector>(Source{{12, 34}}, nullptr, 3u))},
ty.void_(), {});
EXPECT_FALSE(r()->Resolve());
@@ -764,8 +764,8 @@
TEST_F(ResolverFunctionValidationTest, ParameterMatrixNoType) {
// fn f(p : vec3) {}
- Func(Source{{12, 34}}, "f", {Param("p", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3, 3))},
- ty.void_(), {});
+ Func(Source{{12, 34}}, "f",
+ {Param("p", create<ast::Matrix>(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 13a04c9..d50057c 100644
--- a/src/tint/resolver/host_shareable_validation_test.cc
+++ b/src/tint/resolver/host_shareable_validation_test.cc
@@ -28,8 +28,8 @@
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -46,8 +46,8 @@
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -65,8 +65,8 @@
auto* a2 = Alias("a2", ty.Of(s));
GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -87,8 +87,8 @@
GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -129,8 +129,8 @@
GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
WrapInFunction();
diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc
index 2005a42..d746a6c 100644
--- a/src/tint/resolver/intrinsic_table.cc
+++ b/src/tint/resolver/intrinsic_table.cc
@@ -1300,8 +1300,8 @@
// Conversion.
return utils::GetOrCreate(converters, match, [&]() {
auto param = builder.create<sem::Parameter>(
- 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<sem::TypeConversion>(match.return_type, param);
});
}
diff --git a/src/tint/resolver/ptr_ref_test.cc b/src/tint/resolver/ptr_ref_test.cc
index c02ab5d..037c6ff 100644
--- a/src/tint/resolver/ptr_ref_test.cc
+++ b/src/tint/resolver/ptr_ref_test.cc
@@ -63,13 +63,13 @@
auto* workgroup = GlobalVar("w", ty.i32(), ast::StorageClass::kWorkgroup);
auto* uniform = GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(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 d2f8d01..768783b 100644
--- a/src/tint/resolver/ptr_ref_validation_test.cc
+++ b/src/tint/resolver/ptr_ref_validation_test.cc
@@ -145,8 +145,8 @@
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<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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 6794921..e6cad77 100644
--- a/src/tint/resolver/resolver.cc
+++ b/src/tint/resolver/resolver.cc
@@ -857,7 +857,7 @@
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 @@
"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 @@
if (texture_index == -1) {
TINT_ICE(Resolver, diagnostics_) << "texture builtin without texture parameter";
}
- auto* texture = args[texture_index]->As<sem::VariableUser>()->Variable();
+ auto* texture = args[static_cast<size_t>(texture_index)]->As<sem::VariableUser>()->Variable();
if (!texture->Type()->UnwrapRef()->Is<sem::StorageTexture>()) {
int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler);
const sem::Variable* sampler =
- sampler_index != -1 ? args[sampler_index]->As<sem::VariableUser>()->Variable()
- : nullptr;
+ sampler_index != -1
+ ? args[static_cast<size_t>(sampler_index)]->As<sem::VariableUser>()->Variable()
+ : nullptr;
current_function_->AddTextureSamplerPair(texture, sampler);
}
}
@@ -2247,7 +2248,7 @@
}
}
- auto size = std::max<uint64_t>(count, 1u) * stride;
+ auto size = std::max<uint64_t>(static_cast<uint32_t>(count), 1u) * stride;
if (size > std::numeric_limits<uint32_t>::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 2f0992c..9b56c31 100644
--- a/src/tint/resolver/resolver_test.cc
+++ b/src/tint/resolver/resolver_test.cc
@@ -779,8 +779,8 @@
auto* sb_var =
GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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 @@
auto* sb_var =
GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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 @@
auto* t = ty.sampler(ast::SamplerKind::kSampler);
auto* var = GlobalVar("var", t,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1750,8 +1750,8 @@
auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
auto* var = GlobalVar("var", t,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1775,8 +1775,8 @@
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<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1789,10 +1789,10 @@
// @group(3) @binding(4) var s2 : sampler;
auto* s1 = GlobalVar(
Sym(), ty.sampler(ast::SamplerKind::kSampler),
- ast::AttributeList{create<ast::GroupAttribute>(1), create<ast::BindingAttribute>(2)});
+ ast::AttributeList{create<ast::GroupAttribute>(1u), create<ast::BindingAttribute>(2u)});
auto* s2 = GlobalVar(
Sym(), ty.sampler(ast::SamplerKind::kSampler),
- ast::AttributeList{create<ast::GroupAttribute>(3), create<ast::BindingAttribute>(4)});
+ ast::AttributeList{create<ast::GroupAttribute>(3u), create<ast::BindingAttribute>(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 1f5f024..0e2be29 100644
--- a/src/tint/resolver/storage_class_validation_test.cc
+++ b/src/tint/resolver/storage_class_validation_test.cc
@@ -87,8 +87,8 @@
// var<storage> g : bool;
GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kStorage,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -104,8 +104,8 @@
GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate),
ast::StorageClass::kStorage,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -120,8 +120,8 @@
// var<storage> g : i32;
GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kStorage,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -131,8 +131,8 @@
// var<storage> g : vec4<f32>;
GlobalVar(Source{{56, 78}}, "g", ty.vec4<f32>(), ast::StorageClass::kStorage,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -144,8 +144,8 @@
auto* a = ty.array(ty.Of(s), 3_u);
GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -157,8 +157,8 @@
auto* a = Alias("a", ty.bool_());
GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kStorage,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -186,8 +186,8 @@
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<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_TRUE(r()->Resolve());
@@ -202,8 +202,8 @@
auto* a2 = Alias("a2", ty.Of(a1));
GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_TRUE(r()->Resolve());
@@ -217,8 +217,8 @@
GlobalVar(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -232,8 +232,8 @@
// var<uniform> g : bool;
GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -249,8 +249,8 @@
GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate),
ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -265,8 +265,8 @@
// var<uniform> g : i32;
GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -276,8 +276,8 @@
// var<uniform> g : vec4<f32>;
GlobalVar(Source{{56, 78}}, "g", ty.vec4<f32>(), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -292,8 +292,8 @@
auto* a = ty.array(ty.Of(s), 3_u);
GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -305,8 +305,8 @@
auto* a = Alias("a", ty.bool_());
GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_FALSE(r()->Resolve());
@@ -323,8 +323,8 @@
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<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -338,8 +338,8 @@
auto* a1 = Alias("a1", ty.Of(s));
GlobalVar(Source{{56, 78}}, "g", ty.Of(a1), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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 c524f71..5a929a5 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 @@
auto* s = Structure("S", {Member("a", ty.f32())});
GlobalVar("x", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GlobalVar("y", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(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 5b0023d..1c857cd 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, InferVec2ElementTypeFromScalars) {
Enable(ast::Extension::kF16);
- auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), Expr(true), Expr(false));
- auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_i), Expr(2_i));
- auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_u), Expr(2_u));
- auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_f), Expr(2_f));
- auto* vec2_f16 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_h), Expr(2_h));
+ auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2u), Expr(true), Expr(false));
+ auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2u), Expr(1_i), Expr(2_i));
+ auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2u), Expr(1_u), Expr(2_u));
+ auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2u), Expr(1_f), Expr(2_f));
+ auto* vec2_f16 = Construct(create<ast::Vector>(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, InferVec2ElementTypeFromVec2) {
Enable(ast::Extension::kF16);
- auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), vec2<bool>(true, false));
- auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), vec2<i32>(1_i, 2_i));
- auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), vec2<u32>(1_u, 2_u));
- auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), vec2<f32>(1_f, 2_f));
- auto* vec2_f16 = Construct(create<ast::Vector>(nullptr, 2), vec2<f16>(1_h, 2_h));
+ auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2u), vec2<bool>(true, false));
+ auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2u), vec2<i32>(1_i, 2_i));
+ auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2u), vec2<u32>(1_u, 2_u));
+ auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2u), vec2<f32>(1_f, 2_f));
+ auto* vec2_f16 = Construct(create<ast::Vector>(nullptr, 2u), vec2<f16>(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 @@
Enable(ast::Extension::kF16);
auto* vec3_bool =
- Construct(create<ast::Vector>(nullptr, 3), Expr(true), Expr(false), Expr(true));
- auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_i), Expr(2_i), Expr(3_i));
- auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_u), Expr(2_u), Expr(3_u));
- auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_f), Expr(2_f), Expr(3_f));
- auto* vec3_f16 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_h), Expr(2_h), Expr(3_h));
+ Construct(create<ast::Vector>(nullptr, 3u), Expr(true), Expr(false), Expr(true));
+ auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3u), Expr(1_i), Expr(2_i), Expr(3_i));
+ auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3u), Expr(1_u), Expr(2_u), Expr(3_u));
+ auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3u), Expr(1_f), Expr(2_f), Expr(3_f));
+ auto* vec3_f16 = Construct(create<ast::Vector>(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, InferVec3ElementTypeFromVec3) {
Enable(ast::Extension::kF16);
- auto* vec3_bool = Construct(create<ast::Vector>(nullptr, 3), vec3<bool>(true, false, true));
- auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), vec3<i32>(1_i, 2_i, 3_i));
- auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), vec3<u32>(1_u, 2_u, 3_u));
- auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), vec3<f32>(1_f, 2_f, 3_f));
- auto* vec3_f16 = Construct(create<ast::Vector>(nullptr, 3), vec3<f16>(1_h, 2_h, 3_h));
+ auto* vec3_bool = Construct(create<ast::Vector>(nullptr, 3u), vec3<bool>(true, false, true));
+ auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3u), vec3<i32>(1_i, 2_i, 3_i));
+ auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3u), vec3<u32>(1_u, 2_u, 3_u));
+ auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3u), vec3<f32>(1_f, 2_f, 3_f));
+ auto* vec3_f16 = Construct(create<ast::Vector>(nullptr, 3u), vec3<f16>(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 @@
Enable(ast::Extension::kF16);
auto* vec3_bool =
- Construct(create<ast::Vector>(nullptr, 3), Expr(true), vec2<bool>(false, true));
- auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_i), vec2<i32>(2_i, 3_i));
- auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_u), vec2<u32>(2_u, 3_u));
- auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_f), vec2<f32>(2_f, 3_f));
- auto* vec3_f16 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_h), vec2<f16>(2_h, 3_h));
+ Construct(create<ast::Vector>(nullptr, 3u), Expr(true), vec2<bool>(false, true));
+ auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3u), Expr(1_i), vec2<i32>(2_i, 3_i));
+ auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3u), Expr(1_u), vec2<u32>(2_u, 3_u));
+ auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3u), Expr(1_f), vec2<f32>(2_f, 3_f));
+ auto* vec3_f16 = Construct(create<ast::Vector>(nullptr, 3u), Expr(1_h), vec2<f16>(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, InferVec4ElementTypeFromScalars) {
Enable(ast::Extension::kF16);
- auto* vec4_bool = Construct(create<ast::Vector>(nullptr, 4), Expr(true), Expr(false),
+ auto* vec4_bool = Construct(create<ast::Vector>(nullptr, 4u), Expr(true), Expr(false),
Expr(true), Expr(false));
auto* vec4_i32 =
- Construct(create<ast::Vector>(nullptr, 4), Expr(1_i), Expr(2_i), Expr(3_i), Expr(4_i));
+ Construct(create<ast::Vector>(nullptr, 4u), Expr(1_i), Expr(2_i), Expr(3_i), Expr(4_i));
auto* vec4_u32 =
- Construct(create<ast::Vector>(nullptr, 4), Expr(1_u), Expr(2_u), Expr(3_u), Expr(4_u));
+ Construct(create<ast::Vector>(nullptr, 4u), Expr(1_u), Expr(2_u), Expr(3_u), Expr(4_u));
auto* vec4_f32 =
- Construct(create<ast::Vector>(nullptr, 4), Expr(1_f), Expr(2_f), Expr(3_f), Expr(4_f));
+ Construct(create<ast::Vector>(nullptr, 4u), Expr(1_f), Expr(2_f), Expr(3_f), Expr(4_f));
auto* vec4_f16 =
- Construct(create<ast::Vector>(nullptr, 4), Expr(1_h), Expr(2_h), Expr(3_h), Expr(4_h));
+ Construct(create<ast::Vector>(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 @@
Enable(ast::Extension::kF16);
auto* vec4_bool =
- Construct(create<ast::Vector>(nullptr, 4), vec4<bool>(true, false, true, false));
- auto* vec4_i32 = Construct(create<ast::Vector>(nullptr, 4), vec4<i32>(1_i, 2_i, 3_i, 4_i));
- auto* vec4_u32 = Construct(create<ast::Vector>(nullptr, 4), vec4<u32>(1_u, 2_u, 3_u, 4_u));
- auto* vec4_f32 = Construct(create<ast::Vector>(nullptr, 4), vec4<f32>(1_f, 2_f, 3_f, 4_f));
- auto* vec4_f16 = Construct(create<ast::Vector>(nullptr, 4), vec4<f16>(1_h, 2_h, 3_h, 4_h));
+ Construct(create<ast::Vector>(nullptr, 4u), vec4<bool>(true, false, true, false));
+ auto* vec4_i32 = Construct(create<ast::Vector>(nullptr, 4u), vec4<i32>(1_i, 2_i, 3_i, 4_i));
+ auto* vec4_u32 = Construct(create<ast::Vector>(nullptr, 4u), vec4<u32>(1_u, 2_u, 3_u, 4_u));
+ auto* vec4_f32 = Construct(create<ast::Vector>(nullptr, 4u), vec4<f32>(1_f, 2_f, 3_f, 4_f));
+ auto* vec4_f16 = Construct(create<ast::Vector>(nullptr, 4u), vec4<f16>(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 @@
Enable(ast::Extension::kF16);
auto* vec4_bool =
- Construct(create<ast::Vector>(nullptr, 4), Expr(true), vec3<bool>(false, true, false));
+ Construct(create<ast::Vector>(nullptr, 4u), Expr(true), vec3<bool>(false, true, false));
auto* vec4_i32 =
- Construct(create<ast::Vector>(nullptr, 4), Expr(1_i), vec3<i32>(2_i, 3_i, 4_i));
+ Construct(create<ast::Vector>(nullptr, 4u), Expr(1_i), vec3<i32>(2_i, 3_i, 4_i));
auto* vec4_u32 =
- Construct(create<ast::Vector>(nullptr, 4), Expr(1_u), vec3<u32>(2_u, 3_u, 4_u));
+ Construct(create<ast::Vector>(nullptr, 4u), Expr(1_u), vec3<u32>(2_u, 3_u, 4_u));
auto* vec4_f32 =
- Construct(create<ast::Vector>(nullptr, 4), Expr(1_f), vec3<f32>(2_f, 3_f, 4_f));
+ Construct(create<ast::Vector>(nullptr, 4u), Expr(1_f), vec3<f32>(2_f, 3_f, 4_f));
auto* vec4_f16 =
- Construct(create<ast::Vector>(nullptr, 4), Expr(1_h), vec3<f16>(2_h, 3_h, 4_h));
+ Construct(create<ast::Vector>(nullptr, 4u), Expr(1_h), vec3<f16>(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, InferVec4ElementTypeFromVec2AndVec2) {
Enable(ast::Extension::kF16);
- auto* vec4_bool = Construct(create<ast::Vector>(nullptr, 4), vec2<bool>(true, false),
+ auto* vec4_bool = Construct(create<ast::Vector>(nullptr, 4u), vec2<bool>(true, false),
vec2<bool>(true, false));
auto* vec4_i32 =
- Construct(create<ast::Vector>(nullptr, 4), vec2<i32>(1_i, 2_i), vec2<i32>(3_i, 4_i));
+ Construct(create<ast::Vector>(nullptr, 4u), vec2<i32>(1_i, 2_i), vec2<i32>(3_i, 4_i));
auto* vec4_u32 =
- Construct(create<ast::Vector>(nullptr, 4), vec2<u32>(1_u, 2_u), vec2<u32>(3_u, 4_u));
+ Construct(create<ast::Vector>(nullptr, 4u), vec2<u32>(1_u, 2_u), vec2<u32>(3_u, 4_u));
auto* vec4_f32 =
- Construct(create<ast::Vector>(nullptr, 4), vec2<f32>(1_f, 2_f), vec2<f32>(3_f, 4_f));
+ Construct(create<ast::Vector>(nullptr, 4u), vec2<f32>(1_f, 2_f), vec2<f32>(3_f, 4_f));
auto* vec4_f16 =
- Construct(create<ast::Vector>(nullptr, 4), vec2<f16>(1_h, 2_h), vec2<f16>(3_h, 4_h));
+ Construct(create<ast::Vector>(nullptr, 4u), vec2<f16>(1_h, 2_h), vec2<f16>(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, CannotInferVectorElementTypeWithoutArgs) {
- WrapInFunction(Construct(Source{{12, 34}}, create<ast::Vector>(nullptr, 3)));
+ WrapInFunction(Construct(Source{{12, 34}}, create<ast::Vector>(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<ast::Vector>(nullptr, 2),
+ WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 2u),
Expr(Source{{1, 2}}, 1_i), //
Expr(Source{{1, 3}}, 2_u)));
@@ -2194,7 +2194,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScalarsMismatch) {
- WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 3),
+ WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(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, CannotInferVec3ElementTypeFromScalarAndVec2Mismatch) {
- WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 3),
+ WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 3u),
Expr(Source{{1, 2}}, 1_i), //
Construct(Source{{1, 3}}, ty.vec2<f32>(), 2_f, 3_f)));
@@ -2215,7 +2215,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScalarsMismatch) {
- WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4),
+ WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(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, CannotInferVec4ElementTypeFromScalarAndVec3Mismatch) {
- WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4),
+ WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4u),
Expr(Source{{1, 2}}, 1_i), //
Construct(Source{{1, 3}}, ty.vec3<u32>(), 2_u, 3_u, 4_u)));
@@ -2237,7 +2237,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromVec2AndVec2Mismatch) {
- WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4),
+ WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4u),
Construct(Source{{1, 2}}, ty.vec2<i32>(), 3_i, 4_i), //
Construct(Source{{1, 3}}, ty.vec2<u32>(), 3_u, 4_u)));
diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc
index 602cb6e..e746e51 100644
--- a/src/tint/resolver/type_validation_test.cc
+++ b/src/tint/resolver/type_validation_test.cc
@@ -402,7 +402,7 @@
// a: vec3;
// };
- Structure("S", {Member("a", create<ast::Vector>(Source{{12, 34}}, nullptr, 3))});
+ Structure("S", {Member("a", create<ast::Vector>(Source{{12, 34}}, nullptr, 3u))});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing vector element type");
@@ -412,7 +412,7 @@
// struct S {
// a: mat3x3;
// };
- Structure("S", {Member("a", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3, 3))});
+ Structure("S", {Member("a", create<ast::Matrix>(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 18ef8c7..20cf1ea 100644
--- a/src/tint/resolver/validation_test.cc
+++ b/src/tint/resolver/validation_test.cc
@@ -326,8 +326,8 @@
auto* t = ty.sampler(ast::SamplerKind::kSampler);
GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
EXPECT_FALSE(r()->Resolve());
@@ -340,8 +340,8 @@
auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
EXPECT_FALSE(r()->Resolve()) << r()->error();
diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc
index 87bf529..0048d74 100644
--- a/src/tint/resolver/validator.cc
+++ b/src/tint/resolver/validator.cc
@@ -1609,7 +1609,7 @@
return true;
}
std::string name = sem::str(usage);
- auto* arg = call->Arguments()[index];
+ auto* arg = call->Arguments()[static_cast<size_t>(index)];
if (auto values = arg->ConstantValue()) {
// Assert that the constant values are of the expected type.
if (!values.Type()->IsAnyOf<sem::I32, sem::Vector>() ||
@@ -1631,7 +1631,8 @@
return ast::TraverseAction::Stop;
});
if (is_const_expr) {
- auto vector = builtin->Parameters()[index]->Type()->Is<sem::Vector>();
+ auto vector =
+ builtin->Parameters()[static_cast<size_t>(index)]->Type()->Is<sem::Vector>();
for (size_t i = 0, n = values.ElementCount(); i < n; i++) {
auto value = values.Element<AInt>(i).value;
if (value < min || value > max) {
diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc
index f5622c7..2ee5979 100644
--- a/src/tint/resolver/variable_test.cc
+++ b/src/tint/resolver/variable_test.cc
@@ -472,8 +472,8 @@
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<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 4_i);
@@ -1049,18 +1049,18 @@
auto* workgroup = GlobalVar("w", ty.i32(), ast::StorageClass::kWorkgroup);
auto* uniform = GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(0u),
});
auto* handle = GlobalVar("h", ty.depth_texture(ast::TextureDimension::k2d),
ast::AttributeList{
- create<ast::BindingAttribute>(2),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(2u),
+ create<ast::GroupAttribute>(0u),
});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1085,8 +1085,8 @@
auto* storage =
GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(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 51b430f..79b269c 100644
--- a/src/tint/resolver/variable_validation_test.cc
+++ b/src/tint/resolver/variable_validation_test.cc
@@ -245,8 +245,8 @@
auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i);
@@ -318,7 +318,7 @@
TEST_F(ResolverVariableValidationTest, VectorConstNoType) {
// const a : mat3x3 = mat3x3<f32>();
- WrapInFunction(Const("a", create<ast::Vector>(Source{{12, 34}}, nullptr, 3), vec3<f32>()));
+ WrapInFunction(Const("a", create<ast::Vector>(Source{{12, 34}}, nullptr, 3u), vec3<f32>()));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing vector element type");
@@ -326,7 +326,7 @@
TEST_F(ResolverVariableValidationTest, VectorLetNoType) {
// let a : mat3x3 = mat3x3<f32>();
- WrapInFunction(Let("a", create<ast::Vector>(Source{{12, 34}}, nullptr, 3), vec3<f32>()));
+ WrapInFunction(Let("a", create<ast::Vector>(Source{{12, 34}}, nullptr, 3u), vec3<f32>()));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing vector element type");
@@ -334,7 +334,7 @@
TEST_F(ResolverVariableValidationTest, VectorVarNoType) {
// var a : mat3x3;
- WrapInFunction(Var("a", create<ast::Vector>(Source{{12, 34}}, nullptr, 3)));
+ WrapInFunction(Var("a", create<ast::Vector>(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, MatrixConstNoType) {
// const a : mat3x3 = mat3x3<f32>();
- WrapInFunction(Const("a", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3, 3), mat3x3<f32>()));
+ WrapInFunction(
+ Const("a", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3u, 3u), mat3x3<f32>()));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type");
@@ -350,7 +351,7 @@
TEST_F(ResolverVariableValidationTest, MatrixLetNoType) {
// let a : mat3x3 = mat3x3<f32>();
- WrapInFunction(Let("a", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3, 3), mat3x3<f32>()));
+ WrapInFunction(Let("a", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3u, 3u), mat3x3<f32>()));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type");
@@ -358,7 +359,7 @@
TEST_F(ResolverVariableValidationTest, MatrixVarNoType) {
// var a : mat3x3;
- WrapInFunction(Var("a", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3, 3)));
+ WrapInFunction(Var("a", create<ast::Matrix>(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 841d96a..5439600 100644
--- a/src/tint/sem/variable.cc
+++ b/src/tint/sem/variable.cc
@@ -91,4 +91,6 @@
}
}
+VariableUser::~VariableUser() = default;
+
} // namespace tint::sem
diff --git a/src/tint/sem/variable.h b/src/tint/sem/variable.h
index 6d95865..3b5bd0c 100644
--- a/src/tint/sem/variable.h
+++ b/src/tint/sem/variable.h
@@ -226,6 +226,7 @@
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 5f711de..4e31789 100644
--- a/src/tint/transform/combine_samplers.cc
+++ b/src/tint/transform/combine_samplers.cc
@@ -225,19 +225,21 @@
// Replace all texture builtin calls.
if (auto* builtin = call->Target()->As<sem::Builtin>()) {
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<size_t>(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<sem::StorageTexture>()) {
return nullptr;
}
const sem::Expression* sampler =
- sampler_index != -1 ? call->Arguments()[sampler_index] : nullptr;
+ sampler_index != -1 ? call->Arguments()[static_cast<size_t>(sampler_index)]
+ : nullptr;
auto* texture_var = texture->As<sem::VariableUser>()->Variable();
auto* sampler_var =
sampler ? sampler->As<sem::VariableUser>()->Variable() : nullptr;
diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc
index 32ad153..48dae27 100644
--- a/src/tint/transform/decompose_memory_access.cc
+++ b/src/tint/transform/decompose_memory_access.cc
@@ -377,10 +377,10 @@
auto* lhs_lit = tint::As<OffsetLiteral>(lhs);
auto* rhs_lit = tint::As<OffsetLiteral>(rhs);
if (lhs_lit && lhs_lit->literal == 0) {
- return offsets_.Create<OffsetLiteral>(0);
+ return offsets_.Create<OffsetLiteral>(0u);
}
if (rhs_lit && rhs_lit->literal == 0) {
- return offsets_.Create<OffsetLiteral>(0);
+ return offsets_.Create<OffsetLiteral>(0u);
}
if (lhs_lit && lhs_lit->literal == 1) {
return rhs;
@@ -831,7 +831,7 @@
if (swizzle->Indices().size() == 1) {
if (auto access = state.TakeAccess(accessor->structure)) {
auto* vec_ty = access.type->As<sem::Vector>();
- 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 a2bf26d..daff16f 100644
--- a/src/tint/transform/decompose_strided_matrix_test.cc
+++ b/src/tint/transform/decompose_strided_matrix_test.cc
@@ -71,8 +71,8 @@
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
- b.create<ast::StructMemberOffsetAttribute>(16),
- b.create<ast::StrideAttribute>(32),
+ b.create<ast::StructMemberOffsetAttribute>(16u),
+ b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -127,8 +127,8 @@
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
- b.create<ast::StructMemberOffsetAttribute>(16),
- b.create<ast::StrideAttribute>(32),
+ b.create<ast::StructMemberOffsetAttribute>(16u),
+ b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -180,8 +180,8 @@
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
- b.create<ast::StructMemberOffsetAttribute>(16),
- b.create<ast::StrideAttribute>(8),
+ b.create<ast::StructMemberOffsetAttribute>(16u),
+ b.create<ast::StrideAttribute>(8u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -233,8 +233,8 @@
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
- b.create<ast::StructMemberOffsetAttribute>(8),
- b.create<ast::StrideAttribute>(32),
+ b.create<ast::StructMemberOffsetAttribute>(8u),
+ b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -290,8 +290,8 @@
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
- b.create<ast::StructMemberOffsetAttribute>(16),
- b.create<ast::StrideAttribute>(32),
+ b.create<ast::StructMemberOffsetAttribute>(16u),
+ b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -344,8 +344,8 @@
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
- b.create<ast::StructMemberOffsetAttribute>(8),
- b.create<ast::StrideAttribute>(32),
+ b.create<ast::StructMemberOffsetAttribute>(8u),
+ b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -402,8 +402,8 @@
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
- b.create<ast::StructMemberOffsetAttribute>(8),
- b.create<ast::StrideAttribute>(32),
+ b.create<ast::StructMemberOffsetAttribute>(8u),
+ b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -461,8 +461,8 @@
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
- b.create<ast::StructMemberOffsetAttribute>(8),
- b.create<ast::StrideAttribute>(32),
+ b.create<ast::StructMemberOffsetAttribute>(8u),
+ b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -532,8 +532,8 @@
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
- b.create<ast::StructMemberOffsetAttribute>(8),
- b.create<ast::StrideAttribute>(32),
+ b.create<ast::StructMemberOffsetAttribute>(8u),
+ b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
@@ -585,8 +585,8 @@
"S", {
b.Member("m", b.ty.mat2x2<f32>(),
{
- b.create<ast::StructMemberOffsetAttribute>(8),
- b.create<ast::StrideAttribute>(32),
+ b.create<ast::StructMemberOffsetAttribute>(8u),
+ b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
diff --git a/src/tint/transform/robustness.cc b/src/tint/transform/robustness.cc
index aab1e0c..2e1cc40 100644
--- a/src/tint/transform/robustness.cc
+++ b/src/tint/transform/robustness.cc
@@ -223,9 +223,9 @@
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<size_t>(texture_idx)];
+ auto* coords_arg = expr->args[static_cast<size_t>(coords_idx)];
+ auto* coords_ty = builtin->Parameters()[static_cast<size_t>(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 @@
std::function<const ast::Expression*()> level_arg;
if (level_idx >= 0) {
level_arg = [&] {
- auto* arg = expr->args[level_idx];
+ auto* arg = expr->args[static_cast<size_t>(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 @@
// Clamp the array_index argument, if provided
if (array_idx >= 0) {
- auto* arg = expr->args[array_idx];
+ auto* arg = expr->args[static_cast<size_t>(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 @@
// Clamp the level argument, if provided
if (level_idx >= 0) {
- auto* arg = expr->args[level_idx];
+ auto* arg = expr->args[static_cast<size_t>(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 600019c..77ea3e3 100644
--- a/src/tint/utils/block_allocator_test.cc
+++ b/src/tint/utils/block_allocator_test.cc
@@ -67,7 +67,7 @@
TEST_F(BlockAllocatorTest, MoveConstruct) {
using Allocator = BlockAllocator<LifetimeCounter>;
- 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, MoveAssign) {
using Allocator = BlockAllocator<LifetimeCounter>;
- 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 34965c6..b3cca3c 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 bc89d1f..7755ae3 100644
--- a/src/tint/writer/append_vector.cc
+++ b/src/tint/writer/append_vector.cc
@@ -135,7 +135,7 @@
auto* scalar_cast_ast = b->Construct(packed_el_ast_ty, scalar_ast);
auto* scalar_cast_target = b->create<sem::TypeConversion>(
packed_el_sem_ty,
- b->create<sem::Parameter>(nullptr, 0, scalar_sem->Type()->UnwrapRef(),
+ b->create<sem::Parameter>(nullptr, 0u, scalar_sem->Type()->UnwrapRef(),
ast::StorageClass::kNone, ast::Access::kUndefined));
auto* scalar_cast_sem = b->create<sem::Call>(
scalar_cast_ast, scalar_cast_target, std::vector<const sem::Expression*>{scalar_sem},
diff --git a/src/tint/writer/float_to_string_test.cc b/src/tint/writer/float_to_string_test.cc
index 2596be7..b629b50 100644
--- a/src/tint/writer/float_to_string_test.cc
+++ b/src/tint/writer/float_to_string_test.cc
@@ -27,7 +27,7 @@
// - 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 3935fe39..022db4b 100644
--- a/src/tint/writer/glsl/generator_impl.cc
+++ b/src/tint/writer/glsl/generator_impl.cc
@@ -1349,8 +1349,8 @@
// 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<size_t>(idx)] : nullptr;
};
auto* texture = arg(Usage::kTexture);
@@ -2138,7 +2138,7 @@
// 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 a25d023..a70e238 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 @@
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
Func("sub_func",
@@ -405,8 +405,8 @@
GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone,
@@ -450,8 +450,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@@ -500,8 +500,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@@ -551,8 +551,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
Func("frag_main", {}, ty.void_(),
@@ -599,8 +599,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
Func("frag_main", {}, ty.void_(),
@@ -643,8 +643,8 @@
auto* s = Structure("S", {Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
Func("sub_func", {Param("param", ty.f32())}, ty.f32(),
@@ -692,8 +692,8 @@
auto* s = Structure("S", {Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
Func("sub_func", {Param("param", ty.f32())}, ty.f32(),
@@ -921,8 +921,8 @@
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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 11e0e38..875d211 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 @@
b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- b.create<ast::BindingAttribute>(0),
- b.create<ast::GroupAttribute>(1),
+ b.create<ast::BindingAttribute>(0u),
+ b.create<ast::GroupAttribute>(1u),
});
}
diff --git a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc
index 13f2762..ae1b0ba 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 @@
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -71,8 +71,8 @@
});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -113,8 +113,8 @@
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(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 e2a6f97..7a13b66 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 @@
});
ctx->GlobalVar("nephews", ctx->ty.Of(nephews), ast::StorageClass::kStorage,
ast::AttributeList{
- ctx->create<ast::BindingAttribute>(0),
- ctx->create<ast::GroupAttribute>(0),
+ ctx->create<ast::BindingAttribute>(0u),
+ ctx->create<ast::GroupAttribute>(0u),
});
}
diff --git a/src/tint/writer/glsl/generator_impl_type_test.cc b/src/tint/writer/glsl/generator_impl_type_test.cc
index 4242368..acf28ff 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 @@
GlobalVar("tex", t,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
@@ -299,8 +299,8 @@
GlobalVar("tex", t,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
@@ -342,8 +342,8 @@
GlobalVar("tex", t,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
@@ -476,8 +476,8 @@
GlobalVar("tex", t,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(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 fd502d1..3e4352b 100644
--- a/src/tint/writer/hlsl/generator_impl.cc
+++ b/src/tint/writer/hlsl/generator_impl.cc
@@ -2107,7 +2107,7 @@
// 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<size_t>(idx)] : nullptr;
};
auto* texture = arg(Usage::kTexture);
@@ -3039,7 +3039,7 @@
// 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 ee3acfc..5c7e427 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 @@
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 b0e1495..85647a5 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 @@
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
Func("sub_func",
@@ -395,8 +395,8 @@
GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone,
@@ -433,8 +433,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@@ -469,8 +469,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@@ -505,8 +505,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
Func("frag_main", {}, ty.void_(),
@@ -539,8 +539,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
Func("frag_main", {}, ty.void_(),
@@ -569,8 +569,8 @@
auto* s = Structure("S", {Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
Func("sub_func",
@@ -615,8 +615,8 @@
auto* s = Structure("S", {Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(1),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(1u),
});
Func("sub_func",
@@ -861,8 +861,8 @@
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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 3114174..8149b7f 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 @@
b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- b.create<ast::BindingAttribute>(0),
- b.create<ast::GroupAttribute>(1),
+ b.create<ast::BindingAttribute>(0u),
+ b.create<ast::GroupAttribute>(1u),
});
}
diff --git a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc
index a9f6617..3bb1cec 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 @@
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -66,8 +66,8 @@
});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -102,8 +102,8 @@
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
auto* p = Let("p", nullptr, AddressOf("b"));
@@ -142,13 +142,13 @@
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(2),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(2u),
+ create<ast::GroupAttribute>(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 43825a9..614d8f1 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 @@
});
GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -289,8 +289,8 @@
GlobalVar("tex", t,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
@@ -319,8 +319,8 @@
GlobalVar("tex", t,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
@@ -362,8 +362,8 @@
GlobalVar("tex", t,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(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 c649090..f5ffa6c 100644
--- a/src/tint/writer/msl/generator_impl.cc
+++ b/src/tint/writer/msl/generator_impl.cc
@@ -759,7 +759,7 @@
return false;
}
- int i = 0;
+ size_t i = 0;
for (auto* arg : call->Arguments()) {
if (i > 0) {
out << ", ";
@@ -920,7 +920,7 @@
// 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<size_t>(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 e3bfd7f..e520d7a 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 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@@ -379,8 +379,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@@ -417,8 +417,8 @@
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
Func("sub_func",
@@ -471,8 +471,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
Func("sub_func",
@@ -526,8 +526,8 @@
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
Func("sub_func",
@@ -667,8 +667,8 @@
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
{
diff --git a/src/tint/writer/msl/generator_impl_sanitizer_test.cc b/src/tint/writer/msl/generator_impl_sanitizer_test.cc
index 96e9473..1514373 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 @@
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -87,8 +87,8 @@
});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -144,8 +144,8 @@
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
auto* p = Let("p", nullptr, AddressOf("b"));
@@ -204,13 +204,13 @@
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(0u),
});
GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(2),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(2u),
+ create<ast::GroupAttribute>(0u),
});
Func("a_func", {}, ty.void_(),
@@ -269,13 +269,13 @@
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(0u),
});
GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(2),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(2u),
+ create<ast::GroupAttribute>(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 38a6ef7..070b1bb 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 @@
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -358,8 +358,8 @@
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -452,8 +452,8 @@
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -538,8 +538,8 @@
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -602,8 +602,8 @@
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -663,8 +663,8 @@
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -830,8 +830,8 @@
auto* s = ty.storage_texture(params.dim, ast::TexelFormat::kR32Float, ast::Access::kWrite);
GlobalVar("test_var", s,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc
index be33426..fea7a14 100644
--- a/src/tint/writer/spirv/builder.cc
+++ b/src/tint/writer/spirv/builder.cc
@@ -533,7 +533,7 @@
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 @@
// 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<size_t>(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 36c152e..c4bf27e 100644
--- a/src/tint/writer/spirv/builder_builtin_test.cc
+++ b/src/tint/writer/spirv/builder_builtin_test.cc
@@ -453,14 +453,14 @@
auto* tex = GlobalVar("texture", t,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
auto* sampler = GlobalVar("sampler", s,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(0u),
});
auto* expr1 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1_f, 2_f), 2_f);
@@ -1587,8 +1587,8 @@
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a")));
@@ -1634,8 +1634,8 @@
});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a")));
@@ -1678,8 +1678,8 @@
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
auto* p = Let("p", nullptr, AddressOf("b"));
@@ -1738,8 +1738,8 @@
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
auto* p = Let("p", nullptr, AddressOf(Deref(AddressOf("b"))));
@@ -1803,8 +1803,8 @@
});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -1867,8 +1867,8 @@
});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -1939,8 +1939,8 @@
});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -2012,8 +2012,8 @@
});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -2087,8 +2087,8 @@
});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(2u),
});
Func("a_func", {}, ty.void_(),
@@ -2163,8 +2163,8 @@
});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(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 b374a6c..91fa71a 100644
--- a/src/tint/writer/spirv/builder_function_test.cc
+++ b/src/tint/writer/spirv/builder_function_test.cc
@@ -200,8 +200,8 @@
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
{
diff --git a/src/tint/writer/spirv/builder_global_variable_test.cc b/src/tint/writer/spirv/builder_global_variable_test.cc
index 9e9913c..05f6929 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 @@
auto* v =
GlobalVar("var", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr,
ast::AttributeList{
- create<ast::BindingAttribute>(2),
- create<ast::GroupAttribute>(3),
+ create<ast::BindingAttribute>(2u),
+ create<ast::GroupAttribute>(3u),
});
spirv::Builder& b = Build();
@@ -450,8 +450,8 @@
GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = SanitizeAndBuild();
@@ -491,8 +491,8 @@
auto* B = Alias("B", ty.Of(A));
GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = SanitizeAndBuild();
@@ -530,8 +530,8 @@
auto* B = Alias("B", ty.Of(A));
GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = SanitizeAndBuild();
@@ -568,13 +568,13 @@
auto* A = Structure("A", {Member("a", ty.i32())});
GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::GroupAttribute>(0),
- create<ast::BindingAttribute>(0),
+ create<ast::GroupAttribute>(0u),
+ create<ast::BindingAttribute>(0u),
});
GlobalVar("c", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::GroupAttribute>(1),
- create<ast::BindingAttribute>(0),
+ create<ast::GroupAttribute>(1u),
+ create<ast::BindingAttribute>(0u),
});
spirv::Builder& b = SanitizeAndBuild();
@@ -614,8 +614,8 @@
auto* var_a = GlobalVar("a", type,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = Build();
@@ -645,16 +645,16 @@
ast::Access::kReadWrite);
auto* var_a = GlobalVar("a", type_a, ast::StorageClass::kNone,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(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 44d6374..b4bff9b 100644
--- a/src/tint/writer/spirv/builder_type_test.cc
+++ b/src/tint/writer/spirv/builder_type_test.cc
@@ -30,8 +30,8 @@
auto* str = Structure("S", {Member("x", ary)});
GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = Build();
@@ -50,8 +50,8 @@
auto* str = Structure("S", {Member("x", ary)});
GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = Build();
@@ -783,8 +783,8 @@
GlobalVar("test_var", s,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = Build();
@@ -802,8 +802,8 @@
GlobalVar("test_var", s,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = Build();
@@ -821,8 +821,8 @@
GlobalVar("test_var", s,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = Build();
@@ -840,8 +840,8 @@
GlobalVar("test_var", s,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = Build();
@@ -859,8 +859,8 @@
GlobalVar("test_var", s,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = Build();
@@ -878,8 +878,8 @@
GlobalVar("test_var", s,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = Build();
@@ -897,8 +897,8 @@
GlobalVar("test_var", s,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
spirv::Builder& b = Build();
diff --git a/src/tint/writer/text_generator.cc b/src/tint/writer/text_generator.cc
index 5e4e93f..1a1fa5a 100644
--- a/src/tint/writer/text_generator.cc
+++ b/src/tint/writer/text_generator.cc
@@ -84,7 +84,7 @@
<< " lines.size(): " << lines.size();
return;
}
- lines.insert(lines.begin() + before, Line{indent, line});
+ lines.insert(lines.begin() + static_cast<int64_t>(before), Line{indent, line});
}
void TextGenerator::TextBuffer::Append(const TextBuffer& tb) {
@@ -105,7 +105,8 @@
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<int64_t>(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 a448827..26e0a29 100644
--- a/src/tint/writer/wgsl/generator_impl.cc
+++ b/src/tint/writer/wgsl/generator_impl.cc
@@ -714,7 +714,7 @@
[&](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 17439c7..0673858 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 @@
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(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 78b5d52..ef9e11c 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_Global_Sampler) {
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler),
ast::AttributeList{
- create<ast::GroupAttribute>(0),
- create<ast::BindingAttribute>(0),
+ create<ast::GroupAttribute>(0u),
+ create<ast::BindingAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -119,8 +119,8 @@
auto* st = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
GlobalVar("t", st,
ast::AttributeList{
- create<ast::GroupAttribute>(0),
- create<ast::BindingAttribute>(0),
+ create<ast::GroupAttribute>(0u),
+ create<ast::BindingAttribute>(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 dd715d4..78d70f6 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 @@
// - 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 108e0d5..b6ae9c5 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 @@
auto* t = ty.storage_texture(param.dim, param.fmt, param.access);
GlobalVar("g", t,
ast::AttributeList{
- create<ast::BindingAttribute>(1),
- create<ast::GroupAttribute>(2),
+ create<ast::BindingAttribute>(1u),
+ create<ast::GroupAttribute>(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 a117459..a02aed8 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 @@
auto* s = Structure("S", {Member("a", ty.i32())});
auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -60,8 +60,8 @@
auto* s = Structure("S", {Member("a", ty.i32())});
auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -75,8 +75,8 @@
auto* s = Structure("S", {Member("a", ty.i32())});
auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
- create<ast::BindingAttribute>(0),
- create<ast::GroupAttribute>(0),
+ create<ast::BindingAttribute>(0u),
+ create<ast::GroupAttribute>(0u),
});
GeneratorImpl& gen = Build();
@@ -90,8 +90,8 @@
auto* v =
GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr,
ast::AttributeList{
- create<ast::GroupAttribute>(1),
- create<ast::BindingAttribute>(2),
+ create<ast::GroupAttribute>(1u),
+ create<ast::BindingAttribute>(2u),
});
GeneratorImpl& gen = Build();