[tint] Move potential type creation out of ValidateReturn.
This CL moves the possible call to create the return type out of the ValidateReturn and into the call. The type is then passed into the ValidateReturn method. Bug: tint:1313 Change-Id: I5d2e78b945fc47a14072f503d0478a7da051137d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87146 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
5d4cac1da1
commit
d431eb9d94
|
@ -2507,7 +2507,9 @@ sem::Statement* Resolver::ReturnStatement(const ast::ReturnStatement* stmt) {
|
||||||
|
|
||||||
// Validate after processing the return value expression so that its type
|
// Validate after processing the return value expression so that its type
|
||||||
// is available for validation.
|
// is available for validation.
|
||||||
return ValidateReturn(stmt, current_function_->ReturnType());
|
auto* ret_type = stmt->value ? TypeOf(stmt->value)->UnwrapRef()
|
||||||
|
: builder_->create<sem::Void>();
|
||||||
|
return ValidateReturn(stmt, current_function_->ReturnType(), ret_type);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -281,7 +281,8 @@ class Resolver {
|
||||||
const sem::Variable* var);
|
const sem::Variable* var);
|
||||||
bool ValidateParameter(const ast::Function* func, const sem::Variable* var);
|
bool ValidateParameter(const ast::Function* func, const sem::Variable* var);
|
||||||
bool ValidateReturn(const ast::ReturnStatement* ret,
|
bool ValidateReturn(const ast::ReturnStatement* ret,
|
||||||
const sem::Type* func_type);
|
const sem::Type* func_type,
|
||||||
|
const sem::Type* ret_type);
|
||||||
bool ValidateStatements(const ast::StatementList& stmts);
|
bool ValidateStatements(const ast::StatementList& stmts);
|
||||||
bool ValidateStorageTexture(const ast::StorageTexture* t);
|
bool ValidateStorageTexture(const ast::StorageTexture* t);
|
||||||
bool ValidateStructure(const sem::Struct* str, ast::PipelineStage stage);
|
bool ValidateStructure(const sem::Struct* str, ast::PipelineStage stage);
|
||||||
|
|
|
@ -2182,10 +2182,8 @@ bool Resolver::ValidateLocationAttribute(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Resolver::ValidateReturn(const ast::ReturnStatement* ret,
|
bool Resolver::ValidateReturn(const ast::ReturnStatement* ret,
|
||||||
const sem::Type* func_type) {
|
const sem::Type* func_type,
|
||||||
auto* ret_type = ret->value ? TypeOf(ret->value)->UnwrapRef()
|
const sem::Type* ret_type) {
|
||||||
: builder_->create<sem::Void>();
|
|
||||||
|
|
||||||
if (func_type->UnwrapRef() != ret_type) {
|
if (func_type->UnwrapRef() != ret_type) {
|
||||||
AddError(
|
AddError(
|
||||||
"return statement type must match its function "
|
"return statement type must match its function "
|
||||||
|
|
Loading…
Reference in New Issue