From f8bd1060411f1bbdc70ce4e813c2b7c5df098547 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 3 Nov 2020 17:46:49 +0000 Subject: [PATCH] Fix all warnings when building with CMake + clang Change-Id: I987b4580f5f99584649b2b189369a0b962b0c3d4 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31721 Commit-Queue: dan sinclair Reviewed-by: dan sinclair --- src/ast/block_statement.h | 3 ++- src/ast/type/array_type.cc | 4 ++-- src/ast/type/i32_type.cc | 4 ++-- src/ast/type/struct_type.cc | 9 +++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ast/block_statement.h b/src/ast/block_statement.h index 3c2a26874e..8fc2ce78b3 100644 --- a/src/ast/block_statement.h +++ b/src/ast/block_statement.h @@ -46,7 +46,8 @@ class BlockStatement : public Statement { /// @param index the index to insert at /// @param stmt the statement to insert void insert(size_t index, std::unique_ptr stmt) { - statements_.insert(statements_.begin() + index, std::move(stmt)); + auto offset = static_cast(index); + statements_.insert(statements_.begin() + offset, std::move(stmt)); } /// @returns true if the block is empty diff --git a/src/ast/type/array_type.cc b/src/ast/type/array_type.cc index 8a497d8985..9a5960a535 100644 --- a/src/ast/type/array_type.cc +++ b/src/ast/type/array_type.cc @@ -59,8 +59,8 @@ uint64_t ArrayType::MinBufferBindingSize(MemoryLayout mem_layout) const { uint64_t ArrayType::BaseAlignment(MemoryLayout mem_layout) const { if (mem_layout == MemoryLayout::kUniformBuffer) { float aligment = 16; // for a vec4 - float unaligned = subtype_->BaseAlignment(mem_layout); - return aligment * std::ceil(unaligned / aligment); + float unaligned = static_cast(subtype_->BaseAlignment(mem_layout)); + return static_cast(aligment * std::ceil(unaligned / aligment)); } else if (mem_layout == MemoryLayout::kStorageBuffer) { return subtype_->BaseAlignment(mem_layout); } diff --git a/src/ast/type/i32_type.cc b/src/ast/type/i32_type.cc index ec1b26eb35..61b4990e05 100644 --- a/src/ast/type/i32_type.cc +++ b/src/ast/type/i32_type.cc @@ -30,11 +30,11 @@ std::string I32Type::type_name() const { return "__i32"; } -uint64_t I32Type::MinBufferBindingSize(MemoryLayout mem_layout) const { +uint64_t I32Type::MinBufferBindingSize(MemoryLayout) const { return 4; } -uint64_t I32Type::BaseAlignment(MemoryLayout mem_layout) const { +uint64_t I32Type::BaseAlignment(MemoryLayout) const { return 4; } diff --git a/src/ast/type/struct_type.cc b/src/ast/type/struct_type.cc index ba7a9b3e04..98b426c2e9 100644 --- a/src/ast/type/struct_type.cc +++ b/src/ast/type/struct_type.cc @@ -59,10 +59,10 @@ uint64_t StructType::MinBufferBindingSize(MemoryLayout mem_layout) const { return 0; } - float unaligned = last_member->offset() + size; - float alignment = BaseAlignment(mem_layout); + float unaligned = static_cast(last_member->offset() + size); + float alignment = static_cast(BaseAlignment(mem_layout)); - return alignment * std::ceil(unaligned / alignment); + return static_cast(alignment * std::ceil(unaligned / alignment)); } uint64_t StructType::BaseAlignment(MemoryLayout mem_layout) const { @@ -75,7 +75,8 @@ uint64_t StructType::BaseAlignment(MemoryLayout mem_layout) const { if (mem_layout == MemoryLayout::kUniformBuffer) { // Round up to a vec4. - return 16 * std::ceil(static_cast(max) / 16.0f); + return static_cast(16 * + std::ceil(static_cast(max) / 16.0f)); } else if (mem_layout == MemoryLayout::kStorageBuffer) { return max; }