summaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-16 11:17:15 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-16 11:17:15 +0000
commitc2e9c1da57c35f46052398ab31707ceb2dfc4e09 (patch)
treeafd93279258b2ca1d846fdca1df67587efe6faad /gcc/fortran
parent56664e5da23e1ca0072b690b206c297484897bd3 (diff)
downloadgcc-c2e9c1da57c35f46052398ab31707ceb2dfc4e09.tar.gz
2012-01-16 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 183204 using svnmerge git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@183208 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog36
-rw-r--r--gcc/fortran/class.c1
-rw-r--r--gcc/fortran/intrinsic.texi10
-rw-r--r--gcc/fortran/module.c30
-rw-r--r--gcc/fortran/resolve.c28
-rw-r--r--gcc/fortran/trans-array.c47
-rw-r--r--gcc/fortran/trans-types.c4
7 files changed, 130 insertions, 26 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 598f47c80bd..2ed3e4b04b7 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,39 @@
+2012-01-14 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/51800
+ * resolve.c (build_default_init_expr): Also initialize
+ nonconstant-length strings with -finit-character=<n>.
+
+2011-01-14 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/51816
+ * module.c (read_module): Don't make nonexisting
+ intrinsic operators as found.
+ (rename_list_remove_duplicate): New function.
+ (gfc_use_modules): Use it.
+
+2012-01-13 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/48351
+ * trans-array.c (structure_alloc_comps): Suppress interative
+ call to self, when current component is deallocated using
+ gfc_trans_dealloc_allocated.
+ * class.c (gfc_build_class_symbol): Copy the 'alloc_comp'
+ attribute from the declared type to the class structure.
+
+2012-01-13 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/51842
+ * fortran/trans-types.c (gfc_init_kinds): Use PTRDIFF_TYPE
+ instead of a signed int of size POINTER_SIZE for
+ gfc_index_integer_kind.
+
+2012-01-12 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/36755
+ * intrinsic.texi (CHMOD): Extend a bit and remove statement
+ that /bin/chmod is called.
+
2012-01-10 Gerald Pfeifer <gerald@pfeifer.com>
* gfortran.texi (Fortran 2003 Status): Fix grammar.
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 37c653a6c33..a17fc0a1fa5 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -432,6 +432,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr,
}
fclass->attr.extension = ts->u.derived->attr.extension + 1;
+ fclass->attr.alloc_comp = ts->u.derived->attr.alloc_comp;
fclass->attr.is_class = 1;
ts->u.derived = fclass;
attr->allocatable = attr->pointer = attr->dimension = attr->codimension = 0;
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 6d4c9ffd20b..294818e43d0 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -1,5 +1,5 @@
@ignore
-Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
+Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012
Free Software Foundation, Inc.
This is part of the GNU Fortran manual.
For copying conditions, see the file gfortran.texi.
@@ -2665,8 +2665,7 @@ END PROGRAM
@table @asis
@item @emph{Description}:
-@code{CHMOD} changes the permissions of a file. This function invokes
-@code{/bin/chmod} and might therefore not work on all platforms.
+@code{CHMOD} changes the permissions of a file.
This intrinsic is provided in both subroutine and function forms; however,
only one form can be used in any given program unit.
@@ -2692,8 +2691,9 @@ file name. Trailing blanks are ignored unless the character
@code{achar(0)} are used as the file name.
@item @var{MODE} @tab Scalar @code{CHARACTER} of default kind giving the
-file permission. @var{MODE} uses the same syntax as the @var{MODE}
-argument of @code{/bin/chmod}.
+file permission. @var{MODE} uses the same syntax as the @code{chmod} utility
+as defined by the POSIX standard. The argument shall either be a string of
+a nonnegative octal number or a symbolic mode.
@item @var{STATUS} @tab (optional) scalar @code{INTEGER}, which is
@code{0} on success and nonzero otherwise.
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index a68132512e4..0616a8591f1 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -4465,7 +4465,7 @@ read_module (void)
int i;
int ambiguous, j, nuse, symbol;
pointer_info *info, *q;
- gfc_use_rename *u;
+ gfc_use_rename *u = NULL;
gfc_symtree *st;
gfc_symbol *sym;
@@ -4678,6 +4678,8 @@ read_module (void)
}
mio_interface (&gfc_current_ns->op[i]);
+ if (u && !gfc_current_ns->op[i])
+ u->found = 0;
}
mio_rparen ();
@@ -6093,6 +6095,31 @@ gfc_use_module (gfc_use_list *module)
}
+/* Remove duplicated intrinsic operators from the rename list. */
+
+static void
+rename_list_remove_duplicate (gfc_use_rename *list)
+{
+ gfc_use_rename *seek, *last;
+
+ for (; list; list = list->next)
+ if (list->op != INTRINSIC_USER && list->op != INTRINSIC_NONE)
+ {
+ last = list;
+ for (seek = list->next; seek; seek = last->next)
+ {
+ if (list->op == seek->op)
+ {
+ last->next = seek->next;
+ free (seek);
+ }
+ else
+ last = seek;
+ }
+ }
+}
+
+
/* Process all USE directives. */
void
@@ -6171,6 +6198,7 @@ gfc_use_modules (void)
for (; module_list; module_list = next)
{
next = module_list->next;
+ rename_list_remove_duplicate (module_list->rename);
gfc_use_module (module_list);
if (module_list->intrinsic)
free_rename (module_list->rename);
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 7f476b83400..352d22d0e01 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -10143,6 +10143,26 @@ build_default_init_expr (gfc_symbol *sym)
gfc_free_expr (init_expr);
init_expr = NULL;
}
+ if (!init_expr && gfc_option.flag_init_character == GFC_INIT_CHARACTER_ON
+ && sym->ts.u.cl->length)
+ {
+ gfc_actual_arglist *arg;
+ init_expr = gfc_get_expr ();
+ init_expr->where = sym->declared_at;
+ init_expr->ts = sym->ts;
+ init_expr->expr_type = EXPR_FUNCTION;
+ init_expr->value.function.isym =
+ gfc_intrinsic_function_by_id (GFC_ISYM_REPEAT);
+ init_expr->value.function.name = "repeat";
+ arg = gfc_get_actual_arglist ();
+ arg->expr = gfc_get_character_expr (sym->ts.kind, &sym->declared_at,
+ NULL, 1);
+ arg->expr->value.character.string[0]
+ = gfc_option.flag_init_character_value;
+ arg->next = gfc_get_actual_arglist ();
+ arg->next->expr = gfc_copy_expr (sym->ts.u.cl->length);
+ init_expr->value.function.actual = arg;
+ }
break;
default:
@@ -10169,10 +10189,12 @@ apply_default_init_local (gfc_symbol *sym)
if (init == NULL)
return;
- /* For saved variables, we don't want to add an initializer at
- function entry, so we just add a static initializer. */
+ /* For saved variables, we don't want to add an initializer at function
+ entry, so we just add a static initializer. Note that automatic variables
+ are stack allocated even with -fno-automatic. */
if (sym->attr.save || sym->ns->save_all
- || gfc_option.flag_max_stack_var_size == 0)
+ || (gfc_option.flag_max_stack_var_size == 0
+ && (!sym->attr.dimension || !is_non_constant_shape_array (sym))))
{
/* Don't clobber an existing initializer! */
gcc_assert (sym->value == NULL);
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 1fd8dcb7f77..57793cee44a 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -7238,6 +7238,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
gfc_loopinfo loop;
stmtblock_t fnblock;
stmtblock_t loopbody;
+ stmtblock_t tmpblock;
tree decl_type;
tree tmp;
tree comp;
@@ -7249,6 +7250,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
tree ctype;
tree vref, dref;
tree null_cond = NULL_TREE;
+ bool called_dealloc_with_status;
gfc_init_block (&fnblock);
@@ -7359,17 +7361,12 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
switch (purpose)
{
case DEALLOCATE_ALLOC_COMP:
- if (cmp_has_alloc_comps && !c->attr.pointer)
- {
- /* Do not deallocate the components of ultimate pointer
- components. */
- comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
- decl, cdecl, NULL_TREE);
- rank = c->as ? c->as->rank : 0;
- tmp = structure_alloc_comps (c->ts.u.derived, comp, NULL_TREE,
- rank, purpose);
- gfc_add_expr_to_block (&fnblock, tmp);
- }
+
+ /* gfc_deallocate_scalar_with_status calls gfc_deallocate_alloc_comp
+ (ie. this function) so generate all the calls and suppress the
+ recursion from here, if necessary. */
+ called_dealloc_with_status = false;
+ gfc_init_block (&tmpblock);
if (c->attr.allocatable
&& (c->attr.dimension || c->attr.codimension))
@@ -7377,7 +7374,7 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
decl, cdecl, NULL_TREE);
tmp = gfc_trans_dealloc_allocated (comp, c->attr.codimension);
- gfc_add_expr_to_block (&fnblock, tmp);
+ gfc_add_expr_to_block (&tmpblock, tmp);
}
else if (c->attr.allocatable)
{
@@ -7387,12 +7384,13 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
tmp = gfc_deallocate_scalar_with_status (comp, NULL, true, NULL,
c->ts);
- gfc_add_expr_to_block (&fnblock, tmp);
+ gfc_add_expr_to_block (&tmpblock, tmp);
+ called_dealloc_with_status = true;
tmp = fold_build2_loc (input_location, MODIFY_EXPR,
void_type_node, comp,
build_int_cst (TREE_TYPE (comp), 0));
- gfc_add_expr_to_block (&fnblock, tmp);
+ gfc_add_expr_to_block (&tmpblock, tmp);
}
else if (c->ts.type == BT_CLASS && CLASS_DATA (c)->attr.allocatable)
{
@@ -7412,14 +7410,33 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl,
{
tmp = gfc_deallocate_scalar_with_status (comp, NULL, true, NULL,
CLASS_DATA (c)->ts);
- gfc_add_expr_to_block (&fnblock, tmp);
+ gfc_add_expr_to_block (&tmpblock, tmp);
+ called_dealloc_with_status = true;
tmp = fold_build2_loc (input_location, MODIFY_EXPR,
void_type_node, comp,
build_int_cst (TREE_TYPE (comp), 0));
}
+ gfc_add_expr_to_block (&tmpblock, tmp);
+ }
+
+ if (cmp_has_alloc_comps
+ && !c->attr.pointer
+ && !called_dealloc_with_status)
+ {
+ /* Do not deallocate the components of ultimate pointer
+ components or iteratively call self if call has been made
+ to gfc_trans_dealloc_allocated */
+ comp = fold_build3_loc (input_location, COMPONENT_REF, ctype,
+ decl, cdecl, NULL_TREE);
+ rank = c->as ? c->as->rank : 0;
+ tmp = structure_alloc_comps (c->ts.u.derived, comp, NULL_TREE,
+ rank, purpose);
gfc_add_expr_to_block (&fnblock, tmp);
}
+
+ /* Now add the deallocation of this component. */
+ gfc_add_block_to_block (&fnblock, &tmpblock);
break;
case NULLIFY_ALLOC_COMP:
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index d643c2e45b8..f817a12f6ec 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -576,8 +576,8 @@ gfc_init_kinds (void)
gfc_default_character_kind = gfc_character_kinds[0].kind;
gfc_character_storage_size = gfc_default_character_kind * 8;
- /* Choose the integer kind the same size as "void*" for our index kind. */
- gfc_index_integer_kind = POINTER_SIZE / 8;
+ gfc_index_integer_kind = get_int_kind_from_name (PTRDIFF_TYPE);
+
/* Pick a kind the same size as the C "int" type. */
gfc_c_int_kind = INT_TYPE_SIZE / 8;