Fix GCC warnings / errors

Fixed: tint:636
Change-Id: Ic1bb602b07d659e553d8cb09fd5898482c40c0c1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44681
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-03-15 19:19:42 +00:00 committed by Commit Bot service account
parent 6eda12a55d
commit b903aadcd2
11 changed files with 65 additions and 64 deletions

View File

@ -43,7 +43,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -73,7 +73,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -95,7 +95,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -121,7 +121,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -143,7 +143,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -165,7 +165,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -187,7 +187,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -213,7 +213,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -235,7 +235,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -261,7 +261,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -286,7 +286,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -308,7 +308,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -330,7 +330,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -352,7 +352,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -378,7 +378,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -404,7 +404,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -426,7 +426,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -448,7 +448,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -470,7 +470,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -492,7 +492,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -559,7 +559,7 @@ fn f() -> void {
} }
)"; )";
auto got = Transform<BoundArrayAccessors>(src); auto got = Run<BoundArrayAccessors>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }

View File

@ -52,7 +52,7 @@ fn non_entry_b() -> void {
} }
)"; )";
auto got = Transform<EmitVertexPointSize>(src); auto got = Run<EmitVertexPointSize>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -85,7 +85,7 @@ fn non_entry_b() -> void {
} }
)"; )";
auto got = Transform<EmitVertexPointSize>(src); auto got = Run<EmitVertexPointSize>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -111,7 +111,7 @@ fn compute_entry() -> void {
} }
)"; )";
auto got = Transform<EmitVertexPointSize>(src); auto got = Run<EmitVertexPointSize>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }

View File

@ -47,7 +47,7 @@ fn entry() -> void {
transforms.emplace_back(std::make_unique<FirstIndexOffset>(0, 0)); transforms.emplace_back(std::make_unique<FirstIndexOffset>(0, 0));
transforms.emplace_back(std::make_unique<FirstIndexOffset>(1, 1)); transforms.emplace_back(std::make_unique<FirstIndexOffset>(1, 1));
auto got = Transform(src, std::move(transforms)); auto got = Run(src, std::move(transforms));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
@ -64,7 +64,7 @@ TEST_F(FirstIndexOffsetTest, EmptyModule) {
auto* src = ""; auto* src = "";
auto* expect = ""; auto* expect = "";
auto got = Transform<FirstIndexOffset>(src, 0, 0); auto got = Run<FirstIndexOffset>(src, 0, 0);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
@ -112,7 +112,7 @@ fn entry() -> void {
} }
)"; )";
auto got = Transform<FirstIndexOffset>(src, 1, 2); auto got = Run<FirstIndexOffset>(src, 1, 2);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
@ -160,7 +160,7 @@ fn entry() -> void {
} }
)"; )";
auto got = Transform<FirstIndexOffset>(src, 1, 7); auto got = Run<FirstIndexOffset>(src, 1, 7);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
@ -213,7 +213,7 @@ fn entry() -> void {
} }
)"; )";
auto got = Transform<FirstIndexOffset>(src, 1, 2); auto got = Run<FirstIndexOffset>(src, 1, 2);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
@ -269,7 +269,7 @@ fn entry() -> void {
} }
)"; )";
auto got = Transform<FirstIndexOffset>(src, 1, 2); auto got = Run<FirstIndexOffset>(src, 1, 2);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));

View File

@ -46,7 +46,7 @@ fn main() -> void {
} }
)"; )";
auto got = Transform<Hlsl>(src); auto got = Run<Hlsl>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -69,7 +69,7 @@ fn main() -> void {
} }
)"; )";
auto got = Transform<Hlsl>(src); auto got = Run<Hlsl>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -86,7 +86,7 @@ const module_arr : array<f32, 4> = array<f32, 4>(0.0, 1.0, 2.0, 3.0);
auto* expect = src; auto* expect = src;
auto got = Transform<Hlsl>(src); auto got = Run<Hlsl>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -138,7 +138,7 @@ fn main() -> void {
} }
)"; )";
auto got = Transform<Hlsl>(src); auto got = Run<Hlsl>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }

View File

@ -320,7 +320,7 @@ void Msl::HandleEntryPointIOTypes(CloneContext& ctx) const {
} }
auto* deco = param->decorations()[0]; auto* deco = param->decorations()[0];
if (auto* builtin = deco->As<ast::BuiltinDecoration>()) { if (deco->Is<ast::BuiltinDecoration>()) {
// Keep any builtin-decorated parameters unchanged. // Keep any builtin-decorated parameters unchanged.
builtins.insert(param); builtins.insert(param);
continue; continue;

View File

@ -55,7 +55,7 @@ fn _tint_main() -> void {
} }
)"; )";
auto got = Transform<Msl>(src); auto got = Run<Msl>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -79,7 +79,7 @@ fn _tint_main() -> void {
} }
)"; )";
auto got = Transform<Msl>(src); auto got = Run<Msl>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -354,7 +354,7 @@ fn frag_main(tint_symbol_4 : tint_symbol_3, [[builtin(frag_coord)]] coord : vec4
} }
)"; )";
auto got = Transform<Msl>(src); auto got = Run<Msl>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -396,7 +396,7 @@ fn frag_main(tint_symbol_4 : tint_symbol_3, [[builtin(frag_coord)]] coord : vec4
} }
)"; )";
auto got = Transform<Msl>(src); auto got = Run<Msl>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }

View File

@ -29,7 +29,7 @@ TEST_F(RenamerTest, EmptyModule) {
auto* src = ""; auto* src = "";
auto* expect = ""; auto* expect = "";
auto got = Transform<Renamer>(src); auto got = Run<Renamer>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
@ -65,7 +65,7 @@ fn _tint_3() -> void {
} }
)"; )";
auto got = Transform<Renamer>(src); auto got = Run<Renamer>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
@ -101,7 +101,7 @@ fn _tint_1() -> void {
} }
)"; )";
auto got = Transform<Renamer>(src); auto got = Run<Renamer>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
@ -134,7 +134,7 @@ fn _tint_1() -> void {
} }
)"; )";
auto got = Transform<Renamer>(src); auto got = Run<Renamer>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));

View File

@ -57,7 +57,7 @@ fn compute_main() -> void {
} }
)"; )";
auto got = Transform<Spirv>(src); auto got = Run<Spirv>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -89,7 +89,7 @@ fn main() -> void {
} }
)"; )";
auto got = Transform<Spirv>(src); auto got = Run<Spirv>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -133,7 +133,7 @@ fn main() -> void {
} }
)"; )";
auto got = Transform<Spirv>(src); auto got = Run<Spirv>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -164,7 +164,7 @@ fn main() -> void {
} }
)"; )";
auto got = Transform<Spirv>(src); auto got = Run<Spirv>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }

View File

@ -37,7 +37,7 @@ class TransformTestBase : public BASE {
/// @param in the input WGSL source /// @param in the input WGSL source
/// @param transforms the list of transforms to apply /// @param transforms the list of transforms to apply
/// @return the transformed output /// @return the transformed output
Transform::Output Transform( Transform::Output Run(
std::string in, std::string in,
std::vector<std::unique_ptr<transform::Transform>> transforms) { std::vector<std::unique_ptr<transform::Transform>> transforms) {
auto file = std::make_unique<Source::File>("test", in); auto file = std::make_unique<Source::File>("test", in);
@ -62,11 +62,11 @@ class TransformTestBase : public BASE {
/// @param transform the transform to apply /// @param transform the transform to apply
/// @param in the input WGSL source /// @param in the input WGSL source
/// @return the transformed output /// @return the transformed output
Transform::Output Transform(std::string in, Transform::Output Run(std::string in,
std::unique_ptr<transform::Transform> transform) { std::unique_ptr<transform::Transform> transform) {
std::vector<std::unique_ptr<transform::Transform>> transforms; std::vector<std::unique_ptr<transform::Transform>> transforms;
transforms.emplace_back(std::move(transform)); transforms.emplace_back(std::move(transform));
return Transform(std::move(in), std::move(transforms)); return Run(std::move(in), std::move(transforms));
} }
/// Transforms and returns the WGSL source `in`, transformed using /// Transforms and returns the WGSL source `in`, transformed using
@ -75,8 +75,8 @@ class TransformTestBase : public BASE {
/// @param args the TRANSFORM constructor arguments /// @param args the TRANSFORM constructor arguments
/// @return the transformed output /// @return the transformed output
template <typename TRANSFORM, typename... ARGS> template <typename TRANSFORM, typename... ARGS>
Transform::Output Transform(std::string in, ARGS&&... args) { Transform::Output Run(std::string in, ARGS&&... args) {
return Transform(std::move(in), return Run(std::move(in),
std::make_unique<TRANSFORM>(std::forward<ARGS>(args)...)); std::make_unique<TRANSFORM>(std::forward<ARGS>(args)...));
} }

View File

@ -33,7 +33,7 @@ TEST_F(VertexPullingTest, Error_NoEntryPoint) {
auto transform = std::make_unique<VertexPulling>(cfg); auto transform = std::make_unique<VertexPulling>(cfg);
auto got = Transform(src, std::move(transform)); auto got = Run(src, std::move(transform));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -51,7 +51,7 @@ fn main() -> void {}
auto transform = std::make_unique<VertexPulling>(cfg); auto transform = std::make_unique<VertexPulling>(cfg);
auto got = Transform(src, std::move(transform)); auto got = Run(src, std::move(transform));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -69,7 +69,7 @@ fn main() -> void {}
auto transform = std::make_unique<VertexPulling>(cfg); auto transform = std::make_unique<VertexPulling>(cfg);
auto got = Transform(src, std::move(transform)); auto got = Run(src, std::move(transform));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -99,7 +99,7 @@ fn main() -> void {
auto transform = std::make_unique<VertexPulling>(cfg); auto transform = std::make_unique<VertexPulling>(cfg);
auto got = Transform(src, std::move(transform)); auto got = Run(src, std::move(transform));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -141,7 +141,7 @@ fn main() -> void {
auto transform = std::make_unique<VertexPulling>(cfg); auto transform = std::make_unique<VertexPulling>(cfg);
auto got = Transform(src, std::move(transform)); auto got = Run(src, std::move(transform));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -183,7 +183,7 @@ fn main() -> void {
auto transform = std::make_unique<VertexPulling>(cfg); auto transform = std::make_unique<VertexPulling>(cfg);
auto got = Transform(src, std::move(transform)); auto got = Run(src, std::move(transform));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -226,7 +226,7 @@ fn main() -> void {
auto transform = std::make_unique<VertexPulling>(cfg); auto transform = std::make_unique<VertexPulling>(cfg);
auto got = Transform(src, std::move(transform)); auto got = Run(src, std::move(transform));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -290,7 +290,7 @@ fn main() -> void {
auto transform = std::make_unique<VertexPulling>(cfg); auto transform = std::make_unique<VertexPulling>(cfg);
auto got = Transform(src, std::move(transform)); auto got = Run(src, std::move(transform));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -339,7 +339,7 @@ fn main() -> void {
auto transform = std::make_unique<VertexPulling>(cfg); auto transform = std::make_unique<VertexPulling>(cfg);
auto got = Transform(src, std::move(transform)); auto got = Run(src, std::move(transform));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
@ -398,7 +398,7 @@ fn main() -> void {
auto transform = std::make_unique<VertexPulling>(cfg); auto transform = std::make_unique<VertexPulling>(cfg);
auto got = Transform(src, std::move(transform)); auto got = Run(src, std::move(transform));
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }

View File

@ -75,6 +75,7 @@ ast::Decoration* createDecoration(ProgramBuilder& builder,
case DecorationKind::kConstantId: case DecorationKind::kConstantId:
return builder.create<ast::ConstantIdDecoration>(0u); return builder.create<ast::ConstantIdDecoration>(0u);
} }
return nullptr;
} }
using ArrayDecorationTest = ValidatorDecorationsTestWithParams; using ArrayDecorationTest = ValidatorDecorationsTestWithParams;