summaryrefslogtreecommitdiff
path: root/gcc/fortran/trans.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/trans.c')
-rw-r--r--gcc/fortran/trans.c55
1 files changed, 29 insertions, 26 deletions
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index 1232272762c..11ef0bf540c 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -1,5 +1,5 @@
/* Code translation -- generate GCC trees from gfc_code.
- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
Foundation, Inc.
Contributed by Paul Brook
@@ -278,8 +278,8 @@ gfc_build_addr_expr (tree type, tree t)
tree type_domain = TYPE_DOMAIN (base_type);
if (type_domain && TYPE_MIN_VALUE (type_domain))
min_val = TYPE_MIN_VALUE (type_domain);
- t = build4 (ARRAY_REF, TREE_TYPE (type), t, min_val,
- NULL_TREE, NULL_TREE);
+ t = fold (build4 (ARRAY_REF, TREE_TYPE (type),
+ t, min_val, NULL_TREE, NULL_TREE));
natural_type = type;
}
else
@@ -296,7 +296,7 @@ gfc_build_addr_expr (tree type, tree t)
{
if (DECL_P (t))
TREE_ADDRESSABLE (t) = 1;
- t = build1 (ADDR_EXPR, natural_type, t);
+ t = fold_build1 (ADDR_EXPR, natural_type, t);
}
if (type && natural_type != type)
@@ -394,11 +394,13 @@ gfc_trans_runtime_check (tree cond, stmtblock_t * pblock, locus * where,
asprintf (&message, "In file '%s', around line %d",
gfc_source_file, input_line + 1);
- arg = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const(message));
+ arg = gfc_build_addr_expr (pchar_type_node,
+ gfc_build_localized_cstring_const (message));
gfc_free(message);
asprintf (&message, "%s", _(msgid));
- arg2 = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const(message));
+ arg2 = gfc_build_addr_expr (pchar_type_node,
+ gfc_build_localized_cstring_const (message));
gfc_free(message);
/* Build the argument array. */
@@ -414,9 +416,9 @@ gfc_trans_runtime_check (tree cond, stmtblock_t * pblock, locus * where,
number of arguments, we can't use build_call_expr directly. */
fntype = TREE_TYPE (gfor_fndecl_runtime_error_at);
tmp = fold_builtin_call_array (TREE_TYPE (fntype),
- build1 (ADDR_EXPR,
- build_pointer_type (fntype),
- gfor_fndecl_runtime_error_at),
+ fold_build1 (ADDR_EXPR,
+ build_pointer_type (fntype),
+ gfor_fndecl_runtime_error_at),
nargs + 2, argarray);
gfc_add_expr_to_block (&block, tmp);
@@ -461,7 +463,7 @@ gfc_call_malloc (stmtblock_t * block, tree type, tree size)
/* size < 0 ? */
negative = fold_build2 (LT_EXPR, boolean_type_node, size,
build_int_cst (size_type_node, 0));
- msg = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const
+ msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
("Attempt to allocate a negative amount of memory."));
tmp = fold_build3 (COND_EXPR, void_type_node, negative,
build_call_expr (gfor_fndecl_runtime_error, 1, msg),
@@ -475,7 +477,7 @@ gfc_call_malloc (stmtblock_t * block, tree type, tree size)
size));
null_result = fold_build2 (EQ_EXPR, boolean_type_node, res,
build_int_cst (pvoid_type_node, 0));
- msg = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const
+ msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
("Memory allocation failed"));
tmp = fold_build3 (COND_EXPR, void_type_node, null_result,
build_call_expr (gfor_fndecl_os_error, 1, msg),
@@ -553,7 +555,7 @@ gfc_allocate_with_status (stmtblock_t * block, tree size, tree status)
if (status != NULL_TREE && !integer_zerop (status))
{
tmp = fold_build2 (MODIFY_EXPR, status_type,
- build1 (INDIRECT_REF, status_type, status),
+ fold_build1 (INDIRECT_REF, status_type, status),
build_int_cst (status_type, 0));
tmp = fold_build3 (COND_EXPR, void_type_node,
fold_build2 (NE_EXPR, boolean_type_node,
@@ -563,7 +565,7 @@ gfc_allocate_with_status (stmtblock_t * block, tree size, tree status)
}
/* Generate the block of code handling (size < 0). */
- msg = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const
+ msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
("Attempt to allocate negative amount of memory. "
"Possible integer overflow"));
error = build_call_expr (gfor_fndecl_runtime_error, 1, msg);
@@ -575,7 +577,7 @@ gfc_allocate_with_status (stmtblock_t * block, tree size, tree status)
gfc_start_block (&set_status_block);
gfc_add_modify_expr (&set_status_block,
- build1 (INDIRECT_REF, status_type, status),
+ fold_build1 (INDIRECT_REF, status_type, status),
build_int_cst (status_type, LIBERROR_ALLOCATION));
gfc_add_modify_expr (&set_status_block, res,
build_int_cst (pvoid_type_node, 0));
@@ -594,8 +596,8 @@ gfc_allocate_with_status (stmtblock_t * block, tree size, tree status)
size,
build_int_cst (size_type_node, 1))));
- msg = gfc_build_addr_expr (pchar_type_node,
- gfc_build_cstring_const ("Out of memory"));
+ msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
+ ("Out of memory"));
tmp = build_call_expr (gfor_fndecl_os_error, 1, msg);
if (status != NULL_TREE && !integer_zerop (status))
@@ -606,7 +608,7 @@ gfc_allocate_with_status (stmtblock_t * block, tree size, tree status)
cond = fold_build2 (EQ_EXPR, boolean_type_node, status,
build_int_cst (status_type, 0));
tmp2 = fold_build2 (MODIFY_EXPR, status_type,
- build1 (INDIRECT_REF, status_type, status),
+ fold_build1 (INDIRECT_REF, status_type, status),
build_int_cst (status_type, LIBERROR_ALLOCATION));
tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp,
tmp2);
@@ -674,7 +676,7 @@ gfc_allocate_array_with_status (stmtblock_t * block, tree mem, tree size,
alloc = gfc_finish_block (&alloc_block);
/* Otherwise, we issue a runtime error or set the status variable. */
- msg = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const
+ msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
("Attempting to allocate already allocated array"));
error = build_call_expr (gfor_fndecl_runtime_error, 1, msg);
@@ -692,7 +694,7 @@ gfc_allocate_array_with_status (stmtblock_t * block, tree mem, tree size,
gfc_add_modify_expr (&set_status_block, res, fold_convert (type, tmp));
gfc_add_modify_expr (&set_status_block,
- build1 (INDIRECT_REF, status_type, status),
+ fold_build1 (INDIRECT_REF, status_type, status),
build_int_cst (status_type, LIBERROR_ALLOCATION));
tmp = fold_build2 (EQ_EXPR, boolean_type_node, status,
@@ -772,8 +774,9 @@ gfc_deallocate_with_status (tree pointer, tree status, bool can_fail)
gfc_start_block (&null);
if (!can_fail)
{
- msg = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const
- ("Attempt to DEALLOCATE unallocated memory."));
+ msg = gfc_build_addr_expr (pchar_type_node,
+ gfc_build_localized_cstring_const
+ ("Attempt to DEALLOCATE unallocated memory."));
error = build_call_expr (gfor_fndecl_runtime_error, 1, msg);
}
else
@@ -787,7 +790,7 @@ gfc_deallocate_with_status (tree pointer, tree status, bool can_fail)
cond2 = fold_build2 (NE_EXPR, boolean_type_node, status,
build_int_cst (TREE_TYPE (status), 0));
tmp = fold_build2 (MODIFY_EXPR, status_type,
- build1 (INDIRECT_REF, status_type, status),
+ fold_build1 (INDIRECT_REF, status_type, status),
build_int_cst (status_type, 1));
error = fold_build3 (COND_EXPR, void_type_node, cond2, tmp, error);
}
@@ -809,7 +812,7 @@ gfc_deallocate_with_status (tree pointer, tree status, bool can_fail)
cond2 = fold_build2 (NE_EXPR, boolean_type_node, status,
build_int_cst (TREE_TYPE (status), 0));
tmp = fold_build2 (MODIFY_EXPR, status_type,
- build1 (INDIRECT_REF, status_type, status),
+ fold_build1 (INDIRECT_REF, status_type, status),
build_int_cst (status_type, 0));
tmp = fold_build3 (COND_EXPR, void_type_node, cond2, tmp,
build_empty_stmt ());
@@ -855,7 +858,7 @@ gfc_call_realloc (stmtblock_t * block, tree mem, tree size)
/* size < 0 ? */
negative = fold_build2 (LT_EXPR, boolean_type_node, size,
build_int_cst (size_type_node, 0));
- msg = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const
+ msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
("Attempt to allocate a negative amount of memory."));
tmp = fold_build3 (COND_EXPR, void_type_node, negative,
build_call_expr (gfor_fndecl_runtime_error, 1, msg),
@@ -872,8 +875,8 @@ gfc_call_realloc (stmtblock_t * block, tree mem, tree size)
build_int_cst (size_type_node, 0));
null_result = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, null_result,
nonzero);
- msg = gfc_build_addr_expr (pchar_type_node,
- gfc_build_cstring_const ("Out of memory"));
+ msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const
+ ("Out of memory"));
tmp = fold_build3 (COND_EXPR, void_type_node, null_result,
build_call_expr (gfor_fndecl_os_error, 1, msg),
build_empty_stmt ());