]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/44054 (Handle -Werror, -Werror=, -fdiagnostics-show-option, !GCC$ diagn...
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Sun, 23 Nov 2014 23:47:42 +0000 (23:47 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Sun, 23 Nov 2014 23:47:42 +0000 (23:47 +0000)
gcc/fortran/ChangeLog:

2014-11-23  Manuel López-Ibáñez  <manu@gcc.gnu.org>

PR fortran/44054
* decl.c (gfc_verify_c_interop_param): Use gfc_error_now_2.
(gfc_set_constant_character_len): Use gfc_warning_now_2.
* resolve.c (resolve_ordinary_assign): Likewise.
* gfortran.h (warn_character_truncation): Do not declare here.
* error.c (gfc_format_decoder): Handle %L.
* lang.opt (Wcharacter-truncation): Add Var and LangEnabledBy.
* options.c (gfc_init_options): Do not handle
warn_character_truncation explicitly.
(set_Wall): Likewise.
(gfc_handle_option): Likewise.

From-SVN: r217992

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/fortran/error.c
gcc/fortran/gfortran.h
gcc/fortran/lang.opt
gcc/fortran/options.c
gcc/fortran/resolve.c

index 41169a856af55e6bdaf1ff57bc309c3efbd6851f..b79f9c23be55264f2c1566312fe6cb6b583799c2 100644 (file)
@@ -1,3 +1,17 @@
+2014-11-23  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR fortran/44054
+       * decl.c (gfc_verify_c_interop_param): Use gfc_error_now_2.
+       (gfc_set_constant_character_len): Use gfc_warning_now_2.
+       * resolve.c (resolve_ordinary_assign): Likewise.
+       * gfortran.h (warn_character_truncation): Do not declare here.
+       * error.c (gfc_format_decoder): Handle %L.
+       * lang.opt (Wcharacter-truncation): Add Var and LangEnabledBy.
+       * options.c (gfc_init_options): Do not handle
+       warn_character_truncation explicitly.
+       (set_Wall): Likewise.
+       (gfc_handle_option): Likewise.
+
 2014-11-23  Tobias Burnus  <burnus@net-b.de>
 
        * invoke.texi (-Wtabs): Swap -Wtabs/-Wno-tabs now that
index e4e41cbe0c1f1eeef4bc9ffbf0706b1ad592d86a..45e5b6c2cd9d06d3317f80e7e052270e15ea714e 100644 (file)
@@ -990,10 +990,9 @@ gfc_verify_c_interop_param (gfc_symbol *sym)
     {
       if (sym->attr.is_bind_c == 0)
         {
-          gfc_error_now ("Procedure '%s' at %L must have the BIND(C) "
-                         "attribute to be C interoperable", sym->name,
-                         &(sym->declared_at));
-
+          gfc_error_now_2 ("Procedure %qs at %L must have the BIND(C) "
+                          "attribute to be C interoperable", sym->name,
+                          &(sym->declared_at));
           return false;
         }
       else
@@ -1224,9 +1223,10 @@ gfc_set_constant_character_len (int len, gfc_expr *expr, int check_len)
       if (len > slen)
        gfc_wide_memset (&s[slen], ' ', len - slen);
 
-      if (gfc_option.warn_character_truncation && slen > len)
-       gfc_warning_now ("CHARACTER expression at %L is being truncated "
-                        "(%d/%d)", &expr->where, slen, len);
+      if (warn_character_truncation && slen > len)
+       gfc_warning_now_2 (OPT_Wcharacter_truncation,
+                          "CHARACTER expression at %L is being truncated "
+                          "(%d/%d)", &expr->where, slen, len);
 
       /* Apply the standard by 'hand' otherwise it gets cleared for
         initializers.  */
index 0f85b496ecf89776bce4ce83b73e671f8993f7a9..471e0ecc86061976fb4fb3c9bedd479a859a9674 100644 (file)
@@ -964,6 +964,7 @@ gfc_warning_now (const char *gmsgid, ...)
    to handle Fortran specific format specifiers with the following meanings:
 
    %C  Current locus (no argument)
+   %L  Takes locus argument
 */
 static bool
 gfc_format_decoder (pretty_printer *pp,
@@ -974,15 +975,21 @@ gfc_format_decoder (pretty_printer *pp,
   switch (*spec)
     {
     case 'C':
+    case 'L':
       {
        static const char *result = "(1)";
-       gcc_assert (gfc_current_locus.nextc - gfc_current_locus.lb->line >= 0);
-       unsigned int c1 = gfc_current_locus.nextc - gfc_current_locus.lb->line;
+       locus *loc;
+       if (*spec == 'C')
+         loc = &gfc_current_locus;
+       else
+         loc = va_arg (*text->args_ptr, locus *);
+       gcc_assert (loc->nextc - loc->lb->line >= 0);
+       unsigned int offset = loc->nextc - loc->lb->line;
        gcc_assert (text->locus);
        *text->locus
          = linemap_position_for_loc_and_offset (line_table,
-                                                gfc_current_locus.lb->location,
-                                                c1);
+                                                loc->lb->location,
+                                                offset);
        global_dc->caret_char = '1';
        pp_string (pp, result);
        return true;
index 1ee7dd497955b0b4b29525be6decc2394f2dc6b5..63a8d1508ad306449140fc916e28036be2875cf9 100644 (file)
@@ -2455,7 +2455,6 @@ typedef struct
   int warn_underflow;
   int warn_intrinsic_shadow;
   int warn_intrinsics_std;
-  int warn_character_truncation;
   int warn_array_temp;
   int warn_align_commons;
   int warn_real_q_constant;
index 5da0453b9beda71e0f86a811b86bddf0127749f8..bac7dce8040fab68d89c1da34020a03fc5cd4e61 100644 (file)
@@ -218,7 +218,7 @@ Fortran
 ; Documented in C
 
 Wcharacter-truncation
-Fortran Warning
+Fortran Var(warn_character_truncation) Warning LangEnabledBy(Fortran,Wall)
 Warn about truncated character expressions
 
 Wcompare-reals
index dee1af48a7c60b04e68093923ec222387511d3a6..0dd0118cdd4d0b1dbb883f577c5bd0a92f7d2316 100644 (file)
@@ -95,7 +95,6 @@ gfc_init_options (unsigned int decoded_options_count,
 
   gfc_option.warn_aliasing = 0;
   gfc_option.warn_ampersand = 0;
-  gfc_option.warn_character_truncation = 0;
   gfc_option.warn_array_temp = 0;
   gfc_option.warn_c_binding_type = 0;
   gfc_option.gfc_warn_conversion = 0;
@@ -460,7 +459,6 @@ set_Wall (int setting)
   gfc_option.warn_underflow = setting;
   gfc_option.warn_intrinsic_shadow = setting;
   gfc_option.warn_intrinsics_std = setting;
-  gfc_option.warn_character_truncation = setting;
   gfc_option.warn_real_q_constant = setting;
   gfc_option.warn_unused_dummy_argument = setting;
   gfc_option.warn_target_lifetime = setting;
@@ -663,10 +661,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
       gfc_option.warn_c_binding_type = value;
       break;
 
-    case OPT_Wcharacter_truncation:
-      gfc_option.warn_character_truncation = value;
-      break;
-
     case OPT_Wcompare_reals:
       gfc_option.warn_compare_reals = value;
       break;
index 4acebd0a3b9cd74d169f2e7aba4d9adcfd283db5..6dc15857559b003c5b3ba7f54c2700fb1b667f4d 100644 (file)
@@ -9208,7 +9208,7 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace *ns)
     }
 
   if (lhs->ts.type == BT_CHARACTER
-       && gfc_option.warn_character_truncation)
+       && warn_character_truncation)
     {
       if (lhs->ts.u.cl != NULL
            && lhs->ts.u.cl->length != NULL
@@ -9224,9 +9224,10 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace *ns)
        rlen = mpz_get_si (rhs->ts.u.cl->length->value.integer);
 
       if (rlen && llen && rlen > llen)
-       gfc_warning_now ("CHARACTER expression will be truncated "
-                        "in assignment (%d/%d) at %L",
-                        llen, rlen, &code->loc);
+       gfc_warning_now_2 (OPT_Wcharacter_truncation,
+                          "CHARACTER expression will be truncated "
+                          "in assignment (%d/%d) at %L",
+                          llen, rlen, &code->loc);
     }
 
   /* Ensure that a vector index expression for the lvalue is evaluated