This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, Fortran] *ping* + PR55638 - elemental: VALUE w/o INTENT fix
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Wed, 12 Dec 2012 17:39:08 +0100
- Subject: [Patch, Fortran] *ping* + PR55638 - elemental: VALUE w/o INTENT fix
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
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