summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-17 09:14:18 +0000
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-17 09:14:18 +0000
commit487e0ef40c1a038ef8216e78feb9c7f9ae238cd8 (patch)
tree30d0a73d9cfc0c2d6079fc219127b33049960cf9
parente1c0b5a5474a54fb66585ed14e8752c5d88c5bfa (diff)
downloadgcc-487e0ef40c1a038ef8216e78feb9c7f9ae238cd8.tar.gz
2011-08-17 Janus Weil <janus@gcc.gnu.org>
PR fortran/50070 * resolve.c (resolve_fl_variable): Reject non-constant character lengths in COMMON variables. 2011-08-17 Janus Weil <janus@gcc.gnu.org> PR fortran/50070 * gfortran.dg/common_13.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177825 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/resolve.c25
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/common_13.f9011
4 files changed, 38 insertions, 9 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 63d5327aad8..d7f4b6d37d5 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2011-08-17 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/50070
+ * resolve.c (resolve_fl_variable): Reject non-constant character lengths
+ in COMMON variables.
+
2011-08-16 Tobias Burnus <burnus@net-b.de>
Dominique Dhumieres <dominiq@lps.ens.fr>
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 27e3ce995ba..7557ab8891d 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -10169,15 +10169,22 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
if (!gfc_is_constant_expr (e)
&& !(e->expr_type == EXPR_VARIABLE
- && e->symtree->n.sym->attr.flavor == FL_PARAMETER)
- && sym->ns->proc_name
- && (sym->ns->proc_name->attr.flavor == FL_MODULE
- || sym->ns->proc_name->attr.is_main_program)
- && !sym->attr.use_assoc)
- {
- gfc_error ("'%s' at %L must have constant character length "
- "in this context", sym->name, &sym->declared_at);
- return FAILURE;
+ && e->symtree->n.sym->attr.flavor == FL_PARAMETER))
+ {
+ if (!sym->attr.use_assoc && sym->ns->proc_name
+ && (sym->ns->proc_name->attr.flavor == FL_MODULE
+ || sym->ns->proc_name->attr.is_main_program))
+ {
+ gfc_error ("'%s' at %L must have constant character length "
+ "in this context", sym->name, &sym->declared_at);
+ return FAILURE;
+ }
+ if (sym->attr.in_common)
+ {
+ gfc_error ("COMMON variable '%s' at %L must have constant "
+ "character length", sym->name, &sym->declared_at);
+ return FAILURE;
+ }
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f435f140b85..1d070a8b433 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-08-17 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/50070
+ * gfortran.dg/common_13.f90: New.
+
2011-08-16 Jason Merrill <jason@redhat.com>
PR c++/50086
diff --git a/gcc/testsuite/gfortran.dg/common_13.f90 b/gcc/testsuite/gfortran.dg/common_13.f90
new file mode 100644
index 00000000000..07c78f1a73c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/common_13.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+!
+! PR 50070: Segmentation fault at size_binop_loc in fold-const.c
+!
+! Contributed by Vittorio Zecca <zeccav@gmail.com>
+
+subroutine sub
+ common n,z ! { dg-error "must have constant character length" }
+ integer :: n
+ character(len=n) :: z
+end