tint: improve error message about function paramter limit
Bug: tint:1209 Change-Id: I0d3b188069e91488a482f529c962bfa054ad6d36 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121740 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
6b304e9ffd
commit
1bb5be9789
|
@ -979,7 +979,7 @@ TEST_F(ResolverFunctionValidationTest, ParameterStoreType_NonAtomicFree) {
|
|||
EXPECT_EQ(r()->error(), "12:34 error: type of function parameter must be constructible");
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, ParameterSotreType_AtomicFree) {
|
||||
TEST_F(ResolverFunctionValidationTest, ParameterStoreType_AtomicFree) {
|
||||
Structure("S", utils::Vector{
|
||||
Member("m", ty.i32()),
|
||||
});
|
||||
|
@ -1008,7 +1008,7 @@ TEST_F(ResolverFunctionValidationTest, ParametersOverLimit) {
|
|||
Func(Source{{12, 34}}, "f", params, ty.void_(), utils::Empty);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: functions may declare at most 255 parameters");
|
||||
EXPECT_EQ(r()->error(), "12:34 error: function declares 256 parameters, maximum is 255");
|
||||
}
|
||||
|
||||
TEST_F(ResolverFunctionValidationTest, ParameterVectorNoType) {
|
||||
|
|
|
@ -76,6 +76,8 @@
|
|||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
constexpr size_t kMaxFunctionParameters = 255;
|
||||
|
||||
bool IsValidStorageTextureDimension(type::TextureDimension dim) {
|
||||
switch (dim) {
|
||||
case type::TextureDimension::k1d:
|
||||
|
@ -1046,8 +1048,10 @@ bool Validator::Function(const sem::Function* func, ast::PipelineStage stage) co
|
|||
}
|
||||
}
|
||||
|
||||
if (decl->params.Length() > 255) {
|
||||
AddError("functions may declare at most 255 parameters", decl->source);
|
||||
if (decl->params.Length() > kMaxFunctionParameters) {
|
||||
AddError("function declares " + std::to_string(decl->params.Length()) +
|
||||
" parameters, maximum is " + std::to_string(kMaxFunctionParameters),
|
||||
decl->source);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue