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

--- Comment #12 from anlauf at gcc dot gnu.org ---
(In reply to kargls from comment #11)

I tried a simpler variation of your patch that aims at a more coherent
error message:

diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc
index f7cbb4bb5e2..28b27874298 100644
--- a/gcc/fortran/intrinsic.cc
+++ b/gcc/fortran/intrinsic.cc
@@ -4377,10 +4377,22 @@ sort_actual (const char *name, gfc_actual_arglist **ap,
   if (a == NULL)
     goto do_sort;

+  /* The generic interface of the following intrinsics was extended in F2008.
+     A specific interface may not be available at a selected standard.  */
+  if ((gfc_option.allow_std & GFC_STD_F2008) != 0
+      && (strcmp (name, "atan") == 0
+         || strcmp (name, "atand") == 0))
+    goto no_specific;
+
 whoops:
   gfc_error ("Too many arguments in call to %qs at %L", name, where);
   return false;

+no_specific:
+  gfc_error ("Generic function %qs at %L is not consistent with a "
+            "specific intrinsic interface", name, where);
+  return false;
+
 keywords:
   /* Associate the remaining actual arguments, all of which have
      to be keyword arguments.  */


With this you get the message:

Error: Generic function 'atan' at (1) is not consistent with a specific
intrinsic interface

whether atan is explicitly declared as intrinsic or not.

> Now, to real cause so head scratching.  keywords are not honored!
> 
> subroutine s3
>    real :: r = 1.
>    print *, atan (y=-1.d0,x=r)  ! Should give error similar to s1 case
> end
> 
> % gfcx -c a.f90
> a.f90:3:10:
> 
>      3 |   print *, atan (y=-1.d0,x=r)  ! Should give error similar to 
> s1 case
>        |          1
> Error: Cannot find keyword named ‘y’ in call to ‘atan’ at (1)
> 
> I think we need to rethink the handling of the 2 argument case, where we
> make the second argument optional.   Then, in gfc_check_atan, we need to
> swap expressions to align Y with arg1 and X with arg2.

Yes, this is because once a keyword is used, we never reach the check.
Which makes me think whether sort_actual is the right place for the check.

Is there any generic intrinsic where a keyword is needed for resolving?
Besides the weird ALLOCATED(), where there can be only one argument
(ARRAY or SCALAR), but then this is a fixed number.

Reply via email to