On Wed, Nov 14, 2018 at 12:35:27PM +0100, Jakub Jelinek wrote:
> > +
> > +   When we come here, we have already matched the !GCC$ builtin string.  */
> > +match
> > +gfc_match_gcc_builtin (void)
> > +{
> > +  char builtin[GFC_MAX_SYMBOL_LEN + 1];
> > +
> > +  if (gfc_match_name (builtin) != MATCH_YES)
> > +    return MATCH_ERROR;
> > +
> > +  gfc_gobble_whitespace ();
> > +  if (gfc_match ("attributes") != MATCH_YES)
> > +    return MATCH_ERROR;
> > +
> > +  gfc_gobble_whitespace ();
> > +  if (gfc_match ("omp_simd_notinbranch") != MATCH_YES)
> > +    return MATCH_ERROR;
> 
> Why so many gfc_match calls?  Can't you e.g. just do
>   if (gfc_match ("%n attributes simd", builtin) != MATCH_YES)
>     return MATCH_ERROR;
> 
>   int builtin_kind = 0; /* Or whatever, just want to show the parsing here.  
> */
>   if (gfc_match ("(notinbranch)") == MATCH_YES)
>     builtin_kind = -1;
>   else if (gfc_match ("(inbranch)") == MATCH_YES)
>     builtin_kind = 1;
> 
> The space in gfc_match indicates gfc_gobble_whitespace (), i.e. optionally
> eating whitespace (note, in fixed form white space is optionally eaten
> pretty much always).  If you want a mandatory space, there is "% ".
> So it depends in if in fixed form we want to support e.g.
> !GCC$ BUI L    TIN SINf ATTRI BUT ESSIMD(NOT IN BRANCH)
> and in free form e.g.
> !gcc$ builtin sinf attributessimd (notinbranch)
> I wouldn't use omp_simd because in C/C++ the attribute is called simd.

One more thing, for fixed form spaces are insignificant generally,
gfc_next_char has:
  do
    {
      c = gfc_next_char_literal (NONSTRING);
    }
  while (gfc_current_form == FORM_FIXED && gfc_is_whitespace (c));
so a gfc_name in fixed form needs to be separated by something different
from whitespace I'd say.  Because in
!gcc$ builtin sinf attribute simd
or
!GCC$ BUILTINSINFATTRIBUTESIMD
you'd get in both cases sinfattributesimd as the builtin's name and nothing
afterwards (so gfc_match would fail).
One possibility is
  if (gfc_match ("(%n) attributes simd", name) == MATCH_YES)
where you'd require parens around the builtin's name.  Or it could go last
in the syntax, i.e.
!gcc$ builtin attributes simd sinf
!gcc$ builtin attributes simd (notinbranch) sinf
But I think ()s are better.

        Jakub

Reply via email to