Fix build for tests on gcc-9

```
../src/inspector/inspector_test.cc
[build] ../src/inspector/inspector_test.cc:203:13: error: explicit specialization in non-namespace scope ‘class tint::inspector::{anonymous}::InspectorHelper’
[build]   203 |   template <>
[build]       |             ^
[build] ../src/inspector/inspector_test.cc:205:60: error: template-id ‘MakeLiteral<bool>’ in declaration of primary template
[build]   205 |                                                   bool* val)
```

These `MakeLiteral()` methods can just be standard non-templated overloads - so do that.

Change-Id: I7e0b4ec10636eaf772d1ed4d3e9341c5da4087af
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31120
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2020-10-27 18:47:39 +00:00 committed by Commit Bot service account
parent 70a3f152f2
commit ebe97f3ce1
1 changed files with 7 additions and 21 deletions

View File

@ -184,33 +184,22 @@ class InspectorHelper {
dvar->set_decorations(std::move(decos));
if (val) {
dvar->set_constructor(std::make_unique<ast::ScalarConstructorExpression>(
MakeLiteral<T>(type, val)));
MakeLiteral(type, val)));
}
mod()->AddGlobalVariable(std::move(dvar));
}
/// Generates an ast::Literal for the given value
/// @tparam T C++ type of the literal, must agree with type
/// @returns a Literal of the expected type and value
template <class T>
std::unique_ptr<ast::Literal> MakeLiteral(ast::type::Type*, T*) {
return nullptr;
}
/// @param type AST type of the literal, must resolve to BoolLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
template <>
std::unique_ptr<ast::Literal> MakeLiteral<bool>(ast::type::Type* type,
bool* val) {
std::unique_ptr<ast::Literal> MakeLiteral(ast::type::Type* type, bool* val) {
return std::make_unique<ast::BoolLiteral>(type, *val);
}
/// @param type AST type of the literal, must resolve to UIntLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
template <>
std::unique_ptr<ast::Literal> MakeLiteral<uint32_t>(ast::type::Type* type,
std::unique_ptr<ast::Literal> MakeLiteral(ast::type::Type* type,
uint32_t* val) {
return std::make_unique<ast::UintLiteral>(type, *val);
}
@ -218,8 +207,7 @@ class InspectorHelper {
/// @param type AST type of the literal, must resolve to IntLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
template <>
std::unique_ptr<ast::Literal> MakeLiteral<int32_t>(ast::type::Type* type,
std::unique_ptr<ast::Literal> MakeLiteral(ast::type::Type* type,
int32_t* val) {
return std::make_unique<ast::SintLiteral>(type, *val);
}
@ -227,9 +215,7 @@ class InspectorHelper {
/// @param type AST type of the literal, must resolve to FloattLiteral
/// @param val scalar value for the literal to contain
/// @returns a Literal of the expected type and value
template <>
std::unique_ptr<ast::Literal> MakeLiteral<float>(ast::type::Type* type,
float* val) {
std::unique_ptr<ast::Literal> MakeLiteral(ast::type::Type* type, float* val) {
return std::make_unique<ast::FloatLiteral>(type, *val);
}