On Fri, Jul 08, 2016 at 09:58:57AM -0700, Cesar Philippidis wrote:
> >> +#define matcha(keyword, subr, st)                         \
> >> +    do {                                                  \
> >> +      if (spec_only && gfc_match (keyword) == MATCH_YES)  \
> >> +  goto do_spec_only;                                      \
> >> +      else if (match_word (keyword, subr, &old_locus)             \
> >> +         == MATCH_YES)                                    \
> >> +  return st;                                              \
> >> +      else                                                        \
> >> +  undo_new_statement ();                                  \
> >> +    } while (0);
> >> +
> >>  static gfc_statement
> >>  decode_oacc_directive (void)
> >>  {
> >>    locus old_locus;
> >>    char c;
> >> +  bool spec_only = false;
> >>  
> >>    gfc_enforce_clean_symbol_state ();
> >>  
> >> @@ -608,6 +622,10 @@ decode_oacc_directive (void)
> >>        return ST_NONE;
> >>      }
> >>  
> >> +  if (gfc_current_state () == COMP_FUNCTION
> >> +      && gfc_current_block ()->result->ts.kind == -1)
> >> +    spec_only = true;
> >> +
> >>    gfc_unset_implicit_pure (NULL);
> >>  
> >>    old_locus = gfc_current_locus;
> >> @@ -627,7 +645,7 @@ decode_oacc_directive (void)
> >>        match ("cache", gfc_match_oacc_cache, ST_OACC_CACHE);
> > 
> > Why isn't ST_OACC_ATOMIC matcha?
> > At least from the case_executable/case_exec_markers vs.
> > case_decl defines, all directives but "routine" and "declare" should
> > be matcha IMHO.
> 
> Because the atomic directive must operate on a sequence of instructions,
> otherwise it should generate a syntax error.

But you are then relying on a nested decode_statement to do something, it
works, but IMHO just rejecting them earlier is much cleaner and more
maintainable, with the simple rule that even can be documented that
declaration directives use match, all others use matcha (similarly how in
decode_omp_directive directives use the matchd[os] while executable directives
use match[os]).
What do you see as advantage of only marking some of the executable
directives?

> > Also, can you figure out in the OpenACC standard and/or discuss on lang
> > committee whether acc declare and/or acc routine can appear anywhere in the
> > specification part, or need to be ordered certain way?
> > If like in OpenMP they can appear anywhere, then
> > case ST_OACC_ROUTINE: case ST_OACC_DECLARE
> > should move from case_decl to case_omp_decl macro.
> 
> OK, I'll check with them. Can that be a follow up patch, or would you
> like to see it resolved in one patch?

Sure, that can be done incrementally.

        Jakub

Reply via email to