On Wed, Jan 10, 2018 at 3:35 PM, Dominique d'Humières
<domi...@tournesol.lps.ens.fr> wrote:
> Hi Janne,
>
> With this patch, bootstrap fails with
>
> ../../work/gcc/fortran/array.c: In function 'bool 
> gfc_resolve_character_array_constructor(gfc_expr*)':
> ../../work/gcc/fortran/array.c:2062:36: error: unknown conversion type 
> character 'l' in format [-Werror=format=]
>      current_length, &p->expr->where);
>                                     ^
> ../../work/gcc/fortran/array.c:2062:36: error: unknown conversion type 
> character 'l' in format [-Werror=format=]
> ../../work/gcc/fortran/array.c:2062:36: error: format '%L' expects argument 
> of type 'locus*', but argument 2 has type 'long long int' [-Werror=format]
> ../../work/gcc/fortran/array.c:2062:36: error: too many arguments for format 
> [-Werror=format-extra-args]
>
> Note that trying to only update I saw the same problem for data.c:179 and 
> decl.c:1570/1580.

Please try the attached patch on top of the original.

Ok for trunk with that change?

(I don't know why HOST_WIDE_INT_PRINT_DEC doesn't work with the
diagnostics machinery on darwin, but IMHO at this point it's too late
to do surgery there for the GCC-8 release. So I suggest the attached
patch, and then at some future stage1 someone with an interest in
win64 or crosscompiling from a 32-bit host to a 64-bit target can look
into the issue.)



-- 
Janne Blomqvist
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index ed5fdb2..93deb0d 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -2019,10 +2019,9 @@ got_charlen:
            found_length = current_length;
          else if (found_length != current_length)
            {
-             gfc_error ("Different CHARACTER lengths ("
-                        HOST_WIDE_INT_PRINT_DEC "/" HOST_WIDE_INT_PRINT_DEC
-                        ") in array constructor at %L", found_length,
-                        current_length, &p->expr->where);
+             gfc_error ("Different CHARACTER lengths (%ld/%ld) in array"
+                        " constructor at %L", (long) found_length,
+                        (long) current_length, &p->expr->where);
              return false;
            }
 
diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c
index 45bb5c0..fdd7052 100644
--- a/gcc/fortran/data.c
+++ b/gcc/fortran/data.c
@@ -174,9 +174,8 @@ create_character_initializer (gfc_expr *init, gfc_typespec 
*ts,
       else
        {
          gfc_warning_now (0, "Initialization string at %L was truncated to "
-                          "fit the variable (" HOST_WIDE_INT_PRINT_DEC "/"
-                          HOST_WIDE_INT_PRINT_DEC ")", &rvalue->where,
-                          tlen, len);
+                          "fit the variable (%ld/%ld)", &rvalue->where,
+                          (long) tlen, (long) len);
          len = tlen;
        }
     }
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 14c8072..6adfbde 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1565,19 +1565,17 @@ gfc_set_constant_character_len (gfc_charlen_t len, 
gfc_expr *expr,
       if (warn_character_truncation && slen > len)
        gfc_warning_now (OPT_Wcharacter_truncation,
                         "CHARACTER expression at %L is being truncated "
-                        "(" HOST_WIDE_INT_PRINT_DEC "/"
-                        HOST_WIDE_INT_PRINT_DEC ")", &expr->where,
-                        (HOST_WIDE_INT) slen, (HOST_WIDE_INT) len);
+                        "(%ld/%ld)", &expr->where,
+                        (long) slen, (long) len);
 
       /* Apply the standard by 'hand' otherwise it gets cleared for
         initializers.  */
       if (check_len != -1 && slen != check_len
           && !(gfc_option.allow_std & GFC_STD_GNU))
        gfc_error_now ("The CHARACTER elements of the array constructor "
-                      "at %L must have the same length ("
-                      HOST_WIDE_INT_PRINT_DEC "/" HOST_WIDE_INT_PRINT_DEC ")",
-                      &expr->where, (HOST_WIDE_INT) slen,
-                      (HOST_WIDE_INT) check_len);
+                      "at %L must have the same length (%ld/%ld)",
+                      &expr->where, (long) slen,
+                      (long) check_len);
 
       s[len] = '\0';
       free (expr->value.character.string);
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index d32fe96..efa5b26 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -10218,9 +10218,8 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace 
*ns)
       if (rlen && llen && rlen > llen)
        gfc_warning_now (OPT_Wcharacter_truncation,
                         "CHARACTER expression will be truncated "
-                        "in assignment (" HOST_WIDE_INT_PRINT_DEC "/"
-                        HOST_WIDE_INT_PRINT_DEC ") at %L",
-                        llen, rlen, &code->loc);
+                        "in assignment (%ld/%ld) at %L",
+                        (long) llen, (long) rlen, &code->loc);
     }
 
   /* Ensure that a vector index expression for the lvalue is evaluated

Reply via email to