PR fortran/34729
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Feb 2008 08:36:15 +0000 (08:36 +0000)
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Feb 2008 08:36:15 +0000 (08:36 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132612 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-const.c
gcc/fortran/trans-const.h
gcc/fortran/trans-io.c
gcc/fortran/trans.c

index 5b639fc..5ba83fb 100644 (file)
@@ -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.
index 8d5f8a8..37251ef 100644 (file)
@@ -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.  */
index 04b60cf..808a1a5 100644 (file)
@@ -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 *);
index c3124f3..d0af342 100644 (file)
@@ -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);
index 6964aa9..11ef0bf 100644 (file)
@@ -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 ());