On Mon, Nov 22, 2021 at 03:49:42PM +0100, Thomas Schwinge wrote:
> Then, regarding the user-visible behavior:
> 
> > +#pragma acc routine  /* { dg-error "not immediately followed by a single 
> > function declaration or definition" "" { target c++ } } */
> > +int foo (int bar ());
> 
> So in C++ we now refuse, but in C we do accept this.  I suppose I shall
> look into making C behave the same way -- unless there is a reason for
> the different behavior?  And/or, is it actually is useful to allow such
> nested usage?  Per its associated clauses, an OpenACC 'routine' directive
> really is meant to apply to one function only, in contrast to OpenMP
> 'target declare'.  But the question is whether we should raise an error
> for the example above, or whether the 'routine' shall just apply to 'foo'
> but not 'bar', but without an error diagnostic?

All I've verified is that our OpenMP code handles it the same way,
i.e.
#pragma omp declare simd
int foo (int bar ());
is accepted in C and rejected in C++.
I guess one question is to check if it is in both languages actually
the same thing.  If we want to accept it in C++ and let the pragma
apply only to the outer declaration, I guess we'd need to temporarily
set to NULL parser->omp_declare_simd and parser->oacc_routine while
parsing the parameters of a function declaration or definition.
At least OpenMP is fairly fuzzy here, the reason we error on
#pragma omp declare simd
int foo (), i;
has been mainly some discussions in the lang committee and the fact
that it talks about a single declaration, not all affected declarations.
Whether int foo (int bar ()); should be in that light treated as two
function declarations or one with another one nested in it and irrelevant
for it is unclear.

        Jakub

Reply via email to