// Copyright 2021 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "src/tint/lang/core/builtin_value.h"
#include "src/tint/lang/core/type/texture_dimension.h"
#include "src/tint/lang/wgsl/ast/disable_validation_attribute.h"
#include "src/tint/lang/wgsl/ast/transform/add_block_attribute.h"
#include "src/tint/lang/wgsl/resolver/resolver.h"
#include "src/tint/lang/wgsl/resolver/resolver_helper_test.h"
#include "src/tint/utils/containers/transform.h"
#include "src/tint/utils/macros/compiler.h"
#include "src/tint/utils/text/string_stream.h"

#include "gmock/gmock.h"

namespace tint::resolver {

using namespace tint::core::fluent_types;     // NOLINT
using namespace tint::core::number_suffixes;  // NOLINT

// Helpers and typedefs
template <typename T>
using DataType = builder::DataType<T>;
template <typename T, int ID = 0>
using alias = builder::alias<T, ID>;
template <typename T>
using alias1 = builder::alias1<T>;
template <typename T>
using alias2 = builder::alias2<T>;
template <typename T>
using alias3 = builder::alias3<T>;

namespace AttributeTests {
namespace {
enum class AttributeKind {
    kAlign,
    kBinding,
    kBlendSrc,
    kBuiltinPosition,
    kColor,
    kDiagnostic,
    kGroup,
    kId,
    kInterpolate,
    kInvariant,
    kLocation,
    kMustUse,
    kOffset,
    kSize,
    kStageCompute,
    kStride,
    kWorkgroupSize,
};
static std::ostream& operator<<(std::ostream& o, AttributeKind k) {
    switch (k) {
        case AttributeKind::kAlign:
            return o << "@align";
        case AttributeKind::kBinding:
            return o << "@binding";
        case AttributeKind::kBlendSrc:
            return o << "@blend_src";
        case AttributeKind::kBuiltinPosition:
            return o << "@builtin(position)";
        case AttributeKind::kColor:
            return o << "@color";
        case AttributeKind::kDiagnostic:
            return o << "@diagnostic";
        case AttributeKind::kGroup:
            return o << "@group";
        case AttributeKind::kId:
            return o << "@id";
        case AttributeKind::kInterpolate:
            return o << "@interpolate";
        case AttributeKind::kInvariant:
            return o << "@invariant";
        case AttributeKind::kLocation:
            return o << "@location";
        case AttributeKind::kOffset:
            return o << "@offset";
        case AttributeKind::kMustUse:
            return o << "@must_use";
        case AttributeKind::kSize:
            return o << "@size";
        case AttributeKind::kStageCompute:
            return o << "@stage(compute)";
        case AttributeKind::kStride:
            return o << "@stride";
        case AttributeKind::kWorkgroupSize:
            return o << "@workgroup_size";
    }
    TINT_UNREACHABLE();
    return o << "<unknown>";
}

static bool IsBindingAttribute(AttributeKind kind) {
    switch (kind) {
        case AttributeKind::kBinding:
        case AttributeKind::kGroup:
            return true;
        default:
            return false;
    }
}

struct TestParams {
    Vector<AttributeKind, 2> attributes;
    std::string error;  // empty string (Pass) is an expected pass
};

static constexpr const char* Pass = "";

static std::vector<TestParams> OnlyDiagnosticValidFor(std::string thing) {
    return {TestParams{
                {AttributeKind::kAlign},
                "1:2 error: @align is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kBinding},
                "1:2 error: @binding is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kBlendSrc},
                "1:2 error: @blend_src is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kBuiltinPosition},
                "1:2 error: @builtin is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kColor},
                "1:2 error: @color is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kDiagnostic},
                Pass,
            },
            TestParams{
                {AttributeKind::kGroup},
                "1:2 error: @group is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kId},
                "1:2 error: @id is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kInterpolate},
                "1:2 error: @interpolate is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kInvariant},
                "1:2 error: @invariant is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kLocation},
                "1:2 error: @location is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kMustUse},
                "1:2 error: @must_use is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kOffset},
                "1:2 error: @offset is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kSize},
                "1:2 error: @size is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kStageCompute},
                "1:2 error: @stage is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kStride},
                "1:2 error: @stride is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kWorkgroupSize},
                "1:2 error: @workgroup_size is not valid for " + thing,
            },
            TestParams{
                {AttributeKind::kBinding, AttributeKind::kGroup},
                "1:2 error: @binding is not valid for " + thing,
            }};
}

static std::ostream& operator<<(std::ostream& o, const TestParams& c) {
    return o << "attributes: " << c.attributes << ", expect pass: " << c.error.empty();
}

const ast::Attribute* CreateAttribute(const Source& source,
                                      ProgramBuilder& builder,
                                      AttributeKind kind) {
    switch (kind) {
        case AttributeKind::kAlign:
            return builder.MemberAlign(source, 4_i);
        case AttributeKind::kBinding:
            return builder.Binding(source, 1_a);
        case AttributeKind::kBuiltinPosition:
            return builder.Builtin(source, core::BuiltinValue::kPosition);
        case AttributeKind::kColor:
            return builder.Color(source, 2_a);
        case AttributeKind::kDiagnostic:
            return builder.DiagnosticAttribute(source, wgsl::DiagnosticSeverity::kInfo, "chromium",
                                               "unreachable_code");
        case AttributeKind::kGroup:
            return builder.Group(source, 1_a);
        case AttributeKind::kId:
            return builder.Id(source, 0_a);
        case AttributeKind::kBlendSrc:
            return builder.BlendSrc(source, 0_a);
        case AttributeKind::kInterpolate:
            return builder.Interpolate(source, core::InterpolationType::kLinear,
                                       core::InterpolationSampling::kCenter);
        case AttributeKind::kInvariant:
            return builder.Invariant(source);
        case AttributeKind::kLocation:
            return builder.Location(source, 0_a);
        case AttributeKind::kOffset:
            return builder.MemberOffset(source, 4_a);
        case AttributeKind::kMustUse:
            return builder.MustUse(source);
        case AttributeKind::kSize:
            return builder.MemberSize(source, 16_a);
        case AttributeKind::kStageCompute:
            return builder.Stage(source, ast::PipelineStage::kCompute);
        case AttributeKind::kStride:
            return builder.create<ast::StrideAttribute>(source, 4u);
        case AttributeKind::kWorkgroupSize:
            return builder.create<ast::WorkgroupAttribute>(source, builder.Expr(1_i));
    }
    TINT_UNREACHABLE() << kind;
    return nullptr;
}

struct TestWithParams : ResolverTestWithParam<TestParams> {
    void EnableExtensionIfNecessary(AttributeKind attribute) {
        switch (attribute) {
            case AttributeKind::kColor:
                Enable(wgsl::Extension::kChromiumExperimentalFramebufferFetch);
                break;
            case AttributeKind::kBlendSrc:
                Enable(wgsl::Extension::kChromiumInternalDualSourceBlending);
                break;
            default:
                break;
        }
    }

    void EnableRequiredExtensions() {
        for (auto attribute : GetParam().attributes) {
            EnableExtensionIfNecessary(attribute);
        }
    }

    Vector<const ast::Attribute*, 2> CreateAttributes(ProgramBuilder& builder,
                                                      VectorRef<AttributeKind> kinds) {
        return Transform<2>(kinds, [&](AttributeKind kind, size_t index) {
            return CreateAttribute(Source{{static_cast<uint32_t>(index) * 2 + 1,
                                           static_cast<uint32_t>(index) * 2 + 2}},
                                   builder, kind);
        });
    }

    Vector<const ast::Attribute*, 2> CreateAttributes() {
        return CreateAttributes(*this, GetParam().attributes);
    }
};

#undef CHECK
#define CHECK()                                      \
    if (GetParam().error.empty()) {                  \
        EXPECT_TRUE(r()->Resolve()) << r()->error(); \
    } else {                                         \
        EXPECT_FALSE(r()->Resolve());                \
        EXPECT_EQ(GetParam().error, r()->error());   \
    }                                                \
    TINT_REQUIRE_SEMICOLON

namespace FunctionTests {
using VoidFunctionAttributeTest = TestWithParams;
TEST_P(VoidFunctionAttributeTest, IsValid) {
    EnableRequiredExtensions();

    Func(Source{{9, 9}}, "main", Empty, ty.void_(), Empty, CreateAttributes());

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    VoidFunctionAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kColor},
            R"(1:2 error: @color is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            Pass,
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(1:2 error: @interpolate is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(1:2 error: @invariant is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kLocation},
            R"(1:2 error: @location is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use can only be applied to functions that return a value)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(9:9 error: a compute shader must include 'workgroup_size' in its attributes)",
        },
        TestParams{
            {AttributeKind::kStageCompute, AttributeKind::kWorkgroupSize},
            Pass,
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for functions)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is only valid for compute stages)",
        }));

using NonVoidFunctionAttributeTest = TestWithParams;
TEST_P(NonVoidFunctionAttributeTest, IsValid) {
    EnableRequiredExtensions();

    Func(Source{{9, 9}}, "main", Empty, ty.i32(), Vector{Return(1_i)}, CreateAttributes());

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         NonVoidFunctionAttributeTest,
                         testing::Values(
                             TestParams{
                                 {AttributeKind::kAlign},
                                 R"(1:2 error: @align is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kBinding},
                                 R"(1:2 error: @binding is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kBlendSrc},
                                 R"(1:2 error: @blend_src is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kBuiltinPosition},
                                 R"(1:2 error: @builtin is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kColor},
                                 R"(1:2 error: @color is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kDiagnostic},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kGroup},
                                 R"(1:2 error: @group is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kId},
                                 R"(1:2 error: @id is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kInterpolate},
                                 R"(1:2 error: @interpolate is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kInvariant},
                                 R"(1:2 error: @invariant is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kLocation},
                                 R"(1:2 error: @location is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kMustUse},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kOffset},
                                 R"(1:2 error: @offset is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kSize},
                                 R"(1:2 error: @size is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kStageCompute},
                                 R"(9:9 error: missing entry point IO attribute on return type)",
                             },
                             TestParams{
                                 {AttributeKind::kStageCompute, AttributeKind::kWorkgroupSize},
                                 R"(9:9 error: missing entry point IO attribute on return type)",
                             },
                             TestParams{
                                 {AttributeKind::kStride},
                                 R"(1:2 error: @stride is not valid for functions)",
                             },
                             TestParams{
                                 {AttributeKind::kWorkgroupSize},
                                 R"(1:2 error: @workgroup_size is only valid for compute stages)",
                             }));
}  // namespace FunctionTests

namespace FunctionInputAndOutputTests {
using FunctionParameterAttributeTest = TestWithParams;
TEST_P(FunctionParameterAttributeTest, IsValid) {
    EnableRequiredExtensions();

    Func("main",
         Vector{
             Param("a", ty.vec4<f32>(), CreateAttributes()),
         },
         ty.void_(), tint::Empty);

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    FunctionParameterAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin is not valid for non-entry point function parameters)",
        },
        TestParams{
            {AttributeKind::kColor},
            R"(1:2 error: @color is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(1:2 error: @interpolate is not valid for non-entry point function parameters)",
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(1:2 error: @invariant is not valid for non-entry point function parameters)",
        },
        TestParams{
            {AttributeKind::kLocation},
            R"(1:2 error: @location is not valid for non-entry point function parameters)",
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for function parameters)",
        }));

using FunctionReturnTypeAttributeTest = TestWithParams;
TEST_P(FunctionReturnTypeAttributeTest, IsValid) {
    EnableRequiredExtensions();

    Func("main", tint::Empty, ty.f32(),
         Vector{
             Return(1_f),
         },
         tint::Empty, CreateAttributes());

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    FunctionReturnTypeAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kColor},
            R"(1:2 error: @color is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(1:2 error: @interpolate is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(1:2 error: @invariant is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kLocation},
            R"(1:2 error: @location is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for non-entry point function return types)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for non-entry point function return types)",
        }));
}  // namespace FunctionInputAndOutputTests

namespace EntryPointInputAndOutputTests {
using ComputeShaderParameterAttributeTest = TestWithParams;
TEST_P(ComputeShaderParameterAttributeTest, IsValid) {
    EnableRequiredExtensions();
    Func("main",
         Vector{
             Param("a", ty.vec4<f32>(), CreateAttributes()),
         },
         ty.void_(), tint::Empty,
         Vector{
             Stage(ast::PipelineStage::kCompute),
             WorkgroupSize(1_i),
         });

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    ComputeShaderParameterAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin(position) cannot be used for compute shader input)",
        },
        TestParams{
            {AttributeKind::kColor},
            R"(1:2 error: @color can only be used for fragment shader input)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(1:2 error: @interpolate cannot be used by compute shaders)",
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(1:2 error: @invariant cannot be used by compute shaders)",
        },
        TestParams{
            {AttributeKind::kLocation},
            R"(1:2 error: @location cannot be used by compute shaders)",
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for function parameters)",
        }));

using FragmentShaderParameterAttributeTest = TestWithParams;
TEST_P(FragmentShaderParameterAttributeTest, IsValid) {
    EnableRequiredExtensions();
    auto* p = Param(Source{{9, 9}}, "a", ty.vec4<f32>(), CreateAttributes());
    Func("frag_main", Vector{p}, ty.void_(), tint::Empty,
         Vector{
             Stage(ast::PipelineStage::kFragment),
         });

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    FragmentShaderParameterAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            Pass,
        },
        TestParams{
            {AttributeKind::kColor},
            Pass,
        },
        TestParams{
            {AttributeKind::kColor, AttributeKind::kLocation},
            R"(3:4 error: multiple entry point IO attributes
1:2 note: previously consumed @color)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(9:9 error: missing entry point IO attribute on parameter)",
        },
        TestParams{
            {AttributeKind::kInterpolate, AttributeKind::kBuiltinPosition},
            R"(1:2 error: @interpolate can only be used with @location)",
        },
        TestParams{
            {AttributeKind::kInterpolate, AttributeKind::kLocation},
            Pass,
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(9:9 error: missing entry point IO attribute on parameter)",
        },
        TestParams{
            {AttributeKind::kInvariant, AttributeKind::kBuiltinPosition},
            Pass,
        },
        TestParams{
            {AttributeKind::kLocation},
            Pass,
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for function parameters)",
        }));

using VertexShaderParameterAttributeTest = TestWithParams;
TEST_P(VertexShaderParameterAttributeTest, IsValid) {
    EnableRequiredExtensions();

    auto* p = Param(Source{{9, 9}}, "a", ty.vec4<f32>(), CreateAttributes());
    Func("vertex_main", Vector{p}, ty.vec4<f32>(),
         Vector{
             Return(Call<vec4<f32>>()),
         },
         Vector{
             Stage(ast::PipelineStage::kVertex),
         },
         Vector{
             Builtin(core::BuiltinValue::kPosition),
         });

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    VertexShaderParameterAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin(position) cannot be used for vertex shader input)",
        },
        TestParams{
            {AttributeKind::kColor},
            R"(1:2 error: @color can only be used for fragment shader input)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(9:9 error: missing entry point IO attribute on parameter)",
        },
        TestParams{
            {AttributeKind::kInterpolate, AttributeKind::kLocation},
            Pass,
        },
        TestParams{
            {AttributeKind::kInterpolate, AttributeKind::kBuiltinPosition},
            R"(3:4 error: @builtin(position) cannot be used for vertex shader input)",
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(9:9 error: missing entry point IO attribute on parameter)",
        },
        TestParams{
            {AttributeKind::kInvariant, AttributeKind::kLocation},
            R"(1:2 error: @invariant must be applied to a position builtin)",
        },
        TestParams{
            {AttributeKind::kInvariant, AttributeKind::kBuiltinPosition},
            R"(3:4 error: @builtin(position) cannot be used for vertex shader input)",
        },
        TestParams{
            {AttributeKind::kLocation},
            Pass,
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for function parameters)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for function parameters)",
        }));

using ComputeShaderReturnTypeAttributeTest = TestWithParams;
TEST_P(ComputeShaderReturnTypeAttributeTest, IsValid) {
    EnableRequiredExtensions();

    Func("main", tint::Empty, ty.vec4<f32>(),
         Vector{
             Return(Call<vec4<f32>>(1_f)),
         },
         Vector{
             Stage(ast::PipelineStage::kCompute),
             WorkgroupSize(1_i),
         },
         CreateAttributes());

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    ComputeShaderReturnTypeAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src can only be used for fragment shader output)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin(position) cannot be used for compute shader output)",
        },
        TestParams{
            {AttributeKind::kColor},
            R"(1:2 error: @color is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(1:2 error: @interpolate cannot be used by compute shaders)",
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(1:2 error: @invariant cannot be used by compute shaders)",
        },
        TestParams{
            {AttributeKind::kLocation},
            R"(1:2 error: @location cannot be used by compute shaders)",
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for entry point return types)",
        }));

using FragmentShaderReturnTypeAttributeTest = TestWithParams;
TEST_P(FragmentShaderReturnTypeAttributeTest, IsValid) {
    EnableRequiredExtensions();

    Func(Source{{9, 9}}, "frag_main", tint::Empty, ty.vec4<f32>(),
         Vector{Return(Call<vec4<f32>>())},
         Vector{
             Stage(ast::PipelineStage::kFragment),
         },
         CreateAttributes());

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    FragmentShaderReturnTypeAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(9:9 error: missing entry point IO attribute on return type)",
        },
        TestParams{
            {AttributeKind::kBlendSrc, AttributeKind::kLocation},
            Pass,
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin(position) cannot be used for fragment shader output)",
        },
        TestParams{
            {AttributeKind::kColor},
            R"(1:2 error: @color is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(9:9 error: missing entry point IO attribute on return type)",
        },
        TestParams{
            {AttributeKind::kInterpolate, AttributeKind::kLocation},
            Pass,
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(9:9 error: missing entry point IO attribute on return type)",
        },
        TestParams{
            {AttributeKind::kInvariant, AttributeKind::kLocation},
            R"(1:2 error: @invariant must be applied to a position builtin)",
        },
        TestParams{
            {AttributeKind::kLocation},
            Pass,
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kBinding, AttributeKind::kGroup},
            R"(1:2 error: @binding is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kBlendSrc, AttributeKind::kLocation},
            Pass,
        }));

using VertexShaderReturnTypeAttributeTest = TestWithParams;
TEST_P(VertexShaderReturnTypeAttributeTest, IsValid) {
    EnableRequiredExtensions();
    auto attrs = CreateAttributes();
    // a vertex shader must include the 'position' builtin in its return type
    if (!GetParam().attributes.Any([](auto b) { return b == AttributeKind::kBuiltinPosition; })) {
        attrs.Push(Builtin(Source{{9, 9}}, core::BuiltinValue::kPosition));
    }
    Func("vertex_main", tint::Empty, ty.vec4<f32>(),
         Vector{
             Return(Call<vec4<f32>>()),
         },
         Vector{
             Stage(ast::PipelineStage::kVertex),
         },
         std::move(attrs));

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    VertexShaderReturnTypeAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src can only be used for fragment shader output)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            Pass,
        },
        TestParams{
            {AttributeKind::kColor},
            R"(1:2 error: @color is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(1:2 error: @interpolate can only be used with @location)",
        },
        TestParams{
            {AttributeKind::kInvariant},
            Pass,
        },
        TestParams{
            {AttributeKind::kLocation},
            R"(9:9 error: multiple entry point IO attributes
1:2 note: previously consumed @location)",
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kBinding, AttributeKind::kGroup},
            R"(1:2 error: @binding is not valid for entry point return types)",
        },
        TestParams{
            {AttributeKind::kLocation, AttributeKind::kLocation},
            R"(3:4 error: duplicate location attribute
1:2 note: first attribute declared here)",
        }));

using EntryPointParameterAttributeTest = TestWithParams;
TEST_F(EntryPointParameterAttributeTest, DuplicateInternalAttribute) {
    auto* s = Param("s", ty.sampler(core::type::SamplerKind::kSampler),
                    Vector{
                        Binding(0_a),
                        Group(0_a),
                        Disable(ast::DisabledValidation::kBindingPointCollision),
                        Disable(ast::DisabledValidation::kEntryPointParameter),
                    });
    Func("f", Vector{s}, ty.void_(), tint::Empty,
         Vector{
             Stage(ast::PipelineStage::kFragment),
         });

    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

using EntryPointReturnTypeAttributeTest = ResolverTest;
TEST_F(EntryPointReturnTypeAttributeTest, DuplicateInternalAttribute) {
    Func("f", tint::Empty, ty.i32(), Vector{Return(1_i)},
         Vector{
             Stage(ast::PipelineStage::kFragment),
         },
         Vector{
             Disable(ast::DisabledValidation::kBindingPointCollision),
             Disable(ast::DisabledValidation::kEntryPointParameter),
         });

    EXPECT_TRUE(r()->Resolve()) << r()->error();
}
}  // namespace EntryPointInputAndOutputTests

namespace StructAndStructMemberTests {
using StructAttributeTest = TestWithParams;
using SpirvBlockAttribute = ast::transform::AddBlockAttribute::BlockAttribute;
TEST_P(StructAttributeTest, IsValid) {
    EnableRequiredExtensions();

    Structure("S", Vector{Member("a", ty.f32())}, CreateAttributes());

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    StructAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kColor},
            R"(1:2 error: @color is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(1:2 error: @interpolate is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(1:2 error: @invariant is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kLocation},
            R"(1:2 error: @location is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for struct declarations)",
        },
        TestParams{
            {AttributeKind::kBinding, AttributeKind::kGroup},
            R"(1:2 error: @binding is not valid for struct declarations)",
        }));

using StructMemberAttributeTest = TestWithParams;
TEST_P(StructMemberAttributeTest, IsValid) {
    EnableRequiredExtensions();
    Structure("S", Vector{Member("a", ty.vec4<f32>(), CreateAttributes())});

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         StructMemberAttributeTest,
                         testing::Values(
                             TestParams{
                                 {AttributeKind::kAlign},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kBinding},
                                 R"(1:2 error: @binding is not valid for struct members)",
                             },
                             TestParams{
                                 {AttributeKind::kBlendSrc},
                                 R"(1:2 error: @blend_src can only be used with @location(0))",
                             },
                             TestParams{
                                 {AttributeKind::kBuiltinPosition},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kColor},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kDiagnostic},
                                 R"(1:2 error: @diagnostic is not valid for struct members)",
                             },
                             TestParams{
                                 {AttributeKind::kGroup},
                                 R"(1:2 error: @group is not valid for struct members)",
                             },
                             TestParams{
                                 {AttributeKind::kId},
                                 R"(1:2 error: @id is not valid for struct members)",
                             },
                             TestParams{
                                 {AttributeKind::kInterpolate},
                                 R"(1:2 error: @interpolate can only be used with @location)",
                             },
                             TestParams{
                                 {AttributeKind::kInterpolate, AttributeKind::kLocation},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kInvariant},
                                 R"(1:2 error: @invariant must be applied to a position builtin)",
                             },
                             TestParams{
                                 {AttributeKind::kInvariant, AttributeKind::kBuiltinPosition},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kLocation},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kMustUse},
                                 R"(1:2 error: @must_use is not valid for struct members)",
                             },
                             TestParams{
                                 {AttributeKind::kOffset},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kSize},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kStageCompute},
                                 R"(1:2 error: @stage is not valid for struct members)",
                             },
                             TestParams{
                                 {AttributeKind::kStride},
                                 R"(1:2 error: @stride is not valid for struct members)",
                             },
                             TestParams{
                                 {AttributeKind::kWorkgroupSize},
                                 R"(1:2 error: @workgroup_size is not valid for struct members)",
                             },
                             TestParams{
                                 {AttributeKind::kBinding, AttributeKind::kGroup},
                                 R"(1:2 error: @binding is not valid for struct members)",
                             },
                             TestParams{
                                 {AttributeKind::kAlign, AttributeKind::kAlign},
                                 R"(3:4 error: duplicate align attribute
1:2 note: first attribute declared here)",
                             }));

TEST_F(StructMemberAttributeTest, Align_Attribute_Const) {
    GlobalConst("val", ty.i32(), Expr(1_i));

    Structure("mystruct", Vector{Member("a", ty.f32(), Vector{MemberAlign("val")})});
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstNegative) {
    GlobalConst("val", ty.i32(), Expr(-2_i));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberAlign(Source{{12, 34}}, "val")})});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(12:34 error: @align value must be a positive, power-of-two integer)");
}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstPowerOfTwo) {
    GlobalConst("val", ty.i32(), Expr(3_i));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberAlign(Source{{12, 34}}, "val")})});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(12:34 error: @align value must be a positive, power-of-two integer)");
}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstF32) {
    GlobalConst("val", ty.f32(), Expr(1.23_f));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberAlign(Source{{12, 34}}, "val")})});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @align must be an i32 or u32 value)");
}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstU32) {
    GlobalConst("val", ty.u32(), Expr(2_u));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberAlign(Source{{12, 34}}, "val")})});
    EXPECT_TRUE(r()->Resolve());
}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstAInt) {
    GlobalConst("val", Expr(2_a));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberAlign(Source{{12, 34}}, "val")})});
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstAFloat) {
    GlobalConst("val", Expr(2.0_a));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberAlign(Source{{12, 34}}, "val")})});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @align must be an i32 or u32 value)");
}

TEST_F(StructMemberAttributeTest, Align_Attribute_Var) {
    GlobalVar(Source{{1, 2}}, "val", ty.f32(), core::AddressSpace::kPrivate,
              core::Access::kUndefined, Expr(1.23_f));

    Structure(Source{{6, 4}}, "mystruct",
              Vector{Member(Source{{12, 5}}, "a", ty.f32(),
                            Vector{MemberAlign(Expr(Source{{12, 35}}, "val"))})});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:35 error: var 'val' cannot be referenced at module-scope
1:2 note: var 'val' declared here)");
}

TEST_F(StructMemberAttributeTest, Align_Attribute_Override) {
    Override("val", ty.f32(), Expr(1.23_f));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberAlign(Expr(Source{{12, 34}}, "val"))})});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(
        r()->error(),
        R"(12:34 error: @align requires a const-expression, but expression is an override-expression)");
}

TEST_F(StructMemberAttributeTest, Size_Attribute_Const) {
    GlobalConst("val", ty.i32(), Expr(4_i));

    Structure("mystruct", Vector{Member("a", ty.f32(), Vector{MemberSize("val")})});
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(StructMemberAttributeTest, Size_Attribute_ConstNegative) {
    GlobalConst("val", ty.i32(), Expr(-2_i));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberSize(Source{{12, 34}}, "val")})});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @size must be a positive integer)");
}

TEST_F(StructMemberAttributeTest, Size_Attribute_ConstF32) {
    GlobalConst("val", ty.f32(), Expr(1.23_f));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberSize(Source{{12, 34}}, "val")})});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @size must be an i32 or u32 value)");
}

TEST_F(StructMemberAttributeTest, Size_Attribute_ConstU32) {
    GlobalConst("val", ty.u32(), Expr(4_u));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberSize(Source{{12, 34}}, "val")})});
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(StructMemberAttributeTest, Size_Attribute_ConstAInt) {
    GlobalConst("val", Expr(4_a));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberSize(Source{{12, 34}}, "val")})});
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(StructMemberAttributeTest, Size_Attribute_ConstAFloat) {
    GlobalConst("val", Expr(2.0_a));

    Structure("mystruct",
              Vector{Member("a", ty.f32(), Vector{MemberSize(Source{{12, 34}}, "val")})});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @size must be an i32 or u32 value)");
}

TEST_F(StructMemberAttributeTest, Size_Attribute_Var) {
    GlobalVar(Source{{1, 2}}, "val", ty.f32(), core::AddressSpace::kPrivate,
              core::Access::kUndefined, Expr(1.23_f));

    Structure(Source{{6, 4}}, "mystruct",
              Vector{Member(Source{{12, 5}}, "a", ty.f32(),
                            Vector{MemberSize(Expr(Source{{12, 35}}, "val"))})});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:35 error: var 'val' cannot be referenced at module-scope
1:2 note: var 'val' declared here)");
}

TEST_F(StructMemberAttributeTest, Size_Attribute_Override) {
    Override("val", ty.f32(), Expr(1.23_f));

    Structure("mystruct",
              Vector{
                  Member("a", ty.f32(), Vector{MemberSize(Expr(Source{{12, 34}}, "val"))}),
              });
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(
        r()->error(),
        R"(12:34 error: @size requires a const-expression, but expression is an override-expression)");
}

TEST_F(StructMemberAttributeTest, Size_On_RuntimeSizedArray) {
    Structure("mystruct",
              Vector{
                  Member("a", ty.array<i32>(), Vector{MemberSize(Source{{12, 34}}, 8_a)}),
              });
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(
        r()->error(),
        R"(12:34 error: @size can only be applied to members where the member's type size can be fully determined at shader creation time)");
}

}  // namespace StructAndStructMemberTests

using ArrayAttributeTest = TestWithParams;
TEST_P(ArrayAttributeTest, IsValid) {
    EnableRequiredExtensions();

    auto arr = ty.array(ty.f32(), CreateAttributes());
    Structure("S", Vector{
                       Member("a", arr),
                   });

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         ArrayAttributeTest,
                         testing::Values(
                             TestParams{
                                 {AttributeKind::kAlign},
                                 R"(1:2 error: @align is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kBinding},
                                 R"(1:2 error: @binding is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kBlendSrc},
                                 R"(1:2 error: @blend_src is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kBuiltinPosition},
                                 R"(1:2 error: @builtin is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kDiagnostic},
                                 R"(1:2 error: @diagnostic is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kGroup},
                                 R"(1:2 error: @group is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kId},
                                 R"(1:2 error: @id is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kInterpolate},
                                 R"(1:2 error: @interpolate is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kInvariant},
                                 R"(1:2 error: @invariant is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kLocation},
                                 R"(1:2 error: @location is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kMustUse},
                                 R"(1:2 error: @must_use is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kOffset},
                                 R"(1:2 error: @offset is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kSize},
                                 R"(1:2 error: @size is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kStageCompute},
                                 R"(1:2 error: @stage is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kStride},
                                 Pass,
                             },
                             TestParams{
                                 {AttributeKind::kWorkgroupSize},
                                 R"(1:2 error: @workgroup_size is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kBinding, AttributeKind::kGroup},
                                 R"(1:2 error: @binding is not valid for array types)",
                             },
                             TestParams{
                                 {AttributeKind::kStride, AttributeKind::kStride},
                                 R"(3:4 error: duplicate stride attribute
1:2 note: first attribute declared here)",
                             }));

using VariableAttributeTest = TestWithParams;
TEST_P(VariableAttributeTest, IsValid) {
    EnableRequiredExtensions();

    if (GetParam().attributes.Any(IsBindingAttribute)) {
        GlobalVar(Source{{9, 9}}, "a", ty.sampler(core::type::SamplerKind::kSampler),
                  CreateAttributes());
    } else {
        GlobalVar(Source{{9, 9}}, "a", ty.f32(), core::AddressSpace::kPrivate, CreateAttributes());
    }

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    VariableAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(9:9 error: resource variables require @group and @binding attributes)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(9:9 error: resource variables require @group and @binding attributes)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(1:2 error: @interpolate is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(1:2 error: @invariant is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kLocation},
            R"(1:2 error: @location is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for module-scope 'var')",
        },
        TestParams{
            {AttributeKind::kBinding, AttributeKind::kGroup},
            Pass,
        },
        TestParams{
            {AttributeKind::kBinding, AttributeKind::kGroup, AttributeKind::kBinding},
            R"(5:6 error: duplicate binding attribute
1:2 note: first attribute declared here)",
        }));

TEST_F(VariableAttributeTest, LocalVar) {
    auto* v = Var("a", ty.f32(), Vector{Binding(Source{{12, 34}}, 2_a)});

    WrapInFunction(v);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: @binding is not valid for function-scope 'var'");
}

TEST_F(VariableAttributeTest, LocalLet) {
    auto* v = Let("a", Vector{Binding(Source{{12, 34}}, 2_a)}, Expr(1_a));

    WrapInFunction(v);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), "12:34 error: @binding is not valid for 'let' declaration");
}

using ConstantAttributeTest = TestWithParams;
TEST_P(ConstantAttributeTest, IsValid) {
    EnableRequiredExtensions();

    GlobalConst("a", ty.f32(), Expr(1.23_f), CreateAttributes());

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    ConstantAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kId},
            R"(1:2 error: @id is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(1:2 error: @interpolate is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(1:2 error: @invariant is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kLocation},
            R"(1:2 error: @location is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for 'const' declaration)",
        },
        TestParams{
            {AttributeKind::kBinding, AttributeKind::kGroup},
            R"(1:2 error: @binding is not valid for 'const' declaration)",
        }));

using OverrideAttributeTest = TestWithParams;
TEST_P(OverrideAttributeTest, IsValid) {
    EnableRequiredExtensions();

    Override("a", ty.f32(), Expr(1.23_f), CreateAttributes());

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    OverrideAttributeTest,
    testing::Values(
        TestParams{
            {AttributeKind::kAlign},
            R"(1:2 error: @align is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kBinding},
            R"(1:2 error: @binding is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kBlendSrc},
            R"(1:2 error: @blend_src is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kBuiltinPosition},
            R"(1:2 error: @builtin is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kDiagnostic},
            R"(1:2 error: @diagnostic is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kGroup},
            R"(1:2 error: @group is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kId},
            Pass,
        },
        TestParams{
            {AttributeKind::kInterpolate},
            R"(1:2 error: @interpolate is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kInvariant},
            R"(1:2 error: @invariant is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kLocation},
            R"(1:2 error: @location is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kMustUse},
            R"(1:2 error: @must_use is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kOffset},
            R"(1:2 error: @offset is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kSize},
            R"(1:2 error: @size is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kStageCompute},
            R"(1:2 error: @stage is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kStride},
            R"(1:2 error: @stride is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kWorkgroupSize},
            R"(1:2 error: @workgroup_size is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kBinding, AttributeKind::kGroup},
            R"(1:2 error: @binding is not valid for 'override' declaration)",
        },
        TestParams{
            {AttributeKind::kId, AttributeKind::kId},
            R"(3:4 error: duplicate id attribute
1:2 note: first attribute declared here)",
        }));

using SwitchStatementAttributeTest = TestWithParams;
TEST_P(SwitchStatementAttributeTest, IsValid) {
    EnableRequiredExtensions();

    WrapInFunction(Switch(Expr(0_a), Vector{DefaultCase()}, CreateAttributes()));

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         SwitchStatementAttributeTest,
                         testing::ValuesIn(OnlyDiagnosticValidFor("switch statements")));

using SwitchBodyAttributeTest = TestWithParams;
TEST_P(SwitchBodyAttributeTest, IsValid) {
    EnableRequiredExtensions();

    WrapInFunction(Switch(Expr(0_a), Vector{DefaultCase()}, tint::Empty, CreateAttributes()));

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         SwitchBodyAttributeTest,
                         testing::ValuesIn(OnlyDiagnosticValidFor("switch body")));

using IfStatementAttributeTest = TestWithParams;
TEST_P(IfStatementAttributeTest, IsValid) {
    EnableRequiredExtensions();

    WrapInFunction(If(Expr(true), Block(), ElseStmt(), CreateAttributes()));

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         IfStatementAttributeTest,
                         testing::ValuesIn(OnlyDiagnosticValidFor("if statements")));

using ForStatementAttributeTest = TestWithParams;
TEST_P(ForStatementAttributeTest, IsValid) {
    EnableRequiredExtensions();

    WrapInFunction(For(nullptr, Expr(false), nullptr, Block(), CreateAttributes()));

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         ForStatementAttributeTest,
                         testing::ValuesIn(OnlyDiagnosticValidFor("for statements")));

using LoopStatementAttributeTest = TestWithParams;
TEST_P(LoopStatementAttributeTest, IsValid) {
    EnableRequiredExtensions();

    WrapInFunction(Loop(Block(Return()), Block(), CreateAttributes()));

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         LoopStatementAttributeTest,
                         testing::ValuesIn(OnlyDiagnosticValidFor("loop statements")));

using WhileStatementAttributeTest = TestWithParams;
TEST_P(WhileStatementAttributeTest, IsValid) {
    EnableRequiredExtensions();

    WrapInFunction(While(Expr(false), Block(), CreateAttributes()));

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         WhileStatementAttributeTest,
                         testing::ValuesIn(OnlyDiagnosticValidFor("while statements")));

using BlockStatementTest = TestWithParams;
TEST_P(BlockStatementTest, CompoundStatement) {
    Func("foo", tint::Empty, ty.void_(),
         Vector{
             Block(Vector{Return()}, CreateAttributes()),
         });

    CHECK();
}
TEST_P(BlockStatementTest, FunctionBody) {
    Func("foo", tint::Empty, ty.void_(), Block(Vector{Return()}, CreateAttributes()));

    CHECK();
}
TEST_P(BlockStatementTest, IfStatementBody) {
    Func("foo", tint::Empty, ty.void_(),
         Vector{
             If(Expr(true), Block(Vector{Return()}, CreateAttributes())),
         });

    CHECK();
}
TEST_P(BlockStatementTest, ElseStatementBody) {
    Func("foo", tint::Empty, ty.void_(),
         Vector{
             If(Expr(true), Block(Vector{Return()}),
                Else(Block(Vector{Return()}, CreateAttributes()))),
         });

    CHECK();
}
TEST_P(BlockStatementTest, ForStatementBody) {
    Func("foo", tint::Empty, ty.void_(),
         Vector{
             For(nullptr, Expr(true), nullptr, Block(Vector{Break()}, CreateAttributes())),
         });

    CHECK();
}
TEST_P(BlockStatementTest, LoopStatementBody) {
    Func("foo", tint::Empty, ty.void_(),
         Vector{
             Loop(Block(Vector{Break()}, CreateAttributes())),
         });

    CHECK();
}
TEST_P(BlockStatementTest, WhileStatementBody) {
    Func("foo", tint::Empty, ty.void_(),
         Vector{
             While(Expr(true), Block(Vector{Break()}, CreateAttributes())),
         });

    CHECK();
}
TEST_P(BlockStatementTest, CaseStatementBody) {
    Func("foo", tint::Empty, ty.void_(),
         Vector{
             Switch(1_a, Case(CaseSelector(1_a), Block(Vector{Break()}, CreateAttributes())),
                    DefaultCase(Block({}))),
         });

    CHECK();
}
TEST_P(BlockStatementTest, DefaultStatementBody) {
    Func("foo", tint::Empty, ty.void_(),
         Vector{
             Switch(1_a, Case(CaseSelector(1_a), Block()),
                    DefaultCase(Block(Vector{Break()}, CreateAttributes()))),
         });

    CHECK();
}
INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         BlockStatementTest,
                         testing::ValuesIn(OnlyDiagnosticValidFor("block statements")));

}  // namespace
}  // namespace AttributeTests

namespace ArrayStrideTests {
namespace {

struct Params {
    builder::ast_type_func_ptr create_el_type;
    uint32_t stride;
    bool should_pass;
};

template <typename T>
constexpr Params ParamsFor(uint32_t stride, bool should_pass) {
    return Params{DataType<T>::AST, stride, should_pass};
}

struct TestWithParams : ResolverTestWithParam<Params> {};

using ArrayStrideTest = TestWithParams;
TEST_P(ArrayStrideTest, All) {
    auto& params = GetParam();
    ast::Type el_ty = params.create_el_type(*this);

    StringStream ss;
    ss << "el_ty: " << FriendlyName(el_ty) << ", stride: " << params.stride
       << ", should_pass: " << params.should_pass;
    SCOPED_TRACE(ss.str());

    auto arr = ty.array(el_ty, 4_u,
                        Vector{
                            create<ast::StrideAttribute>(Source{{12, 34}}, params.stride),
                        });

    GlobalVar("myarray", arr, core::AddressSpace::kPrivate);

    if (params.should_pass) {
        EXPECT_TRUE(r()->Resolve()) << r()->error();
    } else {
        EXPECT_FALSE(r()->Resolve());
        EXPECT_EQ(r()->error(),
                  "12:34 error: arrays decorated with the stride attribute must have a stride that "
                  "is at least the size of the element type, and be a multiple of the element "
                  "type's alignment value");
    }
}

struct SizeAndAlignment {
    uint32_t size;
    uint32_t align;
};
constexpr SizeAndAlignment default_u32 = {4, 4};
constexpr SizeAndAlignment default_i32 = {4, 4};
constexpr SizeAndAlignment default_f32 = {4, 4};
constexpr SizeAndAlignment default_vec2 = {8, 8};
constexpr SizeAndAlignment default_vec3 = {12, 16};
constexpr SizeAndAlignment default_vec4 = {16, 16};
constexpr SizeAndAlignment default_mat2x2 = {16, 8};
constexpr SizeAndAlignment default_mat3x3 = {48, 16};
constexpr SizeAndAlignment default_mat4x4 = {64, 16};

INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
                         ArrayStrideTest,
                         testing::Values(
                             // Succeed because stride >= element size (while being multiple of
                             // element alignment)
                             ParamsFor<u32>(default_u32.size, true),
                             ParamsFor<i32>(default_i32.size, true),
                             ParamsFor<f32>(default_f32.size, true),
                             ParamsFor<vec2<f32>>(default_vec2.size, true),
                             // vec3's default size is not a multiple of its alignment
                             // ParamsFor<vec3<f32>, default_vec3.size, true},
                             ParamsFor<vec4<f32>>(default_vec4.size, true),
                             ParamsFor<mat2x2<f32>>(default_mat2x2.size, true),
                             ParamsFor<mat3x3<f32>>(default_mat3x3.size, true),
                             ParamsFor<mat4x4<f32>>(default_mat4x4.size, true),

                             // Fail because stride is < element size
                             ParamsFor<u32>(default_u32.size - 1, false),
                             ParamsFor<i32>(default_i32.size - 1, false),
                             ParamsFor<f32>(default_f32.size - 1, false),
                             ParamsFor<vec2<f32>>(default_vec2.size - 1, false),
                             ParamsFor<vec3<f32>>(default_vec3.size - 1, false),
                             ParamsFor<vec4<f32>>(default_vec4.size - 1, false),
                             ParamsFor<mat2x2<f32>>(default_mat2x2.size - 1, false),
                             ParamsFor<mat3x3<f32>>(default_mat3x3.size - 1, false),
                             ParamsFor<mat4x4<f32>>(default_mat4x4.size - 1, false),

                             // Succeed because stride equals multiple of element alignment
                             ParamsFor<u32>(default_u32.align * 7, true),
                             ParamsFor<i32>(default_i32.align * 7, true),
                             ParamsFor<f32>(default_f32.align * 7, true),
                             ParamsFor<vec2<f32>>(default_vec2.align * 7, true),
                             ParamsFor<vec3<f32>>(default_vec3.align * 7, true),
                             ParamsFor<vec4<f32>>(default_vec4.align * 7, true),
                             ParamsFor<mat2x2<f32>>(default_mat2x2.align * 7, true),
                             ParamsFor<mat3x3<f32>>(default_mat3x3.align * 7, true),
                             ParamsFor<mat4x4<f32>>(default_mat4x4.align * 7, true),

                             // Fail because stride is not multiple of element alignment
                             ParamsFor<u32>((default_u32.align - 1) * 7, false),
                             ParamsFor<i32>((default_i32.align - 1) * 7, false),
                             ParamsFor<f32>((default_f32.align - 1) * 7, false),
                             ParamsFor<vec2<f32>>((default_vec2.align - 1) * 7, false),
                             ParamsFor<vec3<f32>>((default_vec3.align - 1) * 7, false),
                             ParamsFor<vec4<f32>>((default_vec4.align - 1) * 7, false),
                             ParamsFor<mat2x2<f32>>((default_mat2x2.align - 1) * 7, false),
                             ParamsFor<mat3x3<f32>>((default_mat3x3.align - 1) * 7, false),
                             ParamsFor<mat4x4<f32>>((default_mat4x4.align - 1) * 7, false)));

TEST_F(ArrayStrideTest, DuplicateAttribute) {
    auto arr = ty.array(Source{{12, 34}}, ty.i32(), 4_u,
                        Vector{
                            create<ast::StrideAttribute>(Source{{12, 34}}, 4u),
                            create<ast::StrideAttribute>(Source{{56, 78}}, 4u),
                        });

    GlobalVar("myarray", arr, core::AddressSpace::kPrivate);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(56:78 error: duplicate stride attribute
12:34 note: first attribute declared here)");
}

}  // namespace
}  // namespace ArrayStrideTests

namespace ResourceTests {
namespace {

using ResourceAttributeTest = ResolverTest;
TEST_F(ResourceAttributeTest, UniformBufferMissingBinding) {
    auto* s = Structure("S", Vector{
                                 Member("x", ty.i32()),
                             });
    GlobalVar(Source{{12, 34}}, "G", ty.Of(s), core::AddressSpace::kUniform);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(12:34 error: resource variables require @group and @binding attributes)");
}

TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) {
    auto* s = Structure("S", Vector{
                                 Member("x", ty.i32()),
                             });
    GlobalVar(Source{{12, 34}}, "G", ty.Of(s), core::AddressSpace::kStorage, core::Access::kRead);

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(12:34 error: resource variables require @group and @binding attributes)");
}

TEST_F(ResourceAttributeTest, TextureMissingBinding) {
    GlobalVar(Source{{12, 34}}, "G", ty.depth_texture(core::type::TextureDimension::k2d));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(12:34 error: resource variables require @group and @binding attributes)");
}

TEST_F(ResourceAttributeTest, SamplerMissingBinding) {
    GlobalVar(Source{{12, 34}}, "G", ty.sampler(core::type::SamplerKind::kSampler));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(12:34 error: resource variables require @group and @binding attributes)");
}

TEST_F(ResourceAttributeTest, BindingPairMissingBinding) {
    GlobalVar(Source{{12, 34}}, "G", ty.sampler(core::type::SamplerKind::kSampler), Group(1_a));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(12:34 error: resource variables require @group and @binding attributes)");
}

TEST_F(ResourceAttributeTest, BindingPairMissingGroup) {
    GlobalVar(Source{{12, 34}}, "G", ty.sampler(core::type::SamplerKind::kSampler), Binding(1_a));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(12:34 error: resource variables require @group and @binding attributes)");
}

TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) {
    GlobalVar(Source{{12, 34}}, "A",
              ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding(1_a),
              Group(2_a));
    GlobalVar(Source{{56, 78}}, "B",
              ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding(1_a),
              Group(2_a));

    Func("F", tint::Empty, ty.void_(),
         Vector{
             Decl(Var("a", ty.vec4<f32>(),
                      Call("textureLoad", "A", Call<vec2<i32>>(1_i, 2_i), 0_i))),
             Decl(Var("b", ty.vec4<f32>(),
                      Call("textureLoad", "B", Call<vec2<i32>>(1_i, 2_i), 0_i))),
         },
         Vector{
             Stage(ast::PipelineStage::kFragment),
         });

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(
        r()->error(),
        R"(56:78 error: entry point 'F' references multiple variables that use the same resource binding @group(2), @binding(1)
12:34 note: first resource binding usage declared here)");
}

TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) {
    GlobalVar(Source{{12, 34}}, "A",
              ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding(1_a),
              Group(2_a));
    GlobalVar(Source{{56, 78}}, "B",
              ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding(1_a),
              Group(2_a));

    Func("F_A", tint::Empty, ty.void_(),
         Vector{
             Decl(Var("a", ty.vec4<f32>(),
                      Call("textureLoad", "A", Call<vec2<i32>>(1_i, 2_i), 0_i))),
         },
         Vector{
             Stage(ast::PipelineStage::kFragment),
         });
    Func("F_B", tint::Empty, ty.void_(),
         Vector{
             Decl(Var("b", ty.vec4<f32>(),
                      Call("textureLoad", "B", Call<vec2<i32>>(1_i, 2_i), 0_i))),
         },
         Vector{
             Stage(ast::PipelineStage::kFragment),
         });

    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(ResourceAttributeTest, BindingPointOnNonResource) {
    GlobalVar(Source{{12, 34}}, "G", ty.f32(), core::AddressSpace::kPrivate, Binding(1_a),
              Group(2_a));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(12:34 error: non-resource variables must not have @group or @binding attributes)");
}

}  // namespace
}  // namespace ResourceTests

namespace WorkgroupAttributeTests {
namespace {

using WorkgroupAttribute = ResolverTest;
TEST_F(WorkgroupAttribute, NotAnEntryPoint) {
    Func("main", tint::Empty, ty.void_(), tint::Empty,
         Vector{
             create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1_i)),
         });

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @workgroup_size is only valid for compute stages)");
}

TEST_F(WorkgroupAttribute, NotAComputeShader) {
    Func("main", tint::Empty, ty.void_(), tint::Empty,
         Vector{
             Stage(ast::PipelineStage::kFragment),
             create<ast::WorkgroupAttribute>(Source{{12, 34}}, Expr(1_i)),
         });

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @workgroup_size is only valid for compute stages)");
}

TEST_F(WorkgroupAttribute, DuplicateAttribute) {
    Func(Source{{12, 34}}, "main", tint::Empty, ty.void_(), tint::Empty,
         Vector{
             Stage(ast::PipelineStage::kCompute),
             WorkgroupSize(Source{{12, 34}}, 1_i, nullptr, nullptr),
             WorkgroupSize(Source{{56, 78}}, 2_i, nullptr, nullptr),
         });

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(),
              R"(56:78 error: duplicate workgroup_size attribute
12:34 note: first attribute declared here)");
}

}  // namespace
}  // namespace WorkgroupAttributeTests

namespace InterpolateTests {
namespace {

using InterpolateTest = ResolverTest;

struct Params {
    core::InterpolationType type;
    core::InterpolationSampling sampling;
    bool should_pass;
};

struct TestWithParams : ResolverTestWithParam<Params> {};

using InterpolateParameterTest = TestWithParams;
TEST_P(InterpolateParameterTest, All) {
    auto& params = GetParam();
    Func("main",
         Vector{
             Param("a", ty.f32(),
                   Vector{
                       Location(0_a),
                       Interpolate(Source{{12, 34}}, params.type, params.sampling),
                   }),
         },
         ty.void_(), tint::Empty,
         Vector{
             Stage(ast::PipelineStage::kFragment),
         });

    if (params.should_pass) {
        EXPECT_TRUE(r()->Resolve()) << r()->error();
    } else {
        EXPECT_FALSE(r()->Resolve());
        EXPECT_EQ(
            r()->error(),
            R"(12:34 error: flat interpolation attribute must not have a sampling parameter)");
    }
}

TEST_P(InterpolateParameterTest, IntegerScalar) {
    auto& params = GetParam();
    Func("main",
         Vector{
             Param("a", ty.i32(),
                   Vector{
                       Location(0_a),
                       Interpolate(Source{{12, 34}}, params.type, params.sampling),
                   }),
         },
         ty.void_(), tint::Empty,
         Vector{
             Stage(ast::PipelineStage::kFragment),
         });

    if (params.type != core::InterpolationType::kFlat) {
        EXPECT_FALSE(r()->Resolve());
        EXPECT_EQ(
            r()->error(),
            R"(12:34 error: interpolation type must be 'flat' for integral user-defined IO types)");
    } else if (params.should_pass) {
        EXPECT_TRUE(r()->Resolve()) << r()->error();
    } else {
        EXPECT_FALSE(r()->Resolve());
        EXPECT_EQ(
            r()->error(),
            R"(12:34 error: flat interpolation attribute must not have a sampling parameter)");
    }
}

TEST_P(InterpolateParameterTest, IntegerVector) {
    auto& params = GetParam();
    Func("main",
         Vector{
             Param("a", ty.vec4<u32>(),
                   Vector{
                       Location(0_a),
                       Interpolate(Source{{12, 34}}, params.type, params.sampling),
                   }),
         },
         ty.void_(), tint::Empty,
         Vector{
             Stage(ast::PipelineStage::kFragment),
         });

    if (params.type != core::InterpolationType::kFlat) {
        EXPECT_FALSE(r()->Resolve());
        EXPECT_EQ(
            r()->error(),
            R"(12:34 error: interpolation type must be 'flat' for integral user-defined IO types)");
    } else if (params.should_pass) {
        EXPECT_TRUE(r()->Resolve()) << r()->error();
    } else {
        EXPECT_FALSE(r()->Resolve());
        EXPECT_EQ(
            r()->error(),
            R"(12:34 error: flat interpolation attribute must not have a sampling parameter)");
    }
}

INSTANTIATE_TEST_SUITE_P(
    ResolverAttributeValidationTest,
    InterpolateParameterTest,
    testing::Values(
        Params{core::InterpolationType::kPerspective, core::InterpolationSampling::kUndefined,
               true},
        Params{core::InterpolationType::kPerspective, core::InterpolationSampling::kCenter, true},
        Params{core::InterpolationType::kPerspective, core::InterpolationSampling::kCentroid, true},
        Params{core::InterpolationType::kPerspective, core::InterpolationSampling::kSample, true},
        Params{core::InterpolationType::kLinear, core::InterpolationSampling::kUndefined, true},
        Params{core::InterpolationType::kLinear, core::InterpolationSampling::kCenter, true},
        Params{core::InterpolationType::kLinear, core::InterpolationSampling::kCentroid, true},
        Params{core::InterpolationType::kLinear, core::InterpolationSampling::kSample, true},
        // flat interpolation must not have a sampling type
        Params{core::InterpolationType::kFlat, core::InterpolationSampling::kUndefined, true},
        Params{core::InterpolationType::kFlat, core::InterpolationSampling::kCenter, false},
        Params{core::InterpolationType::kFlat, core::InterpolationSampling::kCentroid, false},
        Params{core::InterpolationType::kFlat, core::InterpolationSampling::kSample, false}));

TEST_F(InterpolateTest, FragmentInput_Integer_MissingFlatInterpolation) {
    Func("main", Vector{Param(Source{{12, 34}}, "a", ty.i32(), Vector{Location(0_a)})}, ty.void_(),
         tint::Empty,
         Vector{
             Stage(ast::PipelineStage::kFragment),
         });

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(
        r()->error(),
        R"(12:34 error: integral user-defined fragment inputs must have a flat interpolation attribute)");
}

TEST_F(InterpolateTest, VertexOutput_Integer_MissingFlatInterpolation) {
    auto* s = Structure(
        "S", Vector{
                 Member("pos", ty.vec4<f32>(), Vector{Builtin(core::BuiltinValue::kPosition)}),
                 Member(Source{{12, 34}}, "u", ty.u32(), Vector{Location(0_a)}),
             });
    Func("main", tint::Empty, ty.Of(s),
         Vector{
             Return(Call(ty.Of(s))),
         },
         Vector{
             Stage(ast::PipelineStage::kVertex),
         });

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(
        r()->error(),
        R"(12:34 error: integral user-defined vertex outputs must have a flat interpolation attribute
note: while analyzing entry point 'main')");
}

using GroupAndBindingTest = ResolverTest;

TEST_F(GroupAndBindingTest, Const_I32) {
    GlobalConst("b", Expr(4_i));
    GlobalConst("g", Expr(2_i));
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding("b"),
              Group("g"));

    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(GroupAndBindingTest, Const_U32) {
    GlobalConst("b", Expr(4_u));
    GlobalConst("g", Expr(2_u));
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding("b"),
              Group("g"));

    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(GroupAndBindingTest, Const_AInt) {
    GlobalConst("b", Expr(4_a));
    GlobalConst("g", Expr(2_a));
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding("b"),
              Group("g"));

    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(GroupAndBindingTest, Binding_NonConstant) {
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()),
              Binding(Call<u32>(Call(Source{{12, 34}}, "dpdx", 1_a))), Group(1_i));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(
        r()->error(),
        R"(12:34 error: @binding requires a const-expression, but expression is a runtime-expression)");
}

TEST_F(GroupAndBindingTest, Binding_Negative) {
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()),
              Binding(Source{{12, 34}}, -2_i), Group(1_i));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @binding value must be non-negative)");
}

TEST_F(GroupAndBindingTest, Binding_F32) {
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()),
              Binding(Source{{12, 34}}, 2.0_f), Group(1_u));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @binding must be an i32 or u32 value)");
}

TEST_F(GroupAndBindingTest, Binding_AFloat) {
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()),
              Binding(Source{{12, 34}}, 2.0_a), Group(1_u));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @binding must be an i32 or u32 value)");
}

TEST_F(GroupAndBindingTest, Group_NonConstant) {
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding(2_u),
              Group(Call<u32>(Call(Source{{12, 34}}, "dpdx", 1_a))));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(
        r()->error(),
        R"(12:34 error: @group requires a const-expression, but expression is a runtime-expression)");
}

TEST_F(GroupAndBindingTest, Group_Negative) {
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding(2_u),
              Group(Source{{12, 34}}, -1_i));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @group value must be non-negative)");
}

TEST_F(GroupAndBindingTest, Group_F32) {
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding(2_u),
              Group(Source{{12, 34}}, 1.0_f));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @group must be an i32 or u32 value)");
}

TEST_F(GroupAndBindingTest, Group_AFloat) {
    GlobalVar("val", ty.sampled_texture(core::type::TextureDimension::k2d, ty.f32()), Binding(2_u),
              Group(Source{{12, 34}}, 1.0_a));

    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @group must be an i32 or u32 value)");
}

using IdTest = ResolverTest;

TEST_F(IdTest, Const_I32) {
    Override("val", ty.f32(), Vector{Id(1_i)});
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(IdTest, Const_U32) {
    Override("val", ty.f32(), Vector{Id(1_u)});
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(IdTest, Const_AInt) {
    Override("val", ty.f32(), Vector{Id(1_a)});
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_F(IdTest, NonConstant) {
    Override("val", ty.f32(), Vector{Id(Call<u32>(Call(Source{{12, 34}}, "dpdx", 1_a)))});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(
        r()->error(),
        R"(12:34 error: @id requires a const-expression, but expression is a runtime-expression)");
}

TEST_F(IdTest, Negative) {
    Override("val", ty.f32(), Vector{Id(Source{{12, 34}}, -1_i)});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @id value must be non-negative)");
}

TEST_F(IdTest, F32) {
    Override("val", ty.f32(), Vector{Id(Source{{12, 34}}, 1_f)});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @id must be an i32 or u32 value)");
}

TEST_F(IdTest, AFloat) {
    Override("val", ty.f32(), Vector{Id(Source{{12, 34}}, 1.0_a)});
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @id must be an i32 or u32 value)");
}

enum class LocationAttributeType {
    kEntryPointParameter,
    kEntryPointReturnType,
    kStructureMember,
};

struct LocationTest : ResolverTestWithParam<LocationAttributeType> {
    void Build(const ast::Expression* location_value) {
        switch (GetParam()) {
            case LocationAttributeType::kEntryPointParameter:
                Func("main",
                     Vector{Param(Source{{12, 34}}, "a", ty.i32(),
                                  Vector{
                                      Location(Source{{12, 34}}, location_value),
                                      Flat(),
                                  })},
                     ty.void_(), tint::Empty,
                     Vector{
                         Stage(ast::PipelineStage::kFragment),
                     });
                return;
            case LocationAttributeType::kEntryPointReturnType:
                Func("main", tint::Empty, ty.f32(),
                     Vector{
                         Return(1_a),
                     },
                     Vector{
                         Stage(ast::PipelineStage::kFragment),
                     },
                     Vector{
                         Location(Source{{12, 34}}, location_value),
                     });
                return;
            case LocationAttributeType::kStructureMember:
                Structure("S", Vector{
                                   Member("m", ty.f32(),
                                          Vector{
                                              Location(Source{{12, 34}}, location_value),
                                          }),
                               });
                return;
        }
    }
};

TEST_P(LocationTest, Const_I32) {
    Build(Expr(0_i));
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_P(LocationTest, Const_U32) {
    Build(Expr(0_u));
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_P(LocationTest, Const_AInt) {
    Build(Expr(0_a));
    EXPECT_TRUE(r()->Resolve()) << r()->error();
}

TEST_P(LocationTest, NonConstant) {
    Build(Call<u32>(Call(Source{{12, 34}}, "dpdx", 1_a)));
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(
        r()->error(),
        R"(12:34 error: @location value requires a const-expression, but expression is a runtime-expression)");
}

TEST_P(LocationTest, Negative) {
    Build(Expr(-1_a));
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @location value must be non-negative)");
}

TEST_P(LocationTest, F32) {
    Build(Expr(1_f));
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @location must be an i32 or u32 value)");
}

TEST_P(LocationTest, AFloat) {
    Build(Expr(1.0_a));
    EXPECT_FALSE(r()->Resolve());
    EXPECT_EQ(r()->error(), R"(12:34 error: @location must be an i32 or u32 value)");
}

INSTANTIATE_TEST_SUITE_P(LocationTest,
                         LocationTest,
                         testing::Values(LocationAttributeType::kEntryPointParameter,
                                         LocationAttributeType::kEntryPointReturnType,
                                         LocationAttributeType::kStructureMember));

}  // namespace
}  // namespace InterpolateTests

namespace InternalAttributeDeps {
namespace {

class TestAttribute : public Castable<TestAttribute, ast::InternalAttribute> {
  public:
    TestAttribute(GenerationID pid, ast::NodeID nid, const ast::IdentifierExpression* dep)
        : Base(pid, nid, Vector{dep}) {}
    std::string InternalName() const override { return "test_attribute"; }
    const Node* Clone(ast::CloneContext&) const override { return nullptr; }
};

using InternalAttributeDepsTest = ResolverTest;
TEST_F(InternalAttributeDepsTest, Dependency) {
    auto* ident = Expr("v");
    auto* attr = ASTNodes().Create<TestAttribute>(ID(), AllocateNodeID(), ident);
    auto* f = Func("f", tint::Empty, ty.void_(), tint::Empty, Vector{attr});
    auto* v = GlobalVar("v", ty.i32(), core::AddressSpace::kPrivate);

    EXPECT_TRUE(r()->Resolve()) << r()->error();

    auto* user = As<sem::VariableUser>(Sem().Get(ident));
    ASSERT_NE(user, nullptr);

    auto* var = Sem().Get(v);
    EXPECT_EQ(user->Variable(), var);

    auto* fn = Sem().Get(f);
    EXPECT_THAT(fn->DirectlyReferencedGlobals(), testing::ElementsAre(var));
    EXPECT_THAT(fn->TransitivelyReferencedGlobals(), testing::ElementsAre(var));
}

}  // namespace
}  // namespace InternalAttributeDeps

}  // namespace tint::resolver

TINT_INSTANTIATE_TYPEINFO(tint::resolver::InternalAttributeDeps::TestAttribute);
