Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -2621,9 +2621,12 @@ // Skip internally declared static variables. llvm::Optional Res = OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD); + bool IsUsingUnifiedMemory = + Stack->hasRequiresDeclWithClause(); if (VD->hasGlobalStorage() && CS && !CS->capturesVariable(VD) && - (Stack->hasRequiresDeclWithClause() || - !Res || *Res != OMPDeclareTargetDeclAttr::MT_Link)) + ((!IsUsingUnifiedMemory && + (!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link)) || + (IsUsingUnifiedMemory && !Res))) return; SourceLocation ELoc = E->getExprLoc();