[pushed] wwwdocs: news: Update links to Craig Burley's notes on g77
The new site does not offer https, so staying with http. Pushed. Gerald On the way remove a mailto: link to offer g77 help from 1999. --- htdocs/news.html | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/news.html b/htdocs/news.html index 5e782349..6fac4ea5 100644 --- a/htdocs/news.html +++ b/htdocs/news.html @@ -1612,14 +1612,11 @@ series. On behalf of the entire GCC team, the steering committee would like to thank Craig for his work. Craig has written a detailed analysis of the -http://world.std.com/~burley/g77-why.html";>current state +http://www.kilmnj.com/g77/why.html";>current state and -http://world.std.com/~burley/g77-next.html";>possible future +http://www.kilmnj.com/g77/next.html";>possible future of g77, available at his -http://world.std.com/~burley/g77.html";>g77 web site. - -If you are interested in helping with g77, please mailto:g...@gcc.gnu.org?subject=g77%20Help%20Wanted?";>contact us! +http://www.kilmnj.com/g77/";>g77 web site. October 12, 1999 -- 2.45.2
[PATCH] fortran: Correctly evaluate the MASK argument of MINLOC/MAXLOC
From: Mikael Morin Hello, I'm currently testing this on x86_64-linux. I plan to push to master if all goes well. Mikael -- 8< -- Add the preliminary code that the generated expression for MASK may depend on when generating the inline code to evaluate MINLOC or MAXLOC with a scalar MASK. The generated code was only keeping the generated expression but not the preliminary code, which was sufficient for simple cases such as data references or simple (scalar) function calls, but was bogus with more complicated ones. gcc/fortran/ChangeLog: * trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Add the preliminary code generated for MASK to the preliminary code of MINLOC/MAXLOC. gcc/testsuite/ChangeLog: * gfortran.dg/minmaxloc_17.f90: New test. --- gcc/fortran/trans-intrinsic.cc | 1 + gcc/testsuite/gfortran.dg/minmaxloc_17.f90 | 33 ++ 2 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_17.f90 diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index cadbd177452..180d0d7a88c 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -5749,6 +5749,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) gfc_init_se (&maskse, NULL); gfc_conv_expr_val (&maskse, maskexpr); + gfc_add_block_to_block (&se->pre, &maskse.pre); gfc_init_block (&block); gfc_add_block_to_block (&block, &loop.pre); gfc_add_block_to_block (&block, &loop.post); diff --git a/gcc/testsuite/gfortran.dg/minmaxloc_17.f90 b/gcc/testsuite/gfortran.dg/minmaxloc_17.f90 new file mode 100644 index 000..7e6e586ab03 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/minmaxloc_17.f90 @@ -0,0 +1,33 @@ +! { dg-do run } +! +! Check that the code necessary to evaluate MINLOC's or MAXLOC's MASK +! argument is correctly generated. + +program p + implicit none + integer, parameter :: data10(*) = (/ 2, 5, 2, 0, 6, 5, 3, 6, 0, 1 /) + logical, parameter :: mask10(*) = (/ .false., .true., .false., & + .false., .true., .true., & + .true. , .true., .false., & + .false. /) + type bool_wrapper +logical :: l + end type + call check_minloc + call check_maxloc +contains + subroutine check_minloc +integer :: a(10) +integer :: r +a = data10 +r = minloc(a, dim = 1, mask = sum(a) > 0) +if (r /= 4) stop 11 + end subroutine + subroutine check_maxloc +integer :: a(10) +integer :: r +a = data10 +r = maxloc(a, dim = 1, mask = sum(a) > 0) +if (r /= 5) stop 18 + end subroutine +end program -- 2.43.0
[Patch, fortran] PR84868 - [11/12/13/14/15 Regression] ICE in gfc_conv_descriptor_offset, at fortran/trans-array.c:208
Hi All, After messing around with argument mapping, where I found and fixed another bug, I realised that the problem lay with simplification of len_trim with an argument that is the element of a parameter array. The fix was then a straightforward lift of existing code in expr.cc. The mapping bug is also fixed by supplying the se string length when building character typespecs. Regtests just fine. OK for mainline? I believe that this is safe for backporting to 14-branch before the 14.2 release - thoughts? Regards Paul Change.Logs Description: Binary data Change.Logs Description: Binary data
Re: [Patch, fortran] PR84868 - [11/12/13/14/15 Regression] ICE in gfc_conv_descriptor_offset, at fortran/trans-array.c:208
Hi All, Harald has pointed out that I attached the ChangeLog twice and the patch not at all :-( Please find the patch duly attached. Paul On Sat, 13 Jul 2024 at 10:58, Paul Richard Thomas < paul.richard.tho...@gmail.com> wrote: > Hi All, > > After messing around with argument mapping, where I found and fixed > another bug, I realised that the problem lay with simplification of > len_trim with an argument that is the element of a parameter array. The fix > was then a straightforward lift of existing code in expr.cc. The mapping > bug is also fixed by supplying the se string length when building character > typespecs. > > Regtests just fine. OK for mainline? I believe that this is safe for > backporting to 14-branch before the 14.2 release - thoughts? > > Regards > > Paul > diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index 7a5d31c01a6..5199ede98fe 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -4637,6 +4637,76 @@ gfc_simplify_len_trim (gfc_expr *e, gfc_expr *kind) if (k == -1) return &gfc_bad_expr; + if (e->expr_type == EXPR_VARIABLE + && e->ts.type == BT_CHARACTER + && e->symtree->n.sym->attr.flavor == FL_PARAMETER + && e->ref && e->ref->type == REF_ARRAY + && e->ref->u.ar.dimen_type[0] == DIMEN_ELEMENT + && e->symtree->n.sym->value) +{ + char name[GFC_MAX_SYMBOL_LEN + 10]; + gfc_namespace *ns = e->symtree->n.sym->ns; + gfc_symtree *st; + gfc_expr *expr; + gfc_expr *p; + gfc_constructor *c; + int cnt = 0; + + sprintf (name, "_len_trim_%s", e->symtree->n.sym->name); + st = gfc_find_symtree (ns->sym_root, name); + if (st) + goto already_built; + + /* Recursively call this fcn to simplify the constructor elements. */ + expr = gfc_copy_expr (e->symtree->n.sym->value); + expr->ts.type = BT_INTEGER; + expr->ts.kind = k; + expr->ts.u.cl = NULL; + expr->rank = 1; + c = gfc_constructor_first (expr->value.constructor); + for (; c; c = gfc_constructor_next (c)) + { + if (c->iterator) + continue; + + if (c->expr && c->expr->ts.type == BT_CHARACTER) + { + p = gfc_simplify_len_trim (c->expr, kind); + if (p == NULL) + goto clean_up; + gfc_replace_expr (c->expr, p); + cnt++; + } + } + + if (cnt) + { + /* Build a new parameter to take the result. */ + st = gfc_new_symtree (&ns->sym_root, name); + st->n.sym = gfc_new_symbol (st->name, ns); + st->n.sym->value = expr; + st->n.sym->ts = expr->ts; + st->n.sym->attr.dimension = 1; + st->n.sym->attr.save = SAVE_IMPLICIT; + st->n.sym->attr.flavor = FL_PARAMETER; + st->n.sym->as = gfc_copy_array_spec (e->symtree->n.sym->as); + gfc_set_sym_referenced (st->n.sym); + st->n.sym->refs++; + +already_built: + /* Build a return expression. */ + expr = gfc_copy_expr (e); + expr->ts = st->n.sym->ts; + expr->symtree = st; + expr->rank = 0; + return expr; + } + +clean_up: + gfc_free_expr (expr); + return NULL; +} + if (e->expr_type != EXPR_CONSTANT) return NULL; diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 477c2720187..fe872a661ec 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -4490,12 +4490,15 @@ gfc_get_interface_mapping_charlen (gfc_interface_mapping * mapping, static tree gfc_get_interface_mapping_array (stmtblock_t * block, gfc_symbol * sym, - gfc_packed packed, tree data) + gfc_packed packed, tree data, tree len) { tree type; tree var; - type = gfc_typenode_for_spec (&sym->ts); + if (len != NULL_TREE && (TREE_CONSTANT (len) || VAR_P (len))) +type = gfc_get_character_type_len (sym->ts.kind, len); + else +type = gfc_typenode_for_spec (&sym->ts); type = gfc_get_nodesc_array_type (type, sym->as, packed, !sym->attr.target && !sym->attr.pointer && !sym->attr.proc_pointer); @@ -4642,7 +4645,8 @@ gfc_add_interface_mapping (gfc_interface_mapping * mapping, convert it to a boundless character type. */ else if (!sym->attr.dimension && sym->ts.type == BT_CHARACTER) { - tmp = gfc_get_character_type_len (sym->ts.kind, NULL); + se->string_length = gfc_evaluate_now (se->string_length, &se->pre); + tmp = gfc_get_character_type_len (sym->ts.kind, se->string_length); tmp = build_pointer_type (tmp); if (sym->attr.pointer) value = build_fold_indirect_ref_loc (input_location, @@ -4661,7 +4665,7 @@ gfc_add_interface_mapping (gfc_interface_mapping * mapping, /* For character(*), use the actual argument's descriptor. */ else if (sym->ts.type == BT_CHARACTER && !new_sym->ts.u.cl->length) value = build_fold_indirect_ref_loc (input_location, - se->expr); + se->expr); /* If the argument is an array descriptor, use it to determine information about the actual argument's shape. */ @@ -4675,7 +4679,8 @@ gfc_add_interface_mapping (gfc_interface_ma
Re: [PATCH] fortran: Correctly evaluate the MASK argument of MINLOC/MAXLOC
Hi Mikael, The fix is blindingly obvious :-) Not only that, the failing testcase runs correctly. OK for mainline and please backport to 14-branch before the 14.2 release. Thanks for the patch Paul On Sat, 13 Jul 2024 at 10:48, Mikael Morin wrote: > From: Mikael Morin > > Hello, > > I'm currently testing this on x86_64-linux. > I plan to push to master if all goes well. > > Mikael > > -- 8< -- > > Add the preliminary code that the generated expression for MASK may depend > on when generating the inline code to evaluate MINLOC or MAXLOC with a > scalar MASK. > > The generated code was only keeping the generated expression but not the > preliminary code, which was sufficient for simple cases such as data > references or simple (scalar) function calls, but was bogus with more > complicated ones. > > gcc/fortran/ChangeLog: > > * trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Add the > preliminary code generated for MASK to the preliminary code of > MINLOC/MAXLOC. > > gcc/testsuite/ChangeLog: > > * gfortran.dg/minmaxloc_17.f90: New test. > --- > gcc/fortran/trans-intrinsic.cc | 1 + > gcc/testsuite/gfortran.dg/minmaxloc_17.f90 | 33 ++ > 2 files changed, 34 insertions(+) > create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_17.f90 > > diff --git a/gcc/fortran/trans-intrinsic.cc > b/gcc/fortran/trans-intrinsic.cc > index cadbd177452..180d0d7a88c 100644 > --- a/gcc/fortran/trans-intrinsic.cc > +++ b/gcc/fortran/trans-intrinsic.cc > @@ -5749,6 +5749,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr > * expr, enum tree_code op) > >gfc_init_se (&maskse, NULL); >gfc_conv_expr_val (&maskse, maskexpr); > + gfc_add_block_to_block (&se->pre, &maskse.pre); >gfc_init_block (&block); >gfc_add_block_to_block (&block, &loop.pre); >gfc_add_block_to_block (&block, &loop.post); > diff --git a/gcc/testsuite/gfortran.dg/minmaxloc_17.f90 > b/gcc/testsuite/gfortran.dg/minmaxloc_17.f90 > new file mode 100644 > index 000..7e6e586ab03 > --- /dev/null > +++ b/gcc/testsuite/gfortran.dg/minmaxloc_17.f90 > @@ -0,0 +1,33 @@ > +! { dg-do run } > +! > +! Check that the code necessary to evaluate MINLOC's or MAXLOC's MASK > +! argument is correctly generated. > + > +program p > + implicit none > + integer, parameter :: data10(*) = (/ 2, 5, 2, 0, 6, 5, 3, 6, 0, 1 /) > + logical, parameter :: mask10(*) = (/ .false., .true., .false., & > + .false., .true., .true., & > + .true. , .true., .false., & > + .false. /) > + type bool_wrapper > +logical :: l > + end type > + call check_minloc > + call check_maxloc > +contains > + subroutine check_minloc > +integer :: a(10) > +integer :: r > +a = data10 > +r = minloc(a, dim = 1, mask = sum(a) > 0) > +if (r /= 4) stop 11 > + end subroutine > + subroutine check_maxloc > +integer :: a(10) > +integer :: r > +a = data10 > +r = maxloc(a, dim = 1, mask = sum(a) > 0) > +if (r /= 5) stop 18 > + end subroutine > +end program > -- > 2.43.0 > >