[SPIR-V] Allow `using` and `using namespace` declarations (#6229)

Fixes #5938
This commit is contained in:
Cassandra Beckley 2024-01-31 06:51:21 -08:00 коммит произвёл GitHub
Родитель 2fae54abe6
Коммит ad4dc46888
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -1025,6 +1025,10 @@ void SpirvEmitter::doDecl(const Decl *decl) {
doClassTemplateDecl(classTemplateDecl);
} else if (isa<FunctionTemplateDecl>(decl)) {
// nothing to do.
} else if (isa<UsingDecl>(decl)) {
// nothing to do.
} else if (isa<UsingDirectiveDecl>(decl)) {
// nothing to do.
} else {
emitError("decl type %0 unimplemented", decl->getLocation())
<< decl->getDeclKindName();

Просмотреть файл

@ -0,0 +1,23 @@
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s
namespace n {
using f = float;
namespace n2 {
f foo(f a) { return sin(a); }
}
}
using namespace n;
using f32 = n::f;
using n2::foo;
// CHECK: %src_main = OpFunction %float
// CHECK-NEXT: %a = OpFunctionParameter %_ptr_Function_float
f32 main(f32 a:A) : SV_Target {
// CHECK: OpFunctionCall %float %n__n2__foo %param_var_a_0
return foo(a);
}