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

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 17 10:31:11 PST 2020


yaxunl marked an inline comment as done.
yaxunl added inline comments.


================
Comment at: clang/lib/Sema/Sema.cpp:1468
   }
-  S.DeviceDeferredDiags.erase(It);
 
----------------
Fznamznon wrote:
> This particular change causes duplication of deferred diagnostics.
> Consider the following example (please correct me if I'm doing something wrong, I'm not an expert in OpenMP):
> 
> ```
> int foobar1() { throw 1; } // error is expected here
> 
> // let's try to use foobar1 in the code where exceptions aren't allowed
> #pragma omp declare target    
> int (*B)() = &foobar1;        
> #pragma omp end declare target
> 
> // and in some other place let's use foobar1 in device code again
> #pragma omp declare target    
> int a = foobar1();            
> #pragma omp end declare target
> 
> ```
> Then diagnostic for `foobar1`  will be duplicated for each use of `foobar1` under `target` directive.
> I first experienced this behavior not with OpenMP, so I suppose reproducer can be done for each programming model which uses deferred diagnostics.
The change is intentional so that each call chain causing the diagnostic can be identified. The drawback is that it is more verbose.

I can change this behavior so that the diagnostic will be emitted only for the first call chain that causes the diagnostic, if less verbose diagnostics is preferred.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172





More information about the cfe-commits mailing list