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>
This commit is contained in:
dan sinclair 2022-06-29 14:38:15 +00:00 committed by Dawn LUCI CQ
parent ad10eb59d1
commit 3a2a279714
88 changed files with 577 additions and 513 deletions

View File

@ -22,18 +22,6 @@ function(tint_spvtools_compile_options TARGET)
${spirv-tools_SOURCE_DIR} ${spirv-tools_SOURCE_DIR}
${spirv-tools_BINARY_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() endfunction()
## Tint diagnostic utilities. Used by libtint and tint_utils_io. ## Tint diagnostic utilities. Used by libtint and tint_utils_io.

View File

@ -62,7 +62,7 @@ TEST_F(AstArrayTest, FriendlyName_ConstantSized) {
TEST_F(AstArrayTest, FriendlyName_WithStride) { TEST_F(AstArrayTest, FriendlyName_WithStride) {
auto* i32 = create<I32>(); 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>"); EXPECT_EQ(arr->FriendlyName(Symbols()), "@stride(32) array<i32, 5>");
} }

View File

@ -20,7 +20,7 @@ namespace {
using BindingAttributeTest = TestHelper; using BindingAttributeTest = TestHelper;
TEST_F(BindingAttributeTest, Creation) { TEST_F(BindingAttributeTest, Creation) {
auto* d = create<BindingAttribute>(2); auto* d = create<BindingAttribute>(2u);
EXPECT_EQ(2u, d->value); EXPECT_EQ(2u, d->value);
} }

View File

@ -142,8 +142,8 @@ const ast::Type* TextureOverloadCase::BuildResultVectorComponentType(ProgramBuil
const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b) const { const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b) const {
AttributeList attrs = { AttributeList attrs = {
b->create<ast::GroupAttribute>(0), b->create<ast::GroupAttribute>(0u),
b->create<ast::BindingAttribute>(0), b->create<ast::BindingAttribute>(0u),
}; };
switch (texture_kind) { switch (texture_kind) {
case ast::builtin::test::TextureKind::kRegular: case ast::builtin::test::TextureKind::kRegular:
@ -176,8 +176,8 @@ const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b
const ast::Variable* TextureOverloadCase::BuildSamplerVariable(ProgramBuilder* b) const { const ast::Variable* TextureOverloadCase::BuildSamplerVariable(ProgramBuilder* b) const {
AttributeList attrs = { AttributeList attrs = {
b->create<ast::GroupAttribute>(0), b->create<ast::GroupAttribute>(0u),
b->create<ast::BindingAttribute>(1), b->create<ast::BindingAttribute>(1u),
}; };
return b->GlobalVar("sampler", b->ty.sampler(sampler_kind), attrs); return b->GlobalVar("sampler", b->ty.sampler(sampler_kind), attrs);
} }

View File

@ -20,7 +20,7 @@ namespace {
using GroupAttributeTest = TestHelper; using GroupAttributeTest = TestHelper;
TEST_F(GroupAttributeTest, Creation) { TEST_F(GroupAttributeTest, Creation) {
auto* d = create<GroupAttribute>(2); auto* d = create<GroupAttribute>(2u);
EXPECT_EQ(2u, d->value); EXPECT_EQ(2u, d->value);
} }

View File

@ -22,7 +22,7 @@ namespace {
using IdAttributeTest = TestHelper; using IdAttributeTest = TestHelper;
TEST_F(IdAttributeTest, Creation) { TEST_F(IdAttributeTest, Creation) {
auto* d = create<IdAttribute>(12); auto* d = create<IdAttribute>(12u);
EXPECT_EQ(12u, d->value); EXPECT_EQ(12u, d->value);
} }

View File

@ -20,7 +20,7 @@ namespace {
using LocationAttributeTest = TestHelper; using LocationAttributeTest = TestHelper;
TEST_F(LocationAttributeTest, Creation) { TEST_F(LocationAttributeTest, Creation) {
auto* d = create<LocationAttribute>(2); auto* d = create<LocationAttribute>(2u);
EXPECT_EQ(2u, d->value); EXPECT_EQ(2u, d->value);
} }

View File

@ -34,7 +34,7 @@ using AstMatrixTest = TestHelper;
TEST_F(AstMatrixTest, Creation) { TEST_F(AstMatrixTest, Creation) {
auto* i32 = create<I32>(); 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->type, i32);
EXPECT_EQ(m->rows, 2u); EXPECT_EQ(m->rows, 2u);
EXPECT_EQ(m->columns, 4u); EXPECT_EQ(m->columns, 4u);
@ -42,12 +42,12 @@ TEST_F(AstMatrixTest, Creation) {
TEST_F(AstMatrixTest, FriendlyName) { TEST_F(AstMatrixTest, FriendlyName) {
auto* i32 = create<I32>(); 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>"); EXPECT_EQ(m->FriendlyName(Symbols()), "mat2x3<i32>");
} }
TEST_F(AstMatrixTest, FriendlyName_WithoutType) { 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"); EXPECT_EQ(m->FriendlyName(Symbols()), "mat2x3");
} }

View File

@ -20,13 +20,13 @@ namespace {
using StrideAttributeTest = TestHelper; using StrideAttributeTest = TestHelper;
TEST_F(StrideAttributeTest, Creation) { TEST_F(StrideAttributeTest, Creation) {
auto* d = create<StrideAttribute>(2); auto* d = create<StrideAttribute>(2u);
EXPECT_EQ(2u, d->stride); EXPECT_EQ(2u, d->stride);
} }
TEST_F(StrideAttributeTest, Source) { TEST_F(StrideAttributeTest, Source) {
auto* d = create<StrideAttribute>( 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.line, 1u);
EXPECT_EQ(d->source.range.begin.column, 2u); EXPECT_EQ(d->source.range.begin.column, 2u);
EXPECT_EQ(d->source.range.end.line, 3u); EXPECT_EQ(d->source.range.end.line, 3u);

View File

@ -22,7 +22,7 @@ namespace {
using StructMemberAlignAttributeTest = TestHelper; using StructMemberAlignAttributeTest = TestHelper;
TEST_F(StructMemberAlignAttributeTest, Creation) { TEST_F(StructMemberAlignAttributeTest, Creation) {
auto* d = create<StructMemberAlignAttribute>(2); auto* d = create<StructMemberAlignAttribute>(2u);
EXPECT_EQ(2u, d->align); EXPECT_EQ(2u, d->align);
} }

View File

@ -20,7 +20,7 @@ namespace {
using StructMemberOffsetAttributeTest = TestHelper; using StructMemberOffsetAttributeTest = TestHelper;
TEST_F(StructMemberOffsetAttributeTest, Creation) { TEST_F(StructMemberOffsetAttributeTest, Creation) {
auto* d = create<StructMemberOffsetAttribute>(2); auto* d = create<StructMemberOffsetAttribute>(2u);
EXPECT_EQ(2u, d->offset); EXPECT_EQ(2u, d->offset);
} }

View File

@ -22,7 +22,7 @@ namespace {
using StructMemberSizeAttributeTest = TestHelper; using StructMemberSizeAttributeTest = TestHelper;
TEST_F(StructMemberSizeAttributeTest, Creation) { TEST_F(StructMemberSizeAttributeTest, Creation) {
auto* d = create<StructMemberSizeAttribute>(2); auto* d = create<StructMemberSizeAttribute>(2u);
EXPECT_EQ(2u, d->size); EXPECT_EQ(2u, d->size);
} }

View File

@ -94,9 +94,9 @@ TEST_F(VariableTest, Assert_DifferentProgramID_Constructor) {
TEST_F(VariableTest, WithAttributes) { TEST_F(VariableTest, WithAttributes) {
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr, auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
AttributeList{ AttributeList{
create<LocationAttribute>(1), create<LocationAttribute>(1u),
create<BuiltinAttribute>(Builtin::kPosition), create<BuiltinAttribute>(Builtin::kPosition),
create<IdAttribute>(1200), create<IdAttribute>(1200u),
}); });
auto& attributes = var->attributes; auto& attributes = var->attributes;
@ -112,8 +112,8 @@ TEST_F(VariableTest, WithAttributes) {
TEST_F(VariableTest, BindingPoint) { TEST_F(VariableTest, BindingPoint) {
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr, auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
AttributeList{ AttributeList{
create<BindingAttribute>(2), create<BindingAttribute>(2u),
create<GroupAttribute>(1), create<GroupAttribute>(1u),
}); });
EXPECT_TRUE(var->BindingPoint()); EXPECT_TRUE(var->BindingPoint());
ASSERT_NE(var->BindingPoint().binding, nullptr); ASSERT_NE(var->BindingPoint().binding, nullptr);
@ -132,7 +132,7 @@ TEST_F(VariableTest, BindingPointAttributes) {
TEST_F(VariableTest, BindingPointMissingGroupAttribute) { TEST_F(VariableTest, BindingPointMissingGroupAttribute) {
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr, auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
AttributeList{ AttributeList{
create<BindingAttribute>(2), create<BindingAttribute>(2u),
}); });
EXPECT_FALSE(var->BindingPoint()); EXPECT_FALSE(var->BindingPoint());
ASSERT_NE(var->BindingPoint().binding, nullptr); ASSERT_NE(var->BindingPoint().binding, nullptr);
@ -142,7 +142,7 @@ TEST_F(VariableTest, BindingPointMissingGroupAttribute) {
TEST_F(VariableTest, BindingPointMissingBindingAttribute) { TEST_F(VariableTest, BindingPointMissingBindingAttribute) {
auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr, auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, nullptr,
AttributeList{create<GroupAttribute>(1)}); AttributeList{create<GroupAttribute>(1u)});
EXPECT_FALSE(var->BindingPoint()); EXPECT_FALSE(var->BindingPoint());
ASSERT_NE(var->BindingPoint().group, nullptr); ASSERT_NE(var->BindingPoint().group, nullptr);
EXPECT_EQ(var->BindingPoint().group->value, 1u); EXPECT_EQ(var->BindingPoint().group->value, 1u);

View File

@ -24,14 +24,14 @@ using AstVectorTest = TestHelper;
TEST_F(AstVectorTest, Creation) { TEST_F(AstVectorTest, Creation) {
auto* i32 = create<I32>(); auto* i32 = create<I32>();
auto* v = create<Vector>(i32, 2); auto* v = create<Vector>(i32, 2u);
EXPECT_EQ(v->type, i32); EXPECT_EQ(v->type, i32);
EXPECT_EQ(v->width, 2u); EXPECT_EQ(v->width, 2u);
} }
TEST_F(AstVectorTest, FriendlyName) { TEST_F(AstVectorTest, FriendlyName) {
auto* f32 = create<F32>(); auto* f32 = create<F32>();
auto* v = create<Vector>(f32, 3); auto* v = create<Vector>(f32, 3u);
EXPECT_EQ(v->FriendlyName(Symbols()), "vec3<f32>"); EXPECT_EQ(v->FriendlyName(Symbols()), "vec3<f32>");
} }

View File

@ -26,4 +26,8 @@ const TypeInfo detail::TypeInfoOf<CastableBase>::info{
tint::TypeInfo::FullHashCodeOf<CastableBase>(), tint::TypeInfo::FullHashCodeOf<CastableBase>(),
}; };
CastableBase::CastableBase(const CastableBase&) = default;
CastableBase::~CastableBase() = default;
} // namespace tint } // namespace tint

View File

@ -320,10 +320,10 @@ inline const TO* As(const FROM* obj) {
class CastableBase { class CastableBase {
public: public:
/// Copy constructor /// Copy constructor
CastableBase(const CastableBase&) = default; CastableBase(const CastableBase&);
/// Destructor /// Destructor
virtual ~CastableBase() = default; virtual ~CastableBase();
/// Copy assignment /// Copy assignment
/// @param other the CastableBase to copy /// @param other the CastableBase to copy
@ -626,7 +626,7 @@ inline void SwitchCases(T* object, RETURN_TYPE* result, std::tuple<CASES...>&& c
// Static assertions // Static assertions
static constexpr bool kDefaultIsOK = 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 = static constexpr bool kReturnIsOK =
kHasDefaultCase || !kHasReturnType || std::is_constructible_v<RETURN_TYPE>; kHasDefaultCase || !kHasReturnType || std::is_constructible_v<RETURN_TYPE>;
static_assert(kDefaultIsOK, "Default case must be last in Switch()"); static_assert(kDefaultIsOK, "Default case must be last in Switch()");

View File

@ -23,6 +23,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::Cloneable);
namespace tint { namespace tint {
Cloneable::Cloneable() = default;
Cloneable::Cloneable(Cloneable&&) = default;
Cloneable::~Cloneable() = default;
CloneContext::ListTransforms::ListTransforms() = default; CloneContext::ListTransforms::ListTransforms() = default;
CloneContext::ListTransforms::~ListTransforms() = default; CloneContext::ListTransforms::~ListTransforms() = default;

View File

@ -48,6 +48,13 @@ ProgramID ProgramIDOf(const ProgramBuilder*);
/// Cloneable is the base class for all objects that can be cloned /// Cloneable is the base class for all objects that can be cloned
class Cloneable : public Castable<Cloneable> { class Cloneable : public Castable<Cloneable> {
public: public:
/// Constructor
Cloneable();
/// Move constructor
Cloneable(Cloneable&&);
/// Destructor
~Cloneable() override;
/// Performs a deep clone of this object using the CloneContext `ctx`. /// Performs a deep clone of this object using the CloneContext `ctx`.
/// @param ctx the clone context /// @param ctx the clone context
/// @return the newly cloned object /// @return the newly cloned object

View File

@ -49,7 +49,7 @@ std::string Demangler::Demangle(const SymbolTable& symbols, const std::string& s
auto len = end_idx - start_idx; auto len = end_idx - start_idx;
auto id = str.substr(start_idx, len); 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); out << symbols.NameFor(sym);
pos = end_idx; pos = end_idx;

View File

@ -815,8 +815,8 @@ void Inspector::GenerateSamplerTargets() {
continue; continue;
} }
auto* t = c->args[texture_index]; auto* t = c->args[static_cast<size_t>(texture_index)];
auto* s = c->args[sampler_index]; auto* s = c->args[static_cast<size_t>(sampler_index)];
GetOriginatingResources( GetOriginatingResources(
std::array<const ast::Expression*, 2>{t, s}, std::array<const ast::Expression*, 2>{t, s},

View File

@ -3048,7 +3048,7 @@ TEST_F(InspectorGetWorkgroupStorageSizeTest, StructAlignment) {
// here the struct is expected to occupy 1024 bytes of workgroup storage. // here the struct is expected to occupy 1024 bytes of workgroup storage.
const auto* wg_struct_type = MakeStructTypeFromMembers( const auto* wg_struct_type = MakeStructTypeFromMembers(
"WgStruct", "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)); AddWorkgroupStorage("wg_struct_var", ty.Of(wg_struct_type));
MakeStructVariableReferenceBodyFunction("wg_struct_func", "wg_struct_var", {{0, ty.f32()}}); MakeStructVariableReferenceBodyFunction("wg_struct_func", "wg_struct_var", {{0, ty.f32()}});

View File

@ -285,11 +285,11 @@ const ast::Type* InspectorBuilder::GetCoordsType(ast::TextureDimension dim,
return scalar; return scalar;
case ast::TextureDimension::k2d: case ast::TextureDimension::k2d:
case ast::TextureDimension::k2dArray: case ast::TextureDimension::k2dArray:
return create<ast::Vector>(scalar, 2); return create<ast::Vector>(scalar, 2u);
case ast::TextureDimension::k3d: case ast::TextureDimension::k3d:
case ast::TextureDimension::kCube: case ast::TextureDimension::kCube:
case ast::TextureDimension::kCubeArray: case ast::TextureDimension::kCubeArray:
return create<ast::Vector>(scalar, 3); return create<ast::Vector>(scalar, 3u);
default: default:
[=]() { FAIL() << "Unsupported texture dimension: " << dim; }(); [=]() { FAIL() << "Unsupported texture dimension: " << dim; }();
} }

View File

@ -1024,11 +1024,13 @@ bool FunctionEmitter::EmitPipelineInput(std::string var_name,
[&](const Struct* struct_type) -> bool { [&](const Struct* struct_type) -> bool {
const auto& members = struct_type->members; const auto& members = struct_type->members;
index_prefix.push_back(0); index_prefix.push_back(0);
for (int i = 0; i < static_cast<int>(members.size()); ++i) { for (size_t i = 0; i < members.size(); ++i) {
index_prefix.back() = i; index_prefix.back() = static_cast<int>(i);
ast::AttributeList member_attrs(*attrs); ast::AttributeList member_attrs(*attrs);
if (!parser_impl_.ConvertPipelineDecorations( 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)) { &member_attrs)) {
return false; return false;
} }
@ -1078,7 +1080,7 @@ bool FunctionEmitter::EmitPipelineInput(std::string var_name,
store_dest = builder_.MemberAccessor( store_dest = builder_.MemberAccessor(
store_dest, store_dest,
builder_.Expr(parser_impl_.GetMemberName(*struct_type, index))); 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 @@ bool FunctionEmitter::EmitPipelineOutput(std::string var_name,
&member_attrs)) { &member_attrs)) {
return false; return false;
} }
if (!EmitPipelineOutput(var_name, var_type, &member_attrs, index_prefix, members[i], if (!EmitPipelineOutput(var_name, var_type, &member_attrs, index_prefix,
forced_member_type, return_members, return_exprs)) { members[static_cast<size_t>(i)], forced_member_type,
return_members, return_exprs)) {
return false; return false;
} }
// Copy the location as updated by nested expansion of the member. // Copy the location as updated by nested expansion of the member.
@ -1223,7 +1226,7 @@ bool FunctionEmitter::EmitPipelineOutput(std::string var_name,
load_source = builder_.MemberAccessor( load_source = builder_.MemberAccessor(
load_source, load_source,
builder_.Expr(parser_impl_.GetMemberName(*struct_type, index))); 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 @@ bool FunctionEmitter::LabelControlFlowConstructs() {
// The current block is a header. // The current block is a header.
const auto header = block_id; const auto header = block_id;
const auto* header_info = block_info; 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; const auto ct = header_info->continue_for_header;
if (ct != 0) { if (ct != 0) {
// The current block is a loop header. // The current block is a loop header.
@ -4310,7 +4313,7 @@ TypedExpression FunctionEmitter::MakeCompositeExtract(const spvtools::opt::Instr
// This is structurally similar to creating an access chain, but // This is structurally similar to creating an access chain, but
// the SPIR-V instruction has literal indices instead of IDs for indices. // 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; auto first_index_position = 1;
TypedExpression current_expr(MakeOperand(inst, composite_index)); TypedExpression current_expr(MakeOperand(inst, composite_index));
if (!current_expr) { if (!current_expr) {
@ -4354,13 +4357,14 @@ TypedExpression FunctionEmitter::MakeCompositeValueDecomposition(
// hierarchy, maintaining |current_type_id| as the SPIR-V ID of the type of // hierarchy, maintaining |current_type_id| as the SPIR-V ID of the type of
// the object pointed to after processing the previous indices. // the object pointed to after processing the previous indices.
const auto num_in_operands = inst.NumInOperands(); 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 uint32_t index_val = inst.GetSingleWordInOperand(index);
const auto* current_type_inst = def_use_mgr_->GetDef(current_type_id); const auto* current_type_inst = def_use_mgr_->GetDef(current_type_id);
if (!current_type_inst) { if (!current_type_inst) {
Fail() << "composite type %" << current_type_id << " is invalid after following " 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 {}; return {};
} }
const char* operation_name = nullptr; const char* operation_name = nullptr;
@ -4650,7 +4654,7 @@ void FunctionEmitter::FindValuesNeedingNamedOrHoistedDefinition() {
// but only if they are defined in this function as well. // but only if they are defined in this function as well.
auto require_named_const_def = [&](const spvtools::opt::Instruction& inst, auto require_named_const_def = [&](const spvtools::opt::Instruction& inst,
int in_operand_index) { 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); auto* const operand_def = GetDefInfo(id);
if (operand_def) { if (operand_def) {
operand_def->requires_named_const_def = true; operand_def->requires_named_const_def = true;
@ -4918,7 +4922,7 @@ bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) {
bool FunctionEmitter::EmitControlBarrier(const spvtools::opt::Instruction& inst) { bool FunctionEmitter::EmitControlBarrier(const spvtools::opt::Instruction& inst) {
uint32_t operands[3]; uint32_t operands[3];
for (int i = 0; i < 3; i++) { for (uint32_t i = 0; i < 3; i++) {
auto id = inst.GetSingleWordInOperand(i); auto id = inst.GetSingleWordInOperand(i);
if (auto* constant = constant_mgr_->FindDeclaredConstant(id)) { if (auto* constant = constant_mgr_->FindDeclaredConstant(id)) {
operands[i] = constant->GetU32(); operands[i] = constant->GetU32();
@ -4936,7 +4940,7 @@ bool FunctionEmitter::EmitControlBarrier(const spvtools::opt::Instruction& inst)
<< "expected Workgroup (2), got: " << execution; << "expected Workgroup (2), got: " << execution;
} }
if (semantics & SpvMemorySemanticsAcquireReleaseMask) { if (semantics & SpvMemorySemanticsAcquireReleaseMask) {
semantics &= ~SpvMemorySemanticsAcquireReleaseMask; semantics &= ~static_cast<uint32_t>(SpvMemorySemanticsAcquireReleaseMask);
} else { } else {
return Fail() << "control barrier semantics requires acquire and release"; return Fail() << "control barrier semantics requires acquire and release";
} }
@ -4945,14 +4949,14 @@ bool FunctionEmitter::EmitControlBarrier(const spvtools::opt::Instruction& inst)
return Fail() << "workgroupBarrier requires workgroup memory scope"; return Fail() << "workgroupBarrier requires workgroup memory scope";
} }
AddStatement(create<ast::CallStatement>(builder_.Call("workgroupBarrier"))); AddStatement(create<ast::CallStatement>(builder_.Call("workgroupBarrier")));
semantics &= ~SpvMemorySemanticsWorkgroupMemoryMask; semantics &= ~static_cast<uint32_t>(SpvMemorySemanticsWorkgroupMemoryMask);
} }
if (semantics & SpvMemorySemanticsUniformMemoryMask) { if (semantics & SpvMemorySemanticsUniformMemoryMask) {
if (memory != SpvScopeDevice) { if (memory != SpvScopeDevice) {
return Fail() << "storageBarrier requires device memory scope"; return Fail() << "storageBarrier requires device memory scope";
} }
AddStatement(create<ast::CallStatement>(builder_.Call("storageBarrier"))); AddStatement(create<ast::CallStatement>(builder_.Call("storageBarrier")));
semantics &= ~SpvMemorySemanticsUniformMemoryMask; semantics &= ~static_cast<uint32_t>(SpvMemorySemanticsUniformMemoryMask);
} }
if (semantics) { if (semantics) {
return Fail() << "unsupported control barrier semantics: " << semantics; return Fail() << "unsupported control barrier semantics: " << semantics;
@ -5600,7 +5604,7 @@ ast::ExpressionList FunctionEmitter::MakeCoordinateOperandsForImageAccess(
} }
ast::TextureDimension dim = texture_type->dims; ast::TextureDimension dim = texture_type->dims;
// Number of regular coordinates. // 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); bool is_arrayed = ast::IsTextureArray(dim);
if ((num_axes == 0) || (num_axes > 3)) { if ((num_axes == 0) || (num_axes > 3)) {
Fail() << "unsupported image dimensionality for " << texture_type->TypeInfo().name Fail() << "unsupported image dimensionality for " << texture_type->TypeInfo().name

View File

@ -816,7 +816,7 @@ bool ParserImpl::RegisterWorkgroupSizeBuiltin() {
/// Returns false and emits a diagnostic on error. /// Returns false and emits a diagnostic on error.
auto set_param = [this, composite_def](uint32_t* id_ptr, uint32_t* value_ptr, auto set_param = [this, composite_def](uint32_t* id_ptr, uint32_t* value_ptr,
int index) -> bool { 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); const auto* def = def_use_mgr_->GetDef(id);
if (!def || (def->opcode() != SpvOpSpecConstant && def->opcode() != SpvOpConstant) || if (!def || (def->opcode() != SpvOpSpecConstant && def->opcode() != SpvOpConstant) ||
(def->NumInOperands() != 1)) { (def->NumInOperands() != 1)) {
@ -1336,7 +1336,7 @@ bool ParserImpl::EmitScalarSpecConstants() {
}, },
[&](const U32*) { [&](const U32*) {
return create<ast::IntLiteralExpression>( return create<ast::IntLiteralExpression>(
Source{}, static_cast<uint64_t>(literal_value), Source{}, static_cast<int64_t>(literal_value),
ast::IntLiteralExpression::Suffix::kU); ast::IntLiteralExpression::Suffix::kU);
}, },
[&](const F32*) { [&](const F32*) {
@ -1715,8 +1715,8 @@ DecorationList ParserImpl::GetMemberPipelineDecorations(const Struct& struct_typ
int member_index) { int member_index) {
// Yes, I could have used std::copy_if or std::copy_if. // Yes, I could have used std::copy_if or std::copy_if.
DecorationList result; DecorationList result;
for (const auto& deco : for (const auto& deco : GetDecorationsForMember(struct_id_for_symbol_[struct_type.name],
GetDecorationsForMember(struct_id_for_symbol_[struct_type.name], member_index)) { static_cast<uint32_t>(member_index))) {
if (IsPipelineDecoration(deco)) { if (IsPipelineDecoration(deco)) {
result.emplace_back(deco); result.emplace_back(deco);
} }
@ -2721,7 +2721,7 @@ std::string ParserImpl::GetMemberName(const Struct& struct_type, int member_inde
Fail() << "no structure type registered for symbol"; Fail() << "no structure type registered for symbol";
return ""; return "";
} }
return namer_.GetMemberName(where->second, member_index); return namer_.GetMemberName(where->second, static_cast<uint32_t>(member_index));
} }
WorkgroupSizeInfo::WorkgroupSizeInfo() = default; WorkgroupSizeInfo::WorkgroupSizeInfo() = default;

View File

@ -22,8 +22,18 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "src/tint/utils/compiler_macros.h"
#if TINT_BUILD_SPV_READER #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" #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 #endif
#include "src/tint/program_builder.h" #include "src/tint/program_builder.h"

View File

@ -21,8 +21,18 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "src/tint/utils/compiler_macros.h"
#if TINT_BUILD_SPV_READER #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" #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 #endif
#include "gtest/gtest.h" #include "gtest/gtest.h"

View File

@ -163,6 +163,12 @@ const ast::Type* I32::Build(ProgramBuilder& b) const {
return b.ty.i32(); 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 Type* t, ast::StorageClass s) : type(t), storage_class(s) {}
Pointer::Pointer(const Pointer&) = default; Pointer::Pointer(const Pointer&) = default;

View File

@ -40,6 +40,13 @@ namespace tint::reader::spirv {
/// Type is the base class for all types /// Type is the base class for all types
class Type : public Castable<Type> { class Type : public Castable<Type> {
public: public:
/// Constructor
Type();
/// Copy constructor
Type(const Type&);
/// Destructor
~Type() override;
/// @param b the ProgramBuilder used to construct the AST types /// @param b the ProgramBuilder used to construct the AST types
/// @returns the constructed ast::Type node for the given type /// @returns the constructed ast::Type node for the given type
virtual const ast::Type* Build(ProgramBuilder& b) const = 0; virtual const ast::Type* Build(ProgramBuilder& b) const = 0;
@ -314,6 +321,8 @@ struct Sampler final : public Castable<Sampler, Type> {
/// Base class for texture types /// Base class for texture types
struct Texture : public Castable<Texture, Type> { struct Texture : public Castable<Texture, Type> {
~Texture() override;
/// Constructor /// Constructor
/// @param d the texture dimensions /// @param d the texture dimensions
explicit Texture(ast::TextureDimension d); explicit Texture(ast::TextureDimension d);

View File

@ -45,7 +45,7 @@ TEST_F(SpvParserTest, Usage_Trivial_Output) {
} }
TEST_F(SpvParserTest, Usage_Equality_OneDifference) { TEST_F(SpvParserTest, Usage_Equality_OneDifference) {
const int num_usages = 9; const size_t num_usages = 9u;
std::vector<Usage> usages(num_usages); std::vector<Usage> usages(num_usages);
usages[1].AddSampler(); usages[1].AddSampler();
usages[2].AddComparisonSampler(); usages[2].AddComparisonSampler();
@ -55,8 +55,8 @@ TEST_F(SpvParserTest, Usage_Equality_OneDifference) {
usages[6].AddDepthTexture(); usages[6].AddDepthTexture();
usages[7].AddStorageReadTexture(); usages[7].AddStorageReadTexture();
usages[8].AddStorageWriteTexture(); usages[8].AddStorageWriteTexture();
for (int i = 0; i < num_usages; ++i) { for (size_t i = 0; i < num_usages; ++i) {
for (int j = 0; j < num_usages; ++j) { for (size_t j = 0; j < num_usages; ++j) {
const auto& lhs = usages[i]; const auto& lhs = usages[i];
const auto& rhs = usages[j]; const auto& rhs = usages[j];
if (i == j) { if (i == j) {

View File

@ -412,7 +412,7 @@ Token Lexer::try_hex_float() {
// clang-format on // clang-format on
// -? // -?
int64_t sign_bit = 0; uint64_t sign_bit = 0;
if (matches(end, "-")) { if (matches(end, "-")) {
sign_bit = 1; sign_bit = 1;
end++; end++;
@ -794,7 +794,7 @@ Token Lexer::build_token_from_int_if_possible(Source source, size_t start, int32
const bool overflow = errno == ERANGE; const bool overflow = errno == ERANGE;
if (end_ptr) { if (end_ptr) {
advance(end_ptr - start_ptr); advance(static_cast<size_t>(end_ptr - start_ptr));
} }
if (matches(pos(), "u")) { if (matches(pos(), "u")) {

View File

@ -32,8 +32,8 @@ TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) {
auto* s = Structure("S", {Member("m", ty.i32())}); auto* s = Structure("S", {Member("m", ty.i32())});
GlobalVar(Source{{12, 34}}, "a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar(Source{{12, 34}}, "a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i)); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i));
@ -237,13 +237,13 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) {
GlobalVar("a", make_type(), ast::StorageClass::kNone, GlobalVar("a", make_type(), ast::StorageClass::kNone,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GlobalVar("b", make_type(), ast::StorageClass::kNone, GlobalVar("b", make_type(), ast::StorageClass::kNone,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
WrapInFunction(Assign(Source{{56, 78}}, "a", "b")); WrapInFunction(Assign(Source{{56, 78}}, "a", "b"));
@ -260,8 +260,8 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) {
auto* s = Structure("S", {Member("a", ty.atomic(ty.i32()))}); auto* s = Structure("S", {Member("a", ty.atomic(ty.i32()))});
GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a")));
@ -278,8 +278,8 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) {
auto* s = Structure("S", {Member("a", ty.array(ty.f32()))}); auto* s = Structure("S", {Member("a", ty.array(ty.f32()))});
GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a")));

View File

@ -48,8 +48,8 @@ TEST_F(ResolverAtomicTest, GlobalStorageStruct) {
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}); 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, auto* g = GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
EXPECT_TRUE(r()->Resolve()) << r()->error(); EXPECT_TRUE(r()->Resolve()) << r()->error();

View File

@ -508,8 +508,8 @@ TEST_F(EntryPointParameterAttributeTest, DuplicateAttribute) {
TEST_F(EntryPointParameterAttributeTest, DuplicateInternalAttribute) { TEST_F(EntryPointParameterAttributeTest, DuplicateInternalAttribute) {
auto* s = Param("s", ty.sampler(ast::SamplerKind::kSampler), auto* s = Param("s", ty.sampler(ast::SamplerKind::kSampler),
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
Disable(ast::DisabledValidation::kBindingPointCollision), Disable(ast::DisabledValidation::kBindingPointCollision),
Disable(ast::DisabledValidation::kEntryPointParameter), Disable(ast::DisabledValidation::kEntryPointParameter),
}); });
@ -745,9 +745,9 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
TEST_F(VariableAttributeTest, DuplicateAttribute) { TEST_F(VariableAttributeTest, DuplicateAttribute) {
GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler),
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(Source{{12, 34}}, 2), create<ast::BindingAttribute>(Source{{12, 34}}, 2u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
create<ast::BindingAttribute>(Source{{56, 78}}, 3), create<ast::BindingAttribute>(Source{{56, 78}}, 3u),
}); });
WrapInFunction(); WrapInFunction();
@ -761,7 +761,7 @@ TEST_F(VariableAttributeTest, DuplicateAttribute) {
TEST_F(VariableAttributeTest, LocalVariable) { TEST_F(VariableAttributeTest, LocalVariable) {
auto* v = Var("a", ty.f32(), auto* v = Var("a", ty.f32(),
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(Source{{12, 34}}, 2), create<ast::BindingAttribute>(Source{{12, 34}}, 2u),
}); });
WrapInFunction(v); WrapInFunction(v);
@ -807,8 +807,8 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
TEST_F(ConstantAttributeTest, DuplicateAttribute) { TEST_F(ConstantAttributeTest, DuplicateAttribute) {
GlobalConst("a", ty.f32(), Expr(1.23_f), GlobalConst("a", ty.f32(), Expr(1.23_f),
ast::AttributeList{ ast::AttributeList{
create<ast::IdAttribute>(Source{{12, 34}}, 0), create<ast::IdAttribute>(Source{{12, 34}}, 0u),
create<ast::IdAttribute>(Source{{56, 78}}, 1), create<ast::IdAttribute>(Source{{56, 78}}, 1u),
}); });
WrapInFunction(); WrapInFunction();
@ -854,8 +854,8 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
TEST_F(OverrideAttributeTest, DuplicateAttribute) { TEST_F(OverrideAttributeTest, DuplicateAttribute) {
Override("a", ty.f32(), Expr(1.23_f), Override("a", ty.f32(), Expr(1.23_f),
ast::AttributeList{ ast::AttributeList{
create<ast::IdAttribute>(Source{{12, 34}}, 0), create<ast::IdAttribute>(Source{{12, 34}}, 0u),
create<ast::IdAttribute>(Source{{56, 78}}, 1), create<ast::IdAttribute>(Source{{56, 78}}, 1u),
}); });
WrapInFunction(); WrapInFunction();
@ -976,8 +976,8 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
TEST_F(ArrayStrideTest, DuplicateAttribute) { TEST_F(ArrayStrideTest, DuplicateAttribute) {
auto* arr = ty.array(Source{{12, 34}}, ty.i32(), 4_u, auto* arr = ty.array(Source{{12, 34}}, ty.i32(), 4_u,
{ {
create<ast::StrideAttribute>(Source{{12, 34}}, 4_i), create<ast::StrideAttribute>(Source{{12, 34}}, 4u),
create<ast::StrideAttribute>(Source{{56, 78}}, 4_i), create<ast::StrideAttribute>(Source{{56, 78}}, 4u),
}); });
GlobalVar("myarray", arr, ast::StorageClass::kPrivate); GlobalVar("myarray", arr, ast::StorageClass::kPrivate);
@ -1035,7 +1035,7 @@ TEST_F(ResourceAttributeTest, BindingPairMissingBinding) {
GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler),
ast::StorageClass::kNone, ast::StorageClass::kNone,
ast::AttributeList{ ast::AttributeList{
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());
@ -1047,7 +1047,7 @@ TEST_F(ResourceAttributeTest, BindingPairMissingGroup) {
GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler),
ast::StorageClass::kNone, ast::StorageClass::kNone,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
}); });
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());
@ -1059,14 +1059,14 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) {
GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone, ast::StorageClass::kNone,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone, ast::StorageClass::kNone,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("F", {}, ty.void_(), Func("F", {}, ty.void_(),
@ -1091,14 +1091,14 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) {
GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone, ast::StorageClass::kNone,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone, ast::StorageClass::kNone,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("F_A", {}, ty.void_(), Func("F_A", {}, ty.void_(),
@ -1124,8 +1124,8 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) {
TEST_F(ResourceAttributeTest, BindingPointOnNonResource) { TEST_F(ResourceAttributeTest, BindingPointOnNonResource) {
GlobalVar(Source{{12, 34}}, "G", ty.f32(), ast::StorageClass::kPrivate, GlobalVar(Source{{12, 34}}, "G", ty.f32(), ast::StorageClass::kPrivate,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());

View File

@ -187,8 +187,8 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParam<Textur
if (type->IsAnyOf<ast::Texture, ast::Sampler>()) { if (type->IsAnyOf<ast::Texture, ast::Sampler>()) {
GlobalVar(name, type, GlobalVar(name, type,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
} else { } else {
@ -618,8 +618,8 @@ TEST_F(ResolverBuiltinDataTest, ArrayLength_Vector) {
auto* str = Structure("S", {Member("x", ary)}); auto* str = Structure("S", {Member("x", ary)});
GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x"))); auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x")));

View File

@ -257,11 +257,11 @@ TEST_P(BuiltinTextureConstExprArgValidationTest, Immediate) {
err << "12:34 error: each component of the " << param.name err << "12:34 error: each component of the " << param.name
<< " argument must be at least " << param.min << " and at most " << param.max << " argument must be at least " << param.min << " and at most " << param.max
<< ". " << param.name << " component " << expr.invalid_index << " is " << ". " << 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 { } else {
err << "12:34 error: the " << param.name << " argument must be at least " << param.min err << "12:34 error: the " << param.name << " argument must be at least " << param.min
<< " and at most " << param.max << ". " << param.name << " is " << " 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()); EXPECT_EQ(r()->error(), err.str());
} }

View File

@ -754,7 +754,7 @@ TEST_F(ResolverFunctionValidationTest, ParametersOverLimit) {
TEST_F(ResolverFunctionValidationTest, ParameterVectorNoType) { TEST_F(ResolverFunctionValidationTest, ParameterVectorNoType) {
// fn f(p : vec3) {} // 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_(), {}); ty.void_(), {});
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());
@ -764,8 +764,8 @@ TEST_F(ResolverFunctionValidationTest, ParameterVectorNoType) {
TEST_F(ResolverFunctionValidationTest, ParameterMatrixNoType) { TEST_F(ResolverFunctionValidationTest, ParameterMatrixNoType) {
// fn f(p : vec3) {} // fn f(p : vec3) {}
Func(Source{{12, 34}}, "f", {Param("p", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3, 3))}, Func(Source{{12, 34}}, "f",
ty.void_(), {}); {Param("p", create<ast::Matrix>(Source{{12, 34}}, nullptr, 3u, 3u))}, ty.void_(), {});
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type"); EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type");

View File

@ -28,8 +28,8 @@ TEST_F(ResolverHostShareableValidationTest, BoolMember) {
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -46,8 +46,8 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) {
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -65,8 +65,8 @@ TEST_F(ResolverHostShareableValidationTest, Aliases) {
auto* a2 = Alias("a2", ty.Of(s)); auto* a2 = Alias("a2", ty.Of(s));
GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -87,8 +87,8 @@ TEST_F(ResolverHostShareableValidationTest, NestedStructures) {
GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -129,8 +129,8 @@ TEST_F(ResolverHostShareableValidationTest, NoError) {
GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
WrapInFunction(); WrapInFunction();

View File

@ -1300,8 +1300,8 @@ const sem::CallTarget* Impl::Lookup(CtorConvIntrinsic type,
// Conversion. // Conversion.
return utils::GetOrCreate(converters, match, [&]() { return utils::GetOrCreate(converters, match, [&]() {
auto param = builder.create<sem::Parameter>( auto param = builder.create<sem::Parameter>(
nullptr, 0, match.parameters[0].type, ast::StorageClass::kNone, ast::Access::kUndefined, nullptr, 0u, match.parameters[0].type, ast::StorageClass::kNone,
match.parameters[0].usage); ast::Access::kUndefined, match.parameters[0].usage);
return builder.create<sem::TypeConversion>(match.return_type, param); return builder.create<sem::TypeConversion>(match.return_type, param);
}); });
} }

View File

@ -63,13 +63,13 @@ TEST_F(ResolverPtrRefTest, DefaultPtrStorageClass) {
auto* workgroup = GlobalVar("w", ty.i32(), ast::StorageClass::kWorkgroup); auto* workgroup = GlobalVar("w", ty.i32(), ast::StorageClass::kWorkgroup);
auto* uniform = GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform, auto* uniform = GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* function_ptr = auto* function_ptr =

View File

@ -145,8 +145,8 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) {
auto* buf = Structure("S", {Member("inner", ty.Of(inner))}); auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i);

View File

@ -857,7 +857,7 @@ sem::Function* Resolver::Function(const ast::Function* decl) {
bool Resolver::WorkgroupSize(const ast::Function* func) { bool Resolver::WorkgroupSize(const ast::Function* func) {
// Set work-group size defaults. // Set work-group size defaults.
sem::WorkgroupSize ws; sem::WorkgroupSize ws;
for (int i = 0; i < 3; i++) { for (size_t i = 0; i < 3; i++) {
ws[i].value = 1; ws[i].value = 1;
ws[i].overridable_const = nullptr; ws[i].overridable_const = nullptr;
} }
@ -876,7 +876,7 @@ bool Resolver::WorkgroupSize(const ast::Function* func) {
"workgroup_size argument must be either a literal, constant, or overridable of type " "workgroup_size argument must be either a literal, constant, or overridable of type "
"abstract-integer, i32 or u32"; "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 // Each argument to this attribute can either be a literal, an identifier for a module-scope
// constants, or nullptr if not specified. // constants, or nullptr if not specified.
auto* value = values[i]; auto* value = values[i];
@ -1731,12 +1731,13 @@ void Resolver::CollectTextureSamplerPairs(const sem::Builtin* builtin,
if (texture_index == -1) { if (texture_index == -1) {
TINT_ICE(Resolver, diagnostics_) << "texture builtin without texture parameter"; 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>()) { if (!texture->Type()->UnwrapRef()->Is<sem::StorageTexture>()) {
int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler); int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler);
const sem::Variable* sampler = const sem::Variable* sampler =
sampler_index != -1 ? args[sampler_index]->As<sem::VariableUser>()->Variable() sampler_index != -1
: nullptr; ? args[static_cast<size_t>(sampler_index)]->As<sem::VariableUser>()->Variable()
: nullptr;
current_function_->AddTextureSamplerPair(texture, sampler); current_function_->AddTextureSamplerPair(texture, sampler);
} }
} }
@ -2247,7 +2248,7 @@ sem::Array* Resolver::Array(const ast::Array* arr) {
} }
} }
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()) { if (size > std::numeric_limits<uint32_t>::max()) {
std::stringstream msg; std::stringstream msg;
msg << "array size (0x" << std::hex << size << ") must not exceed 0xffffffff bytes"; msg << "array size (0x" << std::hex << size << ") must not exceed 0xffffffff bytes";

View File

@ -779,8 +779,8 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables) {
auto* sb_var = auto* sb_var =
GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* wg_var = GlobalVar("wg_var", ty.f32(), ast::StorageClass::kWorkgroup); auto* wg_var = GlobalVar("wg_var", ty.f32(), ast::StorageClass::kWorkgroup);
auto* priv_var = GlobalVar("priv_var", ty.f32(), ast::StorageClass::kPrivate); auto* priv_var = GlobalVar("priv_var", ty.f32(), ast::StorageClass::kPrivate);
@ -812,8 +812,8 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) {
auto* sb_var = auto* sb_var =
GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* wg_var = GlobalVar("wg_var", ty.f32(), ast::StorageClass::kWorkgroup); auto* wg_var = GlobalVar("wg_var", ty.f32(), ast::StorageClass::kWorkgroup);
auto* priv_var = GlobalVar("priv_var", ty.f32(), ast::StorageClass::kPrivate); auto* priv_var = GlobalVar("priv_var", ty.f32(), ast::StorageClass::kPrivate);
@ -1737,8 +1737,8 @@ TEST_F(ResolverTest, StorageClass_SetForSampler) {
auto* t = ty.sampler(ast::SamplerKind::kSampler); auto* t = ty.sampler(ast::SamplerKind::kSampler);
auto* var = GlobalVar("var", t, auto* var = GlobalVar("var", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
EXPECT_TRUE(r()->Resolve()) << r()->error(); EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1750,8 +1750,8 @@ TEST_F(ResolverTest, StorageClass_SetForTexture) {
auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
auto* var = GlobalVar("var", t, auto* var = GlobalVar("var", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
EXPECT_TRUE(r()->Resolve()) << r()->error(); EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1775,8 +1775,8 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) {
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}); auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
auto* var = GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, auto* var = GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
EXPECT_TRUE(r()->Resolve()) << r()->error(); EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -1789,10 +1789,10 @@ TEST_F(ResolverTest, BindingPoint_SetForResources) {
// @group(3) @binding(4) var s2 : sampler; // @group(3) @binding(4) var s2 : sampler;
auto* s1 = GlobalVar( auto* s1 = GlobalVar(
Sym(), ty.sampler(ast::SamplerKind::kSampler), 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( auto* s2 = GlobalVar(
Sym(), ty.sampler(ast::SamplerKind::kSampler), 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(); EXPECT_TRUE(r()->Resolve()) << r()->error();

View File

@ -87,8 +87,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBool) {
// var<storage> g : bool; // var<storage> g : bool;
GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kStorage, GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -104,8 +104,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferPointer) {
GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate), GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate),
ast::StorageClass::kStorage, ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -120,8 +120,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferIntScalar) {
// var<storage> g : i32; // var<storage> g : i32;
GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kStorage, GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -131,8 +131,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferVector) {
// var<storage> g : vec4<f32>; // var<storage> g : vec4<f32>;
GlobalVar(Source{{56, 78}}, "g", ty.vec4<f32>(), ast::StorageClass::kStorage, GlobalVar(Source{{56, 78}}, "g", ty.vec4<f32>(), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -144,8 +144,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferArray) {
auto* a = ty.array(ty.Of(s), 3_u); auto* a = ty.array(ty.Of(s), 3_u);
GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -157,8 +157,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBoolAlias) {
auto* a = Alias("a", ty.bool_()); auto* a = Alias("a", ty.bool_());
GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kStorage, GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -186,8 +186,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Basic) {
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}); 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, GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()); ASSERT_TRUE(r()->Resolve());
@ -202,8 +202,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Aliases) {
auto* a2 = Alias("a2", ty.Of(a1)); auto* a2 = Alias("a2", ty.Of(a1));
GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()); ASSERT_TRUE(r()->Resolve());
@ -217,8 +217,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBuffer_Struct_Runtime) {
GlobalVar(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform, GlobalVar(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -232,8 +232,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferBool) {
// var<uniform> g : bool; // var<uniform> g : bool;
GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kUniform, GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -249,8 +249,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferPointer) {
GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate), GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate),
ast::StorageClass::kUniform, ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -265,8 +265,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferIntScalar) {
// var<uniform> g : i32; // var<uniform> g : i32;
GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kUniform, GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -276,8 +276,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferVector) {
// var<uniform> g : vec4<f32>; // var<uniform> g : vec4<f32>;
GlobalVar(Source{{56, 78}}, "g", ty.vec4<f32>(), ast::StorageClass::kUniform, GlobalVar(Source{{56, 78}}, "g", ty.vec4<f32>(), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -292,8 +292,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferArray) {
auto* a = ty.array(ty.Of(s), 3_u); auto* a = ty.array(ty.Of(s), 3_u);
GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform, GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -305,8 +305,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferBoolAlias) {
auto* a = Alias("a", ty.bool_()); auto* a = Alias("a", ty.bool_());
GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kUniform, GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_FALSE(r()->Resolve()); ASSERT_FALSE(r()->Resolve());
@ -323,8 +323,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Basic) {
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}); auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform, GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -338,8 +338,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Aliases) {
auto* a1 = Alias("a1", ty.Of(s)); auto* a1 = Alias("a1", ty.Of(s));
GlobalVar(Source{{56, 78}}, "g", ty.Of(a1), ast::StorageClass::kUniform, GlobalVar(Source{{56, 78}}, "g", ty.Of(a1), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();

View File

@ -161,13 +161,13 @@ TEST_F(ResolverStorageClassUseTest, StructMultipleStorageClassUses) {
auto* s = Structure("S", {Member("a", ty.f32())}); auto* s = Structure("S", {Member("a", ty.f32())});
GlobalVar("x", ty.Of(s), ast::StorageClass::kUniform, GlobalVar("x", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GlobalVar("y", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("y", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
WrapInFunction(Var("g", ty.Of(s))); WrapInFunction(Var("g", ty.Of(s)));

View File

@ -1856,11 +1856,11 @@ TEST_F(ResolverTypeConstructorValidationTest,
TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromScalars) { TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromScalars) {
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), Expr(true), Expr(false)); auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2u), Expr(true), Expr(false));
auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_i), Expr(2_i)); auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2u), Expr(1_i), Expr(2_i));
auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_u), Expr(2_u)); auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2u), Expr(1_u), Expr(2_u));
auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_f), Expr(2_f)); auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2u), Expr(1_f), Expr(2_f));
auto* vec2_f16 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_h), Expr(2_h)); 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); WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32, vec2_f16);
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -1890,11 +1890,11 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromScalars) {
TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromVec2) { TEST_F(ResolverTypeConstructorValidationTest, InferVec2ElementTypeFromVec2) {
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), vec2<bool>(true, false)); auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2u), vec2<bool>(true, false));
auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), vec2<i32>(1_i, 2_i)); auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2u), vec2<i32>(1_i, 2_i));
auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), vec2<u32>(1_u, 2_u)); auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2u), vec2<u32>(1_u, 2_u));
auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), vec2<f32>(1_f, 2_f)); auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2u), vec2<f32>(1_f, 2_f));
auto* vec2_f16 = Construct(create<ast::Vector>(nullptr, 2), vec2<f16>(1_h, 2_h)); 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); WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32, vec2_f16);
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -1925,11 +1925,11 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalars) {
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
auto* vec3_bool = auto* vec3_bool =
Construct(create<ast::Vector>(nullptr, 3), Expr(true), Expr(false), Expr(true)); Construct(create<ast::Vector>(nullptr, 3u), 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_i32 = Construct(create<ast::Vector>(nullptr, 3u), 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_u32 = Construct(create<ast::Vector>(nullptr, 3u), 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_f32 = Construct(create<ast::Vector>(nullptr, 3u), 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)); 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); WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32, vec3_f16);
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -1959,11 +1959,11 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalars) {
TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromVec3) { TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromVec3) {
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
auto* vec3_bool = Construct(create<ast::Vector>(nullptr, 3), vec3<bool>(true, false, true)); auto* vec3_bool = Construct(create<ast::Vector>(nullptr, 3u), vec3<bool>(true, false, true));
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), vec3<i32>(1_i, 2_i, 3_i)); 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, 3), vec3<u32>(1_u, 2_u, 3_u)); 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, 3), vec3<f32>(1_f, 2_f, 3_f)); 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, 3), vec3<f16>(1_h, 2_h, 3_h)); 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); WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32, vec3_f16);
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -1994,11 +1994,11 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalarAndV
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
auto* vec3_bool = auto* vec3_bool =
Construct(create<ast::Vector>(nullptr, 3), Expr(true), vec2<bool>(false, true)); Construct(create<ast::Vector>(nullptr, 3u), 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_i32 = Construct(create<ast::Vector>(nullptr, 3u), 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_u32 = Construct(create<ast::Vector>(nullptr, 3u), 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_f32 = Construct(create<ast::Vector>(nullptr, 3u), 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)); 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); WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32, vec3_f16);
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -2028,16 +2028,16 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec3ElementTypeFromScalarAndV
TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalars) { TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalars) {
Enable(ast::Extension::kF16); 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)); Expr(true), Expr(false));
auto* vec4_i32 = 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 = 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 = 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 = 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); WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32, vec4_f16);
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -2068,11 +2068,11 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec4) {
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
auto* vec4_bool = auto* vec4_bool =
Construct(create<ast::Vector>(nullptr, 4), vec4<bool>(true, false, true, false)); Construct(create<ast::Vector>(nullptr, 4u), 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_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, 4), vec4<u32>(1_u, 2_u, 3_u, 4_u)); 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, 4), vec4<f32>(1_f, 2_f, 3_f, 4_f)); 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, 4), vec4<f16>(1_h, 2_h, 3_h, 4_h)); 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); WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32, vec4_f16);
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -2103,15 +2103,15 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalarAndV
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
auto* vec4_bool = 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 = 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 = 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 = 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 = 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); WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32, vec4_f16);
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -2141,16 +2141,16 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromScalarAndV
TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec2AndVec2) { TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec2AndVec2) {
Enable(ast::Extension::kF16); 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)); vec2<bool>(true, false));
auto* vec4_i32 = 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 = 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 = 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 = 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); WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32, vec4_f16);
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -2178,14 +2178,14 @@ TEST_F(ResolverTypeConstructorValidationTest, InferVec4ElementTypeFromVec2AndVec
} }
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVectorElementTypeWithoutArgs) { 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_FALSE(r()->Resolve());
EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for vec3()")); EXPECT_THAT(r()->error(), HasSubstr("12:34 error: no matching constructor for vec3()"));
} }
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec2ElementTypeFromScalarsMismatch) { 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, 2}}, 1_i), //
Expr(Source{{1, 3}}, 2_u))); Expr(Source{{1, 3}}, 2_u)));
@ -2194,7 +2194,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec2ElementTypeFromScal
} }
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScalarsMismatch) { 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, 2}}, 1_i), //
Expr(Source{{1, 3}}, 2_u), // Expr(Source{{1, 3}}, 2_u), //
Expr(Source{{1, 4}}, 3_i))); Expr(Source{{1, 4}}, 3_i)));
@ -2205,7 +2205,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScal
} }
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScalarAndVec2Mismatch) { 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), // Expr(Source{{1, 2}}, 1_i), //
Construct(Source{{1, 3}}, ty.vec2<f32>(), 2_f, 3_f))); Construct(Source{{1, 3}}, ty.vec2<f32>(), 2_f, 3_f)));
@ -2215,7 +2215,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScal
} }
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScalarsMismatch) { 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, 2}}, 1_i), //
Expr(Source{{1, 3}}, 2_i), // Expr(Source{{1, 3}}, 2_i), //
Expr(Source{{1, 4}}, 3_f), // Expr(Source{{1, 4}}, 3_f), //
@ -2227,7 +2227,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScal
} }
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScalarAndVec3Mismatch) { 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), // Expr(Source{{1, 2}}, 1_i), //
Construct(Source{{1, 3}}, ty.vec3<u32>(), 2_u, 3_u, 4_u))); Construct(Source{{1, 3}}, ty.vec3<u32>(), 2_u, 3_u, 4_u)));
@ -2237,7 +2237,7 @@ TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScal
} }
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromVec2AndVec2Mismatch) { 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, 2}}, ty.vec2<i32>(), 3_i, 4_i), //
Construct(Source{{1, 3}}, ty.vec2<u32>(), 3_u, 4_u))); Construct(Source{{1, 3}}, ty.vec2<u32>(), 3_u, 4_u)));

View File

@ -402,7 +402,7 @@ TEST_F(ResolverTypeValidationTest, Struct_Member_VectorNoType) {
// a: vec3; // 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_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing vector element type"); EXPECT_EQ(r()->error(), "12:34 error: missing vector element type");
@ -412,7 +412,7 @@ TEST_F(ResolverTypeValidationTest, Struct_Member_MatrixNoType) {
// struct S { // struct S {
// a: mat3x3; // 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_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type"); EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type");

View File

@ -326,8 +326,8 @@ TEST_F(ResolverValidationTest, StorageClass_SamplerExplicitStorageClass) {
auto* t = ty.sampler(ast::SamplerKind::kSampler); auto* t = ty.sampler(ast::SamplerKind::kSampler);
GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle, GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());
@ -340,8 +340,8 @@ TEST_F(ResolverValidationTest, StorageClass_TextureExplicitStorageClass) {
auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle, GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
EXPECT_FALSE(r()->Resolve()) << r()->error(); EXPECT_FALSE(r()->Resolve()) << r()->error();

View File

@ -1609,7 +1609,7 @@ bool Validator::TextureBuiltinFunction(const sem::Call* call) const {
return true; return true;
} }
std::string name = sem::str(usage); 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()) { if (auto values = arg->ConstantValue()) {
// Assert that the constant values are of the expected type. // Assert that the constant values are of the expected type.
if (!values.Type()->IsAnyOf<sem::I32, sem::Vector>() || if (!values.Type()->IsAnyOf<sem::I32, sem::Vector>() ||
@ -1631,7 +1631,8 @@ bool Validator::TextureBuiltinFunction(const sem::Call* call) const {
return ast::TraverseAction::Stop; return ast::TraverseAction::Stop;
}); });
if (is_const_expr) { 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++) { for (size_t i = 0, n = values.ElementCount(); i < n; i++) {
auto value = values.Element<AInt>(i).value; auto value = values.Element<AInt>(i).value;
if (value < min || value > max) { if (value < min || value > max) {

View File

@ -472,8 +472,8 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) {
auto* buf = Structure("S", {Member("inner", ty.Of(inner))}); auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 4_i); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 4_i);
@ -1049,18 +1049,18 @@ TEST_F(ResolverVariableTest, GlobalVar_StorageClass) {
auto* workgroup = GlobalVar("w", ty.i32(), ast::StorageClass::kWorkgroup); auto* workgroup = GlobalVar("w", ty.i32(), ast::StorageClass::kWorkgroup);
auto* uniform = GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform, auto* uniform = GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* handle = GlobalVar("h", ty.depth_texture(ast::TextureDimension::k2d), auto* handle = GlobalVar("h", ty.depth_texture(ast::TextureDimension::k2d),
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(2), create<ast::BindingAttribute>(2u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -1085,8 +1085,8 @@ TEST_F(ResolverVariableTest, GlobalVar_ExplicitStorageClass) {
auto* storage = auto* storage =
GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();

View File

@ -245,8 +245,8 @@ TEST_F(ResolverVariableValidationTest, InferredPtrStorageAccessMismatch) {
auto* buf = Structure("S", {Member("inner", ty.Of(inner))}); auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i);
@ -318,7 +318,7 @@ TEST_F(ResolverVariableValidationTest, InvalidStorageClassForInitializer) {
TEST_F(ResolverVariableValidationTest, VectorConstNoType) { TEST_F(ResolverVariableValidationTest, VectorConstNoType) {
// const a : mat3x3 = mat3x3<f32>(); // 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_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing vector element type"); EXPECT_EQ(r()->error(), "12:34 error: missing vector element type");
@ -326,7 +326,7 @@ TEST_F(ResolverVariableValidationTest, VectorConstNoType) {
TEST_F(ResolverVariableValidationTest, VectorLetNoType) { TEST_F(ResolverVariableValidationTest, VectorLetNoType) {
// let a : mat3x3 = mat3x3<f32>(); // 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_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing vector element type"); EXPECT_EQ(r()->error(), "12:34 error: missing vector element type");
@ -334,7 +334,7 @@ TEST_F(ResolverVariableValidationTest, VectorLetNoType) {
TEST_F(ResolverVariableValidationTest, VectorVarNoType) { TEST_F(ResolverVariableValidationTest, VectorVarNoType) {
// var a : mat3x3; // 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_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing vector element type"); EXPECT_EQ(r()->error(), "12:34 error: missing vector element type");
@ -342,7 +342,8 @@ TEST_F(ResolverVariableValidationTest, VectorVarNoType) {
TEST_F(ResolverVariableValidationTest, MatrixConstNoType) { TEST_F(ResolverVariableValidationTest, MatrixConstNoType) {
// const a : mat3x3 = mat3x3<f32>(); // 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_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type"); EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type");
@ -350,7 +351,7 @@ TEST_F(ResolverVariableValidationTest, MatrixConstNoType) {
TEST_F(ResolverVariableValidationTest, MatrixLetNoType) { TEST_F(ResolverVariableValidationTest, MatrixLetNoType) {
// let a : mat3x3 = mat3x3<f32>(); // 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_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type"); EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type");
@ -358,7 +359,7 @@ TEST_F(ResolverVariableValidationTest, MatrixLetNoType) {
TEST_F(ResolverVariableValidationTest, MatrixVarNoType) { TEST_F(ResolverVariableValidationTest, MatrixVarNoType) {
// var a : mat3x3; // 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_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type"); EXPECT_EQ(r()->error(), "12:34 error: missing matrix element type");

View File

@ -91,4 +91,6 @@ VariableUser::VariableUser(const ast::IdentifierExpression* declaration,
} }
} }
VariableUser::~VariableUser() = default;
} // namespace tint::sem } // namespace tint::sem

View File

@ -226,6 +226,7 @@ class VariableUser final : public Castable<VariableUser, Expression> {
VariableUser(const ast::IdentifierExpression* declaration, VariableUser(const ast::IdentifierExpression* declaration,
Statement* statement, Statement* statement,
sem::Variable* variable); sem::Variable* variable);
~VariableUser() override;
/// @returns the variable that this expression refers to /// @returns the variable that this expression refers to
const sem::Variable* Variable() const { return variable_; } const sem::Variable* Variable() const { return variable_; }

View File

@ -225,19 +225,21 @@ struct CombineSamplers::State {
// Replace all texture builtin calls. // Replace all texture builtin calls.
if (auto* builtin = call->Target()->As<sem::Builtin>()) { if (auto* builtin = call->Target()->As<sem::Builtin>()) {
const auto& signature = builtin->Signature(); const auto& signature = builtin->Signature();
int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler); auto sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler);
int texture_index = signature.IndexOf(sem::ParameterUsage::kTexture); auto texture_index = signature.IndexOf(sem::ParameterUsage::kTexture);
if (texture_index == -1) { if (texture_index == -1) {
return nullptr; 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 // We don't want to combine storage textures with anything, since
// they never have associated samplers in GLSL. // they never have associated samplers in GLSL.
if (texture->Type()->UnwrapRef()->Is<sem::StorageTexture>()) { if (texture->Type()->UnwrapRef()->Is<sem::StorageTexture>()) {
return nullptr; return nullptr;
} }
const sem::Expression* sampler = 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* texture_var = texture->As<sem::VariableUser>()->Variable();
auto* sampler_var = auto* sampler_var =
sampler ? sampler->As<sem::VariableUser>()->Variable() : nullptr; sampler ? sampler->As<sem::VariableUser>()->Variable() : nullptr;

View File

@ -377,10 +377,10 @@ struct DecomposeMemoryAccess::State {
auto* lhs_lit = tint::As<OffsetLiteral>(lhs); auto* lhs_lit = tint::As<OffsetLiteral>(lhs);
auto* rhs_lit = tint::As<OffsetLiteral>(rhs); auto* rhs_lit = tint::As<OffsetLiteral>(rhs);
if (lhs_lit && lhs_lit->literal == 0) { if (lhs_lit && lhs_lit->literal == 0) {
return offsets_.Create<OffsetLiteral>(0); return offsets_.Create<OffsetLiteral>(0u);
} }
if (rhs_lit && rhs_lit->literal == 0) { if (rhs_lit && rhs_lit->literal == 0) {
return offsets_.Create<OffsetLiteral>(0); return offsets_.Create<OffsetLiteral>(0u);
} }
if (lhs_lit && lhs_lit->literal == 1) { if (lhs_lit && lhs_lit->literal == 1) {
return rhs; return rhs;
@ -831,7 +831,7 @@ void DecomposeMemoryAccess::Run(CloneContext& ctx, const DataMap&, DataMap&) con
if (swizzle->Indices().size() == 1) { if (swizzle->Indices().size() == 1) {
if (auto access = state.TakeAccess(accessor->structure)) { if (auto access = state.TakeAccess(accessor->structure)) {
auto* vec_ty = access.type->As<sem::Vector>(); 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, { state.AddAccess(accessor, {
access.var, access.var,
state.Add(access.offset, offset), state.Add(access.offset, offset),

View File

@ -71,8 +71,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix) {
"S", { "S", {
b.Member("m", b.ty.mat2x2<f32>(), b.Member("m", b.ty.mat2x2<f32>(),
{ {
b.create<ast::StructMemberOffsetAttribute>(16), b.create<ast::StructMemberOffsetAttribute>(16u),
b.create<ast::StrideAttribute>(32), b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}), }),
}); });
@ -127,8 +127,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformColumn) {
"S", { "S", {
b.Member("m", b.ty.mat2x2<f32>(), b.Member("m", b.ty.mat2x2<f32>(),
{ {
b.create<ast::StructMemberOffsetAttribute>(16), b.create<ast::StructMemberOffsetAttribute>(16u),
b.create<ast::StrideAttribute>(32), b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}), }),
}); });
@ -180,8 +180,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix_DefaultStride) {
"S", { "S", {
b.Member("m", b.ty.mat2x2<f32>(), b.Member("m", b.ty.mat2x2<f32>(),
{ {
b.create<ast::StructMemberOffsetAttribute>(16), b.create<ast::StructMemberOffsetAttribute>(16u),
b.create<ast::StrideAttribute>(8), b.create<ast::StrideAttribute>(8u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}), }),
}); });
@ -233,8 +233,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) {
"S", { "S", {
b.Member("m", b.ty.mat2x2<f32>(), b.Member("m", b.ty.mat2x2<f32>(),
{ {
b.create<ast::StructMemberOffsetAttribute>(8), b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32), b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}), }),
}); });
@ -290,8 +290,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) {
"S", { "S", {
b.Member("m", b.ty.mat2x2<f32>(), b.Member("m", b.ty.mat2x2<f32>(),
{ {
b.create<ast::StructMemberOffsetAttribute>(16), b.create<ast::StructMemberOffsetAttribute>(16u),
b.create<ast::StrideAttribute>(32), b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}), }),
}); });
@ -344,8 +344,8 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
"S", { "S", {
b.Member("m", b.ty.mat2x2<f32>(), b.Member("m", b.ty.mat2x2<f32>(),
{ {
b.create<ast::StructMemberOffsetAttribute>(8), b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32), b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}), }),
}); });
@ -402,8 +402,8 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
"S", { "S", {
b.Member("m", b.ty.mat2x2<f32>(), b.Member("m", b.ty.mat2x2<f32>(),
{ {
b.create<ast::StructMemberOffsetAttribute>(8), b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32), b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}), }),
}); });
@ -461,8 +461,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
"S", { "S", {
b.Member("m", b.ty.mat2x2<f32>(), b.Member("m", b.ty.mat2x2<f32>(),
{ {
b.create<ast::StructMemberOffsetAttribute>(8), b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32), b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}), }),
}); });
@ -532,8 +532,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadPrivateMatrix) {
"S", { "S", {
b.Member("m", b.ty.mat2x2<f32>(), b.Member("m", b.ty.mat2x2<f32>(),
{ {
b.create<ast::StructMemberOffsetAttribute>(8), b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32), b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}), }),
}); });
@ -585,8 +585,8 @@ TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) {
"S", { "S", {
b.Member("m", b.ty.mat2x2<f32>(), b.Member("m", b.ty.mat2x2<f32>(),
{ {
b.create<ast::StructMemberOffsetAttribute>(8), b.create<ast::StructMemberOffsetAttribute>(8u),
b.create<ast::StrideAttribute>(32), b.create<ast::StrideAttribute>(32u),
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}), }),
}); });

View File

@ -223,9 +223,9 @@ struct Robustness::State {
auto array_idx = signature.IndexOf(sem::ParameterUsage::kArrayIndex); auto array_idx = signature.IndexOf(sem::ParameterUsage::kArrayIndex);
auto level_idx = signature.IndexOf(sem::ParameterUsage::kLevel); auto level_idx = signature.IndexOf(sem::ParameterUsage::kLevel);
auto* texture_arg = expr->args[texture_idx]; auto* texture_arg = expr->args[static_cast<size_t>(texture_idx)];
auto* coords_arg = expr->args[coords_idx]; auto* coords_arg = expr->args[static_cast<size_t>(coords_idx)];
auto* coords_ty = builtin->Parameters()[coords_idx]->Type(); 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 // 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 // used by textureDimensions() and the texture[Load|Store]() calls, we need
@ -235,7 +235,7 @@ struct Robustness::State {
std::function<const ast::Expression*()> level_arg; std::function<const ast::Expression*()> level_arg;
if (level_idx >= 0) { if (level_idx >= 0) {
level_arg = [&] { 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* num_levels = b.Call("textureNumLevels", ctx.Clone(texture_arg));
auto* zero = b.Expr(0_i); auto* zero = b.Expr(0_i);
auto* max = ctx.dst->Sub(num_levels, 1_i); auto* max = ctx.dst->Sub(num_levels, 1_i);
@ -258,7 +258,7 @@ struct Robustness::State {
// Clamp the array_index argument, if provided // Clamp the array_index argument, if provided
if (array_idx >= 0) { 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* num_layers = b.Call("textureNumLayers", ctx.Clone(texture_arg));
auto* zero = b.Expr(0_i); auto* zero = b.Expr(0_i);
auto* max = ctx.dst->Sub(num_layers, 1_i); auto* max = ctx.dst->Sub(num_layers, 1_i);
@ -268,7 +268,7 @@ struct Robustness::State {
// Clamp the level argument, if provided // Clamp the level argument, if provided
if (level_idx >= 0) { 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)); ctx.Replace(arg, level_arg ? level_arg() : ctx.dst->Expr(0_i));
} }

View File

@ -67,7 +67,7 @@ TEST_F(BlockAllocatorTest, ObjectLifetime) {
TEST_F(BlockAllocatorTest, MoveConstruct) { TEST_F(BlockAllocatorTest, MoveConstruct) {
using Allocator = BlockAllocator<LifetimeCounter>; 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; size_t count = 0;
{ {
Allocator allocator_a; Allocator allocator_a;
@ -87,7 +87,7 @@ TEST_F(BlockAllocatorTest, MoveConstruct) {
TEST_F(BlockAllocatorTest, MoveAssign) { TEST_F(BlockAllocatorTest, MoveAssign) {
using Allocator = BlockAllocator<LifetimeCounter>; 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_a = 0;
size_t count_b = 0; size_t count_b = 0;

View File

@ -25,7 +25,11 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define TINT_DISABLE_WARNING_CONSTANT_OVERFLOW __pragma(warning(disable : 4756)) #define TINT_DISABLE_WARNING_CONSTANT_OVERFLOW __pragma(warning(disable : 4756))
#define TINT_DISABLE_WARNING_MAYBE_UNINITIALIZED /* currently no-op */ #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_UNREACHABLE_CODE __pragma(warning(disable : 4702))
#define TINT_DISABLE_WARNING_WEAK_VTABLES /* currently no-op */
// clang-format off // clang-format off
#define TINT_BEGIN_DISABLE_WARNING(name) \ #define TINT_BEGIN_DISABLE_WARNING(name) \
@ -42,7 +46,12 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#define TINT_DISABLE_WARNING_CONSTANT_OVERFLOW /* currently no-op */ #define TINT_DISABLE_WARNING_CONSTANT_OVERFLOW /* currently no-op */
#define TINT_DISABLE_WARNING_MAYBE_UNINITIALIZED /* 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_UNREACHABLE_CODE /* currently no-op */
#define TINT_DISABLE_WARNING_WEAK_VTABLES _Pragma("clang diagnostic ignored \"-Wweak-vtables\"")
// clang-format off // clang-format off
#define TINT_BEGIN_DISABLE_WARNING(name) \ #define TINT_BEGIN_DISABLE_WARNING(name) \
@ -60,7 +69,11 @@
#define TINT_DISABLE_WARNING_CONSTANT_OVERFLOW /* currently no-op */ #define TINT_DISABLE_WARNING_CONSTANT_OVERFLOW /* currently no-op */
#define TINT_DISABLE_WARNING_MAYBE_UNINITIALIZED \ #define TINT_DISABLE_WARNING_MAYBE_UNINITIALIZED \
_Pragma("GCC diagnostic ignored \"-Wmaybe-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_UNREACHABLE_CODE /* currently no-op */
#define TINT_DISABLE_WARNING_WEAK_VTABLES /* currently no-op */
// clang-format off // clang-format off
#define TINT_BEGIN_DISABLE_WARNING(name) \ #define TINT_BEGIN_DISABLE_WARNING(name) \

View File

@ -135,7 +135,7 @@ const sem::Call* AppendVector(ProgramBuilder* b,
auto* scalar_cast_ast = b->Construct(packed_el_ast_ty, scalar_ast); auto* scalar_cast_ast = b->Construct(packed_el_ast_ty, scalar_ast);
auto* scalar_cast_target = b->create<sem::TypeConversion>( auto* scalar_cast_target = b->create<sem::TypeConversion>(
packed_el_sem_ty, 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)); ast::StorageClass::kNone, ast::Access::kUndefined));
auto* scalar_cast_sem = b->create<sem::Call>( auto* scalar_cast_sem = b->create<sem::Call>(
scalar_cast_ast, scalar_cast_target, std::vector<const sem::Expression*>{scalar_sem}, scalar_cast_ast, scalar_cast_target, std::vector<const sem::Expression*>{scalar_sem},

View File

@ -27,7 +27,7 @@ namespace {
// - 0 sign if sign is 0, 1 otherwise // - 0 sign if sign is 0, 1 otherwise
// - 'exponent_bits' is placed in the exponent space. // - 'exponent_bits' is placed in the exponent space.
// So, the exponent bias must already be included. // 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; const uint32_t sign_bit = sign ? 0x80000000u : 0u;
// The binary32 exponent is 8 bits, just below the sign. // The binary32 exponent is 8 bits, just below the sign.
const uint32_t exponent_bits = (biased_exponent & 0xffu) << 23; const uint32_t exponent_bits = (biased_exponent & 0xffu) << 23;

View File

@ -1349,8 +1349,8 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
// Returns the argument with the given usage // Returns the argument with the given usage
auto arg = [&](Usage usage) { auto arg = [&](Usage usage) {
int idx = signature.IndexOf(usage); auto 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); auto* texture = arg(Usage::kTexture);
@ -2138,7 +2138,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
// Emit the layout(local_size) attributes. // Emit the layout(local_size) attributes.
auto wgsize = func_sem->WorkgroupSize(); auto wgsize = func_sem->WorkgroupSize();
out << "layout("; out << "layout(";
for (int i = 0; i < 3; i++) { for (size_t i = 0; i < 3; i++) {
if (i > 0) { if (i > 0) {
out << ", "; out << ", ";
} }

View File

@ -351,8 +351,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())}); auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
Func("sub_func", Func("sub_func",
@ -405,8 +405,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStr
GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform, GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, auto* var = Var("v", ty.f32(), ast::StorageClass::kNone,
@ -450,8 +450,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@ -500,8 +500,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@ -551,8 +551,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
Func("frag_main", {}, ty.void_(), Func("frag_main", {}, ty.void_(),
@ -599,8 +599,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
Func("frag_main", {}, ty.void_(), Func("frag_main", {}, ty.void_(),
@ -643,8 +643,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
auto* s = Structure("S", {Member("x", ty.f32())}); auto* s = Structure("S", {Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform, GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
Func("sub_func", {Param("param", ty.f32())}, ty.f32(), Func("sub_func", {Param("param", ty.f32())}, ty.f32(),
@ -692,8 +692,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
auto* s = Structure("S", {Member("x", ty.f32())}); auto* s = Structure("S", {Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
Func("sub_func", {Param("param", ty.f32())}, ty.f32(), Func("sub_func", {Param("param", ty.f32())}, ty.f32(),
@ -921,8 +921,8 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
{ {

View File

@ -93,8 +93,8 @@ class GlslGeneratorImplTest_MemberAccessorBase : public BASE {
b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
b.create<ast::BindingAttribute>(0), b.create<ast::BindingAttribute>(0u),
b.create<ast::GroupAttribute>(1), b.create<ast::GroupAttribute>(1u),
}); });
} }

View File

@ -28,8 +28,8 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -71,8 +71,8 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
}); });
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -113,8 +113,8 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
auto* p = Let("p", nullptr, AddressOf("b")); auto* p = Let("p", nullptr, AddressOf("b"));

View File

@ -37,8 +37,8 @@ void TestAlign(ProgramBuilder* ctx) {
}); });
ctx->GlobalVar("nephews", ctx->ty.Of(nephews), ast::StorageClass::kStorage, ctx->GlobalVar("nephews", ctx->ty.Of(nephews), ast::StorageClass::kStorage,
ast::AttributeList{ ast::AttributeList{
ctx->create<ast::BindingAttribute>(0), ctx->create<ast::BindingAttribute>(0u),
ctx->create<ast::GroupAttribute>(0), ctx->create<ast::GroupAttribute>(0u),
}); });
} }

View File

@ -272,8 +272,8 @@ TEST_P(GlslDepthTexturesTest, Emit) {
GlobalVar("tex", t, GlobalVar("tex", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
@ -299,8 +299,8 @@ TEST_F(GlslDepthMultisampledTexturesTest, Emit) {
GlobalVar("tex", t, GlobalVar("tex", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
@ -342,8 +342,8 @@ TEST_P(GlslSampledTexturesTest, Emit) {
GlobalVar("tex", t, GlobalVar("tex", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
@ -476,8 +476,8 @@ TEST_P(GlslStorageTexturesTest, Emit) {
GlobalVar("tex", t, GlobalVar("tex", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},

View File

@ -2107,7 +2107,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
// Returns the argument with the given usage // Returns the argument with the given usage
auto arg = [&](Usage usage) { auto arg = [&](Usage usage) {
int idx = signature.IndexOf(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); auto* texture = arg(Usage::kTexture);
@ -3039,7 +3039,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) {
// Emit the workgroup_size attribute. // Emit the workgroup_size attribute.
auto wgsize = func_sem->WorkgroupSize(); auto wgsize = func_sem->WorkgroupSize();
out << "[numthreads("; out << "[numthreads(";
for (int i = 0; i < 3; i++) { for (size_t i = 0; i < 3; i++) {
if (i > 0) { if (i > 0) {
out << ", "; out << ", ";
} }

View File

@ -99,7 +99,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_Default) {
gen.increment_indent(); 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: { EXPECT_EQ(gen.result(), R"( default: {
break; break;
} }

View File

@ -348,8 +348,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())}); auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
Func("sub_func", Func("sub_func",
@ -395,8 +395,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStr
GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform, GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, auto* var = Var("v", ty.f32(), ast::StorageClass::kNone,
@ -433,8 +433,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@ -469,8 +469,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@ -505,8 +505,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
Func("frag_main", {}, ty.void_(), Func("frag_main", {}, ty.void_(),
@ -539,8 +539,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
Func("frag_main", {}, ty.void_(), Func("frag_main", {}, ty.void_(),
@ -569,8 +569,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
auto* s = Structure("S", {Member("x", ty.f32())}); auto* s = Structure("S", {Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform, GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
Func("sub_func", Func("sub_func",
@ -615,8 +615,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_
auto* s = Structure("S", {Member("x", ty.f32())}); auto* s = Structure("S", {Member("x", ty.f32())});
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
}); });
Func("sub_func", Func("sub_func",
@ -861,8 +861,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
{ {

View File

@ -93,8 +93,8 @@ class HlslGeneratorImplTest_MemberAccessorBase : public BASE {
b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
b.create<ast::BindingAttribute>(0), b.create<ast::BindingAttribute>(0u),
b.create<ast::GroupAttribute>(1), b.create<ast::GroupAttribute>(1u),
}); });
} }

View File

@ -28,8 +28,8 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -66,8 +66,8 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
}); });
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -102,8 +102,8 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
auto* p = Let("p", nullptr, AddressOf("b")); auto* p = Let("p", nullptr, AddressOf("b"));
@ -142,13 +142,13 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(2), create<ast::BindingAttribute>(2u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),

View File

@ -155,8 +155,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) {
}); });
GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -289,8 +289,8 @@ TEST_P(HlslDepthTexturesTest, Emit) {
GlobalVar("tex", t, GlobalVar("tex", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
@ -319,8 +319,8 @@ TEST_F(HlslDepthMultisampledTexturesTest, Emit) {
GlobalVar("tex", t, GlobalVar("tex", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
@ -362,8 +362,8 @@ TEST_P(HlslSampledTexturesTest, Emit) {
GlobalVar("tex", t, GlobalVar("tex", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},

View File

@ -759,7 +759,7 @@ bool GeneratorImpl::EmitTypeConstructor(std::ostream& out,
return false; return false;
} }
int i = 0; size_t i = 0;
for (auto* arg : call->Arguments()) { for (auto* arg : call->Arguments()) {
if (i > 0) { if (i > 0) {
out << ", "; out << ", ";
@ -920,7 +920,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& out,
// Returns the argument with the given usage // Returns the argument with the given usage
auto arg = [&](Usage usage) { auto arg = [&](Usage usage) {
int idx = signature.IndexOf(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(); auto* texture = arg(Usage::kTexture)->Declaration();

View File

@ -337,8 +337,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RW_StorageBu
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@ -379,8 +379,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RO_StorageBu
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b"));
@ -417,8 +417,8 @@ TEST_F(MslGeneratorImplTest, Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())}); auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
Func("sub_func", Func("sub_func",
@ -471,8 +471,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RW
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
Func("sub_func", Func("sub_func",
@ -526,8 +526,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RO
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
Func("sub_func", Func("sub_func",
@ -667,8 +667,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_ModuleV
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
{ {

View File

@ -29,8 +29,8 @@ TEST_F(MslSanitizerTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -87,8 +87,8 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
}); });
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -144,8 +144,8 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
auto* p = Let("p", nullptr, AddressOf("b")); auto* p = Let("p", nullptr, AddressOf("b"));
@ -204,13 +204,13 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(2), create<ast::BindingAttribute>(2u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -269,13 +269,13 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniformMissingBinding)
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(2), create<ast::BindingAttribute>(2u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),

View File

@ -249,8 +249,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) {
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -358,8 +358,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_Structures) {
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -452,8 +452,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) {
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -538,8 +538,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayVec3DefaultStride) {
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -602,8 +602,8 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) {
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -663,8 +663,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) {
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -830,8 +830,8 @@ TEST_P(MslStorageTexturesTest, Emit) {
auto* s = ty.storage_texture(params.dim, ast::TexelFormat::kR32Float, ast::Access::kWrite); auto* s = ty.storage_texture(params.dim, ast::TexelFormat::kR32Float, ast::Access::kWrite);
GlobalVar("test_var", s, GlobalVar("test_var", s,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();

View File

@ -533,7 +533,7 @@ bool Builder::GenerateExecutionModes(const ast::Function* func, uint32_t id) {
wgsize_ops.push_back(wgsize_result); wgsize_ops.push_back(wgsize_result);
// Generate OpConstant instructions for each dimension. // 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); auto constant = ScalarConstant::U32(wgsize[i].value);
if (wgsize[i].overridable_const) { if (wgsize[i].overridable_const) {
// Make the constant specializable. // Make the constant specializable.
@ -2688,7 +2688,7 @@ bool Builder::GenerateTextureBuiltin(const sem::Call* call,
// Returns the argument with the given usage // Returns the argument with the given usage
auto arg = [&](Usage usage) { auto arg = [&](Usage usage) {
int idx = signature.IndexOf(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 // Generates the argument with the given usage, returning the operand ID

View File

@ -453,14 +453,14 @@ TEST_F(BuiltinBuilderTest, Call_TextureSampleCompare_Twice) {
auto* tex = GlobalVar("texture", t, auto* tex = GlobalVar("texture", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* sampler = GlobalVar("sampler", s, auto* sampler = GlobalVar("sampler", s,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* expr1 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1_f, 2_f), 2_f); auto* expr1 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1_f, 2_f), 2_f);
@ -1587,8 +1587,8 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a")));
@ -1634,8 +1634,8 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
}); });
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a")));
@ -1678,8 +1678,8 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
auto* p = Let("p", nullptr, AddressOf("b")); auto* p = Let("p", nullptr, AddressOf("b"));
@ -1738,8 +1738,8 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) {
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))}); auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
auto* p = Let("p", nullptr, AddressOf(Deref(AddressOf("b")))); auto* p = Let("p", nullptr, AddressOf(Deref(AddressOf("b"))));
@ -1803,8 +1803,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicLoad) {
}); });
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -1867,8 +1867,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicStore) {
}); });
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -1939,8 +1939,8 @@ TEST_P(Builtin_Builtin_AtomicRMW_i32, Test) {
}); });
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -2012,8 +2012,8 @@ TEST_P(Builtin_Builtin_AtomicRMW_u32, Test) {
}); });
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -2087,8 +2087,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicExchange) {
}); });
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),
@ -2163,8 +2163,8 @@ TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) {
}); });
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
Func("a_func", {}, ty.void_(), Func("a_func", {}, ty.void_(),

View File

@ -200,8 +200,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
{ {

View File

@ -206,8 +206,8 @@ TEST_F(BuilderTest, GlobalVar_WithBindingAndGroup) {
auto* v = auto* v =
GlobalVar("var", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr, GlobalVar("var", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(2), create<ast::BindingAttribute>(2u),
create<ast::GroupAttribute>(3), create<ast::GroupAttribute>(3u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -450,8 +450,8 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) {
GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = SanitizeAndBuild(); spirv::Builder& b = SanitizeAndBuild();
@ -491,8 +491,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) {
auto* B = Alias("B", ty.Of(A)); auto* B = Alias("B", ty.Of(A));
GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = SanitizeAndBuild(); spirv::Builder& b = SanitizeAndBuild();
@ -530,8 +530,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) {
auto* B = Alias("B", ty.Of(A)); auto* B = Alias("B", ty.Of(A));
GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = SanitizeAndBuild(); spirv::Builder& b = SanitizeAndBuild();
@ -568,13 +568,13 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) {
auto* A = Structure("A", {Member("a", ty.i32())}); auto* A = Structure("A", {Member("a", ty.i32())});
GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
}); });
GlobalVar("c", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("c", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
}); });
spirv::Builder& b = SanitizeAndBuild(); spirv::Builder& b = SanitizeAndBuild();
@ -614,8 +614,8 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) {
auto* var_a = GlobalVar("a", type, auto* var_a = GlobalVar("a", type,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -645,16 +645,16 @@ TEST_F(BuilderTest, DISABLED_GlobalVar_TextureStorageWithDifferentAccess) {
ast::Access::kReadWrite); ast::Access::kReadWrite);
auto* var_a = GlobalVar("a", type_a, ast::StorageClass::kNone, auto* var_a = GlobalVar("a", type_a, ast::StorageClass::kNone,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
auto* type_b = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint, auto* type_b = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint,
ast::Access::kWrite); ast::Access::kWrite);
auto* var_b = GlobalVar("b", type_b, ast::StorageClass::kNone, auto* var_b = GlobalVar("b", type_b, ast::StorageClass::kNone,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();

View File

@ -30,8 +30,8 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
auto* str = Structure("S", {Member("x", ary)}); auto* str = Structure("S", {Member("x", ary)});
GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -50,8 +50,8 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) {
auto* str = Structure("S", {Member("x", ary)}); auto* str = Structure("S", {Member("x", ary)});
GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -783,8 +783,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) {
GlobalVar("test_var", s, GlobalVar("test_var", s,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -802,8 +802,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) {
GlobalVar("test_var", s, GlobalVar("test_var", s,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -821,8 +821,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) {
GlobalVar("test_var", s, GlobalVar("test_var", s,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -840,8 +840,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) {
GlobalVar("test_var", s, GlobalVar("test_var", s,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -859,8 +859,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32floa
GlobalVar("test_var", s, GlobalVar("test_var", s,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -878,8 +878,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint)
GlobalVar("test_var", s, GlobalVar("test_var", s,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -897,8 +897,8 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeUint_Format_r32uint)
GlobalVar("test_var", s, GlobalVar("test_var", s,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
spirv::Builder& b = Build(); spirv::Builder& b = Build();

View File

@ -84,7 +84,7 @@ void TextGenerator::TextBuffer::Insert(const std::string& line, size_t before, u
<< " lines.size(): " << lines.size(); << " lines.size(): " << lines.size();
return; 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) { void TextGenerator::TextBuffer::Append(const TextBuffer& tb) {
@ -105,7 +105,8 @@ void TextGenerator::TextBuffer::Insert(const TextBuffer& tb, size_t before, uint
size_t idx = 0; size_t idx = 0;
for (auto& line : tb.lines) { for (auto& line : tb.lines) {
// TODO(bclayton): inefficent, consider optimizing // 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++; idx++;
} }
} }

View File

@ -714,7 +714,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out, const ast::AttributeList&
[&](const ast::WorkgroupAttribute* workgroup) { [&](const ast::WorkgroupAttribute* workgroup) {
auto values = workgroup->Values(); auto values = workgroup->Values();
out << "workgroup_size("; out << "workgroup_size(";
for (int i = 0; i < 3; i++) { for (size_t i = 0; i < 3; i++) {
if (values[i]) { if (values[i]) {
if (i > 0) { if (i > 0) {
out << ", "; out << ", ";

View File

@ -162,8 +162,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_Module
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
{ {

View File

@ -103,8 +103,8 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) {
TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) { TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) {
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler),
ast::AttributeList{ ast::AttributeList{
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -119,8 +119,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) {
auto* st = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); auto* st = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
GlobalVar("t", st, GlobalVar("t", st,
ast::AttributeList{ ast::AttributeList{
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();

View File

@ -25,7 +25,7 @@ namespace {
// - 0 sign if sign is 0, 1 otherwise // - 0 sign if sign is 0, 1 otherwise
// - 'exponent_bits' is placed in the exponent space. // - 'exponent_bits' is placed in the exponent space.
// So, the exponent bias must already be included. // 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; const uint32_t sign_bit = sign ? 0x80000000u : 0u;
// The binary32 exponent is 8 bits, just below the sign. // The binary32 exponent is 8 bits, just below the sign.
const uint32_t exponent_bits = (biased_exponent & 0xffu) << 23; const uint32_t exponent_bits = (biased_exponent & 0xffu) << 23;

View File

@ -422,8 +422,8 @@ TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) {
auto* t = ty.storage_texture(param.dim, param.fmt, param.access); auto* t = ty.storage_texture(param.dim, param.fmt, param.access);
GlobalVar("g", t, GlobalVar("g", t,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(1), create<ast::BindingAttribute>(1u),
create<ast::GroupAttribute>(2), create<ast::GroupAttribute>(2u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();

View File

@ -45,8 +45,8 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) {
auto* s = Structure("S", {Member("a", ty.i32())}); auto* s = Structure("S", {Member("a", ty.i32())});
auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -60,8 +60,8 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Write) {
auto* s = Structure("S", {Member("a", ty.i32())}); auto* s = Structure("S", {Member("a", ty.i32())});
auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -75,8 +75,8 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_ReadWrite) {
auto* s = Structure("S", {Member("a", ty.i32())}); auto* s = Structure("S", {Member("a", ty.i32())});
auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{ ast::AttributeList{
create<ast::BindingAttribute>(0), create<ast::BindingAttribute>(0u),
create<ast::GroupAttribute>(0), create<ast::GroupAttribute>(0u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -90,8 +90,8 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) {
auto* v = auto* v =
GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr, GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr,
ast::AttributeList{ ast::AttributeList{
create<ast::GroupAttribute>(1), create<ast::GroupAttribute>(1u),
create<ast::BindingAttribute>(2), create<ast::BindingAttribute>(2u),
}); });
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();