1 Upstream-Status: Inappropriate [Backport]
2 From 1c9148fe797f564821355a8976802689519324dd Mon Sep 17 00:00:00 2001
3 From: burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
4 Date: Fri, 29 Apr 2011 21:26:07 +0000
5 Subject: [PATCH 198/200] 2011-04-29 Tobias Burnus <burnus@net-b.de>
8 * resolve.c (resolve_typebound_generic_call): Don't check access
9 flags of the specific function.
12 * resolve.c (resolve_formal_arglist): Don't change AS_DEFERRED
13 to AS_ASSUMED_SHAPE for function results.
14 (resolve_fl_var_and_proc): Print also for function results with
15 AS_DEFERRED an error, if they are not a pointer or allocatable.
16 (resolve_types): Make sure arguments of procedures in interface
19 2011-04-29 Tobias Burnus <burnus@net-b.de>
22 * gfortran.dg/typebound_proc_22.f90: New.
25 * gfortran.dg/interface_36.f90: New.
29 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173191 138bc75d-0d04-0410-961f-82ee72b054a4
31 index f661140..7618db9 100644
32 --- a/gcc/fortran/resolve.c
33 +++ b/gcc/fortran/resolve.c
34 @@ -315,7 +315,8 @@ resolve_formal_arglist (gfc_symbol *proc)
35 shape until we know if it has the pointer or allocatable attributes.
37 if (sym->as && sym->as->rank > 0 && sym->as->type == AS_DEFERRED
38 - && !(sym->attr.pointer || sym->attr.allocatable))
39 + && !(sym->attr.pointer || sym->attr.allocatable)
40 + && sym->attr.flavor != FL_PROCEDURE)
42 sym->as->type = AS_ASSUMED_SHAPE;
43 for (i = 0; i < sym->as->rank; i++)
44 @@ -5674,7 +5675,7 @@ success:
45 /* Make sure that we have the right specific instance for the name. */
46 derived = get_declared_from_expr (NULL, NULL, e);
48 - st = gfc_find_typebound_proc (derived, NULL, genname, false, &e->where);
49 + st = gfc_find_typebound_proc (derived, NULL, genname, true, &e->where);
51 e->value.compcall.tbp = st->n.tb;
53 @@ -9890,7 +9891,7 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag)
56 if (!mp_flag && !sym->attr.allocatable && !sym->attr.pointer
57 - && !sym->attr.dummy && sym->ts.type != BT_CLASS && !sym->assoc)
58 + && sym->ts.type != BT_CLASS && !sym->assoc)
60 gfc_error ("Array '%s' at %L cannot have a deferred shape",
61 sym->name, &sym->declared_at);
62 @@ -13505,6 +13506,10 @@ resolve_types (gfc_namespace *ns)
64 resolve_contained_functions (ns);
66 + if (ns->proc_name && ns->proc_name->attr.flavor == FL_PROCEDURE
67 + && ns->proc_name->attr.if_source == IFSRC_IFBODY)
68 + resolve_formal_arglist (ns->proc_name);
70 gfc_traverse_ns (ns, resolve_bind_c_derived_types);
72 for (cl = ns->cl_list; cl; cl = cl->next)
74 index 0000000..5032291
76 +++ b/gcc/testsuite/gfortran.dg/interface_36.f90
82 +! Contributed by Daniel Carrera
84 + pure function runge_kutta_step(t, r_, dr, h) result(res)
85 + real, intent(in) :: t, r_(:), h
86 + real, dimension(:), allocatable :: k1, k2, k3, k4, res
90 + pure function dr(t, r_) ! { dg-error "cannot have a deferred shape" }
91 + real, intent(in) :: t, r_(:)
97 + allocate(k1(N),k2(N),k3(N),k4(N),res(N))
100 + k2 = dr(t + h/2, r_ + k1*h/2)
101 + k3 = dr(t + h/2, r_ + k2*h/2)
102 + k4 = dr(t + h , r_ + k3*h)
104 + res = r_ + (k1 + 2*k2 + 2*k3 + k4) * h/6
106 diff --git a/gcc/testsuite/gfortran.dg/typebound_proc_22.f90 b/gcc/testsuite/gfortran.dg/typebound_proc_22.f90
108 index 0000000..f7691c5
110 +++ b/gcc/testsuite/gfortran.dg/typebound_proc_22.f90
116 +! Contributed by Andrew Baldwin
123 + procedure :: gimmex
124 + generic, public :: getx => gimmex
127 + function gimmex(foo)
128 + class (foobar) :: foo
131 + end function gimmex
139 + procedure :: gimmexPriv
140 + generic, private :: getxPriv => gimmexPriv
141 + end type foobarPriv
143 + function gimmexPriv(foo)
144 + class (foobarPriv) :: foo
147 + end function gimmexPriv
148 + end module qtestPriv
153 + type (foobar) :: foo
154 + type (foobarPriv) :: fooPriv
156 + bar = foo%getx() ! OK
157 + bar = fooPriv%getxPriv() ! { dg-error " is PRIVATE " }
158 + end program quicktest
160 +! { dg-final { cleanup-modules "qtest qtestpriv" } }