This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/25071] dummy argument larger than actual argument


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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |janus at gcc dot gnu.org

--- Comment #16 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #15)
> The errors introduced at r124411 have been changed to warnings by Tobias
> Burnus at r126271

.. but only for the CHARACTER case. For non-character arrays there were never
any errors, and a warning has been added only in the second commit you mention.


> > Legacy code like the one in comment #11 should be allowed with -std=legacy
> > only (if at all).
> 
> If there is an agreement about that, this is something that I can handle.

I'm not sure if there will be any agreement about it, but in any case here is a
patch proposal:


Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c     (Revision 233007)
+++ gcc/fortran/interface.c     (Arbeitskopie)
@@ -2787,10 +2787,10 @@
                         f->sym->name, actual_size, formal_size,
                         &a->expr->where);
           else if (where)
-           gfc_warning (0, "Actual argument contains too few "
-                        "elements for dummy argument %qs (%lu/%lu) at %L",
-                        f->sym->name, actual_size, formal_size,
-                        &a->expr->where);
+           gfc_notify_std (GFC_STD_LEGACY, "Actual argument contains too few "
+                           "elements for dummy argument %qs (%lu/%lu) at %L",
+                           f->sym->name, actual_size, formal_size,
+                           &a->expr->where);
          return  0;
        }


On comment 0 this gives a hard error with -std=f95/f2003/f2008, a warning (as
before) with -std=gnu and no diagnostic at all with -std=legacy.

For comment 11 the behavior is almost unchanged, giving a warning for all -std
levels except legacy.

The patch does not trigger any failures in the testsuite, which is certainly a
good sign. It might still break some legacy codes, but they can just use
-std=legacy (which they probably already do). Everyone else will rather benefit
from the stricter diagnostics, I guess. It can catch some rather bad errors.

Any opinions on this?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]