aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2011-07-23 00:39:10 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2011-07-23 00:39:10 +0200
commitefc694a70a411f4399c71c715afaa22b10edac75 (patch)
tree46400e4f1cc98b9ae152afccca2b060c049d14ad /gcc
parenteda42c4f3c1d39590277fb33309e95af8baf8062 (diff)
downloadgcc-efc694a70a411f4399c71c715afaa22b10edac75.zip
gcc-efc694a70a411f4399c71c715afaa22b10edac75.tar.gz
gcc-efc694a70a411f4399c71c715afaa22b10edac75.tar.bz2
resolve.c (resolve_symbol): Fix coarray var decl check.
2011-07-23 Tobias Burnus <burnus@net-b.de> * resolve.c (resolve_symbol): Fix coarray var decl check. 2011-07-23 Tobias Burnus <burnus@net-b.de> * gfortran.dg/coarray_25.f90: New. From-SVN: r176660
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog4
-rw-r--r--gcc/fortran/resolve.c8
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gfortran.dg/coarray_25.f9018
-rw-r--r--gcc/testsuite/gfortran.dg/coarray_4.f902
5 files changed, 30 insertions, 6 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index dd4cd8d..533c28c5 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,7 @@
+2011-07-23 Tobias Burnus <burnus@net-b.de>
+
+ * resolve.c (resolve_symbol): Fix coarray var decl check.
+
2011-07-21 Daniel Carrera <dcarrera@gmail.com>
* trans.c (gfc_allocate_with_status): Split into two functions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 71e0ba0..e9e7bf0 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -12435,16 +12435,14 @@ resolve_symbol (gfc_symbol *sym)
sym->name, &sym->declared_at);
/* F2008, C526. The function-result case was handled above. */
- if (((sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.coarray_comp)
- || sym->attr.codimension)
+ if (sym->attr.codimension
&& !(sym->attr.allocatable || sym->attr.dummy || sym->attr.save
|| sym->ns->save_all
|| sym->ns->proc_name->attr.flavor == FL_MODULE
|| sym->ns->proc_name->attr.is_main_program
|| sym->attr.function || sym->attr.result || sym->attr.use_assoc))
- gfc_error ("Variable '%s' at %L is a coarray or has a coarray "
- "component and is not ALLOCATABLE, SAVE nor a "
- "dummy argument", sym->name, &sym->declared_at);
+ gfc_error ("Variable '%s' at %L is a coarray and is not ALLOCATABLE, SAVE "
+ "nor a dummy argument", sym->name, &sym->declared_at);
/* F2008, C528. */ /* FIXME: sym->as check due to PR 43412. */
else if (sym->attr.codimension && !sym->attr.allocatable
&& sym->as && sym->as->cotype == AS_DEFERRED)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ec8a8e0..8eb2828 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2011-07-23 Tobias Burnus <burnus@net-b.de>
+
+ * gfortran.dg/coarray_25.f90: New.
+
2011-07-22 Ville Voutilainen <ville.voutilainen@gmail.com>
* override1.C: This test should use c++0x mode.
diff --git a/gcc/testsuite/gfortran.dg/coarray_25.f90 b/gcc/testsuite/gfortran.dg/coarray_25.f90
new file mode 100644
index 0000000..a78a196
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_25.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+!
+! Used to be rejected with:
+! Error: Variable 'x' at (1) is a coarray or has a coarray
+! component and is not ALLOCATABLE, SAVE nor a dummy argument
+!
+! Is valid as "a" is allocatable, cf. C526
+! and http://j3-fortran.org/pipermail/j3/2011-June/004403.html
+!
+
+ subroutine test2()
+ type t
+ integer, allocatable :: a(:)[:]
+ end type t
+ type(t) :: x
+ allocate(x%a(1)[*])
+ end subroutine test2
diff --git a/gcc/testsuite/gfortran.dg/coarray_4.f90 b/gcc/testsuite/gfortran.dg/coarray_4.f90
index be2bc4e..cdc4ef8 100644
--- a/gcc/testsuite/gfortran.dg/coarray_4.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_4.f90
@@ -31,7 +31,7 @@ subroutine valid2()
integer, allocatable :: b[:]
end type tt
type(tt), save :: foo
- type(tt) :: bar ! { dg-error "is a coarray or has a coarray component" }
+ type(tt) :: bar
end subroutine valid2
subroutine invalid(n)