Hello

New OpenMP 5.0 features that won't be available in GCC 9, are planned for GCC 10
or later versions as time permits:

...
- nested declare target support

You said in an email two years ago that nested declare target was not supported yet. I do not see any patches that claim to implement this since then, but when I ran a quick test with a trunk build:

#pragma omp declare target
  #pragma omp declare target
    int foo() { return 1; }
  #pragma omp end declare target
  int bar() { return 2; }
#pragma omp end declare target

This compiles and appears to do the right thing:

__attribute__((omp declare target, omp declare target block))
foo ()
...

__attribute__((omp declare target, omp declare target block))
bar ()
...

Looking at the C parser:

static void
c_parser_omp_declare_target (c_parser *parser)
{
  ...
  else
    {
      c_parser_skip_to_pragma_eol (parser);
      current_omp_declare_target_attribute++;
      return;
    }

static void
c_parser_omp_end_declare_target (c_parser *parser)
{
  ...
    current_omp_declare_target_attribute--;
}

It looks like this was written to handle nesting to begin with (since at least 2013) by making current_omp_declare_target_attribute (which effectively tracks the nesting level) an integer. Is there anything that is currently missing for nested declare target support?

Thanks

Kwok

Reply via email to