chromium/third_party/dawn/src/tint/lang/wgsl/resolver/attribute_validation_test.cc

// 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 {

usingnamespacetint::core::fluent_types;     // NOLINT
usingnamespacetint::core::number_suffixes;  // NOLINT

// Helpers and typedefs
DataType;
alias;
alias1;
alias2;
alias3;

namespace AttributeTests {
namespace {
enum class AttributeKind {};
static std::ostream& operator<<(std::ostream& o, AttributeKind k) {}

static bool IsBindingAttribute(AttributeKind kind) {}

struct TestParams {};

static constexpr const char* Pass =;

static std::vector<TestParams> OnlyDiagnosticValidFor(std::string thing) {}

static std::ostream& operator<<(std::ostream& o, const TestParams& c) {}

const ast::Attribute* CreateAttribute(const Source& source,
                                      ProgramBuilder& builder,
                                      AttributeKind kind) {}

struct TestWithParams : ResolverTestWithParam<TestParams> {};

#undef CHECK
#define CHECK()

namespace FunctionTests {
VoidFunctionAttributeTest;
TEST_P(VoidFunctionAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

NonVoidFunctionAttributeTest;
TEST_P(NonVoidFunctionAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();
}  // namespace FunctionTests

namespace FunctionInputAndOutputTests {
FunctionParameterAttributeTest;
TEST_P(FunctionParameterAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

FunctionReturnTypeAttributeTest;
TEST_P(FunctionReturnTypeAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();
}  // namespace FunctionInputAndOutputTests

namespace EntryPointInputAndOutputTests {
ComputeShaderParameterAttributeTest;
TEST_P(ComputeShaderParameterAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

FragmentShaderParameterAttributeTest;
TEST_P(FragmentShaderParameterAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

VertexShaderParameterAttributeTest;
TEST_P(VertexShaderParameterAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

ComputeShaderReturnTypeAttributeTest;
TEST_P(ComputeShaderReturnTypeAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

FragmentShaderReturnTypeAttributeTest;
TEST_P(FragmentShaderReturnTypeAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

VertexShaderReturnTypeAttributeTest;
TEST_P(VertexShaderReturnTypeAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

EntryPointParameterAttributeTest;
TEST_F(EntryPointParameterAttributeTest, DuplicateInternalAttribute) {}

EntryPointReturnTypeAttributeTest;
TEST_F(EntryPointReturnTypeAttributeTest, DuplicateInternalAttribute) {}
}  // namespace EntryPointInputAndOutputTests

namespace StructAndStructMemberTests {
StructAttributeTest;
SpirvBlockAttribute;
TEST_P(StructAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

StructMemberAttributeTest;
TEST_P(StructMemberAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

TEST_F(StructMemberAttributeTest, Align_Attribute_Const) {}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstNegative) {}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstPowerOfTwo) {}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstF32) {}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstU32) {}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstAInt) {}

TEST_F(StructMemberAttributeTest, Align_Attribute_ConstAFloat) {}

TEST_F(StructMemberAttributeTest, Align_Attribute_Var) {}

TEST_F(StructMemberAttributeTest, Align_Attribute_Override) {}

TEST_F(StructMemberAttributeTest, Size_Attribute_Const) {}

TEST_F(StructMemberAttributeTest, Size_Attribute_ConstNegative) {}

TEST_F(StructMemberAttributeTest, Size_Attribute_ConstF32) {}

TEST_F(StructMemberAttributeTest, Size_Attribute_ConstU32) {}

TEST_F(StructMemberAttributeTest, Size_Attribute_ConstAInt) {}

TEST_F(StructMemberAttributeTest, Size_Attribute_ConstAFloat) {}

TEST_F(StructMemberAttributeTest, Size_Attribute_Var) {}

TEST_F(StructMemberAttributeTest, Size_Attribute_Override) {}

TEST_F(StructMemberAttributeTest, Size_On_RuntimeSizedArray) {}

}  // namespace StructAndStructMemberTests

ArrayAttributeTest;
TEST_P(ArrayAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

VariableAttributeTest;
TEST_P(VariableAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

TEST_F(VariableAttributeTest, LocalVar) {}

TEST_F(VariableAttributeTest, LocalLet) {}

ConstantAttributeTest;
TEST_P(ConstantAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

OverrideAttributeTest;
TEST_P(OverrideAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

SwitchStatementAttributeTest;
TEST_P(SwitchStatementAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

SwitchBodyAttributeTest;
TEST_P(SwitchBodyAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

IfStatementAttributeTest;
TEST_P(IfStatementAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

ForStatementAttributeTest;
TEST_P(ForStatementAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

LoopStatementAttributeTest;
TEST_P(LoopStatementAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

WhileStatementAttributeTest;
TEST_P(WhileStatementAttributeTest, IsValid) {}
INSTANTIATE_TEST_SUITE_P();

BlockStatementTest;
TEST_P(BlockStatementTest, CompoundStatement) {}
TEST_P(BlockStatementTest, FunctionBody) {}
TEST_P(BlockStatementTest, IfStatementBody) {}
TEST_P(BlockStatementTest, ElseStatementBody) {}
TEST_P(BlockStatementTest, ForStatementBody) {}
TEST_P(BlockStatementTest, LoopStatementBody) {}
TEST_P(BlockStatementTest, WhileStatementBody) {}
TEST_P(BlockStatementTest, CaseStatementBody) {}
TEST_P(BlockStatementTest, DefaultStatementBody) {}
INSTANTIATE_TEST_SUITE_P();

}  // namespace
}  // namespace AttributeTests

namespace ArrayStrideTests {
namespace {

struct Params {};

template <typename T>
constexpr Params ParamsFor(uint32_t stride, bool should_pass) {}

struct TestWithParams : ResolverTestWithParam<Params> {};

ArrayStrideTest;
TEST_P(ArrayStrideTest, All) {}

struct SizeAndAlignment {};
constexpr SizeAndAlignment default_u32 =;
constexpr SizeAndAlignment default_i32 =;
constexpr SizeAndAlignment default_f32 =;
constexpr SizeAndAlignment default_vec2 =;
constexpr SizeAndAlignment default_vec3 =;
constexpr SizeAndAlignment default_vec4 =;
constexpr SizeAndAlignment default_mat2x2 =;
constexpr SizeAndAlignment default_mat3x3 =;
constexpr SizeAndAlignment default_mat4x4 =;

INSTANTIATE_TEST_SUITE_P();

TEST_F(ArrayStrideTest, DuplicateAttribute) {}

}  // namespace
}  // namespace ArrayStrideTests

namespace ResourceTests {
namespace {

ResourceAttributeTest;
TEST_F(ResourceAttributeTest, UniformBufferMissingBinding) {}

TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) {}

TEST_F(ResourceAttributeTest, TextureMissingBinding) {}

TEST_F(ResourceAttributeTest, SamplerMissingBinding) {}

TEST_F(ResourceAttributeTest, BindingPairMissingBinding) {}

TEST_F(ResourceAttributeTest, BindingPairMissingGroup) {}

TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) {}

TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) {}

TEST_F(ResourceAttributeTest, BindingPointOnNonResource) {}

}  // namespace
}  // namespace ResourceTests

namespace WorkgroupAttributeTests {
namespace {

WorkgroupAttribute;
TEST_F(WorkgroupAttribute, NotAnEntryPoint) {}

TEST_F(WorkgroupAttribute, NotAComputeShader) {}

TEST_F(WorkgroupAttribute, DuplicateAttribute) {}

}  // namespace
}  // namespace WorkgroupAttributeTests

namespace InterpolateTests {
namespace {

InterpolateTest;

struct Params {};

struct TestWithParams : ResolverTestWithParam<Params> {};

InterpolateParameterTest;
TEST_P(InterpolateParameterTest, All) {}

TEST_P(InterpolateParameterTest, IntegerScalar) {}

TEST_P(InterpolateParameterTest, IntegerVector) {}

INSTANTIATE_TEST_SUITE_P();

TEST_F(InterpolateTest, FragmentInput_Integer_MissingFlatInterpolation) {}

TEST_F(InterpolateTest, VertexOutput_Integer_MissingFlatInterpolation) {}

GroupAndBindingTest;

TEST_F(GroupAndBindingTest, Const_I32) {}

TEST_F(GroupAndBindingTest, Const_U32) {}

TEST_F(GroupAndBindingTest, Const_AInt) {}

TEST_F(GroupAndBindingTest, Binding_NonConstant) {}

TEST_F(GroupAndBindingTest, Binding_Negative) {}

TEST_F(GroupAndBindingTest, Binding_F32) {}

TEST_F(GroupAndBindingTest, Binding_AFloat) {}

TEST_F(GroupAndBindingTest, Group_NonConstant) {}

TEST_F(GroupAndBindingTest, Group_Negative) {}

TEST_F(GroupAndBindingTest, Group_F32) {}

TEST_F(GroupAndBindingTest, Group_AFloat) {}

IdTest;

TEST_F(IdTest, Const_I32) {}

TEST_F(IdTest, Const_U32) {}

TEST_F(IdTest, Const_AInt) {}

TEST_F(IdTest, NonConstant) {}

TEST_F(IdTest, Negative) {}

TEST_F(IdTest, F32) {}

TEST_F(IdTest, AFloat) {}

enum class LocationAttributeType {};

struct LocationTest : ResolverTestWithParam<LocationAttributeType> {};

TEST_P(LocationTest, Const_I32) {}

TEST_P(LocationTest, Const_U32) {}

TEST_P(LocationTest, Const_AInt) {}

TEST_P(LocationTest, NonConstant) {}

TEST_P(LocationTest, Negative) {}

TEST_P(LocationTest, F32) {}

TEST_P(LocationTest, AFloat) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace
}  // namespace InterpolateTests

namespace InternalAttributeDeps {
namespace {

class TestAttribute : public Castable<TestAttribute, ast::InternalAttribute> {};

InternalAttributeDepsTest;
TEST_F(InternalAttributeDepsTest, Dependency) {}

}  // namespace
}  // namespace InternalAttributeDeps

}  // namespace tint::resolver

TINT_INSTANTIATE_TYPEINFO();