]> gcc.gnu.org Git - gcc.git/commitdiff
Fortran : Spurious warning message with -Wsurprising PR59107
authorMark Eggleston <markeggleston@gcc.gnu.org>
Thu, 23 Apr 2020 09:33:14 +0000 (10:33 +0100)
committerMark Eggleston <markeggleston@gcc.gnu.org>
Mon, 11 May 2020 08:27:32 +0000 (09:27 +0100)
This change is from a patch developed for gcc-5.  The code
has moved on since then requiring a change to interface.c

2020-05-11  Janus Weil  <janus@gcc.gnu.org>
    Dominique d'Humieres  <dominiq@lps.ens.fr>

gcc/fortran/

PR fortran/59107
* gfortran.h: Rename field resolved as resolve_symbol_called
and assign two 2 bits instead of 1.
* interface.c (check_dtio_interface1): Use new field name.
(gfc_find_typebound_dtio_proc): Use new field name.
* resolve.c (gfc_resolve_intrinsic): Replace check of the formal
field with resolve_symbol_called is at least 2, if it is not
set the field to 2.  (resolve_typebound_procedure): Use new field
name.  (resolve_symbol): Use new field name and check whether it
is at least 1, if it is not set the field to 1.

2020-05-11  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/

PR fortran/59107
* gfortran.dg/pr59107.f90: New test.

gcc/fortran/ChangeLog
gcc/fortran/gfortran.h
gcc/fortran/interface.c
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr59107.f90 [new file with mode: 0644]

index 6f1db3890f960a9432dc2c7976d7539b2532a4de..005f68668dd2cdd8e2b2a1f4266135c860c80c0a 100644 (file)
@@ -1,3 +1,17 @@
+2020-05-11  Janus Weil  <janus@gcc.gnu.org>
+           Dominique d'Humieres  <dominiq@lps.ens.fr>
+    
+       PR fortran/59107
+       * gfortran.h: Rename field resolved as resolve_symbol_called
+       and assign two 2 bits instead of 1.
+       * interface.c (check_dtio_interface1): Use new field name.
+       (gfc_find_typebound_dtio_proc): Use new field name.
+       * resolve.c (gfc_resolve_intrinsic): Replace check of the formal
+       field with resolve_symbol_called is at least 2, if it is not
+       set the field to 2.  (resolve_typebound_procedure): Use new field
+       name.  (resolve_symbol): Use new field name and check whether it
+       is at least 1, if it is not set the field to 1.
+
 2020-05-10  Harald Anlauf  <anlauf@gmx.de>
 
        PR fortran/93499
index 4e1da8c88a030750d21c264c37d0e78bf736263b..7094791e8716c4dd9129fd29b8bd5b05d87f2f3b 100644 (file)
@@ -1621,7 +1621,10 @@ typedef struct gfc_symbol
   /* Set if the symbol is used in a function result specification .  */
   unsigned fn_result_spec:1;
   /* Used to avoid multiple resolutions of a single symbol.  */
-  unsigned resolved:1;
+  /* = 2 if this has already been resolved as an intrinsic,
+       in gfc_resolve_intrinsic,
+     = 1 if it has been resolved in resolve_symbol.  */
+  unsigned resolve_symbol_called:2;
   /* Set if this is a module function or subroutine with the
      abreviated declaration in a submodule.  */
   unsigned abr_modproc_decl:1;
index ba1c8bc322eade13caf726aae58b242e375bb02a..f33c6632b45b53033367d671a3da95af982aae94 100644 (file)
@@ -5015,7 +5015,7 @@ check_dtio_interface1 (gfc_symbol *derived, gfc_symtree *tb_io_st,
     gfc_error ("DTIO procedure %qs at %L must be a subroutine",
               dtio_sub->name, &dtio_sub->declared_at);
 
-  if (!dtio_sub->resolved)
+  if (!dtio_sub->resolve_symbol_called)
     gfc_resolve_formal_arglist (dtio_sub);
 
   arg_num = 0;
@@ -5149,7 +5149,8 @@ gfc_find_typebound_dtio_proc (gfc_symbol *derived, bool write, bool formatted)
   gfc_symtree *tb_io_st = NULL;
   bool t = false;
 
-  if (!derived || !derived->resolved || derived->attr.flavor != FL_DERIVED)
+  if (!derived || !derived->resolve_symbol_called
+      || derived->attr.flavor != FL_DERIVED)
     return NULL;
 
   /* Try to find a typebound DTIO binding.  */
index fd3b025a84ffb74415c5f4eab9cf1902eaac126a..88ba88d8bf300e676f06ff76fc5194d841b5331b 100644 (file)
@@ -1753,9 +1753,11 @@ gfc_resolve_intrinsic (gfc_symbol *sym, locus *loc)
   gfc_intrinsic_sym* isym = NULL;
   const char* symstd;
 
-  if (sym->formal)
+  if (sym->resolve_symbol_called >= 2)
     return true;
 
+  sym->resolve_symbol_called = 2;
+
   /* Already resolved.  */
   if (sym->from_intmod && sym->ts.type != BT_UNKNOWN)
     return true;
@@ -13909,7 +13911,7 @@ resolve_typebound_procedure (gfc_symtree* stree)
     {
       /* If proc has not been resolved at this point, proc->name may
         actually be a USE associated entity. See PR fortran/89647. */
-      if (!proc->resolved
+      if (!proc->resolve_symbol_called
          && proc->attr.function == 0 && proc->attr.subroutine == 0)
        {
          gfc_symbol *tmp;
@@ -15154,9 +15156,9 @@ resolve_symbol (gfc_symbol *sym)
   gfc_array_spec *as;
   bool saved_specification_expr;
 
-  if (sym->resolved)
+  if (sym->resolve_symbol_called >= 1)
     return;
-  sym->resolved = 1;
+  sym->resolve_symbol_called = 1;
 
   /* No symbol will ever have union type; only components can be unions.
      Union type declaration symbols have type BT_UNKNOWN but flavor FL_UNION
index aa11ca3fd993ab7b26fac2fd7f5afd45ffb3b472..ea329c740a36cd62f87a25be15931543a238070b 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-11  Mark Eggleston  <markeggleston@gcc.gnu.org>
+    
+       PR fortran/59107
+       * gfortran.dg/pr59107.f90: New test.
+
 2020-05-11  Xiong Hu Luo  <luoxhu@linux.ibm.com>
 
        PR tree-optimization/83403
diff --git a/gcc/testsuite/gfortran.dg/pr59107.f90 b/gcc/testsuite/gfortran.dg/pr59107.f90
new file mode 100644 (file)
index 0000000..a84328f
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-compile }
+! { dg-options "-Wsurprising" }
+
+! There should be no surprising warnings
+
+program p
+  Integer :: nargs
+  intrinsic :: command_argument_count
+  nargs = command_argument_count()
+end
+
This page took 0.105482 seconds and 5 git commands to generate.