diff -Nrcpad gcc-4.3.0/gcc/fortran/ChangeLog gcc-4.3.1/gcc/fortran/ChangeLog *** gcc-4.3.0/gcc/fortran/ChangeLog Wed Mar 5 17:43:00 2008 --- gcc-4.3.1/gcc/fortran/ChangeLog Fri Jun 6 14:29:15 2008 *************** *** 1,3 **** --- 1,159 ---- + 2008-06-06 Release Manager + + * GCC 4.3.1 released. + + 2008-05-18 Francois-Xavier Coudert + + PR fortran/36176 + * target-memory.c (gfc_target_expr_size): Correctly treat + substrings. + (gfc_target_encode_expr): Likewise. + (gfc_interpret_complex): Whitespace change. + + 2008-05-17 Jerry DeLisle + + Backport from mainline: + PR fortran/35184 + * trans-array.c (gfc_conv_array_index_offset): Remove + unnecessary assert. + + 2008-05-17 Paul Thomas + + Backport from mainline: + PR fortran/35756 + PR fortran/35759 + * trans-stmt.c (gfc_trans_where): Tighten up the dependency + check for calling gfc_trans_where_3. + + PR fortran/35743 + * trans-stmt.c (gfc_trans_where_2): Set the mask size to zero + if it is calculated to be negative. + + PR fortran/35745 + * trans-stmt.c (gfc_trans_where_3, gfc_trans_where_assign): Set + ss->where for scalar right hand sides. + * trans-array.c (gfc_add_loop_ss_code): If ss->where is set do + not evaluate scalars outside the loop. Clean up whitespace. + * trans.h : Add a bitfield 'where' to gfc_ss. + + PR fortran/36233 + * interface.c (compare_actual_formal): Do not check sizes if the + actual is BT_PROCEDURE. + + 2008-05-13 Paul Thomas + + PR fortran/35997 + * module.c (find_symbol): Do not return a result for a symbol + that has been renamed in another module. + + 2008-05-01 Paul Thomas + + PR fortran/35864 + * expr.c (scalarize_intrinsic_call): Reorder identification of + array argument so that if one is not found a segfault does not + occur. Return FAILURE if all scalar arguments. + + PR fortran/35780 + * expr.c (scalarize_intrinsic_call): Identify which argument is + an array and use that as the template. + (check_init_expr): Remove tests that first argument is an array + in the call to scalarize_intrinsic_call. + + 2008-04-26 Jerry DeLisle + Francois-Xavier Coudert + + PR fortran/35994 + * trans-instrinsic.c (gfc_conv_intrinsic_minmaxloc): + Correctly adjust loop counter offset. + + 2008-04-19 Paul Thomas + + PR fortran/35944 + PR fortran/35946 + PR fortran/35947 + * trans_array.c (gfc_trans_array_constructor): Temporarily + realign loop, if loop->from is not zero, before creating + the temporary array and provide an offset. + + PR fortran/35959 + * trans-decl.c (gfc_init_default_dt): Add gfc_ prefix to name + and allow for NULL body. Change all references from + init_default_dt to gfc_init_default_dt. + * trans.h : Add prototype for gfc_init_default_dt. + * trans-array.c (gfc_trans_deferred_vars): After nullification + call gfc_init_default_dt for derived types with allocatable + components. + + 2008-04-18 Jerry DeLisle + + PR fortran/35724 + * iresolve.c (gfc_resolve_eoshift): Check for NULL symtree in + test for optional argument attribute. + + 2008-04-16 Paul Thomas + + PR fortran/35932 + * trans-intrinsic.c (gfc_conv_intrinsic_char): Even though KIND + is not used, the argument must be converted. + + 2008-04-16 Jakub Jelinek + + PR target/35662 + * f95-lang.c (gfc_init_builtin_functions): Make sure + BUILT_IN_SINCOS{,F,L} types aren't varargs. + + 2008-04-03 Jakub Jelinek + + PR fortran/35786 + * openmp.c (resolve_omp_clauses): Diagnose if a clause symbol + isn't a variable. + + 2008-04-01 Joseph Myers + + * gfortran.texi: Include gpl_v3.texi instead of gpl.texi + * Make-lang.in (GFORTRAN_TEXI): Include gpl_v3.texi instead of + gpl.texi. + + 2008-03-30 Paul Thomas + + PR fortran/35740 + * resolve.c (resolve_function, resolve_call): If the procedure + is elemental do not look for noncopying intrinsics. + + 2008-03-29 Paul Thomas + + PR fortran/35698 + * trans-array.c (gfc_array_init_size): Set 'size' zero if + negative in one dimension. + + PR fortran/35702 + * trans-expr.c (gfc_trans_string_copy): Only assign a char + directly if the lhs and rhs types are the same. + + 2008-03-27 Jerry DeLisle + + PR fortran/35724 + * iresolve.c (gfc_resolve_cshift): Check for NULL symtree in + test for optional argument attribute. + + 2008-03-24 Paul Thomas + + PR fortran/34813 + * resolve.c (resolve_structure_cons): It is an error to assign + NULL to anything other than a pointer or allocatable component. + + PR fortran/33295 + * resolve.c (resolve_symbol): If the symbol is a derived type, + resolve the derived type. If the symbol is a derived type + function, ensure that the derived type is visible in the same + namespace as the function. + + 2008-03-14 Paul Thomas + + PR fortran/35474 + * module.c (mio_symtree_ref): After providing a symbol for a + missing equivalence member, resolve and NULL the fixups. + 2008-03-05 Release Manager * GCC 4.3.0 released. diff -Nrcpad gcc-4.3.0/gcc/fortran/Make-lang.in gcc-4.3.1/gcc/fortran/Make-lang.in *** gcc-4.3.0/gcc/fortran/Make-lang.in Wed Feb 6 21:51:24 2008 --- gcc-4.3.1/gcc/fortran/Make-lang.in Tue Apr 1 18:49:36 2008 *************** GFORTRAN_TEXI = \ *** 149,155 **** $(srcdir)/fortran/intrinsic.texi \ $(srcdir)/fortran/invoke.texi \ $(srcdir)/doc/include/fdl.texi \ ! $(srcdir)/doc/include/gpl.texi \ $(srcdir)/doc/include/funding.texi \ $(srcdir)/doc/include/gcc-common.texi \ gcc-vers.texi --- 149,155 ---- $(srcdir)/fortran/intrinsic.texi \ $(srcdir)/fortran/invoke.texi \ $(srcdir)/doc/include/fdl.texi \ ! $(srcdir)/doc/include/gpl_v3.texi \ $(srcdir)/doc/include/funding.texi \ $(srcdir)/doc/include/gcc-common.texi \ gcc-vers.texi diff -Nrcpad gcc-4.3.0/gcc/fortran/expr.c gcc-4.3.1/gcc/fortran/expr.c *** gcc-4.3.0/gcc/fortran/expr.c Thu Jan 31 22:20:47 2008 --- gcc-4.3.1/gcc/fortran/expr.c Thu May 1 07:31:28 2008 *************** scalarize_intrinsic_call (gfc_expr *e) *** 1701,1717 **** gfc_actual_arglist *a, *b; gfc_constructor *args[5], *ctor, *new_ctor; gfc_expr *expr, *old; ! int n, i, rank[5]; old = gfc_copy_expr (e); - /* Assume that the old expression carries the type information and - that the first arg carries all the shape information. */ - expr = gfc_copy_expr (old->value.function.actual->expr); gfc_free_constructor (expr->value.constructor); expr->value.constructor = NULL; expr->ts = old->ts; expr->expr_type = EXPR_ARRAY; /* Copy the array argument constructors into an array, with nulls --- 1701,1733 ---- gfc_actual_arglist *a, *b; gfc_constructor *args[5], *ctor, *new_ctor; gfc_expr *expr, *old; ! int n, i, rank[5], array_arg; ! ! /* Find which, if any, arguments are arrays. Assume that the old ! expression carries the type information and that the first arg ! that is an array expression carries all the shape information.*/ ! n = array_arg = 0; ! a = e->value.function.actual; ! for (; a; a = a->next) ! { ! n++; ! if (a->expr->expr_type != EXPR_ARRAY) ! continue; ! array_arg = n; ! expr = gfc_copy_expr (a->expr); ! break; ! } ! ! if (!array_arg) ! return FAILURE; old = gfc_copy_expr (e); gfc_free_constructor (expr->value.constructor); expr->value.constructor = NULL; expr->ts = old->ts; + expr->where = old->where; expr->expr_type = EXPR_ARRAY; /* Copy the array argument constructors into an array, with nulls *************** scalarize_intrinsic_call (gfc_expr *e) *** 1744,1757 **** n++; } - for (i = 1; i < n; i++) - if (rank[i] && rank[i] != rank[0]) - goto compliance; ! /* Using the first argument as the master, step through the array calling the function for each element and advancing the array constructors together. */ ! ctor = args[0]; new_ctor = NULL; for (; ctor; ctor = ctor->next) { --- 1760,1770 ---- n++; } ! /* Using the array argument as the master, step through the array calling the function for each element and advancing the array constructors together. */ ! ctor = args[array_arg - 1]; new_ctor = NULL; for (; ctor; ctor = ctor->next) { *************** scalarize_intrinsic_call (gfc_expr *e) *** 1785,1801 **** b = b->next; } ! /* Simplify the function calls. */ ! if (gfc_simplify_expr (new_ctor->expr, 0) == FAILURE) ! goto cleanup; for (i = 0; i < n; i++) if (args[i]) args[i] = args[i]->next; for (i = 1; i < n; i++) ! if (rank[i] && ((args[i] != NULL && args[0] == NULL) ! || (args[i] == NULL && args[0] != NULL))) goto compliance; } --- 1798,1815 ---- b = b->next; } ! /* Simplify the function calls. If the simplification fails, the ! error will be flagged up down-stream or the library will deal ! with it. */ ! gfc_simplify_expr (new_ctor->expr, 0); for (i = 0; i < n; i++) if (args[i]) args[i] = args[i]->next; for (i = 1; i < n; i++) ! if (rank[i] && ((args[i] != NULL && args[array_arg - 1] == NULL) ! || (args[i] == NULL && args[array_arg - 1] != NULL))) goto compliance; } *************** check_init_expr (gfc_expr *e) *** 2186,2196 **** array argument. */ isym = gfc_find_function (e->symtree->n.sym->name); if (isym && isym->elemental ! && e->value.function.actual->expr->expr_type == EXPR_ARRAY) ! { ! if ((t = scalarize_intrinsic_call (e)) == SUCCESS) ! break; ! } } if (m == MATCH_YES) --- 2200,2207 ---- array argument. */ isym = gfc_find_function (e->symtree->n.sym->name); if (isym && isym->elemental ! && (t = scalarize_intrinsic_call (e)) == SUCCESS) ! break; } if (m == MATCH_YES) diff -Nrcpad gcc-4.3.0/gcc/fortran/f95-lang.c gcc-4.3.1/gcc/fortran/f95-lang.c *** gcc-4.3.0/gcc/fortran/f95-lang.c Thu Feb 28 07:08:51 2008 --- gcc-4.3.1/gcc/fortran/f95-lang.c Wed Apr 16 16:05:51 2008 *************** *** 1,5 **** /* gfortran backend interface ! Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Contributed by Paul Brook. --- 1,5 ---- /* gfortran backend interface ! Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Contributed by Paul Brook. *************** gfc_init_builtin_functions (void) *** 853,873 **** ptype = build_pointer_type (float_type_node); tmp = tree_cons (NULL_TREE, float_type_node, tree_cons (NULL_TREE, ptype, ! build_tree_list (NULL_TREE, ptype))); func_float_floatp_floatp = build_function_type (void_type_node, tmp); ptype = build_pointer_type (double_type_node); tmp = tree_cons (NULL_TREE, double_type_node, tree_cons (NULL_TREE, ptype, ! build_tree_list (NULL_TREE, ptype))); func_double_doublep_doublep = build_function_type (void_type_node, tmp); ptype = build_pointer_type (long_double_type_node); tmp = tree_cons (NULL_TREE, long_double_type_node, tree_cons (NULL_TREE, ptype, ! build_tree_list (NULL_TREE, ptype))); func_longdouble_longdoublep_longdoublep = build_function_type (void_type_node, tmp); --- 853,873 ---- ptype = build_pointer_type (float_type_node); tmp = tree_cons (NULL_TREE, float_type_node, tree_cons (NULL_TREE, ptype, ! tree_cons (NULL_TREE, ptype, void_list_node))); func_float_floatp_floatp = build_function_type (void_type_node, tmp); ptype = build_pointer_type (double_type_node); tmp = tree_cons (NULL_TREE, double_type_node, tree_cons (NULL_TREE, ptype, ! tree_cons (NULL_TREE, ptype, void_list_node))); func_double_doublep_doublep = build_function_type (void_type_node, tmp); ptype = build_pointer_type (long_double_type_node); tmp = tree_cons (NULL_TREE, long_double_type_node, tree_cons (NULL_TREE, ptype, ! tree_cons (NULL_TREE, ptype, void_list_node))); func_longdouble_longdoublep_longdoublep = build_function_type (void_type_node, tmp); diff -Nrcpad gcc-4.3.0/gcc/fortran/gfortran.info gcc-4.3.1/gcc/fortran/gfortran.info *** gcc-4.3.0/gcc/fortran/gfortran.info Wed Mar 5 18:56:25 2008 --- gcc-4.3.1/gcc/fortran/gfortran.info Fri Jun 6 15:32:21 2008 *************** *** 1,5 **** This is doc/gfortran.info, produced by makeinfo version 4.11 from ! /usr/src/gcc-4.3.0/gcc-4.3.0/gcc-4.3.0/gcc/fortran/gfortran.texi. Copyright (C) 1999-2007 Free Software Foundation, Inc. --- 1,5 ---- This is doc/gfortran.info, produced by makeinfo version 4.11 from ! /gcc-4.3/gcc-4.3.1/gcc-4.3.1/gcc/fortran/gfortran.texi. Copyright (C) 1999-2007 Free Software Foundation, Inc. *************** Environment Options *** 11712,12011 ****  File: gfortran.info, Node: Copying, Next: GNU Free Documentation License, Prev: Contributing, Up: Top ! GNU GENERAL PUBLIC LICENSE ************************** ! Version 2, June 1991 ! Copyright (C) 1989, 1991 Free Software Foundation, Inc. ! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA ! Everyone is permitted to copy and distribute verbatim copies ! of this license document, but changing it is not allowed. Preamble ======== ! The licenses for most software are designed to take away your freedom ! to share and change it. By contrast, the GNU General Public License is ! intended to guarantee your freedom to share and change free ! software--to make sure the software is free for all its users. This ! General Public License applies to most of the Free Software ! Foundation's software and to any other program whose authors commit to ! using it. (Some other Free Software Foundation software is covered by ! the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for ! this service if you wish), that you receive source code or can get it ! if you want it, that you can change the software or use pieces of it in ! new free programs; and that you know you can do these things. ! To protect your rights, we need to make restrictions that forbid ! anyone to deny you these rights or to ask you to surrender the rights. ! These restrictions translate to certain responsibilities for you if you ! distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether ! gratis or for a fee, you must give the recipients all the rights that ! you have. You must make sure that they, too, receive or can get the ! source code. And you must show them these terms so they know their ! rights. ! We protect your rights with two steps: (1) copyright the software, ! and (2) offer you this license which gives you legal permission to copy, ! distribute and/or modify the software. ! Also, for each author's protection and ours, we want to make certain ! that everyone understands that there is no warranty for this free ! software. If the software is modified by someone else and passed on, we ! want its recipients to know that what they have is not the original, so ! that any problems introduced by others will not reflect on the original ! authors' reputations. ! Finally, any free program is threatened constantly by software ! patents. We wish to avoid the danger that redistributors of a free ! program will individually obtain patent licenses, in effect making the ! program proprietary. To prevent this, we have made it clear that any ! patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. ! TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION ! 0. This License applies to any program or other work which contains a ! notice placed by the copyright holder saying it may be distributed ! under the terms of this General Public License. The "Program", ! below, refers to any such program or work, and a "work based on ! the Program" means either the Program or any derivative work under ! copyright law: that is to say, a work containing the Program or a ! portion of it, either verbatim or with modifications and/or ! translated into another language. (Hereinafter, translation is ! included without limitation in the term "modification".) Each ! licensee is addressed as "you". ! Activities other than copying, distribution and modification are ! not covered by this License; they are outside its scope. The act ! of running the Program is not restricted, and the output from the ! Program is covered only if its contents constitute a work based on ! the Program (independent of having been made by running the ! Program). Whether that is true depends on what the Program does. ! 1. You may copy and distribute verbatim copies of the Program's ! source code as you receive it, in any medium, provided that you ! conspicuously and appropriately publish on each copy an appropriate ! copyright notice and disclaimer of warranty; keep intact all the ! notices that refer to this License and to the absence of any ! warranty; and give any other recipients of the Program a copy of ! this License along with the Program. ! You may charge a fee for the physical act of transferring a copy, ! and you may at your option offer warranty protection in exchange ! for a fee. ! 2. You may modify your copy or copies of the Program or any portion ! of it, thus forming a work based on the Program, and copy and ! distribute such modifications or work under the terms of Section 1 ! above, provided that you also meet all of these conditions: ! a. You must cause the modified files to carry prominent notices ! stating that you changed the files and the date of any change. ! b. You must cause any work that you distribute or publish, that ! in whole or in part contains or is derived from the Program ! or any part thereof, to be licensed as a whole at no charge ! to all third parties under the terms of this License. ! c. If the modified program normally reads commands interactively ! when run, you must cause it, when started running for such ! interactive use in the most ordinary way, to print or display ! an announcement including an appropriate copyright notice and ! a notice that there is no warranty (or else, saying that you ! provide a warranty) and that users may redistribute the ! program under these conditions, and telling the user how to ! view a copy of this License. (Exception: if the Program ! itself is interactive but does not normally print such an ! announcement, your work based on the Program is not required ! to print an announcement.) ! These requirements apply to the modified work as a whole. If ! identifiable sections of that work are not derived from the ! Program, and can be reasonably considered independent and separate ! works in themselves, then this License, and its terms, do not ! apply to those sections when you distribute them as separate ! works. But when you distribute the same sections as part of a ! whole which is a work based on the Program, the distribution of ! the whole must be on the terms of this License, whose permissions ! for other licensees extend to the entire whole, and thus to each ! and every part regardless of who wrote it. ! Thus, it is not the intent of this section to claim rights or ! contest your rights to work written entirely by you; rather, the ! intent is to exercise the right to control the distribution of ! derivative or collective works based on the Program. ! In addition, mere aggregation of another work not based on the ! Program with the Program (or with a work based on the Program) on ! a volume of a storage or distribution medium does not bring the ! other work under the scope of this License. ! 3. You may copy and distribute the Program (or a work based on it, ! under Section 2) in object code or executable form under the terms ! of Sections 1 and 2 above provided that you also do one of the ! following: ! a. Accompany it with the complete corresponding machine-readable ! source code, which must be distributed under the terms of ! Sections 1 and 2 above on a medium customarily used for ! software interchange; or, ! b. Accompany it with a written offer, valid for at least three ! years, to give any third party, for a charge no more than your ! cost of physically performing source distribution, a complete ! machine-readable copy of the corresponding source code, to be ! distributed under the terms of Sections 1 and 2 above on a ! medium customarily used for software interchange; or, ! c. Accompany it with the information you received as to the offer ! to distribute corresponding source code. (This alternative is ! allowed only for noncommercial distribution and only if you ! received the program in object code or executable form with ! such an offer, in accord with Subsection b above.) ! The source code for a work means the preferred form of the work for ! making modifications to it. For an executable work, complete ! source code means all the source code for all modules it contains, ! plus any associated interface definition files, plus the scripts ! used to control compilation and installation of the executable. ! However, as a special exception, the source code distributed need ! not include anything that is normally distributed (in either ! source or binary form) with the major components (compiler, ! kernel, and so on) of the operating system on which the executable ! runs, unless that component itself accompanies the executable. ! If distribution of executable or object code is made by offering ! access to copy from a designated place, then offering equivalent ! access to copy the source code from the same place counts as ! distribution of the source code, even though third parties are not ! compelled to copy the source along with the object code. ! 4. You may not copy, modify, sublicense, or distribute the Program ! except as expressly provided under this License. Any attempt ! otherwise to copy, modify, sublicense or distribute the Program is ! void, and will automatically terminate your rights under this ! License. However, parties who have received copies, or rights, ! from you under this License will not have their licenses ! terminated so long as such parties remain in full compliance. ! 5. You are not required to accept this License, since you have not ! signed it. However, nothing else grants you permission to modify ! or distribute the Program or its derivative works. These actions ! are prohibited by law if you do not accept this License. ! Therefore, by modifying or distributing the Program (or any work ! based on the Program), you indicate your acceptance of this ! License to do so, and all its terms and conditions for copying, ! distributing or modifying the Program or works based on it. ! 6. Each time you redistribute the Program (or any work based on the ! Program), the recipient automatically receives a license from the ! original licensor to copy, distribute or modify the Program ! subject to these terms and conditions. You may not impose any ! further restrictions on the recipients' exercise of the rights ! granted herein. You are not responsible for enforcing compliance ! by third parties to this License. ! 7. If, as a consequence of a court judgment or allegation of patent ! infringement or for any other reason (not limited to patent ! issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this ! License. If you cannot distribute so as to satisfy simultaneously ! your obligations under this License and any other pertinent ! obligations, then as a consequence you may not distribute the ! Program at all. For example, if a patent license would not permit ! royalty-free redistribution of the Program by all those who ! receive copies directly or indirectly through you, then the only ! way you could satisfy both it and this License would be to refrain ! entirely from distribution of the Program. ! ! If any portion of this section is held invalid or unenforceable ! under any particular circumstance, the balance of the section is ! intended to apply and the section as a whole is intended to apply ! in other circumstances. ! It is not the purpose of this section to induce you to infringe any ! patents or other property right claims or to contest validity of ! any such claims; this section has the sole purpose of protecting ! the integrity of the free software distribution system, which is ! implemented by public license practices. Many people have made ! generous contributions to the wide range of software distributed ! through that system in reliance on consistent application of that ! system; it is up to the author/donor to decide if he or she is ! willing to distribute software through any other system and a ! licensee cannot impose that choice. ! This section is intended to make thoroughly clear what is believed ! to be a consequence of the rest of this License. ! 8. If the distribution and/or use of the Program is restricted in ! certain countries either by patents or by copyrighted interfaces, ! the original copyright holder who places the Program under this ! License may add an explicit geographical distribution limitation ! excluding those countries, so that distribution is permitted only ! in or among countries not thus excluded. In such case, this ! License incorporates the limitation as if written in the body of ! this License. ! 9. The Free Software Foundation may publish revised and/or new ! versions of the General Public License from time to time. Such ! new versions will be similar in spirit to the present version, but ! may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the ! Program specifies a version number of this License which applies ! to it and "any later version", you have the option of following ! the terms and conditions either of that version or of any later ! version published by the Free Software Foundation. If the Program ! does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. ! 10. If you wish to incorporate parts of the Program into other free ! programs whose distribution conditions are different, write to the ! author to ask for permission. For software which is copyrighted ! by the Free Software Foundation, write to the Free Software ! Foundation; we sometimes make exceptions for this. Our decision ! will be guided by the two goals of preserving the free status of ! all derivatives of our free software and of promoting the sharing ! and reuse of software generally. ! NO WARRANTY ! 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO ! WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE ! LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT ! HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT ! WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT ! NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND ! FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE ! QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE ! PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY ! SERVICING, REPAIR OR CORRECTION. ! 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN ! WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY ! MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE ! LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, ! INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR ! INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF ! DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU ! OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY ! OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ! ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ! END OF TERMS AND CONDITIONS ! Appendix: How to Apply These Terms to Your New Programs ! ======================================================= If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it --- 11712,12382 ----  File: gfortran.info, Node: Copying, Next: GNU Free Documentation License, Prev: Contributing, Up: Top ! GNU General Public License ************************** ! Version 3, 29 June 2007 ! Copyright (C) 2007 Free Software Foundation, Inc. `http://fsf.org/' ! Everyone is permitted to copy and distribute verbatim copies of this ! license document, but changing it is not allowed. Preamble ======== ! The GNU General Public License is a free, copyleft license for software ! and other kinds of works. ! ! The licenses for most software and other practical works are designed ! to take away your freedom to share and change the works. By contrast, ! the GNU General Public License is intended to guarantee your freedom to ! share and change all versions of a program-to make sure it remains free ! software for all its users. We, the Free Software Foundation, use the ! GNU General Public License for most of our software; it applies also to ! any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for ! them if you wish), that you receive source code or can get it if you ! want it, that you can change the software or use pieces of it in new ! free programs, and that you know you can do these things. ! To protect your rights, we need to prevent others from denying you ! these rights or asking you to surrender the rights. Therefore, you ! have certain responsibilities if you distribute copies of the software, ! or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether ! gratis or for a fee, you must pass on to the recipients the same ! freedoms that you received. You must make sure that they, too, receive ! or can get the source code. And you must show them these terms so they ! know their rights. ! Developers that use the GNU GPL protect your rights with two steps: ! (1) assert copyright on the software, and (2) offer you this License ! giving you legal permission to copy, distribute and/or modify it. ! For the developers' and authors' protection, the GPL clearly explains ! that there is no warranty for this free software. For both users' and ! authors' sake, the GPL requires that modified versions be marked as ! changed, so that their problems will not be attributed erroneously to ! authors of previous versions. ! Some devices are designed to deny users access to install or run ! modified versions of the software inside them, although the ! manufacturer can do so. This is fundamentally incompatible with the ! aim of protecting users' freedom to change the software. The ! systematic pattern of such abuse occurs in the area of products for ! individuals to use, which is precisely where it is most unacceptable. ! Therefore, we have designed this version of the GPL to prohibit the ! practice for those products. If such problems arise substantially in ! other domains, we stand ready to extend this provision to those domains ! in future versions of the GPL, as needed to protect the freedom of ! users. ! ! Finally, every program is threatened constantly by software patents. ! States should not allow patents to restrict development and use of ! software on general-purpose computers, but in those that do, we wish to ! avoid the special danger that patents applied to a free program could ! make it effectively proprietary. To prevent this, the GPL assures that ! patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. ! TERMS AND CONDITIONS ! ==================== ! 0. Definitions. ! "This License" refers to version 3 of the GNU General Public ! License. ! "Copyright" also means copyright-like laws that apply to other ! kinds of works, such as semiconductor masks. ! "The Program" refers to any copyrightable work licensed under this ! License. Each licensee is addressed as "you". "Licensees" and ! "recipients" may be individuals or organizations. ! To "modify" a work means to copy from or adapt all or part of the ! work in a fashion requiring copyright permission, other than the ! making of an exact copy. The resulting work is called a "modified ! version" of the earlier work or a work "based on" the earlier work. ! A "covered work" means either the unmodified Program or a work ! based on the Program. ! To "propagate" a work means to do anything with it that, without ! permission, would make you directly or secondarily liable for ! infringement under applicable copyright law, except executing it ! on a computer or modifying a private copy. Propagation includes ! copying, distribution (with or without modification), making ! available to the public, and in some countries other activities as ! well. ! To "convey" a work means any kind of propagation that enables other ! parties to make or receive copies. Mere interaction with a user ! through a computer network, with no transfer of a copy, is not ! conveying. ! An interactive user interface displays "Appropriate Legal Notices" ! to the extent that it includes a convenient and prominently visible ! feature that (1) displays an appropriate copyright notice, and (2) ! tells the user that there is no warranty for the work (except to ! the extent that warranties are provided), that licensees may ! convey the work under this License, and how to view a copy of this ! License. If the interface presents a list of user commands or ! options, such as a menu, a prominent item in the list meets this ! criterion. ! 1. Source Code. ! The "source code" for a work means the preferred form of the work ! for making modifications to it. "Object code" means any ! non-source form of a work. ! A "Standard Interface" means an interface that either is an ! official standard defined by a recognized standards body, or, in ! the case of interfaces specified for a particular programming ! language, one that is widely used among developers working in that ! language. ! The "System Libraries" of an executable work include anything, ! other than the work as a whole, that (a) is included in the normal ! form of packaging a Major Component, but which is not part of that ! Major Component, and (b) serves only to enable use of the work ! with that Major Component, or to implement a Standard Interface ! for which an implementation is available to the public in source ! code form. A "Major Component", in this context, means a major ! essential component (kernel, window system, and so on) of the ! specific operating system (if any) on which the executable work ! runs, or a compiler used to produce the work, or an object code ! interpreter used to run it. ! The "Corresponding Source" for a work in object code form means all ! the source code needed to generate, install, and (for an executable ! work) run the object code and to modify the work, including ! scripts to control those activities. However, it does not include ! the work's System Libraries, or general-purpose tools or generally ! available free programs which are used unmodified in performing ! those activities but which are not part of the work. For example, ! Corresponding Source includes interface definition files ! associated with source files for the work, and the source code for ! shared libraries and dynamically linked subprograms that the work ! is specifically designed to require, such as by intimate data ! communication or control flow between those subprograms and other ! parts of the work. ! The Corresponding Source need not include anything that users can ! regenerate automatically from other parts of the Corresponding ! Source. ! The Corresponding Source for a work in source code form is that ! same work. ! 2. Basic Permissions. ! All rights granted under this License are granted for the term of ! copyright on the Program, and are irrevocable provided the stated ! conditions are met. This License explicitly affirms your unlimited ! permission to run the unmodified Program. The output from running ! a covered work is covered by this License only if the output, ! given its content, constitutes a covered work. This License ! acknowledges your rights of fair use or other equivalent, as ! provided by copyright law. ! You may make, run and propagate covered works that you do not ! convey, without conditions so long as your license otherwise ! remains in force. You may convey covered works to others for the ! sole purpose of having them make modifications exclusively for ! you, or provide you with facilities for running those works, ! provided that you comply with the terms of this License in ! conveying all material for which you do not control copyright. ! Those thus making or running the covered works for you must do so ! exclusively on your behalf, under your direction and control, on ! terms that prohibit them from making any copies of your ! copyrighted material outside their relationship with you. ! Conveying under any other circumstances is permitted solely under ! the conditions stated below. Sublicensing is not allowed; section ! 10 makes it unnecessary. ! ! 3. Protecting Users' Legal Rights From Anti-Circumvention Law. ! ! No covered work shall be deemed part of an effective technological ! measure under any applicable law fulfilling obligations under ! article 11 of the WIPO copyright treaty adopted on 20 December ! 1996, or similar laws prohibiting or restricting circumvention of ! such measures. ! ! When you convey a covered work, you waive any legal power to forbid ! circumvention of technological measures to the extent such ! circumvention is effected by exercising rights under this License ! with respect to the covered work, and you disclaim any intention ! to limit operation or modification of the work as a means of ! enforcing, against the work's users, your or third parties' legal ! rights to forbid circumvention of technological measures. ! ! 4. Conveying Verbatim Copies. ! ! You may convey verbatim copies of the Program's source code as you ! receive it, in any medium, provided that you conspicuously and ! appropriately publish on each copy an appropriate copyright notice; ! keep intact all notices stating that this License and any ! non-permissive terms added in accord with section 7 apply to the ! code; keep intact all notices of the absence of any warranty; and ! give all recipients a copy of this License along with the Program. ! ! You may charge any price or no price for each copy that you convey, ! and you may offer support or warranty protection for a fee. ! ! 5. Conveying Modified Source Versions. ! ! You may convey a work based on the Program, or the modifications to ! produce it from the Program, in the form of source code under the ! terms of section 4, provided that you also meet all of these ! conditions: ! ! a. The work must carry prominent notices stating that you ! modified it, and giving a relevant date. ! ! b. The work must carry prominent notices stating that it is ! released under this License and any conditions added under ! section 7. This requirement modifies the requirement in ! section 4 to "keep intact all notices". ! ! c. You must license the entire work, as a whole, under this ! License to anyone who comes into possession of a copy. This ! License will therefore apply, along with any applicable ! section 7 additional terms, to the whole of the work, and all ! its parts, regardless of how they are packaged. This License ! gives no permission to license the work in any other way, but ! it does not invalidate such permission if you have separately ! received it. ! ! d. If the work has interactive user interfaces, each must display ! Appropriate Legal Notices; however, if the Program has ! interactive interfaces that do not display Appropriate Legal ! Notices, your work need not make them do so. ! ! A compilation of a covered work with other separate and independent ! works, which are not by their nature extensions of the covered ! work, and which are not combined with it such as to form a larger ! program, in or on a volume of a storage or distribution medium, is ! called an "aggregate" if the compilation and its resulting ! copyright are not used to limit the access or legal rights of the ! compilation's users beyond what the individual works permit. ! Inclusion of a covered work in an aggregate does not cause this ! License to apply to the other parts of the aggregate. ! ! 6. Conveying Non-Source Forms. ! ! You may convey a covered work in object code form under the terms ! of sections 4 and 5, provided that you also convey the ! machine-readable Corresponding Source under the terms of this ! License, in one of these ways: ! ! a. Convey the object code in, or embodied in, a physical product ! (including a physical distribution medium), accompanied by the ! Corresponding Source fixed on a durable physical medium ! customarily used for software interchange. ! ! b. Convey the object code in, or embodied in, a physical product ! (including a physical distribution medium), accompanied by a ! written offer, valid for at least three years and valid for ! as long as you offer spare parts or customer support for that ! product model, to give anyone who possesses the object code ! either (1) a copy of the Corresponding Source for all the ! software in the product that is covered by this License, on a ! durable physical medium customarily used for software ! interchange, for a price no more than your reasonable cost of ! physically performing this conveying of source, or (2) access ! to copy the Corresponding Source from a network server at no ! charge. ! ! c. Convey individual copies of the object code with a copy of ! the written offer to provide the Corresponding Source. This ! alternative is allowed only occasionally and noncommercially, ! and only if you received the object code with such an offer, ! in accord with subsection 6b. ! ! d. Convey the object code by offering access from a designated ! place (gratis or for a charge), and offer equivalent access ! to the Corresponding Source in the same way through the same ! place at no further charge. You need not require recipients ! to copy the Corresponding Source along with the object code. ! If the place to copy the object code is a network server, the ! Corresponding Source may be on a different server (operated ! by you or a third party) that supports equivalent copying ! facilities, provided you maintain clear directions next to ! the object code saying where to find the Corresponding Source. ! Regardless of what server hosts the Corresponding Source, you ! remain obligated to ensure that it is available for as long ! as needed to satisfy these requirements. ! ! e. Convey the object code using peer-to-peer transmission, ! provided you inform other peers where the object code and ! Corresponding Source of the work are being offered to the ! general public at no charge under subsection 6d. ! ! ! A separable portion of the object code, whose source code is ! excluded from the Corresponding Source as a System Library, need ! not be included in conveying the object code work. ! ! A "User Product" is either (1) a "consumer product", which means ! any tangible personal property which is normally used for personal, ! family, or household purposes, or (2) anything designed or sold for ! incorporation into a dwelling. In determining whether a product ! is a consumer product, doubtful cases shall be resolved in favor of ! coverage. For a particular product received by a particular user, ! "normally used" refers to a typical or common use of that class of ! product, regardless of the status of the particular user or of the ! way in which the particular user actually uses, or expects or is ! expected to use, the product. A product is a consumer product ! regardless of whether the product has substantial commercial, ! industrial or non-consumer uses, unless such uses represent the ! only significant mode of use of the product. ! ! "Installation Information" for a User Product means any methods, ! procedures, authorization keys, or other information required to ! install and execute modified versions of a covered work in that ! User Product from a modified version of its Corresponding Source. ! The information must suffice to ensure that the continued ! functioning of the modified object code is in no case prevented or ! interfered with solely because modification has been made. ! ! If you convey an object code work under this section in, or with, ! or specifically for use in, a User Product, and the conveying ! occurs as part of a transaction in which the right of possession ! and use of the User Product is transferred to the recipient in ! perpetuity or for a fixed term (regardless of how the transaction ! is characterized), the Corresponding Source conveyed under this ! section must be accompanied by the Installation Information. But ! this requirement does not apply if neither you nor any third party ! retains the ability to install modified object code on the User ! Product (for example, the work has been installed in ROM). ! ! The requirement to provide Installation Information does not ! include a requirement to continue to provide support service, ! warranty, or updates for a work that has been modified or ! installed by the recipient, or for the User Product in which it ! has been modified or installed. Access to a network may be denied ! when the modification itself materially and adversely affects the ! operation of the network or violates the rules and protocols for ! communication across the network. ! ! Corresponding Source conveyed, and Installation Information ! provided, in accord with this section must be in a format that is ! publicly documented (and with an implementation available to the ! public in source code form), and must require no special password ! or key for unpacking, reading or copying. ! ! 7. Additional Terms. ! ! "Additional permissions" are terms that supplement the terms of ! this License by making exceptions from one or more of its ! conditions. Additional permissions that are applicable to the ! entire Program shall be treated as though they were included in ! this License, to the extent that they are valid under applicable ! law. If additional permissions apply only to part of the Program, ! that part may be used separately under those permissions, but the ! entire Program remains governed by this License without regard to ! the additional permissions. ! ! When you convey a copy of a covered work, you may at your option ! remove any additional permissions from that copy, or from any part ! of it. (Additional permissions may be written to require their own ! removal in certain cases when you modify the work.) You may place ! additional permissions on material, added by you to a covered work, ! for which you have or can give appropriate copyright permission. ! ! Notwithstanding any other provision of this License, for material ! you add to a covered work, you may (if authorized by the copyright ! holders of that material) supplement the terms of this License ! with terms: ! ! a. Disclaiming warranty or limiting liability differently from ! the terms of sections 15 and 16 of this License; or ! ! b. Requiring preservation of specified reasonable legal notices ! or author attributions in that material or in the Appropriate ! Legal Notices displayed by works containing it; or ! ! c. Prohibiting misrepresentation of the origin of that material, ! or requiring that modified versions of such material be ! marked in reasonable ways as different from the original ! version; or ! ! d. Limiting the use for publicity purposes of names of licensors ! or authors of the material; or ! ! e. Declining to grant rights under trademark law for use of some ! trade names, trademarks, or service marks; or ! ! f. Requiring indemnification of licensors and authors of that ! material by anyone who conveys the material (or modified ! versions of it) with contractual assumptions of liability to ! the recipient, for any liability that these contractual ! assumptions directly impose on those licensors and authors. ! ! All other non-permissive additional terms are considered "further ! restrictions" within the meaning of section 10. If the Program as ! you received it, or any part of it, contains a notice stating that ! it is governed by this License along with a term that is a further ! restriction, you may remove that term. If a license document ! contains a further restriction but permits relicensing or ! conveying under this License, you may add to a covered work ! material governed by the terms of that license document, provided ! that the further restriction does not survive such relicensing or ! conveying. ! ! If you add terms to a covered work in accord with this section, you ! must place, in the relevant source files, a statement of the ! additional terms that apply to those files, or a notice indicating ! where to find the applicable terms. ! ! Additional terms, permissive or non-permissive, may be stated in ! the form of a separately written license, or stated as exceptions; ! the above requirements apply either way. ! ! 8. Termination. ! ! You may not propagate or modify a covered work except as expressly ! provided under this License. Any attempt otherwise to propagate or ! modify it is void, and will automatically terminate your rights ! under this License (including any patent licenses granted under ! the third paragraph of section 11). ! ! However, if you cease all violation of this License, then your ! license from a particular copyright holder is reinstated (a) ! provisionally, unless and until the copyright holder explicitly ! and finally terminates your license, and (b) permanently, if the ! copyright holder fails to notify you of the violation by some ! reasonable means prior to 60 days after the cessation. ! ! Moreover, your license from a particular copyright holder is ! reinstated permanently if the copyright holder notifies you of the ! violation by some reasonable means, this is the first time you have ! received notice of violation of this License (for any work) from ! that copyright holder, and you cure the violation prior to 30 days ! after your receipt of the notice. ! ! Termination of your rights under this section does not terminate ! the licenses of parties who have received copies or rights from ! you under this License. If your rights have been terminated and ! not permanently reinstated, you do not qualify to receive new ! licenses for the same material under section 10. ! ! 9. Acceptance Not Required for Having Copies. ! ! You are not required to accept this License in order to receive or ! run a copy of the Program. Ancillary propagation of a covered work ! occurring solely as a consequence of using peer-to-peer ! transmission to receive a copy likewise does not require ! acceptance. However, nothing other than this License grants you ! permission to propagate or modify any covered work. These actions ! infringe copyright if you do not accept this License. Therefore, ! by modifying or propagating a covered work, you indicate your ! acceptance of this License to do so. ! ! 10. Automatic Licensing of Downstream Recipients. ! ! Each time you convey a covered work, the recipient automatically ! receives a license from the original licensors, to run, modify and ! propagate that work, subject to this License. You are not ! responsible for enforcing compliance by third parties with this ! License. ! ! An "entity transaction" is a transaction transferring control of an ! organization, or substantially all assets of one, or subdividing an ! organization, or merging organizations. If propagation of a ! covered work results from an entity transaction, each party to that ! transaction who receives a copy of the work also receives whatever ! licenses to the work the party's predecessor in interest had or ! could give under the previous paragraph, plus a right to ! possession of the Corresponding Source of the work from the ! predecessor in interest, if the predecessor has it or can get it ! with reasonable efforts. ! ! You may not impose any further restrictions on the exercise of the ! rights granted or affirmed under this License. For example, you ! may not impose a license fee, royalty, or other charge for ! exercise of rights granted under this License, and you may not ! initiate litigation (including a cross-claim or counterclaim in a ! lawsuit) alleging that any patent claim is infringed by making, ! using, selling, offering for sale, or importing the Program or any ! portion of it. ! ! 11. Patents. ! ! A "contributor" is a copyright holder who authorizes use under this ! License of the Program or a work on which the Program is based. ! The work thus licensed is called the contributor's "contributor ! version". ! ! A contributor's "essential patent claims" are all patent claims ! owned or controlled by the contributor, whether already acquired or ! hereafter acquired, that would be infringed by some manner, ! permitted by this License, of making, using, or selling its ! contributor version, but do not include claims that would be ! infringed only as a consequence of further modification of the ! contributor version. For purposes of this definition, "control" ! includes the right to grant patent sublicenses in a manner ! consistent with the requirements of this License. ! ! Each contributor grants you a non-exclusive, worldwide, ! royalty-free patent license under the contributor's essential ! patent claims, to make, use, sell, offer for sale, import and ! otherwise run, modify and propagate the contents of its ! contributor version. ! ! In the following three paragraphs, a "patent license" is any ! express agreement or commitment, however denominated, not to ! enforce a patent (such as an express permission to practice a ! patent or covenant not to sue for patent infringement). To ! "grant" such a patent license to a party means to make such an ! agreement or commitment not to enforce a patent against the party. ! ! If you convey a covered work, knowingly relying on a patent ! license, and the Corresponding Source of the work is not available ! for anyone to copy, free of charge and under the terms of this ! License, through a publicly available network server or other ! readily accessible means, then you must either (1) cause the ! Corresponding Source to be so available, or (2) arrange to deprive ! yourself of the benefit of the patent license for this particular ! work, or (3) arrange, in a manner consistent with the requirements ! of this License, to extend the patent license to downstream ! recipients. "Knowingly relying" means you have actual knowledge ! that, but for the patent license, your conveying the covered work ! in a country, or your recipient's use of the covered work in a ! country, would infringe one or more identifiable patents in that ! country that you have reason to believe are valid. ! ! If, pursuant to or in connection with a single transaction or ! arrangement, you convey, or propagate by procuring conveyance of, a ! covered work, and grant a patent license to some of the parties ! receiving the covered work authorizing them to use, propagate, ! modify or convey a specific copy of the covered work, then the ! patent license you grant is automatically extended to all ! recipients of the covered work and works based on it. ! ! A patent license is "discriminatory" if it does not include within ! the scope of its coverage, prohibits the exercise of, or is ! conditioned on the non-exercise of one or more of the rights that ! are specifically granted under this License. You may not convey a ! covered work if you are a party to an arrangement with a third ! party that is in the business of distributing software, under ! which you make payment to the third party based on the extent of ! your activity of conveying the work, and under which the third ! party grants, to any of the parties who would receive the covered ! work from you, a discriminatory patent license (a) in connection ! with copies of the covered work conveyed by you (or copies made ! from those copies), or (b) primarily for and in connection with ! specific products or compilations that contain the covered work, ! unless you entered into that arrangement, or that patent license ! was granted, prior to 28 March 2007. ! ! Nothing in this License shall be construed as excluding or limiting ! any implied license or other defenses to infringement that may ! otherwise be available to you under applicable patent law. ! ! 12. No Surrender of Others' Freedom. ! ! If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this ! License. If you cannot convey a covered work so as to satisfy ! simultaneously your obligations under this License and any other ! pertinent obligations, then as a consequence you may not convey it ! at all. For example, if you agree to terms that obligate you to ! collect a royalty for further conveying from those to whom you ! convey the Program, the only way you could satisfy both those ! terms and this License would be to refrain entirely from conveying ! the Program. ! 13. Use with the GNU Affero General Public License. ! Notwithstanding any other provision of this License, you have ! permission to link or combine any covered work with a work licensed ! under version 3 of the GNU Affero General Public License into a ! single combined work, and to convey the resulting work. The terms ! of this License will continue to apply to the part which is the ! covered work, but the special requirements of the GNU Affero ! General Public License, section 13, concerning interaction through ! a network will apply to the combination as such. ! 14. Revised Versions of this License. ! The Free Software Foundation may publish revised and/or new ! versions of the GNU General Public License from time to time. ! Such new versions will be similar in spirit to the present ! version, but may differ in detail to address new problems or ! concerns. Each version is given a distinguishing version number. If the ! Program specifies that a certain numbered version of the GNU ! General Public License "or any later version" applies to it, you ! have the option of following the terms and conditions either of ! that numbered version or of any later version published by the ! Free Software Foundation. If the Program does not specify a ! version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. ! If the Program specifies that a proxy can decide which future ! versions of the GNU General Public License can be used, that ! proxy's public statement of acceptance of a version permanently ! authorizes you to choose that version for the Program. ! Later license versions may give you additional or different ! permissions. However, no additional obligations are imposed on any ! author or copyright holder as a result of your choosing to follow a ! later version. ! 15. Disclaimer of Warranty. ! THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY ! APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE ! COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" ! WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, ! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ! MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE ! RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. ! SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL ! NECESSARY SERVICING, REPAIR OR CORRECTION. ! ! 16. Limitation of Liability. ! ! IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN ! WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES ! AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU ! FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR ! CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE ! THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA ! BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD ! PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER ! PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF ! THE POSSIBILITY OF SUCH DAMAGES. ! ! 17. Interpretation of Sections 15 and 16. ! ! If the disclaimer of warranty and limitation of liability provided ! above cannot be given local legal effect according to their terms, ! reviewing courts shall apply local law that most closely ! approximates an absolute waiver of all civil liability in ! connection with the Program, unless a warranty or assumption of ! liability accompanies a copy of the Program in return for a fee. ! ! ! END OF TERMS AND CONDITIONS ! =========================== ! ! How to Apply These Terms to Your New Programs ! ============================================= If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it *************** terms. *** 12014,12072 **** To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively ! convey the exclusion of warranty; and each file should have at least ! the "copyright" line and a pointer to where the full notice is found. ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. ! Copyright (C) YEAR NAME OF AUTHOR ! This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Also add information on how to contact you by electronic and paper mail. ! If the program is interactive, make it output a short notice like ! this when it starts in an interactive mode: ! Gnomovision version 69, Copyright (C) YEAR NAME OF AUTHOR ! Gnomovision comes with ABSOLUTELY NO WARRANTY; for details ! type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the ! appropriate parts of the General Public License. Of course, the ! commands you use may be called something other than `show w' and `show ! c'; they could even be mouse-clicks or menu items--whatever suits your ! program. You should also get your employer (if you work as a programmer) or ! your school, if any, to sign a "copyright disclaimer" for the program, ! if necessary. Here is a sample; alter the names: ! ! Yoyodyne, Inc., hereby disclaims all copyright interest in the program ! `Gnomovision' (which makes passes at compilers) written by James Hacker. ! ! SIGNATURE OF TY COON, 1 April 1989 ! Ty Coon, President of Vice ! This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the ! GNU Library General Public License instead of this License.  File: gfortran.info, Node: GNU Free Documentation License, Next: Funding, Prev: Copying, Up: Top --- 12385,12436 ---- To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively ! state the exclusion of warranty; and each file should have at least the ! "copyright" line and a pointer to where the full notice is found. ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. ! Copyright (C) YEAR NAME OF AUTHOR ! This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by ! the Free Software Foundation, either version 3 of the License, or (at ! your option) any later version. ! This program is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. You should have received a copy of the GNU General Public License ! along with this program. If not, see `http://www.gnu.org/licenses/'. Also add information on how to contact you by electronic and paper mail. ! If the program does terminal interaction, make it output a short ! notice like this when it starts in an interactive mode: ! PROGRAM Copyright (C) YEAR NAME OF AUTHOR ! This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the ! appropriate parts of the General Public License. Of course, your ! program's commands might be different; for a GUI interface, you would ! use an "about box". You should also get your employer (if you work as a programmer) or ! school, if any, to sign a "copyright disclaimer" for the program, if ! necessary. For more information on this, and how to apply and follow ! the GNU GPL, see `http://www.gnu.org/licenses/'. ! The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the ! GNU Lesser General Public License instead of this License. But first, ! please read `http://www.gnu.org/philosophy/why-not-lgpl.html'.  File: gfortran.info, Node: GNU Free Documentation License, Next: Funding, Prev: Copying, Up: Top *************** Keyword Index *** 13572,13862 ****  Tag Table: ! Node: Top2072 ! Node: Introduction3289 ! Node: About GNU Fortran4034 ! Node: GNU Fortran and GCC8092 ! Node: Preprocessing and conditional compilation10182 ! Node: GNU Fortran and G7711623 ! Node: Project Status12196 ! Node: Standards14694 ! Node: Invoking GNU Fortran15351 ! Node: Option Summary17011 ! Node: Fortran Dialect Options19905 ! Node: Error and Warning Options25648 ! Node: Debugging Options31813 ! Node: Directory Options33979 ! Node: Link Options35506 ! Node: Runtime Options36130 ! Node: Code Gen Options37833 ! Node: Environment Variables48400 ! Node: Runtime49003 ! Node: GFORTRAN_STDIN_UNIT50222 ! Node: GFORTRAN_STDOUT_UNIT50589 ! Node: GFORTRAN_STDERR_UNIT50990 ! Node: GFORTRAN_USE_STDERR51388 ! Node: GFORTRAN_TMPDIR51833 ! Node: GFORTRAN_UNBUFFERED_ALL52274 ! Node: GFORTRAN_UNBUFFERED_PRECONNECTED52797 ! Node: GFORTRAN_SHOW_LOCUS53438 ! Node: GFORTRAN_OPTIONAL_PLUS53932 ! Node: GFORTRAN_DEFAULT_RECL54407 ! Node: GFORTRAN_LIST_SEPARATOR54898 ! Node: GFORTRAN_CONVERT_UNIT55507 ! Node: GFORTRAN_ERROR_DUMPCORE58382 ! Node: GFORTRAN_ERROR_BACKTRACE58929 ! Node: Fortran 2003 status59480 ! Node: Extensions61149 ! Node: Extensions implemented in GNU Fortran61743 ! Node: Old-style kind specifications63063 ! Node: Old-style variable initialization63928 ! Node: Extensions to namelist65240 ! Node: X format descriptor without count field67236 ! Node: Commas in FORMAT specifications67763 ! Node: Missing period in FORMAT specifications68280 ! Node: I/O item lists68842 ! Node: BOZ literal constants69231 ! Node: Real array indices71800 ! Node: Unary operators72097 ! Node: Implicitly convert LOGICAL and INTEGER values72511 ! Node: Hollerith constants support73471 ! Node: Cray pointers75243 ! Node: CONVERT specifier80653 ! Node: OpenMP82655 ! Node: Argument list functions84909 ! Node: Extensions not implemented in GNU Fortran86503 ! Node: STRUCTURE and RECORD87354 ! Node: ENCODE and DECODE statements89411 ! Node: Intrinsic Procedures90729 ! Node: Introduction to Intrinsics104021 ! Node: ABORT106334 ! Node: ABS107037 ! Node: ACCESS108529 ! Node: ACHAR110418 ! Node: ACOS111358 ! Node: ACOSH112288 ! Node: ADJUSTL113261 ! Node: ADJUSTR114155 ! Node: AIMAG115055 ! Node: AINT116465 ! Node: ALARM117910 ! Node: ALL119544 ! Node: ALLOCATED121461 ! Node: AND122327 ! Node: ANINT123489 ! Node: ANY124827 ! Node: ASIN126756 ! Node: ASINH127701 ! Node: ASSOCIATED128654 ! Node: ATAN131479 ! Node: ATAN2132313 ! Node: ATANH133592 ! Node: BESJ0134574 ! Node: BESJ1135488 ! Node: BESJN136408 ! Node: BESY0137499 ! Node: BESY1138357 ! Node: BESYN139215 ! Node: BIT_SIZE140360 ! Node: BTEST141109 ! Node: C_ASSOCIATED141957 ! Node: C_FUNLOC143144 ! Node: C_F_PROCPOINTER144506 ! Node: C_F_POINTER146143 ! Node: C_LOC147626 ! Node: CEILING148745 ! Node: CHAR149706 ! Node: CHDIR150793 ! Node: CHMOD152013 ! Node: CMPLX153776 ! Node: COMMAND_ARGUMENT_COUNT155315 ! Node: COMPLEX156205 ! Node: CONJG157360 ! Node: COS158369 ! Node: COSH159582 ! Node: COUNT160400 ! Node: CPU_TIME162227 ! Node: CSHIFT163580 ! Node: CTIME165229 ! Node: DATE_AND_TIME166452 ! Node: DBLE168815 ! Node: DCMPLX169655 ! Node: DFLOAT170894 ! Node: DIGITS171591 ! Node: DIM172535 ! Node: DOT_PRODUCT173671 ! Node: DPROD175101 ! Node: DREAL175820 ! Node: DTIME176484 ! Node: EOSHIFT179290 ! Node: EPSILON181355 ! Node: ERF182051 ! Node: ERFC182848 ! Node: ETIME183663 ! Node: EXIT185887 ! Node: EXP186746 ! Node: EXPONENT187843 ! Node: FDATE188589 ! Node: FLOAT189809 ! Node: FGET190519 ! Node: FGETC192312 ! Node: FLOOR194060 ! Node: FLUSH195002 ! Node: FNUM195640 ! Node: FPUT196362 ! Node: FPUTC197943 ! Node: FRACTION199663 ! Node: FREE200557 ! Node: FSEEK201394 ! Node: FSTAT203688 ! Node: FTELL204752 ! Node: GAMMA205730 ! Node: GERROR206759 ! Node: GETARG207467 ! Node: GET_COMMAND209142 ! Node: GET_COMMAND_ARGUMENT210022 ! Node: GETCWD211418 ! Node: GETENV212355 ! Node: GET_ENVIRONMENT_VARIABLE213519 ! Node: GETGID214453 ! Node: GETLOG214988 ! Node: GETPID215817 ! Node: GETUID216545 ! Node: GMTIME217059 ! Node: HOSTNM218614 ! Node: HUGE219551 ! Node: IACHAR220264 ! Node: IAND221412 ! Node: IARGC222400 ! Node: IBCLR223416 ! Node: IBITS224079 ! Node: IBSET224999 ! Node: ICHAR225657 ! Node: IDATE227610 ! Node: IEOR228628 ! Node: IERRNO229507 ! Node: INDEX intrinsic230062 ! Node: INT231388 ! Node: INT2232912 ! Node: INT8233692 ! Node: IOR234419 ! Node: IRAND235272 ! Node: IS_IOSTAT_END236627 ! Node: IS_IOSTAT_EOR237713 ! Node: ISATTY238829 ! Node: ISHFT239616 ! Node: ISHFTC240598 ! Node: ISNAN241819 ! Node: ITIME242567 ! Node: KILL243583 ! Node: KIND244498 ! Node: LBOUND245336 ! Node: LEN246620 ! Node: LEN_TRIM247686 ! Node: LGAMMA248645 ! Node: LGE249707 ! Node: LGT251010 ! Node: LINK252280 ! Node: LLE253315 ! Node: LLT254612 ! Node: LNBLNK255875 ! Node: LOC256654 ! Node: LOG257385 ! Node: LOG10258587 ! Node: LOGICAL259453 ! Node: LONG260280 ! Node: LSHIFT261051 ! Node: LSTAT262014 ! Node: LTIME263175 ! Node: MALLOC264654 ! Node: MATMUL266318 ! Node: MAX267505 ! Node: MAXEXPONENT269018 ! Node: MAXLOC269827 ! Node: MAXVAL271960 ! Node: MCLOCK273752 ! Node: MCLOCK8274755 ! Node: MERGE275969 ! Node: MIN276730 ! Node: MINEXPONENT278240 ! Node: MINLOC278863 ! Node: MINVAL280996 ! Node: MOD282762 ! Node: MODULO284139 ! Node: MOVE_ALLOC285346 ! Node: MVBITS286404 ! Node: NEAREST287487 ! Node: NEW_LINE288603 ! Node: NINT289388 ! Node: NOT290408 ! Node: NULL290990 ! Node: OR291874 ! Node: PACK293017 ! Node: PERROR295002 ! Node: PRECISION295592 ! Node: PRESENT296411 ! Node: PRODUCT297510 ! Node: RADIX299037 ! Node: RAN299807 ! Node: RAND300263 ! Node: RANDOM_NUMBER301598 ! Node: RANDOM_SEED303328 ! Node: RANGE305204 ! Node: REAL305824 ! Node: RENAME307325 ! Node: REPEAT308344 ! Node: RESHAPE309069 ! Node: RRSPACING310531 ! Node: RSHIFT311217 ! Node: SCALE312188 ! Node: SCAN312955 ! Node: SECNDS314484 ! Node: SECOND315572 ! Node: SELECTED_INT_KIND316447 ! Node: SELECTED_REAL_KIND317603 ! Node: SET_EXPONENT319542 ! Node: SHAPE320531 ! Node: SIGN321637 ! Node: SIGNAL322713 ! Node: SIN324210 ! Node: SINH325251 ! Node: SIZE326008 ! Node: SIZEOF327287 ! Node: SLEEP328546 ! Node: SNGL329103 ! Node: SPACING329767 ! Node: SPREAD330775 ! Node: SQRT331913 ! Node: SRAND333097 ! Node: STAT334256 ! Node: SUM337371 ! Node: SYMLNK338842 ! Node: SYSTEM339974 ! Node: SYSTEM_CLOCK340922 ! Node: TAN342259 ! Node: TANH343040 ! Node: TIME343852 ! Node: TIME8344956 ! Node: TINY346093 ! Node: TRANSFER346688 ! Node: TRANSPOSE348713 ! Node: TRIM349397 ! Node: TTYNAM350253 ! Node: UBOUND351174 ! Node: UMASK352515 ! Node: UNLINK353103 ! Node: UNPACK354080 ! Node: VERIFY355360 ! Node: XOR357057 ! Node: Intrinsic Modules358229 ! Node: Contributing363055 ! Node: Contributors363907 ! Node: Projects365530 ! Node: Proposed Extensions366333 ! Node: Copying368384 ! Node: GNU Free Documentation License387593 ! Node: Funding410005 ! Node: Option Index412530 ! Node: Keyword Index420131  End Tag Table --- 13936,14226 ----  Tag Table: ! Node: Top2062 ! Node: Introduction3279 ! Node: About GNU Fortran4024 ! Node: GNU Fortran and GCC8082 ! Node: Preprocessing and conditional compilation10172 ! Node: GNU Fortran and G7711613 ! Node: Project Status12186 ! Node: Standards14684 ! Node: Invoking GNU Fortran15341 ! Node: Option Summary17001 ! Node: Fortran Dialect Options19895 ! Node: Error and Warning Options25638 ! Node: Debugging Options31803 ! Node: Directory Options33969 ! Node: Link Options35496 ! Node: Runtime Options36120 ! Node: Code Gen Options37823 ! Node: Environment Variables48390 ! Node: Runtime48993 ! Node: GFORTRAN_STDIN_UNIT50212 ! Node: GFORTRAN_STDOUT_UNIT50579 ! Node: GFORTRAN_STDERR_UNIT50980 ! Node: GFORTRAN_USE_STDERR51378 ! Node: GFORTRAN_TMPDIR51823 ! Node: GFORTRAN_UNBUFFERED_ALL52264 ! Node: GFORTRAN_UNBUFFERED_PRECONNECTED52787 ! Node: GFORTRAN_SHOW_LOCUS53428 ! Node: GFORTRAN_OPTIONAL_PLUS53922 ! Node: GFORTRAN_DEFAULT_RECL54397 ! Node: GFORTRAN_LIST_SEPARATOR54888 ! Node: GFORTRAN_CONVERT_UNIT55497 ! Node: GFORTRAN_ERROR_DUMPCORE58372 ! Node: GFORTRAN_ERROR_BACKTRACE58919 ! Node: Fortran 2003 status59470 ! Node: Extensions61139 ! Node: Extensions implemented in GNU Fortran61733 ! Node: Old-style kind specifications63053 ! Node: Old-style variable initialization63918 ! Node: Extensions to namelist65230 ! Node: X format descriptor without count field67226 ! Node: Commas in FORMAT specifications67753 ! Node: Missing period in FORMAT specifications68270 ! Node: I/O item lists68832 ! Node: BOZ literal constants69221 ! Node: Real array indices71790 ! Node: Unary operators72087 ! Node: Implicitly convert LOGICAL and INTEGER values72501 ! Node: Hollerith constants support73461 ! Node: Cray pointers75233 ! Node: CONVERT specifier80643 ! Node: OpenMP82645 ! Node: Argument list functions84899 ! Node: Extensions not implemented in GNU Fortran86493 ! Node: STRUCTURE and RECORD87344 ! Node: ENCODE and DECODE statements89401 ! Node: Intrinsic Procedures90719 ! Node: Introduction to Intrinsics104011 ! Node: ABORT106324 ! Node: ABS107027 ! Node: ACCESS108519 ! Node: ACHAR110408 ! Node: ACOS111348 ! Node: ACOSH112278 ! Node: ADJUSTL113251 ! Node: ADJUSTR114145 ! Node: AIMAG115045 ! Node: AINT116455 ! Node: ALARM117900 ! Node: ALL119534 ! Node: ALLOCATED121451 ! Node: AND122317 ! Node: ANINT123479 ! Node: ANY124817 ! Node: ASIN126746 ! Node: ASINH127691 ! Node: ASSOCIATED128644 ! Node: ATAN131469 ! Node: ATAN2132303 ! Node: ATANH133582 ! Node: BESJ0134564 ! Node: BESJ1135478 ! Node: BESJN136398 ! Node: BESY0137489 ! Node: BESY1138347 ! Node: BESYN139205 ! Node: BIT_SIZE140350 ! Node: BTEST141099 ! Node: C_ASSOCIATED141947 ! Node: C_FUNLOC143134 ! Node: C_F_PROCPOINTER144496 ! Node: C_F_POINTER146133 ! Node: C_LOC147616 ! Node: CEILING148735 ! Node: CHAR149696 ! Node: CHDIR150783 ! Node: CHMOD152003 ! Node: CMPLX153766 ! Node: COMMAND_ARGUMENT_COUNT155305 ! Node: COMPLEX156195 ! Node: CONJG157350 ! Node: COS158359 ! Node: COSH159572 ! Node: COUNT160390 ! Node: CPU_TIME162217 ! Node: CSHIFT163570 ! Node: CTIME165219 ! Node: DATE_AND_TIME166442 ! Node: DBLE168805 ! Node: DCMPLX169645 ! Node: DFLOAT170884 ! Node: DIGITS171581 ! Node: DIM172525 ! Node: DOT_PRODUCT173661 ! Node: DPROD175091 ! Node: DREAL175810 ! Node: DTIME176474 ! Node: EOSHIFT179280 ! Node: EPSILON181345 ! Node: ERF182041 ! Node: ERFC182838 ! Node: ETIME183653 ! Node: EXIT185877 ! Node: EXP186736 ! Node: EXPONENT187833 ! Node: FDATE188579 ! Node: FLOAT189799 ! Node: FGET190509 ! Node: FGETC192302 ! Node: FLOOR194050 ! Node: FLUSH194992 ! Node: FNUM195630 ! Node: FPUT196352 ! Node: FPUTC197933 ! Node: FRACTION199653 ! Node: FREE200547 ! Node: FSEEK201384 ! Node: FSTAT203678 ! Node: FTELL204742 ! Node: GAMMA205720 ! Node: GERROR206749 ! Node: GETARG207457 ! Node: GET_COMMAND209132 ! Node: GET_COMMAND_ARGUMENT210012 ! Node: GETCWD211408 ! Node: GETENV212345 ! Node: GET_ENVIRONMENT_VARIABLE213509 ! Node: GETGID214443 ! Node: GETLOG214978 ! Node: GETPID215807 ! Node: GETUID216535 ! Node: GMTIME217049 ! Node: HOSTNM218604 ! Node: HUGE219541 ! Node: IACHAR220254 ! Node: IAND221402 ! Node: IARGC222390 ! Node: IBCLR223406 ! Node: IBITS224069 ! Node: IBSET224989 ! Node: ICHAR225647 ! Node: IDATE227600 ! Node: IEOR228618 ! Node: IERRNO229497 ! Node: INDEX intrinsic230052 ! Node: INT231378 ! Node: INT2232902 ! Node: INT8233682 ! Node: IOR234409 ! Node: IRAND235262 ! Node: IS_IOSTAT_END236617 ! Node: IS_IOSTAT_EOR237703 ! Node: ISATTY238819 ! Node: ISHFT239606 ! Node: ISHFTC240588 ! Node: ISNAN241809 ! Node: ITIME242557 ! Node: KILL243573 ! Node: KIND244488 ! Node: LBOUND245326 ! Node: LEN246610 ! Node: LEN_TRIM247676 ! Node: LGAMMA248635 ! Node: LGE249697 ! Node: LGT251000 ! Node: LINK252270 ! Node: LLE253305 ! Node: LLT254602 ! Node: LNBLNK255865 ! Node: LOC256644 ! Node: LOG257375 ! Node: LOG10258577 ! Node: LOGICAL259443 ! Node: LONG260270 ! Node: LSHIFT261041 ! Node: LSTAT262004 ! Node: LTIME263165 ! Node: MALLOC264644 ! Node: MATMUL266308 ! Node: MAX267495 ! Node: MAXEXPONENT269008 ! Node: MAXLOC269817 ! Node: MAXVAL271950 ! Node: MCLOCK273742 ! Node: MCLOCK8274745 ! Node: MERGE275959 ! Node: MIN276720 ! Node: MINEXPONENT278230 ! Node: MINLOC278853 ! Node: MINVAL280986 ! Node: MOD282752 ! Node: MODULO284129 ! Node: MOVE_ALLOC285336 ! Node: MVBITS286394 ! Node: NEAREST287477 ! Node: NEW_LINE288593 ! Node: NINT289378 ! Node: NOT290398 ! Node: NULL290980 ! Node: OR291864 ! Node: PACK293007 ! Node: PERROR294992 ! Node: PRECISION295582 ! Node: PRESENT296401 ! Node: PRODUCT297500 ! Node: RADIX299027 ! Node: RAN299797 ! Node: RAND300253 ! Node: RANDOM_NUMBER301588 ! Node: RANDOM_SEED303318 ! Node: RANGE305194 ! Node: REAL305814 ! Node: RENAME307315 ! Node: REPEAT308334 ! Node: RESHAPE309059 ! Node: RRSPACING310521 ! Node: RSHIFT311207 ! Node: SCALE312178 ! Node: SCAN312945 ! Node: SECNDS314474 ! Node: SECOND315562 ! Node: SELECTED_INT_KIND316437 ! Node: SELECTED_REAL_KIND317593 ! Node: SET_EXPONENT319532 ! Node: SHAPE320521 ! Node: SIGN321627 ! Node: SIGNAL322703 ! Node: SIN324200 ! Node: SINH325241 ! Node: SIZE325998 ! Node: SIZEOF327277 ! Node: SLEEP328536 ! Node: SNGL329093 ! Node: SPACING329757 ! Node: SPREAD330765 ! Node: SQRT331903 ! Node: SRAND333087 ! Node: STAT334246 ! Node: SUM337361 ! Node: SYMLNK338832 ! Node: SYSTEM339964 ! Node: SYSTEM_CLOCK340912 ! Node: TAN342249 ! Node: TANH343030 ! Node: TIME343842 ! Node: TIME8344946 ! Node: TINY346083 ! Node: TRANSFER346678 ! Node: TRANSPOSE348703 ! Node: TRIM349387 ! Node: TTYNAM350243 ! Node: UBOUND351164 ! Node: UMASK352505 ! Node: UNLINK353093 ! Node: UNPACK354070 ! Node: VERIFY355350 ! Node: XOR357047 ! Node: Intrinsic Modules358219 ! Node: Contributing363045 ! Node: Contributors363897 ! Node: Projects365520 ! Node: Proposed Extensions366323 ! Node: Copying368374 ! Node: GNU Free Documentation License405938 ! Node: Funding428350 ! Node: Option Index430875 ! Node: Keyword Index438476  End Tag Table diff -Nrcpad gcc-4.3.0/gcc/fortran/gfortran.texi gcc-4.3.1/gcc/fortran/gfortran.texi *** gcc-4.3.0/gcc/fortran/gfortran.texi Sat Feb 16 14:10:12 2008 --- gcc-4.3.1/gcc/fortran/gfortran.texi Tue Apr 1 18:49:36 2008 *************** Environment variable forcing standard ou *** 1897,1903 **** @c GNU General Public License @c --------------------------------------------------------------------- ! @include gpl.texi --- 1897,1903 ---- @c GNU General Public License @c --------------------------------------------------------------------- ! @include gpl_v3.texi diff -Nrcpad gcc-4.3.0/gcc/fortran/interface.c gcc-4.3.1/gcc/fortran/interface.c *** gcc-4.3.0/gcc/fortran/interface.c Tue Jan 22 19:35:49 2008 --- gcc-4.3.1/gcc/fortran/interface.c Sat May 17 07:10:13 2008 *************** compare_actual_formal (gfc_actual_arglis *** 1937,1943 **** actual_size = get_expr_storage_size (a->expr); formal_size = get_sym_storage_size (f->sym); ! if (actual_size != 0 && actual_size < formal_size) { if (a->expr->ts.type == BT_CHARACTER && !f->sym->as && where) gfc_warning ("Character length of actual argument shorter " --- 1937,1945 ---- actual_size = get_expr_storage_size (a->expr); formal_size = get_sym_storage_size (f->sym); ! if (actual_size != 0 ! && actual_size < formal_size ! && a->expr->ts.type != BT_PROCEDURE) { if (a->expr->ts.type == BT_CHARACTER && !f->sym->as && where) gfc_warning ("Character length of actual argument shorter " diff -Nrcpad gcc-4.3.0/gcc/fortran/iresolve.c gcc-4.3.1/gcc/fortran/iresolve.c *** gcc-4.3.0/gcc/fortran/iresolve.c Sat Jan 19 22:47:47 2008 --- gcc-4.3.1/gcc/fortran/iresolve.c Fri Apr 18 18:40:22 2008 *************** gfc_resolve_cshift (gfc_expr *f, gfc_exp *** 592,598 **** if (dim != NULL) { ! if (dim->expr_type != EXPR_CONSTANT && dim->symtree->n.sym->attr.optional) { /* Mark this for later setting the type in gfc_conv_missing_dummy. */ dim->representation.length = shift->ts.kind; --- 592,599 ---- if (dim != NULL) { ! if (dim->expr_type != EXPR_CONSTANT && dim->symtree != NULL ! && dim->symtree->n.sym->attr.optional) { /* Mark this for later setting the type in gfc_conv_missing_dummy. */ dim->representation.length = shift->ts.kind; *************** gfc_resolve_eoshift (gfc_expr *f, gfc_ex *** 730,736 **** if (dim != NULL) { ! if (dim->expr_type != EXPR_CONSTANT && dim->symtree->n.sym->attr.optional) { /* Mark this for later setting the type in gfc_conv_missing_dummy. */ dim->representation.length = shift->ts.kind; --- 731,738 ---- if (dim != NULL) { ! if (dim->expr_type != EXPR_CONSTANT && dim->symtree != NULL ! && dim->symtree->n.sym->attr.optional) { /* Mark this for later setting the type in gfc_conv_missing_dummy. */ dim->representation.length = shift->ts.kind; diff -Nrcpad gcc-4.3.0/gcc/fortran/module.c gcc-4.3.1/gcc/fortran/module.c *** gcc-4.3.0/gcc/fortran/module.c Wed Jan 30 06:56:10 2008 --- gcc-4.3.1/gcc/fortran/module.c Tue May 13 20:26:47 2008 *************** mio_symtree_ref (gfc_symtree **stp) *** 2310,2315 **** --- 2310,2321 ---- p->u.rsym.symtree->n.sym = p->u.rsym.sym; p->u.rsym.symtree->n.sym->refs++; p->u.rsym.referenced = 1; + + /* If the symbol is PRIVATE and in COMMON, load_commons will + generate a fixup symbol, which must be associated. */ + if (p->fixup) + resolve_fixups (p->fixup, p->u.rsym.sym); + p->fixup = NULL; } if (p->type == P_UNKNOWN) *************** find_symtree_for_symbol (gfc_symtree *st *** 3140,3152 **** /* A recursive function to look for a speficic symbol by name and by module. Whilst several symtrees might point to one symbol, its is sufficient for the purposes here than one exist. Note that ! generic interfaces are distinguished. */ static gfc_symtree * find_symbol (gfc_symtree *st, const char *name, const char *module, int generic) { int c; ! gfc_symtree *retval; if (st == NULL || st->n.sym == NULL) return NULL; --- 3146,3159 ---- /* A recursive function to look for a speficic symbol by name and by module. Whilst several symtrees might point to one symbol, its is sufficient for the purposes here than one exist. Note that ! generic interfaces are distinguished as are symbols that have been ! renamed in another module. */ static gfc_symtree * find_symbol (gfc_symtree *st, const char *name, const char *module, int generic) { int c; ! gfc_symtree *retval, *s; if (st == NULL || st->n.sym == NULL) return NULL; *************** find_symbol (gfc_symtree *st, const char *** 3156,3163 **** && strcmp (module, st->n.sym->module) == 0 && !check_unique_name (st->name)) { ! if ((!generic && !st->n.sym->attr.generic) ! || (generic && st->n.sym->attr.generic)) return st; } --- 3163,3176 ---- && strcmp (module, st->n.sym->module) == 0 && !check_unique_name (st->name)) { ! s = gfc_find_symtree (gfc_current_ns->sym_root, name); ! ! /* Detect symbols that are renamed by use association in another ! module by the absence of a symtree and null attr.use_rename, ! since the latter is not transmitted in the module file. */ ! if (((!generic && !st->n.sym->attr.generic) ! || (generic && st->n.sym->attr.generic)) ! && !(s == NULL && !st->n.sym->attr.use_rename)) return st; } diff -Nrcpad gcc-4.3.0/gcc/fortran/openmp.c gcc-4.3.1/gcc/fortran/openmp.c *** gcc-4.3.0/gcc/fortran/openmp.c Wed Aug 1 16:29:36 2007 --- gcc-4.3.1/gcc/fortran/openmp.c Thu Apr 3 21:20:53 2008 *************** resolve_omp_clauses (gfc_code *code) *** 717,723 **** a symbol can appear on both firstprivate and lastprivate. */ for (list = 0; list < OMP_LIST_NUM; list++) for (n = omp_clauses->lists[list]; n; n = n->next) ! n->sym->mark = 0; for (list = 0; list < OMP_LIST_NUM; list++) if (list != OMP_LIST_FIRSTPRIVATE && list != OMP_LIST_LASTPRIVATE) --- 717,757 ---- a symbol can appear on both firstprivate and lastprivate. */ for (list = 0; list < OMP_LIST_NUM; list++) for (n = omp_clauses->lists[list]; n; n = n->next) ! { ! n->sym->mark = 0; ! if (n->sym->attr.flavor == FL_VARIABLE) ! continue; ! if (n->sym->attr.flavor == FL_PROCEDURE ! && n->sym->result == n->sym ! && n->sym->attr.function) ! { ! if (gfc_current_ns->proc_name == n->sym ! || (gfc_current_ns->parent ! && gfc_current_ns->parent->proc_name == n->sym)) ! continue; ! if (gfc_current_ns->proc_name->attr.entry_master) ! { ! gfc_entry_list *el = gfc_current_ns->entries; ! for (; el; el = el->next) ! if (el->sym == n->sym) ! break; ! if (el) ! continue; ! } ! if (gfc_current_ns->parent ! && gfc_current_ns->parent->proc_name->attr.entry_master) ! { ! gfc_entry_list *el = gfc_current_ns->parent->entries; ! for (; el; el = el->next) ! if (el->sym == n->sym) ! break; ! if (el) ! continue; ! } ! } ! gfc_error ("Object '%s' is not a variable at %L", n->sym->name, ! &code->loc); ! } for (list = 0; list < OMP_LIST_NUM; list++) if (list != OMP_LIST_FIRSTPRIVATE && list != OMP_LIST_LASTPRIVATE) diff -Nrcpad gcc-4.3.0/gcc/fortran/resolve.c gcc-4.3.1/gcc/fortran/resolve.c *** gcc-4.3.0/gcc/fortran/resolve.c Mon Feb 4 22:29:35 2008 --- gcc-4.3.1/gcc/fortran/resolve.c Sun Mar 30 14:23:10 2008 *************** resolve_structure_cons (gfc_expr *expr) *** 827,832 **** --- 827,842 ---- t = gfc_convert_type (cons->expr, &comp->ts, 1); } + if (cons->expr->expr_type == EXPR_NULL + && !(comp->pointer || comp->allocatable)) + { + t = FAILURE; + gfc_error ("The NULL in the derived type constructor at %L is " + "being applied to component '%s', which is neither " + "a POINTER nor ALLOCATABLE", &cons->expr->where, + comp->name); + } + if (!comp->pointer || cons->expr->expr_type == EXPR_NULL) continue; *************** resolve_function (gfc_expr *expr) *** 2365,2371 **** gfc_expr_set_symbols_referenced (expr->ts.cl->length); } ! if (t == SUCCESS) find_noncopying_intrinsics (expr->value.function.esym, expr->value.function.actual); --- 2375,2386 ---- gfc_expr_set_symbols_referenced (expr->ts.cl->length); } ! if (t == SUCCESS ! && !((expr->value.function.esym ! && expr->value.function.esym->attr.elemental) ! || ! (expr->value.function.isym ! && expr->value.function.isym->elemental))) find_noncopying_intrinsics (expr->value.function.esym, expr->value.function.actual); *************** resolve_call (gfc_code *c) *** 2836,2842 **** if (resolve_elemental_actual (NULL, c) == FAILURE) return FAILURE; ! if (t == SUCCESS) find_noncopying_intrinsics (c->resolved_sym, c->ext.actual); return t; } --- 2851,2857 ---- if (resolve_elemental_actual (NULL, c) == FAILURE) return FAILURE; ! if (t == SUCCESS && !(c->resolved_sym && c->resolved_sym->attr.elemental)) find_noncopying_intrinsics (c->resolved_sym, c->ext.actual); return t; } *************** resolve_symbol (gfc_symbol *sym) *** 7974,7979 **** --- 7989,8017 ---- return; } + /* Make sure that the derived type has been resolved and that the + derived type is visible in the symbol's namespace, if it is a + module function and is not PRIVATE. */ + if (sym->ts.type == BT_DERIVED + && sym->ts.derived->attr.use_assoc + && sym->ns->proc_name->attr.flavor == FL_MODULE) + { + gfc_symbol *ds; + + if (resolve_fl_derived (sym->ts.derived) == FAILURE) + return; + + gfc_find_symbol (sym->ts.derived->name, sym->ns, 1, &ds); + if (!ds && sym->attr.function + && gfc_check_access (sym->attr.access, sym->ns->default_access)) + { + symtree = gfc_new_symtree (&sym->ns->sym_root, + sym->ts.derived->name); + symtree->n.sym = sym->ts.derived; + sym->ts.derived->refs++; + } + } + /* Unless the derived-type declaration is use associated, Fortran 95 does not allow public entries of private derived types. See 4.4.1 (F95) and 4.5.1.1 (F2003); and related interpretation diff -Nrcpad gcc-4.3.0/gcc/fortran/target-memory.c gcc-4.3.1/gcc/fortran/target-memory.c *** gcc-4.3.0/gcc/fortran/target-memory.c Thu Dec 20 08:13:09 2007 --- gcc-4.3.1/gcc/fortran/target-memory.c Sun May 18 23:06:16 2008 *************** gfc_target_expr_size (gfc_expr *e) *** 100,106 **** case BT_LOGICAL: return size_logical (e->ts.kind); case BT_CHARACTER: ! return size_character (e->value.character.length); case BT_HOLLERITH: return e->representation.length; case BT_DERIVED: --- 100,115 ---- case BT_LOGICAL: return size_logical (e->ts.kind); case BT_CHARACTER: ! if (e->expr_type == EXPR_SUBSTRING && e->ref) ! { ! int start, end; ! ! gfc_extract_int (e->ref->u.ss.start, &start); ! gfc_extract_int (e->ref->u.ss.end, &end); ! return size_character (MAX(end - start + 1, 0)); ! } ! else ! return size_character (e->value.character.length); case BT_HOLLERITH: return e->representation.length; case BT_DERIVED: *************** gfc_target_encode_expr (gfc_expr *source *** 222,228 **** return encode_array (source, buffer, buffer_size); gcc_assert (source->expr_type == EXPR_CONSTANT ! || source->expr_type == EXPR_STRUCTURE); /* If we already have a target-memory representation, we use that rather than recreating one. */ --- 231,238 ---- return encode_array (source, buffer, buffer_size); gcc_assert (source->expr_type == EXPR_CONSTANT ! || source->expr_type == EXPR_STRUCTURE ! || source->expr_type == EXPR_SUBSTRING); /* If we already have a target-memory representation, we use that rather than recreating one. */ *************** gfc_target_encode_expr (gfc_expr *source *** 248,256 **** return encode_logical (source->ts.kind, source->value.logical, buffer, buffer_size); case BT_CHARACTER: ! return encode_character (source->value.character.length, ! source->value.character.string, buffer, ! buffer_size); case BT_DERIVED: return encode_derived (source, buffer, buffer_size); default: --- 258,278 ---- return encode_logical (source->ts.kind, source->value.logical, buffer, buffer_size); case BT_CHARACTER: ! if (source->expr_type == EXPR_CONSTANT || source->ref == NULL) ! return encode_character (source->value.character.length, ! source->value.character.string, buffer, ! buffer_size); ! else ! { ! int start, end; ! ! gcc_assert (source->expr_type == EXPR_SUBSTRING); ! gfc_extract_int (source->ref->u.ss.start, &start); ! gfc_extract_int (source->ref->u.ss.end, &end); ! return encode_character (MAX(end - start + 1, 0), ! &source->value.character.string[start-1], ! buffer, buffer_size); ! } case BT_DERIVED: return encode_derived (source, buffer, buffer_size); default: *************** gfc_interpret_complex (int kind, unsigne *** 333,339 **** { int size; size = gfc_interpret_float (kind, &buffer[0], buffer_size, real); ! size += gfc_interpret_float (kind, &buffer[size], buffer_size - size, imaginary); return size; } --- 355,362 ---- { int size; size = gfc_interpret_float (kind, &buffer[0], buffer_size, real); ! size += gfc_interpret_float (kind, &buffer[size], buffer_size - size, ! imaginary); return size; } diff -Nrcpad gcc-4.3.0/gcc/fortran/trans-array.c gcc-4.3.1/gcc/fortran/trans-array.c *** gcc-4.3.0/gcc/fortran/trans-array.c Sat Jan 26 19:01:07 2008 --- gcc-4.3.1/gcc/fortran/trans-array.c Sun May 18 00:32:22 2008 *************** gfc_trans_array_constructor (gfc_loopinf *** 1668,1673 **** --- 1668,1674 ---- tree offsetvar; tree desc; tree type; + tree loopfrom; bool dynamic; if (flag_bounds_check && ss->expr->ts.type == BT_CHARACTER) *************** gfc_trans_array_constructor (gfc_loopinf *** 1746,1754 **** --- 1747,1780 ---- } } + /* Temporarily reset the loop variables, so that the returned temporary + has the right size and bounds. This seems only to be necessary for + 1D arrays. */ + if (!integer_zerop (loop->from[0]) && loop->dimen == 1) + { + loopfrom = loop->from[0]; + loop->from[0] = gfc_index_zero_node; + loop->to[0] = fold_build2 (MINUS_EXPR, gfc_array_index_type, + loop->to[0], loopfrom); + } + else + loopfrom = NULL_TREE; + gfc_trans_create_temp_array (&loop->pre, &loop->post, loop, &ss->data.info, type, dynamic, true, false); + if (loopfrom != NULL_TREE) + { + loop->from[0] = loopfrom; + loop->to[0] = fold_build2 (PLUS_EXPR, gfc_array_index_type, + loop->to[0], loopfrom); + /* In the case of a non-zero from, the temporary needs an offset + so that subsequent indexing is correct. */ + ss->data.info.offset = fold_build1 (NEGATE_EXPR, + gfc_array_index_type, + loop->from[0]); + } + desc = ss->data.info.descriptor; offset = gfc_index_zero_node; offsetvar = gfc_create_var_np (gfc_array_index_type, "offset"); *************** gfc_add_loop_ss_code (gfc_loopinfo * loo *** 1841,1860 **** /* Scalar expression. Evaluate this now. This includes elemental dimension indices, but not array section bounds. */ gfc_init_se (&se, NULL); ! gfc_conv_expr (&se, ss->expr); ! gfc_add_block_to_block (&loop->pre, &se.pre); ! if (ss->expr->ts.type != BT_CHARACTER) ! { ! /* Move the evaluation of scalar expressions outside the ! scalarization loop. */ ! if (subscript) ! se.expr = convert(gfc_array_index_type, se.expr); ! se.expr = gfc_evaluate_now (se.expr, &loop->pre); ! gfc_add_block_to_block (&loop->pre, &se.post); ! } ! else ! gfc_add_block_to_block (&loop->post, &se.post); ss->data.scalar.expr = se.expr; ss->string_length = se.string_length; --- 1867,1887 ---- /* Scalar expression. Evaluate this now. This includes elemental dimension indices, but not array section bounds. */ gfc_init_se (&se, NULL); ! gfc_conv_expr (&se, ss->expr); ! gfc_add_block_to_block (&loop->pre, &se.pre); ! if (ss->expr->ts.type != BT_CHARACTER) ! { ! /* Move the evaluation of scalar expressions outside the ! scalarization loop, except for WHERE assignments. */ ! if (subscript) ! se.expr = convert(gfc_array_index_type, se.expr); ! if (!ss->where) ! se.expr = gfc_evaluate_now (se.expr, &loop->pre); ! gfc_add_block_to_block (&loop->pre, &se.post); ! } ! else ! gfc_add_block_to_block (&loop->post, &se.post); ss->data.scalar.expr = se.expr; ss->string_length = se.string_length; *************** gfc_conv_array_index_offset (gfc_se * se *** 2198,2204 **** switch (ar->dimen_type[dim]) { case DIMEN_ELEMENT: - gcc_assert (i == -1); /* Elemental dimension. */ gcc_assert (info->subscript[dim] && info->subscript[dim]->type == GFC_SS_SCALAR); --- 2225,2230 ---- *************** gfc_conv_loop_setup (gfc_loopinfo * loop *** 3490,3496 **** size = 1 - lbound; a.ubound[n] = specified_upper_bound; a.stride[n] = stride; ! size = ubound + size; //size = ubound + 1 - lbound stride = stride * size; } return (stride); --- 3516,3522 ---- size = 1 - lbound; a.ubound[n] = specified_upper_bound; a.stride[n] = stride; ! size = siz >= 0 ? ubound + size : 0; //size = ubound + 1 - lbound stride = stride * size; } return (stride); *************** gfc_array_init_size (tree descriptor, in *** 3590,3595 **** --- 3616,3624 ---- else or_expr = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, or_expr, cond); + size = fold_build3 (COND_EXPR, gfc_array_index_type, cond, + gfc_index_zero_node, size); + /* Multiply the stride by the number of elements in this dimension. */ stride = fold_build2 (MULT_EXPR, gfc_array_index_type, stride, size); stride = gfc_evaluate_now (stride, pblock); *************** gfc_trans_deferred_array (gfc_symbol * s *** 5544,5549 **** --- 5573,5583 ---- rank = sym->as ? sym->as->rank : 0; tmp = gfc_nullify_alloc_comp (sym->ts.derived, descriptor, rank); gfc_add_expr_to_block (&fnblock, tmp); + if (sym->value) + { + tmp = gfc_init_default_dt (sym, NULL); + gfc_add_expr_to_block (&fnblock, tmp); + } } } else if (!GFC_DESCRIPTOR_TYPE_P (type)) diff -Nrcpad gcc-4.3.0/gcc/fortran/trans-decl.c gcc-4.3.1/gcc/fortran/trans-decl.c *** gcc-4.3.0/gcc/fortran/trans-decl.c Thu Feb 28 07:08:51 2008 --- gcc-4.3.1/gcc/fortran/trans-decl.c Sat Apr 19 22:30:03 2008 *************** gfc_finish_var_decl (tree decl, gfc_symb *** 521,529 **** SAVE_EXPLICIT. */ if (!sym->attr.use_assoc && (sym->attr.save != SAVE_NONE || sym->attr.data - || (sym->ts.type == BT_DERIVED - && sym->ts.derived->attr.alloc_comp - && sym->value) || (sym->value && sym->ns->proc_name->attr.is_main_program))) TREE_STATIC (decl) = 1; --- 521,526 ---- *************** gfc_trans_vla_type_sizes (gfc_symbol *sy *** 2565,2572 **** /* Initialize a derived type by building an lvalue from the symbol and using trans_assignment to do the work. */ ! static tree ! init_default_dt (gfc_symbol * sym, tree body) { stmtblock_t fnblock; gfc_expr *e; --- 2562,2569 ---- /* Initialize a derived type by building an lvalue from the symbol and using trans_assignment to do the work. */ ! tree ! gfc_init_default_dt (gfc_symbol * sym, tree body) { stmtblock_t fnblock; gfc_expr *e; *************** init_default_dt (gfc_symbol * sym, tree *** 2586,2592 **** } gfc_add_expr_to_block (&fnblock, tmp); gfc_free_expr (e); ! gfc_add_expr_to_block (&fnblock, body); return gfc_finish_block (&fnblock); } --- 2583,2590 ---- } gfc_add_expr_to_block (&fnblock, tmp); gfc_free_expr (e); ! if (body) ! gfc_add_expr_to_block (&fnblock, body); return gfc_finish_block (&fnblock); } *************** init_intent_out_dt (gfc_symbol * proc_sy *** 2604,2610 **** && f->sym->ts.type == BT_DERIVED && !f->sym->ts.derived->attr.alloc_comp && f->sym->value) ! body = init_default_dt (f->sym, body); gfc_add_expr_to_block (&fnblock, body); return gfc_finish_block (&fnblock); --- 2602,2608 ---- && f->sym->ts.type == BT_DERIVED && !f->sym->ts.derived->attr.alloc_comp && f->sym->value) ! body = gfc_init_default_dt (f->sym, body); gfc_add_expr_to_block (&fnblock, body); return gfc_finish_block (&fnblock); *************** gfc_trans_deferred_vars (gfc_symbol * pr *** 2703,2709 **** && sym->value && !sym->attr.data && sym->attr.save == SAVE_NONE) ! fnbody = init_default_dt (sym, fnbody); gfc_get_backend_locus (&loc); gfc_set_backend_locus (&sym->declared_at); --- 2701,2707 ---- && sym->value && !sym->attr.data && sym->attr.save == SAVE_NONE) ! fnbody = gfc_init_default_dt (sym, fnbody); gfc_get_backend_locus (&loc); gfc_set_backend_locus (&sym->declared_at); *************** gfc_trans_deferred_vars (gfc_symbol * pr *** 2763,2769 **** && sym->value && !sym->attr.data && sym->attr.save == SAVE_NONE) ! fnbody = init_default_dt (sym, fnbody); else gcc_unreachable (); } --- 2761,2767 ---- && sym->value && !sym->attr.data && sym->attr.save == SAVE_NONE) ! fnbody = gfc_init_default_dt (sym, fnbody); else gcc_unreachable (); } diff -Nrcpad gcc-4.3.0/gcc/fortran/trans-expr.c gcc-4.3.1/gcc/fortran/trans-expr.c *** gcc-4.3.0/gcc/fortran/trans-expr.c Thu Feb 28 07:08:51 2008 --- gcc-4.3.1/gcc/fortran/trans-expr.c Sat Mar 29 08:17:36 2008 *************** gfc_trans_string_copy (stmtblock_t * blo *** 2844,2850 **** dsc = gfc_to_single_character (dlen, dest); ! if (dsc != NULL_TREE && ssc != NULL_TREE) { gfc_add_modify_expr (block, dsc, ssc); return; --- 2844,2852 ---- dsc = gfc_to_single_character (dlen, dest); ! /* Assign directly if the types are compatible. */ ! if (dsc != NULL_TREE && ssc != NULL_TREE ! && TREE_TYPE (dsc) == TREE_TYPE (ssc)) { gfc_add_modify_expr (block, dsc, ssc); return; diff -Nrcpad gcc-4.3.0/gcc/fortran/trans-intrinsic.c gcc-4.3.1/gcc/fortran/trans-intrinsic.c *** gcc-4.3.0/gcc/fortran/trans-intrinsic.c Tue Dec 25 10:41:44 2007 --- gcc-4.3.1/gcc/fortran/trans-intrinsic.c Sat Apr 26 15:33:27 2008 *************** gfc_conv_intrinsic_dprod (gfc_se * se, g *** 1275,1293 **** static void gfc_conv_intrinsic_char (gfc_se * se, gfc_expr * expr) { ! tree arg; tree var; tree type; ! gfc_conv_intrinsic_function_args (se, expr, &arg, 1); ! /* We currently don't support character types != 1. */ gcc_assert (expr->ts.kind == 1); type = gfc_character1_type_node; var = gfc_create_var (type, "char"); ! arg = convert (type, arg); ! gfc_add_modify_expr (&se->pre, var, arg); se->expr = gfc_build_addr_expr (build_pointer_type (type), var); se->string_length = integer_one_node; } --- 1275,1296 ---- static void gfc_conv_intrinsic_char (gfc_se * se, gfc_expr * expr) { ! tree arg[2]; tree var; tree type; + unsigned int num_args; ! /* We must allow for the KIND argument, even though.... */ ! num_args = gfc_intrinsic_argument_list_length (expr); ! gfc_conv_intrinsic_function_args (se, expr, arg, num_args); ! /* .... we currently don't support character types != 1. */ gcc_assert (expr->ts.kind == 1); type = gfc_character1_type_node; var = gfc_create_var (type, "char"); ! arg[0] = convert (type, arg[0]); ! gfc_add_modify_expr (&se->pre, var, arg[0]); se->expr = gfc_build_addr_expr (build_pointer_type (type), var); se->string_length = integer_one_node; } *************** gfc_conv_intrinsic_minmaxloc (gfc_se * s *** 2176,2186 **** /* Remember where we are. An offset must be added to the loop counter to obtain the required position. */ ! if (loop.temp_dim) ! tmp = build_int_cst (gfc_array_index_type, 1); else ! tmp =fold_build2 (MINUS_EXPR, gfc_array_index_type, ! gfc_index_one_node, loop.from[0]); gfc_add_modify_expr (&block, offset, tmp); tmp = build2 (PLUS_EXPR, TREE_TYPE (pos), --- 2179,2190 ---- /* Remember where we are. An offset must be added to the loop counter to obtain the required position. */ ! if (loop.from[0]) ! tmp = fold_build2 (MINUS_EXPR, gfc_array_index_type, ! gfc_index_one_node, loop.from[0]); else ! tmp = build_int_cst (gfc_array_index_type, 1); ! gfc_add_modify_expr (&block, offset, tmp); tmp = build2 (PLUS_EXPR, TREE_TYPE (pos), diff -Nrcpad gcc-4.3.0/gcc/fortran/trans-stmt.c gcc-4.3.1/gcc/fortran/trans-stmt.c *** gcc-4.3.0/gcc/fortran/trans-stmt.c Sun Dec 9 17:08:06 2007 --- gcc-4.3.1/gcc/fortran/trans-stmt.c Sat May 17 07:10:13 2008 *************** gfc_trans_where_assign (gfc_expr *expr1, *** 3148,3153 **** --- 3148,3154 ---- { /* The rhs is scalar. Add a ss for the expression. */ rss = gfc_get_ss (); + rss->where = 1; rss->next = gfc_ss_terminator; rss->type = GFC_SS_SCALAR; rss->expr = expr2; *************** gfc_trans_where_2 (gfc_code * code, tree *** 3310,3315 **** --- 3311,3317 ---- gfc_code *cblock; gfc_code *cnext; tree tmp; + tree cond; tree count1, count2; bool need_cmask; bool need_pmask; *************** gfc_trans_where_2 (gfc_code * code, tree *** 3375,3380 **** --- 3377,3389 ---- size = compute_overall_iter_number (nested_forall_info, inner_size, &inner_size_body, block); + /* Check whether the size is negative. */ + cond = fold_build2 (LE_EXPR, boolean_type_node, size, + gfc_index_zero_node); + size = fold_build3 (COND_EXPR, gfc_array_index_type, cond, + gfc_index_zero_node, size); + size = gfc_evaluate_now (size, block); + /* Allocate temporary for WHERE mask if needed. */ if (need_cmask) cmask = allocate_temp_for_forall_nest_1 (mask_type, size, block, *************** gfc_trans_where_3 (gfc_code * cblock, gf *** 3576,3581 **** --- 3585,3591 ---- if (tsss == gfc_ss_terminator) { tsss = gfc_get_ss (); + tsss->where = 1; tsss->next = gfc_ss_terminator; tsss->type = GFC_SS_SCALAR; tsss->expr = tsrc; *************** gfc_trans_where_3 (gfc_code * cblock, gf *** 3593,3598 **** --- 3603,3609 ---- if (esss == gfc_ss_terminator) { esss = gfc_get_ss (); + esss->where = 1; esss->next = gfc_ss_terminator; esss->type = GFC_SS_SCALAR; esss->expr = esrc; *************** gfc_trans_where (gfc_code * code) *** 3707,3725 **** block is dependence free if cond is not dependent on writes to x1 and x2, y1 is not dependent on writes to x2, and y2 is not dependent on writes to x1, and both y's are not ! dependent upon their own x's. */ if (!gfc_check_dependency(cblock->next->expr, cblock->expr, 0) && !gfc_check_dependency(eblock->next->expr, cblock->expr, 0) && !gfc_check_dependency(cblock->next->expr, ! eblock->next->expr2, 0) && !gfc_check_dependency(eblock->next->expr, ! cblock->next->expr2, 0) && !gfc_check_dependency(cblock->next->expr, ! cblock->next->expr2, 0) && !gfc_check_dependency(eblock->next->expr, ! eblock->next->expr2, 0)) return gfc_trans_where_3 (cblock, eblock); } } --- 3718,3745 ---- block is dependence free if cond is not dependent on writes to x1 and x2, y1 is not dependent on writes to x2, and y2 is not dependent on writes to x1, and both y's are not ! dependent upon their own x's. In addition to this, the ! final two dependency checks below exclude all but the same ! array reference if the where and elswhere destinations ! are the same. In short, this is VERY conservative and this ! is needed because the two loops, required by the standard ! are coalesced in gfc_trans_where_3. */ if (!gfc_check_dependency(cblock->next->expr, cblock->expr, 0) && !gfc_check_dependency(eblock->next->expr, cblock->expr, 0) && !gfc_check_dependency(cblock->next->expr, ! eblock->next->expr2, 1) && !gfc_check_dependency(eblock->next->expr, ! cblock->next->expr2, 1) && !gfc_check_dependency(cblock->next->expr, ! cblock->next->expr2, 1) && !gfc_check_dependency(eblock->next->expr, ! eblock->next->expr2, 1) ! && !gfc_check_dependency(cblock->next->expr, ! eblock->next->expr, 0) ! && !gfc_check_dependency(eblock->next->expr, ! cblock->next->expr, 0)) return gfc_trans_where_3 (cblock, eblock); } } diff -Nrcpad gcc-4.3.0/gcc/fortran/trans.h gcc-4.3.1/gcc/fortran/trans.h *** gcc-4.3.0/gcc/fortran/trans.h Thu Feb 28 07:08:51 2008 --- gcc-4.3.1/gcc/fortran/trans.h Sat May 17 07:10:13 2008 *************** typedef struct gfc_ss *** 201,208 **** /* This is used by assignments requiring temporaries. The bits specify which loops the terms appear in. This will be 1 for the RHS expressions, ! 2 for the LHS expressions, and 3(=1|2) for the temporary. */ ! unsigned useflags:2; } gfc_ss; #define gfc_get_ss() gfc_getmem(sizeof(gfc_ss)) --- 201,209 ---- /* This is used by assignments requiring temporaries. The bits specify which loops the terms appear in. This will be 1 for the RHS expressions, ! 2 for the LHS expressions, and 3(=1|2) for the temporary. The bit ! 'where' suppresses precalculation of scalars in WHERE assignments. */ ! unsigned useflags:2, where:1; } gfc_ss; #define gfc_get_ss() gfc_getmem(sizeof(gfc_ss)) *************** tree gfc_get_symbol_decl (gfc_symbol *); *** 405,410 **** --- 406,414 ---- /* Build a static initializer. */ tree gfc_conv_initializer (gfc_expr *, gfc_typespec *, tree, bool, bool); + /* Assign a default initializer to a derived type. */ + tree gfc_init_default_dt (gfc_symbol *, tree); + /* Substitute a temporary variable in place of the real one. */ void gfc_shadow_sym (gfc_symbol *, tree, gfc_saved_var *); diff -Nrcpad gcc-4.3.0/libgfortran/ChangeLog gcc-4.3.1/libgfortran/ChangeLog *** gcc-4.3.0/libgfortran/ChangeLog Wed Mar 5 17:44:35 2008 --- gcc-4.3.1/libgfortran/ChangeLog Fri Jun 6 14:27:15 2008 *************** *** 1,3 **** --- 1,298 ---- + 2008-06-06 Release Manager + + * GCC 4.3.1 released. + + 2008-05-06 Thomas Koenig + + PR libfortran/35995 + PR libfortran/35990 + Backport from trunk. + * m4/ifunction_logical.m4: If the extent of "array" + is less than zero, set it to zero. Use an explicit + flag for breaking out of the main loop to avoid, because + the data pointer for "array" may be NULL for an empty + array. + * m4/ifunction.m4: Likewise. + * generated/all_l1.c: Regenerated. + * generated/all_l16.c: Regenerated. + * generated/all_l2.c: Regenerated. + * generated/all_l4.c: Regenerated. + * generated/all_l8.c: Regenerated. + * generated/any_l1.c: Regenerated. + * generated/any_l16.c: Regenerated. + * generated/any_l2.c: Regenerated. + * generated/any_l4.c: Regenerated. + * generated/any_l8.c: Regenerated. + * generated/count_16_l.c: Regenerated. + * generated/count_1_l.c: Regenerated. + * generated/count_2_l.c: Regenerated. + * generated/count_4_l.c: Regenerated. + * generated/count_8_l.c: Regenerated. + * generated/maxloc1_16_i1.c: Regenerated. + * generated/maxloc1_16_i16.c: Regenerated. + * generated/maxloc1_16_i2.c: Regenerated. + * generated/maxloc1_16_i4.c: Regenerated. + * generated/maxloc1_16_i8.c: Regenerated. + * generated/maxloc1_16_r10.c: Regenerated. + * generated/maxloc1_16_r16.c: Regenerated. + * generated/maxloc1_16_r4.c: Regenerated. + * generated/maxloc1_16_r8.c: Regenerated. + * generated/maxloc1_4_i1.c: Regenerated. + * generated/maxloc1_4_i16.c: Regenerated. + * generated/maxloc1_4_i2.c: Regenerated. + * generated/maxloc1_4_i4.c: Regenerated. + * generated/maxloc1_4_i8.c: Regenerated. + * generated/maxloc1_4_r10.c: Regenerated. + * generated/maxloc1_4_r16.c: Regenerated. + * generated/maxloc1_4_r4.c: Regenerated. + * generated/maxloc1_4_r8.c: Regenerated. + * generated/maxloc1_8_i1.c: Regenerated. + * generated/maxloc1_8_i16.c: Regenerated. + * generated/maxloc1_8_i2.c: Regenerated. + * generated/maxloc1_8_i4.c: Regenerated. + * generated/maxloc1_8_i8.c: Regenerated. + * generated/maxloc1_8_r10.c: Regenerated. + * generated/maxloc1_8_r16.c: Regenerated. + * generated/maxloc1_8_r4.c: Regenerated. + * generated/maxloc1_8_r8.c: Regenerated. + * generated/maxval_i1.c: Regenerated. + * generated/maxval_i16.c: Regenerated. + * generated/maxval_i2.c: Regenerated. + * generated/maxval_i4.c: Regenerated. + * generated/maxval_i8.c: Regenerated. + * generated/maxval_r10.c: Regenerated. + * generated/maxval_r16.c: Regenerated. + * generated/maxval_r4.c: Regenerated. + * generated/maxval_r8.c: Regenerated. + * generated/minloc1_16_i1.c: Regenerated. + * generated/minloc1_16_i16.c: Regenerated. + * generated/minloc1_16_i2.c: Regenerated. + * generated/minloc1_16_i4.c: Regenerated. + * generated/minloc1_16_i8.c: Regenerated. + * generated/minloc1_16_r10.c: Regenerated. + * generated/minloc1_16_r16.c: Regenerated. + * generated/minloc1_16_r4.c: Regenerated. + * generated/minloc1_16_r8.c: Regenerated. + * generated/minloc1_4_i1.c: Regenerated. + * generated/minloc1_4_i16.c: Regenerated. + * generated/minloc1_4_i2.c: Regenerated. + * generated/minloc1_4_i4.c: Regenerated. + * generated/minloc1_4_i8.c: Regenerated. + * generated/minloc1_4_r10.c: Regenerated. + * generated/minloc1_4_r16.c: Regenerated. + * generated/minloc1_4_r4.c: Regenerated. + * generated/minloc1_4_r8.c: Regenerated. + * generated/minloc1_8_i1.c: Regenerated. + * generated/minloc1_8_i16.c: Regenerated. + * generated/minloc1_8_i2.c: Regenerated. + * generated/minloc1_8_i4.c: Regenerated. + * generated/minloc1_8_i8.c: Regenerated. + * generated/minloc1_8_r10.c: Regenerated. + * generated/minloc1_8_r16.c: Regenerated. + * generated/minloc1_8_r4.c: Regenerated. + * generated/minloc1_8_r8.c: Regenerated. + * generated/minval_i1.c: Regenerated. + * generated/minval_i16.c: Regenerated. + * generated/minval_i2.c: Regenerated. + * generated/minval_i4.c: Regenerated. + * generated/minval_i8.c: Regenerated. + * generated/minval_r10.c: Regenerated. + * generated/minval_r16.c: Regenerated. + * generated/minval_r4.c: Regenerated. + * generated/minval_r8.c: Regenerated. + * generated/product_c10.c: Regenerated. + * generated/product_c16.c: Regenerated. + * generated/product_c4.c: Regenerated. + * generated/product_c8.c: Regenerated. + * generated/product_i1.c: Regenerated. + * generated/product_i16.c: Regenerated. + * generated/product_i2.c: Regenerated. + * generated/product_i4.c: Regenerated. + * generated/product_i8.c: Regenerated. + * generated/product_r10.c: Regenerated. + * generated/product_r16.c: Regenerated. + * generated/product_r4.c: Regenerated. + * generated/product_r8.c: Regenerated. + * generated/sum_c10.c: Regenerated. + * generated/sum_c16.c: Regenerated. + * generated/sum_c4.c: Regenerated. + * generated/sum_c8.c: Regenerated. + * generated/sum_i1.c: Regenerated. + * generated/sum_i16.c: Regenerated. + * generated/sum_i2.c: Regenerated. + * generated/sum_i4.c: Regenerated. + * generated/sum_i8.c: Regenerated. + * generated/sum_r10.c: Regenerated. + * generated/sum_r16.c: Regenerated. + * generated/sum_r4.c: Regenerated. + * generated/sum_r8.c: Regenerated. + * intrinsics/pack_generic.c: If an extent of the source + array is less then zero, set it to zero. Set the source + pointer to NULL if the source size is zero. Set the total + number of elements to zero if the vector has an extent + less or equal to zero. + * m4/pack.m4: Set the source pointer to NULL if the + source array is zero-sized. Set the total number of + elemements to zero if the vector has an extent less or + equal to zero. + * generated/pack_i1.c: Regenerated. + * generated/pack_i2.c: Regenerated. + * generated/pack_i4.c: Regenerated. + * generated/pack_i8.c: Regenerated. + * generated/pack_i16.c: Regenerated. + * generated/pack_r4.c: Regenerated. + * generated/pack_r8.c: Regenerated. + * generated/pack_r10.c: Regenerated. + * generated/pack_r16.c: Regenerated. + * generated/pack_c4.c: Regenerated. + * generated/pack_c8.c: Regenerated. + * generated/pack_c10.c: Regenerated. + * generated/pack_c16.c: Regenerated. + + 2008-05-03 Thomas Koenig + + PR libfortran/35993 + Backport from trunk. + * ifunction.m4 (SCALAR_ARRAY_FUNCTION): Use correct + implementation for multi-dimensional return arrays when + the mask is .false. + * generated/maxloc1_16_i1.c: Regenerated. + * generated/maxloc1_16_i16.c: Regenerated. + * generated/maxloc1_16_i2.c: Regenerated. + * generated/maxloc1_16_i4.c: Regenerated. + * generated/maxloc1_16_i8.c: Regenerated. + * generated/maxloc1_16_r10.c: Regenerated. + * generated/maxloc1_16_r16.c: Regenerated. + * generated/maxloc1_16_r4.c: Regenerated. + * generated/maxloc1_16_r8.c: Regenerated. + * generated/maxloc1_4_i1.c: Regenerated. + * generated/maxloc1_4_i16.c: Regenerated. + * generated/maxloc1_4_i2.c: Regenerated. + * generated/maxloc1_4_i4.c: Regenerated. + * generated/maxloc1_4_i8.c: Regenerated. + * generated/maxloc1_4_r10.c: Regenerated. + * generated/maxloc1_4_r16.c: Regenerated. + * generated/maxloc1_4_r4.c: Regenerated. + * generated/maxloc1_4_r8.c: Regenerated. + * generated/maxloc1_8_i1.c: Regenerated. + * generated/maxloc1_8_i16.c: Regenerated. + * generated/maxloc1_8_i2.c: Regenerated. + * generated/maxloc1_8_i4.c: Regenerated. + * generated/maxloc1_8_i8.c: Regenerated. + * generated/maxloc1_8_r10.c: Regenerated. + * generated/maxloc1_8_r16.c: Regenerated. + * generated/maxloc1_8_r4.c: Regenerated. + * generated/maxloc1_8_r8.c: Regenerated. + * generated/maxval_i1.c: Regenerated. + * generated/maxval_i16.c: Regenerated. + * generated/maxval_i2.c: Regenerated. + * generated/maxval_i4.c: Regenerated. + * generated/maxval_i8.c: Regenerated. + * generated/maxval_r10.c: Regenerated. + * generated/maxval_r16.c: Regenerated. + * generated/maxval_r4.c: Regenerated. + * generated/maxval_r8.c: Regenerated. + * generated/minloc1_16_i1.c: Regenerated. + * generated/minloc1_16_i16.c: Regenerated. + * generated/minloc1_16_i2.c: Regenerated. + * generated/minloc1_16_i4.c: Regenerated. + * generated/minloc1_16_i8.c: Regenerated. + * generated/minloc1_16_r10.c: Regenerated. + * generated/minloc1_16_r16.c: Regenerated. + * generated/minloc1_16_r4.c: Regenerated. + * generated/minloc1_16_r8.c: Regenerated. + * generated/minloc1_4_i1.c: Regenerated. + * generated/minloc1_4_i16.c: Regenerated. + * generated/minloc1_4_i2.c: Regenerated. + * generated/minloc1_4_i4.c: Regenerated. + * generated/minloc1_4_i8.c: Regenerated. + * generated/minloc1_4_r10.c: Regenerated. + * generated/minloc1_4_r16.c: Regenerated. + * generated/minloc1_4_r4.c: Regenerated. + * generated/minloc1_4_r8.c: Regenerated. + * generated/minloc1_8_i1.c: Regenerated. + * generated/minloc1_8_i16.c: Regenerated. + * generated/minloc1_8_i2.c: Regenerated. + * generated/minloc1_8_i4.c: Regenerated. + * generated/minloc1_8_i8.c: Regenerated. + * generated/minloc1_8_r10.c: Regenerated. + * generated/minloc1_8_r16.c: Regenerated. + * generated/minloc1_8_r4.c: Regenerated. + * generated/minloc1_8_r8.c: Regenerated. + * generated/minval_i1.c: Regenerated. + * generated/minval_i16.c: Regenerated. + * generated/minval_i2.c: Regenerated. + * generated/minval_i4.c: Regenerated. + * generated/minval_i8.c: Regenerated. + * generated/minval_r10.c: Regenerated. + * generated/minval_r16.c: Regenerated. + * generated/minval_r4.c: Regenerated. + * generated/minval_r8.c: Regenerated. + * generated/product_c10.c: Regenerated. + * generated/product_c16.c: Regenerated. + * generated/product_c4.c: Regenerated. + * generated/product_c8.c: Regenerated. + * generated/product_i1.c: Regenerated. + * generated/product_i16.c: Regenerated. + * generated/product_i2.c: Regenerated. + * generated/product_i4.c: Regenerated. + * generated/product_i8.c: Regenerated. + * generated/product_r10.c: Regenerated. + * generated/product_r16.c: Regenerated. + * generated/product_r4.c: Regenerated. + * generated/product_r8.c: Regenerated. + * generated/sum_c10.c: Regenerated. + * generated/sum_c16.c: Regenerated. + * generated/sum_c4.c: Regenerated. + * generated/sum_c8.c: Regenerated. + * generated/sum_i1.c: Regenerated. + * generated/sum_i16.c: Regenerated. + * generated/sum_i2.c: Regenerated. + * generated/sum_i4.c: Regenerated. + * generated/sum_i8.c: Regenerated. + * generated/sum_r10.c: Regenerated. + * generated/sum_r16.c: Regenerated. + * generated/sum_r4.c: Regenerated. + * generated/sum_r8.c: Regenerated. + + 2008-04-09 Jakub Jelinek + + * io/list_read.c (snprintf): Define if HAVE_SNPRINTF isn't defined. + (nml_read_obj): Add nml_err_msg_size argument. Pass it down to + recursive call. Use snprintf instead of sprintf when %s nl->var_name + is used. + (nml_get_obj_data): Add nml_err_msg_size argument. Pass it down to + nml_read_obj call. Use snprintf instead of sprintf when %s + nl->var_name is used. Pass nml_err_msg to nml_parse_qualifier instead + of parse_err_msg array. Append " for namelist variable " and + nl->var_name to it. + (namelist_read): Increase size of nml_err_msg array to 200. Pass + sizeof nml_err_msg as extra argument to nml_get_obj_data. + + 2008-03-28 Jerry DeLisle + + PR libfortran/35699 + * io/transfer.c (write_buf): Don't pad the record, just return if the + data is NULL. (next_record_w): If there are bytes left in the record + for unformatted direct I/O, pad out the record with zero bytes. + + 2008-03-20 Jerry DeLisle + + PR libfortran/35627 + Backport from trunk. + * io/list_read.c (free_line): Clear the line buffer enable flag and + reset the index into line_buffer, aka item_count. + (next_char): Cleanup whitespace. + (read_logical): Use unget_char to assure that the first character of the + bad logical is saved in case it is part of an object name. Remove the + clearing of index and flag that is now in free_line. + (read_real): Likewise. + + PR libfortran/35617 + Backport from trunk. + * io/list_read.c (eat_separator): If next character after eatline is '!' + then eatline again. + 2008-03-05 Release Manager * GCC 4.3.0 released. diff -Nrcpad gcc-4.3.0/libgfortran/generated/all_l1.c gcc-4.3.1/libgfortran/generated/all_l1.c *** gcc-4.3.0/libgfortran/generated/all_l1.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/all_l1.c Tue May 6 20:46:41 2008 *************** all_l1 (gfc_array_l1 * const restrict re *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** all_l1 (gfc_array_l1 * const restrict re *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** all_l1 (gfc_array_l1 * const restrict re *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_1 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_1 result; *************** all_l1 (gfc_array_l1 * const restrict re *** 206,212 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 211,217 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/all_l16.c gcc-4.3.1/libgfortran/generated/all_l16.c *** gcc-4.3.0/libgfortran/generated/all_l16.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/all_l16.c Tue May 6 20:46:41 2008 *************** all_l16 (gfc_array_l16 * const restrict *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** all_l16 (gfc_array_l16 * const restrict *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** all_l16 (gfc_array_l16 * const restrict *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_16 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_16 result; *************** all_l16 (gfc_array_l16 * const restrict *** 206,212 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 211,217 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/all_l2.c gcc-4.3.1/libgfortran/generated/all_l2.c *** gcc-4.3.0/libgfortran/generated/all_l2.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/all_l2.c Tue May 6 20:46:41 2008 *************** all_l2 (gfc_array_l2 * const restrict re *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** all_l2 (gfc_array_l2 * const restrict re *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** all_l2 (gfc_array_l2 * const restrict re *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_2 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_2 result; *************** all_l2 (gfc_array_l2 * const restrict re *** 206,212 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 211,217 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/all_l4.c gcc-4.3.1/libgfortran/generated/all_l4.c *** gcc-4.3.0/libgfortran/generated/all_l4.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/all_l4.c Tue May 6 20:46:41 2008 *************** all_l4 (gfc_array_l4 * const restrict re *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** all_l4 (gfc_array_l4 * const restrict re *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** all_l4 (gfc_array_l4 * const restrict re *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_4 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_4 result; *************** all_l4 (gfc_array_l4 * const restrict re *** 206,212 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 211,217 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/all_l8.c gcc-4.3.1/libgfortran/generated/all_l8.c *** gcc-4.3.0/libgfortran/generated/all_l8.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/all_l8.c Tue May 6 20:46:41 2008 *************** all_l8 (gfc_array_l8 * const restrict re *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** all_l8 (gfc_array_l8 * const restrict re *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** all_l8 (gfc_array_l8 * const restrict re *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_8 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_8 result; *************** all_l8 (gfc_array_l8 * const restrict re *** 206,212 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 211,217 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/any_l1.c gcc-4.3.1/libgfortran/generated/any_l1.c *** gcc-4.3.0/libgfortran/generated/any_l1.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/any_l1.c Tue May 6 20:46:41 2008 *************** any_l1 (gfc_array_l1 * const restrict re *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** any_l1 (gfc_array_l1 * const restrict re *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** any_l1 (gfc_array_l1 * const restrict re *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_1 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_1 result; *************** any_l1 (gfc_array_l1 * const restrict re *** 206,212 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 211,217 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/any_l16.c gcc-4.3.1/libgfortran/generated/any_l16.c *** gcc-4.3.0/libgfortran/generated/any_l16.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/any_l16.c Tue May 6 20:46:41 2008 *************** any_l16 (gfc_array_l16 * const restrict *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** any_l16 (gfc_array_l16 * const restrict *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** any_l16 (gfc_array_l16 * const restrict *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_16 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_16 result; *************** any_l16 (gfc_array_l16 * const restrict *** 206,212 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 211,217 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/any_l2.c gcc-4.3.1/libgfortran/generated/any_l2.c *** gcc-4.3.0/libgfortran/generated/any_l2.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/any_l2.c Tue May 6 20:46:41 2008 *************** any_l2 (gfc_array_l2 * const restrict re *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** any_l2 (gfc_array_l2 * const restrict re *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** any_l2 (gfc_array_l2 * const restrict re *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_2 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_2 result; *************** any_l2 (gfc_array_l2 * const restrict re *** 206,212 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 211,217 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/any_l4.c gcc-4.3.1/libgfortran/generated/any_l4.c *** gcc-4.3.0/libgfortran/generated/any_l4.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/any_l4.c Tue May 6 20:46:41 2008 *************** any_l4 (gfc_array_l4 * const restrict re *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** any_l4 (gfc_array_l4 * const restrict re *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** any_l4 (gfc_array_l4 * const restrict re *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_4 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_4 result; *************** any_l4 (gfc_array_l4 * const restrict re *** 206,212 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 211,217 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/any_l8.c gcc-4.3.1/libgfortran/generated/any_l8.c *** gcc-4.3.0/libgfortran/generated/any_l8.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/any_l8.c Tue May 6 20:46:41 2008 *************** any_l8 (gfc_array_l8 * const restrict re *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** any_l8 (gfc_array_l8 * const restrict re *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** any_l8 (gfc_array_l8 * const restrict re *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_8 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_LOGICAL_8 result; *************** any_l8 (gfc_array_l8 * const restrict re *** 206,212 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 211,217 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/count_16_l.c gcc-4.3.1/libgfortran/generated/count_16_l.c *** gcc-4.3.0/libgfortran/generated/count_16_l.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/count_16_l.c Tue May 6 20:46:41 2008 *************** count_16_l (gfc_array_i16 * const restri *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** count_16_l (gfc_array_i16 * const restri *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** count_16_l (gfc_array_i16 * const restri *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_INTEGER_16 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_INTEGER_16 result; *************** count_16_l (gfc_array_i16 * const restri *** 202,208 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 207,213 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/count_1_l.c gcc-4.3.1/libgfortran/generated/count_1_l.c *** gcc-4.3.0/libgfortran/generated/count_1_l.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/count_1_l.c Tue May 6 20:46:41 2008 *************** count_1_l (gfc_array_i1 * const restrict *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** count_1_l (gfc_array_i1 * const restrict *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** count_1_l (gfc_array_i1 * const restrict *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_INTEGER_1 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_INTEGER_1 result; *************** count_1_l (gfc_array_i1 * const restrict *** 202,208 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 207,213 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/count_2_l.c gcc-4.3.1/libgfortran/generated/count_2_l.c *** gcc-4.3.0/libgfortran/generated/count_2_l.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/count_2_l.c Tue May 6 20:46:41 2008 *************** count_2_l (gfc_array_i2 * const restrict *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** count_2_l (gfc_array_i2 * const restrict *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** count_2_l (gfc_array_i2 * const restrict *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_INTEGER_2 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_INTEGER_2 result; *************** count_2_l (gfc_array_i2 * const restrict *** 202,208 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 207,213 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/count_4_l.c gcc-4.3.1/libgfortran/generated/count_4_l.c *** gcc-4.3.0/libgfortran/generated/count_4_l.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/count_4_l.c Tue May 6 20:46:41 2008 *************** count_4_l (gfc_array_i4 * const restrict *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** count_4_l (gfc_array_i4 * const restrict *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** count_4_l (gfc_array_i4 * const restrict *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_INTEGER_4 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_INTEGER_4 result; *************** count_4_l (gfc_array_i4 * const restrict *** 202,208 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 207,213 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/count_8_l.c gcc-4.3.1/libgfortran/generated/count_8_l.c *** gcc-4.3.0/libgfortran/generated/count_8_l.c Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/generated/count_8_l.c Tue May 6 20:46:41 2008 *************** count_8_l (gfc_array_i8 * const restrict *** 57,62 **** --- 57,63 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** count_8_l (gfc_array_i8 * const restrict *** 65,70 **** --- 66,74 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** count_8_l (gfc_array_i8 * const restrict *** 163,169 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; GFC_INTEGER_8 result; --- 167,174 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; GFC_INTEGER_8 result; *************** count_8_l (gfc_array_i8 * const restrict *** 202,208 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 207,213 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_16_i1.c gcc-4.3.1/libgfortran/generated/maxloc1_16_i1.c *** gcc-4.3.0/libgfortran/generated/maxloc1_16_i1.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_16_i1.c Tue May 6 20:46:41 2008 *************** maxloc1_16_i1 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_16_i1 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_16 result; *************** maxloc1_16_i1 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_16_i1 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { maxloc1_16_i1 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_16_i1 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_16_i16.c gcc-4.3.1/libgfortran/generated/maxloc1_16_i16.c *** gcc-4.3.0/libgfortran/generated/maxloc1_16_i16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_16_i16.c Tue May 6 20:46:41 2008 *************** maxloc1_16_i16 (gfc_array_i16 * const re *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_16_i16 (gfc_array_i16 * const re *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; *************** maxloc1_16_i16 (gfc_array_i16 * const re *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_16_i16 (gfc_array_i16 * const r *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { maxloc1_16_i16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_16_i16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_16_i2.c gcc-4.3.1/libgfortran/generated/maxloc1_16_i2.c *** gcc-4.3.0/libgfortran/generated/maxloc1_16_i2.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_16_i2.c Tue May 6 20:46:41 2008 *************** maxloc1_16_i2 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_16_i2 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_16 result; *************** maxloc1_16_i2 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_16_i2 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { maxloc1_16_i2 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_16_i2 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_16_i4.c gcc-4.3.1/libgfortran/generated/maxloc1_16_i4.c *** gcc-4.3.0/libgfortran/generated/maxloc1_16_i4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_16_i4.c Tue May 6 20:46:41 2008 *************** maxloc1_16_i4 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_16_i4 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_16 result; *************** maxloc1_16_i4 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_16_i4 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { maxloc1_16_i4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_16_i4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_16_i8.c gcc-4.3.1/libgfortran/generated/maxloc1_16_i8.c *** gcc-4.3.0/libgfortran/generated/maxloc1_16_i8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_16_i8.c Tue May 6 20:46:41 2008 *************** maxloc1_16_i8 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_16_i8 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_16 result; *************** maxloc1_16_i8 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_16_i8 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { maxloc1_16_i8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_16_i8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_16_r10.c gcc-4.3.1/libgfortran/generated/maxloc1_16_r10.c *** gcc-4.3.0/libgfortran/generated/maxloc1_16_r10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_16_r10.c Tue May 6 20:46:41 2008 *************** maxloc1_16_r10 (gfc_array_i16 * const re *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_16_r10 (gfc_array_i16 * const re *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_10 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_10 * restrict src; GFC_INTEGER_16 result; *************** maxloc1_16_r10 (gfc_array_i16 * const re *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_16_r10 (gfc_array_i16 * const r *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { maxloc1_16_r10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_16_r10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_16_r16.c gcc-4.3.1/libgfortran/generated/maxloc1_16_r16.c *** gcc-4.3.0/libgfortran/generated/maxloc1_16_r16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_16_r16.c Tue May 6 20:46:41 2008 *************** maxloc1_16_r16 (gfc_array_i16 * const re *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_16_r16 (gfc_array_i16 * const re *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_16 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_16 * restrict src; GFC_INTEGER_16 result; *************** maxloc1_16_r16 (gfc_array_i16 * const re *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_16_r16 (gfc_array_i16 * const r *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { maxloc1_16_r16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_16_r16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_16_r4.c gcc-4.3.1/libgfortran/generated/maxloc1_16_r4.c *** gcc-4.3.0/libgfortran/generated/maxloc1_16_r4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_16_r4.c Tue May 6 20:46:41 2008 *************** maxloc1_16_r4 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_16_r4 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_4 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_4 * restrict src; GFC_INTEGER_16 result; *************** maxloc1_16_r4 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_16_r4 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { maxloc1_16_r4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_16_r4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_16_r8.c gcc-4.3.1/libgfortran/generated/maxloc1_16_r8.c *** gcc-4.3.0/libgfortran/generated/maxloc1_16_r8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_16_r8.c Tue May 6 20:46:41 2008 *************** maxloc1_16_r8 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_16_r8 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_8 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_8 * restrict src; GFC_INTEGER_16 result; *************** maxloc1_16_r8 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_16_r8 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { maxloc1_16_r8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_16_r8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_4_i1.c gcc-4.3.1/libgfortran/generated/maxloc1_4_i1.c *** gcc-4.3.0/libgfortran/generated/maxloc1_4_i1.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_4_i1.c Tue May 6 20:46:41 2008 *************** maxloc1_4_i1 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_4_i1 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_4 result; *************** maxloc1_4_i1 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_4_i1 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { maxloc1_4_i1 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_4_i1 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_4_i16.c gcc-4.3.1/libgfortran/generated/maxloc1_4_i16.c *** gcc-4.3.0/libgfortran/generated/maxloc1_4_i16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_4_i16.c Tue May 6 20:46:41 2008 *************** maxloc1_4_i16 (gfc_array_i4 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_4_i16 (gfc_array_i4 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_4 result; *************** maxloc1_4_i16 (gfc_array_i4 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_4_i16 (gfc_array_i4 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { maxloc1_4_i16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_4_i16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_4_i2.c gcc-4.3.1/libgfortran/generated/maxloc1_4_i2.c *** gcc-4.3.0/libgfortran/generated/maxloc1_4_i2.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_4_i2.c Tue May 6 20:46:41 2008 *************** maxloc1_4_i2 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_4_i2 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_4 result; *************** maxloc1_4_i2 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_4_i2 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { maxloc1_4_i2 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_4_i2 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_4_i4.c gcc-4.3.1/libgfortran/generated/maxloc1_4_i4.c *** gcc-4.3.0/libgfortran/generated/maxloc1_4_i4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_4_i4.c Tue May 6 20:46:41 2008 *************** maxloc1_4_i4 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_4_i4 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; *************** maxloc1_4_i4 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_4_i4 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { maxloc1_4_i4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_4_i4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_4_i8.c gcc-4.3.1/libgfortran/generated/maxloc1_4_i8.c *** gcc-4.3.0/libgfortran/generated/maxloc1_4_i8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_4_i8.c Tue May 6 20:46:41 2008 *************** maxloc1_4_i8 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_4_i8 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_4 result; *************** maxloc1_4_i8 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_4_i8 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { maxloc1_4_i8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_4_i8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_4_r10.c gcc-4.3.1/libgfortran/generated/maxloc1_4_r10.c *** gcc-4.3.0/libgfortran/generated/maxloc1_4_r10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_4_r10.c Tue May 6 20:46:41 2008 *************** maxloc1_4_r10 (gfc_array_i4 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_4_r10 (gfc_array_i4 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_10 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_10 * restrict src; GFC_INTEGER_4 result; *************** maxloc1_4_r10 (gfc_array_i4 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_4_r10 (gfc_array_i4 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { maxloc1_4_r10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_4_r10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_4_r16.c gcc-4.3.1/libgfortran/generated/maxloc1_4_r16.c *** gcc-4.3.0/libgfortran/generated/maxloc1_4_r16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_4_r16.c Tue May 6 20:46:41 2008 *************** maxloc1_4_r16 (gfc_array_i4 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_4_r16 (gfc_array_i4 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_16 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_16 * restrict src; GFC_INTEGER_4 result; *************** maxloc1_4_r16 (gfc_array_i4 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_4_r16 (gfc_array_i4 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { maxloc1_4_r16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_4_r16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_4_r4.c gcc-4.3.1/libgfortran/generated/maxloc1_4_r4.c *** gcc-4.3.0/libgfortran/generated/maxloc1_4_r4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_4_r4.c Tue May 6 20:46:41 2008 *************** maxloc1_4_r4 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_4_r4 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_4 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_4 * restrict src; GFC_INTEGER_4 result; *************** maxloc1_4_r4 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_4_r4 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { maxloc1_4_r4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_4_r4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_4_r8.c gcc-4.3.1/libgfortran/generated/maxloc1_4_r8.c *** gcc-4.3.0/libgfortran/generated/maxloc1_4_r8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_4_r8.c Tue May 6 20:46:41 2008 *************** maxloc1_4_r8 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_4_r8 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_8 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_8 * restrict src; GFC_INTEGER_4 result; *************** maxloc1_4_r8 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_4_r8 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { maxloc1_4_r8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_4_r8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_8_i1.c gcc-4.3.1/libgfortran/generated/maxloc1_8_i1.c *** gcc-4.3.0/libgfortran/generated/maxloc1_8_i1.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_8_i1.c Tue May 6 20:46:41 2008 *************** maxloc1_8_i1 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_8_i1 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_8 result; *************** maxloc1_8_i1 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_8_i1 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { maxloc1_8_i1 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_8_i1 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_8_i16.c gcc-4.3.1/libgfortran/generated/maxloc1_8_i16.c *** gcc-4.3.0/libgfortran/generated/maxloc1_8_i16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_8_i16.c Tue May 6 20:46:41 2008 *************** maxloc1_8_i16 (gfc_array_i8 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_8_i16 (gfc_array_i8 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_8 result; *************** maxloc1_8_i16 (gfc_array_i8 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_8_i16 (gfc_array_i8 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { maxloc1_8_i16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_8_i16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_8_i2.c gcc-4.3.1/libgfortran/generated/maxloc1_8_i2.c *** gcc-4.3.0/libgfortran/generated/maxloc1_8_i2.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_8_i2.c Tue May 6 20:46:41 2008 *************** maxloc1_8_i2 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_8_i2 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_8 result; *************** maxloc1_8_i2 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_8_i2 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { maxloc1_8_i2 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_8_i2 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_8_i4.c gcc-4.3.1/libgfortran/generated/maxloc1_8_i4.c *** gcc-4.3.0/libgfortran/generated/maxloc1_8_i4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_8_i4.c Tue May 6 20:46:41 2008 *************** maxloc1_8_i4 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_8_i4 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_8 result; *************** maxloc1_8_i4 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_8_i4 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { maxloc1_8_i4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_8_i4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_8_i8.c gcc-4.3.1/libgfortran/generated/maxloc1_8_i8.c *** gcc-4.3.0/libgfortran/generated/maxloc1_8_i8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_8_i8.c Tue May 6 20:46:41 2008 *************** maxloc1_8_i8 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_8_i8 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; *************** maxloc1_8_i8 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_8_i8 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { maxloc1_8_i8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_8_i8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_8_r10.c gcc-4.3.1/libgfortran/generated/maxloc1_8_r10.c *** gcc-4.3.0/libgfortran/generated/maxloc1_8_r10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_8_r10.c Tue May 6 20:46:41 2008 *************** maxloc1_8_r10 (gfc_array_i8 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_8_r10 (gfc_array_i8 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_10 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_10 * restrict src; GFC_INTEGER_8 result; *************** maxloc1_8_r10 (gfc_array_i8 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_8_r10 (gfc_array_i8 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { maxloc1_8_r10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_8_r10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_8_r16.c gcc-4.3.1/libgfortran/generated/maxloc1_8_r16.c *** gcc-4.3.0/libgfortran/generated/maxloc1_8_r16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_8_r16.c Tue May 6 20:46:41 2008 *************** maxloc1_8_r16 (gfc_array_i8 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_8_r16 (gfc_array_i8 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_16 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_16 * restrict src; GFC_INTEGER_8 result; *************** maxloc1_8_r16 (gfc_array_i8 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_8_r16 (gfc_array_i8 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { maxloc1_8_r16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_8_r16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_8_r4.c gcc-4.3.1/libgfortran/generated/maxloc1_8_r4.c *** gcc-4.3.0/libgfortran/generated/maxloc1_8_r4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_8_r4.c Tue May 6 20:46:41 2008 *************** maxloc1_8_r4 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_8_r4 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_4 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_4 * restrict src; GFC_INTEGER_8 result; *************** maxloc1_8_r4 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_8_r4 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { maxloc1_8_r4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_8_r4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxloc1_8_r8.c gcc-4.3.1/libgfortran/generated/maxloc1_8_r8.c *** gcc-4.3.0/libgfortran/generated/maxloc1_8_r8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxloc1_8_r8.c Tue May 6 20:46:41 2008 *************** maxloc1_8_r8 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxloc1_8_r8 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_8 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_8 * restrict src; GFC_INTEGER_8 result; *************** maxloc1_8_r8 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxloc1_8_r8 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { maxloc1_8_r8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxloc1_8_r8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxval_i1.c gcc-4.3.1/libgfortran/generated/maxval_i1.c *** gcc-4.3.0/libgfortran/generated/maxval_i1.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxval_i1.c Tue May 6 20:46:41 2008 *************** maxval_i1 (gfc_array_i1 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxval_i1 (gfc_array_i1 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_1 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_1 result; *************** maxval_i1 (gfc_array_i1 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxval_i1 (gfc_array_i1 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_1 *dest; if (*mask) { maxval_i1 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_1) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = (-GFC_INTEGER_1_HUGE-1) ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_1 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxval_i1 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_1) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = (-GFC_INTEGER_1_HUGE-1); ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxval_i16.c gcc-4.3.1/libgfortran/generated/maxval_i16.c *** gcc-4.3.0/libgfortran/generated/maxval_i16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxval_i16.c Tue May 6 20:46:41 2008 *************** maxval_i16 (gfc_array_i16 * const restri *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxval_i16 (gfc_array_i16 * const restri *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; *************** maxval_i16 (gfc_array_i16 * const restri *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxval_i16 (gfc_array_i16 * const restr *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { maxval_i16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = (-GFC_INTEGER_16_HUGE-1) ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxval_i16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = (-GFC_INTEGER_16_HUGE-1); ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxval_i2.c gcc-4.3.1/libgfortran/generated/maxval_i2.c *** gcc-4.3.0/libgfortran/generated/maxval_i2.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxval_i2.c Tue May 6 20:46:41 2008 *************** maxval_i2 (gfc_array_i2 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxval_i2 (gfc_array_i2 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_2 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_2 result; *************** maxval_i2 (gfc_array_i2 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxval_i2 (gfc_array_i2 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_2 *dest; if (*mask) { maxval_i2 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_2) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = (-GFC_INTEGER_2_HUGE-1) ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_2 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxval_i2 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_2) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = (-GFC_INTEGER_2_HUGE-1); ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxval_i4.c gcc-4.3.1/libgfortran/generated/maxval_i4.c *** gcc-4.3.0/libgfortran/generated/maxval_i4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxval_i4.c Tue May 6 20:46:41 2008 *************** maxval_i4 (gfc_array_i4 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxval_i4 (gfc_array_i4 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; *************** maxval_i4 (gfc_array_i4 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxval_i4 (gfc_array_i4 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { maxval_i4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = (-GFC_INTEGER_4_HUGE-1) ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxval_i4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = (-GFC_INTEGER_4_HUGE-1); ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxval_i8.c gcc-4.3.1/libgfortran/generated/maxval_i8.c *** gcc-4.3.0/libgfortran/generated/maxval_i8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxval_i8.c Tue May 6 20:46:41 2008 *************** maxval_i8 (gfc_array_i8 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxval_i8 (gfc_array_i8 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; *************** maxval_i8 (gfc_array_i8 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxval_i8 (gfc_array_i8 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { maxval_i8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = (-GFC_INTEGER_8_HUGE-1) ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxval_i8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = (-GFC_INTEGER_8_HUGE-1); ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxval_r10.c gcc-4.3.1/libgfortran/generated/maxval_r10.c *** gcc-4.3.0/libgfortran/generated/maxval_r10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxval_r10.c Tue May 6 20:46:41 2008 *************** maxval_r10 (gfc_array_r10 * const restri *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxval_r10 (gfc_array_r10 * const restri *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_10 * restrict src; GFC_REAL_10 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_10 * restrict src; GFC_REAL_10 result; *************** maxval_r10 (gfc_array_r10 * const restri *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxval_r10 (gfc_array_r10 * const restr *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_10 *dest; if (*mask) { maxval_r10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_10) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = -GFC_REAL_10_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_10 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxval_r10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_10) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = -GFC_REAL_10_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxval_r16.c gcc-4.3.1/libgfortran/generated/maxval_r16.c *** gcc-4.3.0/libgfortran/generated/maxval_r16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxval_r16.c Tue May 6 20:46:41 2008 *************** maxval_r16 (gfc_array_r16 * const restri *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxval_r16 (gfc_array_r16 * const restri *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_16 * restrict src; GFC_REAL_16 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_16 * restrict src; GFC_REAL_16 result; *************** maxval_r16 (gfc_array_r16 * const restri *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxval_r16 (gfc_array_r16 * const restr *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_16 *dest; if (*mask) { maxval_r16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = -GFC_REAL_16_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxval_r16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = -GFC_REAL_16_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxval_r4.c gcc-4.3.1/libgfortran/generated/maxval_r4.c *** gcc-4.3.0/libgfortran/generated/maxval_r4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxval_r4.c Tue May 6 20:46:41 2008 *************** maxval_r4 (gfc_array_r4 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxval_r4 (gfc_array_r4 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_4 * restrict src; GFC_REAL_4 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_4 * restrict src; GFC_REAL_4 result; *************** maxval_r4 (gfc_array_r4 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxval_r4 (gfc_array_r4 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_4 *dest; if (*mask) { maxval_r4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = -GFC_REAL_4_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxval_r4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = -GFC_REAL_4_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/maxval_r8.c gcc-4.3.1/libgfortran/generated/maxval_r8.c *** gcc-4.3.0/libgfortran/generated/maxval_r8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/maxval_r8.c Tue May 6 20:46:41 2008 *************** maxval_r8 (gfc_array_r8 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** maxval_r8 (gfc_array_r8 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_8 * restrict src; GFC_REAL_8 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_8 * restrict src; GFC_REAL_8 result; *************** maxval_r8 (gfc_array_r8 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** smaxval_r8 (gfc_array_r8 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_8 *dest; if (*mask) { maxval_r8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MAXVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = -GFC_REAL_8_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { maxval_r8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MAXVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MAXVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = -GFC_REAL_8_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_16_i1.c gcc-4.3.1/libgfortran/generated/minloc1_16_i1.c *** gcc-4.3.0/libgfortran/generated/minloc1_16_i1.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_16_i1.c Tue May 6 20:46:41 2008 *************** minloc1_16_i1 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_16_i1 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_16 result; *************** minloc1_16_i1 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_16_i1 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { minloc1_16_i1 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_16_i1 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_16_i16.c gcc-4.3.1/libgfortran/generated/minloc1_16_i16.c *** gcc-4.3.0/libgfortran/generated/minloc1_16_i16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_16_i16.c Tue May 6 20:46:41 2008 *************** minloc1_16_i16 (gfc_array_i16 * const re *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_16_i16 (gfc_array_i16 * const re *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; *************** minloc1_16_i16 (gfc_array_i16 * const re *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_16_i16 (gfc_array_i16 * const r *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { minloc1_16_i16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_16_i16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_16_i2.c gcc-4.3.1/libgfortran/generated/minloc1_16_i2.c *** gcc-4.3.0/libgfortran/generated/minloc1_16_i2.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_16_i2.c Tue May 6 20:46:41 2008 *************** minloc1_16_i2 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_16_i2 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_16 result; *************** minloc1_16_i2 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_16_i2 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { minloc1_16_i2 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_16_i2 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_16_i4.c gcc-4.3.1/libgfortran/generated/minloc1_16_i4.c *** gcc-4.3.0/libgfortran/generated/minloc1_16_i4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_16_i4.c Tue May 6 20:46:41 2008 *************** minloc1_16_i4 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_16_i4 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_16 result; *************** minloc1_16_i4 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_16_i4 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { minloc1_16_i4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_16_i4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_16_i8.c gcc-4.3.1/libgfortran/generated/minloc1_16_i8.c *** gcc-4.3.0/libgfortran/generated/minloc1_16_i8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_16_i8.c Tue May 6 20:46:41 2008 *************** minloc1_16_i8 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_16_i8 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_16 result; *************** minloc1_16_i8 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_16_i8 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { minloc1_16_i8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_16_i8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_16_r10.c gcc-4.3.1/libgfortran/generated/minloc1_16_r10.c *** gcc-4.3.0/libgfortran/generated/minloc1_16_r10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_16_r10.c Tue May 6 20:46:41 2008 *************** minloc1_16_r10 (gfc_array_i16 * const re *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_16_r10 (gfc_array_i16 * const re *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_10 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_10 * restrict src; GFC_INTEGER_16 result; *************** minloc1_16_r10 (gfc_array_i16 * const re *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_16_r10 (gfc_array_i16 * const r *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { minloc1_16_r10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_16_r10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_16_r16.c gcc-4.3.1/libgfortran/generated/minloc1_16_r16.c *** gcc-4.3.0/libgfortran/generated/minloc1_16_r16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_16_r16.c Tue May 6 20:46:41 2008 *************** minloc1_16_r16 (gfc_array_i16 * const re *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_16_r16 (gfc_array_i16 * const re *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_16 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_16 * restrict src; GFC_INTEGER_16 result; *************** minloc1_16_r16 (gfc_array_i16 * const re *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_16_r16 (gfc_array_i16 * const r *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { minloc1_16_r16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_16_r16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_16_r4.c gcc-4.3.1/libgfortran/generated/minloc1_16_r4.c *** gcc-4.3.0/libgfortran/generated/minloc1_16_r4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_16_r4.c Tue May 6 20:46:41 2008 *************** minloc1_16_r4 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_16_r4 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_4 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_4 * restrict src; GFC_INTEGER_16 result; *************** minloc1_16_r4 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_16_r4 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { minloc1_16_r4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_16_r4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_16_r8.c gcc-4.3.1/libgfortran/generated/minloc1_16_r8.c *** gcc-4.3.0/libgfortran/generated/minloc1_16_r8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_16_r8.c Tue May 6 20:46:41 2008 *************** minloc1_16_r8 (gfc_array_i16 * const res *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_16_r8 (gfc_array_i16 * const res *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_8 * restrict src; GFC_INTEGER_16 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_8 * restrict src; GFC_INTEGER_16 result; *************** minloc1_16_r8 (gfc_array_i16 * const res *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_16_r8 (gfc_array_i16 * const re *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { minloc1_16_r8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_16_r8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_4_i1.c gcc-4.3.1/libgfortran/generated/minloc1_4_i1.c *** gcc-4.3.0/libgfortran/generated/minloc1_4_i1.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_4_i1.c Tue May 6 20:46:41 2008 *************** minloc1_4_i1 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_4_i1 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_4 result; *************** minloc1_4_i1 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_4_i1 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { minloc1_4_i1 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_4_i1 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_4_i16.c gcc-4.3.1/libgfortran/generated/minloc1_4_i16.c *** gcc-4.3.0/libgfortran/generated/minloc1_4_i16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_4_i16.c Tue May 6 20:46:41 2008 *************** minloc1_4_i16 (gfc_array_i4 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_4_i16 (gfc_array_i4 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_4 result; *************** minloc1_4_i16 (gfc_array_i4 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_4_i16 (gfc_array_i4 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { minloc1_4_i16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_4_i16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_4_i2.c gcc-4.3.1/libgfortran/generated/minloc1_4_i2.c *** gcc-4.3.0/libgfortran/generated/minloc1_4_i2.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_4_i2.c Tue May 6 20:46:41 2008 *************** minloc1_4_i2 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_4_i2 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_4 result; *************** minloc1_4_i2 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_4_i2 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { minloc1_4_i2 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_4_i2 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_4_i4.c gcc-4.3.1/libgfortran/generated/minloc1_4_i4.c *** gcc-4.3.0/libgfortran/generated/minloc1_4_i4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_4_i4.c Tue May 6 20:46:41 2008 *************** minloc1_4_i4 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_4_i4 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; *************** minloc1_4_i4 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_4_i4 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { minloc1_4_i4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_4_i4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_4_i8.c gcc-4.3.1/libgfortran/generated/minloc1_4_i8.c *** gcc-4.3.0/libgfortran/generated/minloc1_4_i8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_4_i8.c Tue May 6 20:46:41 2008 *************** minloc1_4_i8 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_4_i8 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_4 result; *************** minloc1_4_i8 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_4_i8 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { minloc1_4_i8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_4_i8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_4_r10.c gcc-4.3.1/libgfortran/generated/minloc1_4_r10.c *** gcc-4.3.0/libgfortran/generated/minloc1_4_r10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_4_r10.c Tue May 6 20:46:41 2008 *************** minloc1_4_r10 (gfc_array_i4 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_4_r10 (gfc_array_i4 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_10 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_10 * restrict src; GFC_INTEGER_4 result; *************** minloc1_4_r10 (gfc_array_i4 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_4_r10 (gfc_array_i4 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { minloc1_4_r10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_4_r10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_4_r16.c gcc-4.3.1/libgfortran/generated/minloc1_4_r16.c *** gcc-4.3.0/libgfortran/generated/minloc1_4_r16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_4_r16.c Tue May 6 20:46:41 2008 *************** minloc1_4_r16 (gfc_array_i4 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_4_r16 (gfc_array_i4 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_16 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_16 * restrict src; GFC_INTEGER_4 result; *************** minloc1_4_r16 (gfc_array_i4 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_4_r16 (gfc_array_i4 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { minloc1_4_r16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_4_r16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_4_r4.c gcc-4.3.1/libgfortran/generated/minloc1_4_r4.c *** gcc-4.3.0/libgfortran/generated/minloc1_4_r4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_4_r4.c Tue May 6 20:46:41 2008 *************** minloc1_4_r4 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_4_r4 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_4 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_4 * restrict src; GFC_INTEGER_4 result; *************** minloc1_4_r4 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_4_r4 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { minloc1_4_r4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_4_r4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_4_r8.c gcc-4.3.1/libgfortran/generated/minloc1_4_r8.c *** gcc-4.3.0/libgfortran/generated/minloc1_4_r8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_4_r8.c Tue May 6 20:46:41 2008 *************** minloc1_4_r8 (gfc_array_i4 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_4_r8 (gfc_array_i4 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_8 * restrict src; GFC_INTEGER_4 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_8 * restrict src; GFC_INTEGER_4 result; *************** minloc1_4_r8 (gfc_array_i4 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_4_r8 (gfc_array_i4 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { minloc1_4_r8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_4_r8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_8_i1.c gcc-4.3.1/libgfortran/generated/minloc1_8_i1.c *** gcc-4.3.0/libgfortran/generated/minloc1_8_i1.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_8_i1.c Tue May 6 20:46:41 2008 *************** minloc1_8_i1 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_8_i1 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_8 result; *************** minloc1_8_i1 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_8_i1 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { minloc1_8_i1 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_8_i1 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_8_i16.c gcc-4.3.1/libgfortran/generated/minloc1_8_i16.c *** gcc-4.3.0/libgfortran/generated/minloc1_8_i16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_8_i16.c Tue May 6 20:46:41 2008 *************** minloc1_8_i16 (gfc_array_i8 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_8_i16 (gfc_array_i8 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_8 result; *************** minloc1_8_i16 (gfc_array_i8 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_8_i16 (gfc_array_i8 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { minloc1_8_i16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_8_i16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_8_i2.c gcc-4.3.1/libgfortran/generated/minloc1_8_i2.c *** gcc-4.3.0/libgfortran/generated/minloc1_8_i2.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_8_i2.c Tue May 6 20:46:41 2008 *************** minloc1_8_i2 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_8_i2 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_8 result; *************** minloc1_8_i2 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_8_i2 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { minloc1_8_i2 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_8_i2 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_8_i4.c gcc-4.3.1/libgfortran/generated/minloc1_8_i4.c *** gcc-4.3.0/libgfortran/generated/minloc1_8_i4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_8_i4.c Tue May 6 20:46:41 2008 *************** minloc1_8_i4 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_8_i4 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_8 result; *************** minloc1_8_i4 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_8_i4 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { minloc1_8_i4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_8_i4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_8_i8.c gcc-4.3.1/libgfortran/generated/minloc1_8_i8.c *** gcc-4.3.0/libgfortran/generated/minloc1_8_i8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_8_i8.c Tue May 6 20:46:41 2008 *************** minloc1_8_i8 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_8_i8 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; *************** minloc1_8_i8 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_8_i8 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { minloc1_8_i8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_8_i8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_8_r10.c gcc-4.3.1/libgfortran/generated/minloc1_8_r10.c *** gcc-4.3.0/libgfortran/generated/minloc1_8_r10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_8_r10.c Tue May 6 20:46:41 2008 *************** minloc1_8_r10 (gfc_array_i8 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_8_r10 (gfc_array_i8 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_10 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_10 * restrict src; GFC_INTEGER_8 result; *************** minloc1_8_r10 (gfc_array_i8 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_8_r10 (gfc_array_i8 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { minloc1_8_r10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_8_r10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_8_r16.c gcc-4.3.1/libgfortran/generated/minloc1_8_r16.c *** gcc-4.3.0/libgfortran/generated/minloc1_8_r16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_8_r16.c Tue May 6 20:46:41 2008 *************** minloc1_8_r16 (gfc_array_i8 * const rest *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_8_r16 (gfc_array_i8 * const rest *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_16 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_16 * restrict src; GFC_INTEGER_8 result; *************** minloc1_8_r16 (gfc_array_i8 * const rest *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_8_r16 (gfc_array_i8 * const res *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { minloc1_8_r16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_8_r16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_8_r4.c gcc-4.3.1/libgfortran/generated/minloc1_8_r4.c *** gcc-4.3.0/libgfortran/generated/minloc1_8_r4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_8_r4.c Tue May 6 20:46:41 2008 *************** minloc1_8_r4 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_8_r4 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_4 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_4 * restrict src; GFC_INTEGER_8 result; *************** minloc1_8_r4 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_8_r4 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { minloc1_8_r4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_8_r4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minloc1_8_r8.c gcc-4.3.1/libgfortran/generated/minloc1_8_r8.c *** gcc-4.3.0/libgfortran/generated/minloc1_8_r8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minloc1_8_r8.c Tue May 6 20:46:41 2008 *************** minloc1_8_r8 (gfc_array_i8 * const restr *** 57,68 **** --- 57,71 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minloc1_8_r8 (gfc_array_i8 * const restr *** 149,155 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_8 * restrict src; GFC_INTEGER_8 result; --- 152,159 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_8 * restrict src; GFC_INTEGER_8 result; *************** minloc1_8_r8 (gfc_array_i8 * const restr *** 193,200 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 197,204 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminloc1_8_r8 (gfc_array_i8 * const rest *** 428,478 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { minloc1_8_r8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINLOC intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 432,562 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minloc1_8_r8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINLOC intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINLOC intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minval_i1.c gcc-4.3.1/libgfortran/generated/minval_i1.c *** gcc-4.3.0/libgfortran/generated/minval_i1.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minval_i1.c Tue May 6 20:46:41 2008 *************** minval_i1 (gfc_array_i1 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minval_i1 (gfc_array_i1 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_1 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_1 result; *************** minval_i1 (gfc_array_i1 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminval_i1 (gfc_array_i1 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_1 *dest; if (*mask) { minval_i1 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_1) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = GFC_INTEGER_1_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_1 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minval_i1 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_1) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = GFC_INTEGER_1_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minval_i16.c gcc-4.3.1/libgfortran/generated/minval_i16.c *** gcc-4.3.0/libgfortran/generated/minval_i16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minval_i16.c Tue May 6 20:46:41 2008 *************** minval_i16 (gfc_array_i16 * const restri *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minval_i16 (gfc_array_i16 * const restri *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; *************** minval_i16 (gfc_array_i16 * const restri *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminval_i16 (gfc_array_i16 * const restr *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { minval_i16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = GFC_INTEGER_16_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minval_i16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = GFC_INTEGER_16_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minval_i2.c gcc-4.3.1/libgfortran/generated/minval_i2.c *** gcc-4.3.0/libgfortran/generated/minval_i2.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minval_i2.c Tue May 6 20:46:41 2008 *************** minval_i2 (gfc_array_i2 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minval_i2 (gfc_array_i2 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_2 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_2 result; *************** minval_i2 (gfc_array_i2 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminval_i2 (gfc_array_i2 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_2 *dest; if (*mask) { minval_i2 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_2) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = GFC_INTEGER_2_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_2 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minval_i2 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_2) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = GFC_INTEGER_2_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minval_i4.c gcc-4.3.1/libgfortran/generated/minval_i4.c *** gcc-4.3.0/libgfortran/generated/minval_i4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minval_i4.c Tue May 6 20:46:41 2008 *************** minval_i4 (gfc_array_i4 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minval_i4 (gfc_array_i4 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; *************** minval_i4 (gfc_array_i4 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminval_i4 (gfc_array_i4 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { minval_i4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = GFC_INTEGER_4_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minval_i4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = GFC_INTEGER_4_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minval_i8.c gcc-4.3.1/libgfortran/generated/minval_i8.c *** gcc-4.3.0/libgfortran/generated/minval_i8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minval_i8.c Tue May 6 20:46:41 2008 *************** minval_i8 (gfc_array_i8 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minval_i8 (gfc_array_i8 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; *************** minval_i8 (gfc_array_i8 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminval_i8 (gfc_array_i8 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { minval_i8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = GFC_INTEGER_8_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minval_i8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = GFC_INTEGER_8_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minval_r10.c gcc-4.3.1/libgfortran/generated/minval_r10.c *** gcc-4.3.0/libgfortran/generated/minval_r10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minval_r10.c Tue May 6 20:46:41 2008 *************** minval_r10 (gfc_array_r10 * const restri *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minval_r10 (gfc_array_r10 * const restri *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_10 * restrict src; GFC_REAL_10 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_10 * restrict src; GFC_REAL_10 result; *************** minval_r10 (gfc_array_r10 * const restri *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminval_r10 (gfc_array_r10 * const restr *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_10 *dest; if (*mask) { minval_r10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_10) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = GFC_REAL_10_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_10 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minval_r10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_10) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = GFC_REAL_10_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minval_r16.c gcc-4.3.1/libgfortran/generated/minval_r16.c *** gcc-4.3.0/libgfortran/generated/minval_r16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minval_r16.c Tue May 6 20:46:41 2008 *************** minval_r16 (gfc_array_r16 * const restri *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minval_r16 (gfc_array_r16 * const restri *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_16 * restrict src; GFC_REAL_16 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_16 * restrict src; GFC_REAL_16 result; *************** minval_r16 (gfc_array_r16 * const restri *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminval_r16 (gfc_array_r16 * const restr *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_16 *dest; if (*mask) { minval_r16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = GFC_REAL_16_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minval_r16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = GFC_REAL_16_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minval_r4.c gcc-4.3.1/libgfortran/generated/minval_r4.c *** gcc-4.3.0/libgfortran/generated/minval_r4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minval_r4.c Tue May 6 20:46:41 2008 *************** minval_r4 (gfc_array_r4 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minval_r4 (gfc_array_r4 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_4 * restrict src; GFC_REAL_4 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_4 * restrict src; GFC_REAL_4 result; *************** minval_r4 (gfc_array_r4 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminval_r4 (gfc_array_r4 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_4 *dest; if (*mask) { minval_r4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = GFC_REAL_4_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minval_r4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = GFC_REAL_4_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/minval_r8.c gcc-4.3.1/libgfortran/generated/minval_r8.c *** gcc-4.3.0/libgfortran/generated/minval_r8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/minval_r8.c Tue May 6 20:46:41 2008 *************** minval_r8 (gfc_array_r8 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** minval_r8 (gfc_array_r8 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_8 * restrict src; GFC_REAL_8 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_8 * restrict src; GFC_REAL_8 result; *************** minval_r8 (gfc_array_r8 * const restrict *** 187,194 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 191,198 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sminval_r8 (gfc_array_r8 * const restric *** 417,467 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_8 *dest; if (*mask) { minval_r8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in MINVAL intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = GFC_REAL_8_HUGE ; } #endif --- 421,551 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { minval_r8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " MINVAL intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " MINVAL intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = GFC_REAL_8_HUGE; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_c10.c gcc-4.3.1/libgfortran/generated/product_c10.c *** gcc-4.3.0/libgfortran/generated/product_c10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_c10.c Tue May 6 20:46:41 2008 *************** product_c10 (gfc_array_c10 * const restr *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_c10 (gfc_array_c10 * const restr *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_COMPLEX_10 * restrict src; GFC_COMPLEX_10 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_COMPLEX_10 * restrict src; GFC_COMPLEX_10 result; *************** product_c10 (gfc_array_c10 * const restr *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_c10 (gfc_array_c10 * const rest *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_COMPLEX_10 *dest; if (*mask) { product_c10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_COMPLEX_10) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_COMPLEX_10 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_c10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_COMPLEX_10) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_c16.c gcc-4.3.1/libgfortran/generated/product_c16.c *** gcc-4.3.0/libgfortran/generated/product_c16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_c16.c Tue May 6 20:46:41 2008 *************** product_c16 (gfc_array_c16 * const restr *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_c16 (gfc_array_c16 * const restr *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_COMPLEX_16 * restrict src; GFC_COMPLEX_16 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_COMPLEX_16 * restrict src; GFC_COMPLEX_16 result; *************** product_c16 (gfc_array_c16 * const restr *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_c16 (gfc_array_c16 * const rest *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_COMPLEX_16 *dest; if (*mask) { product_c16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_COMPLEX_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_COMPLEX_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_c16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_COMPLEX_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_c4.c gcc-4.3.1/libgfortran/generated/product_c4.c *** gcc-4.3.0/libgfortran/generated/product_c4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_c4.c Tue May 6 20:46:41 2008 *************** product_c4 (gfc_array_c4 * const restric *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_c4 (gfc_array_c4 * const restric *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_COMPLEX_4 * restrict src; GFC_COMPLEX_4 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_COMPLEX_4 * restrict src; GFC_COMPLEX_4 result; *************** product_c4 (gfc_array_c4 * const restric *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_c4 (gfc_array_c4 * const restri *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_COMPLEX_4 *dest; if (*mask) { product_c4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_COMPLEX_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_COMPLEX_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_c4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_COMPLEX_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_c8.c gcc-4.3.1/libgfortran/generated/product_c8.c *** gcc-4.3.0/libgfortran/generated/product_c8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_c8.c Tue May 6 20:46:41 2008 *************** product_c8 (gfc_array_c8 * const restric *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_c8 (gfc_array_c8 * const restric *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_COMPLEX_8 * restrict src; GFC_COMPLEX_8 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_COMPLEX_8 * restrict src; GFC_COMPLEX_8 result; *************** product_c8 (gfc_array_c8 * const restric *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_c8 (gfc_array_c8 * const restri *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_COMPLEX_8 *dest; if (*mask) { product_c8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_COMPLEX_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_COMPLEX_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_c8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_COMPLEX_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_i1.c gcc-4.3.1/libgfortran/generated/product_i1.c *** gcc-4.3.0/libgfortran/generated/product_i1.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_i1.c Tue May 6 20:46:41 2008 *************** product_i1 (gfc_array_i1 * const restric *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_i1 (gfc_array_i1 * const restric *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_1 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_1 result; *************** product_i1 (gfc_array_i1 * const restric *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_i1 (gfc_array_i1 * const restri *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_1 *dest; if (*mask) { product_i1 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_1) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_1 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_i1 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_1) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_i16.c gcc-4.3.1/libgfortran/generated/product_i16.c *** gcc-4.3.0/libgfortran/generated/product_i16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_i16.c Tue May 6 20:46:41 2008 *************** product_i16 (gfc_array_i16 * const restr *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_i16 (gfc_array_i16 * const restr *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; *************** product_i16 (gfc_array_i16 * const restr *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_i16 (gfc_array_i16 * const rest *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { product_i16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_i16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_i2.c gcc-4.3.1/libgfortran/generated/product_i2.c *** gcc-4.3.0/libgfortran/generated/product_i2.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_i2.c Tue May 6 20:46:41 2008 *************** product_i2 (gfc_array_i2 * const restric *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_i2 (gfc_array_i2 * const restric *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_2 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_2 result; *************** product_i2 (gfc_array_i2 * const restric *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_i2 (gfc_array_i2 * const restri *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_2 *dest; if (*mask) { product_i2 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_2) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_2 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_i2 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_2) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_i4.c gcc-4.3.1/libgfortran/generated/product_i4.c *** gcc-4.3.0/libgfortran/generated/product_i4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_i4.c Tue May 6 20:46:41 2008 *************** product_i4 (gfc_array_i4 * const restric *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_i4 (gfc_array_i4 * const restric *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; *************** product_i4 (gfc_array_i4 * const restric *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_i4 (gfc_array_i4 * const restri *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { product_i4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_i4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_i8.c gcc-4.3.1/libgfortran/generated/product_i8.c *** gcc-4.3.0/libgfortran/generated/product_i8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_i8.c Tue May 6 20:46:41 2008 *************** product_i8 (gfc_array_i8 * const restric *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_i8 (gfc_array_i8 * const restric *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; *************** product_i8 (gfc_array_i8 * const restric *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_i8 (gfc_array_i8 * const restri *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { product_i8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_i8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_r10.c gcc-4.3.1/libgfortran/generated/product_r10.c *** gcc-4.3.0/libgfortran/generated/product_r10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_r10.c Tue May 6 20:46:41 2008 *************** product_r10 (gfc_array_r10 * const restr *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_r10 (gfc_array_r10 * const restr *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_10 * restrict src; GFC_REAL_10 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_10 * restrict src; GFC_REAL_10 result; *************** product_r10 (gfc_array_r10 * const restr *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_r10 (gfc_array_r10 * const rest *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_10 *dest; if (*mask) { product_r10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_10) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_10 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_r10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_10) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_r16.c gcc-4.3.1/libgfortran/generated/product_r16.c *** gcc-4.3.0/libgfortran/generated/product_r16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_r16.c Tue May 6 20:46:41 2008 *************** product_r16 (gfc_array_r16 * const restr *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_r16 (gfc_array_r16 * const restr *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_16 * restrict src; GFC_REAL_16 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_16 * restrict src; GFC_REAL_16 result; *************** product_r16 (gfc_array_r16 * const restr *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_r16 (gfc_array_r16 * const rest *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_16 *dest; if (*mask) { product_r16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_r16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_r4.c gcc-4.3.1/libgfortran/generated/product_r4.c *** gcc-4.3.0/libgfortran/generated/product_r4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_r4.c Tue May 6 20:46:41 2008 *************** product_r4 (gfc_array_r4 * const restric *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_r4 (gfc_array_r4 * const restric *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_4 * restrict src; GFC_REAL_4 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_4 * restrict src; GFC_REAL_4 result; *************** product_r4 (gfc_array_r4 * const restric *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_r4 (gfc_array_r4 * const restri *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_4 *dest; if (*mask) { product_r4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_r4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/product_r8.c gcc-4.3.1/libgfortran/generated/product_r8.c *** gcc-4.3.0/libgfortran/generated/product_r8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/product_r8.c Tue May 6 20:46:41 2008 *************** product_r8 (gfc_array_r8 * const restric *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** product_r8 (gfc_array_r8 * const restric *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_8 * restrict src; GFC_REAL_8 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_8 * restrict src; GFC_REAL_8 result; *************** product_r8 (gfc_array_r8 * const restric *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** sproduct_r8 (gfc_array_r8 * const restri *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_8 *dest; if (*mask) { product_r8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in PRODUCT intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 1 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { product_r8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " PRODUCT intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " PRODUCT intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 1; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_c10.c gcc-4.3.1/libgfortran/generated/sum_c10.c *** gcc-4.3.0/libgfortran/generated/sum_c10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_c10.c Tue May 6 20:46:41 2008 *************** sum_c10 (gfc_array_c10 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_c10 (gfc_array_c10 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_COMPLEX_10 * restrict src; GFC_COMPLEX_10 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_COMPLEX_10 * restrict src; GFC_COMPLEX_10 result; *************** sum_c10 (gfc_array_c10 * const restrict *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_c10 (gfc_array_c10 * const restrict *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_COMPLEX_10 *dest; if (*mask) { sum_c10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_COMPLEX_10) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_COMPLEX_10 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_c10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_COMPLEX_10) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_c16.c gcc-4.3.1/libgfortran/generated/sum_c16.c *** gcc-4.3.0/libgfortran/generated/sum_c16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_c16.c Tue May 6 20:46:41 2008 *************** sum_c16 (gfc_array_c16 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_c16 (gfc_array_c16 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_COMPLEX_16 * restrict src; GFC_COMPLEX_16 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_COMPLEX_16 * restrict src; GFC_COMPLEX_16 result; *************** sum_c16 (gfc_array_c16 * const restrict *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_c16 (gfc_array_c16 * const restrict *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_COMPLEX_16 *dest; if (*mask) { sum_c16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_COMPLEX_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_COMPLEX_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_c16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_COMPLEX_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_c4.c gcc-4.3.1/libgfortran/generated/sum_c4.c *** gcc-4.3.0/libgfortran/generated/sum_c4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_c4.c Tue May 6 20:46:41 2008 *************** sum_c4 (gfc_array_c4 * const restrict re *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_c4 (gfc_array_c4 * const restrict re *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_COMPLEX_4 * restrict src; GFC_COMPLEX_4 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_COMPLEX_4 * restrict src; GFC_COMPLEX_4 result; *************** sum_c4 (gfc_array_c4 * const restrict re *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_c4 (gfc_array_c4 * const restrict r *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_COMPLEX_4 *dest; if (*mask) { sum_c4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_COMPLEX_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_COMPLEX_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_c4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_COMPLEX_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_c8.c gcc-4.3.1/libgfortran/generated/sum_c8.c *** gcc-4.3.0/libgfortran/generated/sum_c8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_c8.c Tue May 6 20:46:41 2008 *************** sum_c8 (gfc_array_c8 * const restrict re *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_c8 (gfc_array_c8 * const restrict re *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_COMPLEX_8 * restrict src; GFC_COMPLEX_8 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_COMPLEX_8 * restrict src; GFC_COMPLEX_8 result; *************** sum_c8 (gfc_array_c8 * const restrict re *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_c8 (gfc_array_c8 * const restrict r *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_COMPLEX_8 *dest; if (*mask) { sum_c8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_COMPLEX_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_COMPLEX_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_c8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_COMPLEX_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_i1.c gcc-4.3.1/libgfortran/generated/sum_i1.c *** gcc-4.3.0/libgfortran/generated/sum_i1.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_i1.c Tue May 6 20:46:41 2008 *************** sum_i1 (gfc_array_i1 * const restrict re *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_i1 (gfc_array_i1 * const restrict re *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_1 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_1 * restrict src; GFC_INTEGER_1 result; *************** sum_i1 (gfc_array_i1 * const restrict re *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_i1 (gfc_array_i1 * const restrict r *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_1 *dest; if (*mask) { sum_i1 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_1) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_1 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_i1 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_1) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_i16.c gcc-4.3.1/libgfortran/generated/sum_i16.c *** gcc-4.3.0/libgfortran/generated/sum_i16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_i16.c Tue May 6 20:46:41 2008 *************** sum_i16 (gfc_array_i16 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_i16 (gfc_array_i16 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_16 * restrict src; GFC_INTEGER_16 result; *************** sum_i16 (gfc_array_i16 * const restrict *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_i16 (gfc_array_i16 * const restrict *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_16 *dest; if (*mask) { sum_i16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_i16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_i2.c gcc-4.3.1/libgfortran/generated/sum_i2.c *** gcc-4.3.0/libgfortran/generated/sum_i2.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_i2.c Tue May 6 20:46:41 2008 *************** sum_i2 (gfc_array_i2 * const restrict re *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_i2 (gfc_array_i2 * const restrict re *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_2 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_2 * restrict src; GFC_INTEGER_2 result; *************** sum_i2 (gfc_array_i2 * const restrict re *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_i2 (gfc_array_i2 * const restrict r *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_2 *dest; if (*mask) { sum_i2 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_2) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_2 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_i2 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_2) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_i4.c gcc-4.3.1/libgfortran/generated/sum_i4.c *** gcc-4.3.0/libgfortran/generated/sum_i4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_i4.c Tue May 6 20:46:41 2008 *************** sum_i4 (gfc_array_i4 * const restrict re *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_i4 (gfc_array_i4 * const restrict re *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_4 * restrict src; GFC_INTEGER_4 result; *************** sum_i4 (gfc_array_i4 * const restrict re *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_i4 (gfc_array_i4 * const restrict r *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_4 *dest; if (*mask) { sum_i4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_i4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_i8.c gcc-4.3.1/libgfortran/generated/sum_i8.c *** gcc-4.3.0/libgfortran/generated/sum_i8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_i8.c Tue May 6 20:46:41 2008 *************** sum_i8 (gfc_array_i8 * const restrict re *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_i8 (gfc_array_i8 * const restrict re *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_INTEGER_8 * restrict src; GFC_INTEGER_8 result; *************** sum_i8 (gfc_array_i8 * const restrict re *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_i8 (gfc_array_i8 * const restrict r *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_INTEGER_8 *dest; if (*mask) { sum_i8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_INTEGER_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_i8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_INTEGER_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_r10.c gcc-4.3.1/libgfortran/generated/sum_r10.c *** gcc-4.3.0/libgfortran/generated/sum_r10.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_r10.c Tue May 6 20:46:41 2008 *************** sum_r10 (gfc_array_r10 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_r10 (gfc_array_r10 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_10 * restrict src; GFC_REAL_10 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_10 * restrict src; GFC_REAL_10 result; *************** sum_r10 (gfc_array_r10 * const restrict *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_r10 (gfc_array_r10 * const restrict *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_10 *dest; if (*mask) { sum_r10 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_10) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_10 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_r10 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_10) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_r16.c gcc-4.3.1/libgfortran/generated/sum_r16.c *** gcc-4.3.0/libgfortran/generated/sum_r16.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_r16.c Tue May 6 20:46:41 2008 *************** sum_r16 (gfc_array_r16 * const restrict *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_r16 (gfc_array_r16 * const restrict *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_16 * restrict src; GFC_REAL_16 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_16 * restrict src; GFC_REAL_16 result; *************** sum_r16 (gfc_array_r16 * const restrict *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_r16 (gfc_array_r16 * const restrict *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_16 *dest; if (*mask) { sum_r16 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_16) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_16 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_r16 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_16) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_r4.c gcc-4.3.1/libgfortran/generated/sum_r4.c *** gcc-4.3.0/libgfortran/generated/sum_r4.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_r4.c Tue May 6 20:46:41 2008 *************** sum_r4 (gfc_array_r4 * const restrict re *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_r4 (gfc_array_r4 * const restrict re *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_4 * restrict src; GFC_REAL_4 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_4 * restrict src; GFC_REAL_4 result; *************** sum_r4 (gfc_array_r4 * const restrict re *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_r4 (gfc_array_r4 * const restrict r *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_4 *dest; if (*mask) { sum_r4 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_4) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_4 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_r4 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_4) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/generated/sum_r8.c gcc-4.3.1/libgfortran/generated/sum_r8.c *** gcc-4.3.0/libgfortran/generated/sum_r8.c Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/generated/sum_r8.c Tue May 6 20:46:41 2008 *************** sum_r8 (gfc_array_r8 * const restrict re *** 56,67 **** --- 56,70 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** sum_r8 (gfc_array_r8 * const restrict re *** 148,154 **** base = array->data; dest = retarray->data; ! while (base) { const GFC_REAL_8 * restrict src; GFC_REAL_8 result; --- 151,158 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_REAL_8 * restrict src; GFC_REAL_8 result; *************** sum_r8 (gfc_array_r8 * const restrict re *** 186,193 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 190,197 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** ssum_r8 (gfc_array_r8 * const restrict r *** 416,466 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! GFC_REAL_8 *dest; if (*mask) { sum_r8 (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (GFC_REAL_8) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in SUM intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = 0 ; } #endif --- 420,550 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + GFC_REAL_8 * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { sum_r8 (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (GFC_REAL_8) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " SUM intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " SUM intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = 0; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } } #endif diff -Nrcpad gcc-4.3.0/libgfortran/intrinsics/pack_generic.c gcc-4.3.1/libgfortran/intrinsics/pack_generic.c *** gcc-4.3.0/libgfortran/intrinsics/pack_generic.c Thu Dec 27 15:00:10 2007 --- gcc-4.3.1/libgfortran/intrinsics/pack_generic.c Tue May 6 20:46:41 2008 *************** pack_s_internal (gfc_array_char *ret, co *** 350,355 **** --- 350,356 ---- index_type dim; index_type ssize; index_type nelem; + index_type total; dim = GFC_DESCRIPTOR_RANK (array); ssize = 1; *************** pack_s_internal (gfc_array_char *ret, co *** 357,362 **** --- 358,366 ---- { count[n] = 0; extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; + if (extent[n] < 0) + extent[n] = 0; + sstride[n] = array->dim[n].stride * size; ssize *= extent[n]; } *************** pack_s_internal (gfc_array_char *ret, co *** 364,381 **** sstride[0] = size; sstride0 = sstride[0]; ! sptr = array->data; if (ret->data == NULL) { /* Allocate the memory for the result. */ - int total; if (vector != NULL) { /* The return array will have as many elements as there are in vector. */ total = vector->dim[0].ubound + 1 - vector->dim[0].lbound; } else { --- 368,393 ---- sstride[0] = size; sstride0 = sstride[0]; ! ! if (ssize != 0) ! sptr = array->data; ! else ! sptr = NULL; if (ret->data == NULL) { /* Allocate the memory for the result. */ if (vector != NULL) { /* The return array will have as many elements as there are in vector. */ total = vector->dim[0].ubound + 1 - vector->dim[0].lbound; + if (total <= 0) + { + total = 0; + vector = NULL; + } } else { diff -Nrcpad gcc-4.3.0/libgfortran/io/list_read.c gcc-4.3.1/libgfortran/io/list_read.c *** gcc-4.3.0/libgfortran/io/list_read.c Sat Jan 5 16:00:40 2008 --- gcc-4.3.1/libgfortran/io/list_read.c Wed Apr 9 09:03:34 2008 *************** Boston, MA 02110-1301, USA. */ *** 63,68 **** --- 63,72 ---- #define MAX_REPEAT 200000000 + #ifndef HAVE_SNPRINTF + # undef snprintf + # define snprintf(str, size, ...) sprintf (str, __VA_ARGS__) + #endif /* Save a character to a string buffer, enlarging it as necessary. */ *************** free_saved (st_parameter_dt *dtp) *** 120,125 **** --- 124,132 ---- static void free_line (st_parameter_dt *dtp) { + dtp->u.p.item_count = 0; + dtp->u.p.line_buffer_enabled = 0; + if (dtp->u.p.line_buffer == NULL) return; *************** next_char (st_parameter_dt *dtp) *** 157,164 **** goto done; } ! dtp->u.p.item_count = 0; ! dtp->u.p.line_buffer_enabled = 0; } /* Handle the end-of-record and end-of-file conditions for --- 164,171 ---- goto done; } ! dtp->u.p.item_count = 0; ! dtp->u.p.line_buffer_enabled = 0; } /* Handle the end-of-record and end-of-file conditions for *************** eat_separator (st_parameter_dt *dtp) *** 356,361 **** --- 363,373 ---- { eat_line (dtp); c = next_char (dtp); + if (c == '!') + { + eat_line (dtp); + c = next_char (dtp); + } } } while (c == '\n' || c == '\r' || c == ' '); *************** read_logical (st_parameter_dt *dtp, int *** 680,685 **** --- 692,700 ---- return; /* Null value. */ default: + /* Save the character in case it is the beginning + of the next object name. */ + unget_char (dtp, c); goto bad_logical; } *************** read_logical (st_parameter_dt *dtp, int *** 695,702 **** unget_char (dtp, c); eat_separator (dtp); - dtp->u.p.item_count = 0; - dtp->u.p.line_buffer_enabled = 0; set_integer ((int *) dtp->u.p.value, v, length); free_line (dtp); --- 710,715 ---- *************** read_logical (st_parameter_dt *dtp, int *** 750,757 **** logical_done: - dtp->u.p.item_count = 0; - dtp->u.p.line_buffer_enabled = 0; dtp->u.p.saved_type = BT_LOGICAL; dtp->u.p.saved_length = length; set_integer ((int *) dtp->u.p.value, v, length); --- 763,768 ---- *************** read_real (st_parameter_dt *dtp, int len *** 1635,1642 **** push_char (dtp, 'n'); } - dtp->u.p.item_count = 0; - dtp->u.p.line_buffer_enabled = 0; free_line (dtp); goto done; --- 1646,1651 ---- *************** calls: *** 1882,1888 **** static void nml_match_name (char *name, int len) static int nml_query (st_parameter_dt *dtp) static int nml_get_obj_data (st_parameter_dt *dtp, ! namelist_info **prev_nl, char *) calls: static void nml_untouch_nodes (st_parameter_dt *dtp) static namelist_info * find_nml_node (st_parameter_dt *dtp, --- 1891,1897 ---- static void nml_match_name (char *name, int len) static int nml_query (st_parameter_dt *dtp) static int nml_get_obj_data (st_parameter_dt *dtp, ! namelist_info **prev_nl, char *, size_t) calls: static void nml_untouch_nodes (st_parameter_dt *dtp) static namelist_info * find_nml_node (st_parameter_dt *dtp, *************** calls: *** 1891,1897 **** array_loop_spec * ls, int rank, char *) static void nml_touch_nodes (namelist_info * nl) static int nml_read_obj (namelist_info *nl, index_type offset, ! namelist_info **prev_nl, char *, index_type clow, index_type chigh) calls: -itself- */ --- 1900,1906 ---- array_loop_spec * ls, int rank, char *) static void nml_touch_nodes (namelist_info * nl) static int nml_read_obj (namelist_info *nl, index_type offset, ! namelist_info **prev_nl, char *, size_t, index_type clow, index_type chigh) calls: -itself- */ *************** query_return: *** 2305,2311 **** static try nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset, namelist_info **pprev_nl, char *nml_err_msg, ! index_type clow, index_type chigh) { namelist_info * cmp; char * obj_name; --- 2314,2320 ---- static try nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset, namelist_info **pprev_nl, char *nml_err_msg, ! size_t nml_err_msg_size, index_type clow, index_type chigh) { namelist_info * cmp; char * obj_name; *************** nml_read_obj (st_parameter_dt *dtp, name *** 2423,2430 **** { if (nml_read_obj (dtp, cmp, (index_type)(pdata - nl->mem_pos), ! pprev_nl, nml_err_msg, clow, chigh) ! == FAILURE) { free_mem (obj_name); return FAILURE; --- 2432,2439 ---- { if (nml_read_obj (dtp, cmp, (index_type)(pdata - nl->mem_pos), ! pprev_nl, nml_err_msg, nml_err_msg_size, ! clow, chigh) == FAILURE) { free_mem (obj_name); return FAILURE; *************** nml_read_obj (st_parameter_dt *dtp, name *** 2441,2448 **** goto incr_idx; default: ! sprintf (nml_err_msg, "Bad type for namelist object %s", ! nl->var_name); internal_error (&dtp->common, nml_err_msg); goto nml_err_ret; } --- 2450,2457 ---- goto incr_idx; default: ! snprintf (nml_err_msg, nml_err_msg_size, ! "Bad type for namelist object %s", nl->var_name); internal_error (&dtp->common, nml_err_msg); goto nml_err_ret; } *************** incr_idx: *** 2530,2538 **** if (dtp->u.p.repeat_count > 1) { ! sprintf (nml_err_msg, "Repeat count too large for namelist object %s" , ! nl->var_name ); ! goto nml_err_ret; } return SUCCESS; --- 2539,2547 ---- if (dtp->u.p.repeat_count > 1) { ! snprintf (nml_err_msg, nml_err_msg_size, ! "Repeat count too large for namelist object %s", nl->var_name); ! goto nml_err_ret; } return SUCCESS; *************** nml_err_ret: *** 2550,2556 **** static try nml_get_obj_data (st_parameter_dt *dtp, namelist_info **pprev_nl, ! char *nml_err_msg) { char c; namelist_info * nl; --- 2559,2565 ---- static try nml_get_obj_data (st_parameter_dt *dtp, namelist_info **pprev_nl, ! char *nml_err_msg, size_t nml_err_msg_size) { char c; namelist_info * nl; *************** nml_get_obj_data (st_parameter_dt *dtp, *** 2558,2564 **** namelist_info * root_nl = NULL; int dim, parsed_rank; int component_flag; - char parse_err_msg[30]; index_type clow, chigh; int non_zero_rank_count; --- 2567,2572 ---- *************** get_name: *** 2657,2668 **** if (nl == NULL) { if (dtp->u.p.nml_read_error && *pprev_nl) ! sprintf (nml_err_msg, "Bad data for namelist object %s", ! (*pprev_nl)->var_name); else ! sprintf (nml_err_msg, "Cannot match namelist object name %s", ! dtp->u.p.saved_string); goto nml_err_ret; } --- 2665,2677 ---- if (nl == NULL) { if (dtp->u.p.nml_read_error && *pprev_nl) ! snprintf (nml_err_msg, nml_err_msg_size, ! "Bad data for namelist object %s", (*pprev_nl)->var_name); else ! snprintf (nml_err_msg, nml_err_msg_size, ! "Cannot match namelist object name %s", ! dtp->u.p.saved_string); goto nml_err_ret; } *************** get_name: *** 2684,2693 **** { parsed_rank = 0; if (nml_parse_qualifier (dtp, nl->dim, nl->ls, nl->var_rank, ! parse_err_msg, &parsed_rank) == FAILURE) { ! sprintf (nml_err_msg, "%s for namelist variable %s", ! parse_err_msg, nl->var_name); goto nml_err_ret; } --- 2693,2704 ---- { parsed_rank = 0; if (nml_parse_qualifier (dtp, nl->dim, nl->ls, nl->var_rank, ! nml_err_msg, &parsed_rank) == FAILURE) { ! char *nml_err_msg_end = strchr (nml_err_msg, '\0'); ! snprintf (nml_err_msg_end, ! nml_err_msg_size - (nml_err_msg_end - nml_err_msg), ! " for namelist variable %s", nl->var_name); goto nml_err_ret; } *************** get_name: *** 2708,2715 **** { if (nl->type != GFC_DTYPE_DERIVED) { ! sprintf (nml_err_msg, "Attempt to get derived component for %s", ! nl->var_name); goto nml_err_ret; } --- 2719,2726 ---- { if (nl->type != GFC_DTYPE_DERIVED) { ! snprintf (nml_err_msg, nml_err_msg_size, ! "Attempt to get derived component for %s", nl->var_name); goto nml_err_ret; } *************** get_name: *** 2733,2743 **** descriptor_dimension chd[1] = { {1, clow, nl->string_length} }; array_loop_spec ind[1] = { {1, clow, nl->string_length, 1} }; ! if (nml_parse_qualifier (dtp, chd, ind, -1, parse_err_msg, &parsed_rank) == FAILURE) { ! sprintf (nml_err_msg, "%s for namelist variable %s", ! parse_err_msg, nl->var_name); goto nml_err_ret; } --- 2744,2756 ---- descriptor_dimension chd[1] = { {1, clow, nl->string_length} }; array_loop_spec ind[1] = { {1, clow, nl->string_length, 1} }; ! if (nml_parse_qualifier (dtp, chd, ind, -1, nml_err_msg, &parsed_rank) == FAILURE) { ! char *nml_err_msg_end = strchr (nml_err_msg, '\0'); ! snprintf (nml_err_msg_end, ! nml_err_msg_size - (nml_err_msg_end - nml_err_msg), ! " for namelist variable %s", nl->var_name); goto nml_err_ret; } *************** get_name: *** 2746,2754 **** if (ind[0].step != 1) { ! sprintf (nml_err_msg, ! "Step not allowed in substring qualifier" ! " for namelist object %s", nl->var_name); goto nml_err_ret; } --- 2759,2767 ---- if (ind[0].step != 1) { ! snprintf (nml_err_msg, nml_err_msg_size, ! "Step not allowed in substring qualifier" ! " for namelist object %s", nl->var_name); goto nml_err_ret; } *************** get_name: *** 2769,2784 **** if (c == '(') { ! sprintf (nml_err_msg, "Qualifier for a scalar or non-character" ! " namelist object %s", nl->var_name); goto nml_err_ret; } /* Make sure there is no more than one non-zero rank object. */ if (non_zero_rank_count > 1) { ! sprintf (nml_err_msg, "Multiple sub-objects with non-zero rank in" ! " namelist object %s", nl->var_name); non_zero_rank_count = 0; goto nml_err_ret; } --- 2782,2799 ---- if (c == '(') { ! snprintf (nml_err_msg, nml_err_msg_size, ! "Qualifier for a scalar or non-character namelist object %s", ! nl->var_name); goto nml_err_ret; } /* Make sure there is no more than one non-zero rank object. */ if (non_zero_rank_count > 1) { ! snprintf (nml_err_msg, nml_err_msg_size, ! "Multiple sub-objects with non-zero rank in namelist object %s", ! nl->var_name); non_zero_rank_count = 0; goto nml_err_ret; } *************** get_name: *** 2802,2813 **** if (c != '=') { ! sprintf (nml_err_msg, "Equal sign must follow namelist object name %s", ! nl->var_name); goto nml_err_ret; } ! if (nml_read_obj (dtp, nl, 0, pprev_nl, nml_err_msg, clow, chigh) == FAILURE) goto nml_err_ret; return SUCCESS; --- 2817,2830 ---- if (c != '=') { ! snprintf (nml_err_msg, nml_err_msg_size, ! "Equal sign must follow namelist object name %s", ! nl->var_name); goto nml_err_ret; } ! if (nml_read_obj (dtp, nl, 0, pprev_nl, nml_err_msg, nml_err_msg_size, ! clow, chigh) == FAILURE) goto nml_err_ret; return SUCCESS; *************** namelist_read (st_parameter_dt *dtp) *** 2826,2832 **** { char c; jmp_buf eof_jump; ! char nml_err_msg[100]; /* Pointer to the previously read object, in case attempt is made to read new object name. Should this fail, error message can give previous name. */ --- 2843,2849 ---- { char c; jmp_buf eof_jump; ! char nml_err_msg[200]; /* Pointer to the previously read object, in case attempt is made to read new object name. Should this fail, error message can give previous name. */ *************** find_nml_name: *** 2894,2900 **** while (!dtp->u.p.input_complete) { ! if (nml_get_obj_data (dtp, &prev_nl, nml_err_msg) == FAILURE) { gfc_unit *u; --- 2911,2918 ---- while (!dtp->u.p.input_complete) { ! if (nml_get_obj_data (dtp, &prev_nl, nml_err_msg, sizeof nml_err_msg) ! == FAILURE) { gfc_unit *u; diff -Nrcpad gcc-4.3.0/libgfortran/io/transfer.c gcc-4.3.1/libgfortran/io/transfer.c *** gcc-4.3.0/libgfortran/io/transfer.c Sat Jan 26 15:22:59 2008 --- gcc-4.3.1/libgfortran/io/transfer.c Fri Mar 28 23:23:34 2008 *************** write_buf (st_parameter_dt *dtp, void *b *** 639,650 **** } if (buf == NULL && nbytes == 0) ! { ! char *p; ! p = write_block (dtp, dtp->u.p.current_unit->recl); ! memset (p, 0, dtp->u.p.current_unit->recl); ! return SUCCESS; ! } if (swrite (dtp->u.p.current_unit->s, buf, &nbytes) != 0) { --- 639,645 ---- } if (buf == NULL && nbytes == 0) ! return SUCCESS; if (swrite (dtp->u.p.current_unit->s, buf, &nbytes) != 0) { *************** next_record_w (st_parameter_dt *dtp, int *** 2486,2491 **** --- 2481,2493 ---- break; case UNFORMATTED_DIRECT: + if (dtp->u.p.current_unit->bytes_left > 0) + { + length = (int) dtp->u.p.current_unit->bytes_left; + p = salloc_w (dtp->u.p.current_unit->s, &length); + memset (p, 0, length); + } + if (sfree (dtp->u.p.current_unit->s) == FAILURE) goto io_error; break; diff -Nrcpad gcc-4.3.0/libgfortran/m4/ifunction.m4 gcc-4.3.1/libgfortran/m4/ifunction.m4 *** gcc-4.3.0/libgfortran/m4/ifunction.m4 Sun Jan 13 22:13:52 2008 --- gcc-4.3.1/libgfortran/m4/ifunction.m4 Tue May 6 20:46:41 2008 *************** name`'rtype_qual`_'atype_code (rtype * c *** 39,50 **** --- 39,53 ---- index_type len; index_type delta; index_type dim; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; delta = array->dim[dim].stride; for (n = 0; n < dim; n++) *************** name`'rtype_qual`_'atype_code (rtype * c *** 131,137 **** base = array->data; dest = retarray->data; ! while (base) { const atype_name * restrict src; rtype_name result; --- 134,141 ---- base = array->data; dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const atype_name * restrict src; rtype_name result; *************** define(FINISH_ARRAY_FUNCTION, *** 169,176 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; ! break; } else { --- 173,180 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; ! break; } else { *************** void *** 398,448 **** const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { index_type rank; index_type n; ! index_type dstride; ! rtype_name *dest; if (*mask) { name`'rtype_qual`_'atype_code (retarray, array, pdim); return; } ! rank = GFC_DESCRIPTOR_RANK (array); ! if (rank <= 0) ! runtime_error ("Rank of array needs to be > 0"); if (retarray->data == NULL) { ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = rank-1; ! retarray->dim[0].stride = 1; ! retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; retarray->offset = 0; ! retarray->data = internal_malloc_size (sizeof (rtype_name) * rank); } else { if (compile_options.bounds_check) { ! int ret_rank; ! index_type ret_extent; ! ! ret_rank = GFC_DESCRIPTOR_RANK (retarray); ! if (ret_rank != 1) ! runtime_error ("rank of return array in u_name intrinsic" ! " should be 1, is %ld", (long int) ret_rank); ! ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound; ! if (ret_extent != rank) ! runtime_error ("dimension of return array incorrect"); } } - dstride = retarray->dim[0].stride; - dest = retarray->data; ! for (n = 0; n < rank; n++) ! dest[n * dstride] = $1 ; }')dnl define(ARRAY_FUNCTION, `START_ARRAY_FUNCTION --- 402,532 ---- const index_type * const restrict pdim, GFC_LOGICAL_4 * mask) { + index_type count[GFC_MAX_DIMENSIONS]; + index_type extent[GFC_MAX_DIMENSIONS]; + index_type sstride[GFC_MAX_DIMENSIONS]; + index_type dstride[GFC_MAX_DIMENSIONS]; + rtype_name * restrict dest; index_type rank; index_type n; ! index_type dim; ! if (*mask) { name`'rtype_qual`_'atype_code (retarray, array, pdim); return; } ! /* Make dim zero based to avoid confusion. */ ! dim = (*pdim) - 1; ! rank = GFC_DESCRIPTOR_RANK (array) - 1; ! ! for (n = 0; n < dim; n++) ! { ! sstride[n] = array->dim[n].stride; ! extent[n] = array->dim[n].ubound + 1 - array->dim[n].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } ! ! for (n = dim; n < rank; n++) ! { ! sstride[n] = array->dim[n + 1].stride; ! extent[n] = ! array->dim[n + 1].ubound + 1 - array->dim[n + 1].lbound; ! ! if (extent[n] <= 0) ! extent[n] = 0; ! } if (retarray->data == NULL) { ! size_t alloc_size; ! ! for (n = 0; n < rank; n++) ! { ! retarray->dim[n].lbound = 0; ! retarray->dim[n].ubound = extent[n]-1; ! if (n == 0) ! retarray->dim[n].stride = 1; ! else ! retarray->dim[n].stride = retarray->dim[n-1].stride * extent[n-1]; ! } ! retarray->offset = 0; ! retarray->dtype = (array->dtype & ~GFC_DTYPE_RANK_MASK) | rank; ! ! alloc_size = sizeof (rtype_name) * retarray->dim[rank-1].stride ! * extent[rank-1]; ! ! if (alloc_size == 0) ! { ! /* Make sure we have a zero-sized array. */ ! retarray->dim[0].lbound = 0; ! retarray->dim[0].ubound = -1; ! return; ! } ! else ! retarray->data = internal_malloc_size (alloc_size); } else { + if (rank != GFC_DESCRIPTOR_RANK (retarray)) + runtime_error ("rank of return array incorrect in" + " u_name intrinsic: is %ld, should be %ld", + (long int) (GFC_DESCRIPTOR_RANK (retarray)), + (long int) rank); + if (compile_options.bounds_check) { ! for (n=0; n < rank; n++) ! { ! index_type ret_extent; ! ret_extent = retarray->dim[n].ubound + 1 ! - retarray->dim[n].lbound; ! if (extent[n] != ret_extent) ! runtime_error ("Incorrect extent in return value of" ! " u_name intrinsic in dimension %ld:" ! " is %ld, should be %ld", (long int) n + 1, ! (long int) ret_extent, (long int) extent[n]); ! } } } ! for (n = 0; n < rank; n++) ! { ! count[n] = 0; ! dstride[n] = retarray->dim[n].stride; ! } ! ! dest = retarray->data; ! ! while(1) ! { ! *dest = '$1`; ! count[0]++; ! dest += dstride[0]; ! n = 0; ! while (count[n] == extent[n]) ! { ! /* When we get to the end of a dimension, reset it and increment ! the next dimension. */ ! count[n] = 0; ! /* We could precalculate these products, but this is a less ! frequently used path so probably not worth it. */ ! dest -= dstride[n] * extent[n]; ! n++; ! if (n == rank) ! return; ! else ! { ! count[n]++; ! dest += dstride[n]; ! } ! } ! } }')dnl define(ARRAY_FUNCTION, `START_ARRAY_FUNCTION diff -Nrcpad gcc-4.3.0/libgfortran/m4/ifunction_logical.m4 gcc-4.3.1/libgfortran/m4/ifunction_logical.m4 *** gcc-4.3.0/libgfortran/m4/ifunction_logical.m4 Tue Jan 15 21:22:07 2008 --- gcc-4.3.1/libgfortran/m4/ifunction_logical.m4 Tue May 6 20:46:41 2008 *************** name`'rtype_qual`_'atype_code (rtype * c *** 40,45 **** --- 40,46 ---- index_type delta; index_type dim; int src_kind; + int continue_loop; /* Make dim zero based to avoid confusion. */ dim = (*pdim) - 1; *************** name`'rtype_qual`_'atype_code (rtype * c *** 48,53 **** --- 49,57 ---- src_kind = GFC_DESCRIPTOR_SIZE (array); len = array->dim[dim].ubound + 1 - array->dim[dim].lbound; + if (len < 0) + len = 0; + delta = array->dim[dim].stride * src_kind; for (n = 0; n < dim; n++) *************** name`'rtype_qual`_'atype_code (rtype * c *** 146,152 **** dest = retarray->data; ! while (base) { const GFC_LOGICAL_1 * restrict src; rtype_name result; --- 150,157 ---- dest = retarray->data; ! continue_loop = 1; ! while (continue_loop) { const GFC_LOGICAL_1 * restrict src; rtype_name result; *************** define(FINISH_ARRAY_FUNCTION, *** 184,190 **** if (n == rank) { /* Break out of the look. */ ! base = NULL; break; } else --- 189,195 ---- if (n == rank) { /* Break out of the look. */ ! continue_loop = 0; break; } else