summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2011-01-28 19:49:25 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2011-01-28 19:49:25 +0000
commit387580902ecc9c7b39506a5fae99f339682e633a (patch)
tree0b7402a91c513d3f4534f6e36ee16a517b28e7dd
parent34d643203292169931d220ab198c8ac843c0899d (diff)
downloadgcc-387580902ecc9c7b39506a5fae99f339682e633a.tar.gz
2011-01-28 Tobias Burnus <burnus@net-b.de>
PR fortran/47507 * resolve.c (resolve_formal_arglist): Allow arguments with VALUE attribute also without INTENT. 2011-01-28 Tobias Burnus <burnus@net-b.de> PR fortran/47507 * gfortran.dg/pure_formal_1.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169372 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/resolve.c12
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pure_formal_1.f9016
4 files changed, 34 insertions, 5 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 336f28ef1d0..b7064921b43 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,11 @@
2011-01-28 Tobias Burnus <burnus@net-b.de>
+ PR fortran/47507
+ * resolve.c (resolve_formal_arglist): Allow arguments with VALUE
+ attribute also without INTENT.
+
+2011-01-28 Tobias Burnus <burnus@net-b.de>
+
* gfortran.texi (Fortran 2003 status): Mention support for
nonconstant namelist variables.
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 243628397aa..55b5183776f 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -338,15 +338,17 @@ resolve_formal_arglist (gfc_symbol *proc)
if (gfc_pure (proc) && !sym->attr.pointer
&& sym->attr.flavor != FL_PROCEDURE)
{
- if (proc->attr.function && sym->attr.intent != INTENT_IN)
+ if (proc->attr.function && sym->attr.intent != INTENT_IN
+ && !sym->attr.value)
gfc_error ("Argument '%s' of pure function '%s' at %L must be "
- "INTENT(IN)", sym->name, proc->name,
+ "INTENT(IN) or VALUE", sym->name, proc->name,
&sym->declared_at);
- if (proc->attr.subroutine && sym->attr.intent == INTENT_UNKNOWN)
+ if (proc->attr.subroutine && sym->attr.intent == INTENT_UNKNOWN
+ && !sym->attr.value)
gfc_error ("Argument '%s' of pure subroutine '%s' at %L must "
- "have its INTENT specified", sym->name, proc->name,
- &sym->declared_at);
+ "have its INTENT specified or have the VALUE "
+ "attribute", sym->name, proc->name, &sym->declared_at);
}
if (proc->attr.implicit_pure && !sym->attr.pointer
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4d6acf0176f..892a5437a20 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-01-28 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/47507
+ * gfortran.dg/pure_formal_1.f90: New.
+
2011-01-28 Jakub Jelinek <jakub@redhat.com>
PR target/42894
diff --git a/gcc/testsuite/gfortran.dg/pure_formal_1.f90 b/gcc/testsuite/gfortran.dg/pure_formal_1.f90
new file mode 100644
index 00000000000..4e62cf9dee6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pure_formal_1.f90
@@ -0,0 +1,16 @@
+! { dg-do compile }
+!
+! PR fortran/47507
+!
+! PURE procedures: Allow arguments w/o INTENT if they are VALUE
+!
+
+pure function f(x)
+ real, VALUE :: x
+ real :: f
+ f = sin(x)
+end function f
+
+pure subroutine sub(x)
+ real, VALUE :: x
+end subroutine sub