On Tue, Apr 22, 2025 at 07:21:14PM +0200, Tobias Burnus wrote: > I currently do not see whether the code is needed in this case or not, but I > assume it is, if we want to support static initializers?!? > > In any case, it seems as if the condition 'if (flag_openmp)' additionally > requires '&& lookup_attribute ("omp declare target", DECL_ATTRIBUTES > (decl))'.
Depends on when exactly it is done, there is the implicit declare target discovery during gimplification, e.g. the var itself might not be initially omp declare target but have its address used in some omp declare target static var initializer or pragma omp declare target could appear as the last one in the TU. If it is always done after the whole TU was parsed and went through this implicit declare target discovery, then I agree we could use lookup_attribute, otherwise we can't. Jakub