diff options
author | Janus Weil <janus@gcc.gnu.org> | 2009-08-31 12:22:32 +0200 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2009-08-31 12:22:32 +0200 |
commit | 2fbd4117c6872453531aa88123f0ea8efdf1b4df (patch) | |
tree | 10c30d1e9b304179c69b618cd75553a751574792 /gcc/fortran | |
parent | 4a435ffc1c4509ea53e9f93359ef0ed73dd12eec (diff) | |
download | gcc-2fbd4117c6872453531aa88123f0ea8efdf1b4df.zip gcc-2fbd4117c6872453531aa88123f0ea8efdf1b4df.tar.gz gcc-2fbd4117c6872453531aa88123f0ea8efdf1b4df.tar.bz2 |
re PR fortran/40996 ([F03] ALLOCATABLE scalars)
2009-08-31 Janus Weil <janus@gcc.gnu.org>
PR fortran/40996
* check.c (gfc_check_allocated): Implement allocatable scalars.
* resolve.c (resolve_allocate_expr,resolve_fl_var_and_proc): Ditto.
* trans-intrinsic.c (gfc_conv_allocated): Ditto.
2009-08-31 Janus Weil <janus@gcc.gnu.org>
PR fortran/40996
* gfortran.dg/allocatable_scalar_1.f90: New.
* gfortran.dg/allocatable_scalar_2.f90: Renamed from finalize_9.f03.
* gfortran.dg/finalize_9.f03: Renamed to allocatable_scalar_2.f90.
* gfortran.dg/proc_ptr_comp_pass_4.f90: Modified.
From-SVN: r151240
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fortran/check.c | 3 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 15 | ||||
-rw-r--r-- | gcc/fortran/trans-intrinsic.c | 18 |
4 files changed, 31 insertions, 12 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ce732e0..3d2aad6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2009-08-31 Janus Weil <janus@gcc.gnu.org> + + PR fortran/40996 + * check.c (gfc_check_allocated): Implement allocatable scalars. + * resolve.c (resolve_allocate_expr,resolve_fl_var_and_proc): Ditto. + * trans-intrinsic.c (gfc_conv_allocated): Ditto. + 2009-08-30 Daniel Kraft <d@domob.eu> PR fortran/37425 diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 6e2ce41..01775ab 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -546,9 +546,6 @@ gfc_check_allocated (gfc_expr *array) return FAILURE; } - if (array_check (array, 0) == FAILURE) - return FAILURE; - return SUCCESS; } diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index f10a412..b665c35 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -5643,7 +5643,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code) code->next = init_st; } - if (pointer && dimension == 0) + if (pointer || dimension == 0) return SUCCESS; /* Make sure the next-to-last reference node is an array specification. */ @@ -7955,11 +7955,14 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag) if (sym->attr.allocatable) { if (sym->attr.dimension) - gfc_error ("Allocatable array '%s' at %L must have " - "a deferred shape", sym->name, &sym->declared_at); - else - gfc_error ("Scalar object '%s' at %L may not be ALLOCATABLE", - sym->name, &sym->declared_at); + { + gfc_error ("Allocatable array '%s' at %L must have " + "a deferred shape", sym->name, &sym->declared_at); + return FAILURE; + } + else if (gfc_notify_std (GFC_STD_F2003, "Scalar object '%s' at %L " + "may not be ALLOCATABLE", sym->name, + &sym->declared_at) == FAILURE) return FAILURE; } diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 3b2cbd1..b9e5b86 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -4564,10 +4564,22 @@ gfc_conv_allocated (gfc_se *se, gfc_expr *expr) gfc_init_se (&arg1se, NULL); arg1 = expr->value.function.actual; ss1 = gfc_walk_expr (arg1->expr); - arg1se.descriptor_only = 1; - gfc_conv_expr_descriptor (&arg1se, arg1->expr, ss1); - tmp = gfc_conv_descriptor_data_get (arg1se.expr); + if (ss1 == gfc_ss_terminator) + { + /* Allocatable scalar. */ + arg1se.want_pointer = 1; + gfc_conv_expr (&arg1se, arg1->expr); + tmp = arg1se.expr; + } + else + { + /* Allocatable array. */ + arg1se.descriptor_only = 1; + gfc_conv_expr_descriptor (&arg1se, arg1->expr, ss1); + tmp = gfc_conv_descriptor_data_get (arg1se.expr); + } + tmp = fold_build2 (NE_EXPR, boolean_type_node, tmp, fold_convert (TREE_TYPE (tmp), null_pointer_node)); se->expr = convert (gfc_typenode_for_spec (&expr->ts), tmp); |