aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/parse.c
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2019-10-02 10:50:23 +0000
committerTobias Burnus <burnus@gcc.gnu.org>2019-10-02 12:50:23 +0200
commitba045eb2297e8e51c7e99c2b2650f32cb642d209 (patch)
treed7f0ed7450b0af3f1045c81b3a743f450109c511 /gcc/fortran/parse.c
parent4aef466788a964688458f4e633398b140ad89e24 (diff)
downloadgcc-ba045eb2297e8e51c7e99c2b2650f32cb642d209.zip
gcc-ba045eb2297e8e51c7e99c2b2650f32cb642d209.tar.gz
gcc-ba045eb2297e8e51c7e99c2b2650f32cb642d209.tar.bz2
Improve OMP/ACC error diagnostic in Fortran
gcc/fortran/ * openmp.c (gfc_match_omp_clauses): Show a clause-parsing error if none was rised before. * parse.c (matcha, matcho): If error occurred after OpenMP/OpenACC directive matched, do not try other directives. gcc/testsuite/ * gfortran.dg/goacc/asyncwait-1.f95: Handle new error message. * gfortran.dg/goacc/asyncwait-2.f95: Likewise * gfortran.dg/goacc/asyncwait-3.f95: Likewise * gfortran.dg/goacc/asyncwait-4.f95: Likewise * gfortran.dg/goacc/default-2.f: Likewise * gfortran.dg/goacc/enter-exit-data.f95: Likewise * gfortran.dg/goacc/if.f95: Likewise * gfortran.dg/goacc/list.f95: Likewise * gfortran.dg/goacc/literal.f95: Likewise * gfortran.dg/goacc/loop-2-kernels-tile.f: Likewise95 * gfortran.dg/goacc/loop-2-parallel-tile.f95: Likewise * gfortran.dg/goacc/loop-7.f95: Likewise * gfortran.dg/goacc/parallel-kernels-cla: Likewiseuses.f95 * gfortran.dg/goacc/routine-6.f90: Likewise * gfortran.dg/goacc/several-directives.f95: Likewise * gfortran.dg/goacc/sie.f95: Likewise * gfortran.dg/goacc/tile-1.f90: Likewise * gfortran.dg/goacc/update-if_present-2.: Likewisef90 * gfortran.dg/gomp/declare-simd-1.f90: Likewise * gfortran.dg/gomp/pr29759.f90: Likewise From-SVN: r276447
Diffstat (limited to 'gcc/fortran/parse.c')
-rw-r--r--gcc/fortran/parse.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 5bd04b8..4d34345 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -609,13 +609,18 @@ decode_statement (void)
/* Like match 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 matcha(keyword, subr, st) \
do { \
+ match m2; \
if (spec_only && gfc_match (keyword) == MATCH_YES) \
goto do_spec_only; \
- else if (match_word (keyword, subr, &old_locus) \
+ else if ((m2 = match_word (keyword, subr, &old_locus)) \
== MATCH_YES) \
return st; \
+ else if (m2 == MATCH_ERROR) \
+ goto error_handling; \
else \
undo_new_statement (); \
} while (0)
@@ -711,6 +716,7 @@ decode_oacc_directive (void)
/* Directive not found or stored an error message.
Check and give up. */
+ error_handling:
if (gfc_error_check () == 0)
gfc_error_now ("Unclassifiable OpenACC directive at %C");
@@ -746,18 +752,23 @@ decode_oacc_directive (void)
/* 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 (match_word (keyword, subr, &old_locus) \
+ 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)
@@ -1030,6 +1041,7 @@ decode_omp_directive (void)
not -fopenmp and simd_matched is false, i.e. if a directive other
than one marked with match has been seen. */
+ error_handling:
if (flag_openmp || simd_matched)
{
if (!gfc_error_check ())