Commit 642bcbdf by Cesar Philippidis Committed by Cesar Philippidis

parse.c (matcha): Define.

	gcc/fortran/
	* parse.c (matcha): Define.
	(decode_oacc_directive): Add spec_only local var and set it.  Use
	matcha to parse acc directives except for routine and declare.  Return
	ST_GET_FCN_CHARACTERISTICS if a non-declarative directive could be
	matched.

	gcc/testsuite/
	* gfortran.dg/goacc/pr71704.f90: New test.

From-SVN: r238171
parent d81102f4
2016-07-08 Cesar Philippidis <cesar@codesourcery.com>
* parse.c (matcha): Define.
(decode_oacc_directive): Add spec_only local var and set it. Use
matcha to parse acc directives except for routine and declare. Return
ST_GET_FCN_CHARACTERISTICS if a non-declarative directive could be
matched.
2016-07-08 Martin Liska <mliska@suse.cz> 2016-07-08 Martin Liska <mliska@suse.cz>
* invoke.texi (Wundefined-do-loop): Enhance documentation. * invoke.texi (Wundefined-do-loop): Enhance documentation.
......
...@@ -589,11 +589,25 @@ decode_statement (void) ...@@ -589,11 +589,25 @@ decode_statement (void)
return ST_NONE; return ST_NONE;
} }
/* Like match and if spec_only, goto do_spec_only without actually
matching. */
#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 static gfc_statement
decode_oacc_directive (void) decode_oacc_directive (void)
{ {
locus old_locus; locus old_locus;
char c; char c;
bool spec_only = false;
gfc_enforce_clean_symbol_state (); gfc_enforce_clean_symbol_state ();
...@@ -608,6 +622,10 @@ decode_oacc_directive (void) ...@@ -608,6 +622,10 @@ decode_oacc_directive (void)
return ST_NONE; return ST_NONE;
} }
if (gfc_current_state () == COMP_FUNCTION
&& gfc_current_block ()->result->ts.kind == -1)
spec_only = true;
gfc_unset_implicit_pure (NULL); gfc_unset_implicit_pure (NULL);
old_locus = gfc_current_locus; old_locus = gfc_current_locus;
...@@ -621,49 +639,52 @@ decode_oacc_directive (void) ...@@ -621,49 +639,52 @@ decode_oacc_directive (void)
switch (c) switch (c)
{ {
case 'a': case 'a':
match ("atomic", gfc_match_oacc_atomic, ST_OACC_ATOMIC); matcha ("atomic", gfc_match_oacc_atomic, ST_OACC_ATOMIC);
break; break;
case 'c': case 'c':
match ("cache", gfc_match_oacc_cache, ST_OACC_CACHE); matcha ("cache", gfc_match_oacc_cache, ST_OACC_CACHE);
break; break;
case 'd': case 'd':
match ("data", gfc_match_oacc_data, ST_OACC_DATA); matcha ("data", gfc_match_oacc_data, ST_OACC_DATA);
match ("declare", gfc_match_oacc_declare, ST_OACC_DECLARE); match ("declare", gfc_match_oacc_declare, ST_OACC_DECLARE);
break; break;
case 'e': case 'e':
match ("end atomic", gfc_match_omp_eos, ST_OACC_END_ATOMIC); matcha ("end atomic", gfc_match_omp_eos, ST_OACC_END_ATOMIC);
match ("end data", gfc_match_omp_eos, ST_OACC_END_DATA); matcha ("end data", gfc_match_omp_eos, ST_OACC_END_DATA);
match ("end host_data", gfc_match_omp_eos, ST_OACC_END_HOST_DATA); matcha ("end host_data", gfc_match_omp_eos, ST_OACC_END_HOST_DATA);
match ("end kernels loop", gfc_match_omp_eos, ST_OACC_END_KERNELS_LOOP); matcha ("end kernels loop", gfc_match_omp_eos, ST_OACC_END_KERNELS_LOOP);
match ("end kernels", gfc_match_omp_eos, ST_OACC_END_KERNELS); matcha ("end kernels", gfc_match_omp_eos, ST_OACC_END_KERNELS);
match ("end loop", gfc_match_omp_eos, ST_OACC_END_LOOP); matcha ("end loop", gfc_match_omp_eos, ST_OACC_END_LOOP);
match ("end parallel loop", gfc_match_omp_eos, ST_OACC_END_PARALLEL_LOOP); matcha ("end parallel loop", gfc_match_omp_eos,
match ("end parallel", gfc_match_omp_eos, ST_OACC_END_PARALLEL); ST_OACC_END_PARALLEL_LOOP);
match ("enter data", gfc_match_oacc_enter_data, ST_OACC_ENTER_DATA); matcha ("end parallel", gfc_match_omp_eos, ST_OACC_END_PARALLEL);
match ("exit data", gfc_match_oacc_exit_data, ST_OACC_EXIT_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);
break; break;
case 'h': case 'h':
match ("host_data", gfc_match_oacc_host_data, ST_OACC_HOST_DATA); matcha ("host_data", gfc_match_oacc_host_data, ST_OACC_HOST_DATA);
break; break;
case 'p': case 'p':
match ("parallel loop", gfc_match_oacc_parallel_loop, ST_OACC_PARALLEL_LOOP); matcha ("parallel loop", gfc_match_oacc_parallel_loop,
match ("parallel", gfc_match_oacc_parallel, ST_OACC_PARALLEL); ST_OACC_PARALLEL_LOOP);
matcha ("parallel", gfc_match_oacc_parallel, ST_OACC_PARALLEL);
break; break;
case 'k': case 'k':
match ("kernels loop", gfc_match_oacc_kernels_loop, ST_OACC_KERNELS_LOOP); matcha ("kernels loop", gfc_match_oacc_kernels_loop,
match ("kernels", gfc_match_oacc_kernels, ST_OACC_KERNELS); ST_OACC_KERNELS_LOOP);
matcha ("kernels", gfc_match_oacc_kernels, ST_OACC_KERNELS);
break; break;
case 'l': case 'l':
match ("loop", gfc_match_oacc_loop, ST_OACC_LOOP); matcha ("loop", gfc_match_oacc_loop, ST_OACC_LOOP);
break; break;
case 'r': case 'r':
match ("routine", gfc_match_oacc_routine, ST_OACC_ROUTINE); match ("routine", gfc_match_oacc_routine, ST_OACC_ROUTINE);
break; break;
case 'u': case 'u':
match ("update", gfc_match_oacc_update, ST_OACC_UPDATE); matcha ("update", gfc_match_oacc_update, ST_OACC_UPDATE);
break; break;
case 'w': case 'w':
match ("wait", gfc_match_oacc_wait, ST_OACC_WAIT); matcha ("wait", gfc_match_oacc_wait, ST_OACC_WAIT);
break; break;
} }
...@@ -678,6 +699,13 @@ decode_oacc_directive (void) ...@@ -678,6 +699,13 @@ decode_oacc_directive (void)
gfc_error_recovery (); gfc_error_recovery ();
return ST_NONE; return ST_NONE;
do_spec_only:
reject_statement ();
gfc_clear_error ();
gfc_buffer_error (false);
gfc_current_locus = old_locus;
return ST_GET_FCN_CHARACTERISTICS;
} }
/* Like match, but set a flag simd_matched if keyword matched /* Like match, but set a flag simd_matched if keyword matched
......
2016-07-08 Cesar Philippidis <cesar@codesourcery.com>
* gfortran.dg/goacc/pr71704.f90: New test.
2016-07-08 Bill Schmidt <wschmidt@linux.vnet.ibm.com> 2016-07-08 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR target/71297 PR target/71297
......
! PR fortran/71704
! { dg-do compile }
real function f1 ()
!$acc routine (f1)
f1 = 1
end
real function f2 (a)
integer a
!$acc enter data copyin(a)
f2 = 1
end
real function f3 (a)
integer a
!$acc enter data copyin(a)
f3 = 1
end
real function f4 ()
!$acc wait
f4 = 1
end
real function f5 (a)
integer a
!$acc update device(a)
f5 = 1
end
real function f6 ()
!$acc parallel
!$acc end parallel
f6 = 1
end
real function f7 ()
!$acc kernels
!$acc end kernels
f7 = 1
end
real function f8 ()
!$acc data
!$acc end data
f8 = 1
end
real function f9 ()
!$acc host_data
!$acc end host_data
f8 = 1
end
real function f10 (a)
integer a
!$acc declare present (a)
f8 = 1
end
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