// SPIR-V spec: "Storage Class is the Storage Class of the memory holding the
// object. It cannot be Generic. It must be the same as the Storage Class
// operand of the Result Type."
- if (varOp.storageClass() == spirv::StorageClass::Generic)
- return varOp.emitOpError("storage class cannot be 'Generic'");
+ // Also, Function storage class is reserved by spv.Variable.
+ auto storageClass = varOp.storageClass();
+ if (storageClass == spirv::StorageClass::Generic ||
+ storageClass == spirv::StorageClass::Function) {
+ return varOp.emitOpError("storage class cannot be '")
+ << stringifyStorageClass(storageClass) << "'";
+ }
if (auto init =
varOp.getAttrOfType<FlatSymbolRefAttr>(kInitializerAttrName)) {
// -----
spv.module Logical GLSL450 {
+ // expected-error @+1 {{storage class cannot be 'Function'}}
+ spv.globalVariable @var0 : !spv.ptr<f32, Function>
+}
+
+// -----
+
+spv.module Logical GLSL450 {
spv.func @foo() "None" {
// expected-error @+1 {{op must appear in a module-like op's block}}
spv.globalVariable @var0 : !spv.ptr<f32, Input>