diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-11-25 20:28:56 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-11-25 20:28:56 +0000 |
commit | c92cf9e4f8e6b8b0c5de797e0425ae05962f8c72 (patch) | |
tree | e09f0b243a46a3ff9e7a5acdd73e3b23f01bee52 /gcc/fortran/trans-openmp.c | |
parent | dd835b66db94bf756d480ef7de17d8723a57b583 (diff) |
PR fortran/42162
* trans-openmp.c (gfc_trans_omp_do): When dovar isn't a VAR_DECL,
don't use simple loop and handle clauses properly.
* testsuite/libgomp.fortran/pr42162.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154654 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-openmp.c')
-rw-r--r-- | gcc/fortran/trans-openmp.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 4d461cfa488b..7343d1ad0da9 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -1160,6 +1160,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, { int simple = 0; int dovar_found = 0; + tree dovar_decl; if (clauses) { @@ -1200,12 +1201,19 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, gfc_conv_expr_val (&se, code->ext.iterator->step); gfc_add_block_to_block (pblock, &se.pre); step = gfc_evaluate_now (se.expr, pblock); + dovar_decl = dovar; /* Special case simple loops. */ - if (integer_onep (step)) - simple = 1; - else if (tree_int_cst_equal (step, integer_minus_one_node)) - simple = -1; + if (TREE_CODE (dovar) == VAR_DECL) + { + if (integer_onep (step)) + simple = 1; + else if (tree_int_cst_equal (step, integer_minus_one_node)) + simple = -1; + } + else + dovar_decl + = gfc_trans_omp_variable (code->ext.iterator->var->symtree->n.sym); /* Loop body. */ if (simple) @@ -1249,7 +1257,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, if (!dovar_found) { tmp = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE); - OMP_CLAUSE_DECL (tmp) = dovar; + OMP_CLAUSE_DECL (tmp) = dovar_decl; omp_clauses = gfc_trans_add_clause (tmp, omp_clauses); } else if (dovar_found == 2) @@ -1269,7 +1277,7 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, tmp = fold_build2 (MODIFY_EXPR, type, dovar, tmp); for (c = omp_clauses; c ; c = OMP_CLAUSE_CHAIN (c)) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE - && OMP_CLAUSE_DECL (c) == dovar) + && OMP_CLAUSE_DECL (c) == dovar_decl) { OMP_CLAUSE_LASTPRIVATE_STMT (c) = tmp; break; @@ -1279,11 +1287,11 @@ gfc_trans_omp_do (gfc_code *code, stmtblock_t *pblock, { for (c = par_clauses; c ; c = OMP_CLAUSE_CHAIN (c)) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE - && OMP_CLAUSE_DECL (c) == dovar) + && OMP_CLAUSE_DECL (c) == dovar_decl) { tree l = build_omp_clause (input_location, OMP_CLAUSE_LASTPRIVATE); - OMP_CLAUSE_DECL (l) = dovar; + OMP_CLAUSE_DECL (l) = dovar_decl; OMP_CLAUSE_CHAIN (l) = omp_clauses; OMP_CLAUSE_LASTPRIVATE_STMT (l) = tmp; omp_clauses = l; |