]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fortran: Add support for per-location warning groups.
authorMartin Sebor <msebor@redhat.com>
Mon, 28 Jun 2021 20:47:21 +0000 (14:47 -0600)
committerMartin Sebor <msebor@redhat.com>
Mon, 28 Jun 2021 20:47:21 +0000 (14:47 -0600)
gcc/fortran/ChangeLog:

* trans-array.c (trans_array_constructor): Replace direct uses
of TREE_NO_WARNING with warning_suppressed_p, and suppress_warning.
* trans-decl.c (gfc_build_qualified_array): Same.
(gfc_build_dummy_array_decl): Same.
(generate_local_decl): Same.
(gfc_generate_function_code): Same.
* trans-openmp.c (gfc_omp_clause_default_ctor): Same.
(gfc_omp_clause_copy_ctor): Same.
* trans-types.c (get_dtype_type_node): Same.
(gfc_get_desc_dim_type): Same.
(gfc_get_array_descriptor_base): Same.
(gfc_get_caf_vector_type): Same.
(gfc_get_caf_reference_type): Same.
* trans.c (gfc_create_var_np): Same.

gcc/fortran/trans-array.c
gcc/fortran/trans-decl.c
gcc/fortran/trans-openmp.c
gcc/fortran/trans-types.c
gcc/fortran/trans.c

index a6bcd2b5ab75504bacc32b4b4077e9b3f244a332..0d013defdbbf1d3bbb3995436e7f5ed51af06751 100644 (file)
@@ -2764,7 +2764,7 @@ trans_array_constructor (gfc_ss * ss, locus * where)
   desc = ss_info->data.array.descriptor;
   offset = gfc_index_zero_node;
   offsetvar = gfc_create_var_np (gfc_array_index_type, "offset");
-  TREE_NO_WARNING (offsetvar) = 1;
+  suppress_warning (offsetvar);
   TREE_USED (offsetvar) = 0;
   gfc_trans_array_constructor_value (&outer_loop->pre, type, desc, c,
                                     &offset, &offsetvar, dynamic);
index 479ba6fa6ce962025a37294b31af311e6a96af92..a73ce8a3f40c978a4a40da0c4890f433989b84cd 100644 (file)
@@ -1045,7 +1045,7 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
       if (GFC_TYPE_ARRAY_LBOUND (type, dim) == NULL_TREE)
        {
          GFC_TYPE_ARRAY_LBOUND (type, dim) = create_index_var ("lbound", nest);
-         TREE_NO_WARNING (GFC_TYPE_ARRAY_LBOUND (type, dim)) = 1;
+         suppress_warning (GFC_TYPE_ARRAY_LBOUND (type, dim));
        }
       /* Don't try to use the unknown bound for assumed shape arrays.  */
       if (GFC_TYPE_ARRAY_UBOUND (type, dim) == NULL_TREE
@@ -1053,13 +1053,13 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
              || dim < GFC_TYPE_ARRAY_RANK (type) - 1))
        {
          GFC_TYPE_ARRAY_UBOUND (type, dim) = create_index_var ("ubound", nest);
-         TREE_NO_WARNING (GFC_TYPE_ARRAY_UBOUND (type, dim)) = 1;
+         suppress_warning (GFC_TYPE_ARRAY_UBOUND (type, dim));
        }
 
       if (GFC_TYPE_ARRAY_STRIDE (type, dim) == NULL_TREE)
        {
          GFC_TYPE_ARRAY_STRIDE (type, dim) = create_index_var ("stride", nest);
-         TREE_NO_WARNING (GFC_TYPE_ARRAY_STRIDE (type, dim)) = 1;
+         suppress_warning (GFC_TYPE_ARRAY_STRIDE (type, dim));
        }
     }
   for (dim = GFC_TYPE_ARRAY_RANK (type);
@@ -1068,21 +1068,21 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
       if (GFC_TYPE_ARRAY_LBOUND (type, dim) == NULL_TREE)
        {
          GFC_TYPE_ARRAY_LBOUND (type, dim) = create_index_var ("lbound", nest);
-         TREE_NO_WARNING (GFC_TYPE_ARRAY_LBOUND (type, dim)) = 1;
+         suppress_warning (GFC_TYPE_ARRAY_LBOUND (type, dim));
        }
       /* Don't try to use the unknown ubound for the last coarray dimension.  */
       if (GFC_TYPE_ARRAY_UBOUND (type, dim) == NULL_TREE
           && dim < GFC_TYPE_ARRAY_RANK (type) + GFC_TYPE_ARRAY_CORANK (type) - 1)
        {
          GFC_TYPE_ARRAY_UBOUND (type, dim) = create_index_var ("ubound", nest);
-         TREE_NO_WARNING (GFC_TYPE_ARRAY_UBOUND (type, dim)) = 1;
+         suppress_warning (GFC_TYPE_ARRAY_UBOUND (type, dim));
        }
     }
   if (GFC_TYPE_ARRAY_OFFSET (type) == NULL_TREE)
     {
       GFC_TYPE_ARRAY_OFFSET (type) = gfc_create_var_np (gfc_array_index_type,
                                                        "offset");
-      TREE_NO_WARNING (GFC_TYPE_ARRAY_OFFSET (type)) = 1;
+      suppress_warning (GFC_TYPE_ARRAY_OFFSET (type));
 
       if (nest)
        gfc_add_decl_to_parent_function (GFC_TYPE_ARRAY_OFFSET (type));
@@ -1094,7 +1094,7 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
       && as->type != AS_ASSUMED_SIZE)
     {
       GFC_TYPE_ARRAY_SIZE (type) = create_index_var ("size", nest);
-      TREE_NO_WARNING (GFC_TYPE_ARRAY_SIZE (type)) = 1;
+      suppress_warning (GFC_TYPE_ARRAY_SIZE (type));
     }
 
   if (POINTER_TYPE_P (type))
@@ -1299,7 +1299,7 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy)
 
   /* Avoid uninitialized warnings for optional dummy arguments.  */
   if (sym->attr.optional)
-    TREE_NO_WARNING (decl) = 1;
+    suppress_warning (decl);
 
   /* We should never get deferred shape arrays here.  We used to because of
      frontend bugs.  */
@@ -5986,7 +5986,7 @@ generate_local_decl (gfc_symbol * sym)
                             "does not have a default initializer",
                             sym->name, &sym->declared_at);
              if (sym->backend_decl != NULL_TREE)
-               TREE_NO_WARNING(sym->backend_decl) = 1;
+               suppress_warning (sym->backend_decl);
            }
          else if (warn_unused_dummy_argument)
            {
@@ -5996,7 +5996,7 @@ generate_local_decl (gfc_symbol * sym)
                             &sym->declared_at);
 
              if (sym->backend_decl != NULL_TREE)
-               TREE_NO_WARNING(sym->backend_decl) = 1;
+               suppress_warning (sym->backend_decl);
            }
        }
 
@@ -6012,7 +6012,7 @@ generate_local_decl (gfc_symbol * sym)
                           "explicitly imported at %L", sym->name,
                           &sym->declared_at);
              if (sym->backend_decl != NULL_TREE)
-               TREE_NO_WARNING(sym->backend_decl) = 1;
+               suppress_warning (sym->backend_decl);
            }
          else if (!sym->attr.use_assoc)
            {
@@ -6030,7 +6030,7 @@ generate_local_decl (gfc_symbol * sym)
                             "Unused variable %qs declared at %L",
                             sym->name, &sym->declared_at);
              if (sym->backend_decl != NULL_TREE)
-               TREE_NO_WARNING(sym->backend_decl) = 1;
+               suppress_warning (sym->backend_decl);
            }
        }
 
@@ -6145,7 +6145,7 @@ generate_local_decl (gfc_symbol * sym)
          /* Silence bogus "unused parameter" warnings from the
             middle end.  */
          if (sym->backend_decl != NULL_TREE)
-               TREE_NO_WARNING (sym->backend_decl) = 1;
+               suppress_warning (sym->backend_decl);
        }
     }
 
@@ -6976,7 +6976,7 @@ gfc_generate_function_code (gfc_namespace * ns)
                         "Return value of function %qs at %L not set",
                         sym->name, &sym->declared_at);
          if (warn_return_type > 0)
-           TREE_NO_WARNING(sym->backend_decl) = 1;
+           suppress_warning (sym->backend_decl);
        }
       if (result != NULL_TREE)
        gfc_add_expr_to_block (&body, gfc_generate_return ());
index ce1991e366bf9835e92d7fa69a75a7850c36ff5d..ace4faf038a18312b87ebd31d69d53613ce153e0 100644 (file)
@@ -785,7 +785,7 @@ gfc_omp_clause_default_ctor (tree clause, tree decl, tree outer)
                                         else_b));
       /* Avoid -W*uninitialized warnings.  */
       if (DECL_P (decl))
-       TREE_NO_WARNING (decl) = 1;
+       suppress_warning (decl, OPT_Wuninitialized);
     }
   else
     gfc_add_expr_to_block (&block, then_b);
@@ -970,7 +970,7 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src)
                                     void_type_node, cond, then_b, else_b));
   /* Avoid -W*uninitialized warnings.  */
   if (DECL_P (dest))
-    TREE_NO_WARNING (dest) = 1;
+    suppress_warning (dest, OPT_Wuninitialized);
 
   return gfc_finish_block (&block);
 }
index 5582e404df9d99daf5790b171a37b1963bd89f94..d715838a0463167cadea458eebc4dba4fa785571 100644 (file)
@@ -150,23 +150,23 @@ tree get_dtype_type_node (void)
       field = gfc_add_field_to_struct_1 (dtype_node,
                                         get_identifier ("elem_len"),
                                         size_type_node, &dtype_chain);
-      TREE_NO_WARNING (field) = 1;
+      suppress_warning (field);
       field = gfc_add_field_to_struct_1 (dtype_node,
                                         get_identifier ("version"),
                                         integer_type_node, &dtype_chain);
-      TREE_NO_WARNING (field) = 1;
+      suppress_warning (field);
       field = gfc_add_field_to_struct_1 (dtype_node,
                                         get_identifier ("rank"),
                                         signed_char_type_node, &dtype_chain);
-      TREE_NO_WARNING (field) = 1;
+      suppress_warning (field);
       field = gfc_add_field_to_struct_1 (dtype_node,
                                         get_identifier ("type"),
                                         signed_char_type_node, &dtype_chain);
-      TREE_NO_WARNING (field) = 1;
+      suppress_warning (field);
       field = gfc_add_field_to_struct_1 (dtype_node,
                                         get_identifier ("attribute"),
                                         short_integer_type_node, &dtype_chain);
-      TREE_NO_WARNING (field) = 1;
+      suppress_warning (field);
       gfc_finish_type (dtype_node);
       TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (dtype_node)) = 1;
       dtype_type_node = dtype_node;
@@ -1453,17 +1453,17 @@ gfc_get_desc_dim_type (void)
   decl = gfc_add_field_to_struct_1 (type,
                                    get_identifier ("stride"),
                                    gfc_array_index_type, &chain);
-  TREE_NO_WARNING (decl) = 1;
+  suppress_warning (decl);
 
   decl = gfc_add_field_to_struct_1 (type,
                                    get_identifier ("lbound"),
                                    gfc_array_index_type, &chain);
-  TREE_NO_WARNING (decl) = 1;
+  suppress_warning (decl);
 
   decl = gfc_add_field_to_struct_1 (type,
                                    get_identifier ("ubound"),
                                    gfc_array_index_type, &chain);
-  TREE_NO_WARNING (decl) = 1;
+  suppress_warning (decl);
 
   /* Finish off the type.  */
   gfc_finish_type (type);
@@ -1853,19 +1853,19 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted)
   decl = gfc_add_field_to_struct_1 (fat_type,
                                    get_identifier ("offset"),
                                    gfc_array_index_type, &chain);
-  TREE_NO_WARNING (decl) = 1;
+  suppress_warning (decl);
 
   /* Add the dtype component.  */
   decl = gfc_add_field_to_struct_1 (fat_type,
                                    get_identifier ("dtype"),
                                    get_dtype_type_node (), &chain);
-  TREE_NO_WARNING (decl) = 1;
+  suppress_warning (decl);
 
   /* Add the span component.  */
   decl = gfc_add_field_to_struct_1 (fat_type,
                                    get_identifier ("span"),
                                    gfc_array_index_type, &chain);
-  TREE_NO_WARNING (decl) = 1;
+  suppress_warning (decl);
 
   /* Build the array type for the stride and bound components.  */
   if (dimen + codimen > 0)
@@ -1878,7 +1878,7 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted)
 
       decl = gfc_add_field_to_struct_1 (fat_type, get_identifier ("dim"),
                                        arraytype, &chain);
-      TREE_NO_WARNING (decl) = 1;
+      suppress_warning (decl);
     }
 
   if (flag_coarray == GFC_FCOARRAY_LIB)
@@ -1886,7 +1886,7 @@ gfc_get_array_descriptor_base (int dimen, int codimen, bool restricted)
       decl = gfc_add_field_to_struct_1 (fat_type,
                                        get_identifier ("token"),
                                        prvoid_type_node, &chain);
-      TREE_NO_WARNING (decl) = 1;
+      suppress_warning (decl);
     }
 
   /* Finish off the type.  */
@@ -2882,7 +2882,7 @@ copy_derived_types:
          token = gfc_find_component (derived, caf_name, true, true, NULL);
          gcc_assert (token);
          c->caf_token = token->backend_decl;
-         TREE_NO_WARNING (c->caf_token) = 1;
+         suppress_warning (c->caf_token);
        }
     }
 
@@ -3547,11 +3547,11 @@ gfc_get_caf_vector_type (int dim)
       tmp = gfc_add_field_to_struct_1 (vect_struct_type,
                                       get_identifier ("vector"),
                                       pvoid_type_node, &chain);
-      TREE_NO_WARNING (tmp) = 1;
+      suppress_warning (tmp);
       tmp = gfc_add_field_to_struct_1 (vect_struct_type,
                                       get_identifier ("kind"),
                                       integer_type_node, &chain);
-      TREE_NO_WARNING (tmp) = 1;
+      suppress_warning (tmp);
       gfc_finish_type (vect_struct_type);
 
       chain = 0;
@@ -3559,34 +3559,34 @@ gfc_get_caf_vector_type (int dim)
       tmp = gfc_add_field_to_struct_1 (triplet_struct_type,
                                       get_identifier ("lower_bound"),
                                       gfc_array_index_type, &chain);
-      TREE_NO_WARNING (tmp) = 1;
+      suppress_warning (tmp);
       tmp = gfc_add_field_to_struct_1 (triplet_struct_type,
                                       get_identifier ("upper_bound"),
                                       gfc_array_index_type, &chain);
-      TREE_NO_WARNING (tmp) = 1;
+      suppress_warning (tmp);
       tmp = gfc_add_field_to_struct_1 (triplet_struct_type, get_identifier ("stride"),
                                       gfc_array_index_type, &chain);
-      TREE_NO_WARNING (tmp) = 1;
+      suppress_warning (tmp);
       gfc_finish_type (triplet_struct_type);
 
       chain = 0;
       union_type = make_node (UNION_TYPE);
       tmp = gfc_add_field_to_struct_1 (union_type, get_identifier ("v"),
                                        vect_struct_type, &chain);
-      TREE_NO_WARNING (tmp) = 1;
+      suppress_warning (tmp);
       tmp = gfc_add_field_to_struct_1 (union_type, get_identifier ("triplet"),
                                       triplet_struct_type, &chain);
-      TREE_NO_WARNING (tmp) = 1;
+      suppress_warning (tmp);
       gfc_finish_type (union_type);
 
       chain = 0;
       vec_type = make_node (RECORD_TYPE);
       tmp = gfc_add_field_to_struct_1 (vec_type, get_identifier ("nvec"),
                                       size_type_node, &chain);
-      TREE_NO_WARNING (tmp) = 1;
+      suppress_warning (tmp);
       tmp = gfc_add_field_to_struct_1 (vec_type, get_identifier ("u"),
                                       union_type, &chain);
-      TREE_NO_WARNING (tmp) = 1;
+      suppress_warning (tmp);
       gfc_finish_type (vec_type);
       TYPE_NAME (vec_type) = get_identifier ("caf_vector_t");
     }
@@ -3613,11 +3613,11 @@ gfc_get_caf_reference_type ()
   tmp = gfc_add_field_to_struct_1 (c_struct_type,
                                   get_identifier ("offset"),
                                   gfc_array_index_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (c_struct_type,
                                   get_identifier ("caf_token_offset"),
                                   gfc_array_index_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   gfc_finish_type (c_struct_type);
 
   chain = 0;
@@ -3625,15 +3625,15 @@ gfc_get_caf_reference_type ()
   tmp = gfc_add_field_to_struct_1 (s_struct_type,
                                   get_identifier ("start"),
                                   gfc_array_index_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (s_struct_type,
                                   get_identifier ("end"),
                                   gfc_array_index_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (s_struct_type,
                                   get_identifier ("stride"),
                                   gfc_array_index_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   gfc_finish_type (s_struct_type);
 
   chain = 0;
@@ -3641,25 +3641,25 @@ gfc_get_caf_reference_type ()
   tmp = gfc_add_field_to_struct_1 (v_struct_type,
                                   get_identifier ("vector"),
                                   pvoid_type_node, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (v_struct_type,
                                   get_identifier ("nvec"),
                                   size_type_node, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (v_struct_type,
                                   get_identifier ("kind"),
                                   integer_type_node, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   gfc_finish_type (v_struct_type);
 
   chain = 0;
   union_type = make_node (UNION_TYPE);
   tmp = gfc_add_field_to_struct_1 (union_type, get_identifier ("s"),
                                   s_struct_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (union_type, get_identifier ("v"),
                                   v_struct_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   gfc_finish_type (union_type);
 
   tmp = build_range_type (gfc_array_index_type, gfc_index_zero_node,
@@ -3674,40 +3674,40 @@ gfc_get_caf_reference_type ()
                                                    gfc_index_zero_node,
                                         gfc_rank_cst[GFC_MAX_DIMENSIONS - 1])),
                &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (a_struct_type,
                                   get_identifier ("static_array_type"),
                                   integer_type_node, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (a_struct_type, get_identifier ("dim"),
                                   dim_union_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   gfc_finish_type (a_struct_type);
 
   chain = 0;
   u_union_type = make_node (UNION_TYPE);
   tmp = gfc_add_field_to_struct_1 (u_union_type, get_identifier ("c"),
                                   c_struct_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (u_union_type, get_identifier ("a"),
                                   a_struct_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   gfc_finish_type (u_union_type);
 
   chain = 0;
   reference_type = make_node (RECORD_TYPE);
   tmp = gfc_add_field_to_struct_1 (reference_type, get_identifier ("next"),
                                   build_pointer_type (reference_type), &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (reference_type, get_identifier ("type"),
                                   integer_type_node, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (reference_type, get_identifier ("item_size"),
                                   size_type_node, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   tmp = gfc_add_field_to_struct_1 (reference_type, get_identifier ("u"),
                                   u_union_type, &chain);
-  TREE_NO_WARNING (tmp) = 1;
+  suppress_warning (tmp);
   gfc_finish_type (reference_type);
   TYPE_NAME (reference_type) = get_identifier ("caf_reference_t");
 
index f26e91b29e20690165481496272408866492b7b5..275d6a28f1c053072765097b0ed08fa6d80f6e6e 100644 (file)
@@ -129,7 +129,7 @@ gfc_create_var_np (tree type, const char *prefix)
 
   /* No warnings for anonymous variables.  */
   if (prefix == NULL)
-    TREE_NO_WARNING (t) = 1;
+    suppress_warning (t);
 
   return t;
 }