public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR fortran/83939 -- Enforce F2018 C15100
@ 2018-03-11 20:48 Steve Kargl
  2018-03-12  2:04 ` Jerry DeLisle
  0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2018-03-11 20:48 UTC (permalink / raw)
  To: fortran, gcc-patches

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

The attach patch enforces F2018:C15100.  Similar constraints are
present in older versions of the standard.  The patch and testcase
are sufficiently explanatory.  Regression tested on x86_64-*-freebsd.
OK to commit?


2018-03-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/83939
	* resolve.c (resolve_fl_procedure): Enforce F2018:C15100.
2018-03-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/83939
	* gfortran.dg/pr83939.f90
-- 
Steve

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

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 258433)
+++ gcc/fortran/resolve.c	(working copy)
@@ -12451,6 +12451,19 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag)
 	}
     }
 
+  /* F2018, C15100: "The result of an elemental function shall be scalar,
+     and shall not have the POINTER or ALLOCATABLE attribute."  The scalar
+     pointer is tested and caught elsewhere.  */
+  if (sym->attr.elemental && sym->result
+      && (sym->result->attr.allocatable || sym->result->attr.pointer))
+    {
+      gfc_error ("Function result variable %qs at %L of elemental "
+		 "function %qs shall not have an ALLOCATABLE or POINTER "
+		 "attribute", sym->result->name,
+		 &sym->result->declared_at, sym->name);
+      return false;
+    }
+
   if (sym->attr.is_bind_c && sym->attr.is_c_interop != 1)
     {
       gfc_formal_arglist *curr_arg;
Index: gcc/testsuite/gfortran.dg/pr83939.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr83939.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr83939.f90	(working copy)
@@ -0,0 +1,12 @@
+! { dg-do compile }
+elemental function f() result(s) ! { dg-error "shall not have an ALLOCATABLE or POINTER" }
+  allocatable s
+  allocate(s)
+  s = 3.5
+end function
+
+elemental function g() result(s) ! { dg-error "shall not have an ALLOCATABLE or POINTER" }
+  pointer s
+  allocate(s)
+  s = 3.5
+end function

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

* Re: [PATCH] PR fortran/83939 -- Enforce F2018 C15100
  2018-03-11 20:48 [PATCH] PR fortran/83939 -- Enforce F2018 C15100 Steve Kargl
@ 2018-03-12  2:04 ` Jerry DeLisle
  0 siblings, 0 replies; 2+ messages in thread
From: Jerry DeLisle @ 2018-03-12  2:04 UTC (permalink / raw)
  To: sgk, fortran, gcc-patches

On 03/11/2018 01:48 PM, Steve Kargl wrote:
> The attach patch enforces F2018:C15100.  Similar constraints are
> present in older versions of the standard.  The patch and testcase
> are sufficiently explanatory.  Regression tested on x86_64-*-freebsd.
> OK to commit?
> 

Looks OK Steve.

Jerry


> 
> 2018-03-11  Steven G. Kargl  <kargl@gcc.gnu.org>
> 
> 	PR fortran/83939
> 	* resolve.c (resolve_fl_procedure): Enforce F2018:C15100.
> 2018-03-11  Steven G. Kargl  <kargl@gcc.gnu.org>
> 
> 	PR fortran/83939
> 	* gfortran.dg/pr83939.f90
> 

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

end of thread, other threads:[~2018-03-12  2:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-11 20:48 [PATCH] PR fortran/83939 -- Enforce F2018 C15100 Steve Kargl
2018-03-12  2:04 ` Jerry DeLisle

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).