https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96320

--- Comment #18 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
With

--- ../_clean/gcc/fortran/interface.c   2020-07-11 20:06:47.000000000 +0200
+++ gcc/fortran/interface.c     2020-07-28 11:41:57.000000000 +0200
@@ -1466,8 +1466,19 @@ gfc_check_dummy_characteristics (gfc_sym
       int i, compval;
       gfc_expr *shape1, *shape2;

+      if (s1->ns->proc_name && s1->ns->proc_name->attr.module_procedure
+         && s1->as->type == AS_ASSUMED_SHAPE
+         && s2->as->type == AS_DEFERRED)
+       {
+         s2->as->type = AS_ASSUMED_SHAPE;
+         for (i = 0; i < s2->as->rank; i++)
+           if (s1->as->lower[i] != NULL)
+             s2->as->lower[i] = gfc_copy_expr (s1->as->lower[i]);
+       }
+
       if (s1->as->type != s2->as->type)
        {
+/*       gfc_warning_now (0, "s1 %i   s2 %i \n", s1->as->type, s2->as->type);
*/
          snprintf (errmsg, err_len, "Shape mismatch in argument '%s'",
                    s1->name);
          return false;

the patch regtest without regression.

> > /opt/gcc/work/gcc/testsuite/gfortran.dg/whole_file_23.f90:18:32:
> > 
> >    18 |     pure integer function lensum (words, sep)
> > Warning: Interface mismatch in global procedure 'lensum' at (1): Shape 
> > mismatch
> > in argument 'words'
> 
> So, change the dg-error to "Interface mismatch in"  from
> "Shape mismatch in".  Clearly, Paul's patch detects an
> error earlier in the parsing than previously detected.

The warning is at least as old as GCC7 but is suppressed in the testsuite by
-pedantic-errors (very surprising) thus doesn't fail.

Reply via email to