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.
@@ -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;
}
@@ -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
new file mode 100644
@@ -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