[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 18 14:41:00 PDT 2020


rjmccall added a comment.

This looks good, assuming there's either no issue with the lazy emission of variables or that you just intend to tackle that later.



================
Comment at: clang/lib/Sema/Sema.cpp:1540
+    } else if (auto *VD = dyn_cast<VarDecl>(D)) {
+      if (auto *Init = VD->getInit()) {
+        auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
----------------
yaxunl wrote:
> rjmccall wrote:
> > yaxunl wrote:
> > > rjmccall wrote:
> > > > Can there also be deferred diagnostics associated with this initializer?
> > > Yes. A global variable may be marked by omp declare target directive to be emitted on device. If the global var is initialized with the address of a function, the function will be emitted on device. If the device function calls a host device function which contains a deferred diag, that diag will be emitted. This can only be known after everything is parsed.
> > I meant directly with the initializer.  Is there a way today to defer a diagnostic that you would emit while processing an initializer expression?  If so, this needs to trigger that.
> I don't think the initializer itself (without a target declare directive) will cause a deferred diagnostic since it does not cause change of emission states of functions. 
Okay, so if I'm getting this right: only functions are emitted lazily, and variables have to be marked specially in order to get emitted on the device, so there's no need to defer diagnostics within variable initializations because we always know at the time of processing the variable where it will be emitted?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70172/new/

https://reviews.llvm.org/D70172





More information about the cfe-commits mailing list