mirror of git://gcc.gnu.org/git/gcc.git
backport: re PR fortran/71704 (ICE with -fopenmp and some omp constructs)
Backported from mainline 2016-06-30 Jakub Jelinek <jakub@redhat.com> PR fortran/71704 * parse.c (matchs, matcho): Move right before decode_omp_directive. If spec_only, only gfc_match the keyword and if successful, goto do_spec_only. (matchds, matchdo): Define. (decode_omp_directive): Add spec_only local var and set it. Use matchds or matchdo macros instead of matchs or matcho for declare target, declare simd, declare reduction and threadprivate directives. Return ST_GET_FCN_CHARACTERISTICS if a non-declarative directive could be matched. (next_statement): For ST_GET_FCN_CHARACTERISTICS restore gfc_current_locus from old_locus even if there is no label. * gfortran.dg/gomp/pr71704.f90: New test. From-SVN: r238103
This commit is contained in:
parent
0e8f52c0af
commit
e74885afa7
|
|
@ -3,6 +3,19 @@
|
||||||
Backported from mainline
|
Backported from mainline
|
||||||
2016-06-30 Jakub Jelinek <jakub@redhat.com>
|
2016-06-30 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR fortran/71704
|
||||||
|
* parse.c (matchs, matcho): Move right before decode_omp_directive.
|
||||||
|
If spec_only, only gfc_match the keyword and if successful, goto
|
||||||
|
do_spec_only.
|
||||||
|
(matchds, matchdo): Define.
|
||||||
|
(decode_omp_directive): Add spec_only local var and set it.
|
||||||
|
Use matchds or matchdo macros instead of matchs or matcho
|
||||||
|
for declare target, declare simd, declare reduction and threadprivate
|
||||||
|
directives. Return ST_GET_FCN_CHARACTERISTICS if a non-declarative
|
||||||
|
directive could be matched.
|
||||||
|
(next_statement): For ST_GET_FCN_CHARACTERISTICS restore
|
||||||
|
gfc_current_locus from old_locus even if there is no label.
|
||||||
|
|
||||||
PR fortran/71705
|
PR fortran/71705
|
||||||
* trans-openmp.c (gfc_trans_omp_clauses): Set TREE_ADDRESSABLE on
|
* trans-openmp.c (gfc_trans_omp_clauses): Set TREE_ADDRESSABLE on
|
||||||
decls in to/from clauses.
|
decls in to/from clauses.
|
||||||
|
|
|
||||||
|
|
@ -564,28 +564,6 @@ decode_statement (void)
|
||||||
return ST_NONE;
|
return ST_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Like match, but set a flag simd_matched if keyword matched. */
|
|
||||||
#define matchs(keyword, subr, st) \
|
|
||||||
do { \
|
|
||||||
if (match_word_omp_simd (keyword, subr, &old_locus, \
|
|
||||||
&simd_matched) == MATCH_YES) \
|
|
||||||
return st; \
|
|
||||||
else \
|
|
||||||
undo_new_statement (); \
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
/* Like match, but don't match anything if not -fopenmp. */
|
|
||||||
#define matcho(keyword, subr, st) \
|
|
||||||
do { \
|
|
||||||
if (!flag_openmp) \
|
|
||||||
; \
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|
@ -673,12 +651,63 @@ decode_oacc_directive (void)
|
||||||
return ST_NONE;
|
return ST_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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 { \
|
||||||
|
if (spec_only && gfc_match (keyword) == MATCH_YES) \
|
||||||
|
goto do_spec_only; \
|
||||||
|
if (match_word_omp_simd (keyword, subr, &old_locus, \
|
||||||
|
&simd_matched) == MATCH_YES) \
|
||||||
|
return st; \
|
||||||
|
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. */
|
||||||
|
#define matcho(keyword, subr, st) \
|
||||||
|
do { \
|
||||||
|
if (!flag_openmp) \
|
||||||
|
; \
|
||||||
|
else 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);
|
||||||
|
|
||||||
|
/* Like match, but set a flag simd_matched if keyword matched. */
|
||||||
|
#define matchds(keyword, subr, st) \
|
||||||
|
do { \
|
||||||
|
if (match_word_omp_simd (keyword, subr, &old_locus, \
|
||||||
|
&simd_matched) == MATCH_YES) \
|
||||||
|
return st; \
|
||||||
|
else \
|
||||||
|
undo_new_statement (); \
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
/* Like match, but don't match anything if not -fopenmp. */
|
||||||
|
#define matchdo(keyword, subr, st) \
|
||||||
|
do { \
|
||||||
|
if (!flag_openmp) \
|
||||||
|
; \
|
||||||
|
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_omp_directive (void)
|
decode_omp_directive (void)
|
||||||
{
|
{
|
||||||
locus old_locus;
|
locus old_locus;
|
||||||
char c;
|
char c;
|
||||||
bool simd_matched = false;
|
bool simd_matched = false;
|
||||||
|
bool spec_only = false;
|
||||||
|
|
||||||
gfc_enforce_clean_symbol_state ();
|
gfc_enforce_clean_symbol_state ();
|
||||||
|
|
||||||
|
|
@ -693,6 +722,10 @@ decode_omp_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;
|
||||||
|
|
@ -721,12 +754,12 @@ decode_omp_directive (void)
|
||||||
matcho ("critical", gfc_match_omp_critical, ST_OMP_CRITICAL);
|
matcho ("critical", gfc_match_omp_critical, ST_OMP_CRITICAL);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
matchs ("declare reduction", gfc_match_omp_declare_reduction,
|
matchds ("declare reduction", gfc_match_omp_declare_reduction,
|
||||||
ST_OMP_DECLARE_REDUCTION);
|
ST_OMP_DECLARE_REDUCTION);
|
||||||
matchs ("declare simd", gfc_match_omp_declare_simd,
|
matchds ("declare simd", gfc_match_omp_declare_simd,
|
||||||
ST_OMP_DECLARE_SIMD);
|
ST_OMP_DECLARE_SIMD);
|
||||||
matcho ("declare target", gfc_match_omp_declare_target,
|
matchdo ("declare target", gfc_match_omp_declare_target,
|
||||||
ST_OMP_DECLARE_TARGET);
|
ST_OMP_DECLARE_TARGET);
|
||||||
matchs ("distribute parallel do simd",
|
matchs ("distribute parallel do simd",
|
||||||
gfc_match_omp_distribute_parallel_do_simd,
|
gfc_match_omp_distribute_parallel_do_simd,
|
||||||
ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD);
|
ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD);
|
||||||
|
|
@ -846,8 +879,8 @@ decode_omp_directive (void)
|
||||||
matcho ("teams distribute", gfc_match_omp_teams_distribute,
|
matcho ("teams distribute", gfc_match_omp_teams_distribute,
|
||||||
ST_OMP_TEAMS_DISTRIBUTE);
|
ST_OMP_TEAMS_DISTRIBUTE);
|
||||||
matcho ("teams", gfc_match_omp_teams, ST_OMP_TEAMS);
|
matcho ("teams", gfc_match_omp_teams, ST_OMP_TEAMS);
|
||||||
matcho ("threadprivate", gfc_match_omp_threadprivate,
|
matchdo ("threadprivate", gfc_match_omp_threadprivate,
|
||||||
ST_OMP_THREADPRIVATE);
|
ST_OMP_THREADPRIVATE);
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
matcho ("workshare", gfc_match_omp_workshare, ST_OMP_WORKSHARE);
|
matcho ("workshare", gfc_match_omp_workshare, ST_OMP_WORKSHARE);
|
||||||
|
|
@ -870,6 +903,13 @@ decode_omp_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gfc_statement
|
static gfc_statement
|
||||||
|
|
@ -1290,10 +1330,13 @@ next_statement (void)
|
||||||
|
|
||||||
gfc_buffer_error (false);
|
gfc_buffer_error (false);
|
||||||
|
|
||||||
if (st == ST_GET_FCN_CHARACTERISTICS && gfc_statement_label != NULL)
|
if (st == ST_GET_FCN_CHARACTERISTICS)
|
||||||
{
|
{
|
||||||
gfc_free_st_label (gfc_statement_label);
|
if (gfc_statement_label != NULL)
|
||||||
gfc_statement_label = NULL;
|
{
|
||||||
|
gfc_free_st_label (gfc_statement_label);
|
||||||
|
gfc_statement_label = NULL;
|
||||||
|
}
|
||||||
gfc_current_locus = old_locus;
|
gfc_current_locus = old_locus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
Backported from mainline
|
Backported from mainline
|
||||||
2016-06-30 Jakub Jelinek <jakub@redhat.com>
|
2016-06-30 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
PR fortran/71704
|
||||||
|
* gfortran.dg/gomp/pr71704.f90: New test.
|
||||||
|
|
||||||
PR fortran/71705
|
PR fortran/71705
|
||||||
* gfortran.dg/gomp/pr71705.f90: New test.
|
* gfortran.dg/gomp/pr71705.f90: New test.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
! PR fortran/71704
|
||||||
|
! { dg-do compile }
|
||||||
|
|
||||||
|
real function f0 ()
|
||||||
|
!$omp declare simd (f0)
|
||||||
|
f0 = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
real function f1 ()
|
||||||
|
!$omp declare target (f1)
|
||||||
|
f1 = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
real function f2 ()
|
||||||
|
!$omp declare reduction (foo : integer : omp_out = omp_out + omp_in) &
|
||||||
|
!$omp & initializer (omp_priv = 0)
|
||||||
|
f2 = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
real function f3 ()
|
||||||
|
real, save :: t
|
||||||
|
!$omp threadprivate (t)
|
||||||
|
f3 = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
real function f4 ()
|
||||||
|
!$omp taskwait
|
||||||
|
f4 = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
real function f5 ()
|
||||||
|
!$omp barrier
|
||||||
|
f5 = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
real function f6 ()
|
||||||
|
!$omp parallel
|
||||||
|
!$omp end parallel
|
||||||
|
f6 = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
real function f7 ()
|
||||||
|
!$omp single
|
||||||
|
!$omp end single
|
||||||
|
f7 = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
real function f8 ()
|
||||||
|
!$omp critical
|
||||||
|
!$omp end critical
|
||||||
|
f8 = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
real function f9 ()
|
||||||
|
!$omp critical
|
||||||
|
!$omp end critical
|
||||||
|
f9 = 1
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue