re PR fortran/35152 (Implicit procedure with keyword=argument is accepted)
authorDaniel Franke <franke.daniel@gmail.com>
Wed, 19 Mar 2008 19:13:48 +0000 (15:13 -0400)
committerDaniel Franke <dfranke@gcc.gnu.org>
Wed, 19 Mar 2008 19:13:48 +0000 (15:13 -0400)
gcc/fortran:
2008-03-19  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/35152
        * interface.c (gfc_procedure_use): Check for keyworded arguments in
        procedures without explicit interfaces.

gcc/testsuite:
2008-03-19  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/35152
        * gfortran.dg/argument_checking_16.f90: New test.

From-SVN: r133347

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

index 08f1a8c2c260657b4a6fe6e4d0c78c42db52f293..9254562afaeaa954798f6876a2d7fc3218f8ddaa 100644 (file)
@@ -1,3 +1,9 @@
+2008-03-19  Daniel Franke  <franke.daniel@gmail.com>
+
+       PR fortran/35152
+       * interface.c (gfc_procedure_use): Check for keyworded arguments in
+       procedures without explicit interfaces.
+
 2008-03-16  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/35470
index 4cee386d3d578362b0a9b27e0c8dcf8c25d568ed..09f72383b0f91e59b18bf702d236b607e245304a 100644 (file)
@@ -2419,9 +2419,26 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
        }
     }
 
-  if (sym->attr.if_source == IFSRC_UNKNOWN
-      || !compare_actual_formal (ap, sym->formal, 0,
-                                sym->attr.elemental, where))
+  if (sym->attr.external
+      || sym->attr.if_source == IFSRC_UNKNOWN)
+    {
+      gfc_actual_arglist *a;
+      for (a = *ap; a; a = a->next)
+       {
+         /* Skip g77 keyword extensions like %VAL, %REF, %LOC.  */
+         if (a->name != NULL && a->name[0] != '%')
+           {
+             gfc_error("Keyword argument requires explicit interface "
+                       "for procedure '%s' at %L", sym->name, &a->expr->where);
+             break;
+           }
+       }
+
+      return;
+    }
+
+  if (!compare_actual_formal (ap, sym->formal, 0,
+                             sym->attr.elemental, where))
     return;
 
   check_intents (sym->formal, *ap);
index 0781ed5e4beb3b8918bf1edca72cad4a881a5470..6557c0cafb1695dfe7a394db22b1ecc0aef98ce6 100644 (file)
@@ -1,3 +1,8 @@
+2008-03-19  Daniel Franke  <franke.daniel@gmail.com>
+
+       PR fortran/35152
+       * gfortran.dg/argument_checking_16.f90: New test.
+
 2008-03-19  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR libfortran/32972
diff --git a/gcc/testsuite/gfortran.dg/argument_checking_16.f90 b/gcc/testsuite/gfortran.dg/argument_checking_16.f90
new file mode 100644 (file)
index 0000000..75b2ece
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/35152 - implicit procedure with keyword=argument
+
+external bar
+
+call bar(a=5)       ! { dg-error "requires explicit interface" }
+call foo(a=5)       ! { dg-error "requires explicit interface" }
+end
+