From 75ba2ce82008a5c5ab7095a566d18ed966c1ce30 Mon Sep 17 00:00:00 2001 From: bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Mon, 5 Feb 2007 07:57:49 +0000 Subject: [PATCH] 2007-02-05 Paolo Bonzini <bonzini@gnu.org> * cp-tree.h (OMP_ATOMIC_CODE): Delete. (OMP_ATOMIC_DEPENDENT_P): Rewrite. * pt.c (tsubst_expr): Adjust for new format of dependent OMP_ATOMIC expressions. * semantics.c (finish_omp_atomic): Store a whole expression node in operand 1, and integer_zero_node in operand 0, for dependent OMP_ATOMIC. Rewrite to make flow easier to understand. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121592 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 10 ++++++++++ gcc/cp/cp-tree.h | 8 ++------ gcc/cp/pt.c | 13 +++++++------ gcc/cp/semantics.c | 39 +++++++++++++-------------------------- 4 files changed, 32 insertions(+), 38 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c5e688036d23..bd78f583278f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2007-02-05 Paolo Bonzini <bonzini@gnu.org> + + * cp-tree.h (OMP_ATOMIC_CODE): Delete. + (OMP_ATOMIC_DEPENDENT_P): Rewrite. + * pt.c (tsubst_expr): Adjust for new format of dependent OMP_ATOMIC + expressions. + * semantics.c (finish_omp_atomic): Store a whole expression node + in operand 1, and integer_zero_node in operand 0, for dependent + OMP_ATOMIC. Rewrite to make flow easier to understand. + 2007-02-03 Gabriel Dos Reis <gdr@integrable-solutions.net> * decl.c (grokdeclarator): Use OPT_Wreturn_type instead of 0. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 7eb26c595798..4de73ff9c006 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3040,13 +3040,9 @@ extern void decl_shadowed_for_var_insert (tree, tree); (TREE_LANG_FLAG_0 (SCOPE_REF_CHECK (NODE))) /* True for an OMP_ATOMIC that has dependent parameters. These are stored - as bare LHS/RHS, and not as ADDR/RHS, as in the generic statement. */ + as an expr in operand 1, and integer_zero_node in operand 0. */ #define OMP_ATOMIC_DEPENDENT_P(NODE) \ - (TREE_LANG_FLAG_0 (OMP_ATOMIC_CHECK (NODE))) - -/* Used to store the operation code when OMP_ATOMIC_DEPENDENT_P is set. */ -#define OMP_ATOMIC_CODE(NODE) \ - (OMP_ATOMIC_CHECK (NODE)->exp.complexity) + (TREE_CODE (TREE_OPERAND (OMP_ATOMIC_CHECK (NODE), 0)) == INTEGER_CST) /* Used while gimplifying continue statements bound to OMP_FOR nodes. */ #define OMP_FOR_GIMPLIFYING_P(NODE) \ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 21e014bea53b..ba203534e51a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8917,12 +8917,13 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, break; case OMP_ATOMIC: - { - tree op0, op1; - op0 = RECUR (TREE_OPERAND (t, 0)); - op1 = RECUR (TREE_OPERAND (t, 1)); - finish_omp_atomic (OMP_ATOMIC_CODE (t), op0, op1); - } + if (OMP_ATOMIC_DEPENDENT_P (t)) + { + tree op1 = TREE_OPERAND (t, 1); + tree lhs = RECUR (TREE_OPERAND (op1, 0)); + tree rhs = RECUR (TREE_OPERAND (op1, 1)); + finish_omp_atomic (TREE_CODE (op1), lhs, rhs); + } break; default: diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index fea33417aee1..326bcfb4d5a1 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3867,41 +3867,28 @@ finish_omp_for (location_t locus, tree decl, tree init, tree cond, void finish_omp_atomic (enum tree_code code, tree lhs, tree rhs) { - tree orig_lhs; - tree orig_rhs; - bool dependent_p; tree stmt; - orig_lhs = lhs; - orig_rhs = rhs; - dependent_p = false; - stmt = NULL_TREE; - - /* Even in a template, we can detect invalid uses of the atomic - pragma if neither LHS nor RHS is type-dependent. */ - if (processing_template_decl) + if (processing_template_decl + && (type_dependent_expression_p (lhs) + || type_dependent_expression_p (rhs))) + stmt = build2 (OMP_ATOMIC, void_type_node, integer_zero_node, + build2 (code, void_type_node, lhs, rhs)); + else { - dependent_p = (type_dependent_expression_p (lhs) - || type_dependent_expression_p (rhs)); - if (!dependent_p) + /* Even in a template, we can detect invalid uses of the atomic + pragma if neither LHS nor RHS is type-dependent. */ + if (processing_template_decl) { lhs = build_non_dependent_expr (lhs); rhs = build_non_dependent_expr (rhs); } - } - if (!dependent_p) - { + stmt = c_finish_omp_atomic (code, lhs, rhs); - if (stmt == error_mark_node) - return; } - if (processing_template_decl) - { - stmt = build2 (OMP_ATOMIC, void_type_node, orig_lhs, orig_rhs); - OMP_ATOMIC_DEPENDENT_P (stmt) = 1; - OMP_ATOMIC_CODE (stmt) = code; - } - add_stmt (stmt); + + if (stmt != error_mark_node) + add_stmt (stmt); } void -- GitLab