[clang] [OpenMP] Parse and Sema support for declare target in local scope (PR #83223)

Sandeep Kosuri via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 28 20:03:14 PST 2024


================
@@ -23352,6 +23352,15 @@ void Sema::ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc,
           isa<FunctionTemplateDecl>(ND)) &&
          "Expected variable, function or function template.");
 
+  if (auto *VD = dyn_cast<VarDecl>(ND)) {
----------------
sandeepkosuri wrote:

previously `ActOnOpenMPDeclareTargetName` was called for variables of file scope, I guess that's why there was no check to guard against local variables at this point. `checkDeclIsAllowedInOpenMPTarget` is called after giving the `OMPDeclareTargetDeclAttr` to the variable, so it does not filter out local vars from getting that attribute.

https://github.com/llvm/llvm-project/pull/83223


More information about the cfe-commits mailing list