aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/ChangeLog15
-rw-r--r--gcc/fortran/trans-const.c16
-rw-r--r--gcc/fortran/trans-const.h1
-rw-r--r--gcc/fortran/trans-io.c3
-rw-r--r--gcc/fortran/trans.c29
5 files changed, 46 insertions, 18 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 5b639fc..5ba83fb 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,18 @@
+2008-02-25 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ PR fortran/34729
+ * trans-const.c (gfc_build_string_const): Don't call gettext.
+ (gfc_build_localized_string_const): New function.
+ * trans-const.h (gfc_build_localized_string_const): New prototype.
+ * trans.c (gfc_trans_runtime_check): Use
+ gfc_build_localized_string_const instead of gfc_build_string_const.
+ (gfc_call_malloc): Likewise.
+ (gfc_allocate_with_status): Likewise.
+ (gfc_allocate_array_with_status): Likewise.
+ (gfc_deallocate_with_status): Likewise.
+ (gfc_call_realloc): Likewise.
+ * trans-io.c (gfc_trans_io_runtime_check): Likewise.
+
2008-02-24 Tobias Schlüter <tobi@gcc.gnu.org>
* arith.c: Update copyright years.
diff --git a/gcc/fortran/trans-const.c b/gcc/fortran/trans-const.c
index 8d5f8a8..37251ef 100644
--- a/gcc/fortran/trans-const.c
+++ b/gcc/fortran/trans-const.c
@@ -82,14 +82,22 @@ gfc_build_string_const (int length, const char *s)
}
/* Build a Fortran character constant from a zero-terminated string.
- Since this is mainly used for error messages, the string will get
- translated. */
+ There a two version of this function, one that translates the string
+ and one that doesn't. */
tree
-gfc_build_cstring_const (const char *msgid)
+gfc_build_cstring_const (const char *string)
{
- return gfc_build_string_const (strlen (msgid) + 1, _(msgid));
+ return gfc_build_string_const (strlen (string) + 1, string);
}
+tree
+gfc_build_localized_cstring_const (const char *msgid)
+{
+ const char *localized = _(msgid);
+ return gfc_build_string_const (strlen (localized) + 1, localized);
+}
+
+
/* Return a string constant with the given length. Used for static
initializers. The constant will be padded or truncated to match
length. */
diff --git a/gcc/fortran/trans-const.h b/gcc/fortran/trans-const.h
index 04b60cf..808a1a5 100644
--- a/gcc/fortran/trans-const.h
+++ b/gcc/fortran/trans-const.h
@@ -38,6 +38,7 @@ void gfc_conv_constant (gfc_se *, gfc_expr *);
tree gfc_build_string_const (int, const char *);
tree gfc_build_cstring_const (const char *);
+tree gfc_build_localized_cstring_const (const char *);
/* Translate a string constant for a static initializer. */
tree gfc_conv_string_init (tree, gfc_expr *);
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index c3124f3..d0af342 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -240,7 +240,8 @@ gfc_trans_io_runtime_check (tree cond, tree var, int error_code,
arg2 = build_int_cst (integer_type_node, error_code),
asprintf (&message, "%s", _(msgid));
- arg3 = gfc_build_addr_expr (pchar_type_node, gfc_build_cstring_const(message));
+ arg3 = gfc_build_addr_expr (pchar_type_node,
+ gfc_build_localized_cstring_const (message));
gfc_free(message);
tmp = build_call_expr (gfor_fndecl_generate_error, 3, arg1, arg2, arg3);
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index 6964aa9..11ef0bf 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -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. */
@@ -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),
@@ -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);
@@ -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))
@@ -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);
@@ -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
@@ -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 ());