public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR fortran/84346 -- Keywords invalid in statement functions
@ 2018-02-22 22:43 Steve Kargl
  2018-02-23  6:05 ` Thomas Koenig
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2018-02-22 22:43 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

The attached patch fixes PR fortran/84346.  A statement
function always has an implicit interface.  The use of
keywords in a function with an implicit interface is 
invalid.  Regression tested on x86_64-*-freebsd.  OK
to commit?

2018-02-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/84346
	* interface.c (compare_actual_formal): Issue error if keyword is
	used in a statement function.

2018-02-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/84346
	* gfortran.dg/statement_function_1.f90: Update test.

-- 
Steve

[-- Attachment #2: pr84346.diff --]
[-- Type: text/x-diff, Size: 1309 bytes --]

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c	(revision 257695)
+++ gcc/fortran/interface.c	(working copy)
@@ -2865,6 +2865,13 @@ compare_actual_formal (gfc_actual_arglist **ap, gfc_fo
 
   for (a = actual; a; a = a->next, f = f->next)
     {
+      if (a->name != NULL && in_statement_function)
+	{
+	  gfc_error ("Keyword argument %qs at %L is invalid in "
+		     "a statement function", a->name, &a->expr->where);
+	  return false;
+	}
+
       /* Look for keywords but ignore g77 extensions like %VAL.  */
       if (a->name != NULL && a->name[0] != '%')
 	{
Index: gcc/testsuite/gfortran.dg/statement_function_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/statement_function_1.f90	(revision 257695)
+++ gcc/testsuite/gfortran.dg/statement_function_1.f90	(working copy)
@@ -19,10 +19,6 @@
       qofs(s, i) = i * s
       i = 42
       w = qofs(hh, i)
-!
-! The following line should cause an error, because keywords are not
-! allowed in a function with an implicit interface.
-!
-      w = qofs(i = i, s = hh)
+      w = qofs(i = i, s = hh) ! { dg-error "invalid in a statement function" }
       end subroutine step
 ! { dg-prune-output " Obsolescent feature" }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] PR fortran/84346 -- Keywords invalid in statement functions
  2018-02-22 22:43 [PATCH] PR fortran/84346 -- Keywords invalid in statement functions Steve Kargl
@ 2018-02-23  6:05 ` Thomas Koenig
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Koenig @ 2018-02-23  6:05 UTC (permalink / raw)
  To: sgk, fortran, gcc-patches

Hi Steve,

> The attached patch fixes PR fortran/84346.  A statement
> function always has an implicit interface.  The use of
> keywords in a function with an implicit interface is
> invalid.  Regression tested on x86_64-*-freebsd.  OK
> to commit?

OK.

Thanks for the patch!

Regards

	Thomas

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-23  6:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 22:43 [PATCH] PR fortran/84346 -- Keywords invalid in statement functions Steve Kargl
2018-02-23  6:05 ` Thomas Koenig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).