re PR fortran/15586 (gfortran should support i18n in its compiler messages)
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>
Wed, 26 Oct 2005 11:02:00 +0000 (13:02 +0200)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Wed, 26 Oct 2005 11:02:00 +0000 (11:02 +0000)
PR fortran/15586
* resolve.c (resolve_symbol): Remove the use of whynot, so that
error messages are not built from pieces.

From-SVN: r105921

gcc/fortran/ChangeLog
gcc/fortran/resolve.c

index 2cfea316984a6ff7a282fa7260d2d10767e93313..3632e9eb8b093f1015fce144bcef531109a97442 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-26  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR fortran/15586
+       * resolve.c (resolve_symbol): Remove the use of whynot, so that
+       error messages are not built from pieces.
+
 2005-10-26  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/24158
index 03206bbd3a0146b90550765a70f80e87111a2e36..f6fb2b0f8386a72a935fad8b1731ffea0b53177b 100644 (file)
@@ -4181,8 +4181,7 @@ resolve_symbol (gfc_symbol * sym)
   /* Zero if we are checking a formal namespace.  */
   static int formal_ns_flag = 1;
   int formal_ns_save, check_constant, mp_flag;
-  int i;
-  const char *whynot;
+  int i, flag;
   gfc_namelist *nl;
   gfc_symtree * symtree;
   gfc_symtree * this_symtree;
@@ -4463,17 +4462,10 @@ resolve_symbol (gfc_symbol * sym)
     {
     case FL_VARIABLE:
       /* Can the sybol have an initializer?  */
-      whynot = NULL;
-      if (sym->attr.allocatable)
-       whynot = _("Allocatable");
-      else if (sym->attr.external)
-       whynot = _("External");
-      else if (sym->attr.dummy)
-       whynot = _("Dummy");
-      else if (sym->attr.intrinsic)
-       whynot = _("Intrinsic");
-      else if (sym->attr.result)
-       whynot = _("Function Result");
+      flag = 0;
+      if (sym->attr.allocatable || sym->attr.external || sym->attr.dummy
+         || sym->attr.intrinsic || sym->attr.result)
+       flag = 1;
       else if (sym->attr.dimension && !sym->attr.pointer)
        {
          /* Don't allow initialization of automatic arrays.  */
@@ -4484,22 +4476,38 @@ resolve_symbol (gfc_symbol * sym)
                  || sym->as->upper[i] == NULL
                  || sym->as->upper[i]->expr_type != EXPR_CONSTANT)
                {
-                 whynot = _("Automatic array");
+                 flag = 1;
                  break;
                }
            }
        }
 
       /* Reject illegal initializers.  */
-      if (sym->value && whynot)
+      if (sym->value && flag)
        {
-         gfc_error ("%s '%s' at %L cannot have an initializer",
-                    whynot, sym->name, &sym->declared_at);
+         if (sym->attr.allocatable)
+           gfc_error ("Allocatable '%s' at %L cannot have an initializer",
+                      sym->name, &sym->declared_at);
+         else if (sym->attr.external)
+           gfc_error ("External '%s' at %L cannot have an initializer",
+                      sym->name, &sym->declared_at);
+         else if (sym->attr.dummy)
+           gfc_error ("Dummy '%s' at %L cannot have an initializer",
+                      sym->name, &sym->declared_at);
+         else if (sym->attr.intrinsic)
+           gfc_error ("Intrinsic '%s' at %L cannot have an initializer",
+                      sym->name, &sym->declared_at);
+         else if (sym->attr.result)
+           gfc_error ("Function result '%s' at %L cannot have an initializer",
+                      sym->name, &sym->declared_at);
+         else
+           gfc_error ("Automatic array '%s' at %L cannot have an initializer",
+                      sym->name, &sym->declared_at);
          return;
        }
 
       /* Assign default initializer.  */
-      if (sym->ts.type == BT_DERIVED && !(sym->value || whynot)
+      if (sym->ts.type == BT_DERIVED && !(sym->value || flag)
           && !sym->attr.pointer)
        sym->value = gfc_default_initializer (&sym->ts);
       break;