On 02 Feb 13:05, Jakub Jelinek wrote: > On Tue, Jul 29, 2014 at 06:45:01PM +0400, Ilya Tocar wrote: > > Hi, > > > > As discussed here in https://gcc.gnu.org/ml/gcc/2014-01/msg00189.html > > Gcc should complain about pragma omp declare target without > > corresponding pragma omp end declare target. This patch adds a warning > > for those cases. > > Bootstraps/passes make-check. > > Ok for trunk? > > > > ChangeLog: > > > > 2014-07-29 Ilya Tocar <ilya.to...@intel.com> > > > > * c-decl.c (omp_declare_target_location_stack): New. > > * c-lang.h (omp_declare_target_location_stack): Declare. > > * c-parser.c (warn_unclosed_pragma_omp_target): New. > > (c_parser_translation_unit): Call it. > > (c_parser_omp_declare_target): Remeber location. > > (c_parser_omp_end_declare_target): Forget location. > > Sorry for the long delay on this. > Can you check what will happen if you have unclosed #pragma omp declare target > in some header you precompile? If you get the warning during the header > compilation and then not during compilation using that PCH header, > supposedly it might be fine and the patch might be ok as is. > I've completely forgot about PCH. With them this patch fails with segfault. Moreover even if I fix segfault, we will produce strange results for something like: #include "a.h" #pragma omp end declare target // some code > > If we wanted to warn even on a.c, supposedly the vector would need to be > marked for GC. > I've tried:
static GTY(()) vec<int,va_gc_atomic> *omp_declare_target_location_stack; However it fails with: vec.h:1118: undefined reference to `gt_pch_nx(int&)' But in ggc.h (included in c-parser.c) i see gt_pch_nx (unsigned int) { } So I'm not sure how to properly mark vector for PCH.