public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] Fix elemental diagnostic for polymorphic dummies
@ 2012-01-26 23:52 Tobias Burnus
  2012-01-27 12:24 ` Paul Richard Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2012-01-26 23:52 UTC (permalink / raw)
  To: gcc patches, gfortran

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

Dominique found out that there is no diagnostic for polymorphic arrays. 
This patch adds it.

 From the F2008 standard:

"C1289 All dummy arguments of an elemental procedure shall be scalar 
noncoarray dummy data objects and shall not have the POINTER or 
ALLOCATABLE attribute."

"An elemental subroutine has only scalar dummy arguments, but may have 
array actual arguments. In a reference to an elemental subroutine, 
either all actual arguments shall be scalar, or all actual arguments 
corresponding to INTENT (OUT) and INTENT (INOUT) dummy arguments shall 
be arrays of the same shape and the remaining actual arguments shall be 
conformable with them."


Build and currently regtesting on x86-64-linux.
OK for the trunk?

Tobias

[-- Attachment #2: poly-elem-check.diff --]
[-- Type: text/x-patch, Size: 2608 bytes --]

2012-01-27  Tobias Burnus  <burnus@net-b.de>

	* resolve.c (resolve_formal_arglist): Fix elemental
	constraint checks for polymorphic dummies.

2012-01-27  Tobias Burnus  <burnus@net-b.de>

	* gfortran.dg/elemental_args_check_5.f90: New.


Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(Revision 183575)
+++ gcc/fortran/resolve.c	(Arbeitskopie)
@@ -374,21 +374,26 @@ resolve_formal_arglist (gfc_symbol *proc)
       if (gfc_elemental (proc))
 	{
 	  /* F08:C1289.  */
-	  if (sym->attr.codimension)
+	  if (sym->attr.codimension
+	      || (sym->ts.type == BT_CLASS && CLASS_DATA (sym)
+		  && CLASS_DATA (sym)->attr.codimension))
 	    {
 	      gfc_error ("Coarray dummy argument '%s' at %L to elemental "
 			 "procedure", sym->name, &sym->declared_at);
 	      continue;
 	    }
 
-	  if (sym->as != NULL)
+	  if (sym->as || (sym->ts.type == BT_CLASS && CLASS_DATA (sym)
+			  && CLASS_DATA (sym)->as))
 	    {
 	      gfc_error ("Argument '%s' of elemental procedure at %L must "
 			 "be scalar", sym->name, &sym->declared_at);
 	      continue;
 	    }
 
-	  if (sym->attr.allocatable)
+	  if (sym->attr.allocatable
+	      || (sym->ts.type == BT_CLASS && CLASS_DATA (sym)
+		  && CLASS_DATA (sym)->attr.allocatable))
 	    {
 	      gfc_error ("Argument '%s' of elemental procedure at %L cannot "
 			 "have the ALLOCATABLE attribute", sym->name,
Index: gcc/testsuite/gfortran.dg/elemental_args_check_5.f90
===================================================================
--- gcc/testsuite/gfortran.dg/elemental_args_check_5.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/elemental_args_check_5.f90	(Arbeitskopie)
@@ -0,0 +1,30 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+!
+!
+  type t
+  end type t
+  type t2
+  end type t2
+contains
+elemental subroutine foo0(v) ! OK
+  class(t), intent(in) :: v
+end subroutine
+
+elemental subroutine foo1(w) ! { dg-error "Argument 'w' of elemental procedure at .1. cannot have the ALLOCATABLE attribute" }
+  class(t), allocatable, intent(in) :: w
+end subroutine
+
+elemental subroutine foo2(x) ! { dg-error "Argument 'x' of elemental procedure at .1. cannot have the POINTER attribute" }
+  class(t), pointer, intent(in) :: x
+end subroutine
+
+elemental subroutine foo3(y) ! { dg-error "Coarray dummy argument 'y' at .1. to elemental procedure" }
+  class(t2), intent(in) :: y[*]
+end subroutine
+
+elemental subroutine foo4(z) ! { dg-error "Argument 'z' of elemental procedure at .1. must be scalar" }
+  class(t), intent(in) :: z(:)
+end subroutine
+
+end

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

* Re: [Patch, Fortran] Fix elemental diagnostic for polymorphic dummies
  2012-01-26 23:52 [Patch, Fortran] Fix elemental diagnostic for polymorphic dummies Tobias Burnus
@ 2012-01-27 12:24 ` Paul Richard Thomas
  2012-01-27 14:02   ` Tobias Burnus
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Richard Thomas @ 2012-01-27 12:24 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc patches, gfortran

This is 'obvious'  - OK for trunk.

Thanks

Paul

On Fri, Jan 27, 2012 at 12:52 AM, Tobias Burnus <burnus@net-b.de> wrote:
> Dominique found out that there is no diagnostic for polymorphic arrays. This
> patch adds it.
>
> From the F2008 standard:
>
> "C1289 All dummy arguments of an elemental procedure shall be scalar
> noncoarray dummy data objects and shall not have the POINTER or ALLOCATABLE
> attribute."
>
> "An elemental subroutine has only scalar dummy arguments, but may have array
> actual arguments. In a reference to an elemental subroutine, either all
> actual arguments shall be scalar, or all actual arguments corresponding to
> INTENT (OUT) and INTENT (INOUT) dummy arguments shall be arrays of the same
> shape and the remaining actual arguments shall be conformable with them."
>
>
> Build and currently regtesting on x86-64-linux.
> OK for the trunk?
>
> Tobias



-- 
The knack of flying is learning how to throw yourself at the ground and miss.
       --Hitchhikers Guide to the Galaxy

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

* Re: [Patch, Fortran] Fix elemental diagnostic for polymorphic dummies
  2012-01-27 12:24 ` Paul Richard Thomas
@ 2012-01-27 14:02   ` Tobias Burnus
  0 siblings, 0 replies; 3+ messages in thread
From: Tobias Burnus @ 2012-01-27 14:02 UTC (permalink / raw)
  To: Paul Richard Thomas; +Cc: gcc patches, gfortran

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

On 01/27/2012 01:24 PM, Paul Richard Thomas wrote:
> This is 'obvious'  - OK for trunk.

Thanks for the review.

I realized that the following chunk was not in the submitted patch. I 
have no idea why it got lost, but after committal of the original patch 
and update of by devel tree it showed up with "svn diff". That case is 
already tested for in the previously committed patch.

Follow up committed as Rev. 183625.

Tobias

[-- Attachment #2: committed.diff --]
[-- Type: text/x-patch, Size: 1044 bytes --]

Index: gcc/fortran/ChangeLog
===================================================================
--- gcc/fortran/ChangeLog	(revision 183624)
+++ gcc/fortran/ChangeLog	(working copy)
@@ -1,5 +1,12 @@
 2012-01-27  Tobias Burnus  <burnus@net-b.de>
 
+	PR fortran/52016
+	* resolve.c (resolve_formal_arglist): Fix elemental
+	constraint checks for polymorphic dummies also for
+	pointers.
+	
+2012-01-27  Tobias Burnus  <burnus@net-b.de>
+
 	PR fortran/51970
 	PR fortran/51977
 	* primary.c (gfc_match_varspec. gfc_match_rvalue): Set
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 183624)
+++ gcc/fortran/resolve.c	(working copy)
@@ -401,7 +401,9 @@
 	      continue;
 	    }
 
-	  if (sym->attr.pointer)
+	  if (sym->attr.pointer
+	      || (sym->ts.type == BT_CLASS && CLASS_DATA (sym)
+		  && CLASS_DATA (sym)->attr.class_pointer))
 	    {
 	      gfc_error ("Argument '%s' of elemental procedure at %L cannot "
 			 "have the POINTER attribute", sym->name,

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

end of thread, other threads:[~2012-01-27 14:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-26 23:52 [Patch, Fortran] Fix elemental diagnostic for polymorphic dummies Tobias Burnus
2012-01-27 12:24 ` Paul Richard Thomas
2012-01-27 14:02   ` Tobias Burnus

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