I noticed that several diagnostic strings were not tagged as translatable.
I fixed them by adding _ or G_ as prefix ( →gcc/ABOUT-GCC-NLS) and moved a single-use string to the message to make it more readable. One error message did not quit fit the pattern, hence, I modified it slightly, and a few '...' should have used proper %<...%> quotes. OK for mainline? Tobias PS: Currently, 'make gcc.pot' fails because of PR117109.
Fortran: Fix translatability of diagnostic strings

gcc/fortran/ChangeLog:

	* check.cc (is_c_interoperable): Use _(...) around to mark strings
	as translatable.
	* data.cc (gfc_assign_data_value): Move string literal to gfc_error
	to make it translatable.
	* resolve.cc (resolve_fl_variable, resolve_equivalence): Use G_(...)
	around string literals.
	* scanner.cc (skip_fixed_omp_sentinel): Replace '...' by %<...%>.
	* trans-openmp.cc (gfc_split_omp_clauses,
	gfc_trans_omp_declare_variant): Likewise.

 gcc/fortran/check.cc        | 20 ++++++++++----------
 gcc/fortran/data.cc         |  6 +++---
 gcc/fortran/resolve.cc      | 20 ++++++++++----------
 gcc/fortran/scanner.cc      |  2 +-
 gcc/fortran/trans-openmp.cc |  4 ++--
 5 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc
index 79e6668d0af..e90073ad4b0 100644
--- a/gcc/fortran/check.cc
+++ b/gcc/fortran/check.cc
@@ -5615,32 +5615,32 @@ is_c_interoperable (gfc_expr *expr, const char **msg, bool c_loc, bool c_f_ptr)
 
   if (expr->expr_type == EXPR_NULL && expr->ts.type == BT_UNKNOWN)
     {
-      *msg = "NULL() is not interoperable";
+      *msg = _("NULL() is not interoperable");
       return false;
     }
 
   if (expr->ts.type == BT_BOZ)
     {
-      *msg = "BOZ literal constant";
+      *msg = _("BOZ literal constant");
       return false;
     }
 
   if (expr->ts.type == BT_CLASS)
     {
-      *msg = "Expression is polymorphic";
+      *msg = _("Expression is polymorphic");
       return false;
     }
 
   if (expr->ts.type == BT_DERIVED && !expr->ts.u.derived->attr.is_bind_c
       && !expr->ts.u.derived->ts.is_iso_c)
     {
-      *msg = "Expression is a noninteroperable derived type";
+      *msg = _("Expression is a noninteroperable derived type");
       return false;
     }
 
   if (expr->ts.type == BT_PROCEDURE)
     {
-      *msg = "Procedure unexpected as argument";
+      *msg = _("Procedure unexpected as argument");
       return false;
     }
 
@@ -5650,14 +5650,14 @@ is_c_interoperable (gfc_expr *expr, const char **msg, bool c_loc, bool c_f_ptr)
       for (i = 0; gfc_logical_kinds[i].kind; i++)
         if (gfc_logical_kinds[i].kind == expr->ts.kind)
           return true;
-      *msg = "Extension to use a non-C_Bool-kind LOGICAL";
+      *msg = _("Extension to use a non-C_Bool-kind LOGICAL");
       return false;
     }
 
   if (gfc_notification_std (GFC_STD_GNU) && expr->ts.type == BT_CHARACTER
       && expr->ts.kind != 1)
     {
-      *msg = "Extension to use a non-C_CHAR-kind CHARACTER";
+      *msg = _("Extension to use a non-C_CHAR-kind CHARACTER");
       return false;
     }
 
@@ -5678,7 +5678,7 @@ is_c_interoperable (gfc_expr *expr, const char **msg, bool c_loc, bool c_f_ptr)
 	&& expr->ts.u.cl
 	&& !gfc_length_one_character_type_p (&expr->ts))
       {
-	*msg = "Type shall have a character length of 1";
+	*msg = _("Type shall have a character length of 1");
 	return false;
       }
     }
@@ -5689,7 +5689,7 @@ is_c_interoperable (gfc_expr *expr, const char **msg, bool c_loc, bool c_f_ptr)
 
   if (gfc_is_coarray (expr))
     {
-      *msg = "Coarrays are not interoperable";
+      *msg = _("Coarrays are not interoperable");
       return false;
     }
 
@@ -5700,7 +5700,7 @@ is_c_interoperable (gfc_expr *expr, const char **msg, bool c_loc, bool c_f_ptr)
       gfc_array_ref *ar = gfc_find_array_ref (expr);
       if (ar->type == AR_FULL && ar->as->type == AS_ASSUMED_SIZE)
 	{
-	  *msg = "Assumed-size arrays are not interoperable";
+	  *msg = _("Assumed-size arrays are not interoperable");
 	  return false;
 	}
     }
diff --git a/gcc/fortran/data.cc b/gcc/fortran/data.cc
index d80ba66d358..061a6e381a8 100644
--- a/gcc/fortran/data.cc
+++ b/gcc/fortran/data.cc
@@ -272,8 +272,6 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index,
   gfc_symbol *symbol;
   gfc_typespec *last_ts;
   mpz_t offset;
-  const char *msg = "F18(R841): data-implied-do object at %L is neither an "
-		    "array-element nor a scalar-structure-component";
 
   symbol = lvalue->symtree->n.sym;
   init = symbol->value;
@@ -522,7 +520,9 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index,
 	     violates F18(R841). If the error is removed, the expected result
 	     is obtained. Leaving the code in place ensures a clean error
 	     recovery.  */
-	  gfc_error (msg, &lvalue->where);
+	  gfc_error ("data-implied-do object at %L is neither an array-element "
+		     "nor a scalar-structure-component (F2018: R841)",
+		     &lvalue->where);
 
 	  /* This breaks with the other reference types in that the output
 	     constructor has to be of type COMPLEX, whereas the lvalue is
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index ebe449e7119..21bb1b93749 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -13983,8 +13983,8 @@ deferred_requirements (gfc_symbol *sym)
 static bool
 resolve_fl_variable (gfc_symbol *sym, int mp_flag)
 {
-  const char *auto_save_msg = "Automatic object %qs at %L cannot have the "
-			      "SAVE attribute";
+  const char *auto_save_msg = G_("Automatic object %qs at %L cannot have the "
+				 "SAVE attribute");
 
   if (!resolve_fl_var_and_proc (sym, mp_flag))
     return false;
@@ -18245,8 +18245,8 @@ resolve_equivalence (gfc_equiv *eq)
       /* Since the pair of objects is not of the same type, mixed or
 	 non-default sequences can be rejected.  */
 
-      msg = "Sequence %s with mixed components in EQUIVALENCE "
-	    "statement at %L with different type objects";
+      msg = G_("Sequence %s with mixed components in EQUIVALENCE "
+	       "statement at %L with different type objects");
       if ((object ==2
 	   && last_eq_type == SEQ_MIXED
 	   && last_where
@@ -18255,8 +18255,8 @@ resolve_equivalence (gfc_equiv *eq)
 	      && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where)))
 	continue;
 
-      msg = "Non-default type object or sequence %s in EQUIVALENCE "
-	    "statement at %L with objects of different type";
+      msg = G_("Non-default type object or sequence %s in EQUIVALENCE "
+	       "statement at %L with objects of different type");
       if ((object ==2
 	   && last_eq_type == SEQ_NONDEFAULT
 	   && last_where
@@ -18265,15 +18265,15 @@ resolve_equivalence (gfc_equiv *eq)
 	      && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where)))
 	continue;
 
-      msg ="Non-CHARACTER object %qs in default CHARACTER "
-	   "EQUIVALENCE statement at %L";
+      msg = G_("Non-CHARACTER object %qs in default CHARACTER "
+	       "EQUIVALENCE statement at %L");
       if (last_eq_type == SEQ_CHARACTER
 	  && eq_type != SEQ_CHARACTER
 	  && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where))
 		continue;
 
-      msg ="Non-NUMERIC object %qs in default NUMERIC "
-	   "EQUIVALENCE statement at %L";
+      msg = G_("Non-NUMERIC object %qs in default NUMERIC "
+	       "EQUIVALENCE statement at %L");
       if (last_eq_type == SEQ_NUMERIC
 	  && eq_type != SEQ_NUMERIC
 	  && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where))
diff --git a/gcc/fortran/scanner.cc b/gcc/fortran/scanner.cc
index 0631e7b8284..86708c62d81 100644
--- a/gcc/fortran/scanner.cc
+++ b/gcc/fortran/scanner.cc
@@ -1008,7 +1008,7 @@ skip_fixed_omp_sentinel (locus *start)
     }
   else if (UNLIKELY (c == 'x' || c == 'X'))
     gfc_warning_now (OPT_Wsurprising,
-		     "Ignoring '!$omx' vendor-extension sentinel at %C");
+		     "Ignoring %<!$omx%> vendor-extension sentinel at %C");
   return false;
 }
 
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index d3783f56a69..b01a6dd3f9f 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -7216,7 +7216,7 @@ gfc_split_omp_clauses (gfc_code *code,
 		 }
 	     }
 	   if (!found)
-	     gfc_error ("%qs specified in 'allocate' clause at %L but not "
+	     gfc_error ("%qs specified in %<allocate%> clause at %L but not "
 			"in an explicit privatization clause",
 			alloc_nl->sym->name, &alloc_nl->where);
 	 }
@@ -8424,7 +8424,7 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns)
 	{
 	  if (!search_ns->proc_name->attr.function
 	      && !search_ns->proc_name->attr.subroutine)
-	    gfc_error ("The base name for 'declare variant' must be "
+	    gfc_error ("The base name for %<declare variant%> must be "
 		       "specified at %L ", &odv->where);
 	  else
 	    error_found = false;

Reply via email to