Fortran: Cleanup OpenMP match{o,s,do,ds} macros Create match_internal as universal macro and use it to define match{o,s,do,ds} gcc/fortran/ChangeLog: * parse.cc (match_internal): New macro. (matcho, matchs, matchds, matchdo): Use it. diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index 7356d1b5a3a..ebe27a7569f 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -745,81 +745,58 @@ decode_oacc_directive (void) return ST_GET_FCN_CHARACTERISTICS; } -/* Like match, but set a flag simd_matched if keyword matched - and if spec_only, goto do_spec_only without actually matching. */ -#define matchs(keyword, subr, st) \ - do { \ - match m2; \ - if (spec_only && gfc_match (keyword) == MATCH_YES) \ - goto do_spec_only; \ - if ((m2 = match_word_omp_simd (keyword, subr, &old_locus, \ - &simd_matched)) == MATCH_YES) \ - { \ - ret = st; \ - goto finish; \ - } \ - else if (m2 == MATCH_ERROR) \ - goto error_handling; \ - else \ - undo_new_statement (); \ +/* Like match, but with some special handling: + - dosimd - if false, don't do anything if not -fopenmp, + otherwise do match_word_omp_simd matching + - if dospec_only: if spec_only, goto do_spec_only after matching. + + If the directive matched but the clauses failed, do not start + matching the next directive in the same switch statement. */ + +#define match_internal(match_simd, match_spec_only, keyword, subr, st) \ + do { \ + match m2; \ + if (!match_simd && !flag_openmp) \ + ; \ + else if (match_spec_only \ + && spec_only \ + && gfc_match (keyword) == MATCH_YES) \ + goto do_spec_only; \ + else if (!match_simd \ + && ((m2 = match_word (keyword, subr, &old_locus)) \ + == MATCH_YES)) \ + { \ + ret = st; \ + goto finish; \ + } \ + else if (match_simd \ + && (m2 = match_word_omp_simd (keyword, subr, &old_locus, \ + &simd_matched)) == MATCH_YES) \ + { \ + ret = st; \ + goto finish; \ + } \ + else if (m2 == MATCH_ERROR) \ + goto error_handling; \ + else \ + undo_new_statement (); \ } while (0) -/* Like match, but don't match anything if not -fopenmp - and if spec_only, goto do_spec_only without actually matching. */ -/* If the directive matched but the clauses failed, do not start - matching the next directive in the same switch statement. */ -#define matcho(keyword, subr, st) \ - do { \ - match m2; \ - if (!flag_openmp) \ - ; \ - else if (spec_only && gfc_match (keyword) == MATCH_YES) \ - goto do_spec_only; \ - else if ((m2 = match_word (keyword, subr, &old_locus)) \ - == MATCH_YES) \ - { \ - ret = st; \ - goto finish; \ - } \ - else if (m2 == MATCH_ERROR) \ - goto error_handling; \ - else \ - undo_new_statement (); \ - } while (0) +/* Like match. Does simd matching; sets flag simd_matched if keyword matched. */ +#define matchds(keyword, subr, st) \ + match_internal(true, false, keyword, subr, st) -/* Like match, but set a flag simd_matched if keyword matched. */ -#define matchds(keyword, subr, st) \ - do { \ - match m2; \ - if ((m2 = match_word_omp_simd (keyword, subr, &old_locus, \ - &simd_matched)) == MATCH_YES) \ - { \ - ret = st; \ - goto finish; \ - } \ - else if (m2 == MATCH_ERROR) \ - goto error_handling; \ - else \ - undo_new_statement (); \ - } while (0) +/* Like matchds, but also honors spec_only. */ +#define matchs(keyword, subr, st) \ + match_internal(true, true, keyword, subr, st) /* Like match, but don't match anything if not -fopenmp. */ -#define matchdo(keyword, subr, st) \ - do { \ - match m2; \ - if (!flag_openmp) \ - ; \ - else if ((m2 = match_word (keyword, subr, &old_locus)) \ - == MATCH_YES) \ - { \ - ret = st; \ - goto finish; \ - } \ - else if (m2 == MATCH_ERROR) \ - goto error_handling; \ - else \ - undo_new_statement (); \ - } while (0) +#define matchdo(keyword, subr, st) \ + match_internal(false, false, keyword, subr, st) + +/* Like matchdo, but also honors spec_only. */ +#define matcho(keyword, subr, st) \ + match_internal(false, true, keyword, subr, st) static gfc_statement decode_omp_directive (void)