aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2011-05-29 20:17:40 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2011-05-29 20:17:40 +0200
commit427180d243e562912cc37f09b140a4d8c042ae4c (patch)
tree58e3db3d3be0f4d93c2a283b0fa80d1b591cddcd
parent8a5c4899e8f57f09e288043984cc0f4584f17fc4 (diff)
downloadgcc-427180d243e562912cc37f09b140a4d8c042ae4c.zip
gcc-427180d243e562912cc37f09b140a4d8c042ae4c.tar.gz
gcc-427180d243e562912cc37f09b140a4d8c042ae4c.tar.bz2
re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays])
2011-05-29 Tobias Burnus <burnus@net-b.de> PR fortran/18918 * interface.c (compare_parameter): Add check for passing coarray to allocatable noncoarray dummy. 2011-05-29 Tobias Burnus <burnus@net-b.de> PR fortran/18918 * gfortran.dg/coarray_24.f90: New. From-SVN: r174411
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/interface.c18
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/coarray_24.f9026
4 files changed, 55 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 71e6452..5ffa5f6 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,4 +1,10 @@
2011-05-29 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/18918
+ * interface.c (compare_parameter): Add check for passing coarray
+ to allocatable noncoarray dummy.
+
+2011-05-29 Tobias Burnus <burnus@net-b.de>
Richard Guenther <rguenther@suse.de>
PR fortran/18918
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 732a0c59d..6575fbe 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -1645,6 +1645,24 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,
return 0;
}
+ if (formal->attr.allocatable && !formal->attr.codimension
+ && gfc_expr_attr (actual).codimension)
+ {
+ if (formal->attr.intent == INTENT_OUT)
+ {
+ if (where)
+ gfc_error ("Passing coarray at %L to allocatable, noncoarray, "
+ "INTENT(OUT) dummy argument '%s'", &actual->where,
+ formal->name);
+ return 0;
+ }
+ else if (gfc_option.warn_surprising && where
+ && formal->attr.intent != INTENT_IN)
+ gfc_warning ("Passing coarray at %L to allocatable, noncoarray dummy "
+ "argument '%s', which is invalid if the allocation status"
+ " is modified", &actual->where, formal->name);
+ }
+
if (symbol_rank (formal) == actual->rank)
return 1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fce1c32..c416d1a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,11 @@
2011-05-29 Tobias Burnus <burnus@net-b.de>
PR fortran/18918
+ * gfortran.dg/coarray_24.f90: New.
+
+2011-05-29 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/18918
* gfortran.dg/coarray_23.f90: New.
2011-05-29 Richard Sandiford <rdsandiford@googlemail.com>
diff --git a/gcc/testsuite/gfortran.dg/coarray_24.f90 b/gcc/testsuite/gfortran.dg/coarray_24.f90
new file mode 100644
index 0000000..d8d9281
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_24.f90
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single -Wall" }
+!
+! This program is perfectly valid; however, passing an (allocatable) coarray
+! as actual argument to a non-coarray allocatable dummy is doubtful as
+! reallocation is not allowed. Thus, an intent(out) dummy should be always
+! wrong.
+!
+
+integer, allocatable :: myCaf(:)[:]
+
+allocate(myCaf(1)[*])
+
+call doubtful_valid(myCaf) ! { dg-warning "to allocatable, noncoarray dummy" }
+call invalid(myCaf) ! { dg-error "to allocatable, noncoarray, INTENT.OUT. dummy" }
+contains
+ subroutine doubtful_valid(x)
+ integer, allocatable :: x(:)
+ ! Valid as x's allocation status is not touched.
+ x(1) = 7
+ end subroutine doubtful_valid
+ subroutine invalid(y)
+ integer, allocatable, intent(out) :: y(:)
+ allocate (y(1))
+ end subroutine invalid
+end