public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] *ping* + PR55638 - elemental: VALUE w/o INTENT fix
@ 2012-12-12 16:39 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2012-12-12 16:39 UTC (permalink / raw)
  To: gcc patches, gfortran

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

Dear all,

first, I like to ping two patches:

* MOVE_ALLOC: http://gcc.gnu.org/ml/fortran/2012-12/msg00058.html
* MODULE renaming: http://gcc.gnu.org/ml/fortran/2012-12/msg00022.html
   Note: The proper PR number is 55197.

  * * *

Secondly, the attached patch allows VALUE arguments to ELEMENTAL without 
requiring an INTENT(IN). [intent(out)/intent(inout) are not allowed with 
VALUE.]

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

(In Fortran 2003, PURE required INTENT, which was relaxed in Fortran 
2008 such that no VALUE attribute is needed. However, due to IMPURE 
elemental, the intent constraint got lost and had to be re-added in 
F2008 Corr 1. With -std=f2003, an argument with VALUE and w/o intent(in) 
triggers the error message in PURE - also for ELEMENTAL, which should be 
okay.)

Tobias

[-- Attachment #2: value-intent.diff --]
[-- Type: text/x-patch, Size: 2821 bytes --]

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

	PR fortran/55638
	* resolve.c (resolve_formal_arglist): Allow VALUE without
	INTENT for ELEMENTAL procedures.

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

	PR fortran/55638
	* gfortran.dg/elemental_args_check_3.f90: Update dg-error.
	* gfortran.dg/elemental_args_check_7.f90: New.

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 1c7b5fb..d4d5eb9 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -488,10 +488,12 @@ resolve_formal_arglist (gfc_symbol *proc)
 	      continue;
 	    }
 
-	  if (sym->attr.intent == INTENT_UNKNOWN)
+	  /* Fortran 2008 Corrigendum 1, C1290a.  */
+	  if (sym->attr.intent == INTENT_UNKNOWN && !sym->attr.value)
 	    {
 	      gfc_error ("Argument '%s' of elemental procedure '%s' at %L must "
-			 "have its INTENT specified", sym->name, proc->name,
+			 "have its INTENT specified or have the VALUE "
+			 "attribute", sym->name, proc->name,
 			 &sym->declared_at);
 	      continue;
 	    }
diff --git a/gcc/testsuite/gfortran.dg/elemental_args_check_3.f90 b/gcc/testsuite/gfortran.dg/elemental_args_check_3.f90
index 77111f1..8d63874 100644
--- a/gcc/testsuite/gfortran.dg/elemental_args_check_3.f90
+++ b/gcc/testsuite/gfortran.dg/elemental_args_check_3.f90
@@ -13,7 +13,7 @@ CONTAINS
     (a, & ! { dg-error "must be scalar" }
      b, & ! { dg-error "POINTER attribute" }
      c, & ! { dg-error "ALLOCATABLE attribute" }
-     d) ! { dg-error "INTENT specified" }
+     d) ! { dg-error "must have its INTENT specified or have the VALUE attribute" }
     INTEGER, INTENT(IN) :: a(:)
     INTEGER, POINTER, INTENT(IN) :: b
     INTEGER, ALLOCATABLE, INTENT(IN) :: c
diff --git a/gcc/testsuite/gfortran.dg/elemental_args_check_7.f90 b/gcc/testsuite/gfortran.dg/elemental_args_check_7.f90
new file mode 100644
index 0000000..7b5843b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/elemental_args_check_7.f90
@@ -0,0 +1,26 @@
+! { dg-do compile }
+!
+! PR fortran/55638
+!
+! Additionally, VALUE no INTENT is required (and only "intent(in)" allowed)
+!
+
+  elemental subroutine foo(x, y, z)
+    integer, intent(inout) :: x
+    integer, VALUE :: y
+    integer, VALUE, intent(in) :: z
+    x = y
+  end subroutine foo
+
+  impure elemental subroutine foo2(x, y, z) ! { dg-error "Argument 'x' of elemental procedure 'foo2' at .1. must have its INTENT specified or have the VALUE attribute" }
+    integer :: x 
+    integer, VALUE :: y
+    integer, VALUE :: z
+    x = y
+  end subroutine foo2
+
+  subroutine foo3(x, y, z)
+    integer, VALUE, intent(in) :: x
+    integer, VALUE, intent(inout) :: y ! { dg-error "VALUE attribute conflicts with INTENT.INOUT. attribute" }
+    integer, VALUE, intent(out) :: z ! { dg-error "VALUE attribute conflicts with INTENT.OUT. attribute" }
+  end subroutine foo3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-12 16:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-12 16:39 [Patch, Fortran] *ping* + PR55638 - elemental: VALUE w/o INTENT fix 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).