Commit 8beaf167 by Tobias Burnus Committed by Tobias Burnus

Fortran - Improve OpenMP/OpenACC diagnostic

	gcc/fortran/
	* match.h (gfc_match_omp_eos_error): Renamed from gfc_match_omp_eos.
	* openmp.c (gfc_match_omp_eos): Make static.
	(gfc_match_omp_eos_error): New.
	* parse.c (matchs, matchdo, matchds): Do as done for 'matcho' -
        if error occurred after OpenMP/OpenACC directive matched, do not
	try other directives.
	(decode_oacc_directive, decode_omp_directive): Call new function
	instead.

	testsuite/
	* gfortran.dg/goacc/continuation-free-form.f95: Update dg-error.

From-SVN: r276694
parent db4fd465
2019-10-08 Tobias Burnus <tobias@codesourcery.com>
* match.h (gfc_match_omp_eos_error): Renamed from gfc_match_omp_eos.
* openmp.c (gfc_match_omp_eos): Make static.
(gfc_match_omp_eos_error): New.
* parse.c (matchs, matchdo, matchds): Do as done for 'matcho' -
if error occurred after OpenMP/OpenACC directive matched, do not
try other directives.
(decode_oacc_directive, decode_omp_directive): Call new function
instead.
2019-10-05 Steven G. Kargl <kargl@gcc.gnu.org> 2019-10-05 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/47045 PR fortran/47045
......
...@@ -151,7 +151,7 @@ match gfc_match_oacc_exit_data (void); ...@@ -151,7 +151,7 @@ match gfc_match_oacc_exit_data (void);
match gfc_match_oacc_routine (void); match gfc_match_oacc_routine (void);
/* OpenMP directive matchers. */ /* OpenMP directive matchers. */
match gfc_match_omp_eos (void); match gfc_match_omp_eos_error (void);
match gfc_match_omp_atomic (void); match gfc_match_omp_atomic (void);
match gfc_match_omp_barrier (void); match gfc_match_omp_barrier (void);
match gfc_match_omp_cancel (void); match gfc_match_omp_cancel (void);
......
...@@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see
/* Match an end of OpenMP directive. End of OpenMP directive is optional /* Match an end of OpenMP directive. End of OpenMP directive is optional
whitespace, followed by '\n' or comment '!'. */ whitespace, followed by '\n' or comment '!'. */
match static match
gfc_match_omp_eos (void) gfc_match_omp_eos (void)
{ {
locus old_loc; locus old_loc;
...@@ -57,6 +57,17 @@ gfc_match_omp_eos (void) ...@@ -57,6 +57,17 @@ gfc_match_omp_eos (void)
return MATCH_NO; return MATCH_NO;
} }
match
gfc_match_omp_eos_error (void)
{
if (gfc_match_omp_eos() == MATCH_YES)
return MATCH_YES;
gfc_error ("Unexpected junk at %C");
return MATCH_ERROR;
}
/* Free an omp_clauses structure. */ /* Free an omp_clauses structure. */
void void
......
...@@ -674,15 +674,15 @@ decode_oacc_directive (void) ...@@ -674,15 +674,15 @@ decode_oacc_directive (void)
match ("declare", gfc_match_oacc_declare, ST_OACC_DECLARE); match ("declare", gfc_match_oacc_declare, ST_OACC_DECLARE);
break; break;
case 'e': case 'e':
matcha ("end atomic", gfc_match_omp_eos, ST_OACC_END_ATOMIC); matcha ("end atomic", gfc_match_omp_eos_error, ST_OACC_END_ATOMIC);
matcha ("end data", gfc_match_omp_eos, ST_OACC_END_DATA); matcha ("end data", gfc_match_omp_eos_error, ST_OACC_END_DATA);
matcha ("end host_data", gfc_match_omp_eos, ST_OACC_END_HOST_DATA); matcha ("end host_data", gfc_match_omp_eos_error, ST_OACC_END_HOST_DATA);
matcha ("end kernels loop", gfc_match_omp_eos, ST_OACC_END_KERNELS_LOOP); matcha ("end kernels loop", gfc_match_omp_eos_error, ST_OACC_END_KERNELS_LOOP);
matcha ("end kernels", gfc_match_omp_eos, ST_OACC_END_KERNELS); matcha ("end kernels", gfc_match_omp_eos_error, ST_OACC_END_KERNELS);
matcha ("end loop", gfc_match_omp_eos, ST_OACC_END_LOOP); matcha ("end loop", gfc_match_omp_eos_error, ST_OACC_END_LOOP);
matcha ("end parallel loop", gfc_match_omp_eos, matcha ("end parallel loop", gfc_match_omp_eos_error,
ST_OACC_END_PARALLEL_LOOP); ST_OACC_END_PARALLEL_LOOP);
matcha ("end parallel", gfc_match_omp_eos, ST_OACC_END_PARALLEL); matcha ("end parallel", gfc_match_omp_eos_error, ST_OACC_END_PARALLEL);
matcha ("enter data", gfc_match_oacc_enter_data, ST_OACC_ENTER_DATA); matcha ("enter data", gfc_match_oacc_enter_data, ST_OACC_ENTER_DATA);
matcha ("exit data", gfc_match_oacc_exit_data, ST_OACC_EXIT_DATA); matcha ("exit data", gfc_match_oacc_exit_data, ST_OACC_EXIT_DATA);
break; break;
...@@ -738,14 +738,17 @@ decode_oacc_directive (void) ...@@ -738,14 +738,17 @@ decode_oacc_directive (void)
and if spec_only, goto do_spec_only without actually matching. */ and if spec_only, goto do_spec_only without actually matching. */
#define matchs(keyword, subr, st) \ #define matchs(keyword, subr, st) \
do { \ do { \
match m2; \
if (spec_only && gfc_match (keyword) == MATCH_YES) \ if (spec_only && gfc_match (keyword) == MATCH_YES) \
goto do_spec_only; \ goto do_spec_only; \
if (match_word_omp_simd (keyword, subr, &old_locus, \ if ((m2 = match_word_omp_simd (keyword, subr, &old_locus, \
&simd_matched) == MATCH_YES) \ &simd_matched)) == MATCH_YES) \
{ \ { \
ret = st; \ ret = st; \
goto finish; \ goto finish; \
} \ } \
else if (m2 == MATCH_ERROR) \
goto error_handling; \
else \ else \
undo_new_statement (); \ undo_new_statement (); \
} while (0) } while (0)
...@@ -776,12 +779,15 @@ decode_oacc_directive (void) ...@@ -776,12 +779,15 @@ decode_oacc_directive (void)
/* Like match, but set a flag simd_matched if keyword matched. */ /* Like match, but set a flag simd_matched if keyword matched. */
#define matchds(keyword, subr, st) \ #define matchds(keyword, subr, st) \
do { \ do { \
if (match_word_omp_simd (keyword, subr, &old_locus, \ match m2; \
&simd_matched) == MATCH_YES) \ if ((m2 = match_word_omp_simd (keyword, subr, &old_locus, \
&simd_matched)) == MATCH_YES) \
{ \ { \
ret = st; \ ret = st; \
goto finish; \ goto finish; \
} \ } \
else if (m2 == MATCH_ERROR) \
goto error_handling; \
else \ else \
undo_new_statement (); \ undo_new_statement (); \
} while (0) } while (0)
...@@ -789,14 +795,17 @@ decode_oacc_directive (void) ...@@ -789,14 +795,17 @@ decode_oacc_directive (void)
/* Like match, but don't match anything if not -fopenmp. */ /* Like match, but don't match anything if not -fopenmp. */
#define matchdo(keyword, subr, st) \ #define matchdo(keyword, subr, st) \
do { \ do { \
match m2; \
if (!flag_openmp) \ if (!flag_openmp) \
; \ ; \
else if (match_word (keyword, subr, &old_locus) \ else if ((m2 = match_word (keyword, subr, &old_locus)) \
== MATCH_YES) \ == MATCH_YES) \
{ \ { \
ret = st; \ ret = st; \
goto finish; \ goto finish; \
} \ } \
else if (m2 == MATCH_ERROR) \
goto error_handling; \
else \ else \
undo_new_statement (); \ undo_new_statement (); \
} while (0) } while (0)
...@@ -889,63 +898,63 @@ decode_omp_directive (void) ...@@ -889,63 +898,63 @@ decode_omp_directive (void)
matcho ("do", gfc_match_omp_do, ST_OMP_DO); matcho ("do", gfc_match_omp_do, ST_OMP_DO);
break; break;
case 'e': case 'e':
matcho ("end atomic", gfc_match_omp_eos, ST_OMP_END_ATOMIC); matcho ("end atomic", gfc_match_omp_eos_error, ST_OMP_END_ATOMIC);
matcho ("end critical", gfc_match_omp_end_critical, ST_OMP_END_CRITICAL); matcho ("end critical", gfc_match_omp_end_critical, ST_OMP_END_CRITICAL);
matchs ("end distribute parallel do simd", gfc_match_omp_eos, matchs ("end distribute parallel do simd", gfc_match_omp_eos_error,
ST_OMP_END_DISTRIBUTE_PARALLEL_DO_SIMD); ST_OMP_END_DISTRIBUTE_PARALLEL_DO_SIMD);
matcho ("end distribute parallel do", gfc_match_omp_eos, matcho ("end distribute parallel do", gfc_match_omp_eos_error,
ST_OMP_END_DISTRIBUTE_PARALLEL_DO); ST_OMP_END_DISTRIBUTE_PARALLEL_DO);
matchs ("end distribute simd", gfc_match_omp_eos, matchs ("end distribute simd", gfc_match_omp_eos_error,
ST_OMP_END_DISTRIBUTE_SIMD); ST_OMP_END_DISTRIBUTE_SIMD);
matcho ("end distribute", gfc_match_omp_eos, ST_OMP_END_DISTRIBUTE); matcho ("end distribute", gfc_match_omp_eos_error, ST_OMP_END_DISTRIBUTE);
matchs ("end do simd", gfc_match_omp_end_nowait, ST_OMP_END_DO_SIMD); matchs ("end do simd", gfc_match_omp_end_nowait, ST_OMP_END_DO_SIMD);
matcho ("end do", gfc_match_omp_end_nowait, ST_OMP_END_DO); matcho ("end do", gfc_match_omp_end_nowait, ST_OMP_END_DO);
matchs ("end simd", gfc_match_omp_eos, ST_OMP_END_SIMD); matchs ("end simd", gfc_match_omp_eos_error, ST_OMP_END_SIMD);
matcho ("end master", gfc_match_omp_eos, ST_OMP_END_MASTER); matcho ("end master", gfc_match_omp_eos_error, ST_OMP_END_MASTER);
matchs ("end ordered", gfc_match_omp_eos, ST_OMP_END_ORDERED); matchs ("end ordered", gfc_match_omp_eos_error, ST_OMP_END_ORDERED);
matchs ("end parallel do simd", gfc_match_omp_eos, matchs ("end parallel do simd", gfc_match_omp_eos_error,
ST_OMP_END_PARALLEL_DO_SIMD); ST_OMP_END_PARALLEL_DO_SIMD);
matcho ("end parallel do", gfc_match_omp_eos, ST_OMP_END_PARALLEL_DO); matcho ("end parallel do", gfc_match_omp_eos_error, ST_OMP_END_PARALLEL_DO);
matcho ("end parallel sections", gfc_match_omp_eos, matcho ("end parallel sections", gfc_match_omp_eos_error,
ST_OMP_END_PARALLEL_SECTIONS); ST_OMP_END_PARALLEL_SECTIONS);
matcho ("end parallel workshare", gfc_match_omp_eos, matcho ("end parallel workshare", gfc_match_omp_eos_error,
ST_OMP_END_PARALLEL_WORKSHARE); ST_OMP_END_PARALLEL_WORKSHARE);
matcho ("end parallel", gfc_match_omp_eos, ST_OMP_END_PARALLEL); matcho ("end parallel", gfc_match_omp_eos_error, ST_OMP_END_PARALLEL);
matcho ("end sections", gfc_match_omp_end_nowait, ST_OMP_END_SECTIONS); matcho ("end sections", gfc_match_omp_end_nowait, ST_OMP_END_SECTIONS);
matcho ("end single", gfc_match_omp_end_single, ST_OMP_END_SINGLE); matcho ("end single", gfc_match_omp_end_single, ST_OMP_END_SINGLE);
matcho ("end target data", gfc_match_omp_eos, ST_OMP_END_TARGET_DATA); matcho ("end target data", gfc_match_omp_eos_error, ST_OMP_END_TARGET_DATA);
matchs ("end target parallel do simd", gfc_match_omp_eos, matchs ("end target parallel do simd", gfc_match_omp_eos_error,
ST_OMP_END_TARGET_PARALLEL_DO_SIMD); ST_OMP_END_TARGET_PARALLEL_DO_SIMD);
matcho ("end target parallel do", gfc_match_omp_eos, matcho ("end target parallel do", gfc_match_omp_eos_error,
ST_OMP_END_TARGET_PARALLEL_DO); ST_OMP_END_TARGET_PARALLEL_DO);
matcho ("end target parallel", gfc_match_omp_eos, matcho ("end target parallel", gfc_match_omp_eos_error,
ST_OMP_END_TARGET_PARALLEL); ST_OMP_END_TARGET_PARALLEL);
matchs ("end target simd", gfc_match_omp_eos, ST_OMP_END_TARGET_SIMD); matchs ("end target simd", gfc_match_omp_eos_error, ST_OMP_END_TARGET_SIMD);
matchs ("end target teams distribute parallel do simd", matchs ("end target teams distribute parallel do simd",
gfc_match_omp_eos, gfc_match_omp_eos_error,
ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD); ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD);
matcho ("end target teams distribute parallel do", gfc_match_omp_eos, matcho ("end target teams distribute parallel do", gfc_match_omp_eos_error,
ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO); ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO);
matchs ("end target teams distribute simd", gfc_match_omp_eos, matchs ("end target teams distribute simd", gfc_match_omp_eos_error,
ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_SIMD); ST_OMP_END_TARGET_TEAMS_DISTRIBUTE_SIMD);
matcho ("end target teams distribute", gfc_match_omp_eos, matcho ("end target teams distribute", gfc_match_omp_eos_error,
ST_OMP_END_TARGET_TEAMS_DISTRIBUTE); ST_OMP_END_TARGET_TEAMS_DISTRIBUTE);
matcho ("end target teams", gfc_match_omp_eos, ST_OMP_END_TARGET_TEAMS); matcho ("end target teams", gfc_match_omp_eos_error, ST_OMP_END_TARGET_TEAMS);
matcho ("end target", gfc_match_omp_eos, ST_OMP_END_TARGET); matcho ("end target", gfc_match_omp_eos_error, ST_OMP_END_TARGET);
matcho ("end taskgroup", gfc_match_omp_eos, ST_OMP_END_TASKGROUP); matcho ("end taskgroup", gfc_match_omp_eos_error, ST_OMP_END_TASKGROUP);
matchs ("end taskloop simd", gfc_match_omp_eos, matchs ("end taskloop simd", gfc_match_omp_eos_error,
ST_OMP_END_TASKLOOP_SIMD); ST_OMP_END_TASKLOOP_SIMD);
matcho ("end taskloop", gfc_match_omp_eos, ST_OMP_END_TASKLOOP); matcho ("end taskloop", gfc_match_omp_eos_error, ST_OMP_END_TASKLOOP);
matcho ("end task", gfc_match_omp_eos, ST_OMP_END_TASK); matcho ("end task", gfc_match_omp_eos_error, ST_OMP_END_TASK);
matchs ("end teams distribute parallel do simd", gfc_match_omp_eos, matchs ("end teams distribute parallel do simd", gfc_match_omp_eos_error,
ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD); ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD);
matcho ("end teams distribute parallel do", gfc_match_omp_eos, matcho ("end teams distribute parallel do", gfc_match_omp_eos_error,
ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO); ST_OMP_END_TEAMS_DISTRIBUTE_PARALLEL_DO);
matchs ("end teams distribute simd", gfc_match_omp_eos, matchs ("end teams distribute simd", gfc_match_omp_eos_error,
ST_OMP_END_TEAMS_DISTRIBUTE_SIMD); ST_OMP_END_TEAMS_DISTRIBUTE_SIMD);
matcho ("end teams distribute", gfc_match_omp_eos, matcho ("end teams distribute", gfc_match_omp_eos_error,
ST_OMP_END_TEAMS_DISTRIBUTE); ST_OMP_END_TEAMS_DISTRIBUTE);
matcho ("end teams", gfc_match_omp_eos, ST_OMP_END_TEAMS); matcho ("end teams", gfc_match_omp_eos_error, ST_OMP_END_TEAMS);
matcho ("end workshare", gfc_match_omp_end_nowait, matcho ("end workshare", gfc_match_omp_end_nowait,
ST_OMP_END_WORKSHARE); ST_OMP_END_WORKSHARE);
break; break;
...@@ -979,7 +988,7 @@ decode_omp_directive (void) ...@@ -979,7 +988,7 @@ decode_omp_directive (void)
break; break;
case 's': case 's':
matcho ("sections", gfc_match_omp_sections, ST_OMP_SECTIONS); matcho ("sections", gfc_match_omp_sections, ST_OMP_SECTIONS);
matcho ("section", gfc_match_omp_eos, ST_OMP_SECTION); matcho ("section", gfc_match_omp_eos_error, ST_OMP_SECTION);
matcho ("single", gfc_match_omp_single, ST_OMP_SINGLE); matcho ("single", gfc_match_omp_single, ST_OMP_SINGLE);
break; break;
case 't': case 't':
......
2019-10-08 Tobias Burnus <tobias@codesourcery.com>
* gfortran.dg/goacc/continuation-free-form.f95: Update dg-error.
2019-10-08 Richard Sandiford <richard.sandiford@arm.com> 2019-10-08 Richard Sandiford <richard.sandiford@arm.com>
* gcc.target/aarch64/torture/simd-abi-9.c: Require LP64 for * gcc.target/aarch64/torture/simd-abi-9.c: Require LP64 for
......
...@@ -16,8 +16,8 @@ program test ...@@ -16,8 +16,8 @@ program test
x = x + 0.3 x = x + 0.3
enddo enddo
! continuation must begin with sentinel ! continuation must begin with sentinel
!$acc end parallel & ! { dg-error "Unclassifiable OpenACC directive" } !$acc end parallel & ! { dg-error "Unexpected junk" }
! loop ! loop
print *, x print *, x
end end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment