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 mean something like a.h: #pragma omp declare target int i; a.c: #include "a.c" #pragma omp declare target int j; #pragma omp declare target int k; int main () { } gcc -fopenmp -o a.gch a.h gcc -fopenmp -o a a.c If we wanted to warn even on a.c, supposedly the vector would need to be marked for GC. Jakub