@@ -275,23 +275,20 @@ CIRGenModule::getOrCreateStaticVarDecl(const VarDecl &d,
275275 assert (ty->isConstantSizeType () && " VLAs can't be static" );
276276
277277 // Use the label if the variable is renamed with the asm-label extension.
278- std::string name;
279278 if (d.hasAttr <AsmLabelAttr>())
280279 errorNYI (d.getSourceRange (), " getOrCreateStaticVarDecl: asm label" );
281- else
282- name = getStaticDeclName (*this , d);
280+
281+ std::string name = getStaticDeclName (*this , d);
283282
284283 mlir::Type lty = getTypes ().convertTypeForMem (ty);
285284 assert (!cir::MissingFeatures::addressSpace ());
286285
287- // OpenCL variables in local address space and CUDA shared
288- // variables cannot have an initializer.
289- mlir::Attribute init = nullptr ;
290- if (d.hasAttr <LoaderUninitializedAttr>())
286+ if (d.hasAttr <LoaderUninitializedAttr>() || d.hasAttr <CUDASharedAttr>())
291287 errorNYI (d.getSourceRange (),
292288 " getOrCreateStaticVarDecl: LoaderUninitializedAttr" );
289+ assert (!cir::MissingFeatures::addressSpace ());
293290
294- init = builder.getZeroInitAttr (convertType (ty));
291+ mlir::Attribute init = builder.getZeroInitAttr (convertType (ty));
295292
296293 cir::GlobalOp gv = builder.createVersionedGlobal (
297294 getModule (), getLoc (d.getLocation ()), name, lty, linkage);
@@ -443,26 +440,10 @@ void CIRGenFunction::emitStaticVarDecl(const VarDecl &d,
443440
444441 var.setAlignment (alignment.getAsAlign ().value ());
445442
446- if (d.hasAttr <AnnotateAttr>())
447- cgm.errorNYI (d.getSourceRange (), " static var annotation" );
448-
449- if (d.getAttr <PragmaClangBSSSectionAttr>())
450- cgm.errorNYI (d.getSourceRange (), " static var BSS section attribute" );
451- if (d.getAttr <PragmaClangDataSectionAttr>())
452- cgm.errorNYI (d.getSourceRange (), " static var Data section attribute" );
453- if (d.getAttr <PragmaClangRodataSectionAttr>())
454- cgm.errorNYI (d.getSourceRange (), " static var Rodata section attribute" );
455- if (d.getAttr <PragmaClangRelroSectionAttr>())
456- cgm.errorNYI (d.getSourceRange (), " static var Relro section attribute" );
457-
458- if (d.getAttr <SectionAttr>())
459- cgm.errorNYI (d.getSourceRange (),
460- " static var object file section attribute" );
461-
462- if (d.hasAttr <RetainAttr>())
463- cgm.errorNYI (d.getSourceRange (), " static var retain attribute" );
464- else if (d.hasAttr <UsedAttr>())
465- cgm.errorNYI (d.getSourceRange (), " static var used attribute" );
443+ // There are a lot of attributes that need to be handled here. Until
444+ // we start to support them, we just report an error if there are any.
445+ if (d.hasAttrs ())
446+ cgm.errorNYI (d.getSourceRange (), " static var with attrs" );
466447
467448 if (cgm.getCodeGenOpts ().KeepPersistentStorageVariables )
468449 cgm.errorNYI (d.getSourceRange (), " static var keep persistent storage" );
0 commit comments