Fixup various warnings in Tint which were accidentally suppressed.
When enabling the SPIR-V reader or SPIR-V writer we were suppressing
-Wnewline-eof, -Wold-style-cast, -Wsign-conversion, and -Wweak-vtables
for the `libtint` cmake target and anything that depended on that
target. Because we'd build all readers/ writers by default this caused
us to never hit those warnings.
A recent change to the cmake build sets the Tint backend based on
the Dawn backend. So, there is a much higher chance of not building
the SPIR-V support if you're on a Mac or Windows machine.
This CL removes the suppression of the warnings, adds specific pragmas
into the SPIR-V reader code which imports the SPIRV-Tools headers
and fixes up the warnings which were then firing due to checking
for the new warnings.
Change-Id: I0d0be6aa3d0b692e939ce8ff924dfb82c82792fc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94901
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc
index 6794921..e6cad77 100644
--- a/src/tint/resolver/resolver.cc
+++ b/src/tint/resolver/resolver.cc
@@ -857,7 +857,7 @@
bool Resolver::WorkgroupSize(const ast::Function* func) {
// Set work-group size defaults.
sem::WorkgroupSize ws;
- for (int i = 0; i < 3; i++) {
+ for (size_t i = 0; i < 3; i++) {
ws[i].value = 1;
ws[i].overridable_const = nullptr;
}
@@ -876,7 +876,7 @@
"workgroup_size argument must be either a literal, constant, or overridable of type "
"abstract-integer, i32 or u32";
- for (int i = 0; i < 3; i++) {
+ for (size_t i = 0; i < 3; i++) {
// Each argument to this attribute can either be a literal, an identifier for a module-scope
// constants, or nullptr if not specified.
auto* value = values[i];
@@ -1731,12 +1731,13 @@
if (texture_index == -1) {
TINT_ICE(Resolver, diagnostics_) << "texture builtin without texture parameter";
}
- auto* texture = args[texture_index]->As<sem::VariableUser>()->Variable();
+ auto* texture = args[static_cast<size_t>(texture_index)]->As<sem::VariableUser>()->Variable();
if (!texture->Type()->UnwrapRef()->Is<sem::StorageTexture>()) {
int sampler_index = signature.IndexOf(sem::ParameterUsage::kSampler);
const sem::Variable* sampler =
- sampler_index != -1 ? args[sampler_index]->As<sem::VariableUser>()->Variable()
- : nullptr;
+ sampler_index != -1
+ ? args[static_cast<size_t>(sampler_index)]->As<sem::VariableUser>()->Variable()
+ : nullptr;
current_function_->AddTextureSamplerPair(texture, sampler);
}
}
@@ -2247,7 +2248,7 @@
}
}
- auto size = std::max<uint64_t>(count, 1u) * stride;
+ auto size = std::max<uint64_t>(static_cast<uint32_t>(count), 1u) * stride;
if (size > std::numeric_limits<uint32_t>::max()) {
std::stringstream msg;
msg << "array size (0x" << std::hex << size << ") must not exceed 0xffffffff bytes";