summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-11 04:44:16 +0000
committerkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-11 04:44:16 +0000
commit7b7b9e53fb49163f1dcaa512a6bd4973a9fc500d (patch)
tree85d233bc91b50f52d627c1a4ab132a7ed7885909
parent360738f1a5bd169ed4049132a474a1adb716675d (diff)
downloadgcc-7b7b9e53fb49163f1dcaa512a6bd4973a9fc500d.tar.gz
PR fortran/15976
* resolve.c (resolve_symbol): Disallow automatic arrays in module scope. * gfortran.dg/automatic_module_variable.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@106777 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/resolve.c18
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/automatic_module_variable.f9016
4 files changed, 44 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index a138bb11ba8..305f91ad35e 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,4 +1,10 @@
2005-11-10 Paul Thomas <pault@gcc.gnu.org>
+ Steven G. Kargl <kargls@comcast.net>
+
+ PR fortran/15976
+ * resolve.c (resolve_symbol): Disallow automatic arrays in module scope.
+
+2005-11-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/24655
PR fortran/24755
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 50d22b0ea83..0f175856a92 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -4282,6 +4282,22 @@ resolve_symbol (gfc_symbol * sym)
return;
}
+ /* A module array's shape needs to be constant. */
+
+ if (sym->ns->proc_name
+ && sym->attr.flavor == FL_VARIABLE
+ && sym->ns->proc_name->attr.flavor == FL_MODULE
+ && !sym->attr.use_assoc
+ && !sym->attr.allocatable
+ && !sym->attr.pointer
+ && sym->as != NULL
+ && !gfc_is_compile_time_shape (sym->as))
+ {
+ gfc_error ("Module array '%s' at %L cannot be automatic "
+ "or assumed shape", sym->name, &sym->declared_at);
+ return;
+ }
+
/* Make sure that character string variables with assumed length are
dummy arguments. */
@@ -4465,7 +4481,7 @@ resolve_symbol (gfc_symbol * sym)
switch (sym->attr.flavor)
{
case FL_VARIABLE:
- /* Can the sybol have an initializer? */
+ /* Can the symbol have an initializer? */
flag = 0;
if (sym->attr.allocatable || sym->attr.external || sym->attr.dummy
|| sym->attr.intrinsic || sym->attr.result)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e2557a7991b..fa6d7b07e4d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-11-10 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/15976
+ * gfortran.dg/automatic_module_variable.f90: New test.
+
2005-11-11 Kaz Kojima <kkojima@gcc.gnu.org>
PR target/24445
diff --git a/gcc/testsuite/gfortran.dg/automatic_module_variable.f90 b/gcc/testsuite/gfortran.dg/automatic_module_variable.f90
new file mode 100644
index 00000000000..0cf43f7e853
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/automatic_module_variable.f90
@@ -0,0 +1,16 @@
+! { dg-do compile }
+! Tests fix for PR15976
+!
+module sd
+ integer, parameter :: n = 20
+ integer :: i(n)
+ integer :: j(m) ! { dg-error "cannot be automatic or assumed shape" }
+ integer, pointer :: p(:)
+ integer, allocatable :: q(:)
+contains
+ function init (x, l)
+ integer :: x(l)
+ integer :: init(l)
+ init = x
+ end function init
+end module sd