[resolver] Apply type storage class uses via return types
Change-Id: I16cf23af7f6a792d22268e6af45c77d4faeb6918 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46460 Commit-Queue: James Price <jrprice@google.com> Auto-Submit: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
494e82dc8a
commit
5c523f331d
|
@ -321,6 +321,14 @@ bool Resolver::Function(ast::Function* func) {
|
||||||
|
|
||||||
if (auto* str =
|
if (auto* str =
|
||||||
func->return_type()->UnwrapAliasIfNeeded()->As<type::Struct>()) {
|
func->return_type()->UnwrapAliasIfNeeded()->As<type::Struct>()) {
|
||||||
|
if (!ApplyStorageClassUsageToType(ast::StorageClass::kNone, str,
|
||||||
|
func->source())) {
|
||||||
|
diagnostics_.add_note("while instantiating return type for " +
|
||||||
|
builder_->Symbols().NameFor(func->symbol()),
|
||||||
|
func->source());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto* info = Structure(str);
|
auto* info = Structure(str);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -49,6 +49,19 @@ TEST_F(ResolverStorageClassUseTest, StructReachableFromParameter) {
|
||||||
UnorderedElementsAre(ast::StorageClass::kNone));
|
UnorderedElementsAre(ast::StorageClass::kNone));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ResolverStorageClassUseTest, StructReachableFromReturnType) {
|
||||||
|
auto* s = Structure("S", {Member("a", ty.f32())});
|
||||||
|
|
||||||
|
Func("f", {}, s, {Return(Construct(s))}, {});
|
||||||
|
|
||||||
|
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
|
auto* sem = Sem().Get(s);
|
||||||
|
ASSERT_NE(sem, nullptr);
|
||||||
|
EXPECT_THAT(sem->StorageClassUsage(),
|
||||||
|
UnorderedElementsAre(ast::StorageClass::kNone));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ResolverStorageClassUseTest, StructReachableFromGlobal) {
|
TEST_F(ResolverStorageClassUseTest, StructReachableFromGlobal) {
|
||||||
auto* s = Structure("S", {Member("a", ty.f32())});
|
auto* s = Structure("S", {Member("a", ty.f32())});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue