tint: Prevent Expr() implicit conversion to bool

Enfore that the Expr(bool) overloads are only used if the argument type
is explicitly a bool.

Fix a test bug where this was happening.

Change-Id: I5d7520be4859a700265d62b322416a90f278b2d3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89400
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2022-05-10 15:29:14 +00:00 committed by Dawn LUCI CQ
parent 41285aa578
commit 17fa42d527
2 changed files with 8 additions and 3 deletions

View File

@ -974,13 +974,18 @@ class ProgramBuilder {
/// @param source the source information
/// @param value the boolean value
/// @return a Scalar constructor for the given value
const ast::BoolLiteralExpression* Expr(const Source& source, bool value) {
template <typename BOOL>
std::enable_if_t<std::is_same_v<BOOL, bool>, const ast::BoolLiteralExpression*> Expr(
const Source& source,
BOOL value) {
return create<ast::BoolLiteralExpression>(source, value);
}
/// @param value the boolean value
/// @return a Scalar constructor for the given value
const ast::BoolLiteralExpression* Expr(bool value) {
template <typename BOOL>
std::enable_if_t<std::is_same_v<BOOL, bool>, const ast::BoolLiteralExpression*> Expr(
BOOL value) {
return create<ast::BoolLiteralExpression>(value);
}

View File

@ -139,7 +139,7 @@ TEST_F(ResolverCallValidationTest, PointerArgument_AddressOfMemberAccessor) {
Func("main", {}, ty.void_(),
{
Decl(Let("v", ty.Of(S), Construct(ty.Of(S)))),
CallStmt(Call("foo", AddressOf(Expr(Source{{12, 34}}, MemberAccessor("v", "m"))))),
CallStmt(Call("foo", AddressOf(MemberAccessor(Source{{12, 34}}, "v", "m")))),
});
EXPECT_FALSE(r()->Resolve());