summaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-expr.c
diff options
context:
space:
mode:
authorpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2005-08-04 03:06:12 +0000
committerpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>2005-08-04 03:06:12 +0000
commit7b7afa038f578b0d9e86851ab3a8c2a89e0c0f7e (patch)
tree79ce8b2fc6abff72b98587b58b629ea8eae957d7 /gcc/fortran/trans-expr.c
parentc999d03166080730b4476ea879899025991347d9 (diff)
downloadgcc-7b7afa038f578b0d9e86851ab3a8c2a89e0c0f7e.tar.gz
2005-08-04 Paul Brook <paul@codesourcery.com>
* trans-expr.c (gfc_conv_expr, gfc_conv_expr_type): Update comments. (gfc_conv_expr_lhs): Fix assertion. (gfc_conv_expr_val): Merge post block. Set se.expr to new value. * trans.h: Move and update comments. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102729 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/trans-expr.c')
-rw-r--r--gcc/fortran/trans-expr.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 0cd8741758c..a3846f3288e 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -1867,7 +1867,9 @@ gfc_conv_substring_expr (gfc_se * se, gfc_expr * expr)
}
-/* Entry point for expression translation. */
+/* Entry point for expression translation. Evaluates a scalar quantity.
+ EXPR is the expression to be translated, and SE is the state structure if
+ called from within the scalarized. */
void
gfc_conv_expr (gfc_se * se, gfc_expr * expr)
@@ -1923,15 +1925,20 @@ gfc_conv_expr (gfc_se * se, gfc_expr * expr)
}
}
+/* Like gfc_conv_expr_val, but the value is also suitable for use in the lhs
+ of an assignment. */
void
gfc_conv_expr_lhs (gfc_se * se, gfc_expr * expr)
{
gfc_conv_expr (se, expr);
- /* AFAICS all numeric lvalues have empty post chains. If not we need to
+ /* All numeric lvalues should have empty post chains. If not we need to
figure out a way of rewriting an lvalue so that it has no post chain. */
- gcc_assert (expr->ts.type != BT_CHARACTER || !se->post.head);
+ gcc_assert (expr->ts.type == BT_CHARACTER || !se->post.head);
}
+/* Like gfc_conv_expr, but the POST block is guaranteed to be empty for
+ numeric expressions. Used for scalar values whee inserting cleanup code
+ is inconvenient. */
void
gfc_conv_expr_val (gfc_se * se, gfc_expr * expr)
{
@@ -1943,9 +1950,12 @@ gfc_conv_expr_val (gfc_se * se, gfc_expr * expr)
{
val = gfc_create_var (TREE_TYPE (se->expr), NULL);
gfc_add_modify_expr (&se->pre, val, se->expr);
+ se->expr = val;
+ gfc_add_block_to_block (&se->pre, &se->post);
}
}
+/* Helper to translate and expression and convert it to a particular type. */
void
gfc_conv_expr_type (gfc_se * se, gfc_expr * expr, tree type)
{