diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-07-20 05:35:17 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-07-20 05:35:17 +0000 |
commit | 6b351cc8c497c4ed9d296b55b424341f20b56f92 (patch) | |
tree | 8bcbc6cc30a2f9d6253007a662393cfed258713a | |
parent | d0df232358778b869142e628e5e736fc7515f5ab (diff) | |
download | gcc-6b351cc8c497c4ed9d296b55b424341f20b56f92.tar.gz |
2009-07-20 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 149800
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@149801 138bc75d-0d04-0410-961f-82ee72b054a4
467 files changed, 13392 insertions, 11672 deletions
diff --git a/ChangeLog.MELT b/ChangeLog.MELT index 5c386104ccc..95369c44429 100644 --- a/ChangeLog.MELT +++ b/ChangeLog.MELT @@ -1,4 +1,7 @@ +2009-07-20 Basile Starynkevitch <basile@starynkevitch.net> + MELT branch merged with trunk rev 149800 + 2009-07-15 Basile Starynkevitch <basile@starynkevitch.net> MELT branch merged with trunk rev 149655 diff --git a/boehm-gc/ChangeLog b/boehm-gc/ChangeLog index d2a80cc1fcb..14ba80a9a7a 100644 --- a/boehm-gc/ChangeLog +++ b/boehm-gc/ChangeLog @@ -1,3 +1,9 @@ +2009-07-17 Kai Tietz <kai.tietz@onevision.com> + + * configure.ac: Add rule for mingw targets to add -DGC_BUILD=1 to + cflags. + * configure: Regenerated. + 2009-05-17 Dave Korn <dave.korn.cygwin@gmail.com> * win32_threads.c (GC_get_thread_stack_base): Implement for Cygwin. diff --git a/boehm-gc/configure b/boehm-gc/configure index 6d2cf83e4cf..c3adff342fd 100755 --- a/boehm-gc/configure +++ b/boehm-gc/configure @@ -4194,6 +4194,12 @@ case "${host}" in ;; esac +case "${host}" in + *-*-mingw*) + gc_cflags="${gc_cflags} -DGC_BUILD=1" + ;; +esac + GC_CFLAGS=${gc_cflags} @@ -4619,13 +4625,13 @@ if test "${lt_cv_nm_interface+set}" = set; then else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:4622: $ac_compile\"" >&5) + (eval echo "\"\$as_me:4628: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:4625: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:4631: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:4628: output\"" >&5) + (eval echo "\"\$as_me:4634: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5783,7 +5789,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5786 "configure"' > conftest.$ac_ext + echo '#line 5792 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -8277,11 +8283,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8280: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8286: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8284: \$? = $ac_status" >&5 + echo "$as_me:8290: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8616,11 +8622,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8619: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8625: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8623: \$? = $ac_status" >&5 + echo "$as_me:8629: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8721,11 +8727,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8724: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8730: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8728: \$? = $ac_status" >&5 + echo "$as_me:8734: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8776,11 +8782,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8779: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8785: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8783: \$? = $ac_status" >&5 + echo "$as_me:8789: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11643,7 +11649,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11646 "configure" +#line 11652 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11739,7 +11745,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11742 "configure" +#line 11748 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13765,11 +13771,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13768: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13774: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13772: \$? = $ac_status" >&5 + echo "$as_me:13778: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -13864,11 +13870,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13867: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13873: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13871: \$? = $ac_status" >&5 + echo "$as_me:13877: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -13916,11 +13922,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13919: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13925: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13923: \$? = $ac_status" >&5 + echo "$as_me:13929: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17407,6 +17413,9 @@ ac_configure_args="${multilib_arg} ${ac_configure_args}" multi_basedir="$multi_basedir" CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} CC="$CC" +CXX="$CXX" +GFORTRAN="$GFORTRAN" +GCJ="$GCJ" AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" diff --git a/boehm-gc/configure.ac b/boehm-gc/configure.ac index 326a051f767..2206f76eaa2 100644 --- a/boehm-gc/configure.ac +++ b/boehm-gc/configure.ac @@ -84,6 +84,13 @@ case "${host}" in ;; esac +dnl Add for mingw targets GC_BUILD option +case "${host}" in + *-*-mingw*) + gc_cflags="${gc_cflags} -DGC_BUILD=1" + ;; +esac + dnl gc_cflags="${gc_cflags} -fno-builtin" GC_CFLAGS=${gc_cflags} diff --git a/config/ChangeLog b/config/ChangeLog index 481af803499..6bd7bbf5416 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,14 @@ +2009-07-17 Joseph Myers <joseph@codesourcery.com> + + PR other/40784 + * tls.m4 (GCC_CHECK_TLS): Add extra quoting around argument to + AC_LINK_IFELSE. + +2009-07-16 Joseph Myers <joseph@codesourcery.com> + + * tls.m4 (GCC_CHECK_TLS): Also test TLS in a shared library when + cross-compiling. + 2009-06-25 Olivier Hainque <hainque@adacore.com> * config/mh-ppc-aix (BOOT_ADAFLAGS): Remove -mminimal-toc. diff --git a/config/tls.m4 b/config/tls.m4 index e77742c7603..099bdc257a8 100644 --- a/config/tls.m4 +++ b/config/tls.m4 @@ -1,5 +1,6 @@ dnl Check whether the target supports TLS. AC_DEFUN([GCC_CHECK_TLS], [ + AC_REQUIRE([AC_CANONICAL_HOST]) GCC_ENABLE(tls, yes, [], [Use thread-local storage]) AC_CACHE_CHECK([whether the target supports thread-local storage], gcc_cv_have_tls, [ @@ -66,7 +67,24 @@ AC_DEFUN([GCC_CHECK_TLS], [ [dnl This is the cross-compiling case. Assume libc supports TLS if the dnl binutils and the compiler do. AC_LINK_IFELSE([__thread int a; int b; int main() { return a = b; }], - [gcc_cv_have_tls=yes], [gcc_cv_have_tls=no]) + [chktls_save_LDFLAGS="$LDFLAGS" + dnl Shared library options may depend on the host; this check + dnl is only known to be needed for GNU/Linux. + case $host in + *-*-linux*) + LDFLAGS="-shared -Wl,--no-undefined $LDFLAGS" + ;; + esac + chktls_save_CFLAGS="$CFLAGS" + CFLAGS="-fPIC $CFLAGS" + dnl If -shared works, test if TLS works in a shared library. + AC_LINK_IFELSE([int f() { return 0; }], + [AC_LINK_IFELSE([__thread int a; int b; int f() { return a = b; }], + [gcc_cv_have_tls=yes], + [gcc_cv_have_tls=no])], + [gcc_cv_have_tls=yes]) + CFLAGS="$chktls_save_CFLAGS" + LDFLAGS="$chktls_save_LDFLAGS"], [gcc_cv_have_tls=no]) ] )]) if test "$enable_tls $gcc_cv_have_tls" = "yes yes"; then diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 201a3ef8c77..6dd9908c4ce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,280 @@ +2009-07-20 Jan Hubicka <jh@suse.cz> + + * tree-ssa-dce.c (remove_dead_phis): Only look for abnormal PHIs + when handling SSA name. + +2009-07-19 Jan Hubicka <jh@suse.cz> + + PR tree-optimization/40676 + * tree-ssa-dce.c (eliminate_unnecessary_stmts): Do renaming on all + virtual PHIs in empty BBs. + +2009-07-18 Adam Nemet <anemet@caviumnetworks.com> + + * combine.c (make_compound_operation) <SUBREG>: If force_to_mode + re-expanded the compound use gen_lowpart instead to convert to the + desired mode. + +2009-07-18 Adam Nemet <anemet@caviumnetworks.com> + + * combine.c (try_widen_shift_mode): Add COUNT, OUTER_CODE and + OUTER_CONST arguments. + <LSHIFTRT>: Use them to allow widening if the bits shifted in from + the new wider mode will be masked off. + (simplify_shift_const_1): Adjust calls to try_widen_shift_mode. + +2009-07-18 Adam Nemet <anemet@caviumnetworks.com> + + * combine.c (try_widen_shift_mode) <LSHIFTRT>: Allow widening if the + high-order bits are zero. + +2009-07-18 Adam Nemet <anemet@caviumnetworks.com> + + * combine.c (simplify_shift_const_1): Split code to determine + shift_mode into ... + (try_widen_shift_mode): ... here. Allow widening for ASHIFTRT if the + new bits shifted in are identical to the old sign bit. + +2009-07-18 Richard Guenther <rguenther@suse.de> + + PR c/40787 + * gimplify.c (gimplify_call_expr): Reject code using results from + functions returning void. + +2009-07-18 Richard Sandiford <r.sandiford@uk.ibm.com> + + * doc/md.texi: Document the new PowerPC "es" constraint. + Document that "m" can include automodified addresses on this target, + and explain how %U must be used. Extend the "Q" and "Z" documentation + to suggest "es" as well as "m". + * config/rs6000/constraints.md (es): New memory constraint. + (Q, Z): Update strings to match new documentation. + +2009-07-18 Richard Sandiford <r.sandiford@uk.ibm.com> + + * config/rs6000/rs6000.c (rs6000_mode_dependent_address): Allow any + offset from virtual_stack_vars_rtx and arg_pointer_rtx. + * config/rs6000/predicates.md (volatile_mem_operand): Use + offsettable_nonstrict_memref_p. + * config/rs6000/rs6000.md (*floatsidf2_internal): Remove split check. + (*floatunssidf2_internal): Likewise. + (*fix_truncdfsi2_internal): Likewise. + (*fix_trunctfsi2_internal): Likewise. + +2009-07-17 Anatoly Sokolov <aesok@post.ru> + + * config/avr/avr-devices.c (avr_mcu_t): Add atmega8u2, atmega16u2 and + atmega32u2 devices. + * config/avr/t-avr (MULTILIB_MATCHES): (Ditto.). + +2009-07-17 Richard Guenther <rguenther@suse.de> + + PR c/40401 + * tree-pass.h (pass_diagnose_omp_blocks): Declare. + (pass_warn_unused_result): Likewise. + (TODO_set_props): Remove. + * omp-low.c (diagnose_omp_structured_block_errors): Change to + run as a pass. + (pass_diagnose_omp_blocks): Define. + * c-decl.c (pop_file_scope): Do not finalize the CU here. + (c_gimple_diagnostics_recursively): Remove. + (finish_function): Do not call it. + (c_write_global_declarations): Continue after errors. + Finalize the CU here. + * c-gimplify.c (c_genericize): Do not gimplify here. + * c-common.c (c_warn_unused_result): Move ... + * tree-cfg.c (do_warn_unused_result): ... here. + (run_warn_unused_result): New function. + (gate_warn_unused_result): New function. + (pass_warn_unused_result): New pass. + * c-common.h (c_warn_unused_result): Remove. + * flags.h (flag_warn_unused_result): Declare. + * c-opts.c (c_common_init_options): Enable flag_warn_unused_result. + * opts.c (flag_warn_unused_result): Initialize to false. + * toplev.c (compile_file): Add comment. + * omp-low.c (create_omp_child_function): Do not register + the function with the frontend. + (diagnose_omp_structured_block_errors): Prepare to be + called as optimization pass. + (gate_diagnose_omp_blocks): New function. + (pass_diagnose_omp_blocks): New pass. + * cgraph.h (cgraph_optimize): Remove. + (cgraph_analyze_function): Likewise. + * cgraph.c (cgraph_add_new_function): Gimplify C++ thunks. + * cgraphunit.c (cgraph_lower_function): Lower nested functions + before their parents here. + (cgraph_finalize_function): Not here. + (cgraph_analyze_function): Gimplify functions here. + (cgraph_finalize_compilation_unit): Continue after errors. + Optimize the callgraph from here. + (cgraph_optimize): Make static. + * langhooks.c (write_global_declarations): Finalize the CU. + * gimplify.c (gimplify_asm_expr): Do not emit ASMs with errors. + (gimplify_function_tree): Assert we gimplify only once. + Set PROP_gimple_any property. + * tree-nested.c (gimplify_all_functions): New function. + (lower_nested_functions): Gimplify all nested functions. + * gimple.h (diagnose_omp_structured_block_errors): Remove. + * passes.c (init_optimization_passes): Add pass_warn_unused_result + and pass_diagnose_omp_blocks after gimplification. Do not + set TODO_set_props on all_lowering_passes. + (execute_one_pass): Do not handle TODO_set_props. + * Makefile.in (cgraphunit.o): Add $(TREE_DUMP_H) dependency. + (gimplify.o): Add tree-pass.h dependency. + * tree-inline.c (copy_statement_list): Properly copy STATEMENT_LIST. + (copy_tree_body_r): Properly handle TARGET_EXPR like SAVE_EXPR. + (unsave_r): Likewise. + * c-omp.c (c_finish_omp_atomic): Set DECL_CONTEXT on the + temporary variable. + +2009-07-17 Sandra Loosemore <sandra@codesourcery.com> + + * doc/service.texi (Service): Restore previously removed link, + which isn't broken after all. + +2009-07-17 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/40321 + * tree-ssa-pre.c (add_to_exp_gen): Also add names defined by + PHI nodes to the maximal set. + (make_values_for_phi): Add PHI arguments to the maximal set. + (execute_pre): Dump PHI_GEN and the maximal set. + +2009-07-17 Jakub Jelinek <jakub@redhat.com> + + PR c++/40780 + * gimplify.c (gimplify_conversion): Don't change non-conversions into + VIEW_CONVERT_EXPR. + +2009-07-16 Sandra Loosemore <sandra@codesourcery.com> + + * doc/extend.texi (Nested Functions): Replace broken link with + textual reference. + * doc/service.texi (Service): Remove broken link. + +2009-07-16 H.J. Lu <hongjiu.lu@intel.com> + + PR bootstrap/40781 + * builtins.c (expand_builtin_memcmp): Use loc instead of + EXPR_LOCATION (exp). + (expand_builtin_strncmp): Likewise. + +2009-07-17 Aldy Hernandez <aldyh@redhat.com> + Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR 40435 + * tree-complex.c, tree-loop-distribution.c, tree.c, tree.h, + builtins.c, fold-const.c, omp-low.c, cgraphunit.c, tree-ssa-ccp.c, + tree-ssa-dom.c, gimple-low.c, expr.c, tree-ssa-ifcombine.c, + c-decl.c, stor-layout.c, tree-if-conv.c, c-typeck.c, gimplify.c, + calls.c, tree-sra.c, tree-mudflap.c, tree-ssa-copy.c, + tree-ssa-forwprop.c, c-convert.c, c-omp.c, varasm.c, + tree-inline.c, c-common.c, c-common.h, gimple.c, + tree-switch-conversion.c, gimple.h, tree-cfg.c, c-parser.c, + convert.c: Add location argument to fold_{unary,binary,ternary}, + fold_build[123], build_call_expr, build_size_arg, + build_fold_addr_expr, build_call_array, non_lvalue, size_diffop, + fold_build1_initializer, fold_build2_initializer, + fold_build3_initializer, fold_build_call_array, + fold_build_call_array_initializer, fold_single_bit_test, + omit_one_operand, omit_two_operands, invert_truthvalue, + fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, + combine_comparisons, fold_builtin_*, fold_call_expr, + build_range_check, maybe_fold_offset_to_address, round_up, + round_down. + +2009-07-16 Jason Merrill <jason@redhat.com> + + PR libstdc++/37907 + * c-common.c (c_common_reswords): Add __is_standard_layout + and __is_trivial. + * c-common.h (enum rid): Add RID_IS_STD_LAYOUT and RID_IS_TRIVIAL. + * doc/implement-cxx.texi: New. + * doc/gcc.texi: Include it. + +2009-07-16 DJ Delorie <dj@redhat.com> + + * config/m32c/m32c.c (m32c_compare_redundant): Avoid removing + compares that may be indirectly affected by previous instructions. + +2009-07-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * builtins.c (do_mpc_arg2): New. + (fold_builtin_2): Fold builtin cpow. + * real.h (HAVE_mpc_pow): New. + +2009-07-16 Bingfeng Mei <bmei@broadcom.com> + + * modulo-sched.c (sms_schedule): stage_count <= 1 as correct comparison + to skip unprofitable schedule + +2009-07-16 Simon Baldwin <simonb@google.com> + + * gcc.c (option_map): New flag -no-canonical-prefixes. + * (display_help): Print help text for new flag. + * (process_command): Move options translation and language specifics + and handle new flag early. Use it to set a function pointer to a + prefix builder. Replace make_relative_prefix calls with calls to + the function pointed to. Ignore new flag in regular options handling. + * doc/invoke.texi (Overall Options): Documented -no-canonical-prefixes. + +2009-07-15 DJ Delorie <dj@redhat.com> + + * config/mep/mep.md (sibcall_internal): Change register to avoid + argument registers. + (sibcall_value_internal): Likewise. + +2009-07-15 Eric Botcazou <ebotcazou@adacore.com> + + PR rtl-optimization/40710 + * resource.c (mark_target_live_regs): Reset DF problem to LR. + +2009-07-15 Adam Nemet <anemet@caviumnetworks.com> + + * config/mips/mips.md (*extenddi_truncate<mode>, + *extendsi_truncate<mode>): Change type attribute to move_type + with shift_shift. Split out code handling exts from here ... + (*extend<GPR:mode>_truncate<SHORT:mode>_exts): ... to this new + pattern. + (*extendhi_truncateqi): Change type attribute to move_type with + shift_shift. Split out code handling exts from here ... + (*extendhi_truncateqi_exts): ... to this new pattern. + +2009-07-15 Uros Bizjak <ubizjak@gmail.com> + + * config/i386/sse.md (copysign<mode>3): Use "and-not" SSE instruction + instead of "and" with inverted sign bit mask value. Use + "nonimmediate_operand" for operand 1 and operand 2 predicate. + Allocate registers only for operand 4 and operand 5. + +2009-07-15 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/40747 + * fold-const.c (fold_cond_expr_with_comparison): When folding + < and <= to MIN, make sure the MIN uses the same type as the + comparison's operands. + +2009-07-15 Richard Earnshaw <rearnsha@arm.com> + + * arm.md (ior_xor): New code iterator. + (split for ior/xor with shift and zero-extend): New split pattern. + * arm/predicates.md (subreg_lowpart_operator): New special predicate. + +2009-07-15 Richard Guenther <rguenther@suse.de> + + * tree-ssa-structalias.c (make_constraint_from_heapvar): Initialize + offset member. + +2009-07-15 Richard Guenther <rguenther@suse.de> + + PR middle-end/40753 + * alias.c (ao_ref_from_mem): Reject FUNCTION_DECL and LABEL_DECL bases. + +2009-07-15 Maxim Kuvyrkov <maxim@codesourcery.com> + + * config/m68k/linux-unwind.h (m68k_fallback_frame_state): Update to + handle 2.6.30 kernel. + 2009-07-15 DJ Delorie <dj@redhat.com> * config/mep/mep.md (sibcall_internal): Change register to allow @@ -6,9 +283,8 @@ 2009-07-14 Ghassan Shobaki <ghassan.shobaki@amd.com> - * doc/invoke.texi: Added descriptions of the - scheduling heuristics that are enabled/disabled - by the flags introduced by a previous patch. + * doc/invoke.texi: Added descriptions of the scheduling heuristics + that are enabled/disabled by the flags introduced by a previous patch. 2009-07-14 DJ Delorie <dj@redhat.com> diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 3ae0245a06c..37ac3a43bfb 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20090715 +20090720 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 57aeaab8bbc..145c81d1aed 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2422,7 +2422,7 @@ gimplify.o : gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(GIMPLE_H) \ $(LANGHOOKS_DEF_H) $(TREE_FLOW_H) $(CGRAPH_H) $(TIMEVAR_H) $(TM_H) \ coretypes.h $(EXCEPT_H) $(FLAGS_H) $(RTL_H) $(FUNCTION_H) $(EXPR_H) output.h \ $(GGC_H) gt-gimplify.h $(HASHTAB_H) $(TARGET_H) $(TOPLEV_H) $(OPTABS_H) \ - $(REAL_H) $(SPLAY_TREE_H) vec.h tree-iterator.h + $(REAL_H) $(SPLAY_TREE_H) vec.h tree-iterator.h tree-pass.h gimple-iterator.o : gimple-iterator.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TREE_H) $(GIMPLE_H) $(TREE_FLOW_H) value-prof.h gimple-low.o : gimple-low.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \ @@ -2733,7 +2733,7 @@ cgraphunit.o : cgraphunit.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TARGET_H) $(CGRAPH_H) intl.h pointer-set.h $(FUNCTION_H) $(GIMPLE_H) \ $(TREE_FLOW_H) $(TREE_PASS_H) debug.h $(DIAGNOSTIC_H) \ $(FIBHEAP_H) output.h $(PARAMS_H) $(RTL_H) $(TIMEVAR_H) $(IPA_PROP_H) \ - gt-cgraphunit.h tree-iterator.h $(COVERAGE_H) + gt-cgraphunit.h tree-iterator.h $(COVERAGE_H) $(TREE_DUMP_H) cgraphbuild.o : cgraphbuild.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TREE_H) langhooks.h $(CGRAPH_H) intl.h pointer-set.h $(GIMPLE_H) \ $(TREE_FLOW_H) $(TREE_PASS_H) @@ -3829,7 +3829,7 @@ TEXI_GCC_FILES = gcc.texi gcc-common.texi gcc-vers.texi frontends.texi \ gcov.texi trouble.texi bugreport.texi service.texi \ contribute.texi compat.texi funding.texi gnu.texi gpl_v3.texi \ fdl.texi contrib.texi cppenv.texi cppopts.texi \ - implement-c.texi arm-neon-intrinsics.texi + implement-c.texi implement-cxx.texi arm-neon-intrinsics.texi TEXI_GCCINT_FILES = gccint.texi gcc-common.texi gcc-vers.texi \ contribute.texi makefile.texi configterms.texi options.texi \ diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index a3162c2e289..eeb488171a0 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,209 @@ +2009-07-17 Richard Guenther <rguenther@suse.de> + + PR c/40401 + * gcc-interface/utils.c (end_subprog_body): Revert to pre-tuples + state. Remove unused parameter. + (gnat_gimplify_function): Do not gimplify here. + Fold into its only caller and remove. + (gnat_builtin_function): Adjust for end_subprog_body signature change. + (gnat_write_global_declarations): Also finalize the CU. + * gcc-interface/misc.c (gnat_parse_file): Do not finalize the CU here. + * gcc-interface/trans.c (gigi): Revert to pre-tuples state. + (Subprogram_Body_to_gnu): Adjust for end_subprog_body signature + change. + * gcc-interface/gigi.h (end_subprog_body): Remove unused parameter. + +2009-07-15 Arnaud Charlet <charlet@adacore.com> + + * gcc-interface/Make-lang.in: Update dependencies + + * gcc-interface/Makefile.in: Add target pairs for PPC/Xenomai + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * par_sco.adb (Traverse_Declarations_Or_Statements): Add processing for + N_Label. Remove SCO table entry for entry point (not used). + + * par_sco.ads: Remove SCO entry point type (not used) + + * switch.adb: Minor code clean up. + +2009-07-15 Eric Botcazou <ebotcazou@adacore.com> + + * exp_dbug.ads (Base Record Types): Document enhanced encoding. + +2009-07-15 Thomas Quinot <quinot@adacore.com> + + * gnatls.adb: Minor reformatting + + * gnatcmd.adb: Minor code reorganization + +2009-07-15 Ed Schonberg <schonberg@adacore.com> + + * exp_util.adb (Component_May_Be_Bit_Aligned): Use underlying type to + determine whether a component of a private type has a composite type. + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * sem_ch10.adb: Minor reformatting throughout + Minor code reorganization (put nested subprograms in alpha order) + +2009-07-15 Ed Schonberg <schonberg@adacore.com> + + * exp_ch6.adb (Expand_Call): Prevent double attachment of the result + when compiling a call to a protected function that returns a controlled + object. + +2009-07-15 Hristian Kirtchev <kirtchev@adacore.com> + + * sysdep.c (__gnat_localtime_tzoff): Consolidate the Lynx cases into + one. Add task locking and unlocking around the critical region which + mentions localtime_r and global variable timezone for various targets. + Comment reformatting. + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * gnat_rm.texi: Document s-ststop.ads + + * impunit.ad: (Map_Array): New table of alternative names + (Get_Kind_Of_Unit): Return possible suggested alternative name + + * impunit.ads (Get_Kind_Of_Unit): Return possible suggested + alternative name. + + * sem_ch10.adb (Analalyze_With_Clause): Add name of possible + alternative unit if an implementation unit is with'ed. + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * gnat_ugn.texi: Minor updates. + + * snames.ads-tmpl: Minor comment updates for Ada 2005 fully implemented + +2009-07-15 Ed Schonberg <schonberg@adacore.com> + + * sem_warn.adb (Warn_On_Constant_Condition): Handle properly constant + conditions of a derived boolean type. + Minor reformatting + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * gnat1drv.adb: Initialize SCO tables + + * par-load.adb: Call SCO_Record for main unit spec + + * par.adb: Make call to SCO_Record for main unit + + * par_sco.adb (Unit_Table): Change format to facilitate sort + (Process_Decisions): New procedure with list argument + (Traverse_Generic_Package_Declaration): New procedure + (Initialize): New procedure, replaces Init + (SCO_Output): Sort unit table before output + (SCO_Record): Avoid duplications + (SCO_Record): Handle remaining cases of units + (Traverse_Declarations_Or_Statements): Handle generics + + * par_sco.ads (Initialize): New peocedure (replaces Init) + + * sem_ch10.adb (Analyze_Proper_Body): Make call to SCO_Record for + subunit. + +2009-07-15 Arnaud Charlet <charlet@adacore.com> + + * debug.adb: Add -gnatd.J switch for now to support scil generation in + parallel. Add missing doc for -gnatd.I and -gnatd.O + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * lib-load.adb: Minor reformatting + + * lib-writ.adb (Write_ALI): Fix handling of SCO_Output wrt Generate_SCO. + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * par.adb: Minor reformatting + Add ??? comment for possible bad comment + + * par-ch10.adb: Minor reformatting + +2009-07-15 Ed Schonberg <schonberg@adacore.com> + + * sem_warn.adb (Warn_On_Constant_Condition): if the constant condition + is a literal of a derived boolean type, it appears as an unchecked + conversion. Retrieve actual value from expression of conversion. + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * sem_ch3.adb: Minor reformatting + + * lib-xref.ads, lib-xref.adb, lib.ads, par_sco.ads, par_sco.adb, + lib-writ.ads, lib-writ.adb: Minor reformatting. + Fix problem with SCO format in ALI files + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * exp_ch7.adb, exp_util.adb, tbuild.adb, tbuild.ads, exp_ch4.adb, + exp_aggr.adb: Minor code reorganization (better calling sequence for + Make_Temporary). + +2009-07-15 Thomas Quinot <quinot@adacore.com> + + * opt.ads: Minor comment edits + +2009-07-15 Tristan Gingold <gingold@adacore.com> + + * gcc-interface/Makefile.in: Special rule for seh_init.o no longer + needed. + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * lib-writ.adb (Write_Unit_Information): Use SCO_Output to output SCO + information. + + * lib-writ.ads: Document addition of SCO lines to ALI file + + * par_sco.ads, par_sco.adb: New files. + + * opt.ads (Generate_SCO): New switch + + * par.adb (Par): Call SCO_Record to record SCO information + + * sem_warn.adb (Warn_On_Constant_Condition): Adjust SCO condition + + * switch-c.adb: Recognize -gnateS to generate SCO information + + * usage.adb: Add line for -gnateS + + * gcc-interface/Make-lang.in: Add dependency on par_sco.o for gnat1 + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * sinfo.ads, make.adb, par.ads, par.adb, sem_warn.adb: Minor + reformatting. + +2009-07-15 Thomas Quinot <quinot@adacore.com> + + * g-socthi-mingw.adb: Minor comment addition + + * g-socthi-mingw.ads (WSAStartup): First argument is a WORD not an int. + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * g-htable.ads, s-htable.ads: Minor reformatting + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * switch-c.adb, sem_ch10.adb, sem_warn.adb, sem_warn.ads: Implement + new switch -gnatw.g. + (Set_GNAT_Mode_Warnings): New procedure. + + * lib-xref.adb: Minor reformatting + +2009-07-15 Robert Dewar <dewar@adacore.com> + + * exp_aggr.adb, tbuild.ads, tbuild.adb: Minor reformatting + Minor code reorganization + 2009-07-14 Taras Glek <tglek@mozilla.com> Rafael Espindola <espindola@google.com> diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index d0b285abf34..baa04293cd1 100644 --- a/gcc/ada/debug.adb +++ b/gcc/ada/debug.adb @@ -126,13 +126,13 @@ package body Debug is -- d.F -- d.G -- d.H - -- d.I Inspector mode - -- d.J + -- d.I SCIL generation mode + -- d.J Parallel SCIL generation mode -- d.K -- d.L -- d.M -- d.N - -- d.O + -- d.O Dump internal SCO tables -- d.P -- d.Q -- d.R @@ -555,9 +555,17 @@ package body Debug is -- d.C Generate call to System.Concat_n.Str_Concat_n routines in cases -- where we would normally generate inline concatenation code. - -- d.I Inspector mode. Relevant for VM_Target /= None. Try to generate - -- byte code, even in case of unsupported construct, for the sake - -- of static analysis tools. + -- d.I Generate SCIL mode. Generate intermediate code for the sake of + -- of static analysis tools, and ensure additional tree consistency + -- between different compilations of specs. + + -- d.J Ensure the SCIL generated is compatible with parallel builds. + -- This means in particular not writing the same files under the + -- same directory. + + -- d.O Dump internal SCO tables. Before outputting the SCO information to + -- the ALI file, the internal SCO tables (SCO_Table/SCO_Unit_Table) + -- are dumped for debugging purposes. -- d.S Force Optimize_Alignment (Space) mode as the default diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 11174614df1..dfb164b0253 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -2976,27 +2976,27 @@ package body Exp_Aggr is declare SubE : constant Entity_Id := Make_Defining_Identifier (Loc, - New_Internal_Name ('T')); + Chars => New_Internal_Name ('T')); SubD : constant Node_Id := Make_Subtype_Declaration (Loc, - Defining_Identifier => - SubE, + Defining_Identifier => SubE, Subtype_Indication => Make_Subtype_Indication (Loc, - Subtype_Mark => New_Reference_To ( - Etype (Comp_Type), Loc), + Subtype_Mark => + New_Reference_To + (Etype (Comp_Type), Loc), Constraint => - Make_Index_Or_Discriminant_Constraint ( - Loc, Constraints => New_List ( - New_Copy_Tree (Aggregate_Bounds ( - Expr_Q)))))); + Make_Index_Or_Discriminant_Constraint + (Loc, + Constraints => New_List ( + New_Copy_Tree + (Aggregate_Bounds (Expr_Q)))))); -- Create a temporary array of the above subtype which -- will be used to capture the aggregate assignments. - TmpE : constant Entity_Id := - Make_Temporary (Loc, New_Internal_Name ('A'), N); + TmpE : constant Entity_Id := Make_Temporary (Loc, 'A', N); TmpD : constant Node_Id := Make_Object_Declaration (Loc, @@ -3586,7 +3586,7 @@ package body Exp_Aggr is Rewrite (Parent (N), Make_Null_Statement (Loc)); else - Temp := Make_Temporary (Loc, New_Internal_Name ('A'), N); + Temp := Make_Temporary (Loc, 'A', N); -- If the type inherits unknown discriminants, use the view with -- known discriminants if available. @@ -5201,7 +5201,7 @@ package body Exp_Aggr is else Maybe_In_Place_OK := False; - Tmp := Make_Temporary (Loc, New_Internal_Name ('A'), N); + Tmp := Make_Temporary (Loc, 'A', N); Tmp_Decl := Make_Object_Declaration (Loc, diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index f8f2caa79b3..8343ea19b70 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -4043,7 +4043,7 @@ package body Exp_Ch4 is -- and replace the conditional expresion by a reference to Cnn.all ??? if Present (Then_Actions (N)) or else Present (Else_Actions (N)) then - Cnn := Make_Temporary (Loc, New_Internal_Name ('C'), N); + Cnn := Make_Temporary (Loc, 'C', N); New_If := Make_Implicit_If_Statement (N, diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 2d80cbcc62c..8530816c9b3 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -3097,10 +3097,17 @@ package body Exp_Ch6 is -- Functions returning controlled objects need special attention: -- if the return type is limited, the context is an initialization - -- and different processing applies. + -- and different processing applies. If the call is to a protected + -- function, the expansion above will call Expand_Call recusively. + -- To prevent a double attachment, check that the current call is + -- not a rewriting of a protected function call. if Needs_Finalization (Etype (Subp)) and then not Is_Inherently_Limited_Type (Etype (Subp)) + and then + (No (First_Formal (Subp)) + or else + not Is_Concurrent_Record_Type (Etype (First_Formal (Subp)))) then Expand_Ctrl_Function_Call (N); end if; diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 9dd58574214..a8a32fb5114 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -3551,9 +3551,8 @@ package body Exp_Ch7 is procedure Wrap_Transient_Expression (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); - E : constant Entity_Id := - Make_Temporary (Loc, New_Internal_Name ('E'), N); - Etyp : constant Entity_Id := Etype (N); + E : constant Entity_Id := Make_Temporary (Loc, 'E', N); + Etyp : constant Entity_Id := Etype (N); begin Insert_Actions (N, New_List ( diff --git a/gcc/ada/exp_dbug.ads b/gcc/ada/exp_dbug.ads index 15e83aaf113..842456e714e 100644 --- a/gcc/ada/exp_dbug.ads +++ b/gcc/ada/exp_dbug.ads @@ -844,9 +844,11 @@ package Exp_Dbug is -- Specifically, if this name is x, then we produce a record type named -- x___XVS consisting of one field. The name of this field is that of - -- the actual type being encoded, which we'll call y (the type of this - -- single field is arbitrary). Both x and y may have corresponding - -- ___XVE types. + -- the actual type being encoded, which we'll call y. The type of this + -- single field can be either an arbitrary non-reference type, e.g. an + -- integer type, or a reference type; in the latter case, the referenced + -- type is also the actual type being encoded y. Both x and y may have + -- corresponding ___XVE types. -- The size of the objects typed as x should be obtained from the -- structure of x (and x___XVE, if applicable) as for ordinary types diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index bd7f90cbe39..1031050cee7 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -913,6 +913,7 @@ package body Exp_Util is ---------------------------------- function Component_May_Be_Bit_Aligned (Comp : Entity_Id) return Boolean is + UT : constant Entity_Id := Underlying_Type (Etype (Comp)); begin -- If no component clause, then everything is fine, since the back end -- never bit-misaligns by default, even if there is a pragma Packed for @@ -924,8 +925,8 @@ package body Exp_Util is -- It is only array and record types that cause trouble - if not Is_Record_Type (Etype (Comp)) - and then not Is_Array_Type (Etype (Comp)) + if not Is_Record_Type (UT) + and then not Is_Array_Type (UT) then return False; @@ -934,8 +935,8 @@ package body Exp_Util is -- back end can handle these cases correctly. elsif Esize (Comp) <= 64 - and then (Is_Record_Type (Etype (Comp)) - or else Is_Bit_Packed_Array (Etype (Comp))) + and then (Is_Record_Type (UT) + or else Is_Bit_Packed_Array (UT)) then return False; @@ -4588,7 +4589,7 @@ package body Exp_Util is or else Nkind (Exp) in N_Op or else (not Name_Req and then Is_Volatile_Reference (Exp))) then - Def_Id := Make_Temporary (Loc, New_Internal_Name ('R'), Exp); + Def_Id := Make_Temporary (Loc, 'R', Exp); Set_Etype (Def_Id, Exp_Type); Res := New_Reference_To (Def_Id, Loc); @@ -4606,7 +4607,7 @@ package body Exp_Util is -- the pointer, and then do an explicit dereference on the result. elsif Nkind (Exp) = N_Explicit_Dereference then - Def_Id := Make_Temporary (Loc, New_Internal_Name ('R'), Exp); + Def_Id := Make_Temporary (Loc, 'R', Exp); Res := Make_Explicit_Dereference (Loc, New_Reference_To (Def_Id, Loc)); @@ -4650,7 +4651,7 @@ package body Exp_Util is -- Use a renaming to capture the expression, rather than create -- a controlled temporary. - Def_Id := Make_Temporary (Loc, New_Internal_Name ('R'), Exp); + Def_Id := Make_Temporary (Loc, 'R', Exp); Res := New_Reference_To (Def_Id, Loc); Insert_Action (Exp, @@ -4660,7 +4661,7 @@ package body Exp_Util is Name => Relocate_Node (Exp))); else - Def_Id := Make_Temporary (Loc, New_Internal_Name ('R'), Exp); + Def_Id := Make_Temporary (Loc, 'R', Exp); Set_Etype (Def_Id, Exp_Type); Res := New_Reference_To (Def_Id, Loc); @@ -4683,7 +4684,7 @@ package body Exp_Util is and then Nkind (Exp) /= N_Function_Call and then (Name_Req or else not Is_Volatile_Reference (Exp)) then - Def_Id := Make_Temporary (Loc, New_Internal_Name ('R'), Exp); + Def_Id := Make_Temporary (Loc, 'R', Exp); if Nkind (Exp) = N_Selected_Component and then Nkind (Prefix (Exp)) = N_Function_Call @@ -4750,8 +4751,7 @@ package body Exp_Util is and then Ada_Version >= Ada_05 then declare - Obj : constant Entity_Id := - Make_Temporary (Loc, New_Internal_Name ('F'), Exp); + Obj : constant Entity_Id := Make_Temporary (Loc, 'F', Exp); Decl : Node_Id; begin @@ -4781,7 +4781,7 @@ package body Exp_Util is E := Exp; Insert_Action (Exp, Ptr_Typ_Decl); - Def_Id := Make_Temporary (Loc, New_Internal_Name ('R'), Exp); + Def_Id := Make_Temporary (Loc, 'R', Exp); Set_Etype (Def_Id, Exp_Type); Res := diff --git a/gcc/ada/g-htable.ads b/gcc/ada/g-htable.ads index a158d09f618..e747637a590 100644 --- a/gcc/ada/g-htable.ads +++ b/gcc/ada/g-htable.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1995-2008, AdaCore -- +-- Copyright (C) 1995-2009, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -103,7 +103,7 @@ package GNAT.HTable is -- function Get_First return Element; -- -- Returns No_Element if the HTable is empty, otherwise returns one - -- -- non specified element. There is no guarantee that 2 calls to + -- -- non specified element. There is no guarantee that two calls to -- -- this function will return the same element. -- function Get_Next return Element; @@ -188,7 +188,7 @@ package GNAT.HTable is -- function Get_First return Elmt_Ptr; -- -- Returns Null_Ptr if the HTable is empty, otherwise returns one - -- -- non specified element. There is no guarantee that 2 calls to + -- -- non specified element. There is no guarantee that two calls to -- -- this function will return the same element. -- function Get_Next return Elmt_Ptr; diff --git a/gcc/ada/g-socthi-mingw.adb b/gcc/ada/g-socthi-mingw.adb index 7c0e7f6ef7f..49df16363b3 100644 --- a/gcc/ada/g-socthi-mingw.adb +++ b/gcc/ada/g-socthi-mingw.adb @@ -47,7 +47,9 @@ package body GNAT.Sockets.Thin is WSAData_Dummy : array (1 .. 512) of C.int; - WS_Version : constant := 16#0202#; + WS_Version : constant := 16#0202#; + -- Winsock 2.2 + Initialized : Boolean := False; function Standard_Connect diff --git a/gcc/ada/g-socthi-mingw.ads b/gcc/ada/g-socthi-mingw.ads index 42783e5f734..8ec056148f1 100644 --- a/gcc/ada/g-socthi-mingw.ads +++ b/gcc/ada/g-socthi-mingw.ads @@ -191,7 +191,7 @@ package GNAT.Sockets.Thin is (Command : System.Address) return C.int; function WSAStartup - (WS_Version : Interfaces.C.int; + (WS_Version : Interfaces.C.unsigned_short; WSADataAddress : System.Address) return Interfaces.C.int; ------------------------------------------------------- diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index 0f4082a7c2b..521a72120f1 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -139,7 +139,7 @@ GNAT_ADA_OBJS = ada/s-bitops.o ada/ada.o ada/a-charac.o ada/a-chlat1.o ada/a-exc ada/lib-load.o ada/lib-util.o ada/lib-xref.o ada/lib-writ.o ada/live.o \ ada/namet.o ada/namet-sp.o \ ada/nlists.o ada/nmake.o ada/opt.o ada/osint.o ada/osint-c.o \ - ada/output.o \ + ada/output.o ada/par_sco.o \ ada/par.o ada/prep.o ada/prepcomp.o ada/repinfo.o ada/restrict.o \ ada/rident.o ada/rtsfind.o \ ada/s-addope.o ada/s-assert.o ada/s-parame.o ada/s-stache.o \ @@ -2389,25 +2389,25 @@ ada/gnat1drv.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/inline.ads ada/lib.ads ada/lib.adb ada/lib-list.adb \ ada/lib-load.ads ada/lib-sort.adb ada/lib-writ.ads ada/lib-xref.ads \ ada/namet.ads ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/opt.ads \ - ada/osint.ads ada/output.ads ada/prepcomp.ads ada/repinfo.ads \ - ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads ada/sem.adb \ - ada/sem_attr.ads ada/sem_ch10.ads ada/sem_ch11.ads ada/sem_ch12.ads \ - ada/sem_ch13.ads ada/sem_ch2.ads ada/sem_ch3.ads ada/sem_ch4.ads \ - ada/sem_ch5.ads ada/sem_ch6.ads ada/sem_ch7.ads ada/sem_ch8.ads \ - ada/sem_ch9.ads ada/sem_elim.ads ada/sem_eval.ads ada/sem_prag.ads \ - ada/sem_type.ads ada/sem_util.ads ada/sinfo.ads ada/sinfo.adb \ - ada/sinput.ads ada/sinput.adb ada/sinput-l.ads ada/snames.ads \ - ada/sprint.ads ada/stand.ads ada/stringt.ads ada/stylesw.ads \ - ada/system.ads ada/s-assert.ads ada/s-bitops.ads ada/s-exctab.ads \ - ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads \ - ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads \ - ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb \ - ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads \ - ada/table.ads ada/table.adb ada/targparm.ads ada/tree_gen.ads \ - ada/tree_io.ads ada/treepr.ads ada/ttypes.ads ada/types.ads \ - ada/uintp.ads ada/uintp.adb ada/uname.ads ada/unchconv.ads \ - ada/unchdeal.ads ada/urealp.ads ada/usage.ads ada/validsw.ads \ - ada/widechar.ads + ada/osint.ads ada/output.ads ada/par_sco.ads ada/prepcomp.ads \ + ada/repinfo.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem.adb ada/sem_attr.ads ada/sem_ch10.ads \ + ada/sem_ch11.ads ada/sem_ch12.ads ada/sem_ch13.ads ada/sem_ch2.ads \ + ada/sem_ch3.ads ada/sem_ch4.ads ada/sem_ch5.ads ada/sem_ch6.ads \ + ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_ch9.ads ada/sem_elim.ads \ + ada/sem_eval.ads ada/sem_prag.ads ada/sem_type.ads ada/sem_util.ads \ + ada/sinfo.ads ada/sinfo.adb ada/sinput.ads ada/sinput.adb \ + ada/sinput-l.ads ada/snames.ads ada/sprint.ads ada/stand.ads \ + ada/stringt.ads ada/stylesw.ads ada/system.ads ada/s-assert.ads \ + ada/s-bitops.ads ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads \ + ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads \ + ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \ + ada/s-unstyp.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/targparm.ads ada/tree_gen.ads ada/tree_io.ads ada/treepr.ads \ + ada/ttypes.ads ada/types.ads ada/uintp.ads ada/uintp.adb ada/uname.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/usage.ads \ + ada/validsw.ads ada/widechar.ads ada/gnatbind.o : ada/ada.ads ada/a-comlin.ads ada/a-clrefi.ads \ ada/a-except.ads ada/a-unccon.ads ada/a-uncdea.ads ada/ali.ads \ @@ -2441,7 +2441,8 @@ ada/hostparm.o : ada/ada.ads ada/a-unccon.ads ada/hostparm.ads \ ada/impunit.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/atree.adb \ - ada/casing.ads ada/debug.ads ada/einfo.ads ada/einfo.adb ada/fname.ads \ + ada/casing.ads ada/debug.ads ada/einfo.ads ada/einfo.adb \ + ada/err_vars.ads ada/errout.ads ada/erroutc.ads ada/fname.ads \ ada/fname-uf.ads ada/gnat.ads ada/g-hesorg.ads ada/g-htable.ads \ ada/hostparm.ads ada/impunit.ads ada/impunit.adb ada/interfac.ads \ ada/lib.ads ada/lib.adb ada/lib-list.adb ada/lib-sort.adb ada/namet.ads \ @@ -2576,19 +2577,19 @@ ada/lib-writ.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/lib-util.ads ada/lib-util.adb ada/lib-writ.ads ada/lib-writ.adb \ ada/lib-xref.ads ada/namet.ads ada/nlists.ads ada/nlists.adb \ ada/nmake.ads ada/nmake.adb ada/opt.ads ada/osint.ads ada/osint-c.ads \ - ada/output.ads ada/par.ads ada/restrict.ads ada/rident.ads \ - ada/scans.ads ada/scn.ads ada/scng.ads ada/scng.adb ada/sem_aux.ads \ - ada/sinfo.ads ada/sinfo.adb ada/sinput.ads ada/sinput.adb \ - ada/snames.ads ada/stand.ads ada/stringt.ads ada/stringt.adb \ - ada/style.ads ada/styleg.ads ada/styleg.adb ada/stylesw.ads \ - ada/system.ads ada/s-casuti.ads ada/s-carun8.ads ada/s-crc32.ads \ - ada/s-crc32.adb ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads \ - ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads \ - ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ - ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads \ - ada/s-utf_32.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ - ada/tbuild.ads ada/tbuild.adb ada/tree_io.ads ada/types.ads \ - ada/types.adb ada/uintp.ads ada/uintp.adb ada/uname.ads \ + ada/output.ads ada/par.ads ada/par_sco.ads ada/restrict.ads \ + ada/rident.ads ada/scans.ads ada/scn.ads ada/scng.ads ada/scng.adb \ + ada/sem_aux.ads ada/sinfo.ads ada/sinfo.adb ada/sinput.ads \ + ada/sinput.adb ada/snames.ads ada/stand.ads ada/stringt.ads \ + ada/stringt.adb ada/style.ads ada/styleg.ads ada/styleg.adb \ + ada/stylesw.ads ada/system.ads ada/s-casuti.ads ada/s-carun8.ads \ + ada/s-crc32.ads ada/s-crc32.adb ada/s-exctab.ads ada/s-htable.ads \ + ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads \ + ada/s-rident.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \ + ada/s-unstyp.ads ada/s-utf_32.ads ada/s-wchcon.ads ada/table.ads \ + ada/table.adb ada/tbuild.ads ada/tbuild.adb ada/tree_io.ads \ + ada/types.ads ada/types.adb ada/uintp.ads ada/uintp.adb ada/uname.ads \ ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/widechar.ads ada/lib-xref.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ @@ -2748,22 +2749,39 @@ ada/par.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads ada/a-uncdea.ads \ ada/par-ch3.adb ada/par-ch4.adb ada/par-ch5.adb ada/par-ch6.adb \ ada/par-ch7.adb ada/par-ch8.adb ada/par-ch9.adb ada/par-endh.adb \ ada/par-labl.adb ada/par-load.adb ada/par-prag.adb ada/par-sync.adb \ - ada/par-tchk.adb ada/par-util.adb ada/restrict.ads ada/rident.ads \ - ada/scans.ads ada/scans.adb ada/scn.ads ada/scng.ads ada/scng.adb \ - ada/sem_aux.ads ada/sinfo.ads ada/sinfo.adb ada/sinfo-cn.ads \ - ada/sinput.ads ada/sinput.adb ada/sinput-l.ads ada/snames.ads \ - ada/snames.adb ada/stand.ads ada/stringt.ads ada/stringt.adb \ - ada/style.ads ada/styleg.ads ada/styleg.adb ada/stylesw.ads \ - ada/system.ads ada/s-carun8.ads ada/s-crc32.ads ada/s-crc32.adb \ - ada/s-exctab.ads ada/s-exctab.adb ada/s-htable.ads ada/s-imenne.ads \ - ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads \ - ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ - ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \ - ada/s-unstyp.ads ada/s-utf_32.ads ada/s-wchcon.ads ada/table.ads \ - ada/table.adb ada/tbuild.ads ada/tbuild.adb ada/tree_io.ads \ - ada/types.ads ada/types.adb ada/uintp.ads ada/uintp.adb ada/uname.ads \ - ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/validsw.ads \ - ada/widechar.ads + ada/par-tchk.adb ada/par-util.adb ada/par_sco.ads ada/restrict.ads \ + ada/rident.ads ada/scans.ads ada/scans.adb ada/scn.ads ada/scng.ads \ + ada/scng.adb ada/sem_aux.ads ada/sinfo.ads ada/sinfo.adb \ + ada/sinfo-cn.ads ada/sinput.ads ada/sinput.adb ada/sinput-l.ads \ + ada/snames.ads ada/snames.adb ada/stand.ads ada/stringt.ads \ + ada/stringt.adb ada/style.ads ada/styleg.ads ada/styleg.adb \ + ada/stylesw.ads ada/system.ads ada/s-carun8.ads ada/s-crc32.ads \ + ada/s-crc32.adb ada/s-exctab.ads ada/s-exctab.adb ada/s-htable.ads \ + ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads \ + ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ + ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads \ + ada/s-traent.ads ada/s-unstyp.ads ada/s-utf_32.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tbuild.ads ada/tbuild.adb \ + ada/tree_io.ads ada/types.ads ada/types.adb ada/uintp.ads ada/uintp.adb \ + ada/uname.ads ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads \ + ada/validsw.ads ada/widechar.ads + +ada/par_sco.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ + ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/atree.adb \ + ada/casing.ads ada/debug.ads ada/einfo.ads ada/einfo.adb ada/fname.ads \ + ada/gnat.ads ada/g-hesorg.ads ada/g-hesorg.adb ada/g-htable.ads \ + ada/hostparm.ads ada/lib.ads ada/lib.adb ada/lib-list.adb \ + ada/lib-sort.adb ada/lib-util.ads ada/lib-util.adb ada/namet.ads \ + ada/nlists.ads ada/nlists.adb ada/opt.ads ada/osint.ads ada/osint-c.ads \ + ada/output.ads ada/par_sco.ads ada/par_sco.adb ada/sinfo.ads \ + ada/sinfo.adb ada/sinput.ads ada/sinput.adb ada/snames.ads \ + ada/stand.ads ada/stringt.ads ada/system.ads ada/s-exctab.ads \ + ada/s-htable.ads ada/s-htable.adb ada/s-imenne.ads ada/s-memory.ads \ + ada/s-os_lib.ads ada/s-parame.ads ada/s-stalib.ads ada/s-strhas.ads \ + ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/types.ads ada/uintp.ads \ + ada/uintp.adb ada/uname.ads ada/unchconv.ads ada/unchdeal.ads \ + ada/urealp.ads ada/widechar.ads ada/prep.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/casing.ads ada/csets.ads \ @@ -3201,24 +3219,24 @@ ada/sem_ch10.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/interfac.ads ada/lib.ads ada/lib.adb ada/lib-list.adb \ ada/lib-load.ads ada/lib-sort.adb ada/lib-xref.ads ada/namet.ads \ ada/namet.adb ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/nmake.adb \ - ada/opt.ads ada/output.ads ada/restrict.ads ada/rident.ads \ - ada/rtsfind.ads ada/scans.ads ada/scn.ads ada/scng.ads ada/scng.adb \ - ada/sem.ads ada/sem_attr.ads ada/sem_aux.ads ada/sem_ch10.ads \ - ada/sem_ch10.adb ada/sem_ch3.ads ada/sem_ch6.ads ada/sem_ch7.ads \ - ada/sem_ch8.ads ada/sem_dist.ads ada/sem_eval.ads ada/sem_prag.ads \ - ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sem_util.adb \ - ada/sem_warn.ads ada/sinfo.ads ada/sinfo.adb ada/sinfo-cn.ads \ - ada/sinput.ads ada/sinput.adb ada/snames.ads ada/stand.ads \ - ada/stringt.ads ada/style.ads ada/styleg.ads ada/styleg.adb \ - ada/stylesw.ads ada/system.ads ada/s-crc32.ads ada/s-exctab.ads \ - ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads \ - ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads \ - ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb \ - ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads ada/s-utf_32.ads \ - ada/s-wchcon.ads ada/table.ads ada/table.adb ada/targparm.ads \ - ada/tbuild.ads ada/tree_io.ads ada/ttypes.ads ada/types.ads \ - ada/uintp.ads ada/uintp.adb ada/uname.ads ada/unchconv.ads \ - ada/unchdeal.ads ada/urealp.ads ada/widechar.ads + ada/opt.ads ada/output.ads ada/par_sco.ads ada/restrict.ads \ + ada/rident.ads ada/rtsfind.ads ada/scans.ads ada/scn.ads ada/scng.ads \ + ada/scng.adb ada/sem.ads ada/sem_attr.ads ada/sem_aux.ads \ + ada/sem_ch10.ads ada/sem_ch10.adb ada/sem_ch3.ads ada/sem_ch6.ads \ + ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_dist.ads ada/sem_eval.ads \ + ada/sem_prag.ads ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads \ + ada/sem_util.adb ada/sem_warn.ads ada/sinfo.ads ada/sinfo.adb \ + ada/sinfo-cn.ads ada/sinput.ads ada/sinput.adb ada/snames.ads \ + ada/stand.ads ada/stringt.ads ada/style.ads ada/styleg.ads \ + ada/styleg.adb ada/stylesw.ads ada/system.ads ada/s-crc32.ads \ + ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads \ + ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads \ + ada/s-utf_32.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/targparm.ads ada/tbuild.ads ada/tree_io.ads ada/ttypes.ads \ + ada/types.ads ada/uintp.ads ada/uintp.adb ada/uname.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/widechar.ads ada/sem_ch11.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/atree.adb \ @@ -3227,18 +3245,18 @@ ada/sem_ch11.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/fname.ads ada/gnat.ads ada/g-htable.ads ada/hostparm.ads \ ada/lib.ads ada/lib-xref.ads ada/namet.ads ada/nlists.ads \ ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads ada/output.ads \ - ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/sem.ads \ - ada/sem_aux.ads ada/sem_ch11.ads ada/sem_ch11.adb ada/sem_ch5.ads \ - ada/sem_ch8.ads ada/sem_eval.ads ada/sem_res.ads ada/sem_util.ads \ - ada/sem_warn.ads ada/sem_warn.adb ada/sinfo.ads ada/sinfo.adb \ - ada/sinput.ads ada/snames.ads ada/stand.ads ada/stringt.ads \ - ada/system.ads ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads \ - ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads \ - ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ - ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads \ - ada/s-wchcon.ads ada/table.ads ada/table.adb ada/tree_io.ads \ - ada/types.ads ada/uintp.ads ada/uintp.adb ada/unchconv.ads \ - ada/unchdeal.ads ada/urealp.ads + ada/par_sco.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/sem.ads ada/sem_aux.ads ada/sem_ch11.ads ada/sem_ch11.adb \ + ada/sem_ch5.ads ada/sem_ch8.ads ada/sem_eval.ads ada/sem_res.ads \ + ada/sem_util.ads ada/sem_warn.ads ada/sem_warn.adb ada/sinfo.ads \ + ada/sinfo.adb ada/sinput.ads ada/snames.ads ada/stand.ads \ + ada/stringt.ads ada/system.ads ada/s-exctab.ads ada/s-htable.ads \ + ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads \ + ada/s-rident.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \ + ada/s-unstyp.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/tree_io.ads ada/types.ads ada/uintp.ads ada/uintp.adb \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/sem_ch12.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/atree.adb \ @@ -3390,25 +3408,25 @@ ada/sem_ch5.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/g-htable.ads ada/hostparm.ads ada/interfac.ads ada/itypes.ads \ ada/lib.ads ada/lib-xref.ads ada/namet.ads ada/namet.adb ada/nlists.ads \ ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads ada/output.ads \ - ada/restrict.ads ada/rident.ads ada/rtsfind.ads ada/scans.ads \ - ada/scn.ads ada/scng.ads ada/scng.adb ada/sem.ads ada/sem_aggr.ads \ - ada/sem_attr.ads ada/sem_aux.ads ada/sem_case.ads ada/sem_case.adb \ - ada/sem_cat.ads ada/sem_ch13.ads ada/sem_ch3.ads ada/sem_ch4.ads \ - ada/sem_ch5.ads ada/sem_ch5.adb ada/sem_ch6.ads ada/sem_ch8.ads \ - ada/sem_disp.ads ada/sem_dist.ads ada/sem_elab.ads ada/sem_elim.ads \ - ada/sem_eval.ads ada/sem_eval.adb ada/sem_intr.ads ada/sem_res.ads \ - ada/sem_res.adb ada/sem_type.ads ada/sem_util.ads ada/sem_util.adb \ - ada/sem_warn.ads ada/sem_warn.adb ada/sinfo.ads ada/sinfo.adb \ - ada/sinput.ads ada/snames.ads ada/sprint.ads ada/stand.ads \ - ada/stringt.ads ada/stringt.adb ada/style.ads ada/styleg.ads \ - ada/styleg.adb ada/stylesw.ads ada/system.ads ada/s-crc32.ads \ - ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads \ - ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads \ - ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ - ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads \ - ada/s-utf_32.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ - ada/targparm.ads ada/tbuild.ads ada/tree_io.ads ada/ttypes.ads \ - ada/types.ads ada/uintp.ads ada/uintp.adb ada/uname.ads \ + ada/par_sco.ads ada/restrict.ads ada/rident.ads ada/rtsfind.ads \ + ada/scans.ads ada/scn.ads ada/scng.ads ada/scng.adb ada/sem.ads \ + ada/sem_aggr.ads ada/sem_attr.ads ada/sem_aux.ads ada/sem_case.ads \ + ada/sem_case.adb ada/sem_cat.ads ada/sem_ch13.ads ada/sem_ch3.ads \ + ada/sem_ch4.ads ada/sem_ch5.ads ada/sem_ch5.adb ada/sem_ch6.ads \ + ada/sem_ch8.ads ada/sem_disp.ads ada/sem_dist.ads ada/sem_elab.ads \ + ada/sem_elim.ads ada/sem_eval.ads ada/sem_eval.adb ada/sem_intr.ads \ + ada/sem_res.ads ada/sem_res.adb ada/sem_type.ads ada/sem_util.ads \ + ada/sem_util.adb ada/sem_warn.ads ada/sem_warn.adb ada/sinfo.ads \ + ada/sinfo.adb ada/sinput.ads ada/snames.ads ada/sprint.ads \ + ada/stand.ads ada/stringt.ads ada/stringt.adb ada/style.ads \ + ada/styleg.ads ada/styleg.adb ada/stylesw.ads ada/system.ads \ + ada/s-crc32.ads ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads \ + ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads \ + ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \ + ada/s-unstyp.ads ada/s-utf_32.ads ada/s-wchcon.ads ada/table.ads \ + ada/table.adb ada/targparm.ads ada/tbuild.ads ada/tree_io.ads \ + ada/ttypes.ads ada/types.ads ada/uintp.ads ada/uintp.adb ada/uname.ads \ ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/validsw.ads \ ada/widechar.ads @@ -3869,21 +3887,22 @@ ada/sem_warn.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/hostparm.ads ada/interfac.ads ada/lib.ads ada/lib.adb \ ada/lib-list.adb ada/lib-sort.adb ada/lib-xref.ads ada/namet.ads \ ada/namet.adb ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/opt.ads \ - ada/output.ads ada/rident.ads ada/rtsfind.ads ada/scans.ads ada/scn.ads \ - ada/scng.ads ada/scng.adb ada/sem.ads ada/sem_attr.ads ada/sem_aux.ads \ - ada/sem_ch8.ads ada/sem_eval.ads ada/sem_res.ads ada/sem_type.ads \ - ada/sem_util.ads ada/sem_util.adb ada/sem_warn.ads ada/sem_warn.adb \ - ada/sinfo.ads ada/sinfo.adb ada/sinput.ads ada/sinput.adb \ - ada/snames.ads ada/stand.ads ada/stringt.ads ada/style.ads \ - ada/styleg.ads ada/styleg.adb ada/stylesw.ads ada/system.ads \ - ada/s-crc32.ads ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads \ - ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads \ - ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ - ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \ - ada/s-unstyp.ads ada/s-utf_32.ads ada/s-wchcon.ads ada/table.ads \ - ada/table.adb ada/targparm.ads ada/tbuild.ads ada/tree_io.ads \ - ada/ttypes.ads ada/types.ads ada/uintp.ads ada/uintp.adb ada/uname.ads \ - ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/widechar.ads + ada/output.ads ada/par_sco.ads ada/rident.ads ada/rtsfind.ads \ + ada/scans.ads ada/scn.ads ada/scng.ads ada/scng.adb ada/sem.ads \ + ada/sem_attr.ads ada/sem_aux.ads ada/sem_ch8.ads ada/sem_eval.ads \ + ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads ada/sem_util.adb \ + ada/sem_warn.ads ada/sem_warn.adb ada/sinfo.ads ada/sinfo.adb \ + ada/sinput.ads ada/sinput.adb ada/snames.ads ada/stand.ads \ + ada/stringt.ads ada/style.ads ada/styleg.ads ada/styleg.adb \ + ada/stylesw.ads ada/system.ads ada/s-crc32.ads ada/s-exctab.ads \ + ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads \ + ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb \ + ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads ada/s-utf_32.ads \ + ada/s-wchcon.ads ada/table.ads ada/table.adb ada/targparm.ads \ + ada/tbuild.ads ada/tree_io.ads ada/ttypes.ads ada/types.ads \ + ada/uintp.ads ada/uintp.adb ada/uname.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads ada/widechar.ads ada/sinfo-cn.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/atree.ads ada/atree.adb \ diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index 9ec41afa8ba..cd603cf8758 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -1753,6 +1753,22 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(arch) $(osys))),) $(LIBGNAT_TARGET_PAIRS_COMMON) $(LIBGNAT_TARGET_PAIRS_32) endif + ifeq ($(strip $(filter-out xenomai,$(THREAD_KIND))),) + LIBGNAT_TARGET_PAIRS += \ + s-osinte.ads<s-osinte-linux-xenomai.ads \ + s-osprim.adb<s-osprim-linux-xenomai.adb \ + s-taprop.adb<s-taprop-linux-xenomai.adb \ + s-taspri.ads<s-taspri-linux-xenomai.ads \ + system.ads<system-linux-ppc-xenomai.ads + else + LIBGNAT_TARGET_PAIRS += \ + s-osinte.ads<s-osinte-linux.ads \ + s-osprim.adb<s-osprim-posix.adb \ + s-taprop.adb<s-taprop-linux.adb \ + s-taspri.ads<s-taspri-posix-noaltstack.ads \ + system.ads<system-linux-ppc.ads + endif + TOOLS_TARGET_PAIRS = \ mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \ indepsw.adb<indepsw-gnu.adb @@ -2654,12 +2670,6 @@ targext.o : targext.c $(ALL_CPPFLAGS) $(INCLUDES_FOR_SUBDIR) \ $< $(OUTPUT_OPTION) -# No optimization to compile this file as optimizations (-O1 or above) breaks -# the SEH handling on Windows. The reasons are not clear. -seh_init.o : seh_init.c raise.h - $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ADA_CFLAGS) -O0 \ - $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION) - # Need to keep the frame pointer in this file to pop the stack properly on # some targets. tracebak.o : tracebak.c tb-alvms.c tb-alvxw.c tb-gcc.c diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index de253b8d939..05a46869f6e 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -678,9 +678,8 @@ extern tree create_label_decl (tree label_name); extern void begin_subprog_body (tree subprog_decl); /* Finish the definition of the current subprogram BODY and compile it all the - way to assembler language output. ELAB_P tells if this is called for an - elaboration routine, to be entirely discarded if empty. */ -extern void end_subprog_body (tree body, bool elab_p); + way to assembler language output. */ +extern void end_subprog_body (tree body); /* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE. EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs. diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 587eab3379e..4b68227e3cd 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -176,9 +176,6 @@ gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED) /* Call the front end. */ _ada_gnat1drv (); - - /* We always have a single compilation unit in Ada. */ - cgraph_finalize_compilation_unit (); } /* Decode all the language specific options that cannot be decoded by GCC. diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 5b4e5e86318..12599675d83 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -627,6 +627,7 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name, for (info = elab_info_list; info; info = info->next) { tree gnu_body = DECL_SAVED_TREE (info->elab_proc); + tree gnu_stmts; /* Unshare SAVE_EXPRs between subprograms. These are not unshared by the gimplifier for obvious reasons, but it turns out that we need to @@ -638,14 +639,24 @@ gigi (Node_Id gnat_root, int max_gnat_node, int number_name, an upstream bug for which we would not change the outcome. */ walk_tree_without_duplicates (&gnu_body, unshare_save_expr, NULL); - /* Process the function as others, but for indicating this is an - elab proc, to be discarded if empty, then propagate the status - up to the GNAT tree node. */ - begin_subprog_body (info->elab_proc); - end_subprog_body (gnu_body, true); - if (empty_body_p (gimple_body (info->elab_proc))) - Set_Has_No_Elaboration_Code (info->gnat_node, 1); + /* We should have a BIND_EXPR, but it may or may not have any statements + in it. If it doesn't have any, we have nothing to do. */ + gnu_stmts = gnu_body; + if (TREE_CODE (gnu_stmts) == BIND_EXPR) + gnu_stmts = BIND_EXPR_BODY (gnu_stmts); + + /* If there are no statements, there is no elaboration code. */ + if (!gnu_stmts || !STATEMENT_LIST_HEAD (gnu_stmts)) + { + Set_Has_No_Elaboration_Code (info->gnat_node, 1); + } + else + { + /* Process the function as others. */ + begin_subprog_body (info->elab_proc); + end_subprog_body (gnu_body); + } } /* We cannot track the location of errors past this point. */ @@ -2326,7 +2337,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_node) : Sloc (gnat_node)), &DECL_STRUCT_FUNCTION (gnu_subprog_decl)->function_end_locus); - end_subprog_body (gnu_result, false); + end_subprog_body (gnu_result); /* Finally annotate the parameters and disconnect the trees for parameters that we have turned into variables since they are now unusable. */ diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index aa12eb77506..59d9477a44d 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -203,7 +203,6 @@ static GTY((deletable)) tree free_block_chain; static tree merge_sizes (tree, tree, tree, bool, bool); static tree compute_related_constant (tree, tree); static tree split_plus (tree, tree *); -static void gnat_gimplify_function (tree); static tree float_type_for_precision (int, enum machine_mode); static tree convert_to_fat_pointer (tree, tree); static tree convert_to_thin_pointer (tree, tree); @@ -2070,11 +2069,10 @@ gnat_genericize (tree fndecl) } /* Finish the definition of the current subprogram BODY and compile it all the - way to assembler language output. ELAB_P tells if this is called for an - elaboration routine, to be entirely discarded if empty. */ + way to assembler language output. */ void -end_subprog_body (tree body, bool elab_p) +end_subprog_body (tree body) { tree fndecl = current_function_decl; @@ -2107,44 +2105,19 @@ end_subprog_body (tree body, bool elab_p) /* Perform the required pre-gimplification transformations on the tree. */ gnat_genericize (fndecl); + /* Dump functions before gimplification. */ + dump_function (TDI_original, fndecl); + /* We do different things for nested and non-nested functions. ??? This should be in cgraph. */ if (!DECL_CONTEXT (fndecl)) - { - gnat_gimplify_function (fndecl); - - /* If this is an empty elaboration proc, just discard the node. - Otherwise, compile further. */ - if (elab_p && empty_body_p (gimple_body (fndecl))) - cgraph_remove_node (cgraph_node (fndecl)); - else - cgraph_finalize_function (fndecl, false); - } + cgraph_finalize_function (fndecl, false); else /* Register this function with cgraph just far enough to get it added to our parent's nested function list. */ (void) cgraph_node (fndecl); } -/* Convert FNDECL's code to GIMPLE and handle any nested functions. */ - -static void -gnat_gimplify_function (tree fndecl) -{ - struct cgraph_node *cgn; - - dump_function (TDI_original, fndecl); - gimplify_function_tree (fndecl); - dump_function (TDI_generic, fndecl); - - /* Convert all nested functions to GIMPLE now. We do things in this order - so that items like VLA sizes are expanded properly in the context of the - correct function. */ - cgn = cgraph_node (fndecl); - for (cgn = cgn->nested; cgn; cgn = cgn->next_nested) - gnat_gimplify_function (cgn->decl); -} - tree gnat_builtin_function (tree decl) { @@ -3520,7 +3493,7 @@ build_function_stub (tree gnu_subprog, Entity_Id gnat_subprog) gnat_poplevel (); allocate_struct_function (gnu_stub_decl, false); - end_subprog_body (gnu_body, false); + end_subprog_body (gnu_body); } /* Build a type to be used to represent an aliased object whose nominal @@ -4693,7 +4666,7 @@ gnat_write_global_declarations (void) { /* Proceed to optimize and emit assembly. FIXME: shouldn't be the front end's responsibility to call this. */ - cgraph_optimize (); + cgraph_finalize_compilation_unit (); /* Emit debug info for all global declarations. */ emit_debug_global_declarations (VEC_address (tree, global_decls), diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index c8d9cb35b73..79065e26add 100644 --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -45,6 +45,7 @@ with Nlists; with Opt; use Opt; with Osint; use Osint; with Output; use Output; +with Par_SCO; with Prepcomp; with Repinfo; use Repinfo; with Restrict; @@ -506,6 +507,9 @@ begin -- nested blocks, so that the outer one handles unrecoverable error. begin + -- Initialize all packages. For the most part, these initialization + -- calls can be made in any order. Exceptions are as follows: + -- Lib.Initialize need to be called before Scan_Compiler_Arguments, -- because it initializes a table filled by Scan_Compiler_Arguments. @@ -527,6 +531,7 @@ begin Snames.Initialize; Stringt.Initialize; Inline.Initialize; + Par_SCO.Initialize; Sem_Ch8.Initialize; Sem_Ch12.Initialize; Sem_Ch13.Initialize; diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 3e85ef79921..bc18c28b849 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -409,6 +409,7 @@ The GNAT Library * System.Pool_Local (s-pooloc.ads):: * System.Restrictions (s-restri.ads):: * System.Rident (s-rident.ads):: +* System.Strings.Stream_Ops (s-ststop.ads):: * System.Task_Info (s-tasinf.ads):: * System.Wch_Cnv (s-wchcnv.ads):: * System.Wch_Con (s-wchcon.ads):: @@ -13597,6 +13598,7 @@ of GNAT, and will generate a warning message. * System.Pool_Local (s-pooloc.ads):: * System.Restrictions (s-restri.ads):: * System.Rident (s-rident.ads):: +* System.Strings.Stream_Ops (s-ststop.ads):: * System.Task_Info (s-tasinf.ads):: * System.Wch_Cnv (s-wchcnv.ads):: * System.Wch_Con (s-wchcon.ads):: @@ -14939,6 +14941,18 @@ It is not normally necessary to @code{with} this generic package since the necessary instantiation is included in package System.Restrictions. +@node System.Strings.Stream_Ops (s-ststop.ads) +@section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads}) +@cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads}) +@cindex Stream operations +@cindex String stream operations + +@noindent +This package provides a set of stream subprograms for standard string types. +It is intended primarily to support implicit use of such subprograms when +stream attributes are applied to string types, but the subprograms in this +package can be used directly by application programs. + @node System.Task_Info (s-tasinf.ads) @section @code{System.Task_Info} (@file{s-tasinf.ads}) @cindex @code{System.Task_Info} (@file{s-tasinf.ads}) diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index 779a7614c6a..08162371a23 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -11309,6 +11309,7 @@ recognized by GNAT: Ada_05 Ada_2005 Assertion_Policy + Assume_No_Invalid_Values C_Pass_By_Copy Check_Name Check_Policy @@ -11316,12 +11317,14 @@ recognized by GNAT: Compile_Time_Warning Compiler_Unit Component_Alignment + Convention_Identifier Debug_Policy Detect_Blocking Discard_Names Elaboration_Checks Eliminate Extend_System + Extensions_Allowed External_Name_Casing Fast_Math Favor_Top_Level @@ -28274,7 +28277,7 @@ the @option{-gnatE} switch on the compiler (@command{gcc} or @command{gnatmake}) command, or by the use of the configuration pragma: @smallexample @c ada -pragma Elaboration_Checks (RM); +pragma Elaboration_Checks (DYNAMIC); @end smallexample @noindent diff --git a/gcc/ada/gnatcmd.adb b/gcc/ada/gnatcmd.adb index c3ec70c241a..f0e7e7494cb 100644 --- a/gcc/ada/gnatcmd.adb +++ b/gcc/ada/gnatcmd.adb @@ -603,7 +603,7 @@ procedure GNATCmd is if Project = No_Project then return False; - elsif All_Projects or Project = Root_Project then + elsif All_Projects or else Project = Root_Project then return True; elsif The_Command = Metric then @@ -2074,7 +2074,7 @@ begin Process_Link; end if; - if The_Command = Link or The_Command = Bind then + if The_Command = Link or else The_Command = Bind then -- For files that are specified as relative paths with directory -- information, we convert them to absolute paths, with parent diff --git a/gcc/ada/gnatls.adb b/gcc/ada/gnatls.adb index 36e2ee6218d..1b7666f2838 100644 --- a/gcc/ada/gnatls.adb +++ b/gcc/ada/gnatls.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -185,19 +185,19 @@ procedure Gnatls is function Image (Restriction : Restriction_Id) return String; -- Returns the capitalized image of Restriction - --------------------------------------- - -- GLADE specific output subprograms -- - --------------------------------------- + ------------------------------------------ + -- GNATDIST specific output subprograms -- + ------------------------------------------ - package GLADE is + package GNATDIST is - -- Any modification to this subunit requires a synchronization - -- with the GLADE implementation. + -- Any modification to this subunit requires a synchronization with + -- GNATDIST sources. procedure Output_ALI (A : ALI_Id); procedure Output_No_ALI (Afile : File_Name_Type); - end GLADE; + end GNATDIST; ----------------- -- Add_Lib_Dir -- @@ -347,7 +347,7 @@ procedure Gnatls is Source_End := Source_Start - 1; if Print_Source then - Source_End := Source_Start + Max_Src_Length; + Source_End := Source_Start + Max_Src_Length; end if; end Find_General_Layout; @@ -392,11 +392,11 @@ procedure Gnatls is end if; end Find_Status; - ----------- - -- GLADE -- - ----------- + -------------- + -- GNATDIST -- + -------------- - package body GLADE is + package body GNATDIST is N_Flags : Natural; N_Indents : Natural := 0; @@ -610,7 +610,7 @@ procedure Gnatls is -- There is no full source name. This occurs for instance when a -- withed unit has a spec file but no body file. This situation - -- is not a problem for GLADE since the unit may be located on + -- is not a problem for GNATDIST since the unit may be located on -- a partition we do not want to build. However, we need to -- locate the spec file and to find its full source name. -- Replace the body file name with the spec file name used to @@ -794,7 +794,7 @@ procedure Gnatls is N_Indents := N_Indents - 1; end Output_With; - end GLADE; + end GNATDIST; ----------- -- Image -- @@ -1754,7 +1754,7 @@ begin if Ali_File = No_File then if Very_Verbose_Mode then - GLADE.Output_No_ALI (Lib_File_Name (Main_File)); + GNATDIST.Output_No_ALI (Lib_File_Name (Main_File)); else Write_Str ("Can't find library info for "); @@ -1791,7 +1791,7 @@ begin if Very_Verbose_Mode then for A in ALIs.First .. ALIs.Last loop - GLADE.Output_ALI (A); + GNATDIST.Output_ALI (A); end loop; return; diff --git a/gcc/ada/impunit.adb b/gcc/ada/impunit.adb index 4cf3e0c01a5..94112ff8ef5 100644 --- a/gcc/ada/impunit.adb +++ b/gcc/ada/impunit.adb @@ -24,6 +24,7 @@ ------------------------------------------------------------------------------ with Atree; use Atree; +with Errout; use Errout; with Sinfo; use Sinfo; with Fname.UF; use Fname.UF; with Lib; use Lib; @@ -471,6 +472,42 @@ package body Impunit is "g-zspche", -- GNAT.Wide_Wide_Spelling_Checker "g-zstspl"); -- GNAT.Wide_Wide_String_Split + ----------------------- + -- Alternative Units -- + ----------------------- + + -- For some implementation units, there is a unit in the GNAT library + -- that has identical functionality that is usable. If we have such a + -- case we record the appropriate Unit name in Error_Msg_String. + + type Aunit_Record is record + Fname : String (1 .. 6); + Aname : String_Ptr; + end record; + + -- Array of alternative unit names + + Scasuti : aliased String := "GNAT.Case_Util"; + Sos_lib : aliased String := "GNAT.OS_Lib"; + Sregexp : aliased String := "GNAT.Regexp"; + Sregpat : aliased String := "GNAT.Regpat"; + Sstring : aliased String := "GNAT.Strings"; + Sstusta : aliased String := "GNAT.Task_Stack_Usage"; + Stasloc : aliased String := "GNAT.Task_Lock"; + Sutf_32 : aliased String := "GNAT.UTF_32"; + + -- Array giving mapping + + Map_Array : constant array (1 .. 8) of Aunit_Record := ( + ("casuti", Scasuti'Access), + ("os_lib", Sos_lib'Access), + ("regexp", Sregexp'Access), + ("regpat", Sregpat'Access), + ("string", Sstring'Access), + ("stusta", Sstusta'Access), + ("tasloc", Stasloc'Access), + ("utf_32", Sutf_32'Access)); + ---------------------- -- Get_Kind_Of_Unit -- ---------------------- @@ -479,6 +516,8 @@ package body Impunit is Fname : constant File_Name_Type := Unit_File_Name (U); begin + Error_Msg_Strlen := 0; + -- If length of file name is greater than 12, not predefined. -- The value 12 here is an 8 char name with extension .ads. @@ -559,7 +598,23 @@ package body Impunit is return Ada_95_Unit; end if; - -- All tests failed, this is definitely an implementation unit + -- All tests failed, this is definitely an implementation unit. See if + -- we have an alternative name. + + Get_Name_String (Fname); + + if Name_Len = 12 + and then Name_Buffer (1 .. 2) = "s-" + and then Name_Buffer (9 .. 12) = ".ads" + then + for J in Map_Array'Range loop + if Name_Buffer (3 .. 8) = Map_Array (J).Fname then + Error_Msg_Strlen := Map_Array (J).Aname'Length; + Error_Msg_String (1 .. Error_Msg_Strlen) := + Map_Array (J).Aname.all; + end if; + end loop; + end if; return Implementation_Unit; end Get_Kind_Of_Unit; diff --git a/gcc/ada/impunit.ads b/gcc/ada/impunit.ads index f5a706d43ae..f342b79962c 100644 --- a/gcc/ada/impunit.ads +++ b/gcc/ada/impunit.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2000-2007, Free Software Foundation, Inc. -- +-- Copyright (C) 2000-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -55,7 +55,11 @@ package Impunit is function Get_Kind_Of_Unit (U : Unit_Number_Type) return Kind_Of_Unit; -- Given the unit number of a unit, this function determines the type - -- of the unit, as defined above. + -- of the unit, as defined above. If the result is Implementation_Unit, + -- then the name of a possible atlernative equivalent unit is placed in + -- Error_Msg_String/Slen on return. If there is no alternative name, or + -- if the result is not Implementation_Unit, then Error_Msg_Slen is zero + -- on return, indicating that no alternative name was found. function Is_Known_Unit (Nam : Node_Id) return Boolean; -- Nam is the possible name of a child unit, represented as a selected diff --git a/gcc/ada/lib-load.adb b/gcc/ada/lib-load.adb index ee956dc3f77..535dddc6e8b 100644 --- a/gcc/ada/lib-load.adb +++ b/gcc/ada/lib-load.adb @@ -396,7 +396,7 @@ package body Lib.Load is begin while Nkind (Par) = N_Selected_Component and then Chars (Selector_Name (Par)) /= - Chars (Cunit_Entity (Unump)) + Chars (Cunit_Entity (Unump)) loop Par := Prefix (Par); end loop; @@ -694,6 +694,9 @@ package body Lib.Load is -- Remove load stack entry and return the entry in the file table Load_Stack.Decrement_Last; + + -- All done, return unit number + return Unum; -- Case of file not found diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb index f248c05cedc..94d4b455526 100644 --- a/gcc/ada/lib-writ.adb +++ b/gcc/ada/lib-writ.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -38,6 +38,7 @@ with Opt; use Opt; with Osint; use Osint; with Osint.C; use Osint.C; with Par; +with Par_SCO; use Par_SCO; with Restrict; use Restrict; with Rident; use Rident; with Scn; use Scn; @@ -1229,7 +1230,19 @@ package body Lib.Writ is end loop; end; + -- Output cross-references + Output_References; + + -- Output SCO information if present + + if Generate_SCO then + SCO_Output; + end if; + + -- Output final blank line and we are done. This final blank line is + -- probably junk, but we don't feel like making an incompatible change! + Write_Info_Terminate; Close_Output_Library_Info; end Write_ALI; diff --git a/gcc/ada/lib-writ.ads b/gcc/ada/lib-writ.ads index e0c0f34427d..5a15fd302df 100644 --- a/gcc/ada/lib-writ.ads +++ b/gcc/ada/lib-writ.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -31,15 +31,15 @@ package Lib.Writ is -- Format of Library Information -- ----------------------------------- - -- This section describes the format of the library information that is + -- This section describes the format of the library information that is -- associated with object files. The exact method of this association is - -- potentially implementation dependent and is described and implemented - -- in package ali. From the point of view of the description here, all we - -- need to know is that the information is represented as a string of - -- characters that is somehow associated with an object file, and can be - -- retrieved. If no library information exists for a given object file, - -- then we take this as equivalent to the non-existence of the object - -- file, as if source file has not been previously compiled. + -- potentially implementation dependent and is described and implemented in + -- package ali. From the point of view of the description here, all we need + -- to know is that the information is represented as a string of characters + -- that is somehow associated with an object file, and can be retrieved. If + -- no library information exists for a given object file, then we take this + -- as equivalent to the non-existence of the object file, as if source file + -- has not been previously compiled. -- The library information is written as a series of lines of the form: @@ -51,49 +51,48 @@ package Lib.Writ is -- Making Changes to the ALI Format -- -------------------------------------- - -- A number of tools use ali.adb to parse ali files. This means - -- that changes to this format can cause old versions of these tools - -- to be incompatible with new versions of the compiler. Any changes - -- to ali file formats must be carefully evaluated to understand any - -- such possible conflicts, and in particular, it is very undesirable - -- to create conflicts between older versions of GPS and newer versions - -- of the compiler. + -- A number of tools use ali.adb to parse ali files. This means that + -- changes to this format can cause old versions of these tools to be + -- incompatible with new versions of the compiler. Any changes to ali file + -- formats must be carefully evaluated to understand any such possible + -- conflicts, and in particular, it is very undesirable to create conflicts + -- between older versions of GPS and newer versions of the compiler. -- If the following guidelines are respected, downward compatibility -- problems (old tools reading new ali files) should be minimized: -- The basic key character format must be kept - -- The V line must be the first line, this is checked by ali.adb - -- even in Ignore_Errors mode, and is used to verify that the file - -- at hand is indeed likely intended to be an ali file. + -- The V line must be the first line, this is checked by ali.adb even in + -- Ignore_Errors mode, and is used to verify that the file at hand is + -- indeed likely intended to be an ali file. -- The P line must be present, though may be modified in contents - -- according to remaining guidelines. Again, ali.adb assumes the - -- P line is present even in Ignore_Errors mode. + -- according to remaining guidelines. Again, ali.adb assumes the P + -- line is present even in Ignore_Errors mode. - -- New modifiers can generally be added (in particular adding new - -- two letter modifiers to the P or U lines is always safe) + -- New modifiers can generally be added (in particular adding new two + -- letter modifiers to the P or U lines is always safe) - -- Adding entirely new lines (with a new key letter) to the ali - -- file is always safe, at any point (other than before the V - -- line), since such lines will be ignored. + -- Adding entirely new lines (with a new key letter) to the ali file is + -- always safe, at any point (other than before the V line), since such + -- lines will be ignored. - -- Following the guidelines in this section should ensure that this - -- problem is minimized and that old tools will be able to deal - -- successfully with new ali formats. Note that this does not apply - -- to the compiler itself, which always requires consistency between - -- the ali files and the binder. That is because one of the main - -- functions of the binder is to ensure consistency of the partition, - -- and this can be compromised if the ali files are inconsistent. + -- Following the guidelines in this section should ensure that this problem + -- is minimized and that old tools will be able to deal successfully with + -- new ali formats. Note that this does not apply to the compiler itself, + -- which always requires consistency between the ali files and the binder. + -- That is because one of the main functions of the binder is to ensure + -- consistency of the partition, and this can be compromised if the ali + -- files are inconsistent. ------------------ -- Header Lines -- ------------------ -- The initial header lines in the file give information about the - -- compilation environment, and identify other special information - -- such as main program parameters. + -- compilation environment, and identify other special information such as + -- main program parameters. -- ---------------- -- -- V Version -- @@ -104,10 +103,10 @@ package Lib.Writ is -- This line indicates the library output version, as defined in -- Gnatvsn. It ensures that separate object modules of a program are -- consistent. It has to be changed if anything changes which would - -- affect successful binding of separately compiled modules. - -- Examples of such changes are modifications in the format of the - -- library info described in this package, or modifications to - -- calling sequences, or to the way that data is represented. + -- affect successful binding of separately compiled modules. Examples + -- of such changes are modifications in the format of the library info + -- described in this package, or modifications to calling sequences, or + -- to the way that data is represented. -- Note: the V line absolutely must be the first line, and no change -- to the ALI format should change this, since even in Ignore_Errors @@ -119,8 +118,8 @@ package Lib.Writ is -- M type [priority] [T=time-slice] W=? - -- This line appears only if the main unit for this file is - -- suitable for use as a main program. The parameters are: + -- This line appears only if the main unit for this file is suitable + -- for use as a main program. The parameters are: -- type @@ -131,24 +130,24 @@ package Lib.Writ is -- priority -- Present only if there was a valid pragma Priority in the - -- corresponding unit to set the main task priority. It is - -- an unsigned decimal integer. + -- corresponding unit to set the main task priority. It is an + -- unsigned decimal integer. -- T=time-slice -- Present only if there was a valid pragma Time_Slice in the - -- corresponding unit. It is an unsigned decimal integer in - -- the range 0 .. 10**9 giving the time slice value in units - -- of milliseconds. The actual significance of this parameter - -- is target dependent. + -- corresponding unit. It is an unsigned decimal integer in the + -- range 0 .. 10**9 giving the time slice value in units of + -- milliseconds. The actual significance of this parameter is + -- target dependent. -- W=? - -- This parameter indicates the wide character encoding - -- method used when compiling the main program file. The ? - -- character is the single character used in the -gnatW? - -- switch. This is used to provide the default wide-character - -- encoding for Wide_Text_IO files. + -- This parameter indicates the wide character encoding method used + -- when compiling the main program file. The ? character is the + -- single character used in the -gnatW? switch. This is used to + -- provide the default wide-character encoding for Wide_Text_IO + -- files. -- ----------------- -- -- A Argument -- @@ -156,9 +155,9 @@ package Lib.Writ is -- A argument - -- One of these lines appears for each of the arguments present - -- in the call to the gnat1 program. This can be used if it is - -- necessary to reconstruct this call (e.g. for fix and continue) + -- One of these lines appears for each of the arguments present in the + -- call to the gnat1 program. This can be used if it is necessary to + -- reconstruct this call (e.g. for fix and continue) -- ------------------- -- -- P Parameters -- @@ -166,44 +165,44 @@ package Lib.Writ is -- P <<parameters>> - -- Indicates various information that applies to the compilation - -- of the corresponding source file. Parameters is a sequence of - -- zero or more two letter codes that indicate configuration - -- pragmas and other parameters that apply: + -- Indicates various information that applies to the compilation of the + -- corresponding source file. Parameters is a sequence of zero or more + -- two letter codes that indicate configuration pragmas and other + -- parameters that apply: -- -- The arguments are as follows: -- - -- CE Compilation errors. If this is present it means that the - -- ali file resulted from a compilation with the -gnatQ - -- switch set, and illegalities were detected. The ali - -- file contents may not be completely reliable, but the - -- format will be correct and complete. Note that NO is - -- always present if CE is present. + -- CE Compilation errors. If this is present it means that the ali + -- file resulted from a compilation with the -gnatQ switch set, + -- and illegalities were detected. The ali file contents may + -- not be completely reliable, but the format will be correct + -- and complete. Note that NO is always present if CE is + -- present. -- - -- DB Detect_Blocking pragma is in effect for all units in - -- this file. + -- DB Detect_Blocking pragma is in effect for all units in this + -- file. -- - -- FD Configuration pragmas apply to all the units in this - -- file specifying a possibly non-standard floating point - -- format (VAX float with Long_Float using D_Float) + -- FD Configuration pragmas apply to all the units in this file + -- specifying a possibly non-standard floating point format + -- (VAX float with Long_Float using D_Float). -- - -- FG Configuration pragmas apply to all the units in this - -- file specifying a possibly non-standard floating point - -- format (VAX float with Long_Float using G_Float) + -- FG Configuration pragmas apply to all the units in this file + -- specifying a possibly non-standard floating point format + -- (VAX float with Long_Float using G_Float). -- - -- FI Configuration pragmas apply to all the units in this - -- file specifying a possibly non-standard floating point - -- format (IEEE Float) + -- FI Configuration pragmas apply to all the units in this file + -- specifying a possibly non-standard floating point format + -- (IEEE Float). -- - -- Lx A valid Locking_Policy pragma applies to all the units - -- in this file, where x is the first character (upper case) - -- of the policy name (e.g. 'C' for Ceiling_Locking) + -- Lx A valid Locking_Policy pragma applies to all the units in + -- this file, where x is the first character (upper case) of + -- the policy name (e.g. 'C' for Ceiling_Locking). -- - -- NO No object. This flag indicates that the units in this - -- file were not compiled to produce an object. This can - -- occur as a result of the use of -gnatc, or if no object - -- can be produced (e.g. when a package spec is compiled - -- instead of the body, or a subunit on its own). + -- NO No object. This flag indicates that the units in this file + -- were not compiled to produce an object. This can occur as a + -- result of the use of -gnatc, or if no object can be produced + -- (e.g. when a package spec is compiled instead of the body, + -- or a subunit on its own). -- -- NR No_Run_Time. Indicates that a pragma No_Run_Time applies -- to all units in the file. @@ -241,9 +240,9 @@ package Lib.Writ is -- possible cases. These values are checked for consistency by the -- binder and then copied to the generated binder output file. - -- Note: The P line must be present. Even in Ignore_Errors mode, - -- Scan_ALI insists on finding a P line. So if changes are made to - -- the ALI format, they should not include removing the P line! + -- Note: The P line must be present. Even in Ignore_Errors mode, Scan_ALI + -- insists on finding a P line. So if changes are made to the ALI format, + -- they should not include removing the P line! -- --------------------- -- -- R Restrictions -- @@ -257,61 +256,58 @@ package Lib.Writ is -- R <<restriction-characters>> <<restriction-param-id-entries>> -- The first parameter is a string of characters that records - -- information regarding restrictions that do not take parameter - -- not take parameter values. It is a string of characters, one - -- character for each value (in order) in All_Boolean_Restrictions. - -- There are three possible settings for each restriction: + -- information regarding restrictions that do not take parameter not + -- take parameter values. It is a string of characters, one character + -- for each value (in order) in All_Boolean_Restrictions. There are + -- three possible settings for each restriction: -- r Restricted. Unit was compiled under control of a pragma - -- Restrictions for the corresponding restriction. In - -- this case the unit certainly does not violate the - -- Restriction, since this would have been detected by - -- the compiler. + -- Restrictions for the corresponding restriction. In this case + -- the unit certainly does not violate the Restriction, since + -- this would have been detected by the compiler. - -- n Not used. The unit was not compiled under control of a - -- pragma Restrictions for the corresponding restriction, - -- and does not make any use of the referenced feature. + -- n Not used. The unit was not compiled under control of a pragma + -- Restrictions for the corresponding restriction, and does not + -- make any use of the referenced feature. - -- v Violated. The unit was not compiled under control of a - -- pragma Restrictions for the corresponding restriction, - -- and it does indeed use the referenced feature. + -- v Violated. The unit was not compiled under control of a pragma + -- Restrictions for the corresponding restriction, and it does + -- indeed use the referenced feature. - -- This information is used in the binder to check consistency, - -- i.e. to detect cases where one unit has "r" and another unit - -- has "v", which is not permitted, since these restrictions - -- are partition-wide. + -- This information is used in the binder to check consistency, i.e. to + -- detect cases where one unit has "r" and another unit has "v", which + -- is not permitted, since these restrictions are partition-wide. - -- The second parameter, which immediately follows the first (with - -- no separating space) gives restriction information for identifiers - -- for which a parameter is given. + -- The second parameter, which immediately follows the first (with no + -- separating space) gives restriction information for identifiers for + -- which a parameter is given. -- The parameter is a string of entries, one for each value in - -- Restrict.All_Parameter_Restrictions. Each entry has two - -- components in sequence, the first indicating whether or not - -- there is a restriction, and the second indicating whether - -- or not the compiler detected violations. In the boolean case - -- it is not necessary to separate these, since if a restriction - -- is set, and violated, that is an error. But in the parameter - -- case, this is not true. For example, we can have a unit with - -- a pragma Restrictions (Max_Tasks => 4), where the compiler - -- can detect that there are exactly three tasks declared. Both - -- of these pieces of information must be passed to the binder. - -- The parameter of 4 is important in case the total number of - -- tasks in the partition is greater than 4. The parameter of - -- 3 is important in case some other unit has a restrictions - -- pragma with Max_Tasks=>2. + -- Restrict.All_Parameter_Restrictions. Each entry has two components + -- in sequence, the first indicating whether or not there is a + -- restriction, and the second indicating whether or not the compiler + -- detected violations. In the boolean case it is not necessary to + -- separate these, since if a restriction is set, and violated, that is + -- an error. But in the parameter case, this is not true. For example, + -- we can have a unit with a pragma Restrictions (Max_Tasks => 4), + -- where the compiler can detect that there are exactly three tasks + -- declared. Both of these pieces of information must be passed to the + -- binder. The parameter of 4 is important in case the total number of + -- tasks in the partition is greater than 4. The parameter of 3 is + -- important in case some other unit has a restrictions pragma with + -- Max_Tasks=>2. -- The component for the presence of restriction has one of two -- possible forms: - -- n No pragma for this restriction is present in the - -- set of units for this ali file. + -- n No pragma for this restriction is present in the set of units + -- for this ali file. - -- rN At least one pragma for this restriction is present - -- in the set of units for this ali file. The value N - -- is the minimum parameter value encountered in any - -- such pragma. N is in the range of Integer (a value - -- larger than N'Last causes the pragma to be ignored). + -- rN At least one pragma for this restriction is present in the + -- set of units for this ali file. The value N is the minimum + -- parameter value encountered in any such pragma. N is in the + -- range of Integer (a value larger than N'Last causes the + -- pragma to be ignored). -- The component for the violation detection has one of three -- possible forms: @@ -319,12 +315,12 @@ package Lib.Writ is -- n No violations were detected by the compiler -- vN A violation was detected. N is either the maximum or total - -- count of violations (depending on the checking type) in - -- all the units represented by the ali file). Note that - -- this setting is only allowed for restrictions that are - -- in Checked_[Max|Sum]_Parameter_Restrictions. The value - -- here is known to be exact by the compiler and is in the - -- range of Natural. + -- count of violations (depending on the checking type) in all + -- the units represented by the ali file). Note that this + -- setting is only allowed for restrictions that are in + -- Checked_[Max|Sum]_Parameter_Restrictions. The value here is + -- known to be exact by the compiler and is in the range of + -- Natural. -- vN+ A violation was detected. The compiler cannot determine -- the exact count of violations, but it is at least N. @@ -354,18 +350,18 @@ package Lib.Writ is -- I interrupt-number interrupt-state line-number - -- This line records information from an Interrupt_State pragma. - -- There is one line for each separate pragma, and if no such - -- pragmas are used, then no I lines are present. + -- This line records information from an Interrupt_State pragma. There + -- is one line for each separate pragma, and if no such pragmas are + -- used, then no I lines are present. - -- The interrupt-number is an unsigned positive integer giving - -- the value of the interrupt as defined in Ada.Interrupts.Names. + -- The interrupt-number is an unsigned positive integer giving the + -- value of the interrupt as defined in Ada.Interrupts.Names. -- The interrupt-state is one of r/s/u for Runtime/System/User - -- The line number is an unsigned decimal integer giving the - -- line number of the corresponding Interrupt_State pragma. - -- This is used in consistency messages. + -- The line number is an unsigned decimal integer giving the line + -- number of the corresponding Interrupt_State pragma. This is used + -- in consistency messages. -- ------------------------------------- -- -- S Priority Specific Dispatching -- @@ -383,23 +379,22 @@ package Lib.Writ is -- The first_priority and last_priority fields define the range of -- priorities to which the specified dispatching policy apply. - -- The line number is an unsigned decimal integer giving the - -- line number of the corresponding Priority_Specific_Dispatching - -- pragma. This is used in consistency messages. + -- The line number is an unsigned decimal integer giving the line + -- number of the corresponding Priority_Specific_Dispatching pragma. + -- This is used in consistency messages. ---------------------------- -- Compilation Unit Lines -- ---------------------------- -- Following these header lines, a set of information lines appears for - -- each compilation unit that appears in the corresponding object file. - -- In particular, when a package body or subprogram body is compiled, - -- there will be two sets of information, one for the spec and one for - -- the body, with the entry for the body appearing first. This is the - -- only case in which a single ALI file contains more than one unit (in - -- particular note that subunits do *not* count as compilation units for - -- this purpose, and generate no library information, since they are - -- inlined). + -- each compilation unit that appears in the corresponding object file. In + -- particular, when a package body or subprogram body is compiled, there + -- will be two sets of information, one for the spec and one for the body, + -- with the entry for the body appearing first. This is the only case in + -- which a single ALI file contains more than one unit (in particular note + -- that subunits do *not* count as compilation units for this purpose, and + -- generate no library information, since they are inlined). -- -------------------- -- -- U Unit Header -- @@ -409,15 +404,14 @@ package Lib.Writ is -- U unit-name source-name version <<attributes>> -- - -- This line identifies the unit to which this section of the - -- library information file applies. The first three parameters are - -- the unit name in internal format, as described in package Uname, - -- and the name of the source file containing the unit. + -- This line identifies the unit to which this section of the library + -- information file applies. The first three parameters are the unit + -- name in internal format, as described in package Uname, and the name + -- of the source file containing the unit. -- - -- Version is the version given as eight hexadecimal characters - -- with upper case letters. This value is the exclusive or of the - -- source checksums of the unit and all its semantically dependent - -- units. + -- Version is the version given as eight hexadecimal characters with + -- upper case letters. This value is the exclusive or of the source + -- checksums of the unit and all its semantically dependent units. -- -- The <<attributes>> are a series of two letter codes indicating -- information about the unit: @@ -430,47 +424,47 @@ package Lib.Writ is -- not promise, to keep the elaboration of the body close to -- the elaboration of the spec. -- - -- DE Dynamic Elaboration. This unit was compiled with the - -- dynamic elaboration model, as set by either the -gnatE - -- switch or pragma Elaboration_Checks (Dynamic). + -- DE Dynamic Elaboration. This unit was compiled with the dynamic + -- elaboration model, as set by either the -gnatE switch or + -- pragma Elaboration_Checks (Dynamic). -- - -- EB Unit has pragma Elaborate_Body, or is a generic instance - -- that has a body. Set for instances because RM 12.3(20) - -- requires that the body be immediately elaborated after the - -- spec (we would normally do that anyway, because elaborate - -- spec and body together whenever possible, and for an instance - -- it is always possible; however setting EB ensures that this - -- is done even when using the -p gnatbind switch). + -- EB Unit has pragma Elaborate_Body, or is a generic instance that + -- has a body. Set for instances because RM 12.3(20) requires + -- that the body be immediately elaborated after the spec (we + -- would normally do that anyway, because elaborate spec and + -- body together whenever possible, and for an instance it is + -- always possible; however setting EB ensures that this is done + -- even when using the -p gnatbind switch). -- -- EE Elaboration entity is present which must be set true when - -- the unit is elaborated. The name of the elaboration entity - -- is formed from the unit name in the usual way. If EE is - -- present, then this boolean must be set True as part of the - -- elaboration processing routine generated by the binder. - -- Note that EE can be set even if NE is set. This happens - -- when the boolean is needed solely for checking for the - -- case of access before elaboration. + -- the unit is elaborated. The name of the elaboration entity is + -- formed from the unit name in the usual way. If EE is present, + -- then this boolean must be set True as part of the elaboration + -- processing routine generated by the binder. Note that EE can + -- be set even if NE is set. This happens when the boolean is + -- needed solely for checking for the case of access before + -- elaboration. -- -- GE Unit is a generic declaration, or corresponding body -- - -- IL Unit source uses a style with identifiers in all lower - -- IU case (IL) or all upper case (IU). If the standard mixed- - -- case usage is detected, or the compiler cannot determine - -- the style, then no I parameter will appear. + -- IL Unit source uses a style with identifiers in all lower-case + -- IU (IL) or all upper case (IU). If the standard mixed-case usage + -- is detected, or the compiler cannot determine the style, then + -- no I parameter will appear. -- -- IS Initialize_Scalars pragma applies to this unit, or else there -- is at least one use of the Invalid_Value attribute. -- - -- KM Unit source uses a style with keywords in mixed case - -- KU (KM) or all upper case (KU). If the standard lower-case - -- usage is detected, or the compiler cannot determine the - -- style, then no K parameter will appear. + -- KM Unit source uses a style with keywords in mixed case (KM) + -- KU or all upper case (KU). If the standard lower-case usage is + -- is detected, or the compiler cannot determine the style, then + -- no K parameter will appear. -- - -- NE Unit has no elaboration routine. All subprogram bodies - -- and specs are in this category. Package bodies and specs - -- may or may not have NE set, depending on whether or not - -- elaboration code is required. Set if N_Compilation_Unit - -- node has flag Has_No_Elaboration_Code set. + -- NE Unit has no elaboration routine. All subprogram bodies and + -- specs are in this category. Package bodies and specs may or + -- may not have NE set, depending on whether or not elaboration + -- code is required. Set if N_Compilation_Unit node has flag + -- Has_No_Elaboration_Code set. -- -- OL The units in this file are compiled with a local pragma -- Optimize_Alignment, so no consistency requirement applies @@ -515,10 +509,10 @@ package Lib.Writ is -- W unit-name [source-name lib-name] [E] [EA] [ED] [AD] -- - -- One of these lines is present for each unit that is mentioned in - -- an explicit with clause by the current unit. The first parameter is - -- the unit name in internal format. The second parameter is the file - -- name of the file that must be compiled to compile this unit. It is + -- One of these lines is present for each unit that is mentioned in an + -- explicit with clause by the current unit. The first parameter is the + -- unit name in internal format. The second parameter is the file name + -- of the file that must be compiled to compile this unit. It is -- usually the file for the body, except for packages which have no -- body. For units that need a body, if the source file for the body -- cannot be found, the file name of the spec is used instead. The @@ -530,21 +524,20 @@ package Lib.Writ is -- -- EA pragma Elaborate_All applies to this unit -- - -- ED Elaborate_Desirable set for this unit, which means - -- that there is no Elaborate, but the analysis suggests - -- that Program_Error may be raised if the Elaborate - -- conditions cannot be satisfied. The binder will attempt - -- to treat ED as E if it can. + -- ED Elaborate_Desirable set for this unit, which means that there + -- is no Elaborate, but the analysis suggests that Program_Error + -- may be raised if the Elaborate conditions cannot be satisfied. + -- The binder will attempt to treat ED as E if it can. -- - -- AD Elaborate_All_Desirable set for this unit, which means - -- that there is no Elaborate_All, but the analysis suggests - -- that Program_Error may be raised if the Elaborate_All - -- conditions cannot be satisfied. The binder will attempt - -- to treat AD as EA if it can. + -- AD Elaborate_All_Desirable set for this unit, which means that + -- there is no Elaborate_All, but the analysis suggests that + -- Program_Error may be raised if the Elaborate_All conditions + -- cannot be satisfied. The binder will attempt to treat AD as + -- EA if it can. -- - -- The parameter source-name and lib-name are omitted for the case - -- of a generic unit compiled with earlier versions of GNAT which - -- did not generate object or ali files for generics. + -- The parameter source-name and lib-name are omitted for the case of a + -- generic unit compiled with earlier versions of GNAT which did not + -- generate object or ali files for generics. -- In fact W lines include implicit withs ??? @@ -552,11 +545,10 @@ package Lib.Writ is -- -- L Linker_Options -- -- ----------------------- - -- Following the W lines (if any, or the U line if not), are an - -- optional series of lines that indicates the usage of the pragma - -- Linker_Options in the associated unit. For each appearance of a - -- pragma Linker_Options (or Link_With) in the unit, a line is - -- present with the form: + -- Following the W lines (if any, or the U line if not), are an optional + -- series of lines that indicates the usage of the pragma Linker_Options in + -- the associated unit. For each appearance of a pragma Linker_Options (or + -- Link_With) in the unit, a line is present with the form: -- L "string" @@ -570,42 +562,39 @@ package Lib.Writ is -- to separate multiple arguments of a single -- Linker_Options pragma. - -- For further details, see Stringt.Write_String_Table_Entry. Note - -- that wide characters in the form {hhhh} cannot be produced, since - -- pragma Linker_Option accepts only String, not Wide_String. + -- For further details, see Stringt.Write_String_Table_Entry. Note that + -- wide characters in the form {hhhh} cannot be produced, since pragma + -- Linker_Option accepts only String, not Wide_String. -- The L lines are required to appear in the same order as the - -- corresponding Linker_Options (or Link_With) pragmas appear in - -- the source file, so that this order is preserved by the binder - -- in constructing the set of linker arguments. + -- corresponding Linker_Options (or Link_With) pragmas appear in the + -- source file, so that this order is preserved by the binder in + -- constructing the set of linker arguments. --------------------- -- Reference Lines -- --------------------- - -- The reference lines contain information about references from - -- any of the units in the compilation (including, body version - -- and version attributes, linker options pragmas and source - -- dependencies. + -- The reference lines contain information about references from any of the + -- units in the compilation (including, body version and version + -- attributes, linker options pragmas and source dependencies. -- ------------------------------------ -- -- E External Version References -- -- ------------------------------------ - -- One of these lines is present for each use of 'Body_Version or - -- 'Version in any of the units of the compilation. These are used - -- by the linker to determine which version symbols must be output. - -- The format is simply: + -- One of these lines is present for each use of 'Body_Version or 'Version + -- in any of the units of the compilation. These are used by the linker to + -- determine which version symbols must be output. The format is simply: -- E name - -- where name is the external name, i.e. the unit name with either - -- a S or a B for spec or body version referenced (Body_Version - -- always references the body, Version references the Spec, except - -- in the case of a reference to a subprogram with no separate spec). - -- Upper half and wide character codes are encoded using the same - -- method as in Namet (Uhh for upper half, Whhhh for wide character, - -- where hh are hex digits). + -- where name is the external name, i.e. the unit name with either a S or a + -- B for spec or body version referenced (Body_Version always references + -- the body, Version references the Spec, except in the case of a reference + -- to a subprogram with no separate spec). Upper half and wide character + -- codes are encoded using the same method as in Namet (Uhh for upper half, + -- Whhhh for wide character, where hh are hex digits). -- --------------------- -- -- D Dependencies -- @@ -617,55 +606,60 @@ package Lib.Writ is -- D source-name time-stamp checksum [subunit-name] line:file-name - -- The time-stamp field contains the time stamp of the - -- corresponding source file. See types.ads for details on - -- time stamp representation. + -- The time-stamp field contains the time stamp of the corresponding + -- source file. See types.ads for details on time stamp representation. - -- The checksum is an 8-hex digit representation of the source - -- file checksum, with letters given in lower case. + -- The checksum is an 8-hex digit representation of the source file + -- checksum, with letters given in lower case. - -- The subunit name is present only if the dependency line is for - -- a subunit. It contains the fully qualified name of the subunit - -- in all lower case letters. + -- The subunit name is present only if the dependency line is for a + -- subunit. It contains the fully qualified name of the subunit in all + -- lower case letters. -- The line:file-name entry is present only if a Source_Reference - -- pragma appeared in the source file identified by source-name. - -- In this case, it gives the information from this pragma. Note - -- that this allows cross-reference information to be related back - -- to the original file. Note: the reason the line number comes - -- first is that a leading digit immediately identifies this as - -- a Source_Reference entry, rather than a subunit-name. - - -- A line number of zero for line: in this entry indicates that - -- there is more than one source reference pragma. In this case, - -- the line numbers in the cross-reference are correct, and refer - -- to the original line number, but there is no information that - -- allows a reader of the ALI file to determine the exact mapping - -- of physical line numbers back to the original source. + -- pragma appeared in the source file identified by source-name. In + -- this case, it gives the information from this pragma. Note that this + -- allows cross-reference information to be related back to the + -- original file. Note: the reason the line number comes first is that + -- a leading digit immediately identifies this as a Source_Reference + -- entry, rather than a subunit-name. + + -- A line number of zero for line: in this entry indicates that there + -- is more than one source reference pragma. In this case, the line + -- numbers in the cross-reference are correct, and refer to the + -- original line number, but there is no information that allows a + -- reader of the ALI file to determine the exact mapping of physical + -- line numbers back to the original source. -- Files with a zero checksum and a non-zero time stamp are in general -- files on which the compilation depends but which are not Ada files -- with further dependencies. This includes preprocessor data files -- and preprocessor definition files. - -- Note: blank lines are ignored when the library information is - -- read, and separate sections of the file are separated by blank - -- lines to ease readability. Blanks between fields are also - -- ignored. + -- Note: blank lines are ignored when the library information is read, + -- and separate sections of the file are separated by blank lines to + -- ease readability. Blanks between fields are also ignored. - -- For entries corresponding to files that were not present (and - -- thus resulted in error messages), or for files that are not - -- part of the dependency set, both the time stamp and checksum - -- are set to all zero characters. These dummy entries are ignored - -- by the binder in dependency checking, but must be present for - -- proper interpretation of the cross-reference data. + -- For entries corresponding to files that were not present (and thus + -- resulted in error messages), or for files that are not part of the + -- dependency set, both the time stamp and checksum are set to all zero + -- characters. These dummy entries are ignored by the binder in + -- dependency checking, but must be present for proper interpretation + -- of the cross-reference data. -------------------------- -- Cross-Reference Data -- -------------------------- - -- The cross-reference data follows the dependency lines. See - -- the spec of Lib.Xref for details on the format of this data. + -- The cross-reference data follows the dependency lines. See the spec of + -- Lib.Xref for details on the format of this data. + + --------------------------------- + -- Source Coverage Obligations -- + --------------------------------- + + -- The Source Coverage Obligation (SCO) information follows the cross- + -- reference data. See the spec of Par_SCO for full details of the format. ---------------------- -- Global_Variables -- @@ -698,9 +692,9 @@ package Lib.Writ is -- The table structure defined here stores one entry for each -- Priority_Specific_Dispatching pragma encountered either in the main - -- source or in an ancillary with'ed source. Since - -- have to be consistent across all units in a partition, we may - -- as well detect inconsistencies at compile time when we can. + -- source or in an ancillary with'ed source. Since have to be consistent + -- across all units in a partition, we may as well detect inconsistencies + -- at compile time when we can. type Specific_Dispatching_Entry is record Dispatching_Policy : Character; @@ -731,9 +725,9 @@ package Lib.Writ is ----------------- procedure Ensure_System_Dependency; - -- This procedure ensures that a dependency is created on system.ads. - -- Even if there is no semantic dependency, Targparm has read the - -- file to acquire target parameters, so we need a source dependency. + -- This procedure ensures that a dependency is created on system.ads. Even + -- if there is no semantic dependency, Targparm has read the file to + -- acquire target parameters, so we need a source dependency. procedure Write_ALI (Object : Boolean); -- This procedure writes the library information for the current main unit @@ -747,7 +741,7 @@ package Lib.Writ is -- the A lines in this file. procedure Add_Preprocessing_Dependency (S : Source_File_Index); - -- Indicate that there is a dependency to be added on a preprocessing - -- data file or on a preprocessing definition file. + -- Indicate that there is a dependency to be added on a preprocessing data + -- file or on a preprocessing definition file. end Lib.Writ; diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb index 0e45e2e2bf6..516fc55261f 100644 --- a/gcc/ada/lib-xref.adb +++ b/gcc/ada/lib-xref.adb @@ -1464,7 +1464,6 @@ package body Lib.Xref is if Name_Len /= Curlen then return True; - else return Name_Buffer (1 .. Curlen) /= Curnam (1 .. Curlen); end if; @@ -1543,7 +1542,7 @@ package body Lib.Xref is -- Used for {} or <> or () for type reference procedure Check_Type_Reference - (Ent : Entity_Id; + (Ent : Entity_Id; List_Interface : Boolean); -- Find whether there is a meaningful type reference for -- Ent, and display it accordingly. If List_Interface is @@ -1565,7 +1564,7 @@ package body Lib.Xref is -------------------------- procedure Check_Type_Reference - (Ent : Entity_Id; + (Ent : Entity_Id; List_Interface : Boolean) is begin @@ -2138,6 +2137,7 @@ package body Lib.Xref is begin Write_Info_Char ('['); + if Curru /= Gen_U then Write_Info_Nat (Dependency_Num (Gen_U)); Write_Info_Char ('|'); @@ -2231,7 +2231,7 @@ package body Lib.Xref is Output_Import_Export_Info (XE.Ent); end if; - Write_Info_Nat (Int (Get_Column_Number (XE.Loc))); + Write_Info_Nat (Int (Get_Column_Number (XE.Loc))); Output_Instantiation_Refs (Sloc (XE.Ent)); end if; diff --git a/gcc/ada/lib-xref.ads b/gcc/ada/lib-xref.ads index 01e227c047f..b494454e38e 100644 --- a/gcc/ada/lib-xref.ads +++ b/gcc/ada/lib-xref.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1998-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -42,7 +42,7 @@ package Lib.Xref is -- X dependency-number filename -- This header precedes xref information (entities/references from - -- the unit, identified by dependency number and file name. The + -- the unit), identified by dependency number and file name. The -- dependency number is the index into the generated D lines and -- is ones origin (i.e. 2 = reference to second generated D line). diff --git a/gcc/ada/lib.ads b/gcc/ada/lib.ads index 145d16dff08..9c36d91ff35 100644 --- a/gcc/ada/lib.ads +++ b/gcc/ada/lib.ads @@ -295,7 +295,7 @@ package Lib is -- order. The number is ones origin, so a value of 2 refers to the -- second generated D line. The Dependency_Number values are set -- as the D lines are generated, and are used to generate proper - -- unit references in the generated xref information. + -- unit references in the generated xref information and SCO output. -- Dynamic_Elab -- A flag indicating if this unit was compiled with dynamic elaboration diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb index c1afc14e17d..1d96af98189 100644 --- a/gcc/ada/make.adb +++ b/gcc/ada/make.adb @@ -2979,7 +2979,9 @@ package body Make is Comp_Next := Comp_Next + 1; -- Optimize the simple case where the gcc command line looks like - -- gcc -c -I. ... -I- file.adb --into-> gcc -c ... file.adb + -- gcc -c -I. ... -I- file.adb + -- into + -- gcc -c ... file.adb if Args (Args'First).all = "-I" & Normalized_CWD and then Args (Args'Last).all = "-I-" diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 906a782022e..d184da9aa54 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -550,6 +550,12 @@ package Opt is -- True when switch -gnateG is used. When True, create in a file -- <source>.prep, if the source is preprocessed. + Generate_SCO : Boolean := False; + -- GNAT + -- True when switch -gnateS is used. When True, Source Coverage Obligation + -- (SCO) information is generated and output in the ALI file. See unit + -- Par_SCO for full details. + Generating_Code : Boolean := False; -- GNAT -- True if the frontend finished its work and has called the backend to diff --git a/gcc/ada/output.adb b/gcc/ada/output.adb index bb5f5ae50d9..141c12fb294 100644 --- a/gcc/ada/output.adb +++ b/gcc/ada/output.adb @@ -29,13 +29,7 @@ -- -- ------------------------------------------------------------------------------ --- Note: the pragma Warnings (Off) here is because ASIS compiles this unit --- without -gnatg, and System.OS_Lib is an implementation unit. This is a --- temporary kludge which will be better resolved later on ??? - -pragma Warnings (Off); with System.OS_Lib; use System.OS_Lib; -pragma Warnings (On); package body Output is diff --git a/gcc/ada/par-ch10.adb b/gcc/ada/par-ch10.adb index d90d27bfc4e..23cb1cd444c 100644 --- a/gcc/ada/par-ch10.adb +++ b/gcc/ada/par-ch10.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -243,6 +243,7 @@ package body Ch10 is if Token = Tok_Private then Private_Sloc := Token_Ptr; Set_Keyword_Casing (Current_Source_File, Determine_Token_Casing); + if Style_Check then Style.Check_Indentation; end if; @@ -321,6 +322,7 @@ package body Ch10 is -- it hasn't already been done on seeing a WITH or PRIVATE. Set_Keyword_Casing (Current_Source_File, Determine_Token_Casing); + if Style_Check then Style.Check_Indentation; end if; @@ -1059,7 +1061,6 @@ package body Ch10 is Set_Proper_Body (Subunit_Node, Body_Node); return Subunit_Node; - end P_Subunit; ------------------ diff --git a/gcc/ada/par-load.adb b/gcc/ada/par-load.adb index e21fb0434c6..9aa08423805 100644 --- a/gcc/ada/par-load.adb +++ b/gcc/ada/par-load.adb @@ -278,9 +278,14 @@ begin -- If this is a separate spec for the main unit, then we reset -- Main_Unit_Entity to point to the entity for this separate spec + -- and this is also where we generate the SCO's for this spec. if Cur_Unum = Main_Unit then Main_Unit_Entity := Cunit_Entity (Unum); + + if Generate_SCO then + SCO_Record (Unum); + end if; end if; -- If we don't find the spec, then if we have a subprogram body, we diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb index a323d7ad8c7..78ffd604ebd 100644 --- a/gcc/ada/par.adb +++ b/gcc/ada/par.adb @@ -35,6 +35,7 @@ with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Output; use Output; +with Par_SCO; use Par_SCO; with Scans; use Scans; with Scn; use Scn; with Sinput; use Sinput; @@ -50,9 +51,8 @@ with Tbuild; use Tbuild; -- Par -- --------- -function Par - (Configuration_Pragmas : Boolean) return List_Id -is +function Par (Configuration_Pragmas : Boolean) return List_Id is + Num_Library_Units : Natural := 0; -- Count number of units parsed (relevant only in syntax check only mode, -- since in semantics check mode only a single unit is permitted anyway) @@ -197,27 +197,27 @@ is -- Handling of Reserved Words Used as Identifiers -- ---------------------------------------------------- - -- Note: throughout the parser, the terms reserved word and keyword - -- are used interchangeably to refer to the same set of reserved - -- keywords (including until, protected, etc). + -- Note: throughout the parser, the terms reserved word and keyword are + -- used interchangeably to refer to the same set of reserved keywords + -- (including until, protected, etc). - -- If a reserved word is used in place of an identifier, the parser - -- where possible tries to recover gracefully. In particular, if the - -- keyword is clearly spelled using identifier casing, e.g. Until in - -- a source program using mixed case identifiers and lower case keywords, - -- then the keyword is treated as an identifier if it appears in a place - -- where an identifier is required. + -- If a reserved word is used in place of an identifier, the parser where + -- possible tries to recover gracefully. In particular, if the keyword is + -- clearly spelled using identifier casing, e.g. Until in a source program + -- using mixed case identifiers and lower case keywords, then the keyword + -- is treated as an identifier if it appears in a place where an identifier + -- is required. -- The situation is more complex if the keyword is spelled with normal - -- keyword casing. In this case, the parser is more reluctant to - -- consider it to be intended as an identifier, unless it has some - -- further confirmation. + -- keyword casing. In this case, the parser is more reluctant to consider + -- it to be intended as an identifier, unless it has some further + -- confirmation. -- In the case of an identifier appearing in the identifier list of a - -- declaration, the appearance of a comma or colon right after the - -- keyword on the same line is taken as confirmation. For an enumeration - -- literal, a comma or right paren right after the identifier is also - -- treated as adequate confirmation. + -- declaration, the appearance of a comma or colon right after the keyword + -- on the same line is taken as confirmation. For an enumeration literal, + -- a comma or right paren right after the identifier is also treated as + -- adequate confirmation. -- The following type is used in calls to Is_Reserved_Identifier and -- also to P_Defining_Identifier and P_Identifier. The default for all @@ -288,8 +288,8 @@ is -- uncomfortably on the above example). -- We have two approaches to helping to control this situation. First we - -- make every attempt to avoid swallowing the last END; if we can be - -- sure that some error will result from doing so. In particular, we won't + -- make every attempt to avoid swallowing the last END; if we can be sure + -- that some error will result from doing so. In particular, we won't -- accept the END; unless it is exactly correct (in particular it must not -- have incorrect name tokens), and we won't accept it if it is immediately -- followed by end of file, WITH or SEPARATE (all tokens that unmistakeably @@ -409,13 +409,13 @@ is -- Scope Table -- ----------------- - -- The scope table, also referred to as the scope stack, is used to - -- record the current scope context. It is organized as a stack, with - -- inner nested entries corresponding to higher entries on the stack. - -- An entry is made when the parser encounters the opening of a nested - -- construct (such as a record, task, package etc.), and then package - -- Par.Endh uses this stack to deal with END lines (including properly - -- dealing with END nesting errors). + -- The scope table, also referred to as the scope stack, is used to record + -- the current scope context. It is organized as a stack, with inner nested + -- entries corresponding to higher entries on the stack. An entry is made + -- when the parser encounters the opening of a nested construct (such as a + -- record, task, package etc.), and then package Par.Endh uses this stack + -- to deal with END lines (including properly dealing with END nesting + -- errors). type SS_End_Type is -- Type of end entry required for this scope. The last two entries are @@ -446,8 +446,8 @@ is Lreq : Boolean; -- A flag indicating whether the label, if present, is required to - -- appear on the end line. It is referenced only in the case of - -- Etyp = E_Name or E_Suspicious_Is where the name may or may not be + -- appear on the end line. It is referenced only in the case of Etyp is + -- equal to E_Name or E_Suspicious_Is where the name may or may not be -- required (yes for labeled block, no in other cases). Note that for -- all cases except begin, the question of whether a label is required -- can be determined from the other fields (for loop, it is required if @@ -456,10 +456,10 @@ is Ecol : Column_Number; -- Contains the absolute column number (with tabs expanded) of the - -- the expected column of the end assuming normal Ada indentation - -- usage. If the RM_Column_Check mode is set, this value is used for - -- generating error messages about indentation. Otherwise it is used - -- only to control heuristic error recovery actions. + -- expected column of the end assuming normal Ada indentation usage. If + -- the RM_Column_Check mode is set, this value is used for generating + -- error messages about indentation. Otherwise it is used only to + -- control heuristic error recovery actions. Labl : Node_Id; -- This field is used only for the LOOP and BEGIN cases, and is the @@ -479,21 +479,21 @@ is -- the proper location for implicit label declarations. Node : Node_Id; - -- Empty except in the case of entries for IF and CASE statements, - -- in which case it contains the N_If_Statement or N_Case_Statement - -- node. This is used for setting the End_Span field. + -- Empty except in the case of entries for IF and CASE statements, in + -- which case it contains the N_If_Statement or N_Case_Statement node. + -- This is used for setting the End_Span field. Sloc : Source_Ptr; - -- Source location of the opening token of the construct. This is - -- used to refer back to this line in error messages (such as missing - -- or incorrect end lines). The Sloc field is not used, and is not set, - -- if a label is present (the Labl field provides the text name of the + -- Source location of the opening token of the construct. This is used + -- to refer back to this line in error messages (such as missing or + -- incorrect end lines). The Sloc field is not used, and is not set, if + -- a label is present (the Labl field provides the text name of the -- label in this case, which is fine for error messages). S_Is : Source_Ptr; - -- S_Is is relevant only if Etyp is set to E_Suspicious_Is or - -- E_Bad_Is. It records the location of the IS that is considered - -- to be suspicious. + -- S_Is is relevant only if Etyp is set to E_Suspicious_Is or E_Bad_Is. + -- It records the location of the IS that is considered to be + -- suspicious. Junk : Boolean; -- A boolean flag that is set true if the opening entry is the dubious @@ -595,10 +595,9 @@ is -- removed the ACCESS token procedure P_Component_Items (Decls : List_Id); - -- Scan out one or more component items and append them to the - -- given list. Only scans out more than one declaration in the - -- case where the source has a single declaration with multiple - -- defining identifiers. + -- Scan out one or more component items and append them to the given + -- list. Only scans out more than one declaration in the case where the + -- source has a single declaration with multiple defining identifiers. function P_Defining_Identifier (C : Id_Check := None) return Node_Id; -- Scan out a defining identifier. The parameter C controls the @@ -619,6 +618,7 @@ is (Allow_Anonymous_In_95 : Boolean := False) return Boolean; -- Ada 2005 (AI-231): Parse the null-excluding part. A True result -- indicates that the null-excluding part was present. + -- -- Allow_Anonymous_In_95 is True if we are in a context that allows -- anonymous access types in Ada 95, in which case "not null" is legal -- if it precedes "access". @@ -730,8 +730,8 @@ is function P_Subprogram_Specification return Node_Id; procedure P_Mode (Node : Node_Id); - -- Sets In_Present and/or Out_Present flags in Node scanning past - -- IN, OUT or IN OUT tokens in the source. + -- Sets In_Present and/or Out_Present flags in Node scanning past IN, + -- OUT or IN OUT tokens in the source. function P_Subprogram (Pf_Flags : Pf_Rec) return Node_Id; -- Scans out any construct starting with either of the keywords @@ -782,19 +782,20 @@ is package Ch10 is function P_Compilation_Unit return Node_Id; - -- Note: this function scans a single compilation unit, and - -- checks that an end of file follows this unit, diagnosing - -- any unexpected input as an error, and then skipping it, so - -- that Token is set to Tok_EOF on return. An exception is in - -- syntax-only mode, where multiple compilation units are - -- permitted. In this case, P_Compilation_Unit does not check - -- for end of file and there may be more compilation units to - -- scan. The caller can uniquely detect this situation by the + -- Note: this function scans a single compilation unit, and checks that + -- an end of file follows this unit, diagnosing any unexpected input as + -- an error, and then skipping it, so that Token is set to Tok_EOF on + -- return. An exception is in syntax-only mode, where multiple + -- compilation units are permitted. In this case, P_Compilation_Unit + -- does not check for end of file and there may be more compilation + -- units to scan. The caller can uniquely detect this situation by the -- fact that Token is not set to Tok_EOF on return. -- - -- The Ignore parameter is normally set False. It is set True - -- in multiple unit per file mode if we are skipping past a unit - -- that we are not interested in. + -- What about multiple unit/file capability that now exists??? + -- + -- The Ignore parameter is normally set False. It is set True in the + -- multiple unit per file mode if we are skipping past a unit that we + -- are not interested in. end Ch10; -------------- @@ -807,8 +808,8 @@ is function Parse_Exception_Handlers return List_Id; -- Parses the partial construct EXCEPTION followed by a list of - -- exception handlers which appears in a number of productions, - -- and returns the list of exception handlers. + -- exception handlers which appears in a number of productions, and + -- returns the list of exception handlers. end Ch11; -------------- @@ -920,15 +921,15 @@ is -- left pointing to the semicolon rather than past it. procedure Resync_Past_Semicolon_Or_To_Loop_Or_Then; - -- Used if an error occurs while scanning a sequence of statements. - -- The scan pointer is positioned past the next semicolon, or to the - -- next occurrence of either then or loop, and the scan resumes. + -- Used if an error occurs while scanning a sequence of statements. The + -- scan pointer is positioned past the next semicolon, or to the next + -- occurrence of either then or loop, and the scan resumes. procedure Resync_To_When; - -- Used when an error occurs scanning an entry index specification. - -- The scan pointer is positioned to the next WHEN (or to IS or - -- semicolon if either of these appear before WHEN, indicating - -- another error has occurred). + -- Used when an error occurs scanning an entry index specification. The + -- scan pointer is positioned to the next WHEN (or to IS or semicolon if + -- either of these appear before WHEN, indicating another error has + -- occurred). procedure Resync_Semicolon_List; -- Used if an error occurs while scanning a parenthesized list of items @@ -1327,10 +1328,9 @@ begin if Ucount < Multiple_Unit_Index then - -- We skip in syntax check only mode, since we don't want - -- to do anything more than skip past the unit and ignore it. - -- This causes processing like setting up a unit table entry - -- to be skipped. + -- We skip in syntax check only mode, since we don't want to do + -- anything more than skip past the unit and ignore it. This means + -- we skip processing like setting up a unit table entry. declare Save_Operating_Mode : constant Operating_Mode_Type := @@ -1345,8 +1345,8 @@ begin Operating_Mode := Save_Operating_Mode; Style_Check := Save_Style_Check; - -- If we are at an end of file, and not yet at the right - -- unit, then we have a fatal error. The unit is missing. + -- If we are at an end of file, and not yet at the right unit, + -- then we have a fatal error. The unit is missing. if Token = Tok_EOF then Error_Msg_SC ("file has too few compilation units"); @@ -1354,9 +1354,9 @@ begin end if; end; - -- Here if we are not skipping a file in multiple unit per file - -- mode. Parse the unit that we are interested in. Note that in - -- check syntax mode we are interested in all units in the file. + -- Here if we are not skipping a file in multiple unit per file mode. + -- Parse the unit that we are interested in. Note that in check + -- syntax mode we are interested in all units in the file. else declare @@ -1364,14 +1364,14 @@ begin begin -- If parsing was successful and we are not in check syntax - -- mode, check that language defined units are compiled in - -- GNAT mode. For this purpose we do NOT consider renamings - -- in annex J as predefined. That allows users to compile - -- their own versions of these files, and in particular, - -- in the VMS implementation, the DEC versions can be - -- substituted for the standard Ada 95 versions. Another - -- exception is System.RPC and its children. This allows - -- a user to supply their own communication layer. + -- mode, check that language defined units are compiled in GNAT + -- mode. For this purpose we do NOT consider renamings in annex + -- J as predefined. That allows users to compile their own + -- versions of these files, and in particular, in the VMS + -- implementation, the DEC versions can be substituted for the + -- standard Ada 95 versions. Another exception is System.RPC + -- and its children. This allows a user to supply their own + -- communication layer. if Comp_Unit_Node /= Error and then Operating_Mode = Generate_Code @@ -1385,9 +1385,8 @@ begin Name : String (1 .. Uname'Length - 2); begin - -- Because Unit_Name includes "%s" or "%b", we need to - -- strip the last two characters to get the real unit - -- name. + -- Because Unit_Name includes "%s"/"%b", we need to strip + -- the last two characters to get the real unit name. Name := Uname (Uname'First .. Uname'Last - 2); @@ -1447,8 +1446,8 @@ begin Restore_Opt_Config_Switches (Save_Config_Switches); end loop; - -- Now that we have completely parsed the source file, we can - -- complete the source file table entry. + -- Now that we have completely parsed the source file, we can complete + -- the source file table entry. Complete_Source_File_Entry; @@ -1456,9 +1455,15 @@ begin pragma Assert (Scope.Last = 0); - -- Remaining steps are to create implicit label declarations and to - -- load required subsidiary sources. These steps are required only - -- if we are doing semantic checking. + -- Here we make the SCO table entries for the main unit + + if Generate_SCO then + SCO_Record (Main_Unit); + end if; + + -- Remaining steps are to create implicit label declarations and to load + -- required subsidiary sources. These steps are required only if we are + -- doing semantic checking. if Operating_Mode /= Check_Syntax or else Debug_Flag_F then Par.Labl; diff --git a/gcc/ada/par.ads b/gcc/ada/par.ads index cabc65b9e56..d3fc0e7303f 100644 --- a/gcc/ada/par.ads +++ b/gcc/ada/par.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -28,8 +28,7 @@ with Types; use Types; -function Par - (Configuration_Pragmas : Boolean) return List_Id; +function Par (Configuration_Pragmas : Boolean) return List_Id; -- Top level parsing routine. There are two cases: -- -- If Configuration_Pragmas is False, Par parses a compilation unit in the diff --git a/gcc/ada/par_sco.adb b/gcc/ada/par_sco.adb new file mode 100644 index 00000000000..663959de64d --- /dev/null +++ b/gcc/ada/par_sco.adb @@ -0,0 +1,1079 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT COMPILER COMPONENTS -- +-- -- +-- P A R _ S C O -- +-- -- +-- B o d y -- +-- -- +-- Copyright (C) 2009, Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT 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 distributed with GNAT; see file COPYING3. If not, go to -- +-- http://www.gnu.org/licenses for a complete copy of the license. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +with Atree; use Atree; +with Debug; use Debug; +with Lib; use Lib; +with Lib.Util; use Lib.Util; +with Nlists; use Nlists; +with Opt; use Opt; +with Output; use Output; +with Sinfo; use Sinfo; +with Sinput; use Sinput; +with Table; + +with GNAT.HTable; use GNAT.HTable; +with GNAT.Heap_Sort_G; + +package body Par_SCO is + + --------------- + -- SCO_Table -- + --------------- + + -- Internal table used to store recorded SCO values. Table is populated by + -- calls to SCO_Record, and entries may be modified by Set_SCO_Condition. + + type SCO_Table_Entry is record + From : Source_Ptr; + To : Source_Ptr; + C1 : Character; + C2 : Character; + Last : Boolean; + end record; + + package SCO_Table is new Table.Table ( + Table_Component_Type => SCO_Table_Entry, + Table_Index_Type => Nat, + Table_Low_Bound => 1, + Table_Initial => 500, + Table_Increment => 300, + Table_Name => "SCO_Table_Entry"); + + -- The SCO_Table_Entry values appear as follows: + + -- Statements + -- C1 = 'S' + -- C2 = ' ' + -- From = starting sloc + -- To = ending sloc + -- Last = unused + + -- Exit + -- C1 = 'T' + -- C2 = ' ' + -- From = starting sloc + -- To = ending sloc + -- Last = unused + + -- Simple Decision + -- C1 = 'I', 'E', 'W', 'X' (if/exit/while/expression) + -- C2 = 'c', 't', or 'f' + -- From = starting sloc + -- To = ending sloc + -- Last = True + + -- Complex Decision + -- C1 = 'I', 'E', 'W', 'X' (if/exit/while/expression) + -- C2 = ' ' + -- From = No_Location + -- To = No_Location + -- Last = False + + -- Operator + -- C1 = '!', '^', '&', '|' + -- C2 = ' ' + -- From = No_Location + -- To = No_Location + -- Last = False + + -- Element + -- C1 = ' ' + -- C2 = 'c', 't', or 'f' (condition/true/false) + -- From = starting sloc + -- To = ending sloc + -- Last = False for all but the last entry, True for last entry + + -- Note: the sequence starting with a decision, and continuing with + -- operators and elements up to and including the first one labeled with + -- Last=True, indicate the sequence to be output for a complex decision + -- on a single CD decision line. + + ---------------- + -- Unit Table -- + ---------------- + + -- This table keeps track of the units and the corresponding starting and + -- ending indexes (From, To) in the SCO table. Note that entry zero is + -- unused, it is for convenience in calling the sort routine. + + type SCO_Unit_Table_Entry is record + Unit : Unit_Number_Type; + From : Nat; + To : Nat; + end record; + + package SCO_Unit_Table is new Table.Table ( + Table_Component_Type => SCO_Unit_Table_Entry, + Table_Index_Type => Int, + Table_Low_Bound => 0, + Table_Initial => 20, + Table_Increment => 200, + Table_Name => "SCO_Unit_Table_Entry"); + + -------------------------- + -- Condition Hash Table -- + -------------------------- + + -- We need to be able to get to conditions quickly for handling the calls + -- to Set_SCO_Condition efficiently. For this purpose we identify the + -- conditions in the table by their starting sloc, and use the following + -- hash table to map from these starting sloc values to SCO_Table indexes. + + type Header_Num is new Integer range 0 .. 996; + -- Type for hash table headers + + function Hash (F : Source_Ptr) return Header_Num; + -- Function to Hash source pointer value + + function Equal (F1, F2 : Source_Ptr) return Boolean; + -- Function to test two keys for equality + + package Condition_Hash_Table is new Simple_HTable + (Header_Num, Int, 0, Source_Ptr, Hash, Equal); + -- The actual hash table + + -------------------------- + -- Internal Subprograms -- + -------------------------- + + function Has_Decision (N : Node_Id) return Boolean; + -- N is the node for a subexpression. Returns True if the subexpression + -- contains a nested decision (i.e. either is a logical operator, or + -- contains a logical operator in its subtree). + + function Is_Logical_Operator (N : Node_Id) return Boolean; + -- N is the node for a subexpression. This procedure just tests N to see + -- if it is a logical operator (including short circuit conditions) and + -- returns True if so, False otherwise, it does no other processing. + + procedure Process_Decisions (N : Node_Id; T : Character); + -- If N is Empty, has no effect. Otherwise scans the tree for the node N, + -- to output any decisions it contains. T is one of IEWX (for context of + -- expresion: if/while/when-exit/expression). If T is other than X, then + -- the node is always a decision a decision is always present (at the very + -- least a simple decision is present at the top level). + + procedure Process_Decisions (L : List_Id; T : Character); + -- Calls above procedure for each element of the list L + + procedure Set_Table_Entry + (C1 : Character; + C2 : Character; + From : Source_Ptr; + To : Source_Ptr; + Last : Boolean); + -- Append an entry to SCO_Table with fields set as per arguments + + procedure Traverse_Declarations_Or_Statements (L : List_Id); + procedure Traverse_Generic_Package_Declaration (N : Node_Id); + procedure Traverse_Handled_Statement_Sequence (N : Node_Id); + procedure Traverse_Package_Body (N : Node_Id); + procedure Traverse_Package_Declaration (N : Node_Id); + procedure Traverse_Subprogram_Body (N : Node_Id); + -- Traverse the corresponding construct, generating SCO table entries + + procedure dsco; + -- Debug routine to dump SCO table + + ---------- + -- dsco -- + ---------- + + procedure dsco is + begin + Write_Line ("SCO Unit Table"); + Write_Line ("--------------"); + + for Index in SCO_Unit_Table.First .. SCO_Unit_Table.Last loop + Write_Str (" "); + Write_Int (Index); + Write_Str (". Unit = "); + Write_Int (Int (SCO_Unit_Table.Table (Index).Unit)); + Write_Str (" From = "); + Write_Int (Int (SCO_Unit_Table.Table (Index).From)); + Write_Str (" To = "); + Write_Int (Int (SCO_Unit_Table.Table (Index).To)); + Write_Eol; + end loop; + + Write_Eol; + Write_Line ("SCO Table"); + Write_Line ("---------"); + + for Index in SCO_Table.First .. SCO_Table.Last loop + declare + T : SCO_Table_Entry renames SCO_Table.Table (Index); + + begin + Write_Str (" "); + Write_Int (Index); + Write_Str (". C1 = '"); + Write_Char (T.C1); + Write_Str ("' C2 = '"); + Write_Char (T.C2); + Write_Str ("' From = "); + Write_Location (T.From); + Write_Str (" To = "); + Write_Location (T.To); + Write_Str (" Last = "); + + if T.Last then + Write_Str (" True"); + else + Write_Str (" False"); + end if; + + Write_Eol; + end; + end loop; + end dsco; + + ----------- + -- Equal -- + ----------- + + function Equal (F1, F2 : Source_Ptr) return Boolean is + begin + return F1 = F2; + end Equal; + + ------------------ + -- Has_Decision -- + ------------------ + + function Has_Decision (N : Node_Id) return Boolean is + + function Check_Node (N : Node_Id) return Traverse_Result; + + ---------------- + -- Check_Node -- + ---------------- + + function Check_Node (N : Node_Id) return Traverse_Result is + begin + if Is_Logical_Operator (N) then + return Abandon; + else + return OK; + end if; + end Check_Node; + + function Traverse is new Traverse_Func (Check_Node); + + -- Start of processing for Has_Decision + + begin + return Traverse (N) = Abandon; + end Has_Decision; + + ---------- + -- Hash -- + ---------- + + function Hash (F : Source_Ptr) return Header_Num is + begin + return Header_Num (Nat (F) mod 997); + end Hash; + + ---------------- + -- Initialize -- + ---------------- + + procedure Initialize is + begin + SCO_Unit_Table.Init; + SCO_Unit_Table.Increment_Last; + SCO_Table.Init; + end Initialize; + + ------------------------- + -- Is_Logical_Operator -- + ------------------------- + + function Is_Logical_Operator (N : Node_Id) return Boolean is + begin + return Nkind_In (N, N_Op_And, + N_Op_Or, + N_Op_Xor, + N_Op_Not, + N_And_Then, + N_Or_Else); + end Is_Logical_Operator; + + ----------------------- + -- Process_Decisions -- + ----------------------- + + -- Version taking a list + + procedure Process_Decisions (L : List_Id; T : Character) is + N : Node_Id; + begin + if L /= No_List then + N := First (L); + while Present (N) loop + Process_Decisions (N, T); + Next (N); + end loop; + end if; + end Process_Decisions; + + -- Version taking a node + + procedure Process_Decisions (N : Node_Id; T : Character) is + + function Process_Node (N : Node_Id) return Traverse_Result; + -- Processes one node in the traversal, looking for logical operators, + -- and if one is found, outputs the appropriate table entries. + + procedure Output_Decision_Operand (N : Node_Id); + -- The node N is the top level logical operator of a decision, or it is + -- one of the operands of a logical operator belonging to a single + -- complex decision. This routine outputs the sequence of table entries + -- corresponding to the node. Note that we do not process the sub- + -- operands to look for further decisions, that processing is done in + -- Process_Decision_Operand, because we can't get decisions mixed up in + -- the global table. Call has no effect if N is Empty. + + procedure Output_Element (N : Node_Id; T : Character); + -- Node N is an operand of a logical operator that is not itself a + -- logical operator, or it is a simple decision. This routine outputs + -- the table entry for the element, with C1 set to T (' ' for one of + -- the elements of a complex decision, or 'I'/'W'/'E' for a simple + -- decision (from an IF, WHILE, or EXIT WHEN). Last is set to False, + -- and an entry is made in the condition hash table. + + procedure Process_Decision_Operand (N : Node_Id); + -- This is called on node N, the top level node of a decision, or on one + -- of its operands or suboperands after generating the full output for + -- the complex decision. It process the suboperands of the decision + -- looking for nested decisions. + + ----------------------------- + -- Output_Decision_Operand -- + ----------------------------- + + procedure Output_Decision_Operand (N : Node_Id) is + C : Character; + L : Node_Id; + + FSloc : Source_Ptr; + LSloc : Source_Ptr; + + begin + if No (N) then + return; + + -- Logical operator + + elsif Is_Logical_Operator (N) then + if Nkind (N) = N_Op_Not then + C := '!'; + L := Empty; + + else + L := Left_Opnd (N); + + if Nkind (N) = N_Op_Xor then + C := '^'; + elsif Nkind_In (N, N_Op_Or, N_Or_Else) then + C := '|'; + else + C := '&'; + end if; + end if; + + Sloc_Range (N, FSloc, LSloc); + Set_Table_Entry (C, ' ', FSloc, LSloc, False); + + Output_Decision_Operand (L); + Output_Decision_Operand (Right_Opnd (N)); + + -- Not a logical operator + + else + Output_Element (N, ' '); + end if; + end Output_Decision_Operand; + + -------------------- + -- Output_Element -- + -------------------- + + procedure Output_Element (N : Node_Id; T : Character) is + FSloc : Source_Ptr; + LSloc : Source_Ptr; + begin + Sloc_Range (N, FSloc, LSloc); + Set_Table_Entry (T, 'c', FSloc, LSloc, False); + Condition_Hash_Table.Set (FSloc, SCO_Table.Last); + end Output_Element; + + ------------------------------ + -- Process_Decision_Operand -- + ------------------------------ + + procedure Process_Decision_Operand (N : Node_Id) is + begin + if Is_Logical_Operator (N) then + if Nkind (N) /= N_Op_Not then + Process_Decision_Operand (Left_Opnd (N)); + end if; + + Process_Decision_Operand (Right_Opnd (N)); + + else + Process_Decisions (N, 'X'); + end if; + end Process_Decision_Operand; + + ------------------ + -- Process_Node -- + ------------------ + + function Process_Node (N : Node_Id) return Traverse_Result is + begin + case Nkind (N) is + + -- Logical operators and short circuit forms, output table + -- entries and then process operands recursively to deal with + -- nested conditions. + + when N_And_Then | + N_Or_Else | + N_Op_And | + N_Op_Or | + N_Op_Xor | + N_Op_Not => + + declare + T : Character; + + begin + -- If outer level, then type comes from call, otherwise it + -- is more deeply nested and counts as X for expression. + + if N = Process_Decisions.N then + T := Process_Decisions.T; + else + T := 'X'; + end if; + + -- Output header for sequence + + Set_Table_Entry (T, ' ', No_Location, No_Location, False); + + -- Output the decision + + Output_Decision_Operand (N); + + -- Change Last in last table entry to True to mark end + + SCO_Table.Table (SCO_Table.Last).Last := True; + + -- Process any embedded decisions + + Process_Decision_Operand (N); + return Skip; + end; + + -- Conditional expression, processed like an if statement + + when N_Conditional_Expression => + declare + Cond : constant Node_Id := First (Expressions (N)); + Thnx : constant Node_Id := Next (Cond); + Elsx : constant Node_Id := Next (Thnx); + begin + Process_Decisions (Cond, 'I'); + Process_Decisions (Thnx, 'X'); + Process_Decisions (Elsx, 'X'); + return Skip; + end; + + -- All other cases, continue scan + + when others => + return OK; + + end case; + end Process_Node; + + procedure Traverse is new Traverse_Proc (Process_Node); + + -- Start of processing for Process_Decisions + + begin + if No (N) then + return; + end if; + + -- See if we have simple decision at outer level and if so then + -- generate the decision entry for this simple decision. A simple + -- decision is a boolean expression (which is not a logical operator + -- or short circuit form) appearing as the operand of an IF, WHILE + -- or EXIT WHEN construct. + + if T /= 'X' and then not Is_Logical_Operator (N) then + Output_Element (N, T); + + -- Change Last in last table entry to True to mark end of + -- sequence, which is this case is only one element long. + + SCO_Table.Table (SCO_Table.Last).Last := True; + end if; + + Traverse (N); + end Process_Decisions; + + ---------------- + -- SCO_Output -- + ---------------- + + procedure SCO_Output is + Start : Nat; + Stop : Nat; + U : Unit_Number_Type; + + procedure Output_Range (From : Source_Ptr; To : Source_Ptr); + -- Outputs Sloc range in line:col-line:col format (for now we do not + -- worry about generic instantiations???) + + ------------------ + -- Output_Range -- + ------------------ + + procedure Output_Range (From : Source_Ptr; To : Source_Ptr) is + begin + Write_Info_Nat (Int (Get_Logical_Line_Number (From))); + Write_Info_Char (':'); + Write_Info_Nat (Int (Get_Column_Number (From))); + Write_Info_Char ('-'); + Write_Info_Nat (Int (Get_Logical_Line_Number (To))); + Write_Info_Char (':'); + Write_Info_Nat (Int (Get_Column_Number (To))); + end Output_Range; + + -- Start of processing for SCO_Output + + begin + if Debug_Flag_Dot_OO then + dsco; + end if; + + -- Sort the unit table + + Unit_Table_Sort : declare + + function Lt (Op1, Op2 : Natural) return Boolean; + -- Comparison routine for sort call + + procedure Move (From : Natural; To : Natural); + -- Move routine for sort call + + -------- + -- Lt -- + -------- + + function Lt (Op1, Op2 : Natural) return Boolean is + begin + return Dependency_Num (SCO_Unit_Table.Table (Nat (Op1)).Unit) < + Dependency_Num (SCO_Unit_Table.Table (Nat (Op2)).Unit); + end Lt; + + ---------- + -- Move -- + ---------- + + procedure Move (From : Natural; To : Natural) is + begin + SCO_Unit_Table.Table (Nat (To)) := + SCO_Unit_Table.Table (Nat (From)); + end Move; + + package Sorting is new GNAT.Heap_Sort_G (Move, Lt); + + -- Start of processing for Unit_Table_Sort + + begin + Sorting.Sort (Integer (SCO_Unit_Table.Last)); + end Unit_Table_Sort; + + -- Loop through entries in the unit table + + for J in 1 .. SCO_Unit_Table.Last loop + U := SCO_Unit_Table.Table (J).Unit; + + -- Output header line preceded by blank line + + Write_Info_Terminate; + Write_Info_Initiate ('C'); + Write_Info_Char (' '); + Write_Info_Nat (Dependency_Num (U)); + Write_Info_Char (' '); + Write_Info_Name (Reference_Name (Source_Index (U))); + Write_Info_Terminate; + + Start := SCO_Unit_Table.Table (J).From; + Stop := SCO_Unit_Table.Table (J).To; + + -- Loop through relevant entries in SCO table, outputting C lines + + while Start <= Stop loop + declare + T : SCO_Table_Entry renames SCO_Table.Table (Start); + + begin + Write_Info_Initiate ('C'); + Write_Info_Char (T.C1); + + case T.C1 is + + -- Statements, exit + + when 'S' | 'T' => + Write_Info_Char (' '); + Output_Range (T.From, T.To); + + -- Decision + + when 'I' | 'E' | 'W' | 'X' => + if T.C2 = ' ' then + Start := Start + 1; + end if; + + -- Loop through table entries for this decision + + loop + declare + T : SCO_Table_Entry renames SCO_Table.Table (Start); + + begin + Write_Info_Char (' '); + + if T.C1 = '!' or else + T.C1 = '^' or else + T.C1 = '&' or else + T.C1 = '|' + then + Write_Info_Char (T.C1); + + else + Write_Info_Char (T.C2); + Output_Range (T.From, T.To); + end if; + + exit when T.Last; + Start := Start + 1; + end; + end loop; + + when others => + raise Program_Error; + end case; + + Write_Info_Terminate; + end; + + exit when Start = Stop; + Start := Start + 1; + + pragma Assert (Start <= Stop); + end loop; + end loop; + end SCO_Output; + + ---------------- + -- SCO_Record -- + ---------------- + + procedure SCO_Record (U : Unit_Number_Type) is + Lu : Node_Id; + From : Nat; + + begin + -- Ignore call if not generating code and generating SCO's + + if not (Generate_SCO and then Operating_Mode = Generate_Code) then + return; + end if; + + -- Ignore call if this unit already recorded + + for J in 1 .. SCO_Unit_Table.Last loop + if SCO_Unit_Table.Table (J).Unit = U then + return; + end if; + end loop; + + -- Otherwise record starting entry + + From := SCO_Table.Last + 1; + + -- Get Unit (checking case of subunit) + + Lu := Unit (Cunit (U)); + + if Nkind (Lu) = N_Subunit then + Lu := Proper_Body (Lu); + end if; + + -- Traverse the unit + + if Nkind (Lu) = N_Subprogram_Body then + Traverse_Subprogram_Body (Lu); + + elsif Nkind (Lu) = N_Package_Declaration then + Traverse_Package_Declaration (Lu); + + elsif Nkind (Lu) = N_Package_Body then + Traverse_Package_Body (Lu); + + elsif Nkind (Lu) = N_Generic_Package_Declaration then + Traverse_Generic_Package_Declaration (Lu); + + -- For anything else, the only issue is default expressions for + -- parameters, where we have to worry about possible embedded decisions + -- but nothing else. + + else + Process_Decisions (Lu, 'X'); + end if; + + -- Make entry for new unit in unit table + + SCO_Unit_Table.Append ((Unit => U, From => From, To => SCO_Table.Last)); + end SCO_Record; + + ----------------------- + -- Set_SCO_Condition -- + ----------------------- + + procedure Set_SCO_Condition (First_Loc : Source_Ptr; Typ : Character) is + Index : constant Nat := Condition_Hash_Table.Get (First_Loc); + begin + if Index /= 0 then + SCO_Table.Table (Index).C2 := Typ; + end if; + end Set_SCO_Condition; + + --------------------- + -- Set_Table_Entry -- + --------------------- + + procedure Set_Table_Entry + (C1 : Character; + C2 : Character; + From : Source_Ptr; + To : Source_Ptr; + Last : Boolean) + is + begin + SCO_Table.Append ((C1 => C1, + C2 => C2, + From => From, + To => To, + Last => Last)); + end Set_Table_Entry; + + ----------------------------------------- + -- Traverse_Declarations_Or_Statements -- + ----------------------------------------- + + procedure Traverse_Declarations_Or_Statements (L : List_Id) is + N : Node_Id; + Start : Source_Ptr; + Dummy : Source_Ptr; + Stop : Source_Ptr; + From : Source_Ptr; + To : Source_Ptr; + + Term : Boolean; + -- Set False if current entity terminates statement list + + procedure Set_Statement_Entry; + -- If Start is No_Location, does nothing, otherwise outputs a SCO_Table + -- statement entry for the range Start-Stop and then sets both Start + -- and Stop to No_Location. Unconditionally sets Term to True. This is + -- called when we find a statement or declaration that generates its + -- own table entry, so that we must end the current statement sequence. + + ------------------------- + -- Set_Statement_Entry -- + ------------------------- + + procedure Set_Statement_Entry is + begin + Term := True; + + if Start /= No_Location then + Set_Table_Entry ('S', ' ', Start, Stop, False); + Start := No_Location; + Stop := No_Location; + end if; + end Set_Statement_Entry; + + -- Start of processing for Traverse_Declarations_Or_Statements + + begin + if Is_Non_Empty_List (L) then + N := First (L); + Start := No_Location; + + -- Loop through statements or declarations + + while Present (N) loop + Term := False; + + case Nkind (N) is + + -- Package declaration + + when N_Package_Declaration => + Set_Statement_Entry; + Traverse_Package_Declaration (N); + + -- Generic package declaration + + when N_Generic_Package_Declaration => + Set_Statement_Entry; + Traverse_Generic_Package_Declaration (N); + + -- Package body + + when N_Package_Body => + Set_Statement_Entry; + Traverse_Package_Body (N); + + -- Subprogram declaration + + when N_Subprogram_Declaration => + Set_Statement_Entry; + Process_Decisions + (Parameter_Specifications (Specification (N)), 'X'); + + -- Generic subprogram declaration + + when N_Generic_Subprogram_Declaration => + Set_Statement_Entry; + Process_Decisions (Generic_Formal_Declarations (N), 'X'); + Process_Decisions + (Parameter_Specifications (Specification (N)), 'X'); + + -- Subprogram_Body + + when N_Subprogram_Body => + Set_Statement_Entry; + Traverse_Subprogram_Body (N); + + -- Exit statement + + when N_Exit_Statement => + Set_Statement_Entry; + Process_Decisions (Condition (N), 'E'); + + -- This is an exit point + + Sloc_Range (N, From, To); + Set_Table_Entry ('T', ' ', From, To, False); + + -- Label (breaks statement sequence) + + when N_Label => + Set_Statement_Entry; + + -- Block statement + + when N_Block_Statement => + Set_Statement_Entry; + Traverse_Declarations_Or_Statements (Declarations (N)); + Traverse_Handled_Statement_Sequence + (Handled_Statement_Sequence (N)); + + -- If statement + + when N_If_Statement => + Set_Statement_Entry; + Process_Decisions (Condition (N), 'I'); + Traverse_Declarations_Or_Statements (Then_Statements (N)); + + if Present (Elsif_Parts (N)) then + declare + Elif : Node_Id := First (Elsif_Parts (N)); + begin + while Present (Elif) loop + Process_Decisions (Condition (Elif), 'I'); + Traverse_Declarations_Or_Statements + (Then_Statements (Elif)); + Next (Elif); + end loop; + end; + end if; + + Traverse_Declarations_Or_Statements (Else_Statements (N)); + + -- Unconditional exit points + + when N_Requeue_Statement | + N_Goto_Statement | + N_Raise_Statement => + Set_Statement_Entry; + Sloc_Range (N, From, To); + Set_Table_Entry ('T', ' ', From, To, False); + + -- Simple return statement + + when N_Simple_Return_Statement => + Set_Statement_Entry; + + -- Process possible return expression + + Process_Decisions (Expression (N), 'X'); + + -- Return is an exit point + + Sloc_Range (N, From, To); + Set_Table_Entry ('T', ' ', From, To, False); + + -- Extended return statement + + when N_Extended_Return_Statement => + Set_Statement_Entry; + Traverse_Declarations_Or_Statements + (Return_Object_Declarations (N)); + Traverse_Handled_Statement_Sequence + (Handled_Statement_Sequence (N)); + + -- Return is an exit point + + Sloc_Range (N, From, To); + Set_Table_Entry ('T', ' ', From, To, False); + + -- Loop + + when N_Loop_Statement => + + -- Even if not a while loop, we want a new statement seq + + Set_Statement_Entry; + + if Present (Iteration_Scheme (N)) then + Process_Decisions + (Condition (Iteration_Scheme (N)), 'W'); + end if; + + Traverse_Declarations_Or_Statements (Statements (N)); + + -- All other cases + + when others => + if Has_Decision (N) then + Set_Statement_Entry; + Process_Decisions (N, 'X'); + end if; + end case; + + -- If that element did not terminate the current sequence of + -- statements, then establish or extend this sequence. + + if not Term then + if Start = No_Location then + Sloc_Range (N, Start, Stop); + else + Sloc_Range (N, Dummy, Stop); + end if; + end if; + + Next (N); + end loop; + + Set_Statement_Entry; + end if; + end Traverse_Declarations_Or_Statements; + + ------------------------------------------ + -- Traverse_Generic_Package_Declaration -- + ------------------------------------------ + + procedure Traverse_Generic_Package_Declaration (N : Node_Id) is + begin + Process_Decisions (Generic_Formal_Declarations (N), 'X'); + Traverse_Package_Declaration (N); + end Traverse_Generic_Package_Declaration; + + ----------------------------------------- + -- Traverse_Handled_Statement_Sequence -- + ----------------------------------------- + + procedure Traverse_Handled_Statement_Sequence (N : Node_Id) is + Handler : Node_Id; + + begin + if Present (N) then + Traverse_Declarations_Or_Statements (Statements (N)); + + if Present (Exception_Handlers (N)) then + Handler := First (Exception_Handlers (N)); + while Present (Handler) loop + Traverse_Declarations_Or_Statements (Statements (Handler)); + Next (Handler); + end loop; + end if; + end if; + end Traverse_Handled_Statement_Sequence; + + --------------------------- + -- Traverse_Package_Body -- + --------------------------- + + procedure Traverse_Package_Body (N : Node_Id) is + begin + Traverse_Declarations_Or_Statements (Declarations (N)); + Traverse_Handled_Statement_Sequence (Handled_Statement_Sequence (N)); + end Traverse_Package_Body; + + ---------------------------------- + -- Traverse_Package_Declaration -- + ---------------------------------- + + procedure Traverse_Package_Declaration (N : Node_Id) is + Spec : constant Node_Id := Specification (N); + begin + Traverse_Declarations_Or_Statements (Visible_Declarations (Spec)); + Traverse_Declarations_Or_Statements (Private_Declarations (Spec)); + end Traverse_Package_Declaration; + + ------------------------------ + -- Traverse_Subprogram_Body -- + ------------------------------ + + procedure Traverse_Subprogram_Body (N : Node_Id) is + begin + Traverse_Declarations_Or_Statements (Declarations (N)); + Traverse_Handled_Statement_Sequence (Handled_Statement_Sequence (N)); + end Traverse_Subprogram_Body; + +end Par_SCO; diff --git a/gcc/ada/par_sco.ads b/gcc/ada/par_sco.ads new file mode 100644 index 00000000000..a977a11daa1 --- /dev/null +++ b/gcc/ada/par_sco.ads @@ -0,0 +1,214 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT COMPILER COMPONENTS -- +-- -- +-- P A R _ S C O -- +-- -- +-- S p e c -- +-- -- +-- Copyright (C) 2009, Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT 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 distributed with GNAT; see file COPYING3. If not, go to -- +-- http://www.gnu.org/licenses for a complete copy of the license. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +-- This package contains the routines used to deal with generation and output +-- of Soure Coverage Obligations (SCO's) used for coverage analysis purposes. + +with Types; use Types; + +package Par_SCO is + + ---------------- + -- SCO Format -- + ---------------- + + -- Source coverage obligations are generated on a unit-by-unit basis in the + -- ALI file, using lines that start with the identifying character C. These + -- lines are generated if the -gnatC switch is set. + + -- Sloc Ranges + + -- In several places in the SCO lines, Sloc ranges appear. These are used + -- to indicate the first and last Sloc of some construct in the tree and + -- they have the form: + + -- line:col-line:col + + -- Note that SCO's are generated only for generic templates, not for + -- generic instances (since only the first are part of the source). So + -- we don't need generic instantiation stuff in these line:col items. + + -- SCO File headers + + -- The SCO information follows the cross-reference information, so it + -- need not be read by tools like gnatbind, gnatmake etc. The SCO output + -- is divided into sections, one section for each unit for which SCO's + -- are generated. A SCO section has a header of the form: + + -- C dependency-number filename + + -- This header precedes SCO information for the unit identified by + -- dependency number and file name. The dependency number is the + -- index into the generated D lines and is ones origin (i.e. 2 = + -- reference to second generated D line). + + -- Note that the filename here will reflect the original name if + -- a Source_Reference pragma was encountered (since all line number + -- references will be with respect to the original file). + + -- Statements + + -- For the purpose of SCO generation, the notion of statement includes + -- simple statements and also the following declaration types: + + -- type_declaration + -- subtype_declaration + -- object_declaration + -- renaming_declaration + -- generic_instantiation + + -- ??? is this list complete ??? + + -- ??? what is the exact story on complex statements such as blocks ??? + -- ??? are the simple statements inside sufficient ??? + + -- Statement lines + + -- These lines correspond to a sequence of one or more statements which + -- are always exeecuted in sequence, The first statement may be an entry + -- point (e.g. statement after a label), and the last statement may be + -- an exit point (e.g. an exit statement), but no other entry or exit + -- points may occur within the sequence of statements. The idea is that + -- the sequence can be treated as a single unit from a coverage point of + -- view, if any of the code for the statement sequence is executed, this + -- corresponds to coverage of the entire statement sequence. The form of + -- a statement line in the ALI file is: + + -- CS sloc-range + + -- Exit points + + -- An exit point is a statement that causes transfer of control. Examples + -- are exit statements, raise statements and return statements. The form + -- of an exit point in the ALI file is: + + -- CT sloc-range + + -- Decisions + + -- Decisions represent the most significant section of the SCO lines + + -- Note: in the following description, logical operator includes the + -- short circuited forms (so can be any of AND, OR, XOR, NOT, AND THEN, + -- or OR ELSE). + + -- Decisions are either simple or complex. A simple decision is a boolean + -- expresssion that occurs in the context of a control structure in the + -- source program, including WHILE, IF, EXIT WHEN. Note that a boolean + -- expression in any other context, e.g. on the right side of an + -- assignment, is not considered to be a decision. + + -- A complex decision is an occurrence of a logical operator which is not + -- itself an operand of some other logical operator. If any operand of + -- the logical operator is itself a logical operator, this is not a + -- separate decision, it is part of the same decision. + + -- So for example, if we have + + -- A, B, C, D : Boolean; + -- function F (Arg : Boolean) return Boolean); + -- ... + -- A and then (B or else F (C and then D)) + + -- There are two (complex) decisions here: + + -- 1. X and then (Y or else Z) + + -- where X = A, Y = B, and Z = F (C and then D) + + -- 2. C and then D + + -- For each decision, a decision line is generated with the form: + + -- C* expression + + -- Here * is one of the following characters: + + -- I decision in IF statement or conditional expression + -- E decision in EXIT WHEN statement + -- W decision in WHILE iteration scheme + -- X decision appearing in some other expression context + + -- The expression is a prefix polish form indicating the structure of + -- the decision, including logical operators and short circuit forms. + -- The following is a grammar showing the structure of expression: + + -- expression ::= term (if expr is not logical operator) + -- expression ::= & term term (if expr is AND or AND THEN) + -- expression ::= | term term (if expr is OR or OR ELSE) + -- expression ::= ^ term term (if expr is XOR) + -- expression ::= !term (if expr is NOT) + + -- term ::= element + -- term ::= expression + + -- element ::= outcome sloc-range + + -- outcome is one of the following letters: + + -- c condition + -- t true condition + -- f false condition + + -- where t/f are used to mark a condition that has been recognized by + -- the compiler as always being true or false. + + -- & indicates either AND or AND THEN connecting two conditions. In the + -- context of couverture we only permit AND THEN in the source in any + -- case, so & can always be understood to be AND THEN. + + -- | indicates either OR or OR ELSE connection two conditions. In the + -- context of couverture we only permit OR ELSE in the source in any + -- case, so | can always be understood to be OR ELSE. + + -- ^ indicates XOR connecting two conditions. In the context of + -- couverture, we do not permit XOR, so this will never appear. + + -- ! indicates NOT applied to the expression. + + ----------------- + -- Subprograms -- + ----------------- + + procedure Initialize; + -- Initialize internal tables for a new compilation + + procedure SCO_Record (U : Unit_Number_Type); + -- This procedure scans the tree for the unit identified by U, populating + -- internal tables recording the SCO information. Note that this is done + -- before any semantic analysis/expansion happens. + + procedure Set_SCO_Condition (First_Loc : Source_Ptr; Typ : Character); + -- This procedure is called during semantic analysis to record a condition + -- which has been identified as always True (Typ = 't') or always False + -- (Typ = 'f') by the compiler. The condition is identified by the + -- First_Sloc value in the original tree. + + procedure SCO_Output; + -- Outputs SCO lines for all units, with appropriate section headers, for + -- unit U in the ALI file, as recorded by previous calls to SCO_Record, + -- possibly modified by calls to Set_SCO_Condition. + +end Par_SCO; diff --git a/gcc/ada/s-htable.ads b/gcc/ada/s-htable.ads index bc416abd730..fc97cf40940 100644 --- a/gcc/ada/s-htable.ads +++ b/gcc/ada/s-htable.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1995-2008, AdaCore -- +-- Copyright (C) 1995-2009, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -88,7 +88,7 @@ package System.HTable is function Get_First return Element; -- Returns No_Element if the HTable is empty, otherwise returns one - -- non specified element. There is no guarantee that 2 calls to this + -- non specified element. There is no guarantee that two calls to this -- function will return the same element. function Get_Next return Element; @@ -175,7 +175,7 @@ package System.HTable is function Get_First return Elmt_Ptr; -- Returns Null_Ptr if the HTable is empty, otherwise returns one - -- non specified element. There is no guarantee that 2 calls to this + -- non specified element. There is no guarantee that two calls to this -- function will return the same element. function Get_Next return Elmt_Ptr; diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 970d3679224..687dd5c2f9a 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -42,6 +42,7 @@ with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Output; use Output; +with Par_SCO; use Par_SCO; with Restrict; use Restrict; with Rident; use Rident; with Rtsfind; use Rtsfind; @@ -76,13 +77,13 @@ package body Sem_Ch10 is procedure Build_Limited_Views (N : Node_Id); -- Build and decorate the list of shadow entities for a package mentioned -- in a limited_with clause. If the package was not previously analyzed - -- then it also performs a basic decoration of the real entities; this - -- is required to do not pass non-decorated entities to the back-end. + -- then it also performs a basic decoration of the real entities. This is + -- required to do not pass non-decorated entities to the back-end. -- Implements Ada 2005 (AI-50217). procedure Check_Body_Needed_For_SAL (Unit_Name : Entity_Id); - -- Check whether the source for the body of a compilation unit must - -- be included in a standalone library. + -- Check whether the source for the body of a compilation unit must be + -- included in a standalone library. procedure Check_Private_Child_Unit (N : Node_Id); -- If a with_clause mentions a private child unit, the compilation @@ -129,8 +130,8 @@ package body Sem_Ch10 is -- and use_clauses for current unit and its library unit if any. procedure Install_Limited_Context_Clauses (N : Node_Id); - -- Subsidiary to Install_Context. Process only limited with_clauses - -- for current unit. Implements Ada 2005 (AI-50217). + -- Subsidiary to Install_Context. Process only limited with_clauses for + -- current unit. Implements Ada 2005 (AI-50217). procedure Install_Limited_Withed_Unit (N : Node_Id); -- Place shadow entities for a limited_with package in the visibility @@ -139,11 +140,11 @@ package body Sem_Ch10 is procedure Install_Withed_Unit (With_Clause : Node_Id; Private_With_OK : Boolean := False); - -- If the unit is not a child unit, make unit immediately visible. - -- The caller ensures that the unit is not already currently installed. - -- The flag Private_With_OK is set true in Install_Private_With_Clauses, - -- which is called when compiling the private part of a package, or - -- installing the private declarations of a parent unit. + -- If the unit is not a child unit, make unit immediately visible. The + -- caller ensures that the unit is not already currently installed. The + -- flag Private_With_OK is set true in Install_Private_With_Clauses, which + -- is called when compiling the private part of a package, or installing + -- the private declarations of a parent unit. procedure Install_Parents (Lib_Unit : Node_Id; Is_Private : Boolean); -- This procedure establishes the context for the compilation of a child @@ -169,8 +170,8 @@ package body Sem_Ch10 is -- True, then Parent_Spec (Lib_Unit) is non-Empty and points to the -- compilation unit for the parent spec. -- - -- Lib_Unit can also be a subprogram body that acts as its own spec. If - -- the Parent_Spec is non-empty, this is also a child unit. + -- Lib_Unit can also be a subprogram body that acts as its own spec. If the + -- Parent_Spec is non-empty, this is also a child unit. procedure Remove_Context_Clauses (N : Node_Id); -- Subsidiary of previous one. Remove use_ and with_clauses @@ -663,13 +664,13 @@ package body Sem_Ch10 is Analyze_Context (N); - -- If the unit is a package body, the spec is already loaded and must - -- be analyzed first, before we analyze the body. + -- If the unit is a package body, the spec is already loaded and must be + -- analyzed first, before we analyze the body. if Nkind (Unit_Node) = N_Package_Body then - -- If no Lib_Unit, then there was a serious previous error, so - -- just ignore the entire analysis effort + -- If no Lib_Unit, then there was a serious previous error, so just + -- ignore the entire analysis effort if No (Lib_Unit) then return; @@ -687,8 +688,8 @@ package body Sem_Ch10 is ("no legal package declaration for package body", N); return; - -- Otherwise, the entity in the declaration is visible. Update - -- the version to reflect dependence of this body on the spec. + -- Otherwise, the entity in the declaration is visible. Update the + -- version to reflect dependence of this body on the spec. else Spec_Id := Defining_Entity (Unit (Lib_Unit)); @@ -1107,29 +1108,29 @@ package body Sem_Ch10 is -- Case of units which do not require elaboration checks if - -- Pure units do not need checks + -- Pure units do not need checks - Is_Pure (Spec_Id) + Is_Pure (Spec_Id) - -- Preelaborated units do not need checks + -- Preelaborated units do not need checks - or else Is_Preelaborated (Spec_Id) + or else Is_Preelaborated (Spec_Id) - -- No checks needed if pragma Elaborate_Body present + -- No checks needed if pragma Elaborate_Body present - or else Has_Pragma_Elaborate_Body (Spec_Id) + or else Has_Pragma_Elaborate_Body (Spec_Id) - -- No checks needed if unit does not require a body + -- No checks needed if unit does not require a body - or else not Unit_Requires_Body (Spec_Id) + or else not Unit_Requires_Body (Spec_Id) - -- No checks needed for predefined files + -- No checks needed for predefined files - or else Is_Predefined_File_Name (Unit_File_Name (Unum)) + or else Is_Predefined_File_Name (Unit_File_Name (Unum)) - -- No checks required if no separate spec + -- No checks required if no separate spec - or else Acts_As_Spec (N) + or else Acts_As_Spec (N) then -- This is a case where we only need the entity for -- checking to prevent multiple elaboration checks. @@ -1282,15 +1283,15 @@ package body Sem_Ch10 is while Present (Item) loop - -- For with clause, analyze the with clause, and then update - -- the version, since we are dependent on a unit that we with. + -- For with clause, analyze the with clause, and then update the + -- version, since we are dependent on a unit that we with. if Nkind (Item) = N_With_Clause and then not Limited_Present (Item) then -- Skip analyzing with clause if no unit, nothing to do (this - -- happens for a with that references a non-existent unit) - -- Skip as well if this is a with_clause for the main unit, which + -- happens for a with that references a non-existent unit). Skip + -- as well if this is a with_clause for the main unit, which -- happens if a subunit has a useless with_clause on its parent. if Present (Library_Unit (Item)) then @@ -1337,8 +1338,8 @@ package body Sem_Ch10 is if not Implicit_With (Item) then - -- Verify that the illegal contexts given in 10.1.2 (18/2) - -- are properly rejected, including renaming declarations. + -- Verify that the illegal contexts given in 10.1.2 (18/2) are + -- properly rejected, including renaming declarations. if not Nkind_In (Ukind, N_Package_Declaration, N_Subprogram_Declaration) @@ -1399,8 +1400,8 @@ package body Sem_Ch10 is and then not Limited_Present (It) and then Nkind_In (Unit (Library_Unit (It)), - N_Package_Declaration, - N_Package_Renaming_Declaration) + N_Package_Declaration, + N_Package_Renaming_Declaration) then if Nkind (Unit (Library_Unit (It))) = N_Package_Declaration @@ -1511,8 +1512,8 @@ package body Sem_Ch10 is ------------------------- procedure Analyze_Proper_Body (N : Node_Id; Nam : Entity_Id) is - Subunit_Name : constant Unit_Name_Type := Get_Unit_Name (N); - Unum : Unit_Number_Type; + Subunit_Name : constant Unit_Name_Type := Get_Unit_Name (N); + Unum : Unit_Number_Type; procedure Optional_Subunit; -- This procedure is called when the main unit is a stub, or when we @@ -1555,8 +1556,8 @@ package body Sem_Ch10 is then Comp_Unit := Cunit (Unum); - -- If the file was empty or seriously mangled, the unit - -- itself may be missing. + -- If the file was empty or seriously mangled, the unit itself may + -- be missing. if No (Unit (Comp_Unit)) then Error_Msg_N @@ -1587,16 +1588,16 @@ package body Sem_Ch10 is -- Start of processing for Analyze_Proper_Body begin - -- If the subunit is already loaded, it means that the main unit - -- is a subunit, and that the current unit is one of its parents - -- which was being analyzed to provide the needed context for the - -- analysis of the subunit. In this case we analyze the subunit and - -- continue with the parent, without looking a subsequent subunits. + -- If the subunit is already loaded, it means that the main unit is a + -- subunit, and that the current unit is one of its parents which was + -- being analyzed to provide the needed context for the analysis of the + -- subunit. In this case we analyze the subunit and continue with the + -- parent, without looking a subsequent subunits. if Is_Loaded (Subunit_Name) then - -- If the proper body is already linked to the stub node, - -- the stub is in a generic unit and just needs analyzing. + -- If the proper body is already linked to the stub node, the stub is + -- in a generic unit and just needs analyzing. if Present (Library_Unit (N)) then Set_Corresponding_Stub (Unit (Library_Unit (N)), N); @@ -1605,9 +1606,9 @@ package body Sem_Ch10 is -- Otherwise we must load the subunit and link to it else - -- Load the subunit, this must work, since we originally - -- loaded the subunit earlier on. So this will not really - -- load it, just give access to it. + -- Load the subunit, this must work, since we originally loaded + -- the subunit earlier on. So this will not really load it, just + -- give access to it. Unum := Load_Unit @@ -1695,6 +1696,8 @@ package body Sem_Ch10 is Subunit => True, Error_Node => N); + -- Give message if we did not get the unit + if Original_Operating_Mode = Generate_Code and then Unum = No_Unit then @@ -1736,6 +1739,17 @@ package body Sem_Ch10 is Set_Corresponding_Stub (Unit (Comp_Unit), N); + -- Collect SCO information for loaded subunit if we are + -- in the main unit). + + if Generate_SCO + and then + In_Extended_Main_Source_Unit + (Cunit_Entity (Current_Sem_Unit)) + then + SCO_Record (Unum); + end if; + -- Analyze the unit if semantics active if not Fatal_Error (Unum) or else Try_Semantics then @@ -1800,13 +1814,12 @@ package body Sem_Ch10 is -- Analyze_Subprogram_Body_Stub -- ---------------------------------- - -- A subprogram body stub can appear with or without a previous - -- specification. If there is one, the analysis of the body will - -- find it and verify conformance. The formals appearing in the - -- specification of the stub play no role, except for requiring an - -- additional conformance check. If there is no previous subprogram - -- declaration, the stub acts as a spec, and provides the defining - -- entity for the subprogram. + -- A subprogram body stub can appear with or without a previous spec. If + -- there is one, then the analysis of the body will find it and verify + -- conformance. The formals appearing in the specification of the stub play + -- no role, except for requiring an additional conformance check. If there + -- is no previous subprogram declaration, the stub acts as a spec, and + -- provides the defining entity for the subprogram. procedure Analyze_Subprogram_Body_Stub (N : Node_Id) is Decl : Node_Id; @@ -1847,21 +1860,19 @@ package body Sem_Ch10 is -- Analyze_Subunit -- --------------------- - -- A subunit is compiled either by itself (for semantic checking) - -- or as part of compiling the parent (for code generation). In - -- either case, by the time we actually process the subunit, the - -- parent has already been installed and analyzed. The node N is - -- a compilation unit, whose context needs to be treated here, - -- because we come directly here from the parent without calling - -- Analyze_Compilation_Unit. - - -- The compilation context includes the explicit context of the - -- subunit, and the context of the parent, together with the parent - -- itself. In order to compile the current context, we remove the - -- one inherited from the parent, in order to have a clean visibility - -- table. We restore the parent context before analyzing the proper - -- body itself. On exit, we remove only the explicit context of the - -- subunit. + -- A subunit is compiled either by itself (for semantic checking) or as + -- part of compiling the parent (for code generation). In either case, by + -- the time we actually process the subunit, the parent has already been + -- installed and analyzed. The node N is a compilation unit, whose context + -- needs to be treated here, because we come directly here from the parent + -- without calling Analyze_Compilation_Unit. + + -- The compilation context includes the explicit context of the subunit, + -- and the context of the parent, together with the parent itself. In order + -- to compile the current context, we remove the one inherited from the + -- parent, in order to have a clean visibility table. We restore the parent + -- context before analyzing the proper body itself. On exit, we remove only + -- the explicit context of the subunit. procedure Analyze_Subunit (N : Node_Id) is Lib_Unit : constant Node_Id := Library_Unit (N); @@ -1874,29 +1885,29 @@ package body Sem_Ch10 is Svg : constant Suppress_Array := Scope_Suppress; procedure Analyze_Subunit_Context; - -- Capture names in use clauses of the subunit. This must be done - -- before re-installing parent declarations, because items in the - -- context must not be hidden by declarations local to the parent. + -- Capture names in use clauses of the subunit. This must be done before + -- re-installing parent declarations, because items in the context must + -- not be hidden by declarations local to the parent. procedure Re_Install_Parents (L : Node_Id; Scop : Entity_Id); -- Recursive procedure to restore scope of all ancestors of subunit, -- from outermost in. If parent is not a subunit, the call to install - -- context installs context of spec and (if parent is a child unit) - -- the context of its parents as well. It is confusing that parents - -- should be treated differently in both cases, but the semantics are - -- just not identical. + -- context installs context of spec and (if parent is a child unit) the + -- context of its parents as well. It is confusing that parents should + -- be treated differently in both cases, but the semantics are just not + -- identical. procedure Re_Install_Use_Clauses; -- As part of the removal of the parent scope, the use clauses are - -- removed, to be reinstalled when the context of the subunit has - -- been analyzed. Use clauses may also have been affected by the - -- analysis of the context of the subunit, so they have to be applied - -- again, to insure that the compilation environment of the rest of - -- the parent unit is identical. + -- removed, to be reinstalled when the context of the subunit has been + -- analyzed. Use clauses may also have been affected by the analysis of + -- the context of the subunit, so they have to be applied again, to + -- insure that the compilation environment of the rest of the parent + -- unit is identical. procedure Remove_Scope; - -- Remove current scope from scope stack, and preserve the list - -- of use clauses in it, to be reinstalled after context is analyzed. + -- Remove current scope from scope stack, and preserve the list of use + -- clauses in it, to be reinstalled after context is analyzed. ----------------------------- -- Analyze_Subunit_Context -- @@ -1955,8 +1966,8 @@ package body Sem_Ch10 is Next (Item); end loop; - -- Reset visibility of withed units. They will be made visible - -- again when we install the subunit context. + -- Reset visibility of withed units. They will be made visible again + -- when we install the subunit context. Item := First (Context_Items (N)); while Present (Item) loop @@ -2024,9 +2035,9 @@ package body Sem_Ch10 is Next_Entity (E); end loop; - -- A subunit appears within a body, and for a nested subunits - -- all the parents are bodies. Restore full visibility of their - -- private entities. + -- A subunit appears within a body, and for a nested subunits all the + -- parents are bodies. Restore full visibility of their private + -- entities. if Is_Package_Or_Generic_Package (Scop) then Set_In_Package_Body (Scop); @@ -2083,8 +2094,8 @@ package body Sem_Ch10 is Remove_Scope; Remove_Context (Lib_Unit); - -- Now remove parents and their context, including enclosing - -- subunits and the outer parent body which is not a subunit. + -- Now remove parents and their context, including enclosing subunits + -- and the outer parent body which is not a subunit. if Present (Lib_Spec) then Remove_Context (Lib_Spec); @@ -2111,12 +2122,12 @@ package body Sem_Ch10 is Re_Install_Parents (Lib_Unit, Par_Unit); Set_Is_Immediately_Visible (Par_Unit); - -- If the context includes a child unit of the parent of the - -- subunit, the parent will have been removed from visibility, - -- after compiling that cousin in the context. The visibility - -- of the parent must be restored now. This also applies if the - -- context includes another subunit of the same parent which in - -- turn includes a child unit in its context. + -- If the context includes a child unit of the parent of the subunit, + -- the parent will have been removed from visibility, after compiling + -- that cousin in the context. The visibility of the parent must be + -- restored now. This also applies if the context includes another + -- subunit of the same parent which in turn includes a child unit in + -- its context. if Is_Package_Or_Generic_Package (Par_Unit) then if not Is_Immediately_Visible (Par_Unit) @@ -2137,9 +2148,9 @@ package body Sem_Ch10 is Scope_Suppress := Svg; - -- If the subunit is within a child unit, then siblings of any - -- parent unit that appear in the context clause of the subunit - -- must also be made immediately visible. + -- If the subunit is within a child unit, then siblings of any parent + -- unit that appear in the context clause of the subunit must also be + -- made immediately visible. if Present (Enclosing_Child) then Install_Siblings (Enclosing_Child, N); @@ -2150,10 +2161,10 @@ package body Sem_Ch10 is Analyze (Proper_Body (Unit (N))); Remove_Context (N); - -- The subunit may contain a with_clause on a sibling of some - -- ancestor. Removing the context will remove from visibility those - -- ancestor child units, which must be restored to the visibility - -- they have in the enclosing body. + -- The subunit may contain a with_clause on a sibling of some ancestor. + -- Removing the context will remove from visibility those ancestor child + -- units, which must be restored to the visibility they have in the + -- enclosing body. if Present (Enclosing_Child) then declare @@ -2188,9 +2199,7 @@ package body Sem_Ch10 is Nam := Full_View (Nam); end if; - if No (Nam) - or else not Is_Task_Type (Etype (Nam)) - then + if No (Nam) or else not Is_Task_Type (Etype (Nam)) then Error_Msg_N ("missing specification for task body", N); else Set_Scope (Defining_Entity (N), Current_Scope); @@ -2198,11 +2207,11 @@ package body Sem_Ch10 is Set_Has_Completion (Etype (Nam)); Analyze_Proper_Body (N, Etype (Nam)); - -- Set elaboration flag to indicate that entity is callable. - -- This cannot be done in the expansion of the body itself, - -- because the proper body is not in a declarative part. This - -- is only done if expansion is active, because the context - -- may be generic and the flag not defined yet. + -- Set elaboration flag to indicate that entity is callable. This + -- cannot be done in the expansion of the body itself, because the + -- proper body is not in a declarative part. This is only done if + -- expansion is active, because the context may be generic and the + -- flag not defined yet. if Expander_Active then Insert_After (N, @@ -2212,7 +2221,6 @@ package body Sem_Ch10 is New_External_Name (Chars (Etype (Nam)), 'E')), Expression => New_Reference_To (Standard_True, Loc))); end if; - end if; end Analyze_Task_Body_Stub; @@ -2220,16 +2228,16 @@ package body Sem_Ch10 is -- Analyze_With_Clause -- ------------------------- - -- Analyze the declaration of a unit in a with clause. At end, - -- label the with clause with the defining entity for the unit. + -- Analyze the declaration of a unit in a with clause. At end, label the + -- with clause with the defining entity for the unit. procedure Analyze_With_Clause (N : Node_Id) is - -- Retrieve the original kind of the unit node, before analysis. - -- If it is a subprogram instantiation, its analysis below will - -- rewrite as the declaration of the wrapper package. If the same - -- instantiation appears indirectly elsewhere in the context, it - -- will have been analyzed already. + -- Retrieve the original kind of the unit node, before analysis. If it + -- is a subprogram instantiation, its analysis below will rewrite the + -- node as the declaration of the wrapper package. If the same + -- instantiation appears indirectly elsewhere in the context, it will + -- have been analyzed already. Unit_Kind : constant Node_Kind := Nkind (Original_Node (Unit (Library_Unit (N)))); @@ -2320,15 +2328,12 @@ package body Sem_Ch10 is end if; -- Check for inappropriate with of internal implementation unit if we - -- are currently compiling the main unit and the main unit is itself - -- not an internal unit. We do not issue this message for implicit - -- with's generated by the compiler itself. + -- are not compiling an internal unit. We do not issue this message + -- for implicit with's generated by the compiler itself. if Implementation_Unit_Warnings - and then Current_Sem_Unit = Main_Unit and then not Intunit and then not Implicit_With (N) - and then not GNAT_Mode then declare U_Kind : constant Kind_Of_Unit := @@ -2337,10 +2342,17 @@ package body Sem_Ch10 is begin if U_Kind = Implementation_Unit then Error_Msg_F ("& is an internal 'G'N'A'T unit?", Name (N)); - Error_Msg_F - ("\use of this unit is non-portable " & - "and version-dependent?", - Name (N)); + + -- Add alternative name if available, otherwise issue a + -- general warning message. + + if Error_Msg_Strlen /= 0 then + Error_Msg_F ("\use ""~"" instead", Name (N)); + else + Error_Msg_F + ("\use of this unit is non-portable " & + "and version-dependent?", Name (N)); + end if; elsif U_Kind = Ada_05_Unit and then Ada_Version < Ada_05 @@ -2515,6 +2527,10 @@ package body Sem_Ch10 is -- Returns true if and only if the library unit is declared with -- an explicit designation of private. + ----------------------------- + -- Is_Private_Library_Unit -- + ----------------------------- + function Is_Private_Library_Unit (Unit : Entity_Id) return Boolean is Comp_Unit : constant Node_Id := Parent (Unit_Declaration_Node (Unit)); @@ -2774,8 +2790,7 @@ package body Sem_Ch10 is Set_Implicit_With (Withn, True); -- If the unit is a package declaration, a private_with_clause on a - -- child unit implies that the implicit with on the parent is also - -- private. + -- child unit implies the implicit with on the parent is also private. if Nkind (Unit (N)) = N_Package_Declaration then Set_Private_Present (Withn, Private_Present (Item)); @@ -2912,9 +2927,11 @@ package body Sem_Ch10 is function Build_Unit_Name return Node_Id is Result : Node_Id; + begin if No (Parent_Spec (P_Unit)) then return New_Reference_To (P_Name, Loc); + else Result := Make_Expanded_Name (Loc, @@ -3102,13 +3119,10 @@ package body Sem_Ch10 is if Sloc (Library_Unit (Item)) /= No_Location then License_Check : declare - Withu : constant Unit_Number_Type := Get_Source_Unit (Library_Unit (Item)); - Withl : constant License_Type := License (Source_Index (Withu)); - Unitl : constant License_Type := License (Source_Index (Current_Sem_Unit)); @@ -3288,13 +3302,13 @@ package body Sem_Ch10 is procedure Check_Private_Limited_Withed_Unit (Item : Node_Id); -- Check that if a limited_with clause of a given compilation_unit - -- mentions a descendant of a private child of some library unit, - -- then the given compilation_unit shall be the declaration of a - -- private descendant of that library unit, or a public descendant - -- of such. The code is analogous to that of Check_Private_Child_Unit - -- but we cannot use entities on the limited with_clauses because - -- their units have not been analyzed, so we have to climb the tree - -- of ancestors looking for private keywords. + -- mentions a descendant of a private child of some library unit, then + -- the given compilation_unit shall be the declaration of a private + -- descendant of that library unit, or a public descendant of such. The + -- code is analogous to that of Check_Private_Child_Unit but we cannot + -- use entities on the limited with_clauses because their units have not + -- been analyzed, so we have to climb the tree of ancestors looking for + -- private keywords. procedure Expand_Limited_With_Clause (Comp_Unit : Node_Id; @@ -3413,7 +3427,7 @@ package body Sem_Ch10 is Child_Parent := Library_Unit (Item); -- If the child unit is a public child, then locate its nearest - -- private ancestor, if any; Child_Parent will then be set to + -- private ancestor, if any, then Child_Parent will then be set to -- the parent of that ancestor. if not Private_Present (Library_Unit (Item)) then @@ -3430,8 +3444,8 @@ package body Sem_Ch10 is Child_Parent := Parent_Spec (Unit (Child_Parent)); - -- Traverse all the ancestors of the current compilation - -- unit to check if it is a descendant of named library unit. + -- Traverse all the ancestors of the current compilation unit to + -- check if it is a descendant of named library unit. Curr_Parent := Parent (Item); Curr_Private := Private_Present (Curr_Parent); @@ -3454,8 +3468,8 @@ package body Sem_Ch10 is or else Curr_Private or else Private_Present (Item) or else Nkind_In (Unit (Parent (Item)), N_Package_Body, - N_Subprogram_Body, - N_Subunit) + N_Subprogram_Body, + N_Subunit) then -- Current unit is private, of descendant of a private unit @@ -3628,8 +3642,8 @@ package body Sem_Ch10 is end loop; -- Ada 2005 (AI-412): Examine the visible declarations of a package - -- spec, looking for incomplete subtype declarations of incomplete - -- types visible through a limited with clause. + -- spec, looking for incomplete subtype declarations of incomplete types + -- visible through a limited with clause. if Ada_Version >= Ada_05 and then Analyzed (N) @@ -3854,10 +3868,10 @@ package body Sem_Ch10 is Item := First (Context_Items (N)); while Present (Item) loop - -- Do not install private_with_clauses declaration, unless - -- unit is itself a private child unit, or is a body. - -- Note that for a subprogram body the private_with_clause does - -- not take effect until after the specification. + -- Do not install private_with_clauses declaration, unless unit + -- is itself a private child unit, or is a body. Note that for a + -- subprogram body the private_with_clause does not take effect until + -- after the specification. if Nkind (Item) /= N_With_Clause or else Implicit_With (Item) @@ -3876,8 +3890,8 @@ package body Sem_Ch10 is then Set_Is_Immediately_Visible (Id); - -- Check for the presence of another unit in the context, - -- that may be inadvertently hidden by the child. + -- Check for the presence of another unit in the context that + -- may be inadvertently hidden by the child. Prev := Current_Entity (Id); @@ -4101,7 +4115,8 @@ package body Sem_Ch10 is Next (Decl); end loop; - -- Look for declarations that require the presence of a body + -- Look for declarations that require the presence of a body. We + -- have already skipped pragmas at the start of the list. while Present (Decl) loop @@ -4377,7 +4392,7 @@ package body Sem_Ch10 is Next (Item); end loop; - -- If it's a body not acting as spec, follow pointer to + -- If it is a body not acting as spec, follow pointer to the -- corresponding spec, otherwise follow pointer to parent spec. if Present (Library_Unit (Aux_Unit)) @@ -4488,7 +4503,7 @@ package body Sem_Ch10 is -- One of the ancestors has a limited with clause and then Nkind (Parent (Parent (Main_Unit_Entity))) = - N_Package_Specification + N_Package_Specification and then Has_Limited_With_Clause (Scope (Main_Unit_Entity), P) then return; @@ -4514,8 +4529,7 @@ package body Sem_Ch10 is if Analyzed (P_Unit) and then (Is_Immediately_Visible (P) - or else - (Is_Child_Package and then Is_Visible_Child_Unit (P))) + or else (Is_Child_Package and then Is_Visible_Child_Unit (P))) then return; end if; @@ -4757,9 +4771,9 @@ package body Sem_Ch10 is Write_Eol; end if; - -- We do not apply the restrictions to an internal unit unless - -- we are compiling the internal unit as a main unit. This check - -- is also skipped for dummy units (for missing packages). + -- We do not apply the restrictions to an internal unit unless we are + -- compiling the internal unit as a main unit. This check is also + -- skipped for dummy units (for missing packages). if Sloc (Uname) /= No_Location and then (not Is_Internal_File_Name (Unit_File_Name (Current_Sem_Unit)) @@ -4931,8 +4945,9 @@ package body Sem_Ch10 is C_Unit : constant Node_Id := Cunit (Current_Sem_Unit); begin return Nkind (Unit (C_Unit)) = N_Package_Body - and then Has_With_Clause (C_Unit, - Cunit_Entity (Get_Source_Unit (Non_Limited_View (T)))); + and then + Has_With_Clause + (C_Unit, Cunit_Entity (Get_Source_Unit (Non_Limited_View (T)))); end Is_Legal_Shadow_Entity_In_Body; ----------------------- @@ -5006,9 +5021,7 @@ package body Sem_Ch10 is Last_Lim_E : Entity_Id := Empty; -- Last limited entity built Last_Pub_Lim_E : Entity_Id; -- To set the first private entity - procedure Decorate_Incomplete_Type - (E : Entity_Id; - Scop : Entity_Id); + procedure Decorate_Incomplete_Type (E : Entity_Id; Scop : Entity_Id); -- Add attributes of an incomplete type to a shadow entity. The same -- attributes are placed on the real entity, so that gigi receives -- a consistent view. @@ -5024,9 +5037,7 @@ package body Sem_Ch10 is -- Set basic attributes of tagged type T, including its class_wide type. -- The parameters Loc, Scope are used to decorate the class_wide type. - procedure Build_Chain - (Scope : Entity_Id; - First_Decl : Node_Id); + procedure Build_Chain (Scope : Entity_Id; First_Decl : Node_Id); -- Construct list of shadow entities and attach it to entity of -- package that is mentioned in a limited_with clause. @@ -5037,122 +5048,11 @@ package body Sem_Ch10 is -- Build a new internal entity and append it to the list of shadow -- entities available through the limited-header - ------------------------------ - -- Decorate_Incomplete_Type -- - ------------------------------ - - procedure Decorate_Incomplete_Type - (E : Entity_Id; - Scop : Entity_Id) - is - begin - Set_Ekind (E, E_Incomplete_Type); - Set_Scope (E, Scop); - Set_Etype (E, E); - Set_Is_First_Subtype (E, True); - Set_Stored_Constraint (E, No_Elist); - Set_Full_View (E, Empty); - Init_Size_Align (E); - end Decorate_Incomplete_Type; - - -------------------------- - -- Decorate_Tagged_Type -- - -------------------------- - - procedure Decorate_Tagged_Type - (Loc : Source_Ptr; - T : Entity_Id; - Scop : Entity_Id) - is - CW : Entity_Id; - - begin - Decorate_Incomplete_Type (T, Scop); - Set_Is_Tagged_Type (T); - - -- Build corresponding class_wide type, if not previously done - - -- Note: The class-wide entity is shared by the limited-view - -- and the full-view. - - if No (Class_Wide_Type (T)) then - CW := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); - - -- Set parent to be the same as the parent of the tagged type. - -- We need a parent field set, and it is supposed to point to - -- the declaration of the type. The tagged type declaration - -- essentially declares two separate types, the tagged type - -- itself and the corresponding class-wide type, so it is - -- reasonable for the parent fields to point to the declaration - -- in both cases. - - Set_Parent (CW, Parent (T)); - - -- Set remaining fields of classwide type - - Set_Ekind (CW, E_Class_Wide_Type); - Set_Etype (CW, T); - Set_Scope (CW, Scop); - Set_Is_Tagged_Type (CW); - Set_Is_First_Subtype (CW, True); - Init_Size_Align (CW); - Set_Has_Unknown_Discriminants (CW, True); - Set_Class_Wide_Type (CW, CW); - Set_Equivalent_Type (CW, Empty); - Set_From_With_Type (CW, From_With_Type (T)); - - -- Link type to its class-wide type - - Set_Class_Wide_Type (T, CW); - end if; - end Decorate_Tagged_Type; - - ------------------------------------ - -- Decorate_Package_Specification -- - ------------------------------------ - - procedure Decorate_Package_Specification (P : Entity_Id) is - begin - -- Place only the most basic attributes - - Set_Ekind (P, E_Package); - Set_Etype (P, Standard_Void_Type); - end Decorate_Package_Specification; - - -------------------------------- - -- New_Internal_Shadow_Entity -- - -------------------------------- - - function New_Internal_Shadow_Entity - (Kind : Entity_Kind; - Sloc_Value : Source_Ptr; - Id_Char : Character) return Entity_Id - is - E : constant Entity_Id := - Make_Defining_Identifier (Sloc_Value, - Chars => New_Internal_Name (Id_Char)); - - begin - Set_Ekind (E, Kind); - Set_Is_Internal (E, True); - - if Kind in Type_Kind then - Init_Size_Align (E); - end if; - - Append_Entity (E, Lim_Header); - Last_Lim_E := E; - return E; - end New_Internal_Shadow_Entity; - ----------------- -- Build_Chain -- ----------------- - procedure Build_Chain - (Scope : Entity_Id; - First_Decl : Node_Id) - is + procedure Build_Chain (Scope : Entity_Id; First_Decl : Node_Id) is Analyzed_Unit : constant Boolean := Analyzed (Cunit (Unum)); Is_Tagged : Boolean; Decl : Node_Id; @@ -5201,10 +5101,11 @@ package body Sem_Ch10 is -- Create shadow entity for type - Lim_Typ := New_Internal_Shadow_Entity - (Kind => Ekind (Comp_Typ), - Sloc_Value => Sloc (Comp_Typ), - Id_Char => 'Z'); + Lim_Typ := + New_Internal_Shadow_Entity + (Kind => Ekind (Comp_Typ), + Sloc_Value => Sloc (Comp_Typ), + Id_Char => 'Z'); Set_Chars (Lim_Typ, Chars (Comp_Typ)); Set_Parent (Lim_Typ, Parent (Comp_Typ)); @@ -5238,10 +5139,11 @@ package body Sem_Ch10 is end if; end if; - Lim_Typ := New_Internal_Shadow_Entity - (Kind => Ekind (Comp_Typ), - Sloc_Value => Sloc (Comp_Typ), - Id_Char => 'Z'); + Lim_Typ := + New_Internal_Shadow_Entity + (Kind => Ekind (Comp_Typ), + Sloc_Value => Sloc (Comp_Typ), + Id_Char => 'Z'); Set_Chars (Lim_Typ, Chars (Comp_Typ)); Set_Parent (Lim_Typ, Parent (Comp_Typ)); @@ -5264,10 +5166,11 @@ package body Sem_Ch10 is -- Create shadow entity for type - Lim_Typ := New_Internal_Shadow_Entity - (Kind => Ekind (Comp_Typ), - Sloc_Value => Sloc (Comp_Typ), - Id_Char => 'Z'); + Lim_Typ := + New_Internal_Shadow_Entity + (Kind => Ekind (Comp_Typ), + Sloc_Value => Sloc (Comp_Typ), + Id_Char => 'Z'); Set_Chars (Lim_Typ, Chars (Comp_Typ)); Set_Parent (Lim_Typ, Parent (Comp_Typ)); @@ -5291,10 +5194,11 @@ package body Sem_Ch10 is Set_Scope (Comp_Typ, Scope); end if; - Lim_Typ := New_Internal_Shadow_Entity - (Kind => Ekind (Comp_Typ), - Sloc_Value => Sloc (Comp_Typ), - Id_Char => 'Z'); + Lim_Typ := + New_Internal_Shadow_Entity + (Kind => Ekind (Comp_Typ), + Sloc_Value => Sloc (Comp_Typ), + Id_Char => 'Z'); Decorate_Package_Specification (Lim_Typ); Set_Scope (Lim_Typ, Scope); @@ -5316,6 +5220,111 @@ package body Sem_Ch10 is end loop; end Build_Chain; + ------------------------------ + -- Decorate_Incomplete_Type -- + ------------------------------ + + procedure Decorate_Incomplete_Type (E : Entity_Id; Scop : Entity_Id) is + begin + Set_Ekind (E, E_Incomplete_Type); + Set_Scope (E, Scop); + Set_Etype (E, E); + Set_Is_First_Subtype (E, True); + Set_Stored_Constraint (E, No_Elist); + Set_Full_View (E, Empty); + Init_Size_Align (E); + end Decorate_Incomplete_Type; + + -------------------------- + -- Decorate_Tagged_Type -- + -------------------------- + + procedure Decorate_Tagged_Type + (Loc : Source_Ptr; + T : Entity_Id; + Scop : Entity_Id) + is + CW : Entity_Id; + + begin + Decorate_Incomplete_Type (T, Scop); + Set_Is_Tagged_Type (T); + + -- Build corresponding class_wide type, if not previously done + + -- Note: The class-wide entity is shared by the limited-view + -- and the full-view. + + if No (Class_Wide_Type (T)) then + CW := Make_Defining_Identifier (Loc, New_Internal_Name ('S')); + + -- Set parent to be the same as the parent of the tagged type. + -- We need a parent field set, and it is supposed to point to + -- the declaration of the type. The tagged type declaration + -- essentially declares two separate types, the tagged type + -- itself and the corresponding class-wide type, so it is + -- reasonable for the parent fields to point to the declaration + -- in both cases. + + Set_Parent (CW, Parent (T)); + + -- Set remaining fields of classwide type + + Set_Ekind (CW, E_Class_Wide_Type); + Set_Etype (CW, T); + Set_Scope (CW, Scop); + Set_Is_Tagged_Type (CW); + Set_Is_First_Subtype (CW, True); + Init_Size_Align (CW); + Set_Has_Unknown_Discriminants (CW, True); + Set_Class_Wide_Type (CW, CW); + Set_Equivalent_Type (CW, Empty); + Set_From_With_Type (CW, From_With_Type (T)); + + -- Link type to its class-wide type + + Set_Class_Wide_Type (T, CW); + end if; + end Decorate_Tagged_Type; + + ------------------------------------ + -- Decorate_Package_Specification -- + ------------------------------------ + + procedure Decorate_Package_Specification (P : Entity_Id) is + begin + -- Place only the most basic attributes + + Set_Ekind (P, E_Package); + Set_Etype (P, Standard_Void_Type); + end Decorate_Package_Specification; + + -------------------------------- + -- New_Internal_Shadow_Entity -- + -------------------------------- + + function New_Internal_Shadow_Entity + (Kind : Entity_Kind; + Sloc_Value : Source_Ptr; + Id_Char : Character) return Entity_Id + is + E : constant Entity_Id := + Make_Defining_Identifier (Sloc_Value, + Chars => New_Internal_Name (Id_Char)); + + begin + Set_Ekind (E, Kind); + Set_Is_Internal (E, True); + + if Kind in Type_Kind then + Init_Size_Align (E); + end if; + + Append_Entity (E, Lim_Header); + Last_Lim_E := E; + return E; + end New_Internal_Shadow_Entity; + -- Start of processing for Build_Limited_Views begin @@ -5402,11 +5411,11 @@ package body Sem_Ch10 is First_Decl => First (Private_Declarations (Spec))); if Last_Pub_Lim_E /= Empty then - Set_First_Private_Entity (Lim_Header, - Next_Entity (Last_Pub_Lim_E)); + Set_First_Private_Entity + (Lim_Header, Next_Entity (Last_Pub_Lim_E)); else - Set_First_Private_Entity (Lim_Header, - First_Entity (P)); + Set_First_Private_Entity + (Lim_Header, First_Entity (P)); end if; Set_Limited_View_Installed (Spec); @@ -5449,8 +5458,7 @@ package body Sem_Ch10 is return True; elsif Ekind (E) = E_Package - and then - Nkind (Unit_Declaration_Node (E)) = N_Package_Declaration + and then Nkind (Unit_Declaration_Node (E)) = N_Package_Declaration and then Present (Corresponding_Body (Unit_Declaration_Node (E))) then Ent := First_Entity (E); @@ -5473,8 +5481,7 @@ package body Sem_Ch10 is begin if Ekind (Unit_Name) = E_Generic_Package - and then - Nkind (Unit_Declaration_Node (Unit_Name)) = + and then Nkind (Unit_Declaration_Node (Unit_Name)) = N_Generic_Package_Declaration and then Present (Corresponding_Body (Unit_Declaration_Node (Unit_Name))) @@ -5482,7 +5489,8 @@ package body Sem_Ch10 is Set_Body_Needed_For_SAL (Unit_Name); elsif Ekind (Unit_Name) = E_Generic_Procedure - or else Ekind (Unit_Name) = E_Generic_Function + or else + Ekind (Unit_Name) = E_Generic_Function then Set_Body_Needed_For_SAL (Unit_Name); @@ -5678,15 +5686,13 @@ package body Sem_Ch10 is if Ekind (Lim_Typ) /= E_Package and then not Is_Child_Unit (Non_Limited_View (Lim_Typ)) then - - -- If the package has incomplete types, the limited view - -- of the incomplete type is in fact never visible (AI05-129) - -- but we have created a shadow entity E1 for it, that points - -- to E2, a non-limited incomplete type. This in turn has a - -- full view E3 that is the full declaration. There is a - -- corresponding shadow entity E4. When reinstalling the - -- non-limited view, E2 must become the current entity and - -- E3 must be ignored. + -- If the package has incomplete types, the limited view of the + -- incomplete type is in fact never visible (AI05-129) but we + -- have created a shadow entity E1 for it, that points to E2, + -- a non-limited incomplete type. This in turn has a full view + -- E3 that is the full declaration. There is a corresponding + -- shadow entity E4. When reinstalling the non-limited view, + -- E2 must become the current entity and E3 must be ignored. E := Non_Limited_View (Lim_Typ); @@ -5696,8 +5702,8 @@ package body Sem_Ch10 is then -- Lim_Typ is the limited view of a full type declaration - -- that has a previous incomplete declaration, i.e. E3 - -- from the previous description. Nothing to insert. + -- that has a previous incomplete declaration, i.e. E3 from + -- the previous description. Nothing to insert. null; @@ -5760,7 +5766,6 @@ package body Sem_Ch10 is end if; if Present (P_Spec) then - P := Unit (P_Spec); P_Name := Get_Parent_Entity (P); Remove_Context_Clauses (P_Spec); @@ -5781,9 +5786,9 @@ package body Sem_Ch10 is Set_In_Package_Body (P_Name, False); - -- This is the recursive call to remove the context of any - -- higher level parent. This recursion ensures that all parents - -- are removed in the reverse order of their installation. + -- This is the recursive call to remove the context of any higher + -- level parent. This recursion ensures that all parents are removed + -- in the reverse order of their installation. Remove_Parents (P); end if; @@ -5797,9 +5802,9 @@ package body Sem_Ch10 is Item : Node_Id; function In_Regular_With_Clause (E : Entity_Id) return Boolean; - -- Check whether a given unit appears in a regular with_clause. - -- Used to determine whether a private_with_clause, implicit or - -- explicit, should be ignored. + -- Check whether a given unit appears in a regular with_clause. Used to + -- determine whether a private_with_clause, implicit or explicit, should + -- be ignored. ---------------------------- -- In_Regular_With_Clause -- diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 00c40e7677b..992b87a340b 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -13295,9 +13295,9 @@ package body Sem_Ch3 is Ev := Uint_0; -- Loop through literals of enumeration type setting pos and rep values - -- except that if the Ekind is already set, then it means that the - -- literal was already constructed (case of a derived type declaration - -- and we should not disturb the Pos and Rep values. + -- except that if the Ekind is already set, then it means the literal + -- was already constructed (case of a derived type declaration and we + -- should not disturb the Pos and Rep values. while Present (L) loop if Ekind (L) /= E_Enumeration_Literal then diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index e483d051504..1551acf092a 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -33,6 +33,7 @@ with Lib; use Lib; with Namet; use Namet; with Nlists; use Nlists; with Opt; use Opt; +with Par_SCO; use Par_SCO; with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Ch8; use Sem_Ch8; @@ -2997,6 +2998,9 @@ package body Sem_Warn is Warn_On_Unrepped_Components := True; Warn_On_Warnings_Off := True; + when 'g' => + Set_GNAT_Mode_Warnings; + when 'm' => Warn_On_Suspicious_Modulus_Value := True; @@ -3041,6 +3045,45 @@ package body Sem_Warn is return True; end Set_Dot_Warning_Switch; + ---------------------------- + -- Set_GNAT_Mode_Warnings -- + ---------------------------- + + procedure Set_GNAT_Mode_Warnings is + begin + Address_Clause_Overlay_Warnings := True; + Check_Unreferenced := True; + Check_Unreferenced_Formals := True; + Check_Withs := True; + Constant_Condition_Warnings := True; + Elab_Warnings := False; + Implementation_Unit_Warnings := False; + Ineffective_Inline_Warnings := True; + Warn_On_Ada_2005_Compatibility := True; + Warn_On_All_Unread_Out_Parameters := False; + Warn_On_Assertion_Failure := True; + Warn_On_Assumed_Low_Bound := True; + Warn_On_Bad_Fixed_Value := True; + Warn_On_Biased_Representation := True; + Warn_On_Constant := True; + Warn_On_Deleted_Code := False; + Warn_On_Dereference := False; + Warn_On_Export_Import := True; + Warn_On_Hiding := False; + Warn_On_Modified_Unread := True; + Warn_On_No_Value_Assigned := True; + Warn_On_Non_Local_Exception := False; + Warn_On_Object_Renames_Function := False; + Warn_On_Obsolescent_Feature := True; + Warn_On_Questionable_Missing_Parens := True; + Warn_On_Redundant_Constructs := True; + Warn_On_Object_Renames_Function := True; + Warn_On_Unchecked_Conversion := True; + Warn_On_Unrecognized_Pragma := True; + Warn_On_Unrepped_Components := False; + Warn_On_Warnings_Off := False; + end Set_GNAT_Mode_Warnings; + ------------------------ -- Set_Warning_Switch -- ------------------------ @@ -3265,7 +3308,18 @@ package body Sem_Warn is ----------------------------- procedure Warn_On_Known_Condition (C : Node_Id) is - P : Node_Id; + P : Node_Id; + Orig : constant Node_Id := Original_Node (C); + Test_Result : Boolean; + + function Is_Known_Branch return Boolean; + -- If the type of the condition is Boolean, the constant value of the + -- condition is a boolean literal. If the type is a derived boolean + -- type, the constant is wrapped in a type conversion of the derived + -- literal. If the value of the condition is not a literal, no warnings + -- can be produced. This function returns True if the result can be + -- determined, and Test_Result is set True/False accordingly. Otherwise + -- False is returned, and Test_Result is unchanged. procedure Track (N : Node_Id; Loc : Node_Id); -- Adds continuation warning(s) pointing to reason (assignment or test) @@ -3273,6 +3327,34 @@ package body Sem_Warn is -- enough is known about the value to issue the warning). N is the node -- which is judged to have a known value. Loc is the warning location. + --------------------- + -- Is_Known_Branch -- + --------------------- + + function Is_Known_Branch return Boolean is + begin + if Etype (C) = Standard_Boolean + and then Is_Entity_Name (C) + and then + (Entity (C) = Standard_False or else Entity (C) = Standard_True) + then + Test_Result := Entity (C) = Standard_True; + return True; + + elsif Is_Boolean_Type (Etype (C)) + and then Nkind (C) = N_Unchecked_Type_Conversion + and then Is_Entity_Name (Expression (C)) + and then Ekind (Entity (Expression (C))) = E_Enumeration_Literal + then + Test_Result := + Chars (Entity (Expression (C))) = Chars (Standard_True); + return True; + + else + return False; + end if; + end Is_Known_Branch; + ----------- -- Track -- ----------- @@ -3314,17 +3396,47 @@ package body Sem_Warn is -- Start of processing for Warn_On_Known_Condition begin - -- Argument replacement in an inlined body can make conditions static. - -- Do not emit warnings in this case. + -- Adjust SCO condition if from source + + if Generate_SCO + and then Comes_From_Source (Orig) + and then Is_Known_Branch + then + declare + Start : Source_Ptr; + Dummy : Source_Ptr; + Typ : Character; + Atrue : Boolean; + + begin + Sloc_Range (Orig, Start, Dummy); + Atrue := Test_Result; + + if Present (Parent (C)) + and then Nkind (Parent (C)) = N_Op_Not + then + Atrue := not Atrue; + end if; + + if Atrue then + Typ := 't'; + else + Typ := 'f'; + end if; + + Set_SCO_Condition (Start, Typ); + end; + end if; + + -- Argument replacement in an inlined body can make conditions static. + -- Do not emit warnings in this case. if In_Inlined_Body then return; end if; if Constant_Condition_Warnings - and then Nkind (C) = N_Identifier - and then - (Entity (C) = Standard_False or else Entity (C) = Standard_True) + and then Is_Known_Branch and then Comes_From_Source (Original_Node (C)) and then not In_Instance then @@ -3379,7 +3491,7 @@ package body Sem_Warn is if not Operand_Has_Warnings_Suppressed (C) then declare - True_Branch : Boolean := Entity (C) = Standard_True; + True_Branch : Boolean := Test_Result; Cond : Node_Id := C; begin diff --git a/gcc/ada/sem_warn.ads b/gcc/ada/sem_warn.ads index 3acb6873915..1e0f96814bd 100644 --- a/gcc/ada/sem_warn.ads +++ b/gcc/ada/sem_warn.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1999-2008, Free Software Foundation, Inc. -- +-- Copyright (C) 1999-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -77,6 +77,10 @@ package Sem_Warn is -- the command line or .C in a string literal in pragma Warnings. Returns -- True for valid warning character C, False for invalid character. + procedure Set_GNAT_Mode_Warnings; + -- This is called in -gnatg mode to set the warnings for gnat mode. It is + -- also used to set the proper warning statuses for -gnatw.g. + ------------------------------------------ -- Routines to Handle Unused References -- ------------------------------------------ diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 5f741077ce5..5ba4571f0b8 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -2175,7 +2175,7 @@ package Sinfo is -- Aliased_Present (Flag4) set if ALIASED appears -- Constant_Present (Flag17) set if CONSTANT appears -- Null_Exclusion_Present (Flag11) - -- Object_Definition (Node4) subtype indic./array type def./ access def. + -- Object_Definition (Node4) subtype indic./array type def./access def. -- Expression (Node3) (set to Empty if not present) -- Handler_List_Entry (Node2-Sem) -- Corresponding_Generic_Association (Node5-Sem) diff --git a/gcc/ada/snames.ads-tmpl b/gcc/ada/snames.ads-tmpl index 9d5d2984f2f..d132ffab2b3 100644 --- a/gcc/ada/snames.ads-tmpl +++ b/gcc/ada/snames.ads-tmpl @@ -302,16 +302,19 @@ package Snames is -- Names for all pragmas recognized by GNAT. The entries with the comment -- "Ada 83" are pragmas that are defined in Ada 83, but not in Ada 95. - -- These pragmas are fully implemented in both Ada 83 and Ada 95 modes - -- in GNAT. + -- These pragmas are fully implemented in all modes (Ada 83, Ada 95, and + -- Ada 2005). In Ada 95 and Ada 2005 modes, they are technically considered + -- to be implementation dependent pragmas. - -- The entries marked GNAT are pragmas that are defined by GNAT - -- and implemented in both Ada 83 and Ada 95 modes. Full descriptions - -- of these implementation dependent pragmas may be found in the - -- appropriate section in unit Sem_Prag in file sem-prag.adb. + -- The entries marked GNAT are pragmas that are defined by GNAT and that + -- are implemented in all modes (Ada 83, Ada 95, and Ada 2005) Complete + -- descriptions of the syntax of these implementation dependent pragmas + -- may be found in the appropriate section in unit Sem_Prag in file + -- sem-prag.adb, and they are documented in the GNAT reference manual. - -- The entries marked Ada05 are technically implementation dependent - -- pragmas, but they correspond to standard proposals for Ada 2005. + -- The entries marked Ada05 are Ada 2005 pragmas. They are implemented in + -- Ada 83 and Ada 95 mode as well, where they are technically considered to + -- be implementation dependent pragmas. -- The entries marked VMS are VMS specific pragmas that are recognized -- only in OpenVMS versions of GNAT. They are ignored in other versions @@ -323,7 +326,9 @@ package Snames is First_Pragma_Name : constant Name_Id := N + $; - -- Configuration pragmas are grouped at start + -- Configuration pragmas are grouped at start. Note that there is a list + -- of these names in the GNAT Users guide, be sure to update this list if + -- a new configuration pragma is added. Name_Ada_83 : constant Name_Id := N + $; -- GNAT Name_Ada_95 : constant Name_Id := N + $; -- GNAT @@ -447,10 +452,11 @@ package Snames is Name_Inline_Generic : constant Name_Id := N + $; -- GNAT Name_Inspection_Point : constant Name_Id := N + $; - -- Note: Interface is not in this list because its name matches -- GNAT - -- an Ada 2005 keyword. However it is included in the definition - -- of the type Attribute_Id, and the functions Get_Pragma_Id and - -- Is_Pragma_Id correctly recognize and process Name_Storage_Size. + -- Note: Interface is not in this list because its name -- GNAT + -- matches an Ada 2005 keyword. However it is included in + -- the definition of the type Attribute_Id, and the functions + -- Get_Pragma_Id and Is_Pragma_Id correctly recognize and + -- process Name_Storage_Size. Name_Interface_Name : constant Name_Id := N + $; -- GNAT Name_Interrupt_Handler : constant Name_Id := N + $; diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb index f0acc45c766..6825f4ec038 100644 --- a/gcc/ada/switch-c.adb +++ b/gcc/ada/switch-c.adb @@ -462,11 +462,19 @@ package body Switch.C is Ptr := Max + 1; + -- -gnatez ??? + when 'z' => Store_Switch := False; Disable_Switch_Storing; Ptr := Ptr + 1; + -- -gnateS (Store SCO information) + + when 'S' => + Generate_SCO := True; + Ptr := Ptr + 1; + -- All other -gnate? switches are unassigned when others => @@ -508,28 +516,9 @@ package body Switch.C is Ada_Version := Ada_05; Ada_Version_Explicit := Ada_Version; - -- Set default warnings for -gnatg - - Check_Unreferenced := True; - Check_Unreferenced_Formals := True; - Check_Withs := True; - Constant_Condition_Warnings := True; - Implementation_Unit_Warnings := True; - Ineffective_Inline_Warnings := True; - Warn_On_Assertion_Failure := True; - Warn_On_Assumed_Low_Bound := True; - Warn_On_Bad_Fixed_Value := True; - Warn_On_Constant := True; - Warn_On_Export_Import := True; - Warn_On_Modified_Unread := True; - Warn_On_No_Value_Assigned := True; - Warn_On_Non_Local_Exception := False; - Warn_On_Obsolescent_Feature := True; - Warn_On_Redundant_Constructs := True; - Warn_On_Object_Renames_Function := True; - Warn_On_Unchecked_Conversion := True; - Warn_On_Unrecognized_Pragma := True; + -- Set default warnings and style checks for -gnatg + Set_GNAT_Mode_Warnings; Set_GNAT_Style_Check_Options; -- Processing for G switch diff --git a/gcc/ada/switch.adb b/gcc/ada/switch.adb index cb5c4d11f49..0c761b6d34e 100644 --- a/gcc/ada/switch.adb +++ b/gcc/ada/switch.adb @@ -148,10 +148,10 @@ package body Switch is begin return Is_Switch (Switch_Chars) and then - (Switch_Chars (First .. Last) = "-param" or else - Switch_Chars (First .. Last) = "dumpbase" or else - Switch_Chars (First .. Last) = "auxbase-strip" or else - Switch_Chars (First .. Last) = "auxbase"); + (Switch_Chars (First .. Last) = "-param" + or else Switch_Chars (First .. Last) = "dumpbase" + or else Switch_Chars (First .. Last) = "auxbase-strip" + or else Switch_Chars (First .. Last) = "auxbase"); end Is_Internal_GCC_Switch; --------------- @@ -169,15 +169,15 @@ package body Switch is ----------------- function Switch_Last (Switch_Chars : String) return Natural is - Last : constant Natural := Switch_Chars'Last; + Last : Natural := Switch_Chars'Last; begin if Last >= Switch_Chars'First and then Switch_Chars (Last) = ASCII.NUL then - return Last - 1; - else - return Last; + Last := Last - 1; end if; + + return Last; end Switch_Last; ----------------- diff --git a/gcc/ada/sysdep.c b/gcc/ada/sysdep.c index c0489504f43..a27c1479e22 100644 --- a/gcc/ada/sysdep.c +++ b/gcc/ada/sysdep.c @@ -814,7 +814,10 @@ __gnat_localtime_tzoff (const time_t *timer, long *off) } #else -#if defined (__Lynx__) && defined (___THREADS_POSIX4ad4__) + +/* On Lynx, all time values are treated in GMT */ + +#if defined (__Lynx__) /* As of LynxOS 3.1.0a patch level 040, LynuxWorks changes the prototype to the C library function localtime_r from the POSIX.4 @@ -828,18 +831,24 @@ __gnat_localtime_tzoff (const time_t *, long *); void __gnat_localtime_tzoff (const time_t *timer, long *off) { - /* Treat all time values in GMT */ *off = 0; } #else + +/* VMS does not need __gnat_locatime_tzoff */ + #if defined (VMS) -/* __gnat_localtime_tzoff is not needed on VMS */ +/* Other targets except Lynx, VMS and Windows provide a standard locatime_r */ #else -/* All other targets provide a standard localtime_r */ +#define Lock_Task system__soft_links__lock_task +extern void (*Lock_Task) (void); + +#define Unlock_Task system__soft_links__unlock_task +extern void (*Unlock_Task) (void); extern void __gnat_localtime_tzoff (const time_t *, long *); @@ -847,25 +856,33 @@ __gnat_localtime_tzoff (const time_t *, long *); void __gnat_localtime_tzoff (const time_t *timer, long *off) { - struct tm tp; - localtime_r (timer, &tp); + struct tm tp; /* AIX, HPUX, SGI Irix, Sun Solaris */ #if defined (_AIX) || defined (__hpux__) || defined (sgi) || defined (sun) - *off = (long) -timezone; - if (tp.tm_isdst > 0) - *off = *off + 3600; +{ + (*Lock_Task) (); -/* Lynx - Treat all time values in GMT */ -#elif defined (__Lynx__) - *off = 0; + localtime_r (timer, &tp); + *off = (long) -timezone; + + (*Unlock_Task) (); + + if (tp.tm_isdst > 0) + *off = *off + 3600; +} /* VxWorks */ #elif defined (__vxworks) #include <stdlib.h> { + (*Lock_Task) (); + + localtime_r (timer, &tp); + /* Try to read the environment variable TIMEZONE. The variable may not have been initialize, in that case return an offset of zero (0) for UTC. */ + char *tz_str = getenv ("TIMEZONE"); if ((tz_str == NULL) || (*tz_str == '\0')) @@ -880,24 +897,34 @@ __gnat_localtime_tzoff (const time_t *timer, long *off) the value of U involves setting two pointers, one at the beginning and one at the end of the value. The end pointer is then set to null in order to delimit a string slice for atol to process. */ + tz_start = index (tz_str, ':') + 2; tz_end = index (tz_start, ':'); tz_end = '\0'; /* The Ada layer expects an offset in seconds */ + *off = atol (tz_start) * 60; } + + (*Unlock_Task) (); } /* Darwin, Free BSD, Linux, Tru64, where component tm_gmtoff is present in struct tm */ + #elif defined (__APPLE__) || defined (__FreeBSD__) || defined (linux) ||\ (defined (__alpha__) && defined (__osf__)) || defined (__GLIBC__) +{ + localtime_r (timer, &tp); *off = tp.tm_gmtoff; +} + +/* Default: treat all time values in GMT */ -/* All other platforms: Treat all time values in GMT */ #else *off = 0; + #endif } diff --git a/gcc/ada/tbuild.adb b/gcc/ada/tbuild.adb index be882055af4..7273fde6703 100644 --- a/gcc/ada/tbuild.adb +++ b/gcc/ada/tbuild.adb @@ -436,14 +436,19 @@ package body Tbuild is Strval => End_String); end Make_String_Literal; + -------------------- + -- Make_Temporary -- + -------------------- + function Make_Temporary - (Loc : Source_Ptr; - Id : Name_Id; + (Loc : Source_Ptr; + Id : Character; Related_Node : Node_Id := Empty) return Node_Id is - Temp : Node_Id; + Temp : constant Node_Id := + Make_Defining_Identifier (Loc, + Chars => New_Internal_Name (Id)); begin - Temp := Make_Defining_Identifier (Loc, Id); Set_Related_Expression (Temp, Related_Node); return Temp; end Make_Temporary; diff --git a/gcc/ada/tbuild.ads b/gcc/ada/tbuild.ads index f12b616c93a..261776df78f 100644 --- a/gcc/ada/tbuild.ads +++ b/gcc/ada/tbuild.ads @@ -176,12 +176,13 @@ package Tbuild is -- is given as a normal string instead of a String_Id value. function Make_Temporary - (Loc : Source_Ptr; - Id : Name_Id; + (Loc : Source_Ptr; + Id : Character; Related_Node : Node_Id := Empty) return Node_Id; -- Create a defining identifier to capture the value of an expression -- or aggregate, and link it to the expression that it replaces, in - -- order to provide better CodePeer reports. + -- order to provide better CodePeer reports. The defining identifier + -- name is obtained by Make_Internal_Name (Id). function Make_Unsuppress_Block (Loc : Source_Ptr; diff --git a/gcc/ada/tree_in.ads b/gcc/ada/tree_in.ads index d41ee4363b6..66c590acae0 100644 --- a/gcc/ada/tree_in.ads +++ b/gcc/ada/tree_in.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2009 Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- diff --git a/gcc/ada/tree_io.ads b/gcc/ada/tree_io.ads index f5d4bff9cd2..c436054176a 100644 --- a/gcc/ada/tree_io.ads +++ b/gcc/ada/tree_io.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2009 Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- diff --git a/gcc/ada/usage.adb b/gcc/ada/usage.adb index 47e78997559..6b87db9a91f 100644 --- a/gcc/ada/usage.adb +++ b/gcc/ada/usage.adb @@ -202,6 +202,11 @@ begin Write_Switch_Char ("ep=?"); Write_Line ("Specify preprocessing data file, e.g. -gnatep=prep.data"); + -- Line for -gnateS switch + + Write_Switch_Char ("eS"); + Write_Line ("Generate SCO (Source Coverage Obligation) information"); + -- Line for -gnatE switch Write_Switch_Char ("E"); diff --git a/gcc/alias.c b/gcc/alias.c index e9cc2d85f96..fc259b8ef2d 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -279,6 +279,11 @@ ao_ref_from_mem (ao_ref *ref, const_rtx mem) && TREE_CODE (TREE_OPERAND (base, 0)) != SSA_NAME) return false; + /* The tree oracle doesn't like to have these. */ + if (TREE_CODE (base) == FUNCTION_DECL + || TREE_CODE (base) == LABEL_DECL) + return false; + /* If this is a reference based on a partitioned decl replace the base with an INDIRECT_REF of the pointer representative we created during stack slot partitioning. */ diff --git a/gcc/builtins.c b/gcc/builtins.c index a5f41fc91f8..57c0c1bce59 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -60,6 +60,9 @@ along with GCC; see the file COPYING3. If not see #endif #ifdef HAVE_mpc static tree do_mpc_arg1 (tree, tree, int (*)(mpc_ptr, mpc_srcptr, mpc_rnd_t)); +#ifdef HAVE_mpc_pow +static tree do_mpc_arg2 (tree, tree, tree, int (*)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t)); +#endif #endif /* Define the names of the builtin function types and codes. */ @@ -149,65 +152,65 @@ static rtx expand_builtin_fputs (tree, rtx, bool); static rtx expand_builtin_printf (tree, rtx, enum machine_mode, bool); static rtx expand_builtin_fprintf (tree, rtx, enum machine_mode, bool); static rtx expand_builtin_sprintf (tree, rtx, enum machine_mode); -static tree stabilize_va_list (tree, int); +static tree stabilize_va_list_loc (location_t, tree, int); static rtx expand_builtin_expect (tree, rtx); static tree fold_builtin_constant_p (tree); -static tree fold_builtin_expect (tree, tree); +static tree fold_builtin_expect (location_t, tree, tree); static tree fold_builtin_classify_type (tree); -static tree fold_builtin_strlen (tree); -static tree fold_builtin_inf (tree, int); +static tree fold_builtin_strlen (location_t, tree); +static tree fold_builtin_inf (location_t, tree, int); static tree fold_builtin_nan (tree, tree, int); -static tree rewrite_call_expr (tree, int, tree, int, ...); +static tree rewrite_call_expr (location_t, tree, int, tree, int, ...); static bool validate_arg (const_tree, enum tree_code code); static bool integer_valued_real_p (tree); -static tree fold_trunc_transparent_mathfn (tree, tree); +static tree fold_trunc_transparent_mathfn (location_t, tree, tree); static bool readonly_data_expr (tree); static rtx expand_builtin_fabs (tree, rtx, rtx); static rtx expand_builtin_signbit (tree, rtx); -static tree fold_builtin_sqrt (tree, tree); -static tree fold_builtin_cbrt (tree, tree); -static tree fold_builtin_pow (tree, tree, tree, tree); -static tree fold_builtin_powi (tree, tree, tree, tree); -static tree fold_builtin_cos (tree, tree, tree); -static tree fold_builtin_cosh (tree, tree, tree); +static tree fold_builtin_sqrt (location_t, tree, tree); +static tree fold_builtin_cbrt (location_t, tree, tree); +static tree fold_builtin_pow (location_t, tree, tree, tree, tree); +static tree fold_builtin_powi (location_t, tree, tree, tree, tree); +static tree fold_builtin_cos (location_t, tree, tree, tree); +static tree fold_builtin_cosh (location_t, tree, tree, tree); static tree fold_builtin_tan (tree, tree); -static tree fold_builtin_trunc (tree, tree); -static tree fold_builtin_floor (tree, tree); -static tree fold_builtin_ceil (tree, tree); -static tree fold_builtin_round (tree, tree); -static tree fold_builtin_int_roundingfn (tree, tree); +static tree fold_builtin_trunc (location_t, tree, tree); +static tree fold_builtin_floor (location_t, tree, tree); +static tree fold_builtin_ceil (location_t, tree, tree); +static tree fold_builtin_round (location_t, tree, tree); +static tree fold_builtin_int_roundingfn (location_t, tree, tree); static tree fold_builtin_bitop (tree, tree); -static tree fold_builtin_memory_op (tree, tree, tree, tree, bool, int); -static tree fold_builtin_strchr (tree, tree, tree); -static tree fold_builtin_memchr (tree, tree, tree, tree); -static tree fold_builtin_memcmp (tree, tree, tree); -static tree fold_builtin_strcmp (tree, tree); -static tree fold_builtin_strncmp (tree, tree, tree); -static tree fold_builtin_signbit (tree, tree); -static tree fold_builtin_copysign (tree, tree, tree, tree); -static tree fold_builtin_isascii (tree); -static tree fold_builtin_toascii (tree); -static tree fold_builtin_isdigit (tree); -static tree fold_builtin_fabs (tree, tree); -static tree fold_builtin_abs (tree, tree); -static tree fold_builtin_unordered_cmp (tree, tree, tree, enum tree_code, +static tree fold_builtin_memory_op (location_t, tree, tree, tree, tree, bool, int); +static tree fold_builtin_strchr (location_t, tree, tree, tree); +static tree fold_builtin_memchr (location_t, tree, tree, tree, tree); +static tree fold_builtin_memcmp (location_t, tree, tree, tree); +static tree fold_builtin_strcmp (location_t, tree, tree); +static tree fold_builtin_strncmp (location_t, tree, tree, tree); +static tree fold_builtin_signbit (location_t, tree, tree); +static tree fold_builtin_copysign (location_t, tree, tree, tree, tree); +static tree fold_builtin_isascii (location_t, tree); +static tree fold_builtin_toascii (location_t, tree); +static tree fold_builtin_isdigit (location_t, tree); +static tree fold_builtin_fabs (location_t, tree, tree); +static tree fold_builtin_abs (location_t, tree, tree); +static tree fold_builtin_unordered_cmp (location_t, tree, tree, tree, enum tree_code, enum tree_code); -static tree fold_builtin_n (tree, tree *, int, bool); -static tree fold_builtin_0 (tree, bool); -static tree fold_builtin_1 (tree, tree, bool); -static tree fold_builtin_2 (tree, tree, tree, bool); -static tree fold_builtin_3 (tree, tree, tree, tree, bool); -static tree fold_builtin_4 (tree, tree, tree, tree, tree, bool); -static tree fold_builtin_varargs (tree, tree, bool); - -static tree fold_builtin_strpbrk (tree, tree, tree); -static tree fold_builtin_strstr (tree, tree, tree); -static tree fold_builtin_strrchr (tree, tree, tree); -static tree fold_builtin_strcat (tree, tree); -static tree fold_builtin_strncat (tree, tree, tree); -static tree fold_builtin_strspn (tree, tree); -static tree fold_builtin_strcspn (tree, tree); -static tree fold_builtin_sprintf (tree, tree, tree, int); +static tree fold_builtin_n (location_t, tree, tree *, int, bool); +static tree fold_builtin_0 (location_t, tree, bool); +static tree fold_builtin_1 (location_t, tree, tree, bool); +static tree fold_builtin_2 (location_t, tree, tree, tree, bool); +static tree fold_builtin_3 (location_t, tree, tree, tree, tree, bool); +static tree fold_builtin_4 (location_t, tree, tree, tree, tree, tree, bool); +static tree fold_builtin_varargs (location_t, tree, tree, bool); + +static tree fold_builtin_strpbrk (location_t, tree, tree, tree); +static tree fold_builtin_strstr (location_t, tree, tree, tree); +static tree fold_builtin_strrchr (location_t, tree, tree, tree); +static tree fold_builtin_strcat (location_t, tree, tree); +static tree fold_builtin_strncat (location_t, tree, tree, tree); +static tree fold_builtin_strspn (location_t, tree, tree); +static tree fold_builtin_strcspn (location_t, tree, tree); +static tree fold_builtin_sprintf (location_t, tree, tree, tree, int); static rtx expand_builtin_object_size (tree); static rtx expand_builtin_memory_chk (tree, rtx, enum machine_mode, @@ -216,11 +219,11 @@ static void maybe_emit_chk_warning (tree, enum built_in_function); static void maybe_emit_sprintf_chk_warning (tree, enum built_in_function); static void maybe_emit_free_warning (tree); static tree fold_builtin_object_size (tree, tree); -static tree fold_builtin_strcat_chk (tree, tree, tree, tree); -static tree fold_builtin_strncat_chk (tree, tree, tree, tree, tree); -static tree fold_builtin_sprintf_chk (tree, enum built_in_function); -static tree fold_builtin_printf (tree, tree, tree, bool, enum built_in_function); -static tree fold_builtin_fprintf (tree, tree, tree, tree, bool, +static tree fold_builtin_strcat_chk (location_t, tree, tree, tree, tree); +static tree fold_builtin_strncat_chk (location_t, tree, tree, tree, tree, tree); +static tree fold_builtin_sprintf_chk (location_t, tree, enum built_in_function); +static tree fold_builtin_printf (location_t, tree, tree, tree, bool, enum built_in_function); +static tree fold_builtin_fprintf (location_t, tree, tree, tree, tree, bool, enum built_in_function); static bool init_target_chars (void); @@ -479,7 +482,7 @@ c_strlen (tree src, int only_value) and return that. This would perhaps not be valid if we were dealing with named arrays in addition to literal string constants. */ - return size_diffop (size_int (max), offset_node); + return size_diffop_loc (input_location, size_int (max), offset_node); } /* We have a known offset into the string. Start searching there for @@ -2265,6 +2268,7 @@ expand_builtin_interclass_mathfn (tree exp, rtx target, rtx subtarget) enum machine_mode mode; bool errno_set = false; tree arg; + location_t loc = EXPR_LOCATION (exp); if (!validate_arglist (exp, REAL_TYPE, VOID_TYPE)) return NULL_RTX; @@ -2339,7 +2343,7 @@ expand_builtin_interclass_mathfn (tree exp, rtx target, rtx subtarget) get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf)); real_from_string (&r, buf); result = build_call_expr (isgr_fn, 2, - fold_build1 (ABS_EXPR, type, arg), + fold_build1_loc (loc, ABS_EXPR, type, arg), build_real (type, r)); return expand_expr (result, target, VOIDmode, EXPAND_NORMAL); } @@ -2355,7 +2359,7 @@ expand_builtin_interclass_mathfn (tree exp, rtx target, rtx subtarget) get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf)); real_from_string (&r, buf); result = build_call_expr (isle_fn, 2, - fold_build1 (ABS_EXPR, type, arg), + fold_build1_loc (loc, ABS_EXPR, type, arg), build_real (type, r)); return expand_expr (result, target, VOIDmode, EXPAND_NORMAL); } @@ -2373,7 +2377,7 @@ expand_builtin_interclass_mathfn (tree exp, rtx target, rtx subtarget) real_from_string (&rmax, buf); sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (mode)->emin - 1); real_from_string (&rmin, buf); - arg = builtin_save_expr (fold_build1 (ABS_EXPR, type, arg)); + arg = builtin_save_expr (fold_build1_loc (loc, ABS_EXPR, type, arg)); result = build_call_expr (isle_fn, 2, arg, build_real (type, rmax)); result = fold_build2 (BIT_AND_EXPR, integer_type_node, result, @@ -2402,6 +2406,7 @@ expand_builtin_sincos (tree exp) enum machine_mode mode; tree arg, sinp, cosp; int result; + location_t loc = EXPR_LOCATION (exp); if (!validate_arglist (exp, REAL_TYPE, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) @@ -2422,8 +2427,8 @@ expand_builtin_sincos (tree exp) target2 = gen_reg_rtx (mode); op0 = expand_normal (arg); - op1 = expand_normal (build_fold_indirect_ref (sinp)); - op2 = expand_normal (build_fold_indirect_ref (cosp)); + op1 = expand_normal (build_fold_indirect_ref_loc (loc, sinp)); + op2 = expand_normal (build_fold_indirect_ref_loc (loc, cosp)); /* Compute into target1 and target2. Set TARGET to wherever the result comes back. */ @@ -2450,6 +2455,7 @@ expand_builtin_cexpi (tree exp, rtx target, rtx subtarget) tree arg, type; enum machine_mode mode; rtx op0, op1, op2; + location_t loc = EXPR_LOCATION (exp); if (!validate_arglist (exp, REAL_TYPE, VOID_TYPE)) return NULL_RTX; @@ -2531,7 +2537,7 @@ expand_builtin_cexpi (tree exp, rtx target, rtx subtarget) fn = build_fn_decl (name, fntype); } - narg = fold_build2 (COMPLEX_EXPR, ctype, + narg = fold_build2_loc (loc, COMPLEX_EXPR, ctype, build_real (type, dconst0), arg); /* Make sure not to fold the cexp call again. */ @@ -3266,7 +3272,8 @@ expand_builtin_strstr (tree exp, rtx target, enum machine_mode mode) if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) { tree type = TREE_TYPE (exp); - tree result = fold_builtin_strstr (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_strstr (EXPR_LOCATION (exp), + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1), type); if (result) return expand_expr (result, target, mode, EXPAND_NORMAL); @@ -3284,7 +3291,8 @@ expand_builtin_strchr (tree exp, rtx target, enum machine_mode mode) if (validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) { tree type = TREE_TYPE (exp); - tree result = fold_builtin_strchr (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_strchr (EXPR_LOCATION (exp), + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1), type); if (result) return expand_expr (result, target, mode, EXPAND_NORMAL); @@ -3304,7 +3312,8 @@ expand_builtin_strrchr (tree exp, rtx target, enum machine_mode mode) if (validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) { tree type = TREE_TYPE (exp); - tree result = fold_builtin_strrchr (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_strrchr (EXPR_LOCATION (exp), + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1), type); if (result) return expand_expr (result, target, mode, EXPAND_NORMAL); @@ -3322,7 +3331,8 @@ expand_builtin_strpbrk (tree exp, rtx target, enum machine_mode mode) if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) { tree type = TREE_TYPE (exp); - tree result = fold_builtin_strpbrk (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_strpbrk (EXPR_LOCATION (exp), + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1), type); if (result) return expand_expr (result, target, mode, EXPAND_NORMAL); @@ -3370,7 +3380,8 @@ expand_builtin_memcpy (tree exp, rtx target, enum machine_mode mode) unsigned int dest_align = get_pointer_alignment (dest, BIGGEST_ALIGNMENT); rtx dest_mem, src_mem, dest_addr, len_rtx; - tree result = fold_builtin_memory_op (dest, src, len, + tree result = fold_builtin_memory_op (EXPR_LOCATION (exp), + dest, src, len, TREE_TYPE (TREE_TYPE (fndecl)), false, /*endp=*/0); HOST_WIDE_INT expected_size = -1; @@ -3501,7 +3512,8 @@ expand_builtin_mempcpy_args (tree dest, tree src, tree len, tree type, unsigned int dest_align = get_pointer_alignment (dest, BIGGEST_ALIGNMENT); rtx dest_mem, src_mem, len_rtx; - tree result = fold_builtin_memory_op (dest, src, len, type, false, endp); + tree result = fold_builtin_memory_op (UNKNOWN_LOCATION, + dest, src, len, type, false, endp); if (result) { @@ -3596,7 +3608,8 @@ expand_builtin_memmove_args (tree dest, tree src, tree len, tree type, rtx target, enum machine_mode mode, int ignore) { - tree result = fold_builtin_memory_op (dest, src, len, type, ignore, /*endp=*/3); + tree result = fold_builtin_memory_op (UNKNOWN_LOCATION, + dest, src, len, type, ignore, /*endp=*/3); if (result) { @@ -3622,6 +3635,7 @@ expand_builtin_bcopy (tree exp, int ignore) { tree type = TREE_TYPE (exp); tree src, dest, size; + location_t loc = EXPR_LOCATION (exp); if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) @@ -3635,7 +3649,7 @@ expand_builtin_bcopy (tree exp, int ignore) This is done this way so that if it isn't expanded inline, we fall back to calling bcopy instead of memmove. */ return expand_builtin_memmove_args (dest, src, - fold_convert (sizetype, size), + fold_convert_loc (loc, sizetype, size), type, const0_rtx, VOIDmode, ignore); } @@ -3734,7 +3748,8 @@ static rtx expand_builtin_strcpy_args (tree fndecl, tree dest, tree src, rtx target, enum machine_mode mode) { - tree result = fold_builtin_strcpy (fndecl, dest, src, 0); + tree result = fold_builtin_strcpy (UNKNOWN_LOCATION, + fndecl, dest, src, 0); if (result) return expand_expr (result, target, mode, EXPAND_NORMAL); return expand_movstr (dest, src, target, /*endp=*/0); @@ -3750,6 +3765,7 @@ static rtx expand_builtin_stpcpy (tree exp, rtx target, enum machine_mode mode) { tree dst, src; + location_t loc = EXPR_LOCATION (exp); if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) return NULL_RTX; @@ -3784,7 +3800,7 @@ expand_builtin_stpcpy (tree exp, rtx target, enum machine_mode mode) if (! c_getstr (src) || ! (len = c_strlen (src, 0))) return expand_movstr (dst, src, target, /*endp=*/2); - lenp1 = size_binop (PLUS_EXPR, len, ssize_int (1)); + lenp1 = size_binop_loc (loc, PLUS_EXPR, len, ssize_int (1)); ret = expand_builtin_mempcpy_args (dst, src, lenp1, TREE_TYPE (exp), target, mode, /*endp=*/2); @@ -3848,6 +3864,7 @@ static rtx expand_builtin_strncpy (tree exp, rtx target, enum machine_mode mode) { tree fndecl = get_callee_fndecl (exp); + location_t loc = EXPR_LOCATION (exp); if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) @@ -3856,7 +3873,8 @@ expand_builtin_strncpy (tree exp, rtx target, enum machine_mode mode) tree src = CALL_EXPR_ARG (exp, 1); tree len = CALL_EXPR_ARG (exp, 2); tree slen = c_strlen (src, 1); - tree result = fold_builtin_strncpy (fndecl, dest, src, len, slen); + tree result = fold_builtin_strncpy (EXPR_LOCATION (exp), + fndecl, dest, src, len, slen); if (result) { @@ -3873,7 +3891,7 @@ expand_builtin_strncpy (tree exp, rtx target, enum machine_mode mode) if (!host_integerp (len, 1) || !slen || !host_integerp (slen, 1)) return NULL_RTX; - slen = size_binop (PLUS_EXPR, slen, ssize_int (1)); + slen = size_binop_loc (loc, PLUS_EXPR, slen, ssize_int (1)); /* We're required to pad with trailing zeros if the requested len is greater than strlen(s2)+1. In that case try to @@ -4103,6 +4121,7 @@ static rtx expand_builtin_bzero (tree exp) { tree dest, size; + location_t loc = EXPR_LOCATION (exp); if (!validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) return NULL_RTX; @@ -4116,7 +4135,7 @@ expand_builtin_bzero (tree exp) calling bzero instead of memset. */ return expand_builtin_memset_args (dest, integer_zero_node, - fold_convert (sizetype, size), + fold_convert_loc (loc, sizetype, size), const0_rtx, VOIDmode, exp); } @@ -4131,7 +4150,8 @@ expand_builtin_memchr (tree exp, rtx target, enum machine_mode mode) INTEGER_TYPE, VOID_TYPE)) { tree type = TREE_TYPE (exp); - tree result = fold_builtin_memchr (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_memchr (EXPR_LOCATION (exp), + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1), CALL_EXPR_ARG (exp, 2), type); if (result) @@ -4148,12 +4168,15 @@ expand_builtin_memchr (tree exp, rtx target, enum machine_mode mode) static rtx expand_builtin_memcmp (tree exp, rtx target, enum machine_mode mode) { + location_t loc = EXPR_LOCATION (exp); + if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) return NULL_RTX; else { - tree result = fold_builtin_memcmp (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_memcmp (loc, + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1), CALL_EXPR_ARG (exp, 2)); if (result) @@ -4200,7 +4223,7 @@ expand_builtin_memcmp (tree exp, rtx target, enum machine_mode mode) arg1_rtx = get_memory_rtx (arg1, len); arg2_rtx = get_memory_rtx (arg2, len); - arg3_rtx = expand_normal (fold_convert (sizetype, len)); + arg3_rtx = expand_normal (fold_convert_loc (loc, sizetype, len)); /* Set MEM_SIZE as appropriate. */ if (CONST_INT_P (arg3_rtx)) @@ -4258,11 +4281,14 @@ expand_builtin_memcmp (tree exp, rtx target, enum machine_mode mode) static rtx expand_builtin_strcmp (tree exp, rtx target, enum machine_mode mode) { + location_t loc = EXPR_LOCATION (exp); + if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) return NULL_RTX; else { - tree result = fold_builtin_strcmp (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_strcmp (loc, + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1)); if (result) return expand_expr (result, target, mode, EXPAND_NORMAL); @@ -4407,12 +4433,15 @@ expand_builtin_strcmp (tree exp, rtx target, enum machine_mode mode) static rtx expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode) { + location_t loc = EXPR_LOCATION (exp); + if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) return NULL_RTX; else { - tree result = fold_builtin_strncmp (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_strncmp (loc, + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1), CALL_EXPR_ARG (exp, 2)); if (result) @@ -4444,9 +4473,9 @@ expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode) len2 = c_strlen (arg2, 1); if (len1) - len1 = size_binop (PLUS_EXPR, ssize_int (1), len1); + len1 = size_binop_loc (loc, PLUS_EXPR, ssize_int (1), len1); if (len2) - len2 = size_binop (PLUS_EXPR, ssize_int (1), len2); + len2 = size_binop_loc (loc, PLUS_EXPR, ssize_int (1), len2); /* If we don't have a constant length for the first, use the length of the second, if we know it. We don't require a constant for @@ -4477,8 +4506,8 @@ expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode) return NULL_RTX; /* The actual new length parameter is MIN(len,arg3). */ - len = fold_build2 (MIN_EXPR, TREE_TYPE (len), len, - fold_convert (TREE_TYPE (len), arg3)); + len = fold_build2_loc (loc, MIN_EXPR, TREE_TYPE (len), len, + fold_convert_loc (loc, TREE_TYPE (len), arg3)); /* If we don't have POINTER_TYPE, call the function. */ if (arg1_align == 0 || arg2_align == 0) @@ -4534,6 +4563,8 @@ expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode) static rtx expand_builtin_strcat (tree fndecl, tree exp, rtx target, enum machine_mode mode) { + location_t loc = EXPR_LOCATION (exp); + if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) return NULL_RTX; else @@ -4563,7 +4594,8 @@ expand_builtin_strcat (tree fndecl, tree exp, rtx target, enum machine_mode mode newdst = build_call_expr (strlen_fn, 1, dst); /* Create (dst p+ strlen (dst)). */ - newdst = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dst), dst, newdst); + newdst = fold_build2_loc (loc, POINTER_PLUS_EXPR, + TREE_TYPE (dst), dst, newdst); newdst = builtin_save_expr (newdst); if (!expand_builtin_strcpy_args (fndecl, newdst, newsrc, target, mode)) @@ -4594,7 +4626,8 @@ expand_builtin_strncat (tree exp, rtx target, enum machine_mode mode) if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) { - tree result = fold_builtin_strncat (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_strncat (EXPR_LOCATION (exp), + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1), CALL_EXPR_ARG (exp, 2)); if (result) @@ -4612,7 +4645,8 @@ expand_builtin_strspn (tree exp, rtx target, enum machine_mode mode) { if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) { - tree result = fold_builtin_strspn (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_strspn (EXPR_LOCATION (exp), + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1)); if (result) return expand_expr (result, target, mode, EXPAND_NORMAL); @@ -4629,7 +4663,8 @@ expand_builtin_strcspn (tree exp, rtx target, enum machine_mode mode) { if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) { - tree result = fold_builtin_strcspn (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_strcspn (EXPR_LOCATION (exp), + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1)); if (result) return expand_expr (result, target, mode, EXPAND_NORMAL); @@ -4723,7 +4758,7 @@ expand_builtin_next_arg (void) from multiple evaluations. */ static tree -stabilize_va_list (tree valist, int needs_lvalue) +stabilize_va_list_loc (location_t loc, tree valist, int needs_lvalue) { tree vatype = targetm.canonical_va_list_type (TREE_TYPE (valist)); @@ -4741,7 +4776,7 @@ stabilize_va_list (tree valist, int needs_lvalue) if (TREE_CODE (TREE_TYPE (valist)) == ARRAY_TYPE) { tree p1 = build_pointer_type (TREE_TYPE (vatype)); - valist = build_fold_addr_expr_with_type (valist, p1); + valist = build_fold_addr_expr_with_type_loc (loc, valist, p1); } } else @@ -4754,13 +4789,13 @@ stabilize_va_list (tree valist, int needs_lvalue) return valist; pt = build_pointer_type (vatype); - valist = fold_build1 (ADDR_EXPR, pt, valist); + valist = fold_build1_loc (loc, ADDR_EXPR, pt, valist); TREE_SIDE_EFFECTS (valist) = 1; } if (TREE_SIDE_EFFECTS (valist)) valist = save_expr (valist); - valist = build_fold_indirect_ref (valist); + valist = build_fold_indirect_ref_loc (loc, valist); } return valist; @@ -4834,10 +4869,11 @@ expand_builtin_va_start (tree exp) { rtx nextarg; tree valist; + location_t loc = EXPR_LOCATION (exp); if (call_expr_nargs (exp) < 2) { - error ("too few arguments to function %<va_start%>"); + error_at (loc, "too few arguments to function %<va_start%>"); return const0_rtx; } @@ -4845,7 +4881,7 @@ expand_builtin_va_start (tree exp) return const0_rtx; nextarg = expand_builtin_next_arg (); - valist = stabilize_va_list (CALL_EXPR_ARG (exp, 0), 1); + valist = stabilize_va_list_loc (loc, CALL_EXPR_ARG (exp, 0), 1); if (targetm.expand_builtin_va_start) targetm.expand_builtin_va_start (valist, nextarg); @@ -4898,7 +4934,8 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, && !integer_zerop (TYPE_SIZE (type))) { t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp, - fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (valist), + fold_build2 (POINTER_PLUS_EXPR, + TREE_TYPE (valist), valist_tmp, size_int (boundary - 1))); gimplify_and_add (t, pre_p); @@ -4934,10 +4971,12 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, if (PAD_VARARGS_DOWN && !integer_zerop (rounded_size)) { /* Small args are padded downward. */ - t = fold_build2 (GT_EXPR, sizetype, rounded_size, size_int (align)); + t = fold_build2_loc (input_location, GT_EXPR, sizetype, + rounded_size, size_int (align)); t = fold_build3 (COND_EXPR, sizetype, t, size_zero_node, size_binop (MINUS_EXPR, rounded_size, type_size)); - addr = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (addr), addr, t); + addr = fold_build2 (POINTER_PLUS_EXPR, + TREE_TYPE (addr), addr, t); } /* Compute new value for AP. */ @@ -4958,7 +4997,7 @@ std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, tree build_va_arg_indirect_ref (tree addr) { - addr = build_fold_indirect_ref (addr); + addr = build_fold_indirect_ref_loc (EXPR_LOCATION (addr), addr); if (flag_mudflap) /* Don't instrument va_arg INDIRECT_REF. */ mf_mark (addr); @@ -4986,8 +5025,7 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) tree valist = TREE_OPERAND (*expr_p, 0); tree type = TREE_TYPE (*expr_p); tree t; - location_t loc = EXPR_HAS_LOCATION (*expr_p) ? EXPR_LOCATION (*expr_p) : - UNKNOWN_LOCATION; + location_t loc = EXPR_LOCATION (*expr_p); /* Verify that valist is of the proper type. */ have_va_type = TREE_TYPE (valist); @@ -5029,7 +5067,8 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) /* Before the abort, allow the evaluation of the va_list expression to exit or longjmp. */ gimplify_and_add (valist, pre_p); - t = build_call_expr (implicit_built_in_decls[BUILT_IN_TRAP], 0); + t = build_call_expr_loc (loc, + implicit_built_in_decls[BUILT_IN_TRAP], 0); gimplify_and_add (t, pre_p); /* This is dead code, but go ahead and finish so that the @@ -5050,7 +5089,8 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) if (TREE_CODE (TREE_TYPE (valist)) == ARRAY_TYPE) { tree p1 = build_pointer_type (TREE_TYPE (have_va_type)); - valist = fold_convert (p1, build_fold_addr_expr (valist)); + valist = fold_convert_loc (loc, p1, + build_fold_addr_expr_loc (loc, valist)); } gimplify_expr (&valist, pre_p, post_p, is_gimple_val, fb_rvalue); @@ -5064,6 +5104,7 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) return GS_ALL_DONE; *expr_p = targetm.gimplify_va_arg_expr (valist, type, pre_p, post_p); + SET_EXPR_LOCATION (*expr_p, loc); return GS_OK; } } @@ -5091,12 +5132,13 @@ static rtx expand_builtin_va_copy (tree exp) { tree dst, src, t; + location_t loc = EXPR_LOCATION (exp); dst = CALL_EXPR_ARG (exp, 0); src = CALL_EXPR_ARG (exp, 1); - dst = stabilize_va_list (dst, 1); - src = stabilize_va_list (src, 0); + dst = stabilize_va_list_loc (loc, dst, 1); + src = stabilize_va_list_loc (loc, src, 0); gcc_assert (cfun != NULL && cfun->decl != NULL_TREE); @@ -5267,7 +5309,8 @@ expand_builtin_fputs (tree exp, rtx target, bool unlocked) /* Verify the arguments in the original call. */ if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) { - tree result = fold_builtin_fputs (CALL_EXPR_ARG (exp, 0), + tree result = fold_builtin_fputs (EXPR_LOCATION (exp), + CALL_EXPR_ARG (exp, 0), CALL_EXPR_ARG (exp, 1), (target == const0_rtx), unlocked, NULL_TREE); @@ -5843,6 +5886,7 @@ expand_builtin_signbit (tree exp, rtx target) int word, bitpos; enum insn_code icode; rtx temp; + location_t loc = EXPR_LOCATION (exp); if (!validate_arglist (exp, REAL_TYPE, VOID_TYPE)) return NULL_RTX; @@ -5876,7 +5920,7 @@ expand_builtin_signbit (tree exp, rtx target) if (fmt->has_signed_zero && HONOR_SIGNED_ZEROS (fmode)) return NULL_RTX; - arg = fold_build2 (LT_EXPR, TREE_TYPE (exp), arg, + arg = fold_build2_loc (loc, LT_EXPR, TREE_TYPE (exp), arg, build_real (TREE_TYPE (arg), dconst0)); return expand_expr (arg, target, VOIDmode, EXPAND_NORMAL); } @@ -6004,7 +6048,7 @@ expand_builtin_fork_or_exec (tree fn, tree exp, rtx target, int ignore) TREE_NOTHROW (decl) = 1; DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT; DECL_VISIBILITY_SPECIFIED (decl) = 1; - call = rewrite_call_expr (exp, 0, decl, 0); + call = rewrite_call_expr (EXPR_LOCATION (exp), exp, 0, decl, 0); return expand_call (call, target, ignore); } @@ -7289,7 +7333,7 @@ fold_builtin_constant_p (tree arg) return it as a truthvalue. */ static tree -build_builtin_expect_predicate (tree pred, tree expected) +build_builtin_expect_predicate (location_t loc, tree pred, tree expected) { tree fn, arg_types, pred_type, expected_type, call_expr, ret_type; @@ -7299,9 +7343,9 @@ build_builtin_expect_predicate (tree pred, tree expected) pred_type = TREE_VALUE (arg_types); expected_type = TREE_VALUE (TREE_CHAIN (arg_types)); - pred = fold_convert (pred_type, pred); - expected = fold_convert (expected_type, expected); - call_expr = build_call_expr (fn, 2, pred, expected); + pred = fold_convert_loc (loc, pred_type, pred); + expected = fold_convert_loc (loc, expected_type, expected); + call_expr = build_call_expr_loc (loc, fn, 2, pred, expected); return build2 (NE_EXPR, TREE_TYPE (pred), call_expr, build_int_cst (ret_type, 0)); @@ -7311,7 +7355,7 @@ build_builtin_expect_predicate (tree pred, tree expected) NULL_TREE if no simplification is possible. */ static tree -fold_builtin_expect (tree arg0, tree arg1) +fold_builtin_expect (location_t loc, tree arg0, tree arg1) { tree inner, fndecl; enum tree_code code; @@ -7344,11 +7388,11 @@ fold_builtin_expect (tree arg0, tree arg1) tree op0 = TREE_OPERAND (inner, 0); tree op1 = TREE_OPERAND (inner, 1); - op0 = build_builtin_expect_predicate (op0, arg1); - op1 = build_builtin_expect_predicate (op1, arg1); + op0 = build_builtin_expect_predicate (loc, op0, arg1); + op1 = build_builtin_expect_predicate (loc, op1, arg1); inner = build2 (code, TREE_TYPE (inner), op0, op1); - return fold_convert (TREE_TYPE (arg0), inner); + return fold_convert_loc (loc, TREE_TYPE (arg0), inner); } /* If the argument isn't invariant then there's nothing else we can do. */ @@ -7392,7 +7436,7 @@ fold_builtin_classify_type (tree arg) /* Fold a call to __builtin_strlen with argument ARG. */ static tree -fold_builtin_strlen (tree arg) +fold_builtin_strlen (location_t loc, tree arg) { if (!validate_arg (arg, POINTER_TYPE)) return NULL_TREE; @@ -7404,7 +7448,7 @@ fold_builtin_strlen (tree arg) { /* Convert from the internal "sizetype" type to "size_t". */ if (size_type_node) - len = fold_convert (size_type_node, len); + len = fold_convert_loc (loc, size_type_node, len); return len; } @@ -7415,7 +7459,7 @@ fold_builtin_strlen (tree arg) /* Fold a call to __builtin_inf or __builtin_huge_val. */ static tree -fold_builtin_inf (tree type, int warn) +fold_builtin_inf (location_t loc, tree type, int warn) { REAL_VALUE_TYPE real; @@ -7427,7 +7471,7 @@ fold_builtin_inf (tree type, int warn) Thus we pedwarn to ensure this constraint violation is diagnosed. */ if (!MODE_HAS_INFINITIES (TYPE_MODE (type)) && warn) - pedwarn (input_location, 0, "target format does not support infinity"); + pedwarn (loc, 0, "target format does not support infinity"); real_inf (&real); return build_real (type, real); @@ -7530,7 +7574,7 @@ integer_valued_real_p (tree t) Do the transformation for a call with argument ARG. */ static tree -fold_trunc_transparent_mathfn (tree fndecl, tree arg) +fold_trunc_transparent_mathfn (location_t loc, tree fndecl, tree arg) { enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); @@ -7555,9 +7599,11 @@ fold_trunc_transparent_mathfn (tree fndecl, tree arg) if (TYPE_PRECISION (newtype) < TYPE_PRECISION (ftype) && (decl = mathfn_built_in (newtype, fcode))) - return fold_convert (ftype, - build_call_expr (decl, 1, - fold_convert (newtype, arg0))); + return fold_convert_loc (loc, ftype, + build_call_expr_loc (loc, decl, 1, + fold_convert_loc (loc, + newtype, + arg0))); } return NULL_TREE; } @@ -7567,7 +7613,7 @@ fold_trunc_transparent_mathfn (tree fndecl, tree arg) Do the transformation for a call with argument ARG. */ static tree -fold_fixed_mathfn (tree fndecl, tree arg) +fold_fixed_mathfn (location_t loc, tree fndecl, tree arg) { enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); @@ -7577,7 +7623,8 @@ fold_fixed_mathfn (tree fndecl, tree arg) /* If argument is already integer valued, and we don't need to worry about setting errno, there's no need to perform rounding. */ if (! flag_errno_math && integer_valued_real_p (arg)) - return fold_build1 (FIX_TRUNC_EXPR, TREE_TYPE (TREE_TYPE (fndecl)), arg); + return fold_build1_loc (loc, FIX_TRUNC_EXPR, + TREE_TYPE (TREE_TYPE (fndecl)), arg); if (optimize) { @@ -7588,7 +7635,8 @@ fold_fixed_mathfn (tree fndecl, tree arg) if (TYPE_PRECISION (newtype) < TYPE_PRECISION (ftype) && (decl = mathfn_built_in (newtype, fcode))) - return build_call_expr (decl, 1, fold_convert (newtype, arg0)); + return build_call_expr_loc (loc, decl, 1, + fold_convert_loc (loc, newtype, arg0)); } /* Canonicalize llround (x) to lround (x) on LP64 targets where @@ -7621,8 +7669,9 @@ fold_fixed_mathfn (tree fndecl, tree arg) if (newfn) { - tree newcall = build_call_expr(newfn, 1, arg); - return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), newcall); + tree newcall = build_call_expr_loc (loc, newfn, 1, arg); + return fold_convert_loc (loc, + TREE_TYPE (TREE_TYPE (fndecl)), newcall); } } @@ -7633,7 +7682,7 @@ fold_fixed_mathfn (tree fndecl, tree arg) return type. Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_cabs (tree arg, tree type, tree fndecl) +fold_builtin_cabs (location_t loc, tree arg, tree type, tree fndecl) { tree res; @@ -7654,9 +7703,9 @@ fold_builtin_cabs (tree arg, tree type, tree fndecl) /* If either part is zero, cabs is fabs of the other. */ if (real_zerop (real)) - return fold_build1 (ABS_EXPR, type, imag); + return fold_build1_loc (loc, ABS_EXPR, type, imag); if (real_zerop (imag)) - return fold_build1 (ABS_EXPR, type, real); + return fold_build1_loc (loc, ABS_EXPR, type, real); /* cabs(x+xi) -> fabs(x)*sqrt(2). */ if (flag_unsafe_math_optimizations @@ -7665,8 +7714,8 @@ fold_builtin_cabs (tree arg, tree type, tree fndecl) const REAL_VALUE_TYPE sqrt2_trunc = real_value_truncate (TYPE_MODE (type), dconst_sqrt2 ()); STRIP_NOPS (real); - return fold_build2 (MULT_EXPR, type, - fold_build1 (ABS_EXPR, type, real), + return fold_build2_loc (loc, MULT_EXPR, type, + fold_build1_loc (loc, ABS_EXPR, type, real), build_real (type, sqrt2_trunc)); } } @@ -7674,7 +7723,7 @@ fold_builtin_cabs (tree arg, tree type, tree fndecl) /* Optimize cabs(-z) and cabs(conj(z)) as cabs(z). */ if (TREE_CODE (arg) == NEGATE_EXPR || TREE_CODE (arg) == CONJ_EXPR) - return build_call_expr (fndecl, 1, TREE_OPERAND (arg, 0)); + return build_call_expr_loc (loc, fndecl, 1, TREE_OPERAND (arg, 0)); /* Don't do this when optimizing for size. */ if (flag_unsafe_math_optimizations @@ -7688,19 +7737,19 @@ fold_builtin_cabs (tree arg, tree type, tree fndecl) arg = builtin_save_expr (arg); - rpart = fold_build1 (REALPART_EXPR, type, arg); - ipart = fold_build1 (IMAGPART_EXPR, type, arg); + rpart = fold_build1_loc (loc, REALPART_EXPR, type, arg); + ipart = fold_build1_loc (loc, IMAGPART_EXPR, type, arg); rpart = builtin_save_expr (rpart); ipart = builtin_save_expr (ipart); - result = fold_build2 (PLUS_EXPR, type, - fold_build2 (MULT_EXPR, type, + result = fold_build2_loc (loc, PLUS_EXPR, type, + fold_build2_loc (loc, MULT_EXPR, type, rpart, rpart), - fold_build2 (MULT_EXPR, type, + fold_build2_loc (loc, MULT_EXPR, type, ipart, ipart)); - return build_call_expr (sqrtfn, 1, result); + return build_call_expr_loc (loc, sqrtfn, 1, result); } } @@ -7711,7 +7760,7 @@ fold_builtin_cabs (tree arg, tree type, tree fndecl) Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_sqrt (tree arg, tree type) +fold_builtin_sqrt (location_t loc, tree arg, tree type) { enum built_in_function fcode; @@ -7729,10 +7778,10 @@ fold_builtin_sqrt (tree arg, tree type) if (flag_unsafe_math_optimizations && BUILTIN_EXPONENT_P (fcode)) { tree expfn = TREE_OPERAND (CALL_EXPR_FN (arg), 0); - arg = fold_build2 (MULT_EXPR, type, + arg = fold_build2_loc (loc, MULT_EXPR, type, CALL_EXPR_ARG (arg, 0), build_real (type, dconsthalf)); - return build_call_expr (expfn, 1, arg); + return build_call_expr_loc (loc, expfn, 1, arg); } /* Optimize sqrt(Nroot(x)) -> pow(x,1/(2*N)). */ @@ -7757,7 +7806,7 @@ fold_builtin_sqrt (tree arg, tree type) SET_REAL_EXP (&dconstroot, REAL_EXP (&dconstroot) - 1); dconstroot = real_value_truncate (TYPE_MODE (type), dconstroot); tree_root = build_real (type, dconstroot); - return build_call_expr (powfn, 2, arg0, tree_root); + return build_call_expr_loc (loc, powfn, 2, arg0, tree_root); } } @@ -7773,9 +7822,9 @@ fold_builtin_sqrt (tree arg, tree type) tree narg1; if (!tree_expr_nonnegative_p (arg0)) arg0 = build1 (ABS_EXPR, type, arg0); - narg1 = fold_build2 (MULT_EXPR, type, arg1, + narg1 = fold_build2_loc (loc, MULT_EXPR, type, arg1, build_real (type, dconsthalf)); - return build_call_expr (powfn, 2, arg0, narg1); + return build_call_expr_loc (loc, powfn, 2, arg0, narg1); } return NULL_TREE; @@ -7785,7 +7834,7 @@ fold_builtin_sqrt (tree arg, tree type) Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_cbrt (tree arg, tree type) +fold_builtin_cbrt (location_t loc, tree arg, tree type) { const enum built_in_function fcode = builtin_mathfn_code (arg); tree res; @@ -7805,10 +7854,10 @@ fold_builtin_cbrt (tree arg, tree type) tree expfn = TREE_OPERAND (CALL_EXPR_FN (arg), 0); const REAL_VALUE_TYPE third_trunc = real_value_truncate (TYPE_MODE (type), dconst_third ()); - arg = fold_build2 (MULT_EXPR, type, + arg = fold_build2_loc (loc, MULT_EXPR, type, CALL_EXPR_ARG (arg, 0), build_real (type, third_trunc)); - return build_call_expr (expfn, 1, arg); + return build_call_expr_loc (loc, expfn, 1, arg); } /* Optimize cbrt(sqrt(x)) -> pow(x,1/6). */ @@ -7825,7 +7874,7 @@ fold_builtin_cbrt (tree arg, tree type) SET_REAL_EXP (&dconstroot, REAL_EXP (&dconstroot) - 1); dconstroot = real_value_truncate (TYPE_MODE (type), dconstroot); tree_root = build_real (type, dconstroot); - return build_call_expr (powfn, 2, arg0, tree_root); + return build_call_expr_loc (loc, powfn, 2, arg0, tree_root); } } @@ -7846,7 +7895,7 @@ fold_builtin_cbrt (tree arg, tree type) dconst_third_ptr (), dconst_third_ptr ()); dconstroot = real_value_truncate (TYPE_MODE (type), dconstroot); tree_root = build_real (type, dconstroot); - return build_call_expr (powfn, 2, arg0, tree_root); + return build_call_expr_loc (loc, powfn, 2, arg0, tree_root); } } } @@ -7863,9 +7912,9 @@ fold_builtin_cbrt (tree arg, tree type) tree powfn = TREE_OPERAND (CALL_EXPR_FN (arg), 0); const REAL_VALUE_TYPE dconstroot = real_value_truncate (TYPE_MODE (type), dconst_third ()); - tree narg01 = fold_build2 (MULT_EXPR, type, arg01, + tree narg01 = fold_build2_loc (loc, MULT_EXPR, type, arg01, build_real (type, dconstroot)); - return build_call_expr (powfn, 2, arg00, narg01); + return build_call_expr_loc (loc, powfn, 2, arg00, narg01); } } } @@ -7877,7 +7926,8 @@ fold_builtin_cbrt (tree arg, tree type) simplification can be made. */ static tree -fold_builtin_cos (tree arg, tree type, tree fndecl) +fold_builtin_cos (location_t loc, + tree arg, tree type, tree fndecl) { tree res, narg; @@ -7890,7 +7940,7 @@ fold_builtin_cos (tree arg, tree type, tree fndecl) /* Optimize cos(-x) into cos (x). */ if ((narg = fold_strip_sign_ops (arg))) - return build_call_expr (fndecl, 1, narg); + return build_call_expr_loc (loc, fndecl, 1, narg); return NULL_TREE; } @@ -7899,7 +7949,7 @@ fold_builtin_cos (tree arg, tree type, tree fndecl) Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_cosh (tree arg, tree type, tree fndecl) +fold_builtin_cosh (location_t loc, tree arg, tree type, tree fndecl) { if (validate_arg (arg, REAL_TYPE)) { @@ -7911,7 +7961,7 @@ fold_builtin_cosh (tree arg, tree type, tree fndecl) /* Optimize cosh(-x) into cosh (x). */ if ((narg = fold_strip_sign_ops (arg))) - return build_call_expr (fndecl, 1, narg); + return build_call_expr_loc (loc, fndecl, 1, narg); } return NULL_TREE; @@ -7922,7 +7972,8 @@ fold_builtin_cosh (tree arg, tree type, tree fndecl) NULL_TREE if no simplification can be made. */ static tree -fold_builtin_ccos (tree arg, tree type ATTRIBUTE_UNUSED, tree fndecl, +fold_builtin_ccos (location_t loc, + tree arg, tree type ATTRIBUTE_UNUSED, tree fndecl, bool hyper ATTRIBUTE_UNUSED) { if (validate_arg (arg, COMPLEX_TYPE) @@ -7938,7 +7989,7 @@ fold_builtin_ccos (tree arg, tree type ATTRIBUTE_UNUSED, tree fndecl, /* Optimize fn(-x) into fn(x). */ if ((tmp = fold_strip_sign_ops (arg))) - return build_call_expr (fndecl, 1, tmp); + return build_call_expr_loc (loc, fndecl, 1, tmp); } return NULL_TREE; @@ -7975,7 +8026,8 @@ fold_builtin_tan (tree arg, tree type) NULL_TREE if no simplification can be made. */ static tree -fold_builtin_sincos (tree arg0, tree arg1, tree arg2) +fold_builtin_sincos (location_t loc, + tree arg0, tree arg1, tree arg2) { tree type; tree res, fn, call; @@ -7998,15 +8050,15 @@ fold_builtin_sincos (tree arg0, tree arg1, tree arg2) if (!fn) return NULL_TREE; - call = build_call_expr (fn, 1, arg0); + call = build_call_expr_loc (loc, fn, 1, arg0); call = builtin_save_expr (call); return build2 (COMPOUND_EXPR, void_type_node, build2 (MODIFY_EXPR, void_type_node, - build_fold_indirect_ref (arg1), + build_fold_indirect_ref_loc (loc, arg1), build1 (IMAGPART_EXPR, type, call)), build2 (MODIFY_EXPR, void_type_node, - build_fold_indirect_ref (arg2), + build_fold_indirect_ref_loc (loc, arg2), build1 (REALPART_EXPR, type, call))); } @@ -8014,7 +8066,7 @@ fold_builtin_sincos (tree arg0, tree arg1, tree arg2) NULL_TREE if no simplification can be made. */ static tree -fold_builtin_cexp (tree arg0, tree type) +fold_builtin_cexp (location_t loc, tree arg0, tree type) { tree rtype; tree realp, imagp, ifn; @@ -8042,11 +8094,11 @@ fold_builtin_cexp (tree arg0, tree type) if (!ifn) return NULL_TREE; - if ((realp = fold_unary (REALPART_EXPR, rtype, arg0)) + if ((realp = fold_unary_loc (loc, REALPART_EXPR, rtype, arg0)) && real_zerop (realp)) { - tree narg = fold_build1 (IMAGPART_EXPR, rtype, arg0); - return build_call_expr (ifn, 1, narg); + tree narg = fold_build1_loc (loc, IMAGPART_EXPR, rtype, arg0); + return build_call_expr_loc (loc, ifn, 1, narg); } /* In case we can easily decompose real and imaginary parts split cexp @@ -8060,21 +8112,23 @@ fold_builtin_cexp (tree arg0, tree type) if (!rfn) return NULL_TREE; - imagp = fold_unary (IMAGPART_EXPR, rtype, arg0); + imagp = fold_unary_loc (loc, IMAGPART_EXPR, rtype, arg0); if (!imagp) return NULL_TREE; - icall = build_call_expr (ifn, 1, imagp); + icall = build_call_expr_loc (loc, ifn, 1, imagp); icall = builtin_save_expr (icall); - rcall = build_call_expr (rfn, 1, realp); + rcall = build_call_expr_loc (loc, rfn, 1, realp); rcall = builtin_save_expr (rcall); - return fold_build2 (COMPLEX_EXPR, type, - fold_build2 (MULT_EXPR, rtype, + return fold_build2_loc (loc, COMPLEX_EXPR, type, + fold_build2_loc (loc, MULT_EXPR, rtype, rcall, - fold_build1 (REALPART_EXPR, rtype, icall)), - fold_build2 (MULT_EXPR, rtype, + fold_build1_loc (loc, REALPART_EXPR, + rtype, icall)), + fold_build2_loc (loc, MULT_EXPR, rtype, rcall, - fold_build1 (IMAGPART_EXPR, rtype, icall))); + fold_build1_loc (loc, IMAGPART_EXPR, + rtype, icall))); } return NULL_TREE; @@ -8084,7 +8138,7 @@ fold_builtin_cexp (tree arg0, tree type) Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_trunc (tree fndecl, tree arg) +fold_builtin_trunc (location_t loc, tree fndecl, tree arg) { if (!validate_arg (arg, REAL_TYPE)) return NULL_TREE; @@ -8100,14 +8154,14 @@ fold_builtin_trunc (tree fndecl, tree arg) return build_real (type, r); } - return fold_trunc_transparent_mathfn (fndecl, arg); + return fold_trunc_transparent_mathfn (loc, fndecl, arg); } /* Fold function call to builtin floor, floorf or floorl with argument ARG. Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_floor (tree fndecl, tree arg) +fold_builtin_floor (location_t loc, tree fndecl, tree arg) { if (!validate_arg (arg, REAL_TYPE)) return NULL_TREE; @@ -8133,17 +8187,17 @@ fold_builtin_floor (tree fndecl, tree arg) { tree truncfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_TRUNC); if (truncfn) - return build_call_expr (truncfn, 1, arg); + return build_call_expr_loc (loc, truncfn, 1, arg); } - return fold_trunc_transparent_mathfn (fndecl, arg); + return fold_trunc_transparent_mathfn (loc, fndecl, arg); } /* Fold function call to builtin ceil, ceilf or ceill with argument ARG. Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_ceil (tree fndecl, tree arg) +fold_builtin_ceil (location_t loc, tree fndecl, tree arg) { if (!validate_arg (arg, REAL_TYPE)) return NULL_TREE; @@ -8164,14 +8218,14 @@ fold_builtin_ceil (tree fndecl, tree arg) } } - return fold_trunc_transparent_mathfn (fndecl, arg); + return fold_trunc_transparent_mathfn (loc, fndecl, arg); } /* Fold function call to builtin round, roundf or roundl with argument ARG. Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_round (tree fndecl, tree arg) +fold_builtin_round (location_t loc, tree fndecl, tree arg) { if (!validate_arg (arg, REAL_TYPE)) return NULL_TREE; @@ -8192,7 +8246,7 @@ fold_builtin_round (tree fndecl, tree arg) } } - return fold_trunc_transparent_mathfn (fndecl, arg); + return fold_trunc_transparent_mathfn (loc, fndecl, arg); } /* Fold function call to builtin lround, lroundf or lroundl (or the @@ -8201,7 +8255,7 @@ fold_builtin_round (tree fndecl, tree arg) can be made. */ static tree -fold_builtin_int_roundingfn (tree fndecl, tree arg) +fold_builtin_int_roundingfn (location_t loc, tree fndecl, tree arg) { if (!validate_arg (arg, REAL_TYPE)) return NULL_TREE; @@ -8252,13 +8306,13 @@ fold_builtin_int_roundingfn (tree fndecl, tree arg) CASE_FLT_FN (BUILT_IN_LLFLOOR): /* Fold lfloor (x) where x is nonnegative to FIX_TRUNC (x). */ if (tree_expr_nonnegative_p (arg)) - return fold_build1 (FIX_TRUNC_EXPR, TREE_TYPE (TREE_TYPE (fndecl)), - arg); + return fold_build1_loc (loc, FIX_TRUNC_EXPR, + TREE_TYPE (TREE_TYPE (fndecl)), arg); break; default:; } - return fold_fixed_mathfn (fndecl, arg); + return fold_fixed_mathfn (loc, fndecl, arg); } /* Fold function call to builtin ffs, clz, ctz, popcount and parity @@ -8417,7 +8471,7 @@ fold_builtin_bswap (tree fndecl, tree arg) FUNC is the corresponding MPFR logarithm function. */ static tree -fold_builtin_logarithm (tree fndecl, tree arg, +fold_builtin_logarithm (location_t loc, tree fndecl, tree arg, int (*func)(mpfr_ptr, mpfr_srcptr, mp_rnd_t)) { if (validate_arg (arg, REAL_TYPE)) @@ -8441,7 +8495,7 @@ fold_builtin_logarithm (tree fndecl, tree arg, || fcode == BUILT_IN_EXP2F || fcode == BUILT_IN_EXP2L)) || (func == mpfr_log10 && (BUILTIN_EXP10_P (fcode))))) - return fold_convert (type, CALL_EXPR_ARG (arg, 0)); + return fold_convert_loc (loc, type, CALL_EXPR_ARG (arg, 0)); /* Optimize logN(func()) for various exponential functions. We want to determine the value "x" and the power "exponent" in @@ -8496,8 +8550,8 @@ fold_builtin_logarithm (tree fndecl, tree arg, /* Now perform the optimization. */ if (x && exponent) { - tree logfn = build_call_expr (fndecl, 1, x); - return fold_build2 (MULT_EXPR, type, exponent, logfn); + tree logfn = build_call_expr_loc (loc, fndecl, 1, x); + return fold_build2_loc (loc, MULT_EXPR, type, exponent, logfn); } } } @@ -8509,7 +8563,8 @@ fold_builtin_logarithm (tree fndecl, tree arg, NULL_TREE if no simplification can be made. */ static tree -fold_builtin_hypot (tree fndecl, tree arg0, tree arg1, tree type) +fold_builtin_hypot (location_t loc, tree fndecl, + tree arg0, tree arg1, tree type) { tree res, narg0, narg1; @@ -8527,15 +8582,15 @@ fold_builtin_hypot (tree fndecl, tree arg0, tree arg1, tree type) narg1 = fold_strip_sign_ops (arg1); if (narg0 || narg1) { - return build_call_expr (fndecl, 2, narg0 ? narg0 : arg0, + return build_call_expr_loc (loc, fndecl, 2, narg0 ? narg0 : arg0, narg1 ? narg1 : arg1); } /* If either argument is zero, hypot is fabs of the other. */ if (real_zerop (arg0)) - return fold_build1 (ABS_EXPR, type, arg1); + return fold_build1_loc (loc, ABS_EXPR, type, arg1); else if (real_zerop (arg1)) - return fold_build1 (ABS_EXPR, type, arg0); + return fold_build1_loc (loc, ABS_EXPR, type, arg0); /* hypot(x,x) -> fabs(x)*sqrt(2). */ if (flag_unsafe_math_optimizations @@ -8543,8 +8598,8 @@ fold_builtin_hypot (tree fndecl, tree arg0, tree arg1, tree type) { const REAL_VALUE_TYPE sqrt2_trunc = real_value_truncate (TYPE_MODE (type), dconst_sqrt2 ()); - return fold_build2 (MULT_EXPR, type, - fold_build1 (ABS_EXPR, type, arg0), + return fold_build2_loc (loc, MULT_EXPR, type, + fold_build1_loc (loc, ABS_EXPR, type, arg0), build_real (type, sqrt2_trunc)); } @@ -8555,7 +8610,7 @@ fold_builtin_hypot (tree fndecl, tree arg0, tree arg1, tree type) /* Fold a builtin function call to pow, powf, or powl. Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) +fold_builtin_pow (location_t loc, tree fndecl, tree arg0, tree arg1, tree type) { tree res; @@ -8569,7 +8624,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) /* Optimize pow(1.0,y) = 1.0. */ if (real_onep (arg0)) - return omit_one_operand (type, build_real (type, dconst1), arg1); + return omit_one_operand_loc (loc, type, build_real (type, dconst1), arg1); if (TREE_CODE (arg1) == REAL_CST && !TREE_OVERFLOW (arg1)) @@ -8582,7 +8637,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) /* Optimize pow(x,0.0) = 1.0. */ if (REAL_VALUES_EQUAL (c, dconst0)) - return omit_one_operand (type, build_real (type, dconst1), + return omit_one_operand_loc (loc, type, build_real (type, dconst1), arg0); /* Optimize pow(x,1.0) = x. */ @@ -8591,7 +8646,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) /* Optimize pow(x,-1.0) = 1.0/x. */ if (REAL_VALUES_EQUAL (c, dconstm1)) - return fold_build2 (RDIV_EXPR, type, + return fold_build2_loc (loc, RDIV_EXPR, type, build_real (type, dconst1), arg0); /* Optimize pow(x,0.5) = sqrt(x). */ @@ -8601,7 +8656,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) tree sqrtfn = mathfn_built_in (type, BUILT_IN_SQRT); if (sqrtfn != NULL_TREE) - return build_call_expr (sqrtfn, 1, arg0); + return build_call_expr_loc (loc, sqrtfn, 1, arg0); } /* Optimize pow(x,1.0/3.0) = cbrt(x). */ @@ -8614,7 +8669,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) { tree cbrtfn = mathfn_built_in (type, BUILT_IN_CBRT); if (cbrtfn != NULL_TREE) - return build_call_expr (cbrtfn, 1, arg0); + return build_call_expr_loc (loc, cbrtfn, 1, arg0); } } @@ -8645,7 +8700,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) { tree narg0 = fold_strip_sign_ops (arg0); if (narg0) - return build_call_expr (fndecl, 2, narg0, arg1); + return build_call_expr_loc (loc, fndecl, 2, narg0, arg1); } } } @@ -8659,17 +8714,17 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) { tree expfn = TREE_OPERAND (CALL_EXPR_FN (arg0), 0); tree arg = CALL_EXPR_ARG (arg0, 0); - arg = fold_build2 (MULT_EXPR, type, arg, arg1); - return build_call_expr (expfn, 1, arg); + arg = fold_build2_loc (loc, MULT_EXPR, type, arg, arg1); + return build_call_expr_loc (loc, expfn, 1, arg); } /* Optimize pow(sqrt(x),y) = pow(x,y*0.5). */ if (BUILTIN_SQRT_P (fcode)) { tree narg0 = CALL_EXPR_ARG (arg0, 0); - tree narg1 = fold_build2 (MULT_EXPR, type, arg1, + tree narg1 = fold_build2_loc (loc, MULT_EXPR, type, arg1, build_real (type, dconsthalf)); - return build_call_expr (fndecl, 2, narg0, narg1); + return build_call_expr_loc (loc, fndecl, 2, narg0, narg1); } /* Optimize pow(cbrt(x),y) = pow(x,y/3) iff x is nonnegative. */ @@ -8680,9 +8735,9 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) { const REAL_VALUE_TYPE dconstroot = real_value_truncate (TYPE_MODE (type), dconst_third ()); - tree narg1 = fold_build2 (MULT_EXPR, type, arg1, + tree narg1 = fold_build2_loc (loc, MULT_EXPR, type, arg1, build_real (type, dconstroot)); - return build_call_expr (fndecl, 2, arg, narg1); + return build_call_expr_loc (loc, fndecl, 2, arg, narg1); } } @@ -8693,8 +8748,8 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) { tree arg00 = CALL_EXPR_ARG (arg0, 0); tree arg01 = CALL_EXPR_ARG (arg0, 1); - tree narg1 = fold_build2 (MULT_EXPR, type, arg01, arg1); - return build_call_expr (fndecl, 2, arg00, narg1); + tree narg1 = fold_build2_loc (loc, MULT_EXPR, type, arg01, arg1); + return build_call_expr_loc (loc, fndecl, 2, arg00, narg1); } } @@ -8704,7 +8759,7 @@ fold_builtin_pow (tree fndecl, tree arg0, tree arg1, tree type) /* Fold a builtin function call to powi, powif, or powil with argument ARG. Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_powi (tree fndecl ATTRIBUTE_UNUSED, +fold_builtin_powi (location_t loc, tree fndecl ATTRIBUTE_UNUSED, tree arg0, tree arg1, tree type) { if (!validate_arg (arg0, REAL_TYPE) @@ -8713,7 +8768,7 @@ fold_builtin_powi (tree fndecl ATTRIBUTE_UNUSED, /* Optimize pow(1.0,y) = 1.0. */ if (real_onep (arg0)) - return omit_one_operand (type, build_real (type, dconst1), arg1); + return omit_one_operand_loc (loc, type, build_real (type, dconst1), arg1); if (host_integerp (arg1, 0)) { @@ -8731,7 +8786,7 @@ fold_builtin_powi (tree fndecl ATTRIBUTE_UNUSED, /* Optimize pow(x,0) = 1.0. */ if (c == 0) - return omit_one_operand (type, build_real (type, dconst1), + return omit_one_operand_loc (loc, type, build_real (type, dconst1), arg0); /* Optimize pow(x,1) = x. */ @@ -8740,7 +8795,7 @@ fold_builtin_powi (tree fndecl ATTRIBUTE_UNUSED, /* Optimize pow(x,-1) = 1.0/x. */ if (c == -1) - return fold_build2 (RDIV_EXPR, type, + return fold_build2_loc (loc, RDIV_EXPR, type, build_real (type, dconst1), arg0); } @@ -8752,7 +8807,7 @@ fold_builtin_powi (tree fndecl ATTRIBUTE_UNUSED, FUNC is the corresponding MPFR exponent function. */ static tree -fold_builtin_exponent (tree fndecl, tree arg, +fold_builtin_exponent (location_t loc, tree fndecl, tree arg, int (*func)(mpfr_ptr, mpfr_srcptr, mp_rnd_t)) { if (validate_arg (arg, REAL_TYPE)) @@ -8781,7 +8836,7 @@ fold_builtin_exponent (tree fndecl, tree arg, && (fcode == BUILT_IN_LOG10 || fcode == BUILT_IN_LOG10F || fcode == BUILT_IN_LOG10L))) - return fold_convert (type, CALL_EXPR_ARG (arg, 0)); + return fold_convert_loc (loc, type, CALL_EXPR_ARG (arg, 0)); } } @@ -8803,7 +8858,8 @@ var_decl_component_p (tree var) NULL_TREE if no simplification can be made. */ static tree -fold_builtin_memset (tree dest, tree c, tree len, tree type, bool ignore) +fold_builtin_memset (location_t loc, tree dest, tree c, tree len, + tree type, bool ignore) { tree var, ret, etype; unsigned HOST_WIDE_INT length, cval; @@ -8818,7 +8874,7 @@ fold_builtin_memset (tree dest, tree c, tree len, tree type, bool ignore) /* If the LEN parameter is zero, return DEST. */ if (integer_zerop (len)) - return omit_one_operand (type, dest, c); + return omit_one_operand_loc (loc, type, dest, c); if (! host_integerp (c, 1) || TREE_SIDE_EFFECTS (dest)) return NULL_TREE; @@ -8867,20 +8923,22 @@ fold_builtin_memset (tree dest, tree c, tree len, tree type, bool ignore) } ret = build_int_cst_type (etype, cval); - var = build_fold_indirect_ref (fold_convert (build_pointer_type (etype), - dest)); + var = build_fold_indirect_ref_loc (loc, + fold_convert_loc (loc, + build_pointer_type (etype), + dest)); ret = build2 (MODIFY_EXPR, etype, var, ret); if (ignore) return ret; - return omit_one_operand (type, dest, ret); + return omit_one_operand_loc (loc, type, dest, ret); } /* Fold function call to builtin memset. Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_bzero (tree dest, tree size, bool ignore) +fold_builtin_bzero (location_t loc, tree dest, tree size, bool ignore) { if (! validate_arg (dest, POINTER_TYPE) || ! validate_arg (size, INTEGER_TYPE)) @@ -8894,8 +8952,8 @@ fold_builtin_bzero (tree dest, tree size, bool ignore) so that if it isn't expanded inline, we fallback to calling bzero instead of memset. */ - return fold_builtin_memset (dest, integer_zero_node, - fold_convert (sizetype, size), + return fold_builtin_memset (loc, dest, integer_zero_node, + fold_convert_loc (loc, sizetype, size), void_type_node, ignore); } @@ -8908,7 +8966,8 @@ fold_builtin_bzero (tree dest, tree size, bool ignore) (memmove). */ static tree -fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, int endp) +fold_builtin_memory_op (location_t loc, tree dest, tree src, + tree len, tree type, bool ignore, int endp) { tree destvar, srcvar, expr; @@ -8919,7 +8978,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i /* If the LEN parameter is zero, return DEST. */ if (integer_zerop (len)) - return omit_one_operand (type, dest, src); + return omit_one_operand_loc (loc, type, dest, src); /* If SRC and DEST are the same (and not volatile), return DEST{,+LEN,+LEN-1}. */ @@ -8950,12 +9009,12 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i tree fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; if (!fn) return NULL_TREE; - return build_call_expr (fn, 3, dest, src, len); + return build_call_expr_loc (loc, fn, 3, dest, src, len); } /* If *src and *dest can't overlap, optimize into memcpy as well. */ - srcvar = build_fold_indirect_ref (src); - destvar = build_fold_indirect_ref (dest); + srcvar = build_fold_indirect_ref_loc (loc, src); + destvar = build_fold_indirect_ref_loc (loc, dest); if (srcvar && !TREE_THIS_VOLATILE (srcvar) && destvar @@ -9008,7 +9067,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; if (!fn) return NULL_TREE; - return build_call_expr (fn, 3, dest, src, len); + return build_call_expr_loc (loc, fn, 3, dest, src, len); } return NULL_TREE; } @@ -9075,7 +9134,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i srcvar = NULL_TREE; if (tree_int_cst_equal (TYPE_SIZE_UNIT (srctype), len)) { - srcvar = build_fold_indirect_ref (src); + srcvar = build_fold_indirect_ref_loc (loc, src); if (TREE_THIS_VOLATILE (srcvar)) return NULL_TREE; else if (!tree_int_cst_equal (lang_hooks.expr_size (srcvar), len)) @@ -9093,7 +9152,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i destvar = NULL_TREE; if (tree_int_cst_equal (TYPE_SIZE_UNIT (desttype), len)) { - destvar = build_fold_indirect_ref (dest); + destvar = build_fold_indirect_ref_loc (loc, dest); if (TREE_THIS_VOLATILE (destvar)) return NULL_TREE; else if (!tree_int_cst_equal (lang_hooks.expr_size (destvar), len)) @@ -9124,8 +9183,8 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i TYPE_PACKED (srctype) = 1; } srcptype = build_pointer_type_for_mode (srctype, ptr_mode, true); - src = fold_convert (srcptype, src); - srcvar = build_fold_indirect_ref (src); + src = fold_convert_loc (loc, srcptype, src); + srcvar = build_fold_indirect_ref_loc (loc, src); } else if (destvar == NULL_TREE) { @@ -9146,8 +9205,8 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i TYPE_PACKED (desttype) = 1; } destptype = build_pointer_type_for_mode (desttype, ptr_mode, true); - dest = fold_convert (destptype, dest); - destvar = build_fold_indirect_ref (dest); + dest = fold_convert_loc (loc, destptype, dest); + destvar = build_fold_indirect_ref_loc (loc, dest); } if (srctype == desttype @@ -9158,9 +9217,10 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i || POINTER_TYPE_P (TREE_TYPE (srcvar))) && (INTEGRAL_TYPE_P (TREE_TYPE (destvar)) || POINTER_TYPE_P (TREE_TYPE (destvar)))) - expr = fold_convert (TREE_TYPE (destvar), srcvar); + expr = fold_convert_loc (loc, TREE_TYPE (destvar), srcvar); else - expr = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (destvar), srcvar); + expr = fold_build1_loc (loc, VIEW_CONVERT_EXPR, + TREE_TYPE (destvar), srcvar); expr = build2 (MODIFY_EXPR, TREE_TYPE (destvar), destvar, expr); } @@ -9168,20 +9228,20 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i return expr; if (endp == 0 || endp == 3) - return omit_one_operand (type, dest, expr); + return omit_one_operand_loc (loc, type, dest, expr); if (expr == len) expr = NULL_TREE; if (endp == 2) - len = fold_build2 (MINUS_EXPR, TREE_TYPE (len), len, + len = fold_build2_loc (loc, MINUS_EXPR, TREE_TYPE (len), len, ssize_int (1)); - len = fold_convert (sizetype, len); - dest = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dest), dest, len); - dest = fold_convert (type, dest); + len = fold_convert_loc (loc, sizetype, len); + dest = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (dest), dest, len); + dest = fold_convert_loc (loc, type, dest); if (expr) - dest = omit_one_operand (type, dest, expr); + dest = omit_one_operand_loc (loc, type, dest, expr); return dest; } @@ -9190,7 +9250,7 @@ fold_builtin_memory_op (tree dest, tree src, tree len, tree type, bool ignore, i copied. Return NULL_TREE if no simplification can be made. */ tree -fold_builtin_strcpy (tree fndecl, tree dest, tree src, tree len) +fold_builtin_strcpy (location_t loc, tree fndecl, tree dest, tree src, tree len) { tree fn; @@ -9200,7 +9260,7 @@ fold_builtin_strcpy (tree fndecl, tree dest, tree src, tree len) /* If SRC and DEST are the same (and not volatile), return DEST. */ if (operand_equal_p (src, dest, 0)) - return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), dest); + return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest); if (optimize_function_for_size_p (cfun)) return NULL_TREE; @@ -9216,9 +9276,9 @@ fold_builtin_strcpy (tree fndecl, tree dest, tree src, tree len) return NULL_TREE; } - len = size_binop (PLUS_EXPR, len, ssize_int (1)); - return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), - build_call_expr (fn, 3, dest, src, len)); + len = size_binop_loc (loc, PLUS_EXPR, len, ssize_int (1)); + return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), + build_call_expr_loc (loc, fn, 3, dest, src, len)); } /* Fold function call to builtin strncpy with arguments DEST, SRC, and LEN. @@ -9226,7 +9286,8 @@ fold_builtin_strcpy (tree fndecl, tree dest, tree src, tree len) Return NULL_TREE if no simplification can be made. */ tree -fold_builtin_strncpy (tree fndecl, tree dest, tree src, tree len, tree slen) +fold_builtin_strncpy (location_t loc, tree fndecl, tree dest, + tree src, tree len, tree slen) { tree fn; @@ -9237,7 +9298,7 @@ fold_builtin_strncpy (tree fndecl, tree dest, tree src, tree len, tree slen) /* If the LEN parameter is zero, return DEST. */ if (integer_zerop (len)) - return omit_one_operand (TREE_TYPE (TREE_TYPE (fndecl)), dest, src); + return omit_one_operand_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest, src); /* We can't compare slen with len as constants below if len is not a constant. */ @@ -9251,7 +9312,7 @@ fold_builtin_strncpy (tree fndecl, tree dest, tree src, tree len, tree slen) if (slen == 0 || TREE_CODE (slen) != INTEGER_CST) return NULL_TREE; - slen = size_binop (PLUS_EXPR, slen, ssize_int (1)); + slen = size_binop_loc (loc, PLUS_EXPR, slen, ssize_int (1)); /* We do not support simplification of this case, though we do support it when expanding trees into RTL. */ @@ -9263,8 +9324,8 @@ fold_builtin_strncpy (tree fndecl, tree dest, tree src, tree len, tree slen) fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; if (!fn) return NULL_TREE; - return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), - build_call_expr (fn, 3, dest, src, len)); + return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), + build_call_expr_loc (loc, fn, 3, dest, src, len)); } /* Fold function call to builtin memchr. ARG1, ARG2 and LEN are the @@ -9272,7 +9333,7 @@ fold_builtin_strncpy (tree fndecl, tree dest, tree src, tree len, tree slen) Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_memchr (tree arg1, tree arg2, tree len, tree type) +fold_builtin_memchr (location_t loc, tree arg1, tree arg2, tree len, tree type) { if (!validate_arg (arg1, POINTER_TYPE) || !validate_arg (arg2, INTEGER_TYPE) @@ -9301,9 +9362,9 @@ fold_builtin_memchr (tree arg1, tree arg2, tree len, tree type) if (r == NULL) return build_int_cst (TREE_TYPE (arg1), 0); - tem = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (arg1), arg1, + tem = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (arg1), arg1, size_int (r - p1)); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } return NULL_TREE; } @@ -9313,7 +9374,7 @@ fold_builtin_memchr (tree arg1, tree arg2, tree len, tree type) Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_memcmp (tree arg1, tree arg2, tree len) +fold_builtin_memcmp (location_t loc, tree arg1, tree arg2, tree len) { const char *p1, *p2; @@ -9324,12 +9385,12 @@ fold_builtin_memcmp (tree arg1, tree arg2, tree len) /* If the LEN parameter is zero, return zero. */ if (integer_zerop (len)) - return omit_two_operands (integer_type_node, integer_zero_node, + return omit_two_operands_loc (loc, integer_type_node, integer_zero_node, arg1, arg2); /* If ARG1 and ARG2 are the same (and not volatile), return zero. */ if (operand_equal_p (arg1, arg2, 0)) - return omit_one_operand (integer_type_node, integer_zero_node, len); + return omit_one_operand_loc (loc, integer_type_node, integer_zero_node, len); p1 = c_getstr (arg1); p2 = c_getstr (arg2); @@ -9358,15 +9419,19 @@ fold_builtin_memcmp (tree arg1, tree arg2, tree len) tree cst_uchar_ptr_node = build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true); - tree ind1 = fold_convert (integer_type_node, - build1 (INDIRECT_REF, cst_uchar_node, - fold_convert (cst_uchar_ptr_node, + tree ind1 + = fold_convert_loc (loc, integer_type_node, + build1 (INDIRECT_REF, cst_uchar_node, + fold_convert_loc (loc, + cst_uchar_ptr_node, arg1))); - tree ind2 = fold_convert (integer_type_node, - build1 (INDIRECT_REF, cst_uchar_node, - fold_convert (cst_uchar_ptr_node, + tree ind2 + = fold_convert_loc (loc, integer_type_node, + build1 (INDIRECT_REF, cst_uchar_node, + fold_convert_loc (loc, + cst_uchar_ptr_node, arg2))); - return fold_build2 (MINUS_EXPR, integer_type_node, ind1, ind2); + return fold_build2_loc (loc, MINUS_EXPR, integer_type_node, ind1, ind2); } return NULL_TREE; @@ -9376,7 +9441,7 @@ fold_builtin_memcmp (tree arg1, tree arg2, tree len) Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_strcmp (tree arg1, tree arg2) +fold_builtin_strcmp (location_t loc, tree arg1, tree arg2) { const char *p1, *p2; @@ -9409,10 +9474,11 @@ fold_builtin_strcmp (tree arg1, tree arg2) tree cst_uchar_ptr_node = build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true); - return fold_convert (integer_type_node, - build1 (INDIRECT_REF, cst_uchar_node, - fold_convert (cst_uchar_ptr_node, - arg1))); + return fold_convert_loc (loc, integer_type_node, + build1 (INDIRECT_REF, cst_uchar_node, + fold_convert_loc (loc, + cst_uchar_ptr_node, + arg1))); } /* If the first arg is "", return -*(const unsigned char*)arg2. */ @@ -9422,11 +9488,13 @@ fold_builtin_strcmp (tree arg1, tree arg2) tree cst_uchar_ptr_node = build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true); - tree temp = fold_convert (integer_type_node, - build1 (INDIRECT_REF, cst_uchar_node, - fold_convert (cst_uchar_ptr_node, + tree temp + = fold_convert_loc (loc, integer_type_node, + build1 (INDIRECT_REF, cst_uchar_node, + fold_convert_loc (loc, + cst_uchar_ptr_node, arg2))); - return fold_build1 (NEGATE_EXPR, integer_type_node, temp); + return fold_build1_loc (loc, NEGATE_EXPR, integer_type_node, temp); } return NULL_TREE; @@ -9436,7 +9504,7 @@ fold_builtin_strcmp (tree arg1, tree arg2) Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_strncmp (tree arg1, tree arg2, tree len) +fold_builtin_strncmp (location_t loc, tree arg1, tree arg2, tree len) { const char *p1, *p2; @@ -9447,12 +9515,12 @@ fold_builtin_strncmp (tree arg1, tree arg2, tree len) /* If the LEN parameter is zero, return zero. */ if (integer_zerop (len)) - return omit_two_operands (integer_type_node, integer_zero_node, + return omit_two_operands_loc (loc, integer_type_node, integer_zero_node, arg1, arg2); /* If ARG1 and ARG2 are the same (and not volatile), return zero. */ if (operand_equal_p (arg1, arg2, 0)) - return omit_one_operand (integer_type_node, integer_zero_node, len); + return omit_one_operand_loc (loc, integer_type_node, integer_zero_node, len); p1 = c_getstr (arg1); p2 = c_getstr (arg2); @@ -9478,10 +9546,11 @@ fold_builtin_strncmp (tree arg1, tree arg2, tree len) tree cst_uchar_ptr_node = build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true); - return fold_convert (integer_type_node, - build1 (INDIRECT_REF, cst_uchar_node, - fold_convert (cst_uchar_ptr_node, - arg1))); + return fold_convert_loc (loc, integer_type_node, + build1 (INDIRECT_REF, cst_uchar_node, + fold_convert_loc (loc, + cst_uchar_ptr_node, + arg1))); } /* If the first arg is "", and the length is greater than zero, @@ -9494,11 +9563,12 @@ fold_builtin_strncmp (tree arg1, tree arg2, tree len) tree cst_uchar_ptr_node = build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true); - tree temp = fold_convert (integer_type_node, - build1 (INDIRECT_REF, cst_uchar_node, - fold_convert (cst_uchar_ptr_node, - arg2))); - return fold_build1 (NEGATE_EXPR, integer_type_node, temp); + tree temp = fold_convert_loc (loc, integer_type_node, + build1 (INDIRECT_REF, cst_uchar_node, + fold_convert_loc (loc, + cst_uchar_ptr_node, + arg2))); + return fold_build1_loc (loc, NEGATE_EXPR, integer_type_node, temp); } /* If len parameter is one, return an expression corresponding to @@ -9509,15 +9579,17 @@ fold_builtin_strncmp (tree arg1, tree arg2, tree len) tree cst_uchar_ptr_node = build_pointer_type_for_mode (cst_uchar_node, ptr_mode, true); - tree ind1 = fold_convert (integer_type_node, - build1 (INDIRECT_REF, cst_uchar_node, - fold_convert (cst_uchar_ptr_node, - arg1))); - tree ind2 = fold_convert (integer_type_node, - build1 (INDIRECT_REF, cst_uchar_node, - fold_convert (cst_uchar_ptr_node, - arg2))); - return fold_build2 (MINUS_EXPR, integer_type_node, ind1, ind2); + tree ind1 = fold_convert_loc (loc, integer_type_node, + build1 (INDIRECT_REF, cst_uchar_node, + fold_convert_loc (loc, + cst_uchar_ptr_node, + arg1))); + tree ind2 = fold_convert_loc (loc, integer_type_node, + build1 (INDIRECT_REF, cst_uchar_node, + fold_convert_loc (loc, + cst_uchar_ptr_node, + arg2))); + return fold_build2_loc (loc, MINUS_EXPR, integer_type_node, ind1, ind2); } return NULL_TREE; @@ -9527,7 +9599,7 @@ fold_builtin_strncmp (tree arg1, tree arg2, tree len) ARG. Return NULL_TREE if no simplification can be made. */ static tree -fold_builtin_signbit (tree arg, tree type) +fold_builtin_signbit (location_t loc, tree arg, tree type) { tree temp; @@ -9542,16 +9614,16 @@ fold_builtin_signbit (tree arg, tree type) c = TREE_REAL_CST (arg); temp = REAL_VALUE_NEGATIVE (c) ? integer_one_node : integer_zero_node; - return fold_convert (type, temp); + return fold_convert_loc (loc, type, temp); } /* If ARG is non-negative, the result is always zero. */ if (tree_expr_nonnegative_p (arg)) - return omit_one_operand (type, integer_zero_node, arg); + return omit_one_operand_loc (loc, type, integer_zero_node, arg); /* If ARG's format doesn't have signed zeros, return "arg < 0.0". */ if (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg)))) - return fold_build2 (LT_EXPR, type, arg, + return fold_build2_loc (loc, LT_EXPR, type, arg, build_real (TREE_TYPE (arg), dconst0)); return NULL_TREE; @@ -9562,7 +9634,8 @@ fold_builtin_signbit (tree arg, tree type) be made. */ static tree -fold_builtin_copysign (tree fndecl, tree arg1, tree arg2, tree type) +fold_builtin_copysign (location_t loc, tree fndecl, + tree arg1, tree arg2, tree type) { tree tem; @@ -9572,7 +9645,7 @@ fold_builtin_copysign (tree fndecl, tree arg1, tree arg2, tree type) /* copysign(X,X) is X. */ if (operand_equal_p (arg1, arg2, 0)) - return fold_convert (type, arg1); + return fold_convert_loc (loc, type, arg1); /* If ARG1 and ARG2 are compile-time constants, determine the result. */ if (TREE_CODE (arg1) == REAL_CST @@ -9592,14 +9665,14 @@ fold_builtin_copysign (tree fndecl, tree arg1, tree arg2, tree type) /* copysign(X, Y) is fabs(X) when Y is always non-negative. Remember to evaluate Y for side-effects. */ if (tree_expr_nonnegative_p (arg2)) - return omit_one_operand (type, - fold_build1 (ABS_EXPR, type, arg1), + return omit_one_operand_loc (loc, type, + fold_build1_loc (loc, ABS_EXPR, type, arg1), arg2); /* Strip sign changing operations for the first argument. */ tem = fold_strip_sign_ops (arg1); if (tem) - return build_call_expr (fndecl, 2, tem, arg2); + return build_call_expr_loc (loc, fndecl, 2, tem, arg2); return NULL_TREE; } @@ -9607,7 +9680,7 @@ fold_builtin_copysign (tree fndecl, tree arg1, tree arg2, tree type) /* Fold a call to builtin isascii with argument ARG. */ static tree -fold_builtin_isascii (tree arg) +fold_builtin_isascii (location_t loc, tree arg) { if (!validate_arg (arg, INTEGER_TYPE)) return NULL_TREE; @@ -9617,7 +9690,7 @@ fold_builtin_isascii (tree arg) arg = build2 (BIT_AND_EXPR, integer_type_node, arg, build_int_cst (NULL_TREE, ~ (unsigned HOST_WIDE_INT) 0x7f)); - return fold_build2 (EQ_EXPR, integer_type_node, + return fold_build2_loc (loc, EQ_EXPR, integer_type_node, arg, integer_zero_node); } } @@ -9625,20 +9698,20 @@ fold_builtin_isascii (tree arg) /* Fold a call to builtin toascii with argument ARG. */ static tree -fold_builtin_toascii (tree arg) +fold_builtin_toascii (location_t loc, tree arg) { if (!validate_arg (arg, INTEGER_TYPE)) return NULL_TREE; /* Transform toascii(c) -> (c & 0x7f). */ - return fold_build2 (BIT_AND_EXPR, integer_type_node, arg, + return fold_build2_loc (loc, BIT_AND_EXPR, integer_type_node, arg, build_int_cst (NULL_TREE, 0x7f)); } /* Fold a call to builtin isdigit with argument ARG. */ static tree -fold_builtin_isdigit (tree arg) +fold_builtin_isdigit (location_t loc, tree arg) { if (!validate_arg (arg, INTEGER_TYPE)) return NULL_TREE; @@ -9653,10 +9726,10 @@ fold_builtin_isdigit (tree arg) if (target_digit0 == 0) return NULL_TREE; - arg = fold_convert (unsigned_type_node, arg); + arg = fold_convert_loc (loc, unsigned_type_node, arg); arg = build2 (MINUS_EXPR, unsigned_type_node, arg, build_int_cst (unsigned_type_node, target_digit0)); - return fold_build2 (LE_EXPR, integer_type_node, arg, + return fold_build2_loc (loc, LE_EXPR, integer_type_node, arg, build_int_cst (unsigned_type_node, 9)); } } @@ -9664,35 +9737,36 @@ fold_builtin_isdigit (tree arg) /* Fold a call to fabs, fabsf or fabsl with argument ARG. */ static tree -fold_builtin_fabs (tree arg, tree type) +fold_builtin_fabs (location_t loc, tree arg, tree type) { if (!validate_arg (arg, REAL_TYPE)) return NULL_TREE; - arg = fold_convert (type, arg); + arg = fold_convert_loc (loc, type, arg); if (TREE_CODE (arg) == REAL_CST) return fold_abs_const (arg, type); - return fold_build1 (ABS_EXPR, type, arg); + return fold_build1_loc (loc, ABS_EXPR, type, arg); } /* Fold a call to abs, labs, llabs or imaxabs with argument ARG. */ static tree -fold_builtin_abs (tree arg, tree type) +fold_builtin_abs (location_t loc, tree arg, tree type) { if (!validate_arg (arg, INTEGER_TYPE)) return NULL_TREE; - arg = fold_convert (type, arg); + arg = fold_convert_loc (loc, type, arg); if (TREE_CODE (arg) == INTEGER_CST) return fold_abs_const (arg, type); - return fold_build1 (ABS_EXPR, type, arg); + return fold_build1_loc (loc, ABS_EXPR, type, arg); } /* Fold a call to builtin fmin or fmax. */ static tree -fold_builtin_fmin_fmax (tree arg0, tree arg1, tree type, bool max) +fold_builtin_fmin_fmax (location_t loc, tree arg0, tree arg1, + tree type, bool max) { if (validate_arg (arg0, REAL_TYPE) && validate_arg (arg1, REAL_TYPE)) { @@ -9709,16 +9783,16 @@ fold_builtin_fmin_fmax (tree arg0, tree arg1, tree type, bool max) && real_isnan (&TREE_REAL_CST (arg0)) && (! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0))) || ! TREE_REAL_CST (arg0).signalling)) - return omit_one_operand (type, arg1, arg0); + return omit_one_operand_loc (loc, type, arg1, arg0); if (TREE_CODE (arg1) == REAL_CST && real_isnan (&TREE_REAL_CST (arg1)) && (! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg1))) || ! TREE_REAL_CST (arg1).signalling)) - return omit_one_operand (type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg0, arg1); /* Transform fmin/fmax(x,x) -> x. */ if (operand_equal_p (arg0, arg1, OEP_PURE_SAME)) - return omit_one_operand (type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg0, arg1); /* Convert fmin/fmax to MIN_EXPR/MAX_EXPR. C99 requires these functions to return the numeric arg if the other one is NaN. @@ -9726,9 +9800,9 @@ fold_builtin_fmin_fmax (tree arg0, tree arg1, tree type, bool max) -ffinite-math-only is set. C99 doesn't require -0.0 to be handled, so we don't have to worry about it either. */ if (flag_finite_math_only) - return fold_build2 ((max ? MAX_EXPR : MIN_EXPR), type, - fold_convert (type, arg0), - fold_convert (type, arg1)); + return fold_build2_loc (loc, (max ? MAX_EXPR : MIN_EXPR), type, + fold_convert_loc (loc, type, arg0), + fold_convert_loc (loc, type, arg1)); } return NULL_TREE; } @@ -9736,7 +9810,7 @@ fold_builtin_fmin_fmax (tree arg0, tree arg1, tree type, bool max) /* Fold a call to builtin carg(a+bi) -> atan2(b,a). */ static tree -fold_builtin_carg (tree arg, tree type) +fold_builtin_carg (location_t loc, tree arg, tree type) { if (validate_arg (arg, COMPLEX_TYPE) && TREE_CODE (TREE_TYPE (TREE_TYPE (arg))) == REAL_TYPE) @@ -9746,9 +9820,9 @@ fold_builtin_carg (tree arg, tree type) if (atan2_fn) { tree new_arg = builtin_save_expr (arg); - tree r_arg = fold_build1 (REALPART_EXPR, type, new_arg); - tree i_arg = fold_build1 (IMAGPART_EXPR, type, new_arg); - return build_call_expr (atan2_fn, 2, i_arg, r_arg); + tree r_arg = fold_build1_loc (loc, REALPART_EXPR, type, new_arg); + tree i_arg = fold_build1_loc (loc, IMAGPART_EXPR, type, new_arg); + return build_call_expr_loc (loc, atan2_fn, 2, i_arg, r_arg); } } @@ -9758,7 +9832,7 @@ fold_builtin_carg (tree arg, tree type) /* Fold a call to builtin logb/ilogb. */ static tree -fold_builtin_logb (tree arg, tree rettype) +fold_builtin_logb (location_t loc, tree arg, tree rettype) { if (! validate_arg (arg, REAL_TYPE)) return NULL_TREE; @@ -9775,7 +9849,7 @@ fold_builtin_logb (tree arg, tree rettype) case rvc_inf: /* If arg is Inf or NaN and we're logb, return it. */ if (TREE_CODE (rettype) == REAL_TYPE) - return fold_convert (rettype, arg); + return fold_convert_loc (loc, rettype, arg); /* Fall through... */ case rvc_zero: /* Zero may set errno and/or raise an exception for logb, also @@ -9787,8 +9861,9 @@ fold_builtin_logb (tree arg, tree rettype) want the exponent as if they were [1.0, 2.0) so get the exponent and subtract 1. */ if (REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (arg)))->b == 2) - return fold_convert (rettype, build_int_cst (NULL_TREE, - REAL_EXP (value)-1)); + return fold_convert_loc (loc, rettype, + build_int_cst (NULL_TREE, + REAL_EXP (value)-1)); break; } } @@ -9799,7 +9874,7 @@ fold_builtin_logb (tree arg, tree rettype) /* Fold a call to builtin significand, if radix == 2. */ static tree -fold_builtin_significand (tree arg, tree rettype) +fold_builtin_significand (location_t loc, tree arg, tree rettype) { if (! validate_arg (arg, REAL_TYPE)) return NULL_TREE; @@ -9816,7 +9891,7 @@ fold_builtin_significand (tree arg, tree rettype) case rvc_nan: case rvc_inf: /* If arg is +-0, +-Inf or +-NaN, then return it. */ - return fold_convert (rettype, arg); + return fold_convert_loc (loc, rettype, arg); case rvc_normal: /* For normal numbers, proceed iff radix == 2. */ if (REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (arg)))->b == 2) @@ -9838,7 +9913,7 @@ fold_builtin_significand (tree arg, tree rettype) /* Fold a call to builtin frexp, we can assume the base is 2. */ static tree -fold_builtin_frexp (tree arg0, tree arg1, tree rettype) +fold_builtin_frexp (location_t loc, tree arg0, tree arg1, tree rettype) { if (! validate_arg (arg0, REAL_TYPE) || ! validate_arg (arg1, POINTER_TYPE)) return NULL_TREE; @@ -9848,7 +9923,7 @@ fold_builtin_frexp (tree arg0, tree arg1, tree rettype) if (!(TREE_CODE (arg0) == REAL_CST && ! TREE_OVERFLOW (arg0))) return NULL_TREE; - arg1 = build_fold_indirect_ref (arg1); + arg1 = build_fold_indirect_ref_loc (loc, arg1); /* Proceed if a valid pointer type was passed in. */ if (TYPE_MAIN_VARIANT (TREE_TYPE (arg1)) == integer_type_node) @@ -9866,7 +9941,7 @@ fold_builtin_frexp (tree arg0, tree arg1, tree rettype) case rvc_nan: case rvc_inf: /* For +-NaN or +-Inf, *exp is unspecified, return arg0. */ - return omit_one_operand (rettype, arg0, arg1); + return omit_one_operand_loc (loc, rettype, arg0, arg1); case rvc_normal: { /* Since the frexp function always expects base 2, and in @@ -9883,9 +9958,9 @@ fold_builtin_frexp (tree arg0, tree arg1, tree rettype) } /* Create the COMPOUND_EXPR (*arg1 = trunc, frac). */ - arg1 = fold_build2 (MODIFY_EXPR, rettype, arg1, exp); + arg1 = fold_build2_loc (loc, MODIFY_EXPR, rettype, arg1, exp); TREE_SIDE_EFFECTS (arg1) = 1; - return fold_build2 (COMPOUND_EXPR, rettype, arg1, frac); + return fold_build2_loc (loc, COMPOUND_EXPR, rettype, arg1, frac); } return NULL_TREE; @@ -9896,7 +9971,8 @@ fold_builtin_frexp (tree arg0, tree arg1, tree rettype) check the mode of the TYPE parameter in certain cases. */ static tree -fold_builtin_load_exponent (tree arg0, tree arg1, tree type, bool ldexp) +fold_builtin_load_exponent (location_t loc, tree arg0, tree arg1, + tree type, bool ldexp) { if (validate_arg (arg0, REAL_TYPE) && validate_arg (arg1, INTEGER_TYPE)) { @@ -9907,7 +9983,7 @@ fold_builtin_load_exponent (tree arg0, tree arg1, tree type, bool ldexp) if (real_zerop (arg0) || integer_zerop (arg1) || (TREE_CODE (arg0) == REAL_CST && !real_isfinite (&TREE_REAL_CST (arg0)))) - return omit_one_operand (type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg0, arg1); /* If both arguments are constant, then try to evaluate it. */ if ((ldexp || REAL_MODE_FORMAT (TYPE_MODE (type))->b == 2) @@ -9954,7 +10030,7 @@ fold_builtin_load_exponent (tree arg0, tree arg1, tree type, bool ldexp) /* Fold a call to builtin modf. */ static tree -fold_builtin_modf (tree arg0, tree arg1, tree rettype) +fold_builtin_modf (location_t loc, tree arg0, tree arg1, tree rettype) { if (! validate_arg (arg0, REAL_TYPE) || ! validate_arg (arg1, POINTER_TYPE)) return NULL_TREE; @@ -9964,7 +10040,7 @@ fold_builtin_modf (tree arg0, tree arg1, tree rettype) if (!(TREE_CODE (arg0) == REAL_CST && ! TREE_OVERFLOW (arg0))) return NULL_TREE; - arg1 = build_fold_indirect_ref (arg1); + arg1 = build_fold_indirect_ref_loc (loc, arg1); /* Proceed if a valid pointer type was passed in. */ if (TYPE_MAIN_VARIANT (TREE_TYPE (arg1)) == TYPE_MAIN_VARIANT (rettype)) @@ -9997,10 +10073,10 @@ fold_builtin_modf (tree arg0, tree arg1, tree rettype) } /* Create the COMPOUND_EXPR (*arg1 = trunc, frac). */ - arg1 = fold_build2 (MODIFY_EXPR, rettype, arg1, + arg1 = fold_build2_loc (loc, MODIFY_EXPR, rettype, arg1, build_real (rettype, trunc)); TREE_SIDE_EFFECTS (arg1) = 1; - return fold_build2 (COMPOUND_EXPR, rettype, arg1, + return fold_build2_loc (loc, COMPOUND_EXPR, rettype, arg1, build_real (rettype, frac)); } @@ -10011,7 +10087,7 @@ fold_builtin_modf (tree arg0, tree arg1, tree rettype) ARG is the argument for the call. */ static tree -fold_builtin_classify (tree fndecl, tree arg, int builtin_index) +fold_builtin_classify (location_t loc, tree fndecl, tree arg, int builtin_index) { tree type = TREE_TYPE (TREE_TYPE (fndecl)); REAL_VALUE_TYPE r; @@ -10023,7 +10099,7 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index) { case BUILT_IN_ISINF: if (!HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg)))) - return omit_one_operand (type, integer_zero_node, arg); + return omit_one_operand_loc (loc, type, integer_zero_node, arg); if (TREE_CODE (arg) == REAL_CST) { @@ -10051,17 +10127,18 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index) if (signbit_fn && isinf_fn) { - tree signbit_call = build_call_expr (signbit_fn, 1, arg); - tree isinf_call = build_call_expr (isinf_fn, 1, arg); + tree signbit_call = build_call_expr_loc (loc, signbit_fn, 1, arg); + tree isinf_call = build_call_expr_loc (loc, isinf_fn, 1, arg); - signbit_call = fold_build2 (NE_EXPR, integer_type_node, + signbit_call = fold_build2_loc (loc, NE_EXPR, integer_type_node, signbit_call, integer_zero_node); - isinf_call = fold_build2 (NE_EXPR, integer_type_node, + isinf_call = fold_build2_loc (loc, NE_EXPR, integer_type_node, isinf_call, integer_zero_node); - tmp = fold_build3 (COND_EXPR, integer_type_node, signbit_call, + tmp = fold_build3_loc (loc, COND_EXPR, integer_type_node, signbit_call, integer_minus_one_node, integer_one_node); - tmp = fold_build3 (COND_EXPR, integer_type_node, isinf_call, tmp, + tmp = fold_build3_loc (loc, COND_EXPR, integer_type_node, + isinf_call, tmp, integer_zero_node); } @@ -10071,7 +10148,7 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index) case BUILT_IN_ISFINITE: if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg))) && !HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg)))) - return omit_one_operand (type, integer_one_node, arg); + return omit_one_operand_loc (loc, type, integer_one_node, arg); if (TREE_CODE (arg) == REAL_CST) { @@ -10083,7 +10160,7 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index) case BUILT_IN_ISNAN: if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg)))) - return omit_one_operand (type, integer_zero_node, arg); + return omit_one_operand_loc (loc, type, integer_zero_node, arg); if (TREE_CODE (arg) == REAL_CST) { @@ -10092,7 +10169,7 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index) } arg = builtin_save_expr (arg); - return fold_build2 (UNORDERED_EXPR, type, arg, arg); + return fold_build2_loc (loc, UNORDERED_EXPR, type, arg, arg); default: gcc_unreachable (); @@ -10108,7 +10185,7 @@ fold_builtin_classify (tree fndecl, tree arg, int builtin_index) one floating point argument which is "type generic". */ static tree -fold_builtin_fpclassify (tree exp) +fold_builtin_fpclassify (location_t loc, tree exp) { tree fp_nan, fp_infinite, fp_normal, fp_subnormal, fp_zero, arg, type, res, tmp; @@ -10130,7 +10207,7 @@ fold_builtin_fpclassify (tree exp) arg = CALL_EXPR_ARG (exp, 5); type = TREE_TYPE (arg); mode = TYPE_MODE (type); - arg = builtin_save_expr (fold_build1 (ABS_EXPR, type, arg)); + arg = builtin_save_expr (fold_build1_loc (loc, ABS_EXPR, type, arg)); /* fpclassify(x) -> isnan(x) ? FP_NAN : @@ -10138,27 +10215,30 @@ fold_builtin_fpclassify (tree exp) (fabs(x) >= DBL_MIN ? FP_NORMAL : (x == 0 ? FP_ZERO : FP_SUBNORMAL))). */ - tmp = fold_build2 (EQ_EXPR, integer_type_node, arg, + tmp = fold_build2_loc (loc, EQ_EXPR, integer_type_node, arg, build_real (type, dconst0)); - res = fold_build3 (COND_EXPR, integer_type_node, tmp, fp_zero, fp_subnormal); + res = fold_build3_loc (loc, COND_EXPR, integer_type_node, + tmp, fp_zero, fp_subnormal); sprintf (buf, "0x1p%d", REAL_MODE_FORMAT (mode)->emin - 1); real_from_string (&r, buf); - tmp = fold_build2 (GE_EXPR, integer_type_node, arg, build_real (type, r)); - res = fold_build3 (COND_EXPR, integer_type_node, tmp, fp_normal, res); + tmp = fold_build2_loc (loc, GE_EXPR, integer_type_node, + arg, build_real (type, r)); + res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp, fp_normal, res); if (HONOR_INFINITIES (mode)) { real_inf (&r); - tmp = fold_build2 (EQ_EXPR, integer_type_node, arg, + tmp = fold_build2_loc (loc, EQ_EXPR, integer_type_node, arg, build_real (type, r)); - res = fold_build3 (COND_EXPR, integer_type_node, tmp, fp_infinite, res); + res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp, + fp_infinite, res); } if (HONOR_NANS (mode)) { - tmp = fold_build2 (ORDERED_EXPR, integer_type_node, arg, arg); - res = fold_build3 (COND_EXPR, integer_type_node, tmp, res, fp_nan); + tmp = fold_build2_loc (loc, ORDERED_EXPR, integer_type_node, arg, arg); + res = fold_build3_loc (loc, COND_EXPR, integer_type_node, tmp, res, fp_nan); } return res; @@ -10173,7 +10253,7 @@ fold_builtin_fpclassify (tree exp) the rest. */ static tree -fold_builtin_unordered_cmp (tree fndecl, tree arg0, tree arg1, +fold_builtin_unordered_cmp (location_t loc, tree fndecl, tree arg0, tree arg1, enum tree_code unordered_code, enum tree_code ordered_code) { @@ -10198,20 +10278,20 @@ fold_builtin_unordered_cmp (tree fndecl, tree arg0, tree arg1, else if (code0 == INTEGER_TYPE && code1 == REAL_TYPE) cmp_type = type1; - arg0 = fold_convert (cmp_type, arg0); - arg1 = fold_convert (cmp_type, arg1); + arg0 = fold_convert_loc (loc, cmp_type, arg0); + arg1 = fold_convert_loc (loc, cmp_type, arg1); if (unordered_code == UNORDERED_EXPR) { if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))) - return omit_two_operands (type, integer_zero_node, arg0, arg1); - return fold_build2 (UNORDERED_EXPR, type, arg0, arg1); + return omit_two_operands_loc (loc, type, integer_zero_node, arg0, arg1); + return fold_build2_loc (loc, UNORDERED_EXPR, type, arg0, arg1); } code = HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code : ordered_code; - return fold_build1 (TRUTH_NOT_EXPR, type, - fold_build2 (code, type, arg0, arg1)); + return fold_build1_loc (loc, TRUTH_NOT_EXPR, type, + fold_build2_loc (loc, code, type, arg0, arg1)); } /* Fold a call to built-in function FNDECL with 0 arguments. @@ -10219,7 +10299,7 @@ fold_builtin_unordered_cmp (tree fndecl, tree arg0, tree arg1, function returns NULL_TREE if no simplification was possible. */ static tree -fold_builtin_0 (tree fndecl, bool ignore ATTRIBUTE_UNUSED) +fold_builtin_0 (location_t loc, tree fndecl, bool ignore ATTRIBUTE_UNUSED) { tree type = TREE_TYPE (TREE_TYPE (fndecl)); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); @@ -10229,10 +10309,10 @@ fold_builtin_0 (tree fndecl, bool ignore ATTRIBUTE_UNUSED) case BUILT_IN_INFD32: case BUILT_IN_INFD64: case BUILT_IN_INFD128: - return fold_builtin_inf (type, true); + return fold_builtin_inf (loc, type, true); CASE_FLT_FN (BUILT_IN_HUGE_VAL): - return fold_builtin_inf (type, false); + return fold_builtin_inf (loc, type, false); case BUILT_IN_CLASSIFY_TYPE: return fold_builtin_classify_type (NULL_TREE); @@ -10248,7 +10328,7 @@ fold_builtin_0 (tree fndecl, bool ignore ATTRIBUTE_UNUSED) function returns NULL_TREE if no simplification was possible. */ static tree -fold_builtin_1 (tree fndecl, tree arg0, bool ignore) +fold_builtin_1 (location_t loc, tree fndecl, tree arg0, bool ignore) { tree type = TREE_TYPE (TREE_TYPE (fndecl)); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); @@ -10272,39 +10352,39 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore) return fold_builtin_classify_type (arg0); case BUILT_IN_STRLEN: - return fold_builtin_strlen (arg0); + return fold_builtin_strlen (loc, arg0); CASE_FLT_FN (BUILT_IN_FABS): - return fold_builtin_fabs (arg0, type); + return fold_builtin_fabs (loc, arg0, type); case BUILT_IN_ABS: case BUILT_IN_LABS: case BUILT_IN_LLABS: case BUILT_IN_IMAXABS: - return fold_builtin_abs (arg0, type); + return fold_builtin_abs (loc, arg0, type); CASE_FLT_FN (BUILT_IN_CONJ): if (validate_arg (arg0, COMPLEX_TYPE) && TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE) - return fold_build1 (CONJ_EXPR, type, arg0); + return fold_build1_loc (loc, CONJ_EXPR, type, arg0); break; CASE_FLT_FN (BUILT_IN_CREAL): if (validate_arg (arg0, COMPLEX_TYPE) && TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE) - return non_lvalue (fold_build1 (REALPART_EXPR, type, arg0));; + return non_lvalue_loc (loc, fold_build1_loc (loc, REALPART_EXPR, type, arg0));; break; CASE_FLT_FN (BUILT_IN_CIMAG): if (validate_arg (arg0, COMPLEX_TYPE)) - return non_lvalue (fold_build1 (IMAGPART_EXPR, type, arg0)); + return non_lvalue_loc (loc, fold_build1_loc (loc, IMAGPART_EXPR, type, arg0)); break; CASE_FLT_FN (BUILT_IN_CCOS): - return fold_builtin_ccos(arg0, type, fndecl, /*hyper=*/ false); + return fold_builtin_ccos(loc, arg0, type, fndecl, /*hyper=*/ false); CASE_FLT_FN (BUILT_IN_CCOSH): - return fold_builtin_ccos(arg0, type, fndecl, /*hyper=*/ true); + return fold_builtin_ccos(loc, arg0, type, fndecl, /*hyper=*/ true); #ifdef HAVE_mpc CASE_FLT_FN (BUILT_IN_CSIN): @@ -10345,16 +10425,16 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore) #endif CASE_FLT_FN (BUILT_IN_CABS): - return fold_builtin_cabs (arg0, type, fndecl); + return fold_builtin_cabs (loc, arg0, type, fndecl); CASE_FLT_FN (BUILT_IN_CARG): - return fold_builtin_carg (arg0, type); + return fold_builtin_carg (loc, arg0, type); CASE_FLT_FN (BUILT_IN_SQRT): - return fold_builtin_sqrt (arg0, type); + return fold_builtin_sqrt (loc, arg0, type); CASE_FLT_FN (BUILT_IN_CBRT): - return fold_builtin_cbrt (arg0, type); + return fold_builtin_cbrt (loc, arg0, type); CASE_FLT_FN (BUILT_IN_ASIN): if (validate_arg (arg0, REAL_TYPE)) @@ -10396,13 +10476,13 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore) break; CASE_FLT_FN (BUILT_IN_COS): - return fold_builtin_cos (arg0, type, fndecl); + return fold_builtin_cos (loc, arg0, type, fndecl); CASE_FLT_FN (BUILT_IN_TAN): return fold_builtin_tan (arg0, type); CASE_FLT_FN (BUILT_IN_CEXP): - return fold_builtin_cexp (arg0, type); + return fold_builtin_cexp (loc, arg0, type); CASE_FLT_FN (BUILT_IN_CEXPI): if (validate_arg (arg0, REAL_TYPE)) @@ -10415,7 +10495,7 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore) break; CASE_FLT_FN (BUILT_IN_COSH): - return fold_builtin_cosh (arg0, type, fndecl); + return fold_builtin_cosh (loc, arg0, type, fndecl); CASE_FLT_FN (BUILT_IN_TANH): if (validate_arg (arg0, REAL_TYPE)) @@ -10438,14 +10518,14 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore) break; CASE_FLT_FN (BUILT_IN_EXP): - return fold_builtin_exponent (fndecl, arg0, mpfr_exp); + return fold_builtin_exponent (loc, fndecl, arg0, mpfr_exp); CASE_FLT_FN (BUILT_IN_EXP2): - return fold_builtin_exponent (fndecl, arg0, mpfr_exp2); + return fold_builtin_exponent (loc, fndecl, arg0, mpfr_exp2); CASE_FLT_FN (BUILT_IN_EXP10): CASE_FLT_FN (BUILT_IN_POW10): - return fold_builtin_exponent (fndecl, arg0, mpfr_exp10); + return fold_builtin_exponent (loc, fndecl, arg0, mpfr_exp10); CASE_FLT_FN (BUILT_IN_EXPM1): if (validate_arg (arg0, REAL_TYPE)) @@ -10453,13 +10533,13 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore) break; CASE_FLT_FN (BUILT_IN_LOG): - return fold_builtin_logarithm (fndecl, arg0, mpfr_log); + return fold_builtin_logarithm (loc, fndecl, arg0, mpfr_log); CASE_FLT_FN (BUILT_IN_LOG2): - return fold_builtin_logarithm (fndecl, arg0, mpfr_log2); + return fold_builtin_logarithm (loc, fndecl, arg0, mpfr_log2); CASE_FLT_FN (BUILT_IN_LOG10): - return fold_builtin_logarithm (fndecl, arg0, mpfr_log10); + return fold_builtin_logarithm (loc, fndecl, arg0, mpfr_log10); CASE_FLT_FN (BUILT_IN_LOG1P): if (validate_arg (arg0, REAL_TYPE)) @@ -10501,20 +10581,20 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore) return fold_builtin_nan (arg0, type, false); CASE_FLT_FN (BUILT_IN_FLOOR): - return fold_builtin_floor (fndecl, arg0); + return fold_builtin_floor (loc, fndecl, arg0); CASE_FLT_FN (BUILT_IN_CEIL): - return fold_builtin_ceil (fndecl, arg0); + return fold_builtin_ceil (loc, fndecl, arg0); CASE_FLT_FN (BUILT_IN_TRUNC): - return fold_builtin_trunc (fndecl, arg0); + return fold_builtin_trunc (loc, fndecl, arg0); CASE_FLT_FN (BUILT_IN_ROUND): - return fold_builtin_round (fndecl, arg0); + return fold_builtin_round (loc, fndecl, arg0); CASE_FLT_FN (BUILT_IN_NEARBYINT): CASE_FLT_FN (BUILT_IN_RINT): - return fold_trunc_transparent_mathfn (fndecl, arg0); + return fold_trunc_transparent_mathfn (loc, fndecl, arg0); CASE_FLT_FN (BUILT_IN_LCEIL): CASE_FLT_FN (BUILT_IN_LLCEIL): @@ -10522,11 +10602,11 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore) CASE_FLT_FN (BUILT_IN_LLFLOOR): CASE_FLT_FN (BUILT_IN_LROUND): CASE_FLT_FN (BUILT_IN_LLROUND): - return fold_builtin_int_roundingfn (fndecl, arg0); + return fold_builtin_int_roundingfn (loc, fndecl, arg0); CASE_FLT_FN (BUILT_IN_LRINT): CASE_FLT_FN (BUILT_IN_LLRINT): - return fold_fixed_mathfn (fndecl, arg0); + return fold_fixed_mathfn (loc, fndecl, arg0); case BUILT_IN_BSWAP32: case BUILT_IN_BSWAP64: @@ -10540,50 +10620,50 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore) return fold_builtin_bitop (fndecl, arg0); CASE_FLT_FN (BUILT_IN_SIGNBIT): - return fold_builtin_signbit (arg0, type); + return fold_builtin_signbit (loc, arg0, type); CASE_FLT_FN (BUILT_IN_SIGNIFICAND): - return fold_builtin_significand (arg0, type); + return fold_builtin_significand (loc, arg0, type); CASE_FLT_FN (BUILT_IN_ILOGB): CASE_FLT_FN (BUILT_IN_LOGB): - return fold_builtin_logb (arg0, type); + return fold_builtin_logb (loc, arg0, type); case BUILT_IN_ISASCII: - return fold_builtin_isascii (arg0); + return fold_builtin_isascii (loc, arg0); case BUILT_IN_TOASCII: - return fold_builtin_toascii (arg0); + return fold_builtin_toascii (loc, arg0); case BUILT_IN_ISDIGIT: - return fold_builtin_isdigit (arg0); + return fold_builtin_isdigit (loc, arg0); CASE_FLT_FN (BUILT_IN_FINITE): case BUILT_IN_FINITED32: case BUILT_IN_FINITED64: case BUILT_IN_FINITED128: case BUILT_IN_ISFINITE: - return fold_builtin_classify (fndecl, arg0, BUILT_IN_ISFINITE); + return fold_builtin_classify (loc, fndecl, arg0, BUILT_IN_ISFINITE); CASE_FLT_FN (BUILT_IN_ISINF): case BUILT_IN_ISINFD32: case BUILT_IN_ISINFD64: case BUILT_IN_ISINFD128: - return fold_builtin_classify (fndecl, arg0, BUILT_IN_ISINF); + return fold_builtin_classify (loc, fndecl, arg0, BUILT_IN_ISINF); case BUILT_IN_ISINF_SIGN: - return fold_builtin_classify (fndecl, arg0, BUILT_IN_ISINF_SIGN); + return fold_builtin_classify (loc, fndecl, arg0, BUILT_IN_ISINF_SIGN); CASE_FLT_FN (BUILT_IN_ISNAN): case BUILT_IN_ISNAND32: case BUILT_IN_ISNAND64: case BUILT_IN_ISNAND128: - return fold_builtin_classify (fndecl, arg0, BUILT_IN_ISNAN); + return fold_builtin_classify (loc, fndecl, arg0, BUILT_IN_ISNAN); case BUILT_IN_PRINTF: case BUILT_IN_PRINTF_UNLOCKED: case BUILT_IN_VPRINTF: - return fold_builtin_printf (fndecl, arg0, NULL_TREE, ignore, fcode); + return fold_builtin_printf (loc, fndecl, arg0, NULL_TREE, ignore, fcode); default: break; @@ -10598,7 +10678,7 @@ fold_builtin_1 (tree fndecl, tree arg0, bool ignore) function returns NULL_TREE if no simplification was possible. */ static tree -fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore) +fold_builtin_2 (location_t loc, tree fndecl, tree arg0, tree arg1, bool ignore) { tree type = TREE_TYPE (TREE_TYPE (fndecl)); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); @@ -10645,51 +10725,62 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore) break; CASE_FLT_FN (BUILT_IN_HYPOT): - return fold_builtin_hypot (fndecl, arg0, arg1, type); + return fold_builtin_hypot (loc, fndecl, arg0, arg1, type); + +#ifdef HAVE_mpc_pow + CASE_FLT_FN (BUILT_IN_CPOW): + if (validate_arg (arg0, COMPLEX_TYPE) + && TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE + && validate_arg (arg1, COMPLEX_TYPE) + && TREE_CODE (TREE_TYPE (TREE_TYPE (arg1))) == REAL_TYPE) + return do_mpc_arg2 (arg0, arg1, type, mpc_pow); + break; +#endif CASE_FLT_FN (BUILT_IN_LDEXP): - return fold_builtin_load_exponent (arg0, arg1, type, /*ldexp=*/true); + return fold_builtin_load_exponent (loc, arg0, arg1, type, /*ldexp=*/true); CASE_FLT_FN (BUILT_IN_SCALBN): CASE_FLT_FN (BUILT_IN_SCALBLN): - return fold_builtin_load_exponent (arg0, arg1, type, /*ldexp=*/false); + return fold_builtin_load_exponent (loc, arg0, arg1, + type, /*ldexp=*/false); CASE_FLT_FN (BUILT_IN_FREXP): - return fold_builtin_frexp (arg0, arg1, type); + return fold_builtin_frexp (loc, arg0, arg1, type); CASE_FLT_FN (BUILT_IN_MODF): - return fold_builtin_modf (arg0, arg1, type); + return fold_builtin_modf (loc, arg0, arg1, type); case BUILT_IN_BZERO: - return fold_builtin_bzero (arg0, arg1, ignore); + return fold_builtin_bzero (loc, arg0, arg1, ignore); case BUILT_IN_FPUTS: - return fold_builtin_fputs (arg0, arg1, ignore, false, NULL_TREE); + return fold_builtin_fputs (loc, arg0, arg1, ignore, false, NULL_TREE); case BUILT_IN_FPUTS_UNLOCKED: - return fold_builtin_fputs (arg0, arg1, ignore, true, NULL_TREE); + return fold_builtin_fputs (loc, arg0, arg1, ignore, true, NULL_TREE); case BUILT_IN_STRSTR: - return fold_builtin_strstr (arg0, arg1, type); + return fold_builtin_strstr (loc, arg0, arg1, type); case BUILT_IN_STRCAT: - return fold_builtin_strcat (arg0, arg1); + return fold_builtin_strcat (loc, arg0, arg1); case BUILT_IN_STRSPN: - return fold_builtin_strspn (arg0, arg1); + return fold_builtin_strspn (loc, arg0, arg1); case BUILT_IN_STRCSPN: - return fold_builtin_strcspn (arg0, arg1); + return fold_builtin_strcspn (loc, arg0, arg1); case BUILT_IN_STRCHR: case BUILT_IN_INDEX: - return fold_builtin_strchr (arg0, arg1, type); + return fold_builtin_strchr (loc, arg0, arg1, type); case BUILT_IN_STRRCHR: case BUILT_IN_RINDEX: - return fold_builtin_strrchr (arg0, arg1, type); + return fold_builtin_strrchr (loc, arg0, arg1, type); case BUILT_IN_STRCPY: - return fold_builtin_strcpy (fndecl, arg0, arg1, NULL_TREE); + return fold_builtin_strcpy (loc, fndecl, arg0, arg1, NULL_TREE); case BUILT_IN_STPCPY: if (ignore) @@ -10698,46 +10789,52 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore) if (!fn) break; - return build_call_expr (fn, 2, arg0, arg1); + return build_call_expr_loc (loc, fn, 2, arg0, arg1); } break; case BUILT_IN_STRCMP: - return fold_builtin_strcmp (arg0, arg1); + return fold_builtin_strcmp (loc, arg0, arg1); case BUILT_IN_STRPBRK: - return fold_builtin_strpbrk (arg0, arg1, type); + return fold_builtin_strpbrk (loc, arg0, arg1, type); case BUILT_IN_EXPECT: - return fold_builtin_expect (arg0, arg1); + return fold_builtin_expect (loc, arg0, arg1); CASE_FLT_FN (BUILT_IN_POW): - return fold_builtin_pow (fndecl, arg0, arg1, type); + return fold_builtin_pow (loc, fndecl, arg0, arg1, type); CASE_FLT_FN (BUILT_IN_POWI): - return fold_builtin_powi (fndecl, arg0, arg1, type); + return fold_builtin_powi (loc, fndecl, arg0, arg1, type); CASE_FLT_FN (BUILT_IN_COPYSIGN): - return fold_builtin_copysign (fndecl, arg0, arg1, type); + return fold_builtin_copysign (loc, fndecl, arg0, arg1, type); CASE_FLT_FN (BUILT_IN_FMIN): - return fold_builtin_fmin_fmax (arg0, arg1, type, /*max=*/false); + return fold_builtin_fmin_fmax (loc, arg0, arg1, type, /*max=*/false); CASE_FLT_FN (BUILT_IN_FMAX): - return fold_builtin_fmin_fmax (arg0, arg1, type, /*max=*/true); + return fold_builtin_fmin_fmax (loc, arg0, arg1, type, /*max=*/true); case BUILT_IN_ISGREATER: - return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNLE_EXPR, LE_EXPR); + return fold_builtin_unordered_cmp (loc, fndecl, + arg0, arg1, UNLE_EXPR, LE_EXPR); case BUILT_IN_ISGREATEREQUAL: - return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNLT_EXPR, LT_EXPR); + return fold_builtin_unordered_cmp (loc, fndecl, + arg0, arg1, UNLT_EXPR, LT_EXPR); case BUILT_IN_ISLESS: - return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNGE_EXPR, GE_EXPR); + return fold_builtin_unordered_cmp (loc, fndecl, + arg0, arg1, UNGE_EXPR, GE_EXPR); case BUILT_IN_ISLESSEQUAL: - return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNGT_EXPR, GT_EXPR); + return fold_builtin_unordered_cmp (loc, fndecl, + arg0, arg1, UNGT_EXPR, GT_EXPR); case BUILT_IN_ISLESSGREATER: - return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNEQ_EXPR, EQ_EXPR); + return fold_builtin_unordered_cmp (loc, fndecl, + arg0, arg1, UNEQ_EXPR, EQ_EXPR); case BUILT_IN_ISUNORDERED: - return fold_builtin_unordered_cmp (fndecl, arg0, arg1, UNORDERED_EXPR, + return fold_builtin_unordered_cmp (loc, fndecl, + arg0, arg1, UNORDERED_EXPR, NOP_EXPR); /* We do the folding for va_start in the expander. */ @@ -10745,7 +10842,7 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore) break; case BUILT_IN_SPRINTF: - return fold_builtin_sprintf (arg0, arg1, NULL_TREE, ignore); + return fold_builtin_sprintf (loc, arg0, arg1, NULL_TREE, ignore); case BUILT_IN_OBJECT_SIZE: return fold_builtin_object_size (arg0, arg1); @@ -10753,7 +10850,7 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore) case BUILT_IN_PRINTF: case BUILT_IN_PRINTF_UNLOCKED: case BUILT_IN_VPRINTF: - return fold_builtin_printf (fndecl, arg0, arg1, ignore, fcode); + return fold_builtin_printf (loc, fndecl, arg0, arg1, ignore, fcode); case BUILT_IN_PRINTF_CHK: case BUILT_IN_VPRINTF_CHK: @@ -10761,13 +10858,14 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore) || TREE_SIDE_EFFECTS (arg0)) return NULL_TREE; else - return fold_builtin_printf (fndecl, arg1, NULL_TREE, ignore, fcode); + return fold_builtin_printf (loc, fndecl, + arg1, NULL_TREE, ignore, fcode); break; case BUILT_IN_FPRINTF: case BUILT_IN_FPRINTF_UNLOCKED: case BUILT_IN_VFPRINTF: - return fold_builtin_fprintf (fndecl, arg0, arg1, NULL_TREE, + return fold_builtin_fprintf (loc, fndecl, arg0, arg1, NULL_TREE, ignore, fcode); default: @@ -10781,7 +10879,8 @@ fold_builtin_2 (tree fndecl, tree arg0, tree arg1, bool ignore) This function returns NULL_TREE if no simplification was possible. */ static tree -fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore) +fold_builtin_3 (location_t loc, tree fndecl, + tree arg0, tree arg1, tree arg2, bool ignore) { tree type = TREE_TYPE (TREE_TYPE (fndecl)); enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); @@ -10789,7 +10888,7 @@ fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore) { CASE_FLT_FN (BUILT_IN_SINCOS): - return fold_builtin_sincos (arg0, arg1, arg2); + return fold_builtin_sincos (loc, arg0, arg1, arg2); CASE_FLT_FN (BUILT_IN_FMA): if (validate_arg (arg0, REAL_TYPE) @@ -10806,46 +10905,50 @@ fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore) break; case BUILT_IN_MEMSET: - return fold_builtin_memset (arg0, arg1, arg2, type, ignore); + return fold_builtin_memset (loc, arg0, arg1, arg2, type, ignore); case BUILT_IN_BCOPY: - return fold_builtin_memory_op (arg1, arg0, arg2, void_type_node, true, /*endp=*/3); + return fold_builtin_memory_op (loc, arg1, arg0, arg2, + void_type_node, true, /*endp=*/3); case BUILT_IN_MEMCPY: - return fold_builtin_memory_op (arg0, arg1, arg2, type, ignore, /*endp=*/0); + return fold_builtin_memory_op (loc, arg0, arg1, arg2, + type, ignore, /*endp=*/0); case BUILT_IN_MEMPCPY: - return fold_builtin_memory_op (arg0, arg1, arg2, type, ignore, /*endp=*/1); + return fold_builtin_memory_op (loc, arg0, arg1, arg2, + type, ignore, /*endp=*/1); case BUILT_IN_MEMMOVE: - return fold_builtin_memory_op (arg0, arg1, arg2, type, ignore, /*endp=*/3); + return fold_builtin_memory_op (loc, arg0, arg1, arg2, + type, ignore, /*endp=*/3); case BUILT_IN_STRNCAT: - return fold_builtin_strncat (arg0, arg1, arg2); + return fold_builtin_strncat (loc, arg0, arg1, arg2); case BUILT_IN_STRNCPY: - return fold_builtin_strncpy (fndecl, arg0, arg1, arg2, NULL_TREE); + return fold_builtin_strncpy (loc, fndecl, arg0, arg1, arg2, NULL_TREE); case BUILT_IN_STRNCMP: - return fold_builtin_strncmp (arg0, arg1, arg2); + return fold_builtin_strncmp (loc, arg0, arg1, arg2); case BUILT_IN_MEMCHR: - return fold_builtin_memchr (arg0, arg1, arg2, type); + return fold_builtin_memchr (loc, arg0, arg1, arg2, type); case BUILT_IN_BCMP: case BUILT_IN_MEMCMP: - return fold_builtin_memcmp (arg0, arg1, arg2);; + return fold_builtin_memcmp (loc, arg0, arg1, arg2);; case BUILT_IN_SPRINTF: - return fold_builtin_sprintf (arg0, arg1, arg2, ignore); + return fold_builtin_sprintf (loc, arg0, arg1, arg2, ignore); case BUILT_IN_STRCPY_CHK: case BUILT_IN_STPCPY_CHK: - return fold_builtin_stxcpy_chk (fndecl, arg0, arg1, arg2, NULL_TREE, + return fold_builtin_stxcpy_chk (loc, fndecl, arg0, arg1, arg2, NULL_TREE, ignore, fcode); case BUILT_IN_STRCAT_CHK: - return fold_builtin_strcat_chk (fndecl, arg0, arg1, arg2); + return fold_builtin_strcat_chk (loc, fndecl, arg0, arg1, arg2); case BUILT_IN_PRINTF_CHK: case BUILT_IN_VPRINTF_CHK: @@ -10853,13 +10956,14 @@ fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore) || TREE_SIDE_EFFECTS (arg0)) return NULL_TREE; else - return fold_builtin_printf (fndecl, arg1, arg2, ignore, fcode); + return fold_builtin_printf (loc, fndecl, arg1, arg2, ignore, fcode); break; case BUILT_IN_FPRINTF: case BUILT_IN_FPRINTF_UNLOCKED: case BUILT_IN_VFPRINTF: - return fold_builtin_fprintf (fndecl, arg0, arg1, arg2, ignore, fcode); + return fold_builtin_fprintf (loc, fndecl, arg0, arg1, arg2, + ignore, fcode); case BUILT_IN_FPRINTF_CHK: case BUILT_IN_VFPRINTF_CHK: @@ -10867,7 +10971,7 @@ fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore) || TREE_SIDE_EFFECTS (arg1)) return NULL_TREE; else - return fold_builtin_fprintf (fndecl, arg0, arg2, NULL_TREE, + return fold_builtin_fprintf (loc, fndecl, arg0, arg2, NULL_TREE, ignore, fcode); default: @@ -10882,8 +10986,8 @@ fold_builtin_3 (tree fndecl, tree arg0, tree arg1, tree arg2, bool ignore) possible. */ static tree -fold_builtin_4 (tree fndecl, tree arg0, tree arg1, tree arg2, tree arg3, - bool ignore) +fold_builtin_4 (location_t loc, tree fndecl, + tree arg0, tree arg1, tree arg2, tree arg3, bool ignore) { enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); @@ -10893,15 +10997,15 @@ fold_builtin_4 (tree fndecl, tree arg0, tree arg1, tree arg2, tree arg3, case BUILT_IN_MEMPCPY_CHK: case BUILT_IN_MEMMOVE_CHK: case BUILT_IN_MEMSET_CHK: - return fold_builtin_memory_chk (fndecl, arg0, arg1, arg2, arg3, + return fold_builtin_memory_chk (loc, fndecl, arg0, arg1, arg2, arg3, NULL_TREE, ignore, DECL_FUNCTION_CODE (fndecl)); case BUILT_IN_STRNCPY_CHK: - return fold_builtin_strncpy_chk (arg0, arg1, arg2, arg3, NULL_TREE); + return fold_builtin_strncpy_chk (loc, arg0, arg1, arg2, arg3, NULL_TREE); case BUILT_IN_STRNCAT_CHK: - return fold_builtin_strncat_chk (fndecl, arg0, arg1, arg2, arg3); + return fold_builtin_strncat_chk (loc, fndecl, arg0, arg1, arg2, arg3); case BUILT_IN_FPRINTF_CHK: case BUILT_IN_VFPRINTF_CHK: @@ -10909,7 +11013,7 @@ fold_builtin_4 (tree fndecl, tree arg0, tree arg1, tree arg2, tree arg3, || TREE_SIDE_EFFECTS (arg1)) return NULL_TREE; else - return fold_builtin_fprintf (fndecl, arg0, arg2, arg3, + return fold_builtin_fprintf (loc, fndecl, arg0, arg2, arg3, ignore, fcode); break; @@ -10930,26 +11034,26 @@ fold_builtin_4 (tree fndecl, tree arg0, tree arg1, tree arg2, tree arg3, #define MAX_ARGS_TO_FOLD_BUILTIN 4 static tree -fold_builtin_n (tree fndecl, tree *args, int nargs, bool ignore) +fold_builtin_n (location_t loc, tree fndecl, tree *args, int nargs, bool ignore) { tree ret = NULL_TREE; switch (nargs) { case 0: - ret = fold_builtin_0 (fndecl, ignore); + ret = fold_builtin_0 (loc, fndecl, ignore); break; case 1: - ret = fold_builtin_1 (fndecl, args[0], ignore); + ret = fold_builtin_1 (loc, fndecl, args[0], ignore); break; case 2: - ret = fold_builtin_2 (fndecl, args[0], args[1], ignore); + ret = fold_builtin_2 (loc, fndecl, args[0], args[1], ignore); break; case 3: - ret = fold_builtin_3 (fndecl, args[0], args[1], args[2], ignore); + ret = fold_builtin_3 (loc, fndecl, args[0], args[1], args[2], ignore); break; case 4: - ret = fold_builtin_4 (fndecl, args[0], args[1], args[2], args[3], + ret = fold_builtin_4 (loc, fndecl, args[0], args[1], args[2], args[3], ignore); break; default: @@ -10958,6 +11062,7 @@ fold_builtin_n (tree fndecl, tree *args, int nargs, bool ignore) if (ret) { ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret); + SET_EXPR_LOCATION (ret, loc); TREE_NO_WARNING (ret) = 1; return ret; } @@ -10972,7 +11077,8 @@ fold_builtin_n (tree fndecl, tree *args, int nargs, bool ignore) result of the function call is ignored. */ static tree -fold_builtin_varargs (tree fndecl, tree exp, bool ignore ATTRIBUTE_UNUSED) +fold_builtin_varargs (location_t loc, tree fndecl, tree exp, + bool ignore ATTRIBUTE_UNUSED) { enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); tree ret = NULL_TREE; @@ -10981,16 +11087,16 @@ fold_builtin_varargs (tree fndecl, tree exp, bool ignore ATTRIBUTE_UNUSED) { case BUILT_IN_SPRINTF_CHK: case BUILT_IN_VSPRINTF_CHK: - ret = fold_builtin_sprintf_chk (exp, fcode); + ret = fold_builtin_sprintf_chk (loc, exp, fcode); break; case BUILT_IN_SNPRINTF_CHK: case BUILT_IN_VSNPRINTF_CHK: - ret = fold_builtin_snprintf_chk (exp, NULL_TREE, fcode); + ret = fold_builtin_snprintf_chk (loc, exp, NULL_TREE, fcode); break; case BUILT_IN_FPCLASSIFY: - ret = fold_builtin_fpclassify (exp); + ret = fold_builtin_fpclassify (loc, exp); break; default: @@ -10999,6 +11105,7 @@ fold_builtin_varargs (tree fndecl, tree exp, bool ignore ATTRIBUTE_UNUSED) if (ret) { ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret); + SET_EXPR_LOCATION (ret, loc); TREE_NO_WARNING (ret) = 1; return ret; } @@ -11026,7 +11133,7 @@ avoid_folding_inline_builtin (tree fndecl) call node earlier than the warning is generated. */ tree -fold_call_expr (tree exp, bool ignore) +fold_call_expr (location_t loc, tree exp, bool ignore) { tree ret = NULL_TREE; tree fndecl = get_callee_fndecl (exp); @@ -11064,27 +11171,12 @@ fold_call_expr (tree exp, bool ignore) if (nargs <= MAX_ARGS_TO_FOLD_BUILTIN) { tree *args = CALL_EXPR_ARGP (exp); - ret = fold_builtin_n (fndecl, args, nargs, ignore); + ret = fold_builtin_n (loc, fndecl, args, nargs, ignore); } if (!ret) - ret = fold_builtin_varargs (fndecl, exp, ignore); + ret = fold_builtin_varargs (loc, fndecl, exp, ignore); if (ret) - { - /* Propagate location information from original call to - expansion of builtin. Otherwise things like - maybe_emit_chk_warning, that operate on the expansion - of a builtin, will use the wrong location information. */ - if (CAN_HAVE_LOCATION_P (exp) && EXPR_HAS_LOCATION (exp)) - { - tree realret = ret; - if (TREE_CODE (ret) == NOP_EXPR) - realret = TREE_OPERAND (ret, 0); - if (CAN_HAVE_LOCATION_P (realret) - && !EXPR_HAS_LOCATION (realret)) - SET_EXPR_LOCATION (realret, EXPR_LOCATION (exp)); - } - return ret; - } + return ret; } } return NULL_TREE; @@ -11094,17 +11186,17 @@ fold_call_expr (tree exp, bool ignore) function to be called and ARGLIST is a TREE_LIST of arguments. */ tree -build_function_call_expr (tree fndecl, tree arglist) +build_function_call_expr (location_t loc, tree fndecl, tree arglist) { tree fntype = TREE_TYPE (fndecl); tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl); int n = list_length (arglist); tree *argarray = (tree *) alloca (n * sizeof (tree)); int i; - + for (i = 0; i < n; i++, arglist = TREE_CHAIN (arglist)) argarray[i] = TREE_VALUE (arglist); - return fold_builtin_call_array (TREE_TYPE (fntype), fn, n, argarray); + return fold_builtin_call_array (loc, TREE_TYPE (fntype), fn, n, argarray); } /* Conveniently construct a function call expression. FNDECL names the @@ -11112,7 +11204,7 @@ build_function_call_expr (tree fndecl, tree arglist) parameters are the argument expressions. */ tree -build_call_expr (tree fndecl, int n, ...) +build_call_expr_loc (location_t loc, tree fndecl, int n, ...) { va_list ap; tree fntype = TREE_TYPE (fndecl); @@ -11124,14 +11216,14 @@ build_call_expr (tree fndecl, int n, ...) for (i = 0; i < n; i++) argarray[i] = va_arg (ap, tree); va_end (ap); - return fold_builtin_call_array (TREE_TYPE (fntype), fn, n, argarray); + return fold_builtin_call_array (loc, TREE_TYPE (fntype), fn, n, argarray); } /* Construct a CALL_EXPR with type TYPE with FN as the function expression. N arguments are passed in the array ARGARRAY. */ tree -fold_builtin_call_array (tree type, +fold_builtin_call_array (location_t loc, tree type, tree fn, int n, tree *argarray) @@ -11155,10 +11247,10 @@ fold_builtin_call_array (tree type, && TREE_CODE (fndecl2) == FUNCTION_DECL && DECL_BUILT_IN_CLASS (fndecl2) == BUILT_IN_NORMAL && DECL_FUNCTION_CODE (fndecl2) == BUILT_IN_VA_ARG_PACK) - return build_call_array (type, fn, n, argarray); + return build_call_array_loc (loc, type, fn, n, argarray); } if (avoid_folding_inline_builtin (fndecl)) - return build_call_array (type, fn, n, argarray); + return build_call_array_loc (loc, type, fn, n, argarray); if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) { tree arglist = NULL_TREE; @@ -11167,25 +11259,25 @@ fold_builtin_call_array (tree type, ret = targetm.fold_builtin (fndecl, arglist, false); if (ret) return ret; - return build_call_array (type, fn, n, argarray); + return build_call_array_loc (loc, type, fn, n, argarray); } else if (n <= MAX_ARGS_TO_FOLD_BUILTIN) { /* First try the transformations that don't require consing up an exp. */ - ret = fold_builtin_n (fndecl, argarray, n, false); + ret = fold_builtin_n (loc, fndecl, argarray, n, false); if (ret) return ret; } /* If we got this far, we need to build an exp. */ - exp = build_call_array (type, fn, n, argarray); - ret = fold_builtin_varargs (fndecl, exp, false); + exp = build_call_array_loc (loc, type, fn, n, argarray); + ret = fold_builtin_varargs (loc, fndecl, exp, false); return ret ? ret : exp; } } - return build_call_array (type, fn, n, argarray); + return build_call_array_loc (loc, type, fn, n, argarray); } /* Construct a new CALL_EXPR using the tail of the argument list of EXP @@ -11194,7 +11286,7 @@ fold_builtin_call_array (tree type, to do varargs-to-varargs transformations. */ static tree -rewrite_call_expr (tree exp, int skip, tree fndecl, int n, ...) +rewrite_call_expr (location_t loc, tree exp, int skip, tree fndecl, int n, ...) { int oldnargs = call_expr_nargs (exp); int nargs = oldnargs - skip + n; @@ -11218,7 +11310,7 @@ rewrite_call_expr (tree exp, int skip, tree fndecl, int n, ...) else buffer = CALL_EXPR_ARGP (exp) + skip; - return fold (build_call_array (TREE_TYPE (exp), fn, nargs, buffer)); + return fold (build_call_array_loc (loc, TREE_TYPE (exp), fn, nargs, buffer)); } /* Validate a single argument ARG against a tree code CODE representing @@ -11399,7 +11491,7 @@ readonly_data_expr (tree exp) form of the builtin function call. */ static tree -fold_builtin_strstr (tree s1, tree s2, tree type) +fold_builtin_strstr (location_t loc, tree s1, tree s2, tree type) { if (!validate_arg (s1, POINTER_TYPE) || !validate_arg (s2, POINTER_TYPE)) @@ -11423,15 +11515,15 @@ fold_builtin_strstr (tree s1, tree s2, tree type) return build_int_cst (TREE_TYPE (s1), 0); /* Return an offset into the constant string argument. */ - tem = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (s1), + tem = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (s1), s1, size_int (r - p1)); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } /* The argument is const char *, and the result is char *, so we need a type conversion here to avoid a warning. */ if (p2[0] == '\0') - return fold_convert (type, s1); + return fold_convert_loc (loc, type, s1); if (p2[1] != '\0') return NULL_TREE; @@ -11442,7 +11534,7 @@ fold_builtin_strstr (tree s1, tree s2, tree type) /* New argument list transforming strstr(s1, s2) to strchr(s1, s2[0]). */ - return build_call_expr (fn, 2, s1, build_int_cst (NULL_TREE, p2[0])); + return build_call_expr_loc (loc, fn, 2, s1, build_int_cst (NULL_TREE, p2[0])); } } @@ -11465,7 +11557,7 @@ fold_builtin_strstr (tree s1, tree s2, tree type) form of the builtin function call. */ static tree -fold_builtin_strchr (tree s1, tree s2, tree type) +fold_builtin_strchr (location_t loc, tree s1, tree s2, tree type) { if (!validate_arg (s1, POINTER_TYPE) || !validate_arg (s2, INTEGER_TYPE)) @@ -11493,9 +11585,9 @@ fold_builtin_strchr (tree s1, tree s2, tree type) return build_int_cst (TREE_TYPE (s1), 0); /* Return an offset into the constant string argument. */ - tem = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (s1), + tem = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (s1), s1, size_int (r - p1)); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } return NULL_TREE; } @@ -11520,7 +11612,7 @@ fold_builtin_strchr (tree s1, tree s2, tree type) form of the builtin function call. */ static tree -fold_builtin_strrchr (tree s1, tree s2, tree type) +fold_builtin_strrchr (location_t loc, tree s1, tree s2, tree type) { if (!validate_arg (s1, POINTER_TYPE) || !validate_arg (s2, INTEGER_TYPE)) @@ -11549,9 +11641,9 @@ fold_builtin_strrchr (tree s1, tree s2, tree type) return build_int_cst (TREE_TYPE (s1), 0); /* Return an offset into the constant string argument. */ - tem = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (s1), + tem = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (s1), s1, size_int (r - p1)); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } if (! integer_zerop (s2)) @@ -11562,7 +11654,7 @@ fold_builtin_strrchr (tree s1, tree s2, tree type) return NULL_TREE; /* Transform strrchr(s1, '\0') to strchr(s1, '\0'). */ - return build_call_expr (fn, 2, s1, s2); + return build_call_expr_loc (loc, fn, 2, s1, s2); } } @@ -11585,7 +11677,7 @@ fold_builtin_strrchr (tree s1, tree s2, tree type) form of the builtin function call. */ static tree -fold_builtin_strpbrk (tree s1, tree s2, tree type) +fold_builtin_strpbrk (location_t loc, tree s1, tree s2, tree type) { if (!validate_arg (s1, POINTER_TYPE) || !validate_arg (s2, POINTER_TYPE)) @@ -11609,15 +11701,15 @@ fold_builtin_strpbrk (tree s1, tree s2, tree type) return build_int_cst (TREE_TYPE (s1), 0); /* Return an offset into the constant string argument. */ - tem = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (s1), + tem = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (s1), s1, size_int (r - p1)); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } if (p2[0] == '\0') /* strpbrk(x, "") == NULL. Evaluate and ignore s1 in case it had side-effects. */ - return omit_one_operand (TREE_TYPE (s1), integer_zero_node, s1); + return omit_one_operand_loc (loc, TREE_TYPE (s1), integer_zero_node, s1); if (p2[1] != '\0') return NULL_TREE; /* Really call strpbrk. */ @@ -11628,7 +11720,7 @@ fold_builtin_strpbrk (tree s1, tree s2, tree type) /* New argument list transforming strpbrk(s1, s2) to strchr(s1, s2[0]). */ - return build_call_expr (fn, 2, s1, build_int_cst (NULL_TREE, p2[0])); + return build_call_expr_loc (loc, fn, 2, s1, build_int_cst (NULL_TREE, p2[0])); } } @@ -11651,7 +11743,7 @@ fold_builtin_strpbrk (tree s1, tree s2, tree type) form of the builtin function call. */ static tree -fold_builtin_strcat (tree dst, tree src) +fold_builtin_strcat (location_t loc ATTRIBUTE_UNUSED, tree dst, tree src) { if (!validate_arg (dst, POINTER_TYPE) || !validate_arg (src, POINTER_TYPE)) @@ -11687,7 +11779,7 @@ fold_builtin_strcat (tree dst, tree src) form of the builtin function call. */ static tree -fold_builtin_strncat (tree dst, tree src, tree len) +fold_builtin_strncat (location_t loc, tree dst, tree src, tree len) { if (!validate_arg (dst, POINTER_TYPE) || !validate_arg (src, POINTER_TYPE) @@ -11700,7 +11792,7 @@ fold_builtin_strncat (tree dst, tree src, tree len) /* If the requested length is zero, or the src parameter string length is zero, return the dst parameter. */ if (integer_zerop (len) || (p && *p == '\0')) - return omit_two_operands (TREE_TYPE (dst), dst, src, len); + return omit_two_operands_loc (loc, TREE_TYPE (dst), dst, src, len); /* If the requested len is greater than or equal to the string length, call strcat. */ @@ -11714,7 +11806,7 @@ fold_builtin_strncat (tree dst, tree src, tree len) if (!fn) return NULL_TREE; - return build_call_expr (fn, 2, dst, src); + return build_call_expr_loc (loc, fn, 2, dst, src); } return NULL_TREE; } @@ -11739,7 +11831,7 @@ fold_builtin_strncat (tree dst, tree src, tree len) form of the builtin function call. */ static tree -fold_builtin_strspn (tree s1, tree s2) +fold_builtin_strspn (location_t loc, tree s1, tree s2) { if (!validate_arg (s1, POINTER_TYPE) || !validate_arg (s2, POINTER_TYPE)) @@ -11759,7 +11851,7 @@ fold_builtin_strspn (tree s1, tree s2) if ((p1 && *p1 == '\0') || (p2 && *p2 == '\0')) /* Evaluate and ignore both arguments in case either one has side-effects. */ - return omit_two_operands (size_type_node, size_zero_node, + return omit_two_operands_loc (loc, size_type_node, size_zero_node, s1, s2); return NULL_TREE; } @@ -11784,7 +11876,7 @@ fold_builtin_strspn (tree s1, tree s2) form of the builtin function call. */ static tree -fold_builtin_strcspn (tree s1, tree s2) +fold_builtin_strcspn (location_t loc, tree s1, tree s2) { if (!validate_arg (s1, POINTER_TYPE) || !validate_arg (s2, POINTER_TYPE)) @@ -11805,7 +11897,7 @@ fold_builtin_strcspn (tree s1, tree s2) { /* Evaluate and ignore argument s2 in case it has side-effects. */ - return omit_one_operand (size_type_node, + return omit_one_operand_loc (loc, size_type_node, size_zero_node, s2); } @@ -11819,7 +11911,7 @@ fold_builtin_strcspn (tree s1, tree s2) if (!fn) return NULL_TREE; - return build_call_expr (fn, 1, s1); + return build_call_expr_loc (loc, fn, 1, s1); } return NULL_TREE; } @@ -11833,7 +11925,8 @@ fold_builtin_strcspn (tree s1, tree s2) was possible. */ tree -fold_builtin_fputs (tree arg0, tree arg1, bool ignore, bool unlocked, tree len) +fold_builtin_fputs (location_t loc, tree arg0, tree arg1, + bool ignore, bool unlocked, tree len) { /* If we're using an unlocked function, assume the other unlocked functions exist explicitly. */ @@ -11863,7 +11956,8 @@ fold_builtin_fputs (tree arg0, tree arg1, bool ignore, bool unlocked, tree len) switch (compare_tree_int (len, 1)) { case -1: /* length is 0, delete the call entirely . */ - return omit_one_operand (integer_type_node, integer_zero_node, arg1);; + return omit_one_operand_loc (loc, integer_type_node, + integer_zero_node, arg1);; case 0: /* length is 1, call fputc. */ { @@ -11872,7 +11966,7 @@ fold_builtin_fputs (tree arg0, tree arg1, bool ignore, bool unlocked, tree len) if (p != NULL) { if (fn_fputc) - return build_call_expr (fn_fputc, 2, + return build_call_expr_loc (loc, fn_fputc, 2, build_int_cst (NULL_TREE, p[0]), arg1); else return NULL_TREE; @@ -11887,7 +11981,8 @@ fold_builtin_fputs (tree arg0, tree arg1, bool ignore, bool unlocked, tree len) /* New argument list transforming fputs(string, stream) to fwrite(string, 1, len, stream). */ if (fn_fwrite) - return build_call_expr (fn_fwrite, 4, arg0, size_one_node, len, arg1); + return build_call_expr_loc (loc, fn_fwrite, 4, arg0, + size_one_node, len, arg1); else return NULL_TREE; } @@ -12004,7 +12099,8 @@ fold_builtin_next_arg (tree exp, bool va_start_p) the caller does not use the returned value of the function. */ static tree -fold_builtin_sprintf (tree dest, tree fmt, tree orig, int ignored) +fold_builtin_sprintf (location_t loc, tree dest, tree fmt, + tree orig, int ignored) { tree call, retval; const char *fmt_str = NULL; @@ -12043,7 +12139,7 @@ fold_builtin_sprintf (tree dest, tree fmt, tree orig, int ignored) /* Convert sprintf (str, fmt) into strcpy (str, fmt) when 'format' is known to contain no % formats. */ - call = build_call_expr (fn, 2, dest, fmt); + call = build_call_expr_loc (loc, fn, 2, dest, fmt); if (!ignored) retval = build_int_cst (NULL_TREE, strlen (fmt_str)); } @@ -12068,13 +12164,13 @@ fold_builtin_sprintf (tree dest, tree fmt, tree orig, int ignored) if (!retval || TREE_CODE (retval) != INTEGER_CST) return NULL_TREE; } - call = build_call_expr (fn, 2, dest, orig); + call = build_call_expr_loc (loc, fn, 2, dest, orig); } if (call && retval) { - retval = fold_convert - (TREE_TYPE (TREE_TYPE (implicit_built_in_decls[BUILT_IN_SPRINTF])), + retval = fold_convert_loc + (loc, TREE_TYPE (TREE_TYPE (implicit_built_in_decls[BUILT_IN_SPRINTF])), retval); return build2 (COMPOUND_EXPR, TREE_TYPE (retval), call, retval); } @@ -12465,7 +12561,7 @@ fold_builtin_object_size (tree ptr, tree ost) passed as third argument. */ tree -fold_builtin_memory_chk (tree fndecl, +fold_builtin_memory_chk (location_t loc, tree fndecl, tree dest, tree src, tree len, tree size, tree maxlen, bool ignore, enum built_in_function fcode) @@ -12485,11 +12581,13 @@ fold_builtin_memory_chk (tree fndecl, if (fcode != BUILT_IN_MEMSET_CHK && operand_equal_p (src, dest, 0)) { if (fcode != BUILT_IN_MEMPCPY_CHK) - return omit_one_operand (TREE_TYPE (TREE_TYPE (fndecl)), dest, len); + return omit_one_operand_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), + dest, len); else { - tree temp = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dest), dest, len); - return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), temp); + tree temp = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (dest), + dest, len); + return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), temp); } } @@ -12513,7 +12611,7 @@ fold_builtin_memory_chk (tree fndecl, if (!fn) return NULL_TREE; - return build_call_expr (fn, 4, dest, src, len, size); + return build_call_expr_loc (loc, fn, 4, dest, src, len, size); } return NULL_TREE; } @@ -12549,7 +12647,7 @@ fold_builtin_memory_chk (tree fndecl, if (!fn) return NULL_TREE; - return build_call_expr (fn, 3, dest, src, len); + return build_call_expr_loc (loc, fn, 3, dest, src, len); } /* Fold a call to the __st[rp]cpy_chk builtin. @@ -12559,7 +12657,8 @@ fold_builtin_memory_chk (tree fndecl, strings passed as second argument. */ tree -fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size, +fold_builtin_stxcpy_chk (location_t loc, tree fndecl, tree dest, + tree src, tree size, tree maxlen, bool ignore, enum built_in_function fcode) { @@ -12572,7 +12671,7 @@ fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size, /* If SRC and DEST are the same (and not volatile), return DEST. */ if (fcode == BUILT_IN_STRCPY_CHK && operand_equal_p (src, dest, 0)) - return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), dest); + return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest); if (! host_integerp (size, 1)) return NULL_TREE; @@ -12598,7 +12697,7 @@ fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size, if (!fn) return NULL_TREE; - return build_call_expr (fn, 3, dest, src, size); + return build_call_expr_loc (loc, fn, 3, dest, src, size); } if (! len || TREE_SIDE_EFFECTS (len)) @@ -12610,10 +12709,10 @@ fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size, if (!fn) return NULL_TREE; - len = size_binop (PLUS_EXPR, len, ssize_int (1)); - return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), - build_call_expr (fn, 4, - dest, src, len, size)); + len = size_binop_loc (loc, PLUS_EXPR, len, ssize_int (1)); + return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), + build_call_expr_loc (loc, fn, 4, + dest, src, len, size)); } } else @@ -12629,7 +12728,7 @@ fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size, if (!fn) return NULL_TREE; - return build_call_expr (fn, 2, dest, src); + return build_call_expr_loc (loc, fn, 2, dest, src); } /* Fold a call to the __strncpy_chk builtin. DEST, SRC, LEN, and SIZE @@ -12637,8 +12736,8 @@ fold_builtin_stxcpy_chk (tree fndecl, tree dest, tree src, tree size, length passed as third argument. */ tree -fold_builtin_strncpy_chk (tree dest, tree src, tree len, tree size, - tree maxlen) +fold_builtin_strncpy_chk (location_t loc, tree dest, tree src, + tree len, tree size, tree maxlen) { tree fn; @@ -12673,14 +12772,15 @@ fold_builtin_strncpy_chk (tree dest, tree src, tree len, tree size, if (!fn) return NULL_TREE; - return build_call_expr (fn, 3, dest, src, len); + return build_call_expr_loc (loc, fn, 3, dest, src, len); } /* Fold a call to the __strcat_chk builtin FNDECL. DEST, SRC, and SIZE are the arguments to the call. */ static tree -fold_builtin_strcat_chk (tree fndecl, tree dest, tree src, tree size) +fold_builtin_strcat_chk (location_t loc, tree fndecl, tree dest, + tree src, tree size) { tree fn; const char *p; @@ -12693,7 +12793,7 @@ fold_builtin_strcat_chk (tree fndecl, tree dest, tree src, tree size) p = c_getstr (src); /* If the SRC parameter is "", return DEST. */ if (p && *p == '\0') - return omit_one_operand (TREE_TYPE (TREE_TYPE (fndecl)), dest, src); + return omit_one_operand_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest, src); if (! host_integerp (size, 1) || ! integer_all_onesp (size)) return NULL_TREE; @@ -12703,14 +12803,14 @@ fold_builtin_strcat_chk (tree fndecl, tree dest, tree src, tree size) if (!fn) return NULL_TREE; - return build_call_expr (fn, 2, dest, src); + return build_call_expr_loc (loc, fn, 2, dest, src); } /* Fold a call to the __strncat_chk builtin with arguments DEST, SRC, LEN, and SIZE. */ static tree -fold_builtin_strncat_chk (tree fndecl, +fold_builtin_strncat_chk (location_t loc, tree fndecl, tree dest, tree src, tree len, tree size) { tree fn; @@ -12725,9 +12825,9 @@ fold_builtin_strncat_chk (tree fndecl, p = c_getstr (src); /* If the SRC parameter is "" or if LEN is 0, return DEST. */ if (p && *p == '\0') - return omit_one_operand (TREE_TYPE (TREE_TYPE (fndecl)), dest, len); + return omit_one_operand_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest, len); else if (integer_zerop (len)) - return omit_one_operand (TREE_TYPE (TREE_TYPE (fndecl)), dest, src); + return omit_one_operand_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), dest, src); if (! host_integerp (size, 1)) return NULL_TREE; @@ -12745,7 +12845,7 @@ fold_builtin_strncat_chk (tree fndecl, if (!fn) return NULL_TREE; - return build_call_expr (fn, 3, dest, src, size); + return build_call_expr_loc (loc, fn, 3, dest, src, size); } return NULL_TREE; } @@ -12755,7 +12855,7 @@ fold_builtin_strncat_chk (tree fndecl, if (!fn) return NULL_TREE; - return build_call_expr (fn, 3, dest, src, len); + return build_call_expr_loc (loc, fn, 3, dest, src, len); } /* Fold a call EXP to __{,v}sprintf_chk. Return NULL_TREE if @@ -12763,7 +12863,8 @@ fold_builtin_strncat_chk (tree fndecl, inline. FCODE is either BUILT_IN_SPRINTF_CHK or BUILT_IN_VSPRINTF_CHK. */ static tree -fold_builtin_sprintf_chk (tree exp, enum built_in_function fcode) +fold_builtin_sprintf_chk (location_t loc, tree exp, + enum built_in_function fcode) { tree dest, size, len, fn, fmt, flag; const char *fmt_str; @@ -12846,7 +12947,7 @@ fold_builtin_sprintf_chk (tree exp, enum built_in_function fcode) if (!fn) return NULL_TREE; - return rewrite_call_expr (exp, 4, fn, 2, dest, fmt); + return rewrite_call_expr (loc, exp, 4, fn, 2, dest, fmt); } /* Fold a call EXP to {,v}snprintf. Return NULL_TREE if @@ -12856,7 +12957,7 @@ fold_builtin_sprintf_chk (tree exp, enum built_in_function fcode) passed as second argument. */ tree -fold_builtin_snprintf_chk (tree exp, tree maxlen, +fold_builtin_snprintf_chk (location_t loc, tree exp, tree maxlen, enum built_in_function fcode) { tree dest, size, len, fn, fmt, flag; @@ -12923,7 +13024,7 @@ fold_builtin_snprintf_chk (tree exp, tree maxlen, if (!fn) return NULL_TREE; - return rewrite_call_expr (exp, 5, fn, 3, dest, len, fmt); + return rewrite_call_expr (loc, exp, 5, fn, 3, dest, len, fmt); } /* Fold a call to the {,v}printf{,_unlocked} and __{,v}printf_chk builtins. @@ -12935,7 +13036,8 @@ fold_builtin_snprintf_chk (tree exp, tree maxlen, code of the function to be simplified. */ static tree -fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore, +fold_builtin_printf (location_t loc, tree fndecl, tree fmt, + tree arg, bool ignore, enum built_in_function fcode) { tree fn_putchar, fn_puts, newarg, call = NULL_TREE; @@ -13008,7 +13110,7 @@ fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore, function. */ newarg = build_int_cst (NULL_TREE, str[0]); if (fn_putchar) - call = build_call_expr (fn_putchar, 1, newarg); + call = build_call_expr_loc (loc, fn_putchar, 1, newarg); } else { @@ -13024,7 +13126,7 @@ fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore, newarg = build_string_literal (len, newstr); if (fn_puts) - call = build_call_expr (fn_puts, 1, newarg); + call = build_call_expr_loc (loc, fn_puts, 1, newarg); } else /* We'd like to arrange to call fputs(string,stdout) here, @@ -13043,7 +13145,7 @@ fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore, if (!arg || !validate_arg (arg, POINTER_TYPE)) return NULL_TREE; if (fn_puts) - call = build_call_expr (fn_puts, 1, arg); + call = build_call_expr_loc (loc, fn_puts, 1, arg); } /* If the format specifier was "%c", call __builtin_putchar(arg). */ @@ -13052,13 +13154,13 @@ fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore, if (!arg || !validate_arg (arg, INTEGER_TYPE)) return NULL_TREE; if (fn_putchar) - call = build_call_expr (fn_putchar, 1, arg); + call = build_call_expr_loc (loc, fn_putchar, 1, arg); } if (!call) return NULL_TREE; - return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), call); + return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), call); } /* Fold a call to the {,v}fprintf{,_unlocked} and __{,v}printf_chk builtins. @@ -13070,7 +13172,8 @@ fold_builtin_printf (tree fndecl, tree fmt, tree arg, bool ignore, code of the function to be simplified. */ static tree -fold_builtin_fprintf (tree fndecl, tree fp, tree fmt, tree arg, bool ignore, +fold_builtin_fprintf (location_t loc, tree fndecl, tree fp, + tree fmt, tree arg, bool ignore, enum built_in_function fcode) { tree fn_fputc, fn_fputs, call = NULL_TREE; @@ -13129,7 +13232,7 @@ fold_builtin_fprintf (tree fndecl, tree fp, tree fmt, tree arg, bool ignore, fprintf (fp, string) with fputs (string, fp). The fputs builtin will take care of special cases like length == 1. */ if (fn_fputs) - call = build_call_expr (fn_fputs, 2, fmt, fp); + call = build_call_expr_loc (loc, fn_fputs, 2, fmt, fp); } /* The other optimizations can be done only on the non-va_list variants. */ @@ -13142,7 +13245,7 @@ fold_builtin_fprintf (tree fndecl, tree fp, tree fmt, tree arg, bool ignore, if (!arg || !validate_arg (arg, POINTER_TYPE)) return NULL_TREE; if (fn_fputs) - call = build_call_expr (fn_fputs, 2, arg, fp); + call = build_call_expr_loc (loc, fn_fputs, 2, arg, fp); } /* If the format specifier was "%c", call __builtin_fputc (arg, fp). */ @@ -13151,12 +13254,12 @@ fold_builtin_fprintf (tree fndecl, tree fp, tree fmt, tree arg, bool ignore, if (!arg || !validate_arg (arg, INTEGER_TYPE)) return NULL_TREE; if (fn_fputc) - call = build_call_expr (fn_fputc, 2, arg, fp); + call = build_call_expr_loc (loc, fn_fputc, 2, arg, fp); } if (!call) return NULL_TREE; - return fold_convert (TREE_TYPE (TREE_TYPE (fndecl)), call); + return fold_convert_loc (loc, TREE_TYPE (TREE_TYPE (fndecl)), call); } /* Initialize format string characters in the target charset. */ @@ -13715,6 +13818,64 @@ do_mpc_arg1 (tree arg, tree type, int (*func)(mpc_ptr, mpc_srcptr, mpc_rnd_t)) return result; } + +/* If arguments ARG0 and ARG1 are a COMPLEX_CST, call the two-argument + mpc function FUNC on it and return the resulting value as a tree + with type TYPE. The mpfr precision is set to the precision of + TYPE. We assume that function FUNC returns zero if the result + could be calculated exactly within the requested precision. */ + +#ifdef HAVE_mpc_pow +static tree +do_mpc_arg2 (tree arg0, tree arg1, tree type, + int (*func)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t)) +{ + tree result = NULL_TREE; + + STRIP_NOPS (arg0); + STRIP_NOPS (arg1); + + /* To proceed, MPFR must exactly represent the target floating point + format, which only happens when the target base equals two. */ + if (TREE_CODE (arg0) == COMPLEX_CST && !TREE_OVERFLOW (arg0) + && TREE_CODE (TREE_TYPE (TREE_TYPE (arg0))) == REAL_TYPE + && TREE_CODE (arg1) == COMPLEX_CST && !TREE_OVERFLOW (arg1) + && TREE_CODE (TREE_TYPE (TREE_TYPE (arg1))) == REAL_TYPE + && REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (TREE_TYPE (arg0))))->b == 2) + { + const REAL_VALUE_TYPE *const re0 = TREE_REAL_CST_PTR (TREE_REALPART (arg0)); + const REAL_VALUE_TYPE *const im0 = TREE_REAL_CST_PTR (TREE_IMAGPART (arg0)); + const REAL_VALUE_TYPE *const re1 = TREE_REAL_CST_PTR (TREE_REALPART (arg1)); + const REAL_VALUE_TYPE *const im1 = TREE_REAL_CST_PTR (TREE_IMAGPART (arg1)); + + if (real_isfinite (re0) && real_isfinite (im0) + && real_isfinite (re1) && real_isfinite (im1)) + { + const struct real_format *const fmt = + REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (type))); + const int prec = fmt->p; + const mp_rnd_t rnd = fmt->round_towards_zero ? GMP_RNDZ : GMP_RNDN; + const mpc_rnd_t crnd = fmt->round_towards_zero ? MPC_RNDZZ : MPC_RNDNN; + int inexact; + mpc_t m0, m1; + + mpc_init2 (m0, prec); + mpc_init2 (m1, prec); + mpfr_from_real (mpc_realref(m0), re0, rnd); + mpfr_from_real (mpc_imagref(m0), im0, rnd); + mpfr_from_real (mpc_realref(m1), re1, rnd); + mpfr_from_real (mpc_imagref(m1), im1, rnd); + mpfr_clear_flags (); + inexact = func (m0, m0, m1, crnd); + result = do_mpc_ckconv (m0, type, inexact); + mpc_clear (m0); + mpc_clear (m1); + } + } + + return result; +} +# endif #endif /* HAVE_mpc */ /* FIXME tuples. @@ -13741,6 +13902,7 @@ gimple_rewrite_call_expr (gimple stmt, int skip, tree fndecl, int n, ...) tree *buffer; int i, j; va_list ap; + location_t loc = gimple_location (stmt); buffer = XALLOCAVEC (tree, nargs); va_start (ap, n); @@ -13750,7 +13912,7 @@ gimple_rewrite_call_expr (gimple stmt, int skip, tree fndecl, int n, ...) for (j = skip; j < oldnargs; j++, i++) buffer[i] = gimple_call_arg (stmt, j); - return fold (build_call_array (TREE_TYPE (fntype), fn, nargs, buffer)); + return fold (build_call_array_loc (loc, TREE_TYPE (fntype), fn, nargs, buffer)); } /* Fold a call STMT to __{,v}sprintf_chk. Return NULL_TREE if @@ -13929,7 +14091,8 @@ gimple_fold_builtin_snprintf_chk (gimple stmt, tree maxlen, result of the function call is ignored. */ static tree -gimple_fold_builtin_varargs (tree fndecl, gimple stmt, bool ignore ATTRIBUTE_UNUSED) +gimple_fold_builtin_varargs (tree fndecl, gimple stmt, + bool ignore ATTRIBUTE_UNUSED) { enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); tree ret = NULL_TREE; @@ -13966,6 +14129,7 @@ fold_call_stmt (gimple stmt, bool ignore) { tree ret = NULL_TREE; tree fndecl = gimple_call_fndecl (stmt); + location_t loc = gimple_location (stmt); if (fndecl && TREE_CODE (fndecl) == FUNCTION_DECL && DECL_BUILT_IN (fndecl) @@ -13992,7 +14156,7 @@ fold_call_stmt (gimple stmt, bool ignore) int i; for (i = 0; i < nargs; i++) args[i] = gimple_call_arg (stmt, i); - ret = fold_builtin_n (fndecl, args, nargs, ignore); + ret = fold_builtin_n (loc, fndecl, args, nargs, ignore); } if (!ret) ret = gimple_fold_builtin_varargs (fndecl, stmt, ignore); @@ -14009,7 +14173,7 @@ fold_call_stmt (gimple stmt, bool ignore) realret = TREE_OPERAND (ret, 0); if (CAN_HAVE_LOCATION_P (realret) && !EXPR_HAS_LOCATION (realret)) - SET_EXPR_LOCATION (realret, gimple_location (stmt)); + SET_EXPR_LOCATION (realret, loc); return realret; } return ret; diff --git a/gcc/c-common.c b/gcc/c-common.c index 20dac6b2ef4..328e0fdae8e 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -598,6 +598,8 @@ const struct c_common_resword c_common_reswords[] = { "__is_enum", RID_IS_ENUM, D_CXXONLY }, { "__is_pod", RID_IS_POD, D_CXXONLY }, { "__is_polymorphic", RID_IS_POLYMORPHIC, D_CXXONLY }, + { "__is_standard_layout", RID_IS_STD_LAYOUT, D_CXXONLY }, + { "__is_trivial", RID_IS_TRIVIAL, D_CXXONLY }, { "__is_union", RID_IS_UNION, D_CXXONLY }, { "__imag", RID_IMAGPART, 0 }, { "__imag__", RID_IMAGPART, 0 }, @@ -1084,6 +1086,7 @@ c_fully_fold (tree expr, bool in_init, bool *maybe_const) tree eptype = NULL_TREE; bool dummy = true; bool maybe_const_itself = true; + location_t loc = EXPR_LOCATION (expr); /* This function is not relevant to C++ because C++ folds while parsing, and may need changes to be correct for C++ when C++ @@ -1101,7 +1104,7 @@ c_fully_fold (tree expr, bool in_init, bool *maybe_const) ret = c_fully_fold_internal (expr, in_init, maybe_const, &maybe_const_itself); if (eptype) - ret = fold_convert (eptype, ret); + ret = fold_convert_loc (loc, eptype, ret); *maybe_const &= maybe_const_itself; return ret; } @@ -1298,8 +1301,8 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, op1 = decl_constant_value_for_optimization (op1); if (op0 != orig_op0 || op1 != orig_op1 || in_init) ret = in_init - ? fold_build2_initializer (code, TREE_TYPE (expr), op0, op1) - : fold_build2 (code, TREE_TYPE (expr), op0, op1); + ? fold_build2_initializer_loc (loc, code, TREE_TYPE (expr), op0, op1) + : fold_build2_loc (loc, code, TREE_TYPE (expr), op0, op1); else ret = fold (expr); goto out; @@ -1324,8 +1327,8 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, op0 = decl_constant_value_for_optimization (op0); if (op0 != orig_op0 || in_init) ret = in_init - ? fold_build1_initializer (code, TREE_TYPE (expr), op0) - : fold_build1 (code, TREE_TYPE (expr), op0); + ? fold_build1_initializer_loc (loc, code, TREE_TYPE (expr), op0) + : fold_build1_loc (loc, code, TREE_TYPE (expr), op0); else ret = fold (expr); if (code == INDIRECT_REF @@ -1348,8 +1351,8 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, op1 = c_fully_fold_internal (op1, in_init, &op1_const, &op1_const_self); if (op0 != orig_op0 || op1 != orig_op1 || in_init) ret = in_init - ? fold_build2_initializer (code, TREE_TYPE (expr), op0, op1) - : fold_build2 (code, TREE_TYPE (expr), op0, op1); + ? fold_build2_initializer_loc (loc, code, TREE_TYPE (expr), op0, op1) + : fold_build2_loc (loc, code, TREE_TYPE (expr), op0, op1); else ret = fold (expr); *maybe_const_operands &= op0_const; @@ -1377,7 +1380,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, op1 = c_fully_fold_internal (op1, in_init, &op1_const, &op1_const_self); op2 = c_fully_fold_internal (op2, in_init, &op2_const, &op2_const_self); if (op0 != orig_op0 || op1 != orig_op1 || op2 != orig_op2) - ret = fold_build3 (code, TREE_TYPE (expr), op0, op1, op2); + ret = fold_build3_loc (loc, code, TREE_TYPE (expr), op0, op1, op2); else ret = fold (expr); *maybe_const_operands &= op0_const; @@ -1618,7 +1621,8 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, if (lhs && rhs && operand_equal_p (lhs, rhs, 0) && merge_ranges (&in_p, &low, &high, in0_p, low0, high0, in1_p, low1, high1) - && 0 != (tem = build_range_check (type, lhs, in_p, low, high))) + && 0 != (tem = build_range_check (UNKNOWN_LOCATION, + type, lhs, in_p, low, high))) { if (TREE_CODE (tem) != INTEGER_CST) return; @@ -3656,7 +3660,8 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, of pointer PTROP and integer INTOP. */ tree -pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) +pointer_int_sum (location_t loc, enum tree_code resultcode, + tree ptrop, tree intop) { tree size_exp, ret; @@ -3665,19 +3670,19 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE) { - pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith, "pointer of type %<void *%> used in arithmetic"); size_exp = integer_one_node; } else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE) { - pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith, "pointer to a function used in arithmetic"); size_exp = integer_one_node; } else if (TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE) { - pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith, "pointer to member function used in arithmetic"); size_exp = integer_one_node; } @@ -3732,15 +3737,15 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) Do this multiplication as signed, then convert to the appropriate type for the pointer operation. */ intop = convert (sizetype, - build_binary_op (EXPR_LOCATION (intop), + build_binary_op (loc, MULT_EXPR, intop, convert (TREE_TYPE (intop), size_exp), 1)); /* Create the sum or difference. */ if (resultcode == MINUS_EXPR) - intop = fold_build1 (NEGATE_EXPR, sizetype, intop); + intop = fold_build1_loc (loc, NEGATE_EXPR, sizetype, intop); - ret = fold_build2 (POINTER_PLUS_EXPR, result_type, ptrop, intop); + ret = fold_build2_loc (loc, POINTER_PLUS_EXPR, result_type, ptrop, intop); fold_undefer_and_ignore_overflow_warnings (); @@ -3923,7 +3928,7 @@ c_common_truthvalue_conversion (location_t location, tree expr) /* Distribute the conversion into the arms of a COND_EXPR. */ if (c_dialect_cxx ()) { - expr = fold_build3 (COND_EXPR, truthvalue_type_node, + expr = fold_build3_loc (location, COND_EXPR, truthvalue_type_node, TREE_OPERAND (expr, 0), c_common_truthvalue_conversion (location, TREE_OPERAND (expr, @@ -4288,9 +4293,9 @@ c_sizeof_or_alignof_type (location_t loc, { if (is_sizeof) /* Convert in case a char is more than one unit. */ - value = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type), - size_int (TYPE_PRECISION (char_type_node) - / BITS_PER_UNIT)); + value = size_binop_loc (loc, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type), + size_int (TYPE_PRECISION (char_type_node) + / BITS_PER_UNIT)); else value = size_int (TYPE_ALIGN_UNIT (type)); } @@ -4299,7 +4304,7 @@ c_sizeof_or_alignof_type (location_t loc, TYPE_IS_SIZETYPE means that certain things (like overflow) will never happen. However, this node should really have type `size_t', which is just a typedef for an ordinary integer type. */ - value = fold_convert (size_type_node, value); + value = fold_convert_loc (loc, size_type_node, value); gcc_assert (!TYPE_IS_SIZETYPE (TREE_TYPE (value))); return value; @@ -4350,7 +4355,7 @@ c_alignof_expr (location_t loc, tree expr) else return c_alignof (loc, TREE_TYPE (expr)); - return fold_convert (size_type_node, t); + return fold_convert_loc (loc, size_type_node, t); } /* Handle C and C++ default attributes. */ @@ -5626,11 +5631,11 @@ boolean_increment (enum tree_code code, tree arg) break; case PREDECREMENT_EXPR: val = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg, - invert_truthvalue (arg)); + invert_truthvalue_loc (input_location, arg)); break; case POSTDECREMENT_EXPR: val = build2 (MODIFY_EXPR, TREE_TYPE (arg), arg, - invert_truthvalue (arg)); + invert_truthvalue_loc (input_location, arg)); arg = save_expr (arg); val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), val, arg); val = build2 (COMPOUND_EXPR, TREE_TYPE (arg), arg, val); @@ -8221,69 +8226,6 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, return ret; } -/* Walk a gimplified function and warn for functions whose return value is - ignored and attribute((warn_unused_result)) is set. This is done before - inlining, so we don't have to worry about that. */ - -void -c_warn_unused_result (gimple_seq seq) -{ - tree fdecl, ftype; - gimple_stmt_iterator i; - - for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i)) - { - gimple g = gsi_stmt (i); - - switch (gimple_code (g)) - { - case GIMPLE_BIND: - c_warn_unused_result (gimple_bind_body (g)); - break; - case GIMPLE_TRY: - c_warn_unused_result (gimple_try_eval (g)); - c_warn_unused_result (gimple_try_cleanup (g)); - break; - case GIMPLE_CATCH: - c_warn_unused_result (gimple_catch_handler (g)); - break; - case GIMPLE_EH_FILTER: - c_warn_unused_result (gimple_eh_filter_failure (g)); - break; - - case GIMPLE_CALL: - if (gimple_call_lhs (g)) - break; - - /* This is a naked call, as opposed to a GIMPLE_CALL with an - LHS. All calls whose value is ignored should be - represented like this. Look for the attribute. */ - fdecl = gimple_call_fndecl (g); - ftype = TREE_TYPE (TREE_TYPE (gimple_call_fn (g))); - - if (lookup_attribute ("warn_unused_result", TYPE_ATTRIBUTES (ftype))) - { - location_t loc = gimple_location (g); - - if (fdecl) - warning_at (loc, OPT_Wunused_result, - "ignoring return value of %qD, " - "declared with attribute warn_unused_result", - fdecl); - else - warning_at (loc, OPT_Wunused_result, - "ignoring return value of function " - "declared with attribute warn_unused_result"); - } - break; - - default: - /* Not a container, not a call, or a call whose value is used. */ - break; - } - } -} - /* Convert a character from the host to the target execution character set. cpplib handles this, mostly. */ @@ -8355,9 +8297,10 @@ fold_offsetof_1 (tree expr, tree stop_ref) "member %qD", t); return error_mark_node; } - off = size_binop (PLUS_EXPR, DECL_FIELD_OFFSET (t), - size_int (tree_low_cst (DECL_FIELD_BIT_OFFSET (t), 1) - / BITS_PER_UNIT)); + off = size_binop_loc (input_location, PLUS_EXPR, DECL_FIELD_OFFSET (t), + size_int (tree_low_cst (DECL_FIELD_BIT_OFFSET (t), + 1) + / BITS_PER_UNIT)); break; case ARRAY_REF: @@ -8369,7 +8312,7 @@ fold_offsetof_1 (tree expr, tree stop_ref) if (TREE_CODE (t) == INTEGER_CST && tree_int_cst_sgn (t) < 0) { code = MINUS_EXPR; - t = fold_build1 (NEGATE_EXPR, TREE_TYPE (t), t); + t = fold_build1_loc (input_location, NEGATE_EXPR, TREE_TYPE (t), t); } t = convert (sizetype, t); off = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (TREE_TYPE (expr)), t); @@ -8462,9 +8405,9 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) bool fold_p = false; if (VEC_index (constructor_elt, v, 0)->index) - maxindex = fold_convert (sizetype, - VEC_index (constructor_elt, - v, 0)->index); + maxindex = fold_convert_loc (input_location, sizetype, + VEC_index (constructor_elt, + v, 0)->index); curindex = maxindex; for (cnt = 1; @@ -8478,7 +8421,8 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) { if (fold_p) curindex = fold_convert (sizetype, curindex); - curindex = size_binop (PLUS_EXPR, curindex, size_one_node); + curindex = size_binop (PLUS_EXPR, curindex, + size_one_node); } if (tree_int_cst_lt (maxindex, curindex)) maxindex = curindex, fold_p = curfold_p; diff --git a/gcc/c-common.h b/gcc/c-common.h index 04a194597f7..d372e70631e 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -110,6 +110,7 @@ enum rid RID_IS_CONVERTIBLE_TO, RID_IS_CLASS, RID_IS_EMPTY, RID_IS_ENUM, RID_IS_POD, RID_IS_POLYMORPHIC, + RID_IS_STD_LAYOUT, RID_IS_TRIVIAL, RID_IS_UNION, /* C++0x */ @@ -829,7 +830,7 @@ extern tree shorten_binary_op (tree result_type, tree op0, tree op1, bool bitwis and, if so, perhaps change them both back to their original type. */ extern tree shorten_compare (tree *, tree *, tree *, enum tree_code *); -extern tree pointer_int_sum (enum tree_code, tree, tree); +extern tree pointer_int_sum (location_t, enum tree_code, tree, tree); /* Add qualifiers to a type, in the fashion for C. */ extern tree c_build_qualified_type (tree, int); @@ -981,8 +982,6 @@ extern void dump_time_statistics (void); extern bool c_dump_tree (void *, tree); -extern void c_warn_unused_result (gimple_seq); - extern void verify_sequence_points (tree); extern tree fold_offsetof (tree, tree); diff --git a/gcc/c-convert.c b/gcc/c-convert.c index 5349d7a77e8..09638d5b151 100644 --- a/gcc/c-convert.c +++ b/gcc/c-convert.c @@ -71,6 +71,7 @@ convert (tree type, tree expr) enum tree_code code = TREE_CODE (type); const char *invalid_conv_diag; tree ret; + location_t loc = EXPR_LOCATION (expr); if (type == error_mark_node || expr == error_mark_node @@ -93,7 +94,7 @@ convert (tree type, tree expr) STRIP_TYPE_NOPS (e); if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr))) - return fold_convert (type, expr); + return fold_convert_loc (loc, type, expr); if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK) return error_mark_node; if (TREE_CODE (TREE_TYPE (expr)) == VOID_TYPE) @@ -105,7 +106,7 @@ convert (tree type, tree expr) switch (code) { case VOID_TYPE: - return fold_convert (type, e); + return fold_convert_loc (loc, type, e); case INTEGER_TYPE: case ENUMERAL_TYPE: @@ -113,8 +114,8 @@ convert (tree type, tree expr) goto maybe_fold; case BOOLEAN_TYPE: - return fold_convert - (type, c_objc_common_truthvalue_conversion (input_location, expr)); + return fold_convert_loc + (loc, type, c_objc_common_truthvalue_conversion (input_location, expr)); case POINTER_TYPE: case REFERENCE_TYPE: diff --git a/gcc/c-decl.c b/gcc/c-decl.c index fa578cb6529..b594767d04c 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1327,7 +1327,6 @@ pop_file_scope (void) file_scope = 0; maybe_apply_pending_pragma_weaks (); - cgraph_finalize_compilation_unit (); } /* Adjust the bindings for the start of a statement expression. */ @@ -5224,10 +5223,10 @@ grokdeclarator (const struct c_declarator *declarator, - 1. Do the calculation in index_type, so that if it is a variable the computations will be done in the proper mode. */ - itype = fold_build2 (MINUS_EXPR, index_type, - convert (index_type, size), - convert (index_type, - size_one_node)); + itype = fold_build2_loc (loc, MINUS_EXPR, index_type, + convert (index_type, size), + convert (index_type, + size_one_node)); /* If that overflowed, the array is too big. ??? While a size of INT_MAX+1 technically shouldn't @@ -7870,27 +7869,6 @@ store_parm_decls (void) cfun->dont_save_pending_sizes_p = 1; } -/* Emit diagnostics that require gimple input for detection. Operate on - FNDECL and all its nested functions. */ - -static void -c_gimple_diagnostics_recursively (tree fndecl) -{ - struct cgraph_node *cgn; - gimple_seq body = gimple_body (fndecl); - - /* Handle attribute((warn_unused_result)). Relies on gimple input. */ - c_warn_unused_result (body); - - /* Notice when OpenMP structured block constraints are violated. */ - if (flag_openmp) - diagnose_omp_structured_block_errors (fndecl); - - /* Finalize all nested functions now. */ - cgn = cgraph_node (fndecl); - for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested) - c_gimple_diagnostics_recursively (cgn->decl); -} /* Finish up a function declaration and compile that function all the way to assembler language output. The free the storage @@ -7983,7 +7961,6 @@ finish_function (void) if (!decl_function_context (fndecl)) { c_genericize (fndecl); - c_gimple_diagnostics_recursively (fndecl); /* ??? Objc emits functions after finalizing the compilation unit. This should be cleaned up later and this conditional removed. */ @@ -9382,9 +9359,9 @@ c_write_global_declarations (void) if (pch_file) return; - /* Don't waste time on further processing if -fsyntax-only or we've - encountered errors. */ - if (flag_syntax_only || errorcount || sorrycount) + /* Don't waste time on further processing if -fsyntax-only. + Continue for warning and errors issued during lowering though. */ + if (flag_syntax_only) return; /* Close the external scope. */ @@ -9412,7 +9389,7 @@ c_write_global_declarations (void) /* We're done parsing; proceed to optimize and emit assembly. FIXME: shouldn't be the front end's responsibility to call this. */ - cgraph_optimize (); + cgraph_finalize_compilation_unit (); /* After cgraph has had a chance to emit everything that's going to be emitted, output debug information for globals. */ diff --git a/gcc/c-gimplify.c b/gcc/c-gimplify.c index 6595fc8fa03..e50050c2324 100644 --- a/gcc/c-gimplify.c +++ b/gcc/c-gimplify.c @@ -103,14 +103,7 @@ c_genericize (tree fndecl) dump_end (TDI_original, dump_orig); } - /* Go ahead and gimplify for now. */ - gimplify_function_tree (fndecl); - - dump_function (TDI_generic, fndecl); - - /* Genericize all nested functions now. We do things in this order so - that items like VLA sizes are expanded properly in the context of - the correct function. */ + /* Dump all nested functions now. */ cgn = cgraph_node (fndecl); for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested) c_genericize (cgn->decl); diff --git a/gcc/c-omp.c b/gcc/c-omp.c index 5ec9f94ff68..6445e5d42ee 100644 --- a/gcc/c-omp.c +++ b/gcc/c-omp.c @@ -81,8 +81,7 @@ c_finish_omp_barrier (location_t loc) tree x; x = built_in_decls[BUILT_IN_GOMP_BARRIER]; - x = build_call_expr (x, 0); - SET_EXPR_LOCATION (x, loc); + x = build_call_expr_loc (loc, x, 0); add_stmt (x); } @@ -96,8 +95,7 @@ c_finish_omp_taskwait (location_t loc) tree x; x = built_in_decls[BUILT_IN_GOMP_TASKWAIT]; - x = build_call_expr (x, 0); - SET_EXPR_LOCATION (x, loc); + x = build_call_expr_loc (loc, x, 0); add_stmt (x); } @@ -144,6 +142,7 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, tree lhs, tree rhs) /* Make sure LHS is simple enough so that goa_lhs_expr_p can recognize it even after unsharing function body. */ tree var = create_tmp_var_raw (TREE_TYPE (addr), NULL); + DECL_CONTEXT (var) = current_function_decl; addr = build4 (TARGET_EXPR, TREE_TYPE (addr), var, addr, NULL, NULL); } lhs = build_indirect_ref (loc, addr, NULL); @@ -175,8 +174,7 @@ c_finish_omp_flush (location_t loc) tree x; x = built_in_decls[BUILT_IN_SYNCHRONIZE]; - x = build_call_expr (x, 0); - SET_EXPR_LOCATION (x, loc); + x = build_call_expr_loc (loc, x, 0); add_stmt (x); } @@ -185,7 +183,7 @@ c_finish_omp_flush (location_t loc) Helper function for c_finish_omp_for. */ static tree -check_omp_for_incr_expr (tree exp, tree decl) +check_omp_for_incr_expr (location_t loc, tree exp, tree decl) { tree t; @@ -199,22 +197,25 @@ check_omp_for_incr_expr (tree exp, tree decl) switch (TREE_CODE (exp)) { CASE_CONVERT: - t = check_omp_for_incr_expr (TREE_OPERAND (exp, 0), decl); + t = check_omp_for_incr_expr (loc, TREE_OPERAND (exp, 0), decl); if (t != error_mark_node) - return fold_convert (TREE_TYPE (exp), t); + return fold_convert_loc (loc, TREE_TYPE (exp), t); break; case MINUS_EXPR: - t = check_omp_for_incr_expr (TREE_OPERAND (exp, 0), decl); + t = check_omp_for_incr_expr (loc, TREE_OPERAND (exp, 0), decl); if (t != error_mark_node) - return fold_build2 (MINUS_EXPR, TREE_TYPE (exp), t, TREE_OPERAND (exp, 1)); + return fold_build2_loc (loc, MINUS_EXPR, + TREE_TYPE (exp), t, TREE_OPERAND (exp, 1)); break; case PLUS_EXPR: - t = check_omp_for_incr_expr (TREE_OPERAND (exp, 0), decl); + t = check_omp_for_incr_expr (loc, TREE_OPERAND (exp, 0), decl); if (t != error_mark_node) - return fold_build2 (PLUS_EXPR, TREE_TYPE (exp), t, TREE_OPERAND (exp, 1)); - t = check_omp_for_incr_expr (TREE_OPERAND (exp, 1), decl); + return fold_build2_loc (loc, PLUS_EXPR, + TREE_TYPE (exp), t, TREE_OPERAND (exp, 1)); + t = check_omp_for_incr_expr (loc, TREE_OPERAND (exp, 1), decl); if (t != error_mark_node) - return fold_build2 (PLUS_EXPR, TREE_TYPE (exp), TREE_OPERAND (exp, 0), t); + return fold_build2_loc (loc, PLUS_EXPR, + TREE_TYPE (exp), TREE_OPERAND (exp, 0), t); break; default: break; @@ -322,7 +323,7 @@ c_finish_omp_for (location_t locus, tree declv, tree initv, tree condv, { TREE_OPERAND (cond, 0) = TREE_OPERAND (op0, 0); TREE_OPERAND (cond, 1) - = fold_build1 (NOP_EXPR, TREE_TYPE (decl), + = fold_build1_loc (elocus, NOP_EXPR, TREE_TYPE (decl), TREE_OPERAND (cond, 1)); } else if (TREE_CODE (op1) == NOP_EXPR @@ -330,7 +331,7 @@ c_finish_omp_for (location_t locus, tree declv, tree initv, tree condv, { TREE_OPERAND (cond, 1) = TREE_OPERAND (op1, 0); TREE_OPERAND (cond, 0) - = fold_build1 (NOP_EXPR, TREE_TYPE (decl), + = fold_build1_loc (elocus, NOP_EXPR, TREE_TYPE (decl), TREE_OPERAND (cond, 0)); } @@ -396,11 +397,12 @@ c_finish_omp_for (location_t locus, tree declv, tree initv, tree condv, if (POINTER_TYPE_P (TREE_TYPE (decl)) && TREE_OPERAND (incr, 1)) { - tree t = fold_convert (sizetype, TREE_OPERAND (incr, 1)); + tree t = fold_convert_loc (elocus, + sizetype, TREE_OPERAND (incr, 1)); if (TREE_CODE (incr) == POSTDECREMENT_EXPR || TREE_CODE (incr) == PREDECREMENT_EXPR) - t = fold_build1 (NEGATE_EXPR, sizetype, t); + t = fold_build1_loc (elocus, NEGATE_EXPR, sizetype, t); t = build2 (POINTER_PLUS_EXPR, TREE_TYPE (decl), decl, t); incr = build2 (MODIFY_EXPR, void_type_node, decl, t); } @@ -422,7 +424,8 @@ c_finish_omp_for (location_t locus, tree declv, tree initv, tree condv, incr_ok = true; else { - tree t = check_omp_for_incr_expr (TREE_OPERAND (incr, 1), + tree t = check_omp_for_incr_expr (elocus, + TREE_OPERAND (incr, 1), decl); if (t != error_mark_node) { diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 4574bb2e920..3b9b34bdc3f 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -232,6 +232,7 @@ c_common_init_options (unsigned int argc, const char **argv) flag_exceptions = c_dialect_cxx (); warn_pointer_arith = c_dialect_cxx (); warn_write_strings = c_dialect_cxx(); + flag_warn_unused_result = true; /* By default, C99-like requirements for complex multiply and divide. */ flag_complex_method = 2; diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 4d6e2d3060a..43b0c8ce38c 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -7338,7 +7338,7 @@ c_parser_omp_clause_num_threads (c_parser *parser, tree list) } /* Attempt to statically determine when the number isn't positive. */ - c = fold_build2 (LE_EXPR, boolean_type_node, t, + c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, t, build_int_cst (TREE_TYPE (t), 0)); if (CAN_HAVE_LOCATION_P (c)) SET_EXPR_LOCATION (c, expr_loc); diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index f7df74e9eef..42bebe3543c 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -86,7 +86,7 @@ static int type_lists_compatible_p (const_tree, const_tree, bool *); static tree lookup_field (tree, tree); static int convert_arguments (tree, VEC(tree,gc) *, VEC(tree,gc) *, tree, tree); -static tree pointer_diff (tree, tree); +static tree pointer_diff (location_t, tree, tree); static tree convert_for_assignment (location_t, tree, tree, tree, enum impl_conv, bool, tree, tree, int); static tree valid_compound_expr_initializer (tree, tree); @@ -1625,9 +1625,9 @@ c_size_in_bytes (const_tree type) } /* Convert in case a char is more than one unit. */ - return size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type), - size_int (TYPE_PRECISION (char_type_node) - / BITS_PER_UNIT)); + return size_binop_loc (input_location, CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type), + size_int (TYPE_PRECISION (char_type_node) + / BITS_PER_UNIT)); } /* Return either DECL or its known constant value (if it has one). */ @@ -2586,7 +2586,7 @@ build_function_call_vec (location_t loc, tree function, VEC(tree,gc) *params, if (VOID_TYPE_P (return_type)) { if (TYPE_QUALS (return_type) != TYPE_UNQUALIFIED) - pedwarn (input_location, 0, + pedwarn (loc, 0, "function with qualified void return type called"); return trap; } @@ -2599,7 +2599,7 @@ build_function_call_vec (location_t loc, tree function, VEC(tree,gc) *params, build_constructor (return_type, 0), false); else - rhs = fold_convert (return_type, integer_zero_node); + rhs = fold_convert_loc (loc, return_type, integer_zero_node); return require_complete_type (build2 (COMPOUND_EXPR, return_type, trap, rhs)); @@ -2623,23 +2623,24 @@ build_function_call_vec (location_t loc, tree function, VEC(tree,gc) *params, && !strncmp (IDENTIFIER_POINTER (name), "__builtin_", 10)) { if (require_constant_value) - result = fold_build_call_array_initializer (TREE_TYPE (fntype), - function, nargs, argarray); + result = + fold_build_call_array_initializer_loc (loc, TREE_TYPE (fntype), + function, nargs, argarray); else - result = fold_build_call_array (TREE_TYPE (fntype), - function, nargs, argarray); + result = fold_build_call_array_loc (loc, TREE_TYPE (fntype), + function, nargs, argarray); if (TREE_CODE (result) == NOP_EXPR && TREE_CODE (TREE_OPERAND (result, 0)) == INTEGER_CST) STRIP_TYPE_NOPS (result); } else - result = build_call_array (TREE_TYPE (fntype), - function, nargs, argarray); + result = build_call_array_loc (loc, TREE_TYPE (fntype), + function, nargs, argarray); if (VOID_TYPE_P (TREE_TYPE (result))) { if (TYPE_QUALS (TREE_TYPE (result)) != TYPE_UNQUALIFIED) - pedwarn (input_location, 0, + pedwarn (loc, 0, "function with qualified void return type called"); return result; } @@ -3058,7 +3059,7 @@ parser_build_binary_op (location_t location, enum tree_code code, The resulting tree has type int. */ static tree -pointer_diff (tree op0, tree op1) +pointer_diff (location_t loc, tree op0, tree op1) { tree restype = ptrdiff_type_node; @@ -3067,10 +3068,10 @@ pointer_diff (tree op0, tree op1) tree orig_op1 = op1; if (TREE_CODE (target_type) == VOID_TYPE) - pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith, "pointer of type %<void *%> used in subtraction"); if (TREE_CODE (target_type) == FUNCTION_TYPE) - pedwarn (input_location, pedantic ? OPT_pedantic : OPT_Wpointer_arith, + pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith, "pointer to a function used in subtraction"); /* If the conversion to ptrdiff_type does anything like widening or @@ -3122,18 +3123,19 @@ pointer_diff (tree op0, tree op1) Do not do default conversions on the minus operator in case restype is a short type. */ - op0 = build_binary_op (input_location, + op0 = build_binary_op (loc, MINUS_EXPR, convert (restype, op0), convert (restype, op1), 0); /* This generates an error if op1 is pointer to incomplete type. */ if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (orig_op1)))) - error ("arithmetic on pointer to an incomplete type"); + error_at (loc, "arithmetic on pointer to an incomplete type"); /* This generates an error if op0 is pointer to incomplete type. */ op1 = c_size_in_bytes (target_type); /* Divide by the size, in easiest possible way. */ - return fold_build2 (EXACT_DIV_EXPR, restype, op0, convert (restype, op1)); + return fold_build2_loc (loc, EXACT_DIV_EXPR, restype, + op0, convert (restype, op1)); } /* Construct and perhaps optimize a tree representation @@ -3203,7 +3205,7 @@ build_unary_op (location_t location, } else if (!noconvert) arg = default_conversion (arg); - arg = non_lvalue (arg); + arg = non_lvalue_loc (location, arg); break; case NEGATE_EXPR: @@ -3274,7 +3276,7 @@ build_unary_op (location_t location, return error_mark_node; } arg = c_objc_common_truthvalue_conversion (location, arg); - ret = invert_truthvalue (arg); + ret = invert_truthvalue_loc (location, arg); /* If the TRUTH_NOT_EXPR has been folded, reset the location. */ if (EXPR_P (ret) && EXPR_HAS_LOCATION (ret)) location = EXPR_LOCATION (ret); @@ -3284,7 +3286,8 @@ build_unary_op (location_t location, if (TREE_CODE (arg) == COMPLEX_CST) ret = TREE_REALPART (arg); else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE) - ret = fold_build1 (REALPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg); + ret = fold_build1_loc (location, + REALPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg); else ret = arg; if (eptype && TREE_CODE (eptype) == COMPLEX_TYPE) @@ -3295,9 +3298,11 @@ build_unary_op (location_t location, if (TREE_CODE (arg) == COMPLEX_CST) ret = TREE_IMAGPART (arg); else if (TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE) - ret = fold_build1 (IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg); + ret = fold_build1_loc (location, + IMAGPART_EXPR, TREE_TYPE (TREE_TYPE (arg)), arg); else - ret = omit_one_operand (TREE_TYPE (arg), integer_zero_node, arg); + ret = omit_one_operand_loc (location, TREE_TYPE (arg), + integer_zero_node, arg); if (eptype && TREE_CODE (eptype) == COMPLEX_TYPE) eptype = TREE_TYPE (eptype); goto return_build_unary_op; @@ -3405,7 +3410,7 @@ build_unary_op (location_t location, } inc = c_size_in_bytes (TREE_TYPE (argtype)); - inc = fold_convert (sizetype, inc); + inc = fold_convert_loc (location, sizetype, inc); } else if (FRACT_MODE_P (TYPE_MODE (argtype))) { @@ -3475,7 +3480,7 @@ build_unary_op (location_t location, { /* Don't let this be an lvalue. */ if (lvalue_p (TREE_OPERAND (arg, 0))) - return non_lvalue (TREE_OPERAND (arg, 0)); + return non_lvalue_loc (location, TREE_OPERAND (arg, 0)); ret = TREE_OPERAND (arg, 0); goto return_build_unary_op; } @@ -3541,10 +3546,11 @@ build_unary_op (location_t location, if (val && TREE_CODE (val) == INDIRECT_REF && TREE_CONSTANT (TREE_OPERAND (val, 0))) { - tree op0 = fold_convert (sizetype, fold_offsetof (arg, val)), op1; + tree op0 = fold_convert_loc (location, sizetype, + fold_offsetof (arg, val)), op1; - op1 = fold_convert (argtype, TREE_OPERAND (val, 0)); - ret = fold_build2 (POINTER_PLUS_EXPR, argtype, op1, op0); + op1 = fold_convert_loc (location, argtype, TREE_OPERAND (val, 0)); + ret = fold_build2_loc (location, POINTER_PLUS_EXPR, argtype, op1, op0); goto return_build_unary_op; } @@ -3561,8 +3567,8 @@ build_unary_op (location_t location, argtype = TREE_TYPE (arg); if (TREE_CODE (arg) == INTEGER_CST) ret = (require_constant_value - ? fold_build1_initializer (code, argtype, arg) - : fold_build1 (code, argtype, arg)); + ? fold_build1_initializer_loc (location, code, argtype, arg) + : fold_build1_loc (location, code, argtype, arg)); else ret = build1 (code, argtype, arg); return_build_unary_op: @@ -4048,7 +4054,7 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp, && !TREE_OVERFLOW (orig_op2))); } if (int_const || (ifexp_bcp && TREE_CODE (ifexp) == INTEGER_CST)) - ret = fold_build3 (COND_EXPR, result_type, ifexp, op1, op2); + ret = fold_build3_loc (colon_loc, COND_EXPR, result_type, ifexp, op1, op2); else { ret = build3 (COND_EXPR, result_type, ifexp, op1, op2); @@ -4402,7 +4408,7 @@ build_c_cast (location_t loc, tree type, tree expr) /* Don't let a cast be an lvalue. */ if (value == expr) - value = non_lvalue (value); + value = non_lvalue_loc (loc, value); /* Don't allow the results of casting to floating-point or complex types be confused with actual constants, or casts involving @@ -4939,7 +4945,7 @@ convert_for_assignment (location_t location, tree type, tree rhs, pedwarn (location, OPT_pedantic, "ISO C prohibits argument conversion to union type"); - rhs = fold_convert (TREE_TYPE (memb), rhs); + rhs = fold_convert_loc (location, TREE_TYPE (memb), rhs); return build_constructor_single (type, memb, rhs); } } @@ -7316,8 +7322,8 @@ output_init_element (tree value, tree origtype, bool strict_string, tree type, /* Advance the variable that indicates sequential elements output. */ if (TREE_CODE (constructor_type) == ARRAY_TYPE) constructor_unfilled_index - = size_binop (PLUS_EXPR, constructor_unfilled_index, - bitsize_one_node); + = size_binop_loc (input_location, PLUS_EXPR, constructor_unfilled_index, + bitsize_one_node); else if (TREE_CODE (constructor_type) == RECORD_TYPE) { constructor_unfilled_fields @@ -7632,9 +7638,9 @@ process_init_element (struct c_expr value, bool implicit) /* For a record, keep track of end position of last field. */ if (DECL_SIZE (constructor_fields)) constructor_bit_index - = size_binop (PLUS_EXPR, - bit_position (constructor_fields), - DECL_SIZE (constructor_fields)); + = size_binop_loc (input_location, PLUS_EXPR, + bit_position (constructor_fields), + DECL_SIZE (constructor_fields)); /* If the current field was the first one not yet written out, it isn't now, so update. */ @@ -7769,7 +7775,8 @@ process_init_element (struct c_expr value, bool implicit) } constructor_index - = size_binop (PLUS_EXPR, constructor_index, bitsize_one_node); + = size_binop_loc (input_location, PLUS_EXPR, + constructor_index, bitsize_one_node); if (!value.value) /* If we are doing the bookkeeping for an element that was @@ -7801,7 +7808,8 @@ process_init_element (struct c_expr value, bool implicit) } constructor_index - = size_binop (PLUS_EXPR, constructor_index, bitsize_one_node); + = size_binop_loc (input_location, + PLUS_EXPR, constructor_index, bitsize_one_node); if (!value.value) /* If we are doing the bookkeeping for an element that was @@ -7850,7 +7858,8 @@ process_init_element (struct c_expr value, bool implicit) process_init_element (pop_init_level (1), true); } - p->index = size_binop (PLUS_EXPR, p->index, bitsize_one_node); + p->index = size_binop_loc (input_location, + PLUS_EXPR, p->index, bitsize_one_node); if (tree_int_cst_equal (p->index, p->range_end) && !p->prev) finish = 1; @@ -8416,11 +8425,12 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body, } t = build_and_jump (&blab); - exit = fold_build3 (COND_EXPR, void_type_node, cond, exit, t); if (cond_is_first) - SET_EXPR_LOCATION (exit, start_locus); + exit = fold_build3_loc (start_locus, + COND_EXPR, void_type_node, cond, exit, t); else - SET_EXPR_LOCATION (exit, input_location); + exit = fold_build3_loc (input_location, + COND_EXPR, void_type_node, cond, exit, t); } add_stmt (top); @@ -8935,12 +8945,12 @@ build_binary_op (location_t location, enum tree_code code, /* Handle the pointer + int case. */ if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) { - ret = pointer_int_sum (PLUS_EXPR, op0, op1); + ret = pointer_int_sum (location, PLUS_EXPR, op0, op1); goto return_build_binary_op; } else if (code1 == POINTER_TYPE && code0 == INTEGER_TYPE) { - ret = pointer_int_sum (PLUS_EXPR, op1, op0); + ret = pointer_int_sum (location, PLUS_EXPR, op1, op0); goto return_build_binary_op; } else @@ -8953,13 +8963,13 @@ build_binary_op (location_t location, enum tree_code code, if (code0 == POINTER_TYPE && code1 == POINTER_TYPE && comp_target_types (location, type0, type1)) { - ret = pointer_diff (op0, op1); + ret = pointer_diff (location, op0, op1); goto return_build_binary_op; } /* Handle pointer minus int. Just like pointer plus int. */ else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE) { - ret = pointer_int_sum (MINUS_EXPR, op0, op1); + ret = pointer_int_sum (location, MINUS_EXPR, op0, op1); goto return_build_binary_op; } else @@ -9572,8 +9582,9 @@ build_binary_op (location_t location, enum tree_code code, /* Treat expressions in initializers specially as they can't trap. */ if (int_const_or_overflow) ret = (require_constant_value - ? fold_build2_initializer (resultcode, build_type, op0, op1) - : fold_build2 (resultcode, build_type, op0, op1)); + ? fold_build2_initializer_loc (location, resultcode, build_type, + op0, op1) + : fold_build2_loc (location, resultcode, build_type, op0, op1)); else ret = build2 (resultcode, build_type, op0, op1); if (final_type != 0) diff --git a/gcc/calls.c b/gcc/calls.c index c3d7639e4e2..bac4f8bb5d9 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -949,6 +949,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, int *must_preallocate, int *ecf_flags, bool *may_tailcall, bool call_from_thunk_p) { + location_t loc = EXPR_LOCATION (exp); /* 1 if scanning parms front to back, -1 if scanning back to front. */ int inc; @@ -1062,7 +1063,8 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, if (!call_from_thunk_p && DECL_P (base) && !TREE_STATIC (base)) *may_tailcall = false; - args[i].tree_value = build_fold_addr_expr (args[i].tree_value); + args[i].tree_value = build_fold_addr_expr_loc (loc, + args[i].tree_value); type = TREE_TYPE (args[i].tree_value); if (*ecf_flags & ECF_CONST) @@ -1114,7 +1116,7 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED, *ecf_flags &= ~(ECF_PURE | ECF_LOOPING_CONST_OR_PURE); args[i].tree_value - = build_fold_addr_expr (make_tree (type, copy)); + = build_fold_addr_expr_loc (loc, make_tree (type, copy)); type = TREE_TYPE (args[i].tree_value); *may_tailcall = false; } diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 4b3a962fbd3..3d0fee5ba94 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -1836,6 +1836,9 @@ cgraph_add_new_function (tree fndecl, bool lowered) push_cfun (DECL_STRUCT_FUNCTION (fndecl)); current_function_decl = fndecl; gimple_register_cfg_hooks (); + /* C++ Thunks are emitted late via this function, gimplify them. */ + if (!gimple_body (fndecl)) + gimplify_function_tree (fndecl); tree_lowering_passes (fndecl); bitmap_obstack_initialize (NULL); if (!gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl))) diff --git a/gcc/cgraph.h b/gcc/cgraph.h index bf3f320e4f3..3e9a6d4201c 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -426,7 +426,6 @@ struct cgraph_node * cgraph_create_virtual_clone (struct cgraph_node *old_node, void cgraph_finalize_function (tree, bool); void cgraph_mark_if_needed (tree); void cgraph_finalize_compilation_unit (void); -void cgraph_optimize (void); void cgraph_mark_needed_node (struct cgraph_node *); void cgraph_mark_address_taken_node (struct cgraph_node *); void cgraph_mark_reachable_node (struct cgraph_node *); @@ -442,7 +441,6 @@ struct cgraph_node *cgraph_function_versioning (struct cgraph_node *, VEC(ipa_replace_map_p,gc)*, bitmap); void tree_function_versioning (tree, tree, VEC (ipa_replace_map_p,gc)*, bool, bitmap); -void cgraph_analyze_function (struct cgraph_node *); struct cgraph_node *save_inline_function_body (struct cgraph_node *); void record_references_in_initializer (tree); bool cgraph_process_new_functions (void); diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 4521f3b7641..d329dc1c0a2 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -132,6 +132,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "tree-iterator.h" #include "tree-pass.h" +#include "tree-dump.h" #include "output.h" #include "coverage.h" @@ -139,6 +140,8 @@ static void cgraph_expand_all_functions (void); static void cgraph_mark_functions_to_output (void); static void cgraph_expand_function (struct cgraph_node *); static void cgraph_output_pending_asms (void); +static void cgraph_optimize (void); +static void cgraph_analyze_function (struct cgraph_node *); static FILE *cgraph_dump_file; @@ -208,7 +211,8 @@ build_cdtor (bool ctor_p, tree *cdtors, size_t len) priority = p; else if (p != priority) break; - append_to_statement_list (build_function_call_expr (fn, 0), + append_to_statement_list (build_function_call_expr (UNKNOWN_LOCATION, + fn, 0), &body); ++i; } @@ -489,6 +493,11 @@ cgraph_lower_function (struct cgraph_node *node) { if (node->lowered) return; + + if (node->nested) + lower_nested_functions (node->decl); + gcc_assert (!node->nested); + tree_lowering_passes (node->decl); node->lowered = true; } @@ -512,9 +521,6 @@ cgraph_finalize_function (tree decl, bool nested) node->lowered = DECL_STRUCT_FUNCTION (decl)->cfg != NULL; node->finalized_by_frontend = true; record_cdtor_fn (node->decl); - if (node->nested) - lower_nested_functions (decl); - gcc_assert (!node->nested); if (decide_is_function_needed (node, decl)) cgraph_mark_needed_node (node); @@ -788,18 +794,28 @@ cgraph_output_pending_asms (void) } /* Analyze the function scheduled to be output. */ -void +static void cgraph_analyze_function (struct cgraph_node *node) { + tree save = current_function_decl; tree decl = node->decl; current_function_decl = decl; push_cfun (DECL_STRUCT_FUNCTION (decl)); + + /* Make sure to gimplify bodies only once. During analyzing a + function we lower it, which will require gimplified nested + functions, so we can end up here with an already gimplified + body. */ + if (!gimple_body (decl)) + gimplify_function_tree (decl); + dump_function (TDI_generic, decl); + cgraph_lower_function (node); node->analyzed = true; pop_cfun (); - current_function_decl = NULL; + current_function_decl = save; } /* Look for externally_visible and used attributes and mark cgraph nodes @@ -934,8 +950,6 @@ cgraph_analyze_functions (void) } gcc_assert (!node->analyzed && node->reachable); - gcc_assert (gimple_body (decl)); - cgraph_analyze_function (node); for (edge = node->callees; edge; edge = edge->next_callee) @@ -1009,8 +1023,8 @@ cgraph_analyze_functions (void) void cgraph_finalize_compilation_unit (void) { - if (errorcount || sorrycount) - return; + /* Do not skip analyzing the functions if there were errors, we + miss diagnostics for following functions otherwise. */ finalize_size_functions (); finish_aliases_1 (); @@ -1024,6 +1038,8 @@ cgraph_finalize_compilation_unit (void) timevar_push (TV_CGRAPH); cgraph_analyze_functions (); timevar_pop (TV_CGRAPH); + + cgraph_optimize (); } @@ -1310,7 +1326,7 @@ ipa_passes (void) /* Perform simple optimizations based on callgraph. */ -void +static void cgraph_optimize (void) { if (errorcount || sorrycount) diff --git a/gcc/combine.c b/gcc/combine.c index a781484b764..3f39bc3b286 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -7061,6 +7061,12 @@ make_compound_operation (rtx x, enum rtx_code in_code) if (GET_CODE (newer) != SUBREG) newer = make_compound_operation (newer, in_code); + /* force_to_mode can expand compounds. If it just re-expanded the + compound use gen_lowpart instead to convert to the desired + mode. */ + if (rtx_equal_p (newer, x)) + return gen_lowpart (GET_MODE (x), tem); + return newer; } @@ -8982,6 +8988,67 @@ merge_outer_ops (enum rtx_code *pop0, HOST_WIDE_INT *pconst0, enum rtx_code op1, return 1; } +/* A helper to simplify_shift_const_1 to determine the mode we can perform + the shift in. The original shift operation CODE is performed on OP in + ORIG_MODE. Return the wider mode MODE if we can perform the operation + in that mode. Return ORIG_MODE otherwise. We can also assume that the + result of the shift is subject to operation OUTER_CODE with operand + OUTER_CONST. */ + +static enum machine_mode +try_widen_shift_mode (enum rtx_code code, rtx op, int count, + enum machine_mode orig_mode, enum machine_mode mode, + enum rtx_code outer_code, HOST_WIDE_INT outer_const) +{ + if (orig_mode == mode) + return mode; + gcc_assert (GET_MODE_BITSIZE (mode) > GET_MODE_BITSIZE (orig_mode)); + + /* In general we can't perform in wider mode for right shift and rotate. */ + switch (code) + { + case ASHIFTRT: + /* We can still widen if the bits brought in from the left are identical + to the sign bit of ORIG_MODE. */ + if (num_sign_bit_copies (op, mode) + > (unsigned) (GET_MODE_BITSIZE (mode) + - GET_MODE_BITSIZE (orig_mode))) + return mode; + return orig_mode; + + case LSHIFTRT: + /* Similarly here but with zero bits. */ + if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT + && (nonzero_bits (op, mode) & ~GET_MODE_MASK (orig_mode)) == 0) + return mode; + + /* We can also widen if the bits brought in will be masked off. This + operation is performed in ORIG_MODE. */ + if (outer_code == AND + && GET_MODE_BITSIZE (orig_mode) <= HOST_BITS_PER_WIDE_INT) + { + int care_bits; + + outer_const &= GET_MODE_MASK (orig_mode); + care_bits = exact_log2 (outer_const + 1); + + if (care_bits >= 0 + && GET_MODE_BITSIZE (orig_mode) - care_bits >= count) + return mode; + } + /* fall through */ + + case ROTATE: + return orig_mode; + + case ROTATERT: + gcc_unreachable (); + + default: + return mode; + } +} + /* Simplify a shift of VAROP by COUNT bits. CODE says what kind of shift. The result of the shift is RESULT_MODE. Return NULL_RTX if we cannot simplify it. Otherwise, return a simplified value. @@ -9041,13 +9108,8 @@ simplify_shift_const_1 (enum rtx_code code, enum machine_mode result_mode, count = bitsize - count; } - /* We need to determine what mode we will do the shift in. If the - shift is a right shift or a ROTATE, we must always do it in the mode - it was originally done in. Otherwise, we can do it in MODE, the - widest mode encountered. */ - shift_mode - = (code == ASHIFTRT || code == LSHIFTRT || code == ROTATE - ? result_mode : mode); + shift_mode = try_widen_shift_mode (code, varop, count, result_mode, + mode, outer_op, outer_const); /* Handle cases where the count is greater than the size of the mode minus 1. For ASHIFT, use the size minus one as the count (this can @@ -9645,14 +9707,8 @@ simplify_shift_const_1 (enum rtx_code code, enum machine_mode result_mode, break; } - /* We need to determine what mode to do the shift in. If the shift is - a right shift or ROTATE, we must always do it in the mode it was - originally done in. Otherwise, we can do it in MODE, the widest mode - encountered. The code we care about is that of the shift that will - actually be done, not the shift that was originally requested. */ - shift_mode - = (code == ASHIFTRT || code == LSHIFTRT || code == ROTATE - ? result_mode : mode); + shift_mode = try_widen_shift_mode (code, varop, count, result_mode, mode, + outer_op, outer_const); /* We have now finished analyzing the shift. The result should be a shift of type CODE with SHIFT_MODE shifting VAROP COUNT places. If diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 0fd0a1982ea..809f2c49b97 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -4207,6 +4207,28 @@ "" ) +(define_code_iterator ior_xor [ior xor]) + +(define_split + [(set (match_operand:SI 0 "s_register_operand" "") + (ior_xor:SI (and:SI (ashift:SI + (match_operand:SI 1 "s_register_operand" "") + (match_operand:SI 2 "const_int_operand" "")) + (match_operand:SI 3 "const_int_operand" "")) + (zero_extend:SI + (match_operator 5 "subreg_lowpart_operator" + [(match_operand:SI 4 "s_register_operand" "")]))))] + "TARGET_32BIT + && (INTVAL (operands[3]) + == (GET_MODE_MASK (GET_MODE (operands[5])) + & (GET_MODE_MASK (GET_MODE (operands[5])) + << (INTVAL (operands[2])))))" + [(set (match_dup 0) (ior_xor:SI (ashift:SI (match_dup 1) (match_dup 2)) + (match_dup 4))) + (set (match_dup 0) (zero_extend:SI (match_dup 5)))] + "operands[5] = gen_lowpart (GET_MODE (operands[5]), operands[0]);" +) + (define_insn "*compareqi_eq0" [(set (reg:CC_Z CC_REGNUM) (compare:CC_Z (match_operand:QI 0 "s_register_operand" "r") diff --git a/gcc/config/arm/predicates.md b/gcc/config/arm/predicates.md index 7997cc94cf5..d351f443851 100644 --- a/gcc/config/arm/predicates.md +++ b/gcc/config/arm/predicates.md @@ -73,6 +73,10 @@ || REGNO_REG_CLASS (REGNO (op)) == FPA_REGS)); }) +(define_special_predicate "subreg_lowpart_operator" + (and (match_code "subreg") + (match_test "subreg_lowpart_p (op)"))) + ;; Reg, subreg(reg) or const_int. (define_predicate "reg_or_int_operand" (ior (match_code "const_int") diff --git a/gcc/config/avr/avr-devices.c b/gcc/config/avr/avr-devices.c index f422b4e7876..ad58772b2a1 100755 --- a/gcc/config/avr/avr-devices.c +++ b/gcc/config/avr/avr-devices.c @@ -93,6 +93,9 @@ const struct mcu_type_s avr_mcu_types[] = { { "avr35", ARCH_AVR35, NULL, 0, 0x0100, "usb162" }, { "at90usb82", ARCH_AVR35, "__AVR_AT90USB82__", 0, 0x0100, "usb82" }, { "at90usb162", ARCH_AVR35, "__AVR_AT90USB162__", 0, 0x0100, "usb162" }, + { "atmega8u2", ARCH_AVR35, "__AVR_ATmega8U2__", 0, 0x0100, "m8u2" }, + { "atmega16u2", ARCH_AVR35, "__AVR_ATmega16U2__", 0, 0x0100, "m16u2" }, + { "atmega32u2", ARCH_AVR35, "__AVR_ATmega32U2__", 0, 0x0100, "m32u2" }, { "attiny167", ARCH_AVR35, "__AVR_ATtiny167__", 0, 0x0100, "tn167" }, { "attiny327", ARCH_AVR35, "__AVR_ATtiny327__", 0, 0x0100, "tn327" }, /* Enhanced, <= 8K. */ diff --git a/gcc/config/avr/t-avr b/gcc/config/avr/t-avr index c27118e22d4..58656179b8a 100644 --- a/gcc/config/avr/t-avr +++ b/gcc/config/avr/t-avr @@ -94,6 +94,9 @@ MULTILIB_MATCHES = \ mmcu?avr31=mmcu?at43usb320 \ mmcu?avr35=mmcu?at90usb82 \ mmcu?avr35=mmcu?at90usb162 \ + mmcu?avr35=mmcu?atmega8u2 \ + mmcu?avr35=mmcu?atmega16u2 \ + mmcu?avr35=mmcu?atmega32u2 \ mmcu?avr35=mmcu?attiny167 \ mmcu?avr35=mmcu?attiny327 \ mmcu?avr4=mmcu?atmega48 \ diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 8980bf21ac2..ce830298df4 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -1595,23 +1595,21 @@ (set_attr "mode" "<MODE>")]) (define_expand "copysign<mode>3" - [(set (match_dup 5) - (and:SSEMODEF2P (match_operand:SSEMODEF2P 1 "register_operand" "") - (match_dup 3))) - (set (match_dup 6) - (and:SSEMODEF2P (match_operand:SSEMODEF2P 2 "register_operand" "") - (match_dup 4))) + [(set (match_dup 4) + (and:SSEMODEF2P + (not:SSEMODEF2P (match_dup 3)) + (match_operand:SSEMODEF2P 1 "nonimmediate_operand" ""))) + (set (match_dup 5) + (and:SSEMODEF2P (match_dup 3) + (match_operand:SSEMODEF2P 2 "nonimmediate_operand" ""))) (set (match_operand:SSEMODEF2P 0 "register_operand" "") - (ior:SSEMODEF2P (match_dup 5) (match_dup 6)))] + (ior:SSEMODEF2P (match_dup 4) (match_dup 5)))] "SSE_VEC_FLOAT_MODE_P (<MODE>mode)" { - int i; - - for (i = 3; i < 7; i++) - operands[i] = gen_reg_rtx (<MODE>mode); + operands[3] = ix86_build_signbit_mask (<ssescalarmode>mode, 1, 0); - operands[3] = ix86_build_signbit_mask (<ssescalarmode>mode, 1, 1); - operands[4] = ix86_build_signbit_mask (<ssescalarmode>mode, 1, 0); + operands[4] = gen_reg_rtx (<MODE>mode); + operands[5] = gen_reg_rtx (<MODE>mode); }) ;; Also define scalar versions. These are used for abs, neg, and diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c index 9672dfa718a..46dc4dc6639 100644 --- a/gcc/config/m32c/m32c.c +++ b/gcc/config/m32c/m32c.c @@ -4167,6 +4167,40 @@ m32c_compare_redundant (rtx cmp, rtx *operands) #endif return false; } + + /* Check for comparisons against memory - between volatiles and + aliases, we just can't risk this one. */ + if (GET_CODE (operands[0]) == MEM + || GET_CODE (operands[0]) == MEM) + { +#if DEBUG_CMP + fprintf(stderr, "comparisons with memory:\n"); + debug_rtx(prev); +#endif + return false; + } + + /* Check for PREV changing a register that's used to compute a + value in CMP, even if it doesn't otherwise change flags. */ + if (GET_CODE (operands[0]) == REG + && rtx_referenced_p (SET_DEST (PATTERN (prev)), operands[0])) + { +#if DEBUG_CMP + fprintf(stderr, "sub-value affected, op0:\n"); + debug_rtx(prev); +#endif + return false; + } + if (GET_CODE (operands[1]) == REG + && rtx_referenced_p (SET_DEST (PATTERN (prev)), operands[1])) + { +#if DEBUG_CMP + fprintf(stderr, "sub-value affected, op1:\n"); + debug_rtx(prev); +#endif + return false; + } + } while (pflags == FLAGS_N); #if DEBUG_CMP fprintf(stderr, "previous flag-setting insn:\n"); @@ -4251,7 +4285,7 @@ m32c_output_compare (rtx insn, rtx *operands) } #if DEBUG_CMP - fprintf(stderr, "cbranch: cmp needed: `%s'\n", templ); + fprintf(stderr, "cbranch: cmp needed: `%s'\n", templ + 1); #endif return templ + 1; } diff --git a/gcc/config/m68k/linux-unwind.h b/gcc/config/m68k/linux-unwind.h index 5f877464f0f..053c15558ca 100644 --- a/gcc/config/m68k/linux-unwind.h +++ b/gcc/config/m68k/linux-unwind.h @@ -77,9 +77,15 @@ m68k_fallback_frame_state (struct _Unwind_Context *context, fs->regs.reg[9].how = REG_SAVED_OFFSET; fs->regs.reg[9].loc.offset = (long) &sc->sc_a1 - cfa; +#ifdef __uClinux__ + fs->regs.reg[13].how = REG_SAVED_OFFSET; + fs->regs.reg[13].loc.offset = (long) &sc->sc_a5 - cfa; +#endif + fs->regs.reg[24].how = REG_SAVED_OFFSET; fs->regs.reg[24].loc.offset = (long) &sc->sc_pc - cfa; +#ifndef __uClinux__ if (*(int *) sc->sc_fpstate) { int *fpregs = (int *) sc->sc_fpregs; @@ -89,6 +95,9 @@ m68k_fallback_frame_state (struct _Unwind_Context *context, fs->regs.reg[17].how = REG_SAVED_OFFSET; fs->regs.reg[17].loc.offset = (long) &fpregs[M68K_FP_SIZE/4] - cfa; } +#elif defined __mcffpu__ +# error Implement this when uClinux kernel is ported to an FPU architecture +#endif } #ifdef __mcoldfire__ /* move.l #__NR_rt_sigreturn,%d0; trap #0 */ diff --git a/gcc/config/mep/mep.md b/gcc/config/mep/mep.md index 5b5fba87215..20beef6b438 100644 --- a/gcc/config/mep/mep.md +++ b/gcc/config/mep/mep.md @@ -1927,8 +1927,8 @@ return "jmp\t%0"; else if (mep_vliw_mode_match (operands[2])) return - "movu $3, %0\n\ - jmp $3"; + "movu $0, %0\n\ + jmp $0"; else return "ldc $12, $lp\n\ @@ -2002,8 +2002,8 @@ return "jmp\t%1"; else if (mep_vliw_mode_match (operands[3])) return - "movu $3, %1\n\ - jmp $3"; + "movu $0, %1\n\ + jmp $0"; else return "ldc $12, $lp\n\ diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md index 3c42b465693..fc32c758688 100644 --- a/gcc/config/mips/mips.md +++ b/gcc/config/mips/mips.md @@ -3016,14 +3016,9 @@ [(set (match_operand:DI 0 "register_operand" "=d") (sign_extend:DI (truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))] - "TARGET_64BIT && !TARGET_MIPS16" -{ - if (!ISA_HAS_EXTS) - return "#"; - operands[2] = GEN_INT (GET_MODE_BITSIZE (<SHORT:MODE>mode)); - return "exts\t%0,%1,0,%m2"; -} - "&& reload_completed && !ISA_HAS_EXTS" + "TARGET_64BIT && !TARGET_MIPS16 && !ISA_HAS_EXTS" + "#" + "&& reload_completed" [(set (match_dup 2) (ashift:DI (match_dup 1) (match_dup 3))) @@ -3034,21 +3029,16 @@ operands[2] = gen_lowpart (DImode, operands[0]); operands[3] = GEN_INT (BITS_PER_WORD - GET_MODE_BITSIZE (<MODE>mode)); } - [(set_attr "type" "arith") + [(set_attr "move_type" "shift_shift") (set_attr "mode" "DI")]) (define_insn_and_split "*extendsi_truncate<mode>" [(set (match_operand:SI 0 "register_operand" "=d") (sign_extend:SI (truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))] - "TARGET_64BIT && !TARGET_MIPS16" -{ - if (!ISA_HAS_EXTS) - return "#"; - operands[2] = GEN_INT (GET_MODE_BITSIZE (<SHORT:MODE>mode)); - return "exts\t%0,%1,0,%m2"; -} - "&& reload_completed && !ISA_HAS_EXTS" + "TARGET_64BIT && !TARGET_MIPS16 && !ISA_HAS_EXTS" + "#" + "&& reload_completed" [(set (match_dup 2) (ashift:DI (match_dup 1) (match_dup 3))) @@ -3059,18 +3049,16 @@ operands[2] = gen_lowpart (DImode, operands[0]); operands[3] = GEN_INT (BITS_PER_WORD - GET_MODE_BITSIZE (<MODE>mode)); } - [(set_attr "type" "arith") + [(set_attr "move_type" "shift_shift") (set_attr "mode" "SI")]) (define_insn_and_split "*extendhi_truncateqi" [(set (match_operand:HI 0 "register_operand" "=d") (sign_extend:HI (truncate:QI (match_operand:DI 1 "register_operand" "d"))))] - "TARGET_64BIT && !TARGET_MIPS16" -{ - return ISA_HAS_EXTS ? "exts\t%0,%1,0,7" : "#"; -} - "&& reload_completed && !ISA_HAS_EXTS" + "TARGET_64BIT && !TARGET_MIPS16 && !ISA_HAS_EXTS" + "#" + "&& reload_completed" [(set (match_dup 2) (ashift:DI (match_dup 1) (const_int 56))) @@ -3080,6 +3068,27 @@ { operands[2] = gen_lowpart (DImode, operands[0]); } + [(set_attr "move_type" "shift_shift") + (set_attr "mode" "SI")]) + +(define_insn "*extend<GPR:mode>_truncate<SHORT:mode>_exts" + [(set (match_operand:GPR 0 "register_operand" "=d") + (sign_extend:GPR + (truncate:SHORT (match_operand:DI 1 "register_operand" "d"))))] + "TARGET_64BIT && !TARGET_MIPS16 && ISA_HAS_EXTS" +{ + operands[2] = GEN_INT (GET_MODE_BITSIZE (<SHORT:MODE>mode)); + return "exts\t%0,%1,0,%m2"; +} + [(set_attr "type" "arith") + (set_attr "mode" "<GPR:MODE>")]) + +(define_insn "*extendhi_truncateqi_exts" + [(set (match_operand:HI 0 "register_operand" "=d") + (sign_extend:HI + (truncate:QI (match_operand:DI 1 "register_operand" "d"))))] + "TARGET_64BIT && !TARGET_MIPS16 && ISA_HAS_EXTS" + "exts\t%0,%1,0,7" [(set_attr "type" "arith") (set_attr "mode" "SI")]) diff --git a/gcc/config/rs6000/constraints.md b/gcc/config/rs6000/constraints.md index e817a664601..a937d99397d 100644 --- a/gcc/config/rs6000/constraints.md +++ b/gcc/config/rs6000/constraints.md @@ -113,8 +113,17 @@ ;; Memory constraints +(define_memory_constraint "es" + "A ``stable'' memory operand; that is, one which does not include any +automodification of the base register. Unlike @samp{m}, this constraint +can be used in @code{asm} statements that might access the operand +several times, or that might not access it at all." + (and (match_code "mem") + (match_test "GET_RTX_CLASS (GET_CODE (XEXP (op, 0))) != RTX_AUTOINC"))) + (define_memory_constraint "Q" - "Memory operand that is just an offset from a reg" + "Memory operand that is an offset from a register (it is usually better +to use @samp{m} or @samp{es} in @code{asm} statements)" (and (match_code "mem") (match_test "GET_CODE (XEXP (op, 0)) == REG"))) @@ -123,7 +132,8 @@ (match_operand 0 "word_offset_memref_operand")) (define_memory_constraint "Z" - "Indexed or indirect memory operand" + "Memory operand that is an indexed or indirect from a register (it is +usually better to use @samp{m} or @samp{es} in @code{asm} statements)" (match_operand 0 "indexed_or_indirect_operand")) ;; Address constraints diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index 13bb76a12ad..b6b443bf3f8 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -367,7 +367,7 @@ ;; Return 1 if the operand is an offsettable memory operand. (define_predicate "offsettable_mem_operand" (and (match_operand 0 "memory_operand") - (match_test "GET_RTX_CLASS (GET_CODE (XEXP (op, 0))) != RTX_AUTOINC"))) + (match_test "offsettable_nonstrict_memref_p (op)"))) ;; Return 1 if the operand is a memory operand with an address divisible by 4 (define_predicate "word_offset_memref_operand" diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index aa97f381820..6063a6c69b2 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -5165,7 +5165,15 @@ rs6000_mode_dependent_address (rtx addr) switch (GET_CODE (addr)) { case PLUS: - if (GET_CODE (XEXP (addr, 1)) == CONST_INT) + /* Any offset from virtual_stack_vars_rtx and arg_pointer_rtx + is considered a legitimate address before reload, so there + are no offset restrictions in that case. Note that this + condition is safe in strict mode because any address involving + virtual_stack_vars_rtx or arg_pointer_rtx would already have + been rejected as illegitimate. */ + if (XEXP (addr, 0) != virtual_stack_vars_rtx + && XEXP (addr, 0) != arg_pointer_rtx + && GET_CODE (XEXP (addr, 1)) == CONST_INT) { unsigned HOST_WIDE_INT val = INTVAL (XEXP (addr, 1)); return val + 12 + 0x8000 >= 0x10000; diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 64de3dc5337..a2fdc34342c 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -6354,7 +6354,7 @@ (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))] "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT" "#" - "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[4]))" + "" [(pc)] " { @@ -6421,7 +6421,7 @@ (clobber (match_operand:DF 5 "gpc_reg_operand" "=&d"))] "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT" "#" - "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[4]))" + "" [(pc)] " { @@ -6488,7 +6488,7 @@ "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT" "#" - "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[3]))" + "" [(pc)] " { @@ -9396,7 +9396,7 @@ "!TARGET_IEEEQUAD && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128" "#" - "&& (can_create_pseudo_p () || offsettable_nonstrict_memref_p (operands[5]))" + "" [(pc)] { rtx lowword; diff --git a/gcc/convert.c b/gcc/convert.c index 706dc41985c..a1ac3300cac 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see tree convert_to_pointer (tree type, tree expr) { + location_t loc = EXPR_LOCATION (expr); if (TREE_TYPE (expr) == type) return expr; @@ -53,16 +54,16 @@ convert_to_pointer (tree type, tree expr) { case POINTER_TYPE: case REFERENCE_TYPE: - return fold_build1 (NOP_EXPR, type, expr); + return fold_build1_loc (loc, NOP_EXPR, type, expr); case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: if (TYPE_PRECISION (TREE_TYPE (expr)) != POINTER_SIZE) - expr = fold_build1 (NOP_EXPR, + expr = fold_build1_loc (loc, NOP_EXPR, lang_hooks.types.type_for_size (POINTER_SIZE, 0), expr); - return fold_build1 (CONVERT_EXPR, type, expr); + return fold_build1_loc (loc, CONVERT_EXPR, type, expr); default: diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4265fa9f9cf..520ae54629f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,77 @@ +2009-07-17 Richard Guenther <rguenther@suse.de> + + PR c/40401 + * decl.c (finish_function): Do not emit unused result warnings + from here. + * cp-objcp-common.h (LANG_HOOKS_POST_GIMPLIFY_PASS): Use + c_warn_unused_result_pass. + * semantics.c (expand_or_defer_fn): Adjust assertion about IL status. + * optimize.c (clone_body): Clone in GENERIC. + (maybe_clone_body): Do not clear DECL_SAVED_TREE. + * decl2.c (cp_write_global_declarations): Fix body test. + Do not call cgraph_optimize. + * Make-lang.in (optimize.o): Add tree-iterator.h dependency. + * method.c (use_thunk): Register thunk with + cgraph_finalize_function. + * error.c (function_category): Guard access of DECL_LANG_SPECIFIC. + +2009-07-17 Richard Guenther <rguenther@suse.de> + + * init.c (build_vec_delete_1): Do not set DECL_REGISTER on the + temporary pointer. + +2009-07-17 Aldy Hernandez <aldyh@redhat.com> + Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR 40435 + * typeck.c, init.c, class.c, method.c, rtti.c, except.c, error.c, + tree.c, cp-gimplify.c, cxx-pretty-print.c, pt.c, semantics.c, + call.c, cvt.c, mangle.c: Add location argument to + fold_{unary,binary,ternary}, fold_build[123], build_call_expr, + build_size_arg, build_fold_addr_expr, build_call_array, + non_lvalue, size_diffop, fold_build1_initializer, + fold_build2_initializer, fold_build3_initializer, + fold_build_call_array, fold_build_call_array_initializer, + fold_single_bit_test, omit_one_operand, omit_two_operands, + invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref, + fold_indirect_ref, combine_comparisons, fold_builtin_*, + fold_call_expr, build_range_check, maybe_fold_offset_to_address, + round_up, round_down. + +2009-07-16 Jason Merrill <jason@redhat.com> + + PR libstdc++/37907 + Split POD into "standard-layout" and "trivial" as per N2230, + Support std::is_standard_layout and std::is_trivial traits. + * cp-tree.h (enum cp_trait_kind): Add CPTK_IS_STD_LAYOUT, + CPTK_IS_TRIVIAL. + (struct lang_type_class): Add non_std_layout. + (CLASSTYPE_NON_STD_LAYOUT): New. + * class.c (check_bases): Set it. + (check_field_decls): Likewise. + (check_bases_and_members): Likewise. + * parser.c (cp_parser_primary_expression): Handle RID_IS_STD_LAYOUT, + RID_IS_TRIVIAL. + (cp_parser_trait_expr): Likewise. + * semantics.c (trait_expr_value): Handle CPTK_IS_STD_LAYOUT, + CPTK_IS_TRIVIAL. + (finish_trait_expr): Likewise. + * tree.c (scalarish_type_p, trivial_type_p, std_layout_type_p): New. + (pod_type_p): Use them. + (type_has_nontrivial_copy_init, type_has_nontrivial_default_init): New. + + Adjust bits of the language that no longer refer to POD types. + * call.c (convert_arg_to_ellipsis): Use type_has_nontrivial_copy_init + and TYPE_HAS_NONTRIVIAL_DESTRUCTOR rather than pod_type_p. + (build_x_va_arg): Likewise. + (call_builtin_trap): Remove. + * decl.c (declare_local_label): Use type_has_nontrivial_default_init + and TYPE_HAS_NONTRIVIAL_DESTRUCTOR rather than pod_type_p. + (cp_finish_decl): Likewise. + (check_previous_goto_1, check_goto): Adjust error. + * typeck.c (build_class_member_access_expr): Check + CLASSTYPE_NON_STD_LAYOUT rather than CLASSTYPE_NON_POD_P. + 2009-07-14 Taras Glek <tglek@mozilla.com> Rafael Espindola <espindola@google.com> diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 6bff698f00b..c7d1a449a90 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -303,7 +303,7 @@ cp/semantics.o: cp/semantics.c $(CXX_TREE_H) $(TM_H) except.h toplev.h \ cp/dump.o: cp/dump.c $(CXX_TREE_H) $(TM_H) $(TREE_DUMP_H) cp/optimize.o: cp/optimize.c $(CXX_TREE_H) $(TM_H) rtl.h $(INTEGRATE_H) \ insn-config.h input.h $(PARAMS_H) debug.h $(TREE_INLINE_H) $(GIMPLE_H) \ - $(TARGET_H) + $(TARGET_H) tree-iterator.h cp/mangle.o: cp/mangle.c $(CXX_TREE_H) $(TM_H) toplev.h $(REAL_H) \ gt-cp-mangle.h $(TARGET_H) $(TM_P_H) cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) $(DIAGNOSTIC_H) gt-cp-parser.h \ diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 588c997a34b..f4b5b02bb45 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -197,7 +197,6 @@ static conversion *direct_reference_binding (tree, conversion *); static bool promoted_arithmetic_type_p (tree); static conversion *conditional_conversion (tree, tree); static char *name_as_c_string (tree, tree, bool *); -static tree call_builtin_trap (void); static tree prep_operand (tree); static void add_candidates (tree, const VEC(tree,gc) *, tree, bool, tree, tree, int, struct z_candidate **); @@ -363,7 +362,8 @@ build_call_a (tree function, int n, tree *argarray) argarray[i], t); } - function = build_call_array (result_type, function, n, argarray); + function = build_call_array_loc (input_location, + result_type, function, n, argarray); TREE_HAS_CONSTRUCTOR (function) = is_constructor; TREE_NOTHROW (function) = nothrow; @@ -5042,18 +5042,6 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, return expr; } -/* Build a call to __builtin_trap. */ - -static tree -call_builtin_trap (void) -{ - tree fn = implicit_built_in_decls[BUILT_IN_TRAP]; - - gcc_assert (fn != NULL); - fn = build_call_n (fn, 0); - return fn; -} - /* ARG is being passed to a varargs function. Perform any conversions required. Return the converted value. */ @@ -5082,20 +5070,23 @@ convert_arg_to_ellipsis (tree arg) arg = require_complete_type (arg); if (arg != error_mark_node - && !pod_type_p (TREE_TYPE (arg))) + && (type_has_nontrivial_copy_init (TREE_TYPE (arg)) + || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (arg)))) { - /* Undefined behavior [expr.call] 5.2.2/7. We used to just warn - here and do a bitwise copy, but now cp_expr_size will abort if we - try to do that. + /* [expr.call] 5.2.2/7: + Passing a potentially-evaluated argument of class type (Clause 9) + with a non-trivial copy constructor or a non-trivial destructor + with no corresponding parameter is conditionally-supported, with + implementation-defined semantics. + + We used to just warn here and do a bitwise copy, but now + cp_expr_size will abort if we try to do that. + If the call appears in the context of a sizeof expression, - there is no need to emit a warning, since the expression won't be - evaluated. We keep the builtin_trap just as a safety check. */ + it is not potentially-evaluated. */ if (cp_unevaluated_operand == 0) - warning (0, "cannot pass objects of non-POD type %q#T through %<...%>; " - "call will abort at runtime", TREE_TYPE (arg)); - arg = call_builtin_trap (); - arg = build2 (COMPOUND_EXPR, integer_type_node, arg, - integer_zero_node); + error ("cannot pass objects of non-trivially-copyable " + "type %q#T through %<...%>", TREE_TYPE (arg)); } return arg; @@ -5114,16 +5105,16 @@ build_x_va_arg (tree expr, tree type) if (expr == error_mark_node || !type) return error_mark_node; - if (! pod_type_p (type)) + if (type_has_nontrivial_copy_init (type) + || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type) + || TREE_CODE (type) == REFERENCE_TYPE) { /* Remove reference types so we don't ICE later on. */ tree type1 = non_reference (type); - /* Undefined behavior [expr.call] 5.2.2/7. */ - warning (0, "cannot receive objects of non-POD type %q#T through %<...%>; " - "call will abort at runtime", type); + /* conditionally-supported behavior [expr.call] 5.2.2/7. */ + error ("cannot receive objects of non-trivially-copyable type %q#T " + "through %<...%>; ", type); expr = convert (build_pointer_type (type1), null_node); - expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), - call_builtin_trap (), expr); expr = cp_build_indirect_ref (expr, NULL, tf_warning_or_error); return expr; } @@ -5375,8 +5366,9 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) alcarray[ix + 1] = arg; argarray = alcarray; } - expr = build_call_array (return_type, build_addr_func (fn), nargs, - argarray); + expr = build_call_array_loc (input_location, + return_type, build_addr_func (fn), nargs, + argarray); if (TREE_THIS_VOLATILE (fn) && cfun) current_function_returns_abnormally = 1; if (!VOID_TYPE_P (return_type)) diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 4668c68d008..9a768831621 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -333,7 +333,7 @@ build_base_path (enum tree_code code, if (null_test) { tree zero = cp_convert (TREE_TYPE (expr), integer_zero_node); - null_test = fold_build2 (NE_EXPR, boolean_type_node, + null_test = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, expr, zero); } @@ -385,7 +385,7 @@ build_base_path (enum tree_code code, TREE_CONSTANT (v_offset) = 1; offset = convert_to_integer (ptrdiff_type_node, - size_diffop (offset, + size_diffop_loc (input_location, offset, BINFO_OFFSET (v_binfo))); if (!integer_zerop (offset)) @@ -417,7 +417,7 @@ build_base_path (enum tree_code code, { offset = fold_convert (sizetype, offset); if (code == MINUS_EXPR) - offset = fold_build1 (NEGATE_EXPR, sizetype, offset); + offset = fold_build1_loc (input_location, NEGATE_EXPR, sizetype, offset); expr = build2 (POINTER_PLUS_EXPR, ptr_target_type, expr, offset); } else @@ -428,8 +428,8 @@ build_base_path (enum tree_code code, out: if (null_test) - expr = fold_build3 (COND_EXPR, target_type, null_test, expr, - fold_build1 (NOP_EXPR, target_type, + expr = fold_build3_loc (input_location, COND_EXPR, target_type, null_test, expr, + fold_build1_loc (input_location, NOP_EXPR, target_type, integer_zero_node)); return expr; @@ -553,10 +553,11 @@ convert_to_base_statically (tree expr, tree base) expr = cp_build_unary_op (ADDR_EXPR, expr, /*noconvert=*/1, tf_warning_or_error); if (!integer_zerop (BINFO_OFFSET (base))) - expr = fold_build2 (POINTER_PLUS_EXPR, pointer_type, expr, + expr = fold_build2_loc (input_location, + POINTER_PLUS_EXPR, pointer_type, expr, fold_convert (sizetype, BINFO_OFFSET (base))); expr = fold_convert (build_pointer_type (BINFO_TYPE (base)), expr); - expr = build_fold_indirect_ref (expr); + expr = build_fold_indirect_ref_loc (input_location, expr); } return expr; @@ -1248,9 +1249,15 @@ check_bases (tree t, int seen_non_virtual_nearly_empty_base_p; tree base_binfo; tree binfo; + tree field = NULL_TREE; seen_non_virtual_nearly_empty_base_p = 0; + if (!CLASSTYPE_NON_STD_LAYOUT (t)) + for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field)) + if (TREE_CODE (field) == FIELD_DECL) + break; + for (binfo = TYPE_BINFO (t), i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) { @@ -1305,6 +1312,36 @@ check_bases (tree t, CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t) |= CLASSTYPE_CONTAINS_EMPTY_CLASS_P (basetype); TYPE_HAS_COMPLEX_DFLT (t) |= TYPE_HAS_COMPLEX_DFLT (basetype); + + /* A standard-layout class is a class that: + ... + * has no non-standard-layout base classes, */ + CLASSTYPE_NON_STD_LAYOUT (t) |= CLASSTYPE_NON_STD_LAYOUT (basetype); + if (!CLASSTYPE_NON_STD_LAYOUT (t)) + { + tree basefield; + /* ...has no base classes of the same type as the first non-static + data member... */ + if (field && DECL_CONTEXT (field) == t + && (same_type_ignoring_top_level_qualifiers_p + (TREE_TYPE (field), basetype))) + CLASSTYPE_NON_STD_LAYOUT (t) = 1; + else + /* ...either has no non-static data members in the most-derived + class and at most one base class with non-static data + members, or has no base classes with non-static data + members */ + for (basefield = TYPE_FIELDS (basetype); basefield; + basefield = TREE_CHAIN (basefield)) + if (TREE_CODE (basefield) == FIELD_DECL) + { + if (field) + CLASSTYPE_NON_STD_LAYOUT (t) = 1; + else + field = basefield; + break; + } + } } } @@ -1360,7 +1397,8 @@ determine_primary_bases (tree t) /* A virtual binfo might have been copied from within another hierarchy. As we're about to use it as a primary base, make sure the offsets match. */ - delta = size_diffop (convert (ssizetype, + delta = size_diffop_loc (input_location, + convert (ssizetype, BINFO_OFFSET (base_binfo)), convert (ssizetype, BINFO_OFFSET (this_primary))); @@ -1423,7 +1461,7 @@ determine_primary_bases (tree t) /* A virtual binfo might have been copied from within another hierarchy. As we're about to use it as a primary base, make sure the offsets match. */ - delta = size_diffop (ssize_int (0), + delta = size_diffop_loc (input_location, ssize_int (0), convert (ssizetype, BINFO_OFFSET (primary))); propagate_binfo_offsets (primary, delta); @@ -2126,9 +2164,10 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, { /* We convert via virtual base. Adjust the fixed offset to be from there. */ - offset = size_diffop - (offset, convert - (ssizetype, BINFO_OFFSET (virtual_offset))); + offset = + size_diffop (offset, + convert (ssizetype, + BINFO_OFFSET (virtual_offset))); } if (fixed_offset) /* There was an existing fixed offset, this must be @@ -2211,7 +2250,8 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, if (virtual_base) /* The `this' pointer needs to be adjusted from the declaration to the nearest virtual base. */ - delta = size_diffop (convert (ssizetype, BINFO_OFFSET (virtual_base)), + delta = size_diffop_loc (input_location, + convert (ssizetype, BINFO_OFFSET (virtual_base)), convert (ssizetype, BINFO_OFFSET (first_defn))); else if (lost) /* If the nearest definition is in a lost primary, we don't need an @@ -2224,7 +2264,8 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, BINFO to pointing at the base where the final overrider appears. */ virtual_covariant: - delta = size_diffop (convert (ssizetype, + delta = size_diffop_loc (input_location, + convert (ssizetype, BINFO_OFFSET (TREE_VALUE (overrider))), convert (ssizetype, BINFO_OFFSET (binfo))); @@ -2870,6 +2911,7 @@ check_field_decls (tree t, tree *access_decls, bool has_pointers; int any_default_members; int cant_pack = 0; + int field_access = -1; /* Assume there are no access declarations. */ *access_decls = NULL_TREE; @@ -2883,6 +2925,7 @@ check_field_decls (tree t, tree *access_decls, { tree x = *field; tree type = TREE_TYPE (x); + int this_field_access; next = &TREE_CHAIN (x); @@ -2957,10 +3000,21 @@ check_field_decls (tree t, tree *access_decls, if (TREE_PRIVATE (x) || TREE_PROTECTED (x)) CLASSTYPE_NON_AGGREGATE (t) = 1; + /* A standard-layout class is a class that: + ... + has the same access control (Clause 11) for all non-static data members, + ... */ + this_field_access = TREE_PROTECTED (x) ? 1 : TREE_PRIVATE (x) ? 2 : 0; + if (field_access == -1) + field_access = this_field_access; + else if (this_field_access != field_access) + CLASSTYPE_NON_STD_LAYOUT (t) = 1; + /* If this is of reference type, check if it needs an init. */ if (TREE_CODE (type) == REFERENCE_TYPE) { - CLASSTYPE_NON_POD_P (t) = 1; + CLASSTYPE_NON_LAYOUT_POD_P (t) = 1; + CLASSTYPE_NON_STD_LAYOUT (t) = 1; if (DECL_INITIAL (x) == NULL_TREE) SET_CLASSTYPE_REF_FIELDS_NEED_INIT (t, 1); @@ -2975,7 +3029,7 @@ check_field_decls (tree t, tree *access_decls, if (TYPE_PACKED (t)) { - if (!pod_type_p (type) && !TYPE_PACKED (type)) + if (!layout_pod_type_p (type) && !TYPE_PACKED (type)) { warning (0, @@ -3024,10 +3078,13 @@ check_field_decls (tree t, tree *access_decls, if (DECL_MUTABLE_P (x) || TYPE_HAS_MUTABLE_P (type)) CLASSTYPE_HAS_MUTABLE (t) = 1; - if (! pod_type_p (type)) + if (! layout_pod_type_p (type)) /* DR 148 now allows pointers to members (which are POD themselves), to be allowed in POD structs. */ - CLASSTYPE_NON_POD_P (t) = 1; + CLASSTYPE_NON_LAYOUT_POD_P (t) = 1; + + if (!std_layout_type_p (type)) + CLASSTYPE_NON_STD_LAYOUT (t) = 1; if (! zero_init_p (type)) CLASSTYPE_NON_ZERO_INIT_P (t) = 1; @@ -3522,7 +3579,8 @@ layout_nonempty_base_or_field (record_layout_info rli, hierarchy. Therefore, we may not need to add the entire OFFSET. */ propagate_binfo_offsets (binfo, - size_diffop (convert (ssizetype, offset), + size_diffop_loc (input_location, + convert (ssizetype, offset), convert (ssizetype, BINFO_OFFSET (binfo)))); } @@ -3559,7 +3617,8 @@ layout_empty_base (record_layout_info rli, tree binfo, { if (abi_version_at_least (2)) propagate_binfo_offsets - (binfo, size_diffop (size_zero_node, BINFO_OFFSET (binfo))); + (binfo, size_diffop_loc (input_location, + size_zero_node, BINFO_OFFSET (binfo))); else warning (OPT_Wabi, "offset of empty base %qT may not be ABI-compliant and may" @@ -3665,7 +3724,8 @@ build_base_field (record_layout_info rli, tree binfo, /* On some platforms (ARM), even empty classes will not be byte-aligned. */ - eoc = round_up (rli_size_unit_so_far (rli), + eoc = round_up_loc (input_location, + rli_size_unit_so_far (rli), CLASSTYPE_ALIGN_UNIT (basetype)); atend = layout_empty_base (rli, binfo, eoc, offsets); /* A nearly-empty class "has no proper base class that is empty, @@ -4280,7 +4340,7 @@ type_requires_array_cookie (tree type) /* Check the validity of the bases and members declared in T. Add any implicitly-generated functions (like copy-constructors and assignment operators). Compute various flag bits (like - CLASSTYPE_NON_POD_T) for T. This routine works purely at the C++ + CLASSTYPE_NON_LAYOUT_POD_T) for T. This routine works purely at the C++ level: i.e., independently of the ABI in use. */ static void @@ -4346,9 +4406,12 @@ check_bases_and_members (tree t) elsewhere. */ CLASSTYPE_NON_AGGREGATE (t) |= (type_has_user_provided_constructor (t) || TYPE_POLYMORPHIC_P (t)); - CLASSTYPE_NON_POD_P (t) + /* This is the C++98/03 definition of POD; it changed in C++0x, but we + retain the old definition internally for ABI reasons. */ + CLASSTYPE_NON_LAYOUT_POD_P (t) |= (CLASSTYPE_NON_AGGREGATE (t) || saved_nontrivial_dtor || saved_complex_asn_ref); + CLASSTYPE_NON_STD_LAYOUT (t) |= TYPE_CONTAINS_VPTR_P (t); TYPE_HAS_COMPLEX_ASSIGN_REF (t) |= TYPE_CONTAINS_VPTR_P (t); TYPE_HAS_COMPLEX_DFLT (t) |= TYPE_CONTAINS_VPTR_P (t); @@ -4582,7 +4645,8 @@ layout_virtual_bases (record_layout_info rli, splay_tree offsets) && first_vbase && (tree_int_cst_lt (size_binop (CEIL_DIV_EXPR, - round_up (CLASSTYPE_SIZE (t), + round_up_loc (input_location, + CLASSTYPE_SIZE (t), CLASSTYPE_ALIGN (basetype)), bitsize_unit_node), BINFO_OFFSET (vbase)))) @@ -5015,7 +5079,7 @@ layout_class_type (tree t, tree *virtuals_p) /* Make sure that we are on a byte boundary so that the size of the class without virtual bases will always be a round number of bytes. */ - rli->bitpos = round_up (rli->bitpos, BITS_PER_UNIT); + rli->bitpos = round_up_loc (input_location, rli->bitpos, BITS_PER_UNIT); normalize_rli (rli); } @@ -5031,7 +5095,7 @@ layout_class_type (tree t, tree *virtuals_p) /* Create the version of T used for virtual bases. We do not use make_class_type for this version; this is an artificial type. For a POD type, we just reuse T. */ - if (CLASSTYPE_NON_POD_P (t) || CLASSTYPE_EMPTY_P (t)) + if (CLASSTYPE_NON_LAYOUT_POD_P (t) || CLASSTYPE_EMPTY_P (t)) { base_t = make_node (TREE_CODE (t)); @@ -7710,11 +7774,12 @@ build_vbase_offset_vtbl_entries (tree binfo, vtbl_init_data* vid) The vbase offsets go in reverse inheritance-graph order, and we are walking in inheritance graph order so these end up in the right order. */ - delta = size_diffop (BINFO_OFFSET (b), BINFO_OFFSET (non_primary_binfo)); + delta = size_diffop_loc (input_location, + BINFO_OFFSET (b), BINFO_OFFSET (non_primary_binfo)); *vid->last_init = build_tree_list (NULL_TREE, - fold_build1 (NOP_EXPR, + fold_build1_loc (input_location, NOP_EXPR, vtable_entry_type, delta)); vid->last_init = &TREE_CHAIN (*vid->last_init); @@ -7944,9 +8009,11 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid) vid->binfo. But it might be a lost primary, so its BINFO_OFFSET might be wrong, so we just use the BINFO_OFFSET from vid->binfo. */ - vcall_offset = size_diffop (BINFO_OFFSET (base), + vcall_offset = size_diffop_loc (input_location, + BINFO_OFFSET (base), BINFO_OFFSET (vid->binfo)); - vcall_offset = fold_build1 (NOP_EXPR, vtable_entry_type, + vcall_offset = fold_build1_loc (input_location, + NOP_EXPR, vtable_entry_type, vcall_offset); } /* Add the initializer to the vtable. */ @@ -7985,7 +8052,8 @@ build_rtti_vtbl_entries (tree binfo, vtbl_init_data* vid) && BINFO_INHERITANCE_CHAIN (primary_base) == b); b = primary_base; } - offset = size_diffop (BINFO_OFFSET (vid->rtti_binfo), BINFO_OFFSET (b)); + offset = size_diffop_loc (input_location, + BINFO_OFFSET (vid->rtti_binfo), BINFO_OFFSET (b)); /* The second entry is the address of the typeinfo object. */ if (flag_rtti) diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index fc30c06b62f..4cf78dfd4a5 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -924,9 +924,9 @@ cxx_omp_clause_apply_fn (tree fn, tree arg1, tree arg2) size_zero_node, NULL, NULL); } while (TREE_CODE (inner_type) == ARRAY_TYPE); - start1 = build_fold_addr_expr (start1); + start1 = build_fold_addr_expr_loc (input_location, start1); if (arg2) - start2 = build_fold_addr_expr (start2); + start2 = build_fold_addr_expr_loc (input_location, start2); end1 = TYPE_SIZE_UNIT (TREE_TYPE (arg1)); end1 = build2 (POINTER_PLUS_EXPR, TREE_TYPE (start1), start1, end1); @@ -980,9 +980,9 @@ cxx_omp_clause_apply_fn (tree fn, tree arg1, tree arg2) } else { - argarray[i++] = build_fold_addr_expr (arg1); + argarray[i++] = build_fold_addr_expr_loc (input_location, arg1); if (arg2) - argarray[i++] = build_fold_addr_expr (arg2); + argarray[i++] = build_fold_addr_expr_loc (input_location, arg2); /* Handle default arguments. */ for (parm = defparm; parm && parm != void_list_node; parm = TREE_CHAIN (parm), i++) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 933da1992d2..6ad039ae3cf 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -494,6 +494,8 @@ typedef enum cp_trait_kind CPTK_IS_ENUM, CPTK_IS_POD, CPTK_IS_POLYMORPHIC, + CPTK_IS_STD_LAYOUT, + CPTK_IS_TRIVIAL, CPTK_IS_UNION } cp_trait_kind; @@ -1124,6 +1126,7 @@ struct GTY(()) lang_type_class { unsigned non_aggregate : 1; unsigned has_complex_dflt : 1; unsigned has_list_ctor : 1; + unsigned non_std_layout : 1; /* When adding a flag here, consider whether or not it ought to apply to a template instance if it applies to the template. If @@ -1132,7 +1135,7 @@ struct GTY(()) lang_type_class { /* There are some bits left to fill out a 32-bit word. Keep track of this by updating the size of this bitfield whenever you add or remove a flag. */ - unsigned dummy : 10; + unsigned dummy : 9; tree primary_base; VEC(tree_pair_s,gc) *vcall_indices; @@ -1385,8 +1388,14 @@ struct GTY(()) lang_type { #define CLASSTYPE_HAS_MUTABLE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_mutable) #define TYPE_HAS_MUTABLE_P(NODE) (cp_has_mutable_p (NODE)) -/* Nonzero means that this class type is a non-POD class. */ -#define CLASSTYPE_NON_POD_P(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->non_pod_class) +/* Nonzero means that this class type is not POD for the purpose of layout + (as defined in the ABI). This is different from the language's POD. */ +#define CLASSTYPE_NON_LAYOUT_POD_P(NODE) \ + (LANG_TYPE_CLASS_CHECK (NODE)->non_pod_class) + +/* Nonzero means that this class type is a non-standard-layout class. */ +#define CLASSTYPE_NON_STD_LAYOUT(NODE) \ + (LANG_TYPE_CLASS_CHECK (NODE)->non_std_layout) /* Nonzero means that this class contains pod types whose default initialization is not a zero initialization (namely, pointers to @@ -4877,7 +4886,12 @@ extern void stabilize_aggr_init (tree, tree *); extern bool stabilize_init (tree, tree *); extern tree add_stmt_to_compound (tree, tree); extern void init_tree (void); -extern int pod_type_p (const_tree); +extern bool pod_type_p (const_tree); +extern bool layout_pod_type_p (const_tree); +extern bool std_layout_type_p (const_tree); +extern bool trivial_type_p (const_tree); +extern bool type_has_nontrivial_default_init (const_tree); +extern bool type_has_nontrivial_copy_init (const_tree); extern bool class_tmpl_impl_spec_p (const_tree); extern int zero_init_p (const_tree); extern tree strip_typedefs (tree); diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 88ae05a0e61..c42d21cb3cd 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -936,10 +936,11 @@ convert_to_void (tree expr, const char *implicit, tsubst_flags_t complain) && !AGGR_INIT_VIA_CTOR_P (init)) { tree fn = AGGR_INIT_EXPR_FN (init); - expr = build_call_array (TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), - fn, - aggr_init_expr_nargs (init), - AGGR_INIT_EXPR_ARGP (init)); + expr = build_call_array_loc (input_location, + TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), + fn, + aggr_init_expr_nargs (init), + AGGR_INIT_EXPR_ARGP (init)); } } break; diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index b8732896aa4..1d7f9cf2caf 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -659,7 +659,8 @@ pp_cxx_new_expression (cxx_pretty_printer *pp, tree t) if (TREE_CODE (type) == ARRAY_REF) type = build_cplus_array_type (TREE_OPERAND (type, 0), - build_index_type (fold_build2 (MINUS_EXPR, integer_type_node, + build_index_type (fold_build2_loc (input_location, + MINUS_EXPR, integer_type_node, TREE_OPERAND (type, 1), integer_one_node))); pp_cxx_type_id (pp, type); @@ -2296,6 +2297,12 @@ pp_cxx_trait_expression (cxx_pretty_printer *pp, tree t) case CPTK_IS_POLYMORPHIC: pp_cxx_ws_string (pp, "__is_polymorphic"); break; + case CPTK_IS_STD_LAYOUT: + pp_cxx_ws_string (pp, "__is_std_layout"); + break; + case CPTK_IS_TRIVIAL: + pp_cxx_ws_string (pp, "__is_trivial"); + break; case CPTK_IS_UNION: pp_cxx_ws_string (pp, "__is_union"); break; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e1b6678ea2d..251d0a3a5d2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2473,20 +2473,28 @@ declare_local_label (tree id) static int decl_jump_unsafe (tree decl) { + /* [stmt.dcl]/3: A program that jumps from a point where a local variable + with automatic storage duration is not in scope to a point where it is + in scope is ill-formed unless the variable has scalar type, class type + with a trivial default constructor and a trivial destructor, a + cv-qualified version of one of these types, or an array of one of the + preceding types and is declared without an initializer (8.5). */ + tree type = TREE_TYPE (decl); + if (TREE_CODE (decl) != VAR_DECL || TREE_STATIC (decl) - || TREE_TYPE (decl) == error_mark_node) + || type == error_mark_node) return 0; - if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)) + type = strip_array_types (type); + + if (type_has_nontrivial_default_init (TREE_TYPE (decl)) || DECL_NONTRIVIALLY_INITIALIZED_P (decl)) return 2; - if (pod_type_p (TREE_TYPE (decl))) - return 0; + if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl))) + return 1; - /* The POD stuff is just pedantry; why should it matter if the class - contains a field of pointer to member type? */ - return 1; + return 0; } /* A subroutine of check_previous_goto_1 to identify a branch to the user. */ @@ -2541,7 +2549,8 @@ check_previous_goto_1 (tree decl, struct cp_binding_level* level, tree names, if (problem > 1) error (" crosses initialization of %q+#D", new_decls); else - permerror (input_location, " enters scope of non-POD %q+#D", new_decls); + permerror (input_location, " enters scope of %q+#D which has " + "non-trivial destructor", new_decls); } if (b == level) @@ -2656,7 +2665,8 @@ check_goto (tree decl) else if (u > 1) error (" skips initialization of %q+#D", b); else - permerror (input_location, " enters scope of non-POD %q+#D", b); + permerror (input_location, " enters scope of %q+#D which has " + "non-trivial destructor", b); } if (ent->in_try_scope) @@ -5687,11 +5697,13 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, if (TREE_CODE (decl) == VAR_DECL) { - /* Only PODs can have thread-local storage. Other types may require - various kinds of non-trivial initialization. */ - if (DECL_THREAD_LOCAL_P (decl) && !pod_type_p (TREE_TYPE (decl))) - error ("%qD cannot be thread-local because it has non-POD type %qT", - decl, TREE_TYPE (decl)); + /* Only variables with trivial initialization and destruction can + have thread-local storage. */ + if (DECL_THREAD_LOCAL_P (decl) + && (type_has_nontrivial_default_init (TREE_TYPE (decl)) + || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))) + error ("%qD cannot be thread-local because it has non-trivial " + "type %qT", decl, TREE_TYPE (decl)); /* If this is a local variable that will need a mangled name, register it now. We must do this before processing the initializer for the variable, since the initialization might @@ -12422,9 +12434,6 @@ finish_function (int flags) f->x_return_value = NULL; f->bindings = NULL; f->extern_decl_map = NULL; - - /* Handle attribute((warn_unused_result)). Relies on gimple input. */ - c_warn_unused_result (gimple_body (fndecl)); } /* Clear out the bits we don't need. */ local_names = NULL; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 3a5d2fa929b..df79e9c4e1c 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3518,7 +3518,7 @@ cp_write_global_declarations (void) reconsider = true; } - if (!gimple_body (decl)) + if (!DECL_SAVED_TREE (decl)) continue; /* We lie to the back end, pretending that some functions @@ -3640,7 +3640,6 @@ cp_write_global_declarations (void) pop_lang_context (); cgraph_finalize_compilation_unit (); - cgraph_optimize (); /* Now, issue warnings about static, but not defined, functions, etc., and emit debugging information. */ diff --git a/gcc/cp/error.c b/gcc/cp/error.c index a0ba51a6ceb..c5310ff6ca0 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -770,7 +770,8 @@ dump_type_suffix (tree t, int flags) dump_expr (TREE_OPERAND (max, 0), flags & ~TFF_EXPR_IN_PARENS); else - dump_expr (fold_build2 (PLUS_EXPR, dtype, max, + dump_expr (fold_build2_loc (input_location, + PLUS_EXPR, dtype, max, build_int_cst (dtype, 1)), flags & ~TFF_EXPR_IN_PARENS); } @@ -2646,7 +2647,11 @@ cp_print_error_function (diagnostic_context *context, static const char * function_category (tree fn) { - if (DECL_FUNCTION_MEMBER_P (fn)) + /* We can get called from the middle-end for diagnostics of function + clones. Make sure we have language specific information before + dereferencing it. */ + if (DECL_LANG_SPECIFIC (STRIP_TEMPLATE (fn)) + && DECL_FUNCTION_MEMBER_P (fn)) { if (DECL_STATIC_FUNCTION_P (fn)) return _("In static member function %qs"); diff --git a/gcc/cp/except.c b/gcc/cp/except.c index 01512860725..fdef154f5d1 100644 --- a/gcc/cp/except.c +++ b/gcc/cp/except.c @@ -450,7 +450,8 @@ expand_start_catch_block (tree decl) exp = build_exc_ptr (); exp = build1 (NOP_EXPR, build_pointer_type (type), exp); exp = build2 (POINTER_PLUS_EXPR, TREE_TYPE (exp), exp, - fold_build1 (NEGATE_EXPR, sizetype, + fold_build1_loc (input_location, + NEGATE_EXPR, sizetype, TYPE_SIZE_UNIT (TREE_TYPE (exp)))); exp = cp_build_indirect_ref (exp, NULL, tf_warning_or_error); initialize_handler_parm (decl, exp); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 19b24895e55..3da8ab8464c 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -219,7 +219,8 @@ build_zero_init (tree type, tree nelts, bool static_storage_p) /* Iterate over the array elements, building initializations. */ if (nelts) - max_index = fold_build2 (MINUS_EXPR, TREE_TYPE (nelts), + max_index = fold_build2_loc (input_location, + MINUS_EXPR, TREE_TYPE (nelts), nelts, integer_one_node); else max_index = array_type_nelts (type); @@ -965,7 +966,8 @@ expand_cleanup_for_base (tree binfo, tree flag) LOOKUP_NORMAL | LOOKUP_NONVIRTUAL, tf_warning_or_error); if (flag) - expr = fold_build3 (COND_EXPR, void_type_node, + expr = fold_build3_loc (input_location, + COND_EXPR, void_type_node, c_common_truthvalue_conversion (input_location, flag), expr, integer_zero_node); @@ -2048,7 +2050,8 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, many elements to destroy later. We use the last sizeof (size_t) bytes to store the number of elements. */ cookie_ptr = size_binop (MINUS_EXPR, cookie_size, size_in_bytes (sizetype)); - cookie_ptr = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (alloc_node), + cookie_ptr = fold_build2_loc (input_location, + POINTER_PLUS_EXPR, TREE_TYPE (alloc_node), alloc_node, cookie_ptr); size_ptr_type = build_pointer_type (sizetype); cookie_ptr = fold_convert (size_ptr_type, cookie_ptr); @@ -2060,7 +2063,8 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, { /* Also store the element size. */ cookie_ptr = build2 (POINTER_PLUS_EXPR, size_ptr_type, cookie_ptr, - fold_build1 (NEGATE_EXPR, sizetype, + fold_build1_loc (input_location, + NEGATE_EXPR, sizetype, size_in_bytes (sizetype))); cookie = cp_build_indirect_ref (cookie_ptr, NULL, complain); @@ -2498,11 +2502,11 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, tbase = create_temporary_var (ptype); tbase_init = cp_build_modify_expr (tbase, NOP_EXPR, - fold_build2 (POINTER_PLUS_EXPR, ptype, + fold_build2_loc (input_location, + POINTER_PLUS_EXPR, ptype, fold_convert (ptype, base), virtual_size), tf_warning_or_error); - DECL_REGISTER (tbase) = 1; controller = build3 (BIND_EXPR, void_type_node, tbase, NULL_TREE, NULL_TREE); TREE_SIDE_EFFECTS (controller) = 1; @@ -2510,7 +2514,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, body = build1 (EXIT_EXPR, void_type_node, build2 (EQ_EXPR, boolean_type_node, tbase, fold_convert (ptype, base))); - tmp = fold_build1 (NEGATE_EXPR, sizetype, size_exp); + tmp = fold_build1_loc (input_location, NEGATE_EXPR, sizetype, size_exp); body = build_compound_expr (input_location, body, cp_build_modify_expr (tbase, NOP_EXPR, @@ -2575,8 +2579,9 @@ build_vec_delete_1 (tree base, tree maxindex, tree type, body = integer_zero_node; /* Outermost wrapper: If pointer is null, punt. */ - body = fold_build3 (COND_EXPR, void_type_node, - fold_build2 (NE_EXPR, boolean_type_node, base, + body = fold_build3_loc (input_location, COND_EXPR, void_type_node, + fold_build2_loc (input_location, + NE_EXPR, boolean_type_node, base, convert (TREE_TYPE (base), integer_zero_node)), body, integer_zero_node); @@ -2703,7 +2708,7 @@ build_vec_init (tree base, tree maxindex, tree init, || ! TYPE_HAS_NONTRIVIAL_DESTRUCTOR (inner_elt_type))) || from_array)) { - /* Do non-default initialization of POD arrays resulting from + /* Do non-default initialization of trivial arrays resulting from brace-enclosed initializers. In this case, digest_init and store_constructor will handle the semantics for us. */ @@ -2769,7 +2774,7 @@ build_vec_init (tree base, tree maxindex, tree init, if (init != NULL_TREE && TREE_CODE (init) == CONSTRUCTOR) { - /* Do non-default initialization of non-POD arrays resulting from + /* Do non-default initialization of non-trivial arrays resulting from brace-enclosed initializers. */ unsigned HOST_WIDE_INT idx; tree elt; @@ -3279,7 +3284,8 @@ build_vec_delete (tree base, tree maxindex, base = TARGET_EXPR_SLOT (base_init); } type = strip_array_types (TREE_TYPE (type)); - cookie_addr = fold_build1 (NEGATE_EXPR, sizetype, TYPE_SIZE_UNIT (sizetype)); + cookie_addr = fold_build1_loc (input_location, NEGATE_EXPR, + sizetype, TYPE_SIZE_UNIT (sizetype)); cookie_addr = build2 (POINTER_PLUS_EXPR, size_ptr_type, fold_convert (size_ptr_type, base), diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index c49439d0e07..1c79dcc3174 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1264,16 +1264,16 @@ write_integer_cst (const tree cst) if (sign < 0) { write_char ('n'); - n = fold_build1 (NEGATE_EXPR, type, n); + n = fold_build1_loc (input_location, NEGATE_EXPR, type, n); } do { - tree d = fold_build2 (FLOOR_DIV_EXPR, type, n, base); - tree tmp = fold_build2 (MULT_EXPR, type, d, base); + tree d = fold_build2_loc (input_location, FLOOR_DIV_EXPR, type, n, base); + tree tmp = fold_build2_loc (input_location, MULT_EXPR, type, d, base); unsigned c; done = integer_zerop (d); - tmp = fold_build2 (MINUS_EXPR, type, n, tmp); + tmp = fold_build2_loc (input_location, MINUS_EXPR, type, n, tmp); c = hwint_to_ascii (TREE_INT_CST_LOW (tmp), 10, ptr, done ? 1 : chunk_digits); ptr -= c; diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 4e22a208510..c1da08b690f 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -221,7 +221,8 @@ thunk_adjust (tree ptr, bool this_adjusting, { if (this_adjusting) /* Adjust the pointer by the constant. */ - ptr = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (ptr), ptr, + ptr = fold_build2_loc (input_location, + POINTER_PLUS_EXPR, TREE_TYPE (ptr), ptr, size_int (fixed_offset)); /* If there's a virtual offset, look up that value in the vtable and @@ -239,18 +240,21 @@ thunk_adjust (tree ptr, bool this_adjusting, /* Form the vtable address. */ vtable = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (vtable)), vtable); /* Find the entry with the vcall offset. */ - vtable = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (vtable), vtable, - fold_convert (sizetype, virtual_offset)); + vtable = fold_build2_loc (input_location, + POINTER_PLUS_EXPR, TREE_TYPE (vtable), vtable, + fold_convert (sizetype, virtual_offset)); /* Get the offset itself. */ vtable = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (vtable)), vtable); /* Adjust the `this' pointer. */ - ptr = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (ptr), ptr, + ptr = fold_build2_loc (input_location, + POINTER_PLUS_EXPR, TREE_TYPE (ptr), ptr, fold_convert (sizetype, vtable)); } if (!this_adjusting) /* Adjust the pointer by the constant. */ - ptr = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (ptr), ptr, + ptr = fold_build2_loc (input_location, + POINTER_PLUS_EXPR, TREE_TYPE (ptr), ptr, size_int (fixed_offset)); return ptr; diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index 9d4a8c5f8e4..c9d6cebb817 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic.h" #include "tree-dump.h" #include "gimple.h" +#include "tree-iterator.h" /* Prototypes. */ @@ -81,10 +82,7 @@ static void clone_body (tree clone, tree fn, void *arg_map) { copy_body_data id; - gimple_seq new_body; - - /* FN must already be in GIMPLE form. */ - gcc_assert (gimple_body (fn)); + tree stmts; /* Clone the body, as if we were making an inline call. But, remap the parameters in the callee to the parameters of caller. */ @@ -103,9 +101,9 @@ clone_body (tree clone, tree fn, void *arg_map) /* We're not inside any EH region. */ id.eh_region = -1; - /* Actually copy the body. */ - new_body = remap_gimple_seq (gimple_body (fn), &id); - gimple_set_body (clone, new_body); + stmts = DECL_SAVED_TREE (fn); + walk_tree (&stmts, copy_tree_body_r, &id, NULL); + append_to_statement_list_force (stmts, &DECL_SAVED_TREE (clone)); } /* FN is a function that has a complete body. Clone the body as @@ -208,7 +206,8 @@ maybe_clone_body (tree fn) } /* Otherwise, map the VTT parameter to `NULL'. */ else - *pointer_map_insert (decl_map, parm) = null_pointer_node; + *pointer_map_insert (decl_map, parm) + = fold_convert (TREE_TYPE (parm), null_pointer_node); } /* Map other parameters to their equivalents in the cloned function. */ @@ -237,7 +236,6 @@ maybe_clone_body (tree fn) /* Now, expand this function into RTL, if appropriate. */ finish_function (0); BLOCK_ABSTRACT_ORIGIN (DECL_INITIAL (clone)) = DECL_INITIAL (fn); - DECL_SAVED_TREE (clone) = NULL; expand_or_defer_fn (clone); first = false; } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 94fba02aa34..e64d0bf7cbd 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -3399,6 +3399,8 @@ cp_parser_primary_expression (cp_parser *parser, case RID_IS_ENUM: case RID_IS_POD: case RID_IS_POLYMORPHIC: + case RID_IS_STD_LAYOUT: + case RID_IS_TRIVIAL: case RID_IS_UNION: return cp_parser_trait_expr (parser, token->keyword); @@ -6865,6 +6867,12 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword) case RID_IS_POLYMORPHIC: kind = CPTK_IS_POLYMORPHIC; break; + case RID_IS_STD_LAYOUT: + kind = CPTK_IS_STD_LAYOUT; + break; + case RID_IS_TRIVIAL: + kind = CPTK_IS_TRIVIAL; + break; case RID_IS_UNION: kind = CPTK_IS_UNION; break; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 68250c2aff2..de9f828c645 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -9850,7 +9850,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (e1 == error_mark_node || e2 == error_mark_node) return error_mark_node; - return fold_build2 (TREE_CODE (t), TREE_TYPE (t), e1, e2); + return fold_build2_loc (input_location, + TREE_CODE (t), TREE_TYPE (t), e1, e2); } case NEGATE_EXPR: @@ -9860,7 +9861,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (e == error_mark_node) return error_mark_node; - return fold_build1 (TREE_CODE (t), TREE_TYPE (t), e); + return fold_build1_loc (input_location, TREE_CODE (t), TREE_TYPE (t), e); } case TYPENAME_TYPE: @@ -14073,12 +14074,12 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict) /* If only one of the bounds used a MINUS_EXPR, compensate by adding one to the other bound. */ if (parm_cst && !arg_cst) - parm_max = fold_build2 (PLUS_EXPR, + parm_max = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node, parm_max, integer_one_node); else if (arg_cst && !parm_cst) - arg_max = fold_build2 (PLUS_EXPR, + arg_max = fold_build2_loc (input_location, PLUS_EXPR, integer_type_node, arg_max, integer_one_node); diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index c78d92be09b..01bba3477df 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -1099,9 +1099,11 @@ get_pseudo_ti_init (tree type, unsigned tk_index) /* Combine offset and flags into one field. */ offset = fold_convert (offset_type, offset); - offset = fold_build2 (LSHIFT_EXPR, offset_type, offset, + offset = fold_build2_loc (input_location, + LSHIFT_EXPR, offset_type, offset, build_int_cst (offset_type, 8)); - offset = fold_build2 (BIT_IOR_EXPR, offset_type, offset, + offset = fold_build2_loc (input_location, + BIT_IOR_EXPR, offset_type, offset, build_int_cst (offset_type, flags)); base_init = tree_cons (NULL_TREE, offset, base_init); base_init = tree_cons (NULL_TREE, tinfo, base_init); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 61dff51ba75..23db8321431 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3129,10 +3129,11 @@ simplify_aggr_init_expr (tree *tp) style = arg; } - call_expr = build_call_array (TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), - fn, - aggr_init_expr_nargs (aggr_init_expr), - AGGR_INIT_EXPR_ARGP (aggr_init_expr)); + call_expr = build_call_array_loc (input_location, + TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), + fn, + aggr_init_expr_nargs (aggr_init_expr), + AGGR_INIT_EXPR_ARGP (aggr_init_expr)); if (style == ctor) { @@ -3229,7 +3230,7 @@ expand_or_defer_fn (tree fn) return; } - gcc_assert (gimple_body (fn)); + gcc_assert (DECL_SAVED_TREE (fn)); /* If this is a constructor or destructor body, we have to clone it. */ @@ -4878,6 +4879,7 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) switch (kind) { case CPTK_HAS_NOTHROW_ASSIGN: + type1 = strip_array_types (type1); return (!CP_TYPE_CONST_P (type1) && type_code1 != REFERENCE_TYPE && (trait_expr_value (CPTK_HAS_TRIVIAL_ASSIGN, type1, type2) || (CLASS_TYPE_P (type1) @@ -4885,8 +4887,11 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) true)))); case CPTK_HAS_TRIVIAL_ASSIGN: + /* ??? The standard seems to be missing the "or array of such a class + type" wording for this trait. */ + type1 = strip_array_types (type1); return (!CP_TYPE_CONST_P (type1) && type_code1 != REFERENCE_TYPE - && (pod_type_p (type1) + && (trivial_type_p (type1) || (CLASS_TYPE_P (type1) && TYPE_HAS_TRIVIAL_ASSIGN_REF (type1)))); @@ -4899,21 +4904,25 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_HAS_TRIVIAL_CONSTRUCTOR: type1 = strip_array_types (type1); - return (pod_type_p (type1) + return (trivial_type_p (type1) || (CLASS_TYPE_P (type1) && TYPE_HAS_TRIVIAL_DFLT (type1))); case CPTK_HAS_NOTHROW_COPY: + type1 = strip_array_types (type1); return (trait_expr_value (CPTK_HAS_TRIVIAL_COPY, type1, type2) || (CLASS_TYPE_P (type1) && classtype_has_nothrow_assign_or_copy_p (type1, false))); case CPTK_HAS_TRIVIAL_COPY: - return (pod_type_p (type1) || type_code1 == REFERENCE_TYPE + /* ??? The standard seems to be missing the "or array of such a class + type" wording for this trait. */ + type1 = strip_array_types (type1); + return (trivial_type_p (type1) || type_code1 == REFERENCE_TYPE || (CLASS_TYPE_P (type1) && TYPE_HAS_TRIVIAL_INIT_REF (type1))); case CPTK_HAS_TRIVIAL_DESTRUCTOR: type1 = strip_array_types (type1); - return (pod_type_p (type1) || type_code1 == REFERENCE_TYPE + return (trivial_type_p (type1) || type_code1 == REFERENCE_TYPE || (CLASS_TYPE_P (type1) && TYPE_HAS_TRIVIAL_DESTRUCTOR (type1))); @@ -4947,6 +4956,12 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_POLYMORPHIC: return (CLASS_TYPE_P (type1) && TYPE_POLYMORPHIC_P (type1)); + case CPTK_IS_STD_LAYOUT: + return (std_layout_type_p (type1)); + + case CPTK_IS_TRIVIAL: + return (trivial_type_p (type1)); + case CPTK_IS_UNION: return (type_code1 == UNION_TYPE); @@ -4995,6 +5010,8 @@ finish_trait_expr (cp_trait_kind kind, tree type1, tree type2) || kind == CPTK_IS_ENUM || kind == CPTK_IS_POD || kind == CPTK_IS_POLYMORPHIC + || kind == CPTK_IS_STD_LAYOUT + || kind == CPTK_IS_TRIVIAL || kind == CPTK_IS_UNION); if (kind == CPTK_IS_CONVERTIBLE_TO) @@ -5036,6 +5053,8 @@ finish_trait_expr (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_EMPTY: case CPTK_IS_POD: case CPTK_IS_POLYMORPHIC: + case CPTK_IS_STD_LAYOUT: + case CPTK_IS_TRIVIAL: if (!check_trait_type (type1)) { error ("incomplete type %qT not allowed", type1); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index a003b44e9de..83869c17a1b 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1595,7 +1595,8 @@ cxx_print_statistics (void) tree array_type_nelts_top (tree type) { - return fold_build2 (PLUS_EXPR, sizetype, + return fold_build2_loc (input_location, + PLUS_EXPR, sizetype, array_type_nelts (type), size_one_node); } @@ -1612,7 +1613,8 @@ array_type_nelts_total (tree type) while (TREE_CODE (type) == ARRAY_TYPE) { tree n = array_type_nelts_top (type); - sz = fold_build2 (MULT_EXPR, sizetype, sz, n); + sz = fold_build2_loc (input_location, + MULT_EXPR, sizetype, sz, n); type = TREE_TYPE (type); } return sz; @@ -2238,36 +2240,108 @@ is_dummy_object (const_tree ob) && TREE_OPERAND (ob, 0) == void_zero_node); } +/* Returns 1 iff type T is something we want to treat as a scalar type for + the purpose of deciding whether it is trivial/POD/standard-layout. */ + +static bool +scalarish_type_p (const_tree t) +{ + if (t == error_mark_node) + return 1; + + return (SCALAR_TYPE_P (t) + || TREE_CODE (t) == VECTOR_TYPE); +} + +/* Returns true iff T requires non-trivial default initialization. */ + +bool +type_has_nontrivial_default_init (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return TYPE_HAS_COMPLEX_DFLT (t); + else + return 0; +} + +/* Returns true iff copying an object of type T is non-trivial. */ + +bool +type_has_nontrivial_copy_init (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return TYPE_HAS_COMPLEX_INIT_REF (t); + else + return 0; +} + +/* Returns 1 iff type T is a trivial type, as defined in [basic.types]. */ + +bool +trivial_type_p (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return !(TYPE_HAS_COMPLEX_DFLT (t) + || TYPE_HAS_COMPLEX_INIT_REF (t) + || TYPE_HAS_COMPLEX_ASSIGN_REF (t) + || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)); + else + return scalarish_type_p (t); +} + /* Returns 1 iff type T is a POD type, as defined in [basic.types]. */ -int +bool pod_type_p (const_tree t) { /* This CONST_CAST is okay because strip_array_types returns its argument unmodified and we assign it to a const_tree. */ t = strip_array_types (CONST_CAST_TREE(t)); - if (t == error_mark_node) - return 1; - if (INTEGRAL_OR_ENUMERATION_TYPE_P (t)) - return 1; /* integral, character or enumeral type */ - if (FLOAT_TYPE_P (t)) - return 1; - if (TYPE_PTR_P (t)) - return 1; /* pointer to non-member */ - if (TYPE_PTR_TO_MEMBER_P (t)) - return 1; /* pointer to member */ - - if (TREE_CODE (t) == VECTOR_TYPE) - return 1; /* vectors are (small) arrays of scalars */ - - if (! RECORD_OR_UNION_CODE_P (TREE_CODE (t))) - return 0; /* other non-class type (reference or function) */ - if (! CLASS_TYPE_P (t)) - return 1; /* struct created by the back end */ - if (CLASSTYPE_NON_POD_P (t)) - return 0; - return 1; + if (CLASS_TYPE_P (t)) + /* [class]/10: A POD struct is a class that is both a trivial class and a + standard-layout class, and has no non-static data members of type + non-POD struct, non-POD union (or array of such types). + + We don't need to check individual members because if a member is + non-std-layout or non-trivial, the class will be too. */ + return (std_layout_type_p (t) && trivial_type_p (t)); + else + return scalarish_type_p (t); +} + +/* Returns true iff T is POD for the purpose of layout, as defined in the + C++ ABI. */ + +bool +layout_pod_type_p (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return !CLASSTYPE_NON_LAYOUT_POD_P (t); + else + return scalarish_type_p (t); +} + +/* Returns true iff T is a standard-layout type, as defined in + [basic.types]. */ + +bool +std_layout_type_p (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return !CLASSTYPE_NON_STD_LAYOUT (t); + else + return scalarish_type_p (t); } /* Nonzero iff type T is a class template implicit specialization. */ diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 6a4802e3375..8b684dd795e 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2017,7 +2017,7 @@ build_class_member_access_expr (tree object, tree member, in various testsuite cases where a null object is passed where a vtable access is required. */ if (null_object_p && warn_invalid_offsetof - && CLASSTYPE_NON_POD_P (object_type) + && CLASSTYPE_NON_STD_LAYOUT (object_type) && !DECL_FIELD_IS_BASE (member) && cp_unevaluated_operand == 0 && (complain & tf_warning)) @@ -2429,7 +2429,8 @@ build_ptrmemfunc_access_expr (tree ptrmem, tree member_name) /*want_type=*/false); member_type = cp_build_qualified_type (TREE_TYPE (member), cp_type_quals (ptrmem_type)); - return fold_build3 (COMPONENT_REF, member_type, + return fold_build3_loc (input_location, + COMPONENT_REF, member_type, ptrmem, member, NULL_TREE); } @@ -2836,7 +2837,8 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function) TREE_NO_WARNING (vtbl) = 1; /* Finally, extract the function pointer from the vtable. */ - e2 = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (vtbl), vtbl, + e2 = fold_build2_loc (input_location, + POINTER_PLUS_EXPR, TREE_TYPE (vtbl), vtbl, fold_convert (sizetype, idx)); e2 = cp_build_indirect_ref (e2, NULL, tf_warning_or_error); TREE_CONSTANT (e2) = 1; @@ -3134,7 +3136,7 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl, if (fndecl && DECL_BUILT_IN (fndecl) && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CONSTANT_P) /* Don't do ellipsis conversion for __built_in_constant_p - as this will result in spurious warnings for non-POD + as this will result in spurious errors for non-trivial types. */ val = require_complete_type (val); else @@ -4095,7 +4097,7 @@ cp_pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) pointer_int_sum() anyway. */ complete_type (TREE_TYPE (res_type)); - return pointer_int_sum (resultcode, ptrop, + return pointer_int_sum (input_location, resultcode, ptrop, fold_if_not_in_template (intop)); } @@ -4393,7 +4395,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, case TRUTH_NOT_EXPR: arg = perform_implicit_conversion (boolean_type_node, arg, complain); - val = invert_truthvalue (arg); + val = invert_truthvalue_loc (input_location, arg); if (arg != error_mark_node) return val; errstring = "in argument to unary !"; @@ -5201,7 +5203,8 @@ convert_ptrmem (tree type, tree expr, bool allow_inverse_p, PLUS_EXPR, op1, delta, tf_warning_or_error); - expr = fold_build3 (COND_EXPR, ptrdiff_type_node, cond, op1, op2); + expr = fold_build3_loc (input_location, + COND_EXPR, ptrdiff_type_node, cond, op1, op2); } @@ -6384,7 +6387,8 @@ get_delta_difference (tree from, tree to, result = get_delta_difference_1 (to, from, c_cast_p); if (result) - result = size_diffop (size_zero_node, result); + result = size_diffop_loc (input_location, + size_zero_node, result); else { error_not_base_type (from, to); diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 162d27f3e0a..2453bd87570 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -451,10 +451,9 @@ does not refer to anything that has gone out of scope, you should be safe. GCC implements taking the address of a nested function using a technique -called @dfn{trampolines}. A paper describing them is available as - -@noindent -@uref{http://people.debian.org/~aaronl/Usenix88-lexic.pdf}. +called @dfn{trampolines}. This technique was described in +@cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX +C++ Conference Proceedings, October 17-21, 1988). A nested function can jump to a label inherited from a containing function, provided the label was explicitly declared in the containing diff --git a/gcc/doc/gcc.texi b/gcc/doc/gcc.texi index 41031752bf2..34b89634033 100644 --- a/gcc/doc/gcc.texi +++ b/gcc/doc/gcc.texi @@ -134,6 +134,7 @@ Introduction, gccint, GNU Compiler Collection (GCC) Internals}. * Invoking GCC:: Command options supported by @samp{gcc}. * C Implementation:: How GCC implements the ISO C specification. * C Extensions:: GNU extensions to the C language family. +* C++ Implementation:: How GCC implements the ISO C++ specification. * C++ Extensions:: GNU extensions to the C++ language. * Objective-C:: GNU Objective-C runtime features. * Compatibility:: Binary Compatibility @@ -159,6 +160,7 @@ Introduction, gccint, GNU Compiler Collection (GCC) Internals}. @include standards.texi @include invoke.texi @include implement-c.texi +@include implement-cxx.texi @include extend.texi @include objc.texi @include compat.texi diff --git a/gcc/doc/implement-cxx.texi b/gcc/doc/implement-cxx.texi new file mode 100644 index 00000000000..9968f592473 --- /dev/null +++ b/gcc/doc/implement-cxx.texi @@ -0,0 +1,47 @@ +@c Copyright (C) 2009 +@c Free Software Foundation, Inc. +@c This is part of the GCC manual. +@c For copying conditions, see the file gcc.texi. + +@node C++ Implementation +@chapter C++ Implementation-defined behavior +@cindex implementation-defined behavior, C++ language + +A conforming implementation of ISO C++ is required to document its +choice of behavior in each of the areas that are designated +``implementation defined''. The following lists all such areas, +along with the section numbers from the ISO/IEC 14822:1998 and ISO/IEC +14822:2003 standards. Some areas are only implementation-defined in +one version of the standard. + +Some choices depend on the externally determined ABI for the platform +(including standard character encodings) which GCC follows; these are +listed as ``determined by ABI'' below. @xref{Compatibility, , Binary +Compatibility}, and @uref{http://gcc.gnu.org/readings.html}. Some +choices are documented in the preprocessor manual. +@xref{Implementation-defined behavior, , Implementation-defined +behavior, cpp, The C Preprocessor}. Some choices are documented in +the corresponding document for the C language. @xref{C +Implementation}. Some choices are made by the library and operating +system (or other environment when compiling for a freestanding +environment); refer to their documentation for details. + +@menu +* Conditionally-supported behavior:: +@end menu + +@node Conditionally-supported behavior +@section Conditionally-supported behavior + +@cite{Each implementation shall include documentation that identifies +all conditionally-supported constructs that it does not support (C++0x +1.4).} + +@itemize @bullet +@item +@cite{Whether an argument of class type with a non-trivial copy +constructor or destructor can be passed to ... (C++0x 5.2.2).} + +Such argument passing is not supported. + +@end itemize diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index b1f0d99497a..afc05e77037 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -161,7 +161,8 @@ in the following sections. @table @emph @item Overall Options @xref{Overall Options,,Options Controlling the Kind of Output}. -@gccoptlist{-c -S -E -o @var{file} -combine -pipe -pass-exit-codes @gol +@gccoptlist{-c -S -E -o @var{file} -combine -no-canonical-prefixes @gol +-pipe -pass-exit-codes @gol -x @var{language} -v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help @gol --version -wrapper@@@var{file} -fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg}} @@ -1306,6 +1307,12 @@ gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts diff /tmp/O2-opts /tmp/O3-opts | grep enabled @end smallexample +@item -no-canonical-prefixes +@opindex no-canonical-prefixes +Do not expand any symbolic links, resolve references to @samp{/../} +or @samp{/./}, or make the path absolute when generating a relative +prefix. + @item --version @opindex version Display the version number and copyrights of the invoked GCC@. diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index f4ca2b032ff..d9dca7a87ce 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -1972,13 +1972,40 @@ instruction per word Integer/Floating point constant that can be loaded into a register using three instructions +@item m +Memory operand. Note that on PowerPC targets, @code{m} can include +addresses that update the base register. It is therefore only safe +to use @samp{m} in an @code{asm} statement if that @code{asm} statement +accesses the operand exactly once. The @code{asm} statement must also +use @samp{%U@var{<opno>}} as a placeholder for the ``update'' flag in the +corresponding load or store instruction. For example: + +@smallexample +asm ("st%U0 %1,%0" : "=m" (mem) : "r" (val)); +@end smallexample + +is correct but: + +@smallexample +asm ("st %1,%0" : "=m" (mem) : "r" (val)); +@end smallexample + +is not. Use @code{es} rather than @code{m} if you don't want the +base register to be updated. + +@item es +A ``stable'' memory operand; that is, one which does not include any +automodification of the base register. Unlike @samp{m}, this constraint +can be used in @code{asm} statements that might access the operand +several times, or that might not access it at all. + @item Q -Memory operand that is an offset from a register (@samp{m} is preferable -for @code{asm} statements) +Memory operand that is an offset from a register (it is usually better +to use @samp{m} or @samp{es} in @code{asm} statements) @item Z -Memory operand that is an indexed or indirect from a register (@samp{m} is -preferable for @code{asm} statements) +Memory operand that is an indexed or indirect from a register (it is +usually better to use @samp{m} or @samp{es} in @code{asm} statements) @item R AIX TOC entry diff --git a/gcc/expr.c b/gcc/expr.c index b3cd2b14f73..aafa1aaca4a 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -4486,6 +4486,7 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal) rtx temp; rtx alt_rtl = NULL_RTX; int dont_return_target = 0; + location_t loc = EXPR_LOCATION (exp); if (VOID_TYPE_P (TREE_TYPE (exp))) { @@ -4561,13 +4562,13 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal) (TYPE_MODE (TREE_TYPE (exp)), SUBREG_PROMOTED_UNSIGNED_P (target)); - exp = fold_convert (ntype, exp); + exp = fold_convert_loc (loc, ntype, exp); } - exp = fold_convert (lang_hooks.types.type_for_mode - (GET_MODE (SUBREG_REG (target)), - SUBREG_PROMOTED_UNSIGNED_P (target)), - exp); + exp = fold_convert_loc (loc, lang_hooks.types.type_for_mode + (GET_MODE (SUBREG_REG (target)), + SUBREG_PROMOTED_UNSIGNED_P (target)), + exp); inner_target = SUBREG_REG (target); } @@ -4741,9 +4742,9 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal) { /* Compute the size of the data to copy from the string. */ tree copy_size - = size_binop (MIN_EXPR, - make_tree (sizetype, size), - size_int (TREE_STRING_LENGTH (exp))); + = size_binop_loc (loc, MIN_EXPR, + make_tree (sizetype, size), + size_int (TREE_STRING_LENGTH (exp))); rtx copy_size_rtx = expand_expr (copy_size, NULL_RTX, VOIDmode, (call_param_p @@ -6171,6 +6172,7 @@ array_ref_element_size (tree exp) { tree aligned_size = TREE_OPERAND (exp, 3); tree elmt_type = TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0))); + location_t loc = EXPR_LOCATION (exp); /* If a size was specified in the ARRAY_REF, it's the size measured in alignment units of the element type. So multiply by that value. */ @@ -6179,9 +6181,9 @@ array_ref_element_size (tree exp) /* ??? tree_ssa_useless_type_conversion will eliminate casts to sizetype from another type of the same width and signedness. */ if (TREE_TYPE (aligned_size) != sizetype) - aligned_size = fold_convert (sizetype, aligned_size); - return size_binop (MULT_EXPR, aligned_size, - size_int (TYPE_ALIGN_UNIT (elmt_type))); + aligned_size = fold_convert_loc (loc, sizetype, aligned_size); + return size_binop_loc (loc, MULT_EXPR, aligned_size, + size_int (TYPE_ALIGN_UNIT (elmt_type))); } /* Otherwise, take the size from that of the element type. Substitute @@ -6236,6 +6238,7 @@ component_ref_field_offset (tree exp) { tree aligned_offset = TREE_OPERAND (exp, 2); tree field = TREE_OPERAND (exp, 1); + location_t loc = EXPR_LOCATION (exp); /* If an offset was specified in the COMPONENT_REF, it's the offset measured in units of DECL_OFFSET_ALIGN / BITS_PER_UNIT. So multiply by that @@ -6245,9 +6248,10 @@ component_ref_field_offset (tree exp) /* ??? tree_ssa_useless_type_conversion will eliminate casts to sizetype from another type of the same width and signedness. */ if (TREE_TYPE (aligned_offset) != sizetype) - aligned_offset = fold_convert (sizetype, aligned_offset); - return size_binop (MULT_EXPR, aligned_offset, - size_int (DECL_OFFSET_ALIGN (field) / BITS_PER_UNIT)); + aligned_offset = fold_convert_loc (loc, sizetype, aligned_offset); + return size_binop_loc (loc, MULT_EXPR, aligned_offset, + size_int (DECL_OFFSET_ALIGN (field) + / BITS_PER_UNIT)); } /* Otherwise, take the offset from that of the field. Substitute @@ -6755,7 +6759,7 @@ emutls_var_address (tree var) tree fn = built_in_decls [BUILT_IN_EMUTLS_GET_ADDRESS]; tree arg = build_fold_addr_expr_with_type (emuvar, ptr_type_node); tree arglist = build_tree_list (NULL_TREE, arg); - tree call = build_function_call_expr (fn, arglist); + tree call = build_function_call_expr (UNKNOWN_LOCATION, fn, arglist); return fold_convert (build_pointer_type (TREE_TYPE (var)), call); } @@ -7221,6 +7225,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, bool reduce_bit_field; gimple subexp0_def, subexp1_def; tree top0, top1; + location_t loc = EXPR_LOCATION (exp); #define REDUCE_BIT_FIELD(expr) (reduce_bit_field \ ? reduce_to_bit_field_precision ((expr), \ target, \ @@ -7347,7 +7352,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, && TREE_CODE (exp) == VAR_DECL && DECL_THREAD_LOCAL_P (exp)) { - exp = build_fold_indirect_ref (emutls_var_address (exp)); + exp = build_fold_indirect_ref_loc (loc, emutls_var_address (exp)); return expand_expr_real_1 (exp, target, tmode, modifier, NULL); } @@ -7457,7 +7462,7 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, { tree type_for_mode = lang_hooks.types.type_for_mode (mode, 1); if (type_for_mode) - tmp = fold_unary (VIEW_CONVERT_EXPR, type_for_mode, exp); + tmp = fold_unary_loc (loc, VIEW_CONVERT_EXPR, type_for_mode, exp); } if (!tmp) tmp = build_constructor_from_list (type, @@ -7738,7 +7743,8 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, { tree index1 = index; tree low_bound = array_ref_low_bound (exp); - index1 = fold_convert (sizetype, TREE_OPERAND (exp, 1)); + index1 = fold_convert_loc (loc, sizetype, + TREE_OPERAND (exp, 1)); /* Optimize the special-case of a zero lower bound. @@ -7749,8 +7755,9 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, +INDEX), which becomes (ARRAY+255+INDEX). Opps!) */ if (! integer_zerop (low_bound)) - index1 = size_diffop (index1, fold_convert (sizetype, - low_bound)); + index1 = size_diffop_loc (loc, index1, + fold_convert_loc (loc, sizetype, + low_bound)); if (0 > compare_tree_int (index1, TREE_STRING_LENGTH (init))) @@ -8403,11 +8410,12 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode, /* Make sure to sign-extend the sizetype offset in a POINTER_PLUS_EXPR if sizetype precision is smaller than pointer precision. */ if (TYPE_PRECISION (sizetype) < TYPE_PRECISION (type)) - exp = build2 (PLUS_EXPR, type, - TREE_OPERAND (exp, 0), - fold_convert (type, - fold_convert (ssizetype, - TREE_OPERAND (exp, 1)))); + exp + = build2 (PLUS_EXPR, type, + TREE_OPERAND (exp, 0), + fold_convert_loc (loc, type, + fold_convert_loc (loc, ssizetype, + TREE_OPERAND (exp, 1)))); case PLUS_EXPR: /* Check if this is a case for multiplication and addition. */ @@ -9738,6 +9746,7 @@ do_store_flag (tree exp, rtx target, enum machine_mode mode) int unsignedp; rtx op0, op1; rtx subtarget = target; + location_t loc = EXPR_LOCATION (exp); arg0 = TREE_OPERAND (exp, 0); arg1 = TREE_OPERAND (exp, 1); @@ -9862,7 +9871,8 @@ do_store_flag (tree exp, rtx target, enum machine_mode mode) && integer_pow2p (TREE_OPERAND (arg0, 1))) { tree type = lang_hooks.types.type_for_mode (mode, unsignedp); - return expand_expr (fold_single_bit_test (code == NE ? NE_EXPR : EQ_EXPR, + return expand_expr (fold_single_bit_test (loc, + code == NE ? NE_EXPR : EQ_EXPR, arg0, arg1, type), target, VOIDmode, EXPAND_NORMAL); } diff --git a/gcc/flags.h b/gcc/flags.h index 42158de0015..8b71302f3e4 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -250,6 +250,9 @@ extern bool g_switch_set; /* Same for selective scheduling. */ extern bool sel_sched_switch_set; +/* Whether to run the warn_unused_result attribute pass. */ +extern bool flag_warn_unused_result; + /* Values of the -falign-* flags: how much to align labels in code. 0 means `use default', 1 means `don't align'. For each variable, there is an _log variant which is the power diff --git a/gcc/fold-const.c b/gcc/fold-const.c index f3e0614a4a6..803c7a549af 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -99,18 +99,21 @@ static bool negate_mathfn_p (enum built_in_function); static bool negate_expr_p (tree); static tree negate_expr (tree); static tree split_tree (tree, enum tree_code, tree *, tree *, tree *, int); -static tree associate_trees (tree, tree, enum tree_code, tree); +static tree associate_trees (location_t, tree, tree, enum tree_code, tree); static tree const_binop (enum tree_code, tree, tree, int); static enum comparison_code comparison_to_compcode (enum tree_code); static enum tree_code compcode_to_comparison (enum comparison_code); static int operand_equal_for_comparison_p (tree, tree, tree); static int twoval_comparison_p (tree, tree *, tree *, int *); -static tree eval_subst (tree, tree, tree, tree, tree); -static tree pedantic_omit_one_operand (tree, tree, tree); -static tree distribute_bit_expr (enum tree_code, tree, tree, tree); -static tree make_bit_field_ref (tree, tree, HOST_WIDE_INT, HOST_WIDE_INT, int); -static tree optimize_bit_field_compare (enum tree_code, tree, tree, tree); -static tree decode_field_reference (tree, HOST_WIDE_INT *, HOST_WIDE_INT *, +static tree eval_subst (location_t, tree, tree, tree, tree, tree); +static tree pedantic_omit_one_operand_loc (location_t, tree, tree, tree); +static tree distribute_bit_expr (location_t, enum tree_code, tree, tree, tree); +static tree make_bit_field_ref (location_t, tree, tree, + HOST_WIDE_INT, HOST_WIDE_INT, int); +static tree optimize_bit_field_compare (location_t, enum tree_code, + tree, tree, tree); +static tree decode_field_reference (location_t, tree, HOST_WIDE_INT *, + HOST_WIDE_INT *, enum machine_mode *, int *, int *, tree *, tree *); static int all_ones_mask_p (const_tree, int); @@ -120,23 +123,25 @@ static tree range_binop (enum tree_code, tree, tree, int, tree, int); static tree range_predecessor (tree); static tree range_successor (tree); extern tree make_range (tree, int *, tree *, tree *, bool *); -extern tree build_range_check (tree, tree, int, tree, tree); extern bool merge_ranges (int *, tree *, tree *, int, tree, tree, int, tree, tree); -static tree fold_range_test (enum tree_code, tree, tree, tree); -static tree fold_cond_expr_with_comparison (tree, tree, tree, tree); +static tree fold_range_test (location_t, enum tree_code, tree, tree, tree); +static tree fold_cond_expr_with_comparison (location_t, tree, tree, tree, tree); static tree unextend (tree, int, int, tree); -static tree fold_truthop (enum tree_code, tree, tree, tree); -static tree optimize_minmax_comparison (enum tree_code, tree, tree, tree); +static tree fold_truthop (location_t, enum tree_code, tree, tree, tree); +static tree optimize_minmax_comparison (location_t, enum tree_code, + tree, tree, tree); static tree extract_muldiv (tree, tree, enum tree_code, tree, bool *); static tree extract_muldiv_1 (tree, tree, enum tree_code, tree, bool *); -static tree fold_binary_op_with_conditional_arg (enum tree_code, tree, +static tree fold_binary_op_with_conditional_arg (location_t, + enum tree_code, tree, tree, tree, tree, tree, int); -static tree fold_mathfn_compare (enum built_in_function, enum tree_code, +static tree fold_mathfn_compare (location_t, + enum built_in_function, enum tree_code, tree, tree, tree); -static tree fold_inf_compare (enum tree_code, tree, tree, tree); -static tree fold_div_compare (enum tree_code, tree, tree, tree); +static tree fold_inf_compare (location_t, enum tree_code, tree, tree, tree); +static tree fold_div_compare (location_t, enum tree_code, tree, tree, tree); static bool reorder_operands_p (const_tree, const_tree); static tree fold_negate_const (tree, tree); static tree fold_not_const (tree, tree); @@ -1232,7 +1237,7 @@ negate_expr_p (tree t) returned. */ static tree -fold_negate_expr (tree t) +fold_negate_expr (location_t loc, tree t) { tree type = TREE_TYPE (t); tree tem; @@ -1242,7 +1247,7 @@ fold_negate_expr (tree t) /* Convert - (~A) to A + 1. */ case BIT_NOT_EXPR: if (INTEGRAL_TYPE_P (type)) - return fold_build2 (PLUS_EXPR, type, TREE_OPERAND (t, 0), + return fold_build2_loc (loc, PLUS_EXPR, type, TREE_OPERAND (t, 0), build_int_cst (type, 1)); break; @@ -1279,15 +1284,15 @@ fold_negate_expr (tree t) case COMPLEX_EXPR: if (negate_expr_p (t)) - return fold_build2 (COMPLEX_EXPR, type, - fold_negate_expr (TREE_OPERAND (t, 0)), - fold_negate_expr (TREE_OPERAND (t, 1))); + return fold_build2_loc (loc, COMPLEX_EXPR, type, + fold_negate_expr (loc, TREE_OPERAND (t, 0)), + fold_negate_expr (loc, TREE_OPERAND (t, 1))); break; case CONJ_EXPR: if (negate_expr_p (t)) - return fold_build1 (CONJ_EXPR, type, - fold_negate_expr (TREE_OPERAND (t, 0))); + return fold_build1_loc (loc, CONJ_EXPR, type, + fold_negate_expr (loc, TREE_OPERAND (t, 0))); break; case NEGATE_EXPR: @@ -1303,7 +1308,7 @@ fold_negate_expr (tree t) TREE_OPERAND (t, 1))) { tem = negate_expr (TREE_OPERAND (t, 1)); - return fold_build2 (MINUS_EXPR, type, + return fold_build2_loc (loc, MINUS_EXPR, type, tem, TREE_OPERAND (t, 0)); } @@ -1311,7 +1316,7 @@ fold_negate_expr (tree t) if (negate_expr_p (TREE_OPERAND (t, 0))) { tem = negate_expr (TREE_OPERAND (t, 0)); - return fold_build2 (MINUS_EXPR, type, + return fold_build2_loc (loc, MINUS_EXPR, type, tem, TREE_OPERAND (t, 1)); } } @@ -1322,7 +1327,7 @@ fold_negate_expr (tree t) if (!HONOR_SIGN_DEPENDENT_ROUNDING (TYPE_MODE (type)) && !HONOR_SIGNED_ZEROS (TYPE_MODE (type)) && reorder_operands_p (TREE_OPERAND (t, 0), TREE_OPERAND (t, 1))) - return fold_build2 (MINUS_EXPR, type, + return fold_build2_loc (loc, MINUS_EXPR, type, TREE_OPERAND (t, 1), TREE_OPERAND (t, 0)); break; @@ -1337,11 +1342,11 @@ fold_negate_expr (tree t) { tem = TREE_OPERAND (t, 1); if (negate_expr_p (tem)) - return fold_build2 (TREE_CODE (t), type, + return fold_build2_loc (loc, TREE_CODE (t), type, TREE_OPERAND (t, 0), negate_expr (tem)); tem = TREE_OPERAND (t, 0); if (negate_expr_p (tem)) - return fold_build2 (TREE_CODE (t), type, + return fold_build2_loc (loc, TREE_CODE (t), type, negate_expr (tem), TREE_OPERAND (t, 1)); } break; @@ -1367,7 +1372,7 @@ fold_negate_expr (tree t) && (TREE_CODE (tem) != INTEGER_CST || integer_onep (tem))) fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MISC); - return fold_build2 (TREE_CODE (t), type, + return fold_build2_loc (loc, TREE_CODE (t), type, TREE_OPERAND (t, 0), negate_expr (tem)); } tem = TREE_OPERAND (t, 0); @@ -1377,7 +1382,7 @@ fold_negate_expr (tree t) && (TREE_CODE (tem) != INTEGER_CST || tree_int_cst_equal (tem, TYPE_MIN_VALUE (type)))) fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MISC); - return fold_build2 (TREE_CODE (t), type, + return fold_build2_loc (loc, TREE_CODE (t), type, negate_expr (tem), TREE_OPERAND (t, 1)); } } @@ -1389,7 +1394,7 @@ fold_negate_expr (tree t) { tem = strip_float_extensions (t); if (tem != t && negate_expr_p (tem)) - return fold_convert (type, negate_expr (tem)); + return fold_convert_loc (loc, type, negate_expr (tem)); } break; @@ -1402,7 +1407,7 @@ fold_negate_expr (tree t) fndecl = get_callee_fndecl (t); arg = negate_expr (CALL_EXPR_ARG (t, 0)); - return build_call_expr (fndecl, 1, arg); + return build_call_expr_loc (loc, fndecl, 1, arg); } break; @@ -1418,9 +1423,9 @@ fold_negate_expr (tree t) tree ntype = TYPE_UNSIGNED (type) ? signed_type_for (type) : unsigned_type_for (type); - tree temp = fold_convert (ntype, TREE_OPERAND (t, 0)); - temp = fold_build2 (RSHIFT_EXPR, ntype, temp, op1); - return fold_convert (type, temp); + tree temp = fold_convert_loc (loc, ntype, TREE_OPERAND (t, 0)); + temp = fold_build2_loc (loc, RSHIFT_EXPR, ntype, temp, op1); + return fold_convert_loc (loc, type, temp); } } break; @@ -1440,17 +1445,22 @@ static tree negate_expr (tree t) { tree type, tem; + location_t loc; if (t == NULL_TREE) return NULL_TREE; + loc = EXPR_LOCATION (t); type = TREE_TYPE (t); STRIP_SIGN_NOPS (t); - tem = fold_negate_expr (t); + tem = fold_negate_expr (loc, t); if (!tem) - tem = build1 (NEGATE_EXPR, TREE_TYPE (t), t); - return fold_convert (type, tem); + { + tem = build1 (NEGATE_EXPR, TREE_TYPE (t), t); + SET_EXPR_LOCATION (tem, loc); + } + return fold_convert_loc (loc, type, tem); } /* Split a tree IN into a constant, literal and variable parts that could be @@ -1552,13 +1562,16 @@ split_tree (tree in, enum tree_code code, tree *conp, tree *litp, return var; } -/* Re-associate trees split by the above function. T1 and T2 are either - expressions to associate or null. Return the new expression, if any. If +/* Re-associate trees split by the above function. T1 and T2 are + either expressions to associate or null. Return the new + expression, if any. LOC is the location of the new expression. If we build an operation, do it in TYPE and with CODE. */ static tree -associate_trees (tree t1, tree t2, enum tree_code code, tree type) +associate_trees (location_t loc, tree t1, tree t2, enum tree_code code, tree type) { + tree tem; + if (t1 == 0) return t2; else if (t2 == 0) @@ -1573,26 +1586,30 @@ associate_trees (tree t1, tree t2, enum tree_code code, tree type) if (code == PLUS_EXPR) { if (TREE_CODE (t1) == NEGATE_EXPR) - return build2 (MINUS_EXPR, type, fold_convert (type, t2), - fold_convert (type, TREE_OPERAND (t1, 0))); + tem = build2 (MINUS_EXPR, type, fold_convert_loc (loc, type, t2), + fold_convert_loc (loc, type, TREE_OPERAND (t1, 0))); else if (TREE_CODE (t2) == NEGATE_EXPR) - return build2 (MINUS_EXPR, type, fold_convert (type, t1), - fold_convert (type, TREE_OPERAND (t2, 0))); + tem = build2 (MINUS_EXPR, type, fold_convert_loc (loc, type, t1), + fold_convert_loc (loc, type, TREE_OPERAND (t2, 0))); else if (integer_zerop (t2)) - return fold_convert (type, t1); + return fold_convert_loc (loc, type, t1); } else if (code == MINUS_EXPR) { if (integer_zerop (t2)) - return fold_convert (type, t1); + return fold_convert_loc (loc, type, t1); } - return build2 (code, type, fold_convert (type, t1), - fold_convert (type, t2)); + tem = build2 (code, type, fold_convert_loc (loc, type, t1), + fold_convert_loc (loc, type, t2)); + goto associate_trees_exit; } - return fold_build2 (code, type, fold_convert (type, t1), - fold_convert (type, t2)); + return fold_build2_loc (loc, code, type, fold_convert_loc (loc, type, t1), + fold_convert_loc (loc, type, t2)); + associate_trees_exit: + protected_set_expr_location (tem, loc); + return tem; } /* Check whether TYPE1 and TYPE2 are equivalent integer types, suitable @@ -2061,7 +2078,7 @@ size_int_kind (HOST_WIDE_INT number, enum size_type_kind kind) If the operands are constant, so is the result. */ tree -size_binop (enum tree_code code, tree arg0, tree arg1) +size_binop_loc (location_t loc, enum tree_code code, tree arg0, tree arg1) { tree type = TREE_TYPE (arg0); @@ -2097,7 +2114,7 @@ size_binop (enum tree_code code, tree arg0, tree arg1) return int_const_binop (code, arg0, arg1, 0); } - return fold_build2 (code, type, arg0, arg1); + return fold_build2_loc (loc, code, type, arg0, arg1); } /* Given two values, either both of sizetype or both of bitsizetype, @@ -2105,7 +2122,7 @@ size_binop (enum tree_code code, tree arg0, tree arg1) in signed type corresponding to the type of the operands. */ tree -size_diffop (tree arg0, tree arg1) +size_diffop_loc (location_t loc, tree arg0, tree arg1) { tree type = TREE_TYPE (arg0); tree ctype; @@ -2115,7 +2132,7 @@ size_diffop (tree arg0, tree arg1) /* If the type is already signed, just do the simple thing. */ if (!TYPE_UNSIGNED (type)) - return size_binop (MINUS_EXPR, arg0, arg1); + return size_binop_loc (loc, MINUS_EXPR, arg0, arg1); if (type == sizetype) ctype = ssizetype; @@ -2128,8 +2145,9 @@ size_diffop (tree arg0, tree arg1) type and subtract. The hardware will do the right thing with any overflow in the subtraction. */ if (TREE_CODE (arg0) != INTEGER_CST || TREE_CODE (arg1) != INTEGER_CST) - return size_binop (MINUS_EXPR, fold_convert (ctype, arg0), - fold_convert (ctype, arg1)); + return size_binop_loc (loc, MINUS_EXPR, + fold_convert_loc (loc, ctype, arg0), + fold_convert_loc (loc, ctype, arg1)); /* If ARG0 is larger than ARG1, subtract and return the result in CTYPE. Otherwise, subtract the other way, convert to CTYPE (we know that can't @@ -2138,11 +2156,14 @@ size_diffop (tree arg0, tree arg1) if (tree_int_cst_equal (arg0, arg1)) return build_int_cst (ctype, 0); else if (tree_int_cst_lt (arg1, arg0)) - return fold_convert (ctype, size_binop (MINUS_EXPR, arg0, arg1)); + return fold_convert_loc (loc, ctype, + size_binop_loc (loc, MINUS_EXPR, arg0, arg1)); else - return size_binop (MINUS_EXPR, build_int_cst (ctype, 0), - fold_convert (ctype, size_binop (MINUS_EXPR, - arg1, arg0))); + return size_binop_loc (loc, MINUS_EXPR, build_int_cst (ctype, 0), + fold_convert_loc (loc, ctype, + size_binop_loc (loc, + MINUS_EXPR, + arg1, arg0))); } /* A subroutine of fold_convert_const handling conversions of an @@ -2529,7 +2550,7 @@ fold_convertible_p (const_tree type, const_tree arg) simple conversions in preference to calling the front-end's convert. */ tree -fold_convert (tree type, tree arg) +fold_convert_loc (location_t loc, tree type, tree arg) { tree orig = TREE_TYPE (arg); tree tem; @@ -2543,7 +2564,7 @@ fold_convert (tree type, tree arg) return error_mark_node; if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (orig)) - return fold_build1 (NOP_EXPR, type, arg); + return fold_build1_loc (loc, NOP_EXPR, type, arg); switch (TREE_CODE (type)) { @@ -2558,15 +2579,14 @@ fold_convert (tree type, tree arg) } if (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig) || TREE_CODE (orig) == OFFSET_TYPE) - return fold_build1 (NOP_EXPR, type, arg); + return fold_build1_loc (loc, NOP_EXPR, type, arg); if (TREE_CODE (orig) == COMPLEX_TYPE) - { - tem = fold_build1 (REALPART_EXPR, TREE_TYPE (orig), arg); - return fold_convert (type, tem); - } + return fold_convert_loc (loc, type, + fold_build1_loc (loc, REALPART_EXPR, + TREE_TYPE (orig), arg)); gcc_assert (TREE_CODE (orig) == VECTOR_TYPE && tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (orig))); - return fold_build1 (NOP_EXPR, type, arg); + return fold_build1_loc (loc, NOP_EXPR, type, arg); case REAL_TYPE: if (TREE_CODE (arg) == INTEGER_CST) @@ -2593,17 +2613,17 @@ fold_convert (tree type, tree arg) case INTEGER_TYPE: case BOOLEAN_TYPE: case ENUMERAL_TYPE: case POINTER_TYPE: case REFERENCE_TYPE: - return fold_build1 (FLOAT_EXPR, type, arg); + return fold_build1_loc (loc, FLOAT_EXPR, type, arg); case REAL_TYPE: - return fold_build1 (NOP_EXPR, type, arg); + return fold_build1_loc (loc, NOP_EXPR, type, arg); case FIXED_POINT_TYPE: - return fold_build1 (FIXED_CONVERT_EXPR, type, arg); + return fold_build1_loc (loc, FIXED_CONVERT_EXPR, type, arg); case COMPLEX_TYPE: - tem = fold_build1 (REALPART_EXPR, TREE_TYPE (orig), arg); - return fold_convert (type, tem); + tem = fold_build1_loc (loc, REALPART_EXPR, TREE_TYPE (orig), arg); + return fold_convert_loc (loc, type, tem); default: gcc_unreachable (); @@ -2615,7 +2635,7 @@ fold_convert (tree type, tree arg) { tem = fold_convert_const (FIXED_CONVERT_EXPR, type, arg); if (tem != NULL_TREE) - return tem; + goto fold_convert_exit; } switch (TREE_CODE (orig)) @@ -2625,11 +2645,11 @@ fold_convert (tree type, tree arg) case ENUMERAL_TYPE: case BOOLEAN_TYPE: case REAL_TYPE: - return fold_build1 (FIXED_CONVERT_EXPR, type, arg); + return fold_build1_loc (loc, FIXED_CONVERT_EXPR, type, arg); case COMPLEX_TYPE: - tem = fold_build1 (REALPART_EXPR, TREE_TYPE (orig), arg); - return fold_convert (type, tem); + tem = fold_build1_loc (loc, REALPART_EXPR, TREE_TYPE (orig), arg); + return fold_convert_loc (loc, type, tem); default: gcc_unreachable (); @@ -2643,9 +2663,9 @@ fold_convert (tree type, tree arg) case POINTER_TYPE: case REFERENCE_TYPE: case REAL_TYPE: case FIXED_POINT_TYPE: - return fold_build2 (COMPLEX_EXPR, type, - fold_convert (TREE_TYPE (type), arg), - fold_convert (TREE_TYPE (type), + return fold_build2_loc (loc, COMPLEX_EXPR, type, + fold_convert_loc (loc, TREE_TYPE (type), arg), + fold_convert_loc (loc, TREE_TYPE (type), integer_zero_node)); case COMPLEX_TYPE: { @@ -2653,17 +2673,19 @@ fold_convert (tree type, tree arg) if (TREE_CODE (arg) == COMPLEX_EXPR) { - rpart = fold_convert (TREE_TYPE (type), TREE_OPERAND (arg, 0)); - ipart = fold_convert (TREE_TYPE (type), TREE_OPERAND (arg, 1)); - return fold_build2 (COMPLEX_EXPR, type, rpart, ipart); + rpart = fold_convert_loc (loc, TREE_TYPE (type), + TREE_OPERAND (arg, 0)); + ipart = fold_convert_loc (loc, TREE_TYPE (type), + TREE_OPERAND (arg, 1)); + return fold_build2_loc (loc, COMPLEX_EXPR, type, rpart, ipart); } arg = save_expr (arg); - rpart = fold_build1 (REALPART_EXPR, TREE_TYPE (orig), arg); - ipart = fold_build1 (IMAGPART_EXPR, TREE_TYPE (orig), arg); - rpart = fold_convert (TREE_TYPE (type), rpart); - ipart = fold_convert (TREE_TYPE (type), ipart); - return fold_build2 (COMPLEX_EXPR, type, rpart, ipart); + rpart = fold_build1_loc (loc, REALPART_EXPR, TREE_TYPE (orig), arg); + ipart = fold_build1_loc (loc, IMAGPART_EXPR, TREE_TYPE (orig), arg); + rpart = fold_convert_loc (loc, TREE_TYPE (type), rpart); + ipart = fold_convert_loc (loc, TREE_TYPE (type), ipart); + return fold_build2_loc (loc, COMPLEX_EXPR, type, rpart, ipart); } default: @@ -2676,17 +2698,20 @@ fold_convert (tree type, tree arg) gcc_assert (tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (orig))); gcc_assert (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig) || TREE_CODE (orig) == VECTOR_TYPE); - return fold_build1 (VIEW_CONVERT_EXPR, type, arg); + return fold_build1_loc (loc, VIEW_CONVERT_EXPR, type, arg); case VOID_TYPE: tem = fold_ignored_result (arg); if (TREE_CODE (tem) == MODIFY_EXPR) - return tem; - return fold_build1 (NOP_EXPR, type, tem); + goto fold_convert_exit; + return fold_build1_loc (loc, NOP_EXPR, type, tem); default: gcc_unreachable (); } + fold_convert_exit: + protected_set_expr_location (tem, loc); + return tem; } /* Return false if expr can be assumed not to be an lvalue, true @@ -2743,7 +2768,7 @@ maybe_lvalue_p (const_tree x) /* Return an expr equal to X but certainly not valid as an lvalue. */ tree -non_lvalue (tree x) +non_lvalue_loc (location_t loc, tree x) { /* While we are in GIMPLE, NON_LVALUE_EXPR doesn't mean anything to us. */ @@ -2752,7 +2777,9 @@ non_lvalue (tree x) if (! maybe_lvalue_p (x)) return x; - return build1 (NON_LVALUE_EXPR, TREE_TYPE (x), x); + x = build1 (NON_LVALUE_EXPR, TREE_TYPE (x), x); + SET_EXPR_LOCATION (x, loc); + return x; } /* Nonzero means lvalues are limited to those valid in pedantic ANSI C. @@ -2764,12 +2791,12 @@ int pedantic_lvalues; pedantic lvalue. Otherwise, return X. */ static tree -pedantic_non_lvalue (tree x) +pedantic_non_lvalue_loc (location_t loc, tree x) { if (pedantic_lvalues) - return non_lvalue (x); - else - return x; + return non_lvalue_loc (loc, x); + protected_set_expr_location (x, loc); + return x; } /* Given a tree comparison code, return the code that is the logical inverse @@ -2946,7 +2973,8 @@ compcode_to_comparison (enum comparison_code code) if this makes the transformation invalid. */ tree -combine_comparisons (enum tree_code code, enum tree_code lcode, +combine_comparisons (location_t loc, + enum tree_code code, enum tree_code lcode, enum tree_code rcode, tree truth_type, tree ll_arg, tree lr_arg) { @@ -3023,7 +3051,7 @@ combine_comparisons (enum tree_code code, enum tree_code lcode, enum tree_code tcode; tcode = compcode_to_comparison ((enum comparison_code) compcode); - return fold_build2 (tcode, truth_type, ll_arg, lr_arg); + return fold_build2_loc (loc, tcode, truth_type, ll_arg, lr_arg); } } @@ -3513,7 +3541,8 @@ twoval_comparison_p (tree arg, tree *cval1, tree *cval2, int *save_p) NEW1 and OLD1. */ static tree -eval_subst (tree arg, tree old0, tree new0, tree old1, tree new1) +eval_subst (location_t loc, tree arg, tree old0, tree new0, + tree old1, tree new1) { tree type = TREE_TYPE (arg); enum tree_code code = TREE_CODE (arg); @@ -3529,33 +3558,35 @@ eval_subst (tree arg, tree old0, tree new0, tree old1, tree new1) switch (tclass) { case tcc_unary: - return fold_build1 (code, type, - eval_subst (TREE_OPERAND (arg, 0), + return fold_build1_loc (loc, code, type, + eval_subst (loc, TREE_OPERAND (arg, 0), old0, new0, old1, new1)); case tcc_binary: - return fold_build2 (code, type, - eval_subst (TREE_OPERAND (arg, 0), + return fold_build2_loc (loc, code, type, + eval_subst (loc, TREE_OPERAND (arg, 0), old0, new0, old1, new1), - eval_subst (TREE_OPERAND (arg, 1), + eval_subst (loc, TREE_OPERAND (arg, 1), old0, new0, old1, new1)); case tcc_expression: switch (code) { case SAVE_EXPR: - return eval_subst (TREE_OPERAND (arg, 0), old0, new0, old1, new1); + return eval_subst (loc, TREE_OPERAND (arg, 0), old0, new0, + old1, new1); case COMPOUND_EXPR: - return eval_subst (TREE_OPERAND (arg, 1), old0, new0, old1, new1); + return eval_subst (loc, TREE_OPERAND (arg, 1), old0, new0, + old1, new1); case COND_EXPR: - return fold_build3 (code, type, - eval_subst (TREE_OPERAND (arg, 0), + return fold_build3_loc (loc, code, type, + eval_subst (loc, TREE_OPERAND (arg, 0), old0, new0, old1, new1), - eval_subst (TREE_OPERAND (arg, 1), + eval_subst (loc, TREE_OPERAND (arg, 1), old0, new0, old1, new1), - eval_subst (TREE_OPERAND (arg, 2), + eval_subst (loc, TREE_OPERAND (arg, 2), old0, new0, old1, new1)); default: break; @@ -3581,7 +3612,7 @@ eval_subst (tree arg, tree old0, tree new0, tree old1, tree new1) else if (arg1 == old1 || operand_equal_p (arg1, old1, 0)) arg1 = new1; - return fold_build2 (code, type, arg0, arg1); + return fold_build2_loc (loc, code, type, arg0, arg1); } default: @@ -3597,37 +3628,58 @@ eval_subst (tree arg, tree old0, tree new0, tree old1, tree new1) the conversion of RESULT to TYPE. */ tree -omit_one_operand (tree type, tree result, tree omitted) +omit_one_operand_loc (location_t loc, tree type, tree result, tree omitted) { - tree t = fold_convert (type, result); + tree t = fold_convert_loc (loc, type, result); /* If the resulting operand is an empty statement, just return the omitted statement casted to void. */ if (IS_EMPTY_STMT (t) && TREE_SIDE_EFFECTS (omitted)) - return build1 (NOP_EXPR, void_type_node, fold_ignored_result (omitted)); + { + t = build1 (NOP_EXPR, void_type_node, fold_ignored_result (omitted)); + goto omit_one_operand_exit; + } if (TREE_SIDE_EFFECTS (omitted)) - return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t); + { + t = build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t); + goto omit_one_operand_exit; + } + + return non_lvalue_loc (loc, t); - return non_lvalue (t); + omit_one_operand_exit: + protected_set_expr_location (t, loc); + return t; } /* Similar, but call pedantic_non_lvalue instead of non_lvalue. */ static tree -pedantic_omit_one_operand (tree type, tree result, tree omitted) +pedantic_omit_one_operand_loc (location_t loc, tree type, tree result, + tree omitted) { - tree t = fold_convert (type, result); + tree t = fold_convert_loc (loc, type, result); /* If the resulting operand is an empty statement, just return the omitted statement casted to void. */ if (IS_EMPTY_STMT (t) && TREE_SIDE_EFFECTS (omitted)) - return build1 (NOP_EXPR, void_type_node, fold_ignored_result (omitted)); + { + t = build1 (NOP_EXPR, void_type_node, fold_ignored_result (omitted)); + goto pedantic_omit_one_operand_exit; + } if (TREE_SIDE_EFFECTS (omitted)) - return build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t); + { + t = build2 (COMPOUND_EXPR, type, fold_ignored_result (omitted), t); + goto pedantic_omit_one_operand_exit; + } + + return pedantic_non_lvalue_loc (loc, t); - return pedantic_non_lvalue (t); + pedantic_omit_one_operand_exit: + protected_set_expr_location (t, loc); + return t; } /* Return a tree for the case when the result of an expression is RESULT @@ -3640,16 +3692,23 @@ pedantic_omit_one_operand (tree type, tree result, tree omitted) just do the conversion of RESULT to TYPE. */ tree -omit_two_operands (tree type, tree result, tree omitted1, tree omitted2) +omit_two_operands_loc (location_t loc, tree type, tree result, + tree omitted1, tree omitted2) { - tree t = fold_convert (type, result); + tree t = fold_convert_loc (loc, type, result); if (TREE_SIDE_EFFECTS (omitted2)) - t = build2 (COMPOUND_EXPR, type, omitted2, t); + { + t = build2 (COMPOUND_EXPR, type, omitted2, t); + SET_EXPR_LOCATION (t, loc); + } if (TREE_SIDE_EFFECTS (omitted1)) - t = build2 (COMPOUND_EXPR, type, omitted1, t); + { + t = build2 (COMPOUND_EXPR, type, omitted1, t); + SET_EXPR_LOCATION (t, loc); + } - return TREE_CODE (t) != COMPOUND_EXPR ? non_lvalue (t) : t; + return TREE_CODE (t) != COMPOUND_EXPR ? non_lvalue_loc (loc, t) : t; } @@ -3661,10 +3720,11 @@ omit_two_operands (tree type, tree result, tree omitted1, tree omitted2) problems with the dominator optimizer. */ tree -fold_truth_not_expr (tree arg) +fold_truth_not_expr (location_t loc, tree arg) { tree t, type = TREE_TYPE (arg); enum tree_code code = TREE_CODE (arg); + location_t loc1, loc2; /* If this is a comparison, we can simply invert it, except for floating-point non-equality comparisons, in which case we just @@ -3684,8 +3744,7 @@ fold_truth_not_expr (tree arg) return NULL_TREE; t = build2 (code, type, TREE_OPERAND (arg, 0), TREE_OPERAND (arg, 1)); - if (EXPR_HAS_LOCATION (arg)) - SET_EXPR_LOCATION (t, EXPR_LOCATION (arg)); + SET_EXPR_LOCATION (t, loc); return t; } @@ -3695,15 +3754,27 @@ fold_truth_not_expr (tree arg) return constant_boolean_node (integer_zerop (arg), type); case TRUTH_AND_EXPR: + loc1 = EXPR_LOCATION (TREE_OPERAND (arg, 0)); + loc2 = EXPR_LOCATION (TREE_OPERAND (arg, 1)); + if (loc1 == UNKNOWN_LOCATION) + loc1 = loc; + if (loc2 == UNKNOWN_LOCATION) + loc2 = loc; t = build2 (TRUTH_OR_EXPR, type, - invert_truthvalue (TREE_OPERAND (arg, 0)), - invert_truthvalue (TREE_OPERAND (arg, 1))); + invert_truthvalue_loc (loc1, TREE_OPERAND (arg, 0)), + invert_truthvalue_loc (loc2, TREE_OPERAND (arg, 1))); break; case TRUTH_OR_EXPR: + loc1 = EXPR_LOCATION (TREE_OPERAND (arg, 0)); + loc2 = EXPR_LOCATION (TREE_OPERAND (arg, 1)); + if (loc1 == UNKNOWN_LOCATION) + loc1 = loc; + if (loc2 == UNKNOWN_LOCATION) + loc2 = loc; t = build2 (TRUTH_AND_EXPR, type, - invert_truthvalue (TREE_OPERAND (arg, 0)), - invert_truthvalue (TREE_OPERAND (arg, 1))); + invert_truthvalue_loc (loc1, TREE_OPERAND (arg, 0)), + invert_truthvalue_loc (loc2, TREE_OPERAND (arg, 1))); break; case TRUTH_XOR_EXPR: @@ -3717,20 +3788,32 @@ fold_truth_not_expr (tree arg) TREE_OPERAND (TREE_OPERAND (arg, 1), 0)); else t = build2 (TRUTH_XOR_EXPR, type, - invert_truthvalue (TREE_OPERAND (arg, 0)), + invert_truthvalue_loc (loc, TREE_OPERAND (arg, 0)), TREE_OPERAND (arg, 1)); break; case TRUTH_ANDIF_EXPR: + loc1 = EXPR_LOCATION (TREE_OPERAND (arg, 0)); + loc2 = EXPR_LOCATION (TREE_OPERAND (arg, 1)); + if (loc1 == UNKNOWN_LOCATION) + loc1 = loc; + if (loc2 == UNKNOWN_LOCATION) + loc2 = loc; t = build2 (TRUTH_ORIF_EXPR, type, - invert_truthvalue (TREE_OPERAND (arg, 0)), - invert_truthvalue (TREE_OPERAND (arg, 1))); + invert_truthvalue_loc (loc1, TREE_OPERAND (arg, 0)), + invert_truthvalue_loc (loc2, TREE_OPERAND (arg, 1))); break; case TRUTH_ORIF_EXPR: + loc1 = EXPR_LOCATION (TREE_OPERAND (arg, 0)); + loc2 = EXPR_LOCATION (TREE_OPERAND (arg, 1)); + if (loc1 == UNKNOWN_LOCATION) + loc1 = loc; + if (loc2 == UNKNOWN_LOCATION) + loc2 = loc; t = build2 (TRUTH_ANDIF_EXPR, type, - invert_truthvalue (TREE_OPERAND (arg, 0)), - invert_truthvalue (TREE_OPERAND (arg, 1))); + invert_truthvalue_loc (loc1, TREE_OPERAND (arg, 0)), + invert_truthvalue_loc (loc2, TREE_OPERAND (arg, 1))); break; case TRUTH_NOT_EXPR: @@ -3740,24 +3823,39 @@ fold_truth_not_expr (tree arg) { tree arg1 = TREE_OPERAND (arg, 1); tree arg2 = TREE_OPERAND (arg, 2); + + loc1 = EXPR_LOCATION (TREE_OPERAND (arg, 1)); + loc2 = EXPR_LOCATION (TREE_OPERAND (arg, 2)); + if (loc1 == UNKNOWN_LOCATION) + loc1 = loc; + if (loc2 == UNKNOWN_LOCATION) + loc2 = loc; + /* A COND_EXPR may have a throw as one operand, which then has void type. Just leave void operands as they are. */ t = build3 (COND_EXPR, type, TREE_OPERAND (arg, 0), VOID_TYPE_P (TREE_TYPE (arg1)) - ? arg1 : invert_truthvalue (arg1), + ? arg1 : invert_truthvalue_loc (loc1, arg1), VOID_TYPE_P (TREE_TYPE (arg2)) - ? arg2 : invert_truthvalue (arg2)); + ? arg2 : invert_truthvalue_loc (loc2, arg2)); break; } case COMPOUND_EXPR: - t = build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg, 0), - invert_truthvalue (TREE_OPERAND (arg, 1))); + loc1 = EXPR_LOCATION (TREE_OPERAND (arg, 1)); + if (loc1 == UNKNOWN_LOCATION) + loc1 = loc; + t = build2 (COMPOUND_EXPR, type, + TREE_OPERAND (arg, 0), + invert_truthvalue_loc (loc1, TREE_OPERAND (arg, 1))); break; case NON_LVALUE_EXPR: - return invert_truthvalue (TREE_OPERAND (arg, 0)); + loc1 = EXPR_LOCATION (TREE_OPERAND (arg, 0)); + if (loc1 == UNKNOWN_LOCATION) + loc1 = loc; + return invert_truthvalue_loc (loc1, TREE_OPERAND (arg, 0)); CASE_CONVERT: if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE) @@ -3769,8 +3867,11 @@ fold_truth_not_expr (tree arg) /* ... fall through ... */ case FLOAT_EXPR: + loc1 = EXPR_LOCATION (TREE_OPERAND (arg, 0)); + if (loc1 == UNKNOWN_LOCATION) + loc1 = loc; t = build1 (TREE_CODE (arg), type, - invert_truthvalue (TREE_OPERAND (arg, 0))); + invert_truthvalue_loc (loc1, TREE_OPERAND (arg, 0))); break; case BIT_AND_EXPR: @@ -3784,8 +3885,11 @@ fold_truth_not_expr (tree arg) break; case CLEANUP_POINT_EXPR: + loc1 = EXPR_LOCATION (TREE_OPERAND (arg, 0)); + if (loc1 == UNKNOWN_LOCATION) + loc1 = loc; t = build1 (CLEANUP_POINT_EXPR, type, - invert_truthvalue (TREE_OPERAND (arg, 0))); + invert_truthvalue_loc (loc1, TREE_OPERAND (arg, 0))); break; default: @@ -3793,8 +3897,8 @@ fold_truth_not_expr (tree arg) break; } - if (t && EXPR_HAS_LOCATION (arg)) - SET_EXPR_LOCATION (t, EXPR_LOCATION (arg)); + if (t) + SET_EXPR_LOCATION (t, loc); return t; } @@ -3807,16 +3911,19 @@ fold_truth_not_expr (tree arg) problems with the dominator optimizer. */ tree -invert_truthvalue (tree arg) +invert_truthvalue_loc (location_t loc, tree arg) { tree tem; if (TREE_CODE (arg) == ERROR_MARK) return arg; - tem = fold_truth_not_expr (arg); + tem = fold_truth_not_expr (loc, arg); if (!tem) - tem = build1 (TRUTH_NOT_EXPR, TREE_TYPE (arg), arg); + { + tem = build1 (TRUTH_NOT_EXPR, TREE_TYPE (arg), arg); + SET_EXPR_LOCATION (tem, loc); + } return tem; } @@ -3831,7 +3938,8 @@ invert_truthvalue (tree arg) If this optimization cannot be done, 0 will be returned. */ static tree -distribute_bit_expr (enum tree_code code, tree type, tree arg0, tree arg1) +distribute_bit_expr (location_t loc, enum tree_code code, tree type, + tree arg0, tree arg1) { tree common; tree left, right; @@ -3869,17 +3977,18 @@ distribute_bit_expr (enum tree_code code, tree type, tree arg0, tree arg1) else return 0; - common = fold_convert (type, common); - left = fold_convert (type, left); - right = fold_convert (type, right); - return fold_build2 (TREE_CODE (arg0), type, common, - fold_build2 (code, type, left, right)); + common = fold_convert_loc (loc, type, common); + left = fold_convert_loc (loc, type, left); + right = fold_convert_loc (loc, type, right); + return fold_build2_loc (loc, TREE_CODE (arg0), type, common, + fold_build2_loc (loc, code, type, left, right)); } /* Knowing that ARG0 and ARG1 are both RDIV_EXPRs, simplify a binary operation with code CODE. This optimization is unsafe. */ static tree -distribute_real_division (enum tree_code code, tree type, tree arg0, tree arg1) +distribute_real_division (location_t loc, enum tree_code code, tree type, + tree arg0, tree arg1) { bool mul0 = TREE_CODE (arg0) == MULT_EXPR; bool mul1 = TREE_CODE (arg1) == MULT_EXPR; @@ -3888,8 +3997,8 @@ distribute_real_division (enum tree_code code, tree type, tree arg0, tree arg1) if (mul0 == mul1 && operand_equal_p (TREE_OPERAND (arg0, 1), TREE_OPERAND (arg1, 1), 0)) - return fold_build2 (mul0 ? MULT_EXPR : RDIV_EXPR, type, - fold_build2 (code, type, + return fold_build2_loc (loc, mul0 ? MULT_EXPR : RDIV_EXPR, type, + fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), TREE_OPERAND (arg1, 0)), TREE_OPERAND (arg0, 1)); @@ -3908,7 +4017,7 @@ distribute_real_division (enum tree_code code, tree type, tree arg0, tree arg1) if (!mul1) real_arithmetic (&r1, RDIV_EXPR, &dconst1, &r1); real_arithmetic (&r0, code, &r0, &r1); - return fold_build2 (MULT_EXPR, type, + return fold_build2_loc (loc, MULT_EXPR, type, TREE_OPERAND (arg0, 0), build_real (type, r0)); } @@ -3920,8 +4029,8 @@ distribute_real_division (enum tree_code code, tree type, tree arg0, tree arg1) starting at BITPOS. The field is unsigned if UNSIGNEDP is nonzero. */ static tree -make_bit_field_ref (tree inner, tree type, HOST_WIDE_INT bitsize, - HOST_WIDE_INT bitpos, int unsignedp) +make_bit_field_ref (location_t loc, tree inner, tree type, + HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos, int unsignedp) { tree result, bftype; @@ -3932,7 +4041,7 @@ make_bit_field_ref (tree inner, tree type, HOST_WIDE_INT bitsize, || POINTER_TYPE_P (TREE_TYPE (inner))) && host_integerp (size, 0) && tree_low_cst (size, 0) == bitsize) - return fold_convert (type, inner); + return fold_convert_loc (loc, type, inner); } bftype = type; @@ -3942,9 +4051,10 @@ make_bit_field_ref (tree inner, tree type, HOST_WIDE_INT bitsize, result = build3 (BIT_FIELD_REF, bftype, inner, size_int (bitsize), bitsize_int (bitpos)); + SET_EXPR_LOCATION (result, loc); if (bftype != type) - result = fold_convert (type, result); + result = fold_convert_loc (loc, type, result); return result; } @@ -3970,8 +4080,8 @@ make_bit_field_ref (tree inner, tree type, HOST_WIDE_INT bitsize, tree. Otherwise we return zero. */ static tree -optimize_bit_field_compare (enum tree_code code, tree compare_type, - tree lhs, tree rhs) +optimize_bit_field_compare (location_t loc, enum tree_code code, + tree compare_type, tree lhs, tree rhs) { HOST_WIDE_INT lbitpos, lbitsize, rbitpos, rbitsize, nbitpos, nbitsize; tree type = TREE_TYPE (lhs); @@ -4044,15 +4154,15 @@ optimize_bit_field_compare (enum tree_code code, tree compare_type, if (! const_p) /* If not comparing with constant, just rework the comparison and return. */ - return fold_build2 (code, compare_type, - fold_build2 (BIT_AND_EXPR, unsigned_type, - make_bit_field_ref (linner, + return fold_build2_loc (loc, code, compare_type, + fold_build2_loc (loc, BIT_AND_EXPR, unsigned_type, + make_bit_field_ref (loc, linner, unsigned_type, nbitsize, nbitpos, 1), mask), - fold_build2 (BIT_AND_EXPR, unsigned_type, - make_bit_field_ref (rinner, + fold_build2_loc (loc, BIT_AND_EXPR, unsigned_type, + make_bit_field_ref (loc, rinner, unsigned_type, nbitsize, nbitpos, 1), @@ -4070,7 +4180,8 @@ optimize_bit_field_compare (enum tree_code code, tree compare_type, if (lunsignedp) { if (! integer_zerop (const_binop (RSHIFT_EXPR, - fold_convert (unsigned_type, rhs), + fold_convert_loc (loc, + unsigned_type, rhs), size_int (lbitsize), 0))) { warning (0, "comparison is always %d due to width of bit-field", @@ -4080,7 +4191,8 @@ optimize_bit_field_compare (enum tree_code code, tree compare_type, } else { - tree tem = const_binop (RSHIFT_EXPR, fold_convert (signed_type, rhs), + tree tem = const_binop (RSHIFT_EXPR, + fold_convert_loc (loc, signed_type, rhs), size_int (lbitsize - 1), 0); if (! integer_zerop (tem) && ! integer_all_onesp (tem)) { @@ -4100,7 +4212,7 @@ optimize_bit_field_compare (enum tree_code code, tree compare_type, /* Make a new bitfield reference, shift the constant over the appropriate number of bits and mask it with the computed mask (in case this was a signed field). If we changed it, make a new one. */ - lhs = make_bit_field_ref (linner, unsigned_type, nbitsize, nbitpos, 1); + lhs = make_bit_field_ref (loc, linner, unsigned_type, nbitsize, nbitpos, 1); if (lvolatilep) { TREE_SIDE_EFFECTS (lhs) = 1; @@ -4109,13 +4221,15 @@ optimize_bit_field_compare (enum tree_code code, tree compare_type, rhs = const_binop (BIT_AND_EXPR, const_binop (LSHIFT_EXPR, - fold_convert (unsigned_type, rhs), + fold_convert_loc (loc, unsigned_type, rhs), size_int (lbitpos), 0), mask, 0); - return build2 (code, compare_type, - build2 (BIT_AND_EXPR, unsigned_type, lhs, mask), - rhs); + lhs = build2 (code, compare_type, + build2 (BIT_AND_EXPR, unsigned_type, lhs, mask), + rhs); + SET_EXPR_LOCATION (lhs, loc); + return lhs; } /* Subroutine for fold_truthop: decode a field reference. @@ -4142,7 +4256,7 @@ optimize_bit_field_compare (enum tree_code code, tree compare_type, do anything with. */ static tree -decode_field_reference (tree exp, HOST_WIDE_INT *pbitsize, +decode_field_reference (location_t loc, tree exp, HOST_WIDE_INT *pbitsize, HOST_WIDE_INT *pbitpos, enum machine_mode *pmode, int *punsignedp, int *pvolatilep, tree *pmask, tree *pand_mask) @@ -4200,8 +4314,8 @@ decode_field_reference (tree exp, HOST_WIDE_INT *pbitsize, /* Merge it with the mask we found in the BIT_AND_EXPR, if any. */ if (and_mask != 0) - mask = fold_build2 (BIT_AND_EXPR, unsigned_type, - fold_convert (unsigned_type, and_mask), mask); + mask = fold_build2_loc (loc, BIT_AND_EXPR, unsigned_type, + fold_convert_loc (loc, unsigned_type, and_mask), mask); *pmask = mask; *pand_mask = and_mask; @@ -4424,6 +4538,7 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh, tree exp_type = NULL_TREE, arg0_type = NULL_TREE; int in_p, n_in_p; tree low, high, n_low, n_high; + location_t loc = EXPR_LOCATION (exp); /* Start with simply saying "EXP != 0" and then look at the code of EXP and see if we can refine the range. Some of the cases below may not @@ -4542,6 +4657,7 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh, /* ~ X -> -X - 1 */ exp = build2 (MINUS_EXPR, exp_type, negate_expr (arg0), build_int_cst (exp_type, 1)); + SET_EXPR_LOCATION (exp, loc); continue; case PLUS_EXPR: case MINUS_EXPR: @@ -4606,10 +4722,10 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh, n_low = low, n_high = high; if (n_low != 0) - n_low = fold_convert (arg0_type, n_low); + n_low = fold_convert_loc (loc, arg0_type, n_low); if (n_high != 0) - n_high = fold_convert (arg0_type, n_high); + n_high = fold_convert_loc (loc, arg0_type, n_high); /* If we're converting arg0 from an unsigned type, to exp, @@ -4643,9 +4759,9 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh, : TYPE_MAX_VALUE (arg0_type); if (TYPE_PRECISION (exp_type) == TYPE_PRECISION (arg0_type)) - high_positive = fold_build2 (RSHIFT_EXPR, arg0_type, - fold_convert (arg0_type, - high_positive), + high_positive = fold_build2_loc (loc, RSHIFT_EXPR, arg0_type, + fold_convert_loc (loc, arg0_type, + high_positive), build_int_cst (arg0_type, 1)); /* If the low bound is specified, "and" the range with the @@ -4655,8 +4771,8 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh, { if (! merge_ranges (&n_in_p, &n_low, &n_high, 1, n_low, n_high, 1, - fold_convert (arg0_type, - integer_zero_node), + fold_convert_loc (loc, arg0_type, + integer_zero_node), high_positive)) break; @@ -4668,8 +4784,8 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh, that will be interpreted as negative. */ if (! merge_ranges (&n_in_p, &n_low, &n_high, 0, n_low, n_high, 1, - fold_convert (arg0_type, - integer_zero_node), + fold_convert_loc (loc, arg0_type, + integer_zero_node), high_positive)) break; @@ -4708,7 +4824,8 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh, on IN_P) the range. Return 0 if the test couldn't be created. */ tree -build_range_check (tree type, tree exp, int in_p, tree low, tree high) +build_range_check (location_t loc, tree type, tree exp, int in_p, + tree low, tree high) { tree etype = TREE_TYPE (exp), value; @@ -4723,9 +4840,9 @@ build_range_check (tree type, tree exp, int in_p, tree low, tree high) if (! in_p) { - value = build_range_check (type, exp, 1, low, high); + value = build_range_check (loc, type, exp, 1, low, high); if (value != 0) - return invert_truthvalue (value); + return invert_truthvalue_loc (loc, value); return 0; } @@ -4734,26 +4851,26 @@ build_range_check (tree type, tree exp, int in_p, tree low, tree high) return build_int_cst (type, 1); if (low == 0) - return fold_build2 (LE_EXPR, type, exp, - fold_convert (etype, high)); + return fold_build2_loc (loc, LE_EXPR, type, exp, + fold_convert_loc (loc, etype, high)); if (high == 0) - return fold_build2 (GE_EXPR, type, exp, - fold_convert (etype, low)); + return fold_build2_loc (loc, GE_EXPR, type, exp, + fold_convert_loc (loc, etype, low)); if (operand_equal_p (low, high, 0)) - return fold_build2 (EQ_EXPR, type, exp, - fold_convert (etype, low)); + return fold_build2_loc (loc, EQ_EXPR, type, exp, + fold_convert_loc (loc, etype, low)); if (integer_zerop (low)) { if (! TYPE_UNSIGNED (etype)) { etype = unsigned_type_for (etype); - high = fold_convert (etype, high); - exp = fold_convert (etype, exp); + high = fold_convert_loc (loc, etype, high); + exp = fold_convert_loc (loc, etype, exp); } - return build_range_check (type, exp, 1, 0, high); + return build_range_check (loc, type, exp, 1, 0, high); } /* Optimize (c>=1) && (c<=127) into (signed char)c > 0. */ @@ -4785,9 +4902,9 @@ build_range_check (tree type, tree exp, int in_p, tree low, tree high) = build_nonstandard_integer_type (TYPE_PRECISION (etype), 0); else etype = signed_etype; - exp = fold_convert (etype, exp); + exp = fold_convert_loc (loc, etype, exp); } - return fold_build2 (GT_EXPR, type, exp, + return fold_build2_loc (loc, GT_EXPR, type, exp, build_int_cst (etype, 0)); } } @@ -4807,10 +4924,10 @@ build_range_check (tree type, tree exp, int in_p, tree low, tree high) /* Check if (unsigned) INT_MAX + 1 == (unsigned) INT_MIN for the type in question, as we rely on this here. */ utype = unsigned_type_for (etype); - maxv = fold_convert (utype, TYPE_MAX_VALUE (etype)); + maxv = fold_convert_loc (loc, utype, TYPE_MAX_VALUE (etype)); maxv = range_binop (PLUS_EXPR, NULL_TREE, maxv, 1, integer_one_node, 1); - minv = fold_convert (utype, TYPE_MIN_VALUE (etype)); + minv = fold_convert_loc (loc, utype, TYPE_MIN_VALUE (etype)); if (integer_zerop (range_binop (NE_EXPR, integer_type_node, minv, 1, maxv, 1))) @@ -4819,9 +4936,9 @@ build_range_check (tree type, tree exp, int in_p, tree low, tree high) return 0; } - high = fold_convert (etype, high); - low = fold_convert (etype, low); - exp = fold_convert (etype, exp); + high = fold_convert_loc (loc, etype, high); + low = fold_convert_loc (loc, etype, low); + exp = fold_convert_loc (loc, etype, exp); value = const_binop (MINUS_EXPR, high, low, 0); @@ -4830,18 +4947,19 @@ build_range_check (tree type, tree exp, int in_p, tree low, tree high) { if (value != 0 && !TREE_OVERFLOW (value)) { - low = fold_convert (sizetype, low); - low = fold_build1 (NEGATE_EXPR, sizetype, low); - return build_range_check (type, - fold_build2 (POINTER_PLUS_EXPR, etype, exp, low), + low = fold_convert_loc (loc, sizetype, low); + low = fold_build1_loc (loc, NEGATE_EXPR, sizetype, low); + return build_range_check (loc, type, + fold_build2_loc (loc, POINTER_PLUS_EXPR, + etype, exp, low), 1, build_int_cst (etype, 0), value); } return 0; } if (value != 0 && !TREE_OVERFLOW (value)) - return build_range_check (type, - fold_build2 (MINUS_EXPR, etype, exp, low), + return build_range_check (loc, type, + fold_build2_loc (loc, MINUS_EXPR, etype, exp, low), 1, build_int_cst (etype, 0), value); return 0; @@ -5096,7 +5214,8 @@ merge_ranges (int *pin_p, tree *plow, tree *phigh, int in0_p, tree low0, anymore, or NULL_TREE if no folding opportunity is found. */ static tree -fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) +fold_cond_expr_with_comparison (location_t loc, tree type, + tree arg0, tree arg1, tree arg2) { enum tree_code comp_code = TREE_CODE (arg0); tree arg00 = TREE_OPERAND (arg0, 0); @@ -5144,11 +5263,13 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) { case EQ_EXPR: case UNEQ_EXPR: - tem = fold_convert (arg1_type, arg1); - return pedantic_non_lvalue (fold_convert (type, negate_expr (tem))); + tem = fold_convert_loc (loc, arg1_type, arg1); + return pedantic_non_lvalue_loc (loc, + fold_convert_loc (loc, type, + negate_expr (tem))); case NE_EXPR: case LTGT_EXPR: - return pedantic_non_lvalue (fold_convert (type, arg1)); + return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, arg1)); case UNGE_EXPR: case UNGT_EXPR: if (flag_trapping_math) @@ -5157,10 +5278,10 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) case GE_EXPR: case GT_EXPR: if (TYPE_UNSIGNED (TREE_TYPE (arg1))) - arg1 = fold_convert (signed_type_for + arg1 = fold_convert_loc (loc, signed_type_for (TREE_TYPE (arg1)), arg1); - tem = fold_build1 (ABS_EXPR, TREE_TYPE (arg1), arg1); - return pedantic_non_lvalue (fold_convert (type, tem)); + tem = fold_build1_loc (loc, ABS_EXPR, TREE_TYPE (arg1), arg1); + return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, tem)); case UNLE_EXPR: case UNLT_EXPR: if (flag_trapping_math) @@ -5168,10 +5289,10 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) case LE_EXPR: case LT_EXPR: if (TYPE_UNSIGNED (TREE_TYPE (arg1))) - arg1 = fold_convert (signed_type_for + arg1 = fold_convert_loc (loc, signed_type_for (TREE_TYPE (arg1)), arg1); - tem = fold_build1 (ABS_EXPR, TREE_TYPE (arg1), arg1); - return negate_expr (fold_convert (type, tem)); + tem = fold_build1_loc (loc, ABS_EXPR, TREE_TYPE (arg1), arg1); + return negate_expr (fold_convert_loc (loc, type, tem)); default: gcc_assert (TREE_CODE_CLASS (comp_code) == tcc_comparison); break; @@ -5186,7 +5307,7 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) && integer_zerop (arg01) && integer_zerop (arg2)) { if (comp_code == NE_EXPR) - return pedantic_non_lvalue (fold_convert (type, arg1)); + return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, arg1)); else if (comp_code == EQ_EXPR) return build_int_cst (type, 0); } @@ -5242,9 +5363,9 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) switch (comp_code) { case EQ_EXPR: - return pedantic_non_lvalue (fold_convert (type, arg2)); + return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, arg2)); case NE_EXPR: - return pedantic_non_lvalue (fold_convert (type, arg1)); + return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, arg1)); case LE_EXPR: case LT_EXPR: case UNLE_EXPR: @@ -5255,12 +5376,14 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) corresponding COND_EXPR. */ if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg1)))) { - comp_op0 = fold_convert (comp_type, comp_op0); - comp_op1 = fold_convert (comp_type, comp_op1); + comp_op0 = fold_convert_loc (loc, comp_type, comp_op0); + comp_op1 = fold_convert_loc (loc, comp_type, comp_op1); tem = (comp_code == LE_EXPR || comp_code == UNLE_EXPR) - ? fold_build2 (MIN_EXPR, comp_type, comp_op0, comp_op1) - : fold_build2 (MIN_EXPR, comp_type, comp_op1, comp_op0); - return pedantic_non_lvalue (fold_convert (type, tem)); + ? fold_build2_loc (loc, MIN_EXPR, comp_type, comp_op0, comp_op1) + : fold_build2_loc (loc, MIN_EXPR, comp_type, + comp_op1, comp_op0); + return pedantic_non_lvalue_loc (loc, + fold_convert_loc (loc, type, tem)); } break; case GE_EXPR: @@ -5269,21 +5392,25 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) case UNGT_EXPR: if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg1)))) { - comp_op0 = fold_convert (comp_type, comp_op0); - comp_op1 = fold_convert (comp_type, comp_op1); + comp_op0 = fold_convert_loc (loc, comp_type, comp_op0); + comp_op1 = fold_convert_loc (loc, comp_type, comp_op1); tem = (comp_code == GE_EXPR || comp_code == UNGE_EXPR) - ? fold_build2 (MAX_EXPR, comp_type, comp_op0, comp_op1) - : fold_build2 (MAX_EXPR, comp_type, comp_op1, comp_op0); - return pedantic_non_lvalue (fold_convert (type, tem)); + ? fold_build2_loc (loc, MAX_EXPR, comp_type, comp_op0, comp_op1) + : fold_build2_loc (loc, MAX_EXPR, comp_type, + comp_op1, comp_op0); + return pedantic_non_lvalue_loc (loc, + fold_convert_loc (loc, type, tem)); } break; case UNEQ_EXPR: if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg1)))) - return pedantic_non_lvalue (fold_convert (type, arg2)); + return pedantic_non_lvalue_loc (loc, + fold_convert_loc (loc, type, arg2)); break; case LTGT_EXPR: if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg1)))) - return pedantic_non_lvalue (fold_convert (type, arg1)); + return pedantic_non_lvalue_loc (loc, + fold_convert_loc (loc, type, arg1)); break; default: gcc_assert (TREE_CODE_CLASS (comp_code) == tcc_comparison); @@ -5306,35 +5433,43 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) if (TREE_CODE (arg1) == INTEGER_CST) break; /* We can replace A with C1 in this case. */ - arg1 = fold_convert (type, arg01); - return fold_build3 (COND_EXPR, type, arg0, arg1, arg2); + arg1 = fold_convert_loc (loc, type, arg01); + return fold_build3_loc (loc, COND_EXPR, type, arg0, arg1, arg2); case LT_EXPR: - /* If C1 is C2 + 1, this is min(A, C2). */ + /* If C1 is C2 + 1, this is min(A, C2), but use ARG00's type for + MIN_EXPR, to preserve the signedness of the comparison. */ if (! operand_equal_p (arg2, TYPE_MAX_VALUE (type), OEP_ONLY_CONST) && operand_equal_p (arg01, const_binop (PLUS_EXPR, arg2, build_int_cst (type, 1), 0), OEP_ONLY_CONST)) - return pedantic_non_lvalue (fold_build2 (MIN_EXPR, - type, - fold_convert (type, arg1), - arg2)); + { + tem = fold_build2_loc (loc, MIN_EXPR, TREE_TYPE (arg00), arg00, + fold_convert_loc (loc, TREE_TYPE (arg00), + arg2)); + return pedantic_non_lvalue_loc (loc, + fold_convert_loc (loc, type, tem)); + } break; case LE_EXPR: - /* If C1 is C2 - 1, this is min(A, C2). */ + /* If C1 is C2 - 1, this is min(A, C2), with the same care + as above. */ if (! operand_equal_p (arg2, TYPE_MIN_VALUE (type), OEP_ONLY_CONST) && operand_equal_p (arg01, const_binop (MINUS_EXPR, arg2, build_int_cst (type, 1), 0), OEP_ONLY_CONST)) - return pedantic_non_lvalue (fold_build2 (MIN_EXPR, - type, - fold_convert (type, arg1), - arg2)); + { + tem = fold_build2_loc (loc, MIN_EXPR, TREE_TYPE (arg00), arg00, + fold_convert_loc (loc, TREE_TYPE (arg00), + arg2)); + return pedantic_non_lvalue_loc (loc, + fold_convert_loc (loc, type, tem)); + } break; case GT_EXPR: @@ -5346,11 +5481,12 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) const_binop (MINUS_EXPR, arg2, build_int_cst (type, 1), 0), OEP_ONLY_CONST)) - return pedantic_non_lvalue (fold_convert (type, - fold_build2 (MAX_EXPR, TREE_TYPE (arg00), - arg00, - fold_convert (TREE_TYPE (arg00), - arg2)))); + { + tem = fold_build2_loc (loc, MAX_EXPR, TREE_TYPE (arg00), arg00, + fold_convert_loc (loc, TREE_TYPE (arg00), + arg2)); + return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, tem)); + } break; case GE_EXPR: @@ -5361,11 +5497,12 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) const_binop (PLUS_EXPR, arg2, build_int_cst (type, 1), 0), OEP_ONLY_CONST)) - return pedantic_non_lvalue (fold_convert (type, - fold_build2 (MAX_EXPR, TREE_TYPE (arg00), - arg00, - fold_convert (TREE_TYPE (arg00), - arg2)))); + { + tem = fold_build2_loc (loc, MAX_EXPR, TREE_TYPE (arg00), arg00, + fold_convert_loc (loc, TREE_TYPE (arg00), + arg2)); + return pedantic_non_lvalue_loc (loc, fold_convert_loc (loc, type, tem)); + } break; case NE_EXPR: break; @@ -5388,7 +5525,8 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) merge it into some range test. Return the new tree if so. */ static tree -fold_range_test (enum tree_code code, tree type, tree op0, tree op1) +fold_range_test (location_t loc, enum tree_code code, tree type, + tree op0, tree op1) { int or_op = (code == TRUTH_ORIF_EXPR || code == TRUTH_OR_EXPR); @@ -5413,14 +5551,14 @@ fold_range_test (enum tree_code code, tree type, tree op0, tree op1) if ((lhs == 0 || rhs == 0 || operand_equal_p (lhs, rhs, 0)) && merge_ranges (&in_p, &low, &high, in0_p, low0, high0, in1_p, low1, high1) - && 0 != (tem = (build_range_check (type, + && 0 != (tem = (build_range_check (UNKNOWN_LOCATION, type, lhs != 0 ? lhs : rhs != 0 ? rhs : integer_zero_node, in_p, low, high)))) { if (strict_overflow_p) fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON); - return or_op ? invert_truthvalue (tem) : tem; + return or_op ? invert_truthvalue_loc (loc, tem) : tem; } /* On machines where the branch cost is expensive, if this is a @@ -5436,28 +5574,34 @@ fold_range_test (enum tree_code code, tree type, tree op0, tree op1) unless we are at top level or LHS contains a PLACEHOLDER_EXPR, in which cases we can't do this. */ if (simple_operand_p (lhs)) - return build2 (code == TRUTH_ANDIF_EXPR - ? TRUTH_AND_EXPR : TRUTH_OR_EXPR, - type, op0, op1); + { + tem = build2 (code == TRUTH_ANDIF_EXPR + ? TRUTH_AND_EXPR : TRUTH_OR_EXPR, + type, op0, op1); + SET_EXPR_LOCATION (tem, loc); + return tem; + } else if (lang_hooks.decls.global_bindings_p () == 0 && ! CONTAINS_PLACEHOLDER_P (lhs)) { tree common = save_expr (lhs); - if (0 != (lhs = build_range_check (type, common, + if (0 != (lhs = build_range_check (loc, type, common, or_op ? ! in0_p : in0_p, low0, high0)) - && (0 != (rhs = build_range_check (type, common, + && (0 != (rhs = build_range_check (loc, type, common, or_op ? ! in1_p : in1_p, low1, high1)))) { if (strict_overflow_p) fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON); - return build2 (code == TRUTH_ANDIF_EXPR - ? TRUTH_AND_EXPR : TRUTH_OR_EXPR, - type, lhs, rhs); + tem = build2 (code == TRUTH_ANDIF_EXPR + ? TRUTH_AND_EXPR : TRUTH_OR_EXPR, + type, lhs, rhs); + SET_EXPR_LOCATION (tem, loc); + return tem; } } } @@ -5499,12 +5643,14 @@ unextend (tree c, int p, int unsignedp, tree mask) temp = const_binop (RSHIFT_EXPR, temp, size_int (modesize - p - 1), 0); if (mask != 0) temp = const_binop (BIT_AND_EXPR, temp, - fold_convert (TREE_TYPE (c), mask), 0); + fold_convert (TREE_TYPE (c), mask), + 0); /* If necessary, convert the type back to match the type of C. */ if (TYPE_UNSIGNED (type)) temp = fold_convert (type, temp); - return fold_convert (type, const_binop (BIT_XOR_EXPR, c, temp, 0)); + return fold_convert (type, + const_binop (BIT_XOR_EXPR, c, temp, 0)); } /* Find ways of folding logical expressions of LHS and RHS: @@ -5532,7 +5678,8 @@ unextend (tree c, int p, int unsignedp, tree mask) We return the simplified tree or 0 if no optimization is possible. */ static tree -fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) +fold_truthop (location_t loc, enum tree_code code, tree truth_type, + tree lhs, tree rhs) { /* If this is the "or" of two comparisons, we can do something if the comparisons are NE_EXPR. If this is the "and", we can do something @@ -5604,7 +5751,7 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) if (operand_equal_p (ll_arg, rl_arg, 0) && operand_equal_p (lr_arg, rr_arg, 0)) { - result = combine_comparisons (code, lcode, rcode, + result = combine_comparisons (loc, code, lcode, rcode, truth_type, ll_arg, lr_arg); if (result) return result; @@ -5612,7 +5759,7 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) else if (operand_equal_p (ll_arg, rr_arg, 0) && operand_equal_p (lr_arg, rl_arg, 0)) { - result = combine_comparisons (code, lcode, + result = combine_comparisons (loc, code, lcode, swap_tree_comparison (rcode), truth_type, ll_arg, lr_arg); if (result) @@ -5641,10 +5788,13 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) && rcode == NE_EXPR && integer_zerop (rr_arg) && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg) && INTEGRAL_TYPE_P (TREE_TYPE (ll_arg))) - return build2 (NE_EXPR, truth_type, - build2 (BIT_IOR_EXPR, TREE_TYPE (ll_arg), - ll_arg, rl_arg), - build_int_cst (TREE_TYPE (ll_arg), 0)); + { + result = build2 (NE_EXPR, truth_type, + build2 (BIT_IOR_EXPR, TREE_TYPE (ll_arg), + ll_arg, rl_arg), + build_int_cst (TREE_TYPE (ll_arg), 0)); + goto fold_truthop_exit; + } /* Convert (a == 0) && (b == 0) into (a | b) == 0. */ if (code == TRUTH_AND_EXPR @@ -5652,15 +5802,21 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) && rcode == EQ_EXPR && integer_zerop (rr_arg) && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg) && INTEGRAL_TYPE_P (TREE_TYPE (ll_arg))) - return build2 (EQ_EXPR, truth_type, - build2 (BIT_IOR_EXPR, TREE_TYPE (ll_arg), - ll_arg, rl_arg), - build_int_cst (TREE_TYPE (ll_arg), 0)); + { + result = build2 (EQ_EXPR, truth_type, + build2 (BIT_IOR_EXPR, TREE_TYPE (ll_arg), + ll_arg, rl_arg), + build_int_cst (TREE_TYPE (ll_arg), 0)); + goto fold_truthop_exit; + } if (LOGICAL_OP_NON_SHORT_CIRCUIT) { if (code != orig_code || lhs != orig_lhs || rhs != orig_rhs) - return build2 (code, truth_type, lhs, rhs); + { + result = build2 (code, truth_type, lhs, rhs); + goto fold_truthop_exit; + } return NULL_TREE; } } @@ -5673,19 +5829,19 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) return 0; volatilep = 0; - ll_inner = decode_field_reference (ll_arg, + ll_inner = decode_field_reference (loc, ll_arg, &ll_bitsize, &ll_bitpos, &ll_mode, &ll_unsignedp, &volatilep, &ll_mask, &ll_and_mask); - lr_inner = decode_field_reference (lr_arg, + lr_inner = decode_field_reference (loc, lr_arg, &lr_bitsize, &lr_bitpos, &lr_mode, &lr_unsignedp, &volatilep, &lr_mask, &lr_and_mask); - rl_inner = decode_field_reference (rl_arg, + rl_inner = decode_field_reference (loc, rl_arg, &rl_bitsize, &rl_bitpos, &rl_mode, &rl_unsignedp, &volatilep, &rl_mask, &rl_and_mask); - rr_inner = decode_field_reference (rr_arg, + rr_inner = decode_field_reference (loc, rr_arg, &rr_bitsize, &rr_bitpos, &rr_mode, &rr_unsignedp, &volatilep, &rr_mask, &rr_and_mask); @@ -5760,18 +5916,18 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) xrl_bitpos = lnbitsize - xrl_bitpos - rl_bitsize; } - ll_mask = const_binop (LSHIFT_EXPR, fold_convert (lntype, ll_mask), + ll_mask = const_binop (LSHIFT_EXPR, fold_convert_loc (loc, lntype, ll_mask), size_int (xll_bitpos), 0); - rl_mask = const_binop (LSHIFT_EXPR, fold_convert (lntype, rl_mask), + rl_mask = const_binop (LSHIFT_EXPR, fold_convert_loc (loc, lntype, rl_mask), size_int (xrl_bitpos), 0); if (l_const) { - l_const = fold_convert (lntype, l_const); + l_const = fold_convert_loc (loc, lntype, l_const); l_const = unextend (l_const, ll_bitsize, ll_unsignedp, ll_and_mask); l_const = const_binop (LSHIFT_EXPR, l_const, size_int (xll_bitpos), 0); if (! integer_zerop (const_binop (BIT_AND_EXPR, l_const, - fold_build1 (BIT_NOT_EXPR, + fold_build1_loc (loc, BIT_NOT_EXPR, lntype, ll_mask), 0))) { @@ -5782,11 +5938,11 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) } if (r_const) { - r_const = fold_convert (lntype, r_const); + r_const = fold_convert_loc (loc, lntype, r_const); r_const = unextend (r_const, rl_bitsize, rl_unsignedp, rl_and_mask); r_const = const_binop (LSHIFT_EXPR, r_const, size_int (xrl_bitpos), 0); if (! integer_zerop (const_binop (BIT_AND_EXPR, r_const, - fold_build1 (BIT_NOT_EXPR, + fold_build1_loc (loc, BIT_NOT_EXPR, lntype, rl_mask), 0))) { @@ -5827,9 +5983,11 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) xrr_bitpos = rnbitsize - xrr_bitpos - rr_bitsize; } - lr_mask = const_binop (LSHIFT_EXPR, fold_convert (rntype, lr_mask), + lr_mask = const_binop (LSHIFT_EXPR, fold_convert_loc (loc, + rntype, lr_mask), size_int (xlr_bitpos), 0); - rr_mask = const_binop (LSHIFT_EXPR, fold_convert (rntype, rr_mask), + rr_mask = const_binop (LSHIFT_EXPR, fold_convert_loc (loc, + rntype, rr_mask), size_int (xrr_bitpos), 0); /* Make a mask that corresponds to both fields being compared. @@ -5841,17 +5999,18 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) lr_mask = const_binop (BIT_IOR_EXPR, lr_mask, rr_mask, 0); if (lnbitsize == rnbitsize && xll_bitpos == xlr_bitpos) { - lhs = make_bit_field_ref (ll_inner, lntype, lnbitsize, lnbitpos, + lhs = make_bit_field_ref (loc, ll_inner, lntype, lnbitsize, lnbitpos, ll_unsignedp || rl_unsignedp); if (! all_ones_mask_p (ll_mask, lnbitsize)) lhs = build2 (BIT_AND_EXPR, lntype, lhs, ll_mask); - rhs = make_bit_field_ref (lr_inner, rntype, rnbitsize, rnbitpos, + rhs = make_bit_field_ref (loc, lr_inner, rntype, rnbitsize, rnbitpos, lr_unsignedp || rr_unsignedp); if (! all_ones_mask_p (lr_mask, rnbitsize)) rhs = build2 (BIT_AND_EXPR, rntype, rhs, lr_mask); - return build2 (wanted_code, truth_type, lhs, rhs); + result = build2 (wanted_code, truth_type, lhs, rhs); + goto fold_truthop_exit; } /* There is still another way we can do something: If both pairs of @@ -5868,9 +6027,11 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) { tree type; - lhs = make_bit_field_ref (ll_inner, lntype, ll_bitsize + rl_bitsize, + lhs = make_bit_field_ref (loc, ll_inner, lntype, + ll_bitsize + rl_bitsize, MIN (ll_bitpos, rl_bitpos), ll_unsignedp); - rhs = make_bit_field_ref (lr_inner, rntype, lr_bitsize + rr_bitsize, + rhs = make_bit_field_ref (loc, lr_inner, rntype, + lr_bitsize + rr_bitsize, MIN (lr_bitpos, rr_bitpos), lr_unsignedp); ll_mask = const_binop (RSHIFT_EXPR, ll_mask, @@ -5884,14 +6045,14 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) { if (lnbitsize > rnbitsize) { - lhs = fold_convert (rntype, lhs); - ll_mask = fold_convert (rntype, ll_mask); + lhs = fold_convert_loc (loc, rntype, lhs); + ll_mask = fold_convert_loc (loc, rntype, ll_mask); type = rntype; } else if (lnbitsize < rnbitsize) { - rhs = fold_convert (lntype, rhs); - lr_mask = fold_convert (lntype, lr_mask); + rhs = fold_convert_loc (loc, lntype, rhs); + lr_mask = fold_convert_loc (loc, lntype, lr_mask); type = lntype; } } @@ -5902,7 +6063,8 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) if (! all_ones_mask_p (lr_mask, lr_bitsize + rr_bitsize)) rhs = build2 (BIT_AND_EXPR, type, rhs, lr_mask); - return build2 (wanted_code, truth_type, lhs, rhs); + result = build2 (wanted_code, truth_type, lhs, rhs); + goto fold_truthop_exit; } return 0; @@ -5933,22 +6095,30 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) reference we will make. Unless the mask is all ones the width of that field, perform the mask operation. Then compare with the merged constant. */ - result = make_bit_field_ref (ll_inner, lntype, lnbitsize, lnbitpos, + result = make_bit_field_ref (loc, ll_inner, lntype, lnbitsize, lnbitpos, ll_unsignedp || rl_unsignedp); ll_mask = const_binop (BIT_IOR_EXPR, ll_mask, rl_mask, 0); if (! all_ones_mask_p (ll_mask, lnbitsize)) - result = build2 (BIT_AND_EXPR, lntype, result, ll_mask); + { + result = build2 (BIT_AND_EXPR, lntype, result, ll_mask); + SET_EXPR_LOCATION (result, loc); + } + + result = build2 (wanted_code, truth_type, result, + const_binop (BIT_IOR_EXPR, l_const, r_const, 0)); - return build2 (wanted_code, truth_type, result, - const_binop (BIT_IOR_EXPR, l_const, r_const, 0)); + fold_truthop_exit: + SET_EXPR_LOCATION (result, loc); + return result; } /* Optimize T, which is a comparison of a MIN_EXPR or MAX_EXPR with a constant. */ static tree -optimize_minmax_comparison (enum tree_code code, tree type, tree op0, tree op1) +optimize_minmax_comparison (location_t loc, enum tree_code code, tree type, + tree op0, tree op1) { tree arg0 = op0; enum tree_code op_code; @@ -5961,7 +6131,7 @@ optimize_minmax_comparison (enum tree_code code, tree type, tree op0, tree op1) op_code = TREE_CODE (arg0); minmax_const = TREE_OPERAND (arg0, 1); - comp_const = fold_convert (TREE_TYPE (arg0), op1); + comp_const = fold_convert_loc (loc, TREE_TYPE (arg0), op1); consts_equal = tree_int_cst_equal (minmax_const, comp_const); consts_lt = tree_int_cst_lt (minmax_const, comp_const); inner = TREE_OPERAND (arg0, 0); @@ -5981,64 +6151,66 @@ optimize_minmax_comparison (enum tree_code code, tree type, tree op0, tree op1) { case NE_EXPR: case LT_EXPR: case LE_EXPR: { - tree tem = optimize_minmax_comparison (invert_tree_comparison (code, false), - type, op0, op1); + tree tem + = optimize_minmax_comparison (loc, + invert_tree_comparison (code, false), + type, op0, op1); if (tem) - return invert_truthvalue (tem); + return invert_truthvalue_loc (loc, tem); return NULL_TREE; } case GE_EXPR: return - fold_build2 (TRUTH_ORIF_EXPR, type, + fold_build2_loc (loc, TRUTH_ORIF_EXPR, type, optimize_minmax_comparison - (EQ_EXPR, type, arg0, comp_const), + (loc, EQ_EXPR, type, arg0, comp_const), optimize_minmax_comparison - (GT_EXPR, type, arg0, comp_const)); + (loc, GT_EXPR, type, arg0, comp_const)); case EQ_EXPR: if (op_code == MAX_EXPR && consts_equal) /* MAX (X, 0) == 0 -> X <= 0 */ - return fold_build2 (LE_EXPR, type, inner, comp_const); + return fold_build2_loc (loc, LE_EXPR, type, inner, comp_const); else if (op_code == MAX_EXPR && consts_lt) /* MAX (X, 0) == 5 -> X == 5 */ - return fold_build2 (EQ_EXPR, type, inner, comp_const); + return fold_build2_loc (loc, EQ_EXPR, type, inner, comp_const); else if (op_code == MAX_EXPR) /* MAX (X, 0) == -1 -> false */ - return omit_one_operand (type, integer_zero_node, inner); + return omit_one_operand_loc (loc, type, integer_zero_node, inner); else if (consts_equal) /* MIN (X, 0) == 0 -> X >= 0 */ - return fold_build2 (GE_EXPR, type, inner, comp_const); + return fold_build2_loc (loc, GE_EXPR, type, inner, comp_const); else if (consts_lt) /* MIN (X, 0) == 5 -> false */ - return omit_one_operand (type, integer_zero_node, inner); + return omit_one_operand_loc (loc, type, integer_zero_node, inner); else /* MIN (X, 0) == -1 -> X == -1 */ - return fold_build2 (EQ_EXPR, type, inner, comp_const); + return fold_build2_loc (loc, EQ_EXPR, type, inner, comp_const); case GT_EXPR: if (op_code == MAX_EXPR && (consts_equal || consts_lt)) /* MAX (X, 0) > 0 -> X > 0 MAX (X, 0) > 5 -> X > 5 */ - return fold_build2 (GT_EXPR, type, inner, comp_const); + return fold_build2_loc (loc, GT_EXPR, type, inner, comp_const); else if (op_code == MAX_EXPR) /* MAX (X, 0) > -1 -> true */ - return omit_one_operand (type, integer_one_node, inner); + return omit_one_operand_loc (loc, type, integer_one_node, inner); else if (op_code == MIN_EXPR && (consts_equal || consts_lt)) /* MIN (X, 0) > 0 -> false MIN (X, 0) > 5 -> false */ - return omit_one_operand (type, integer_zero_node, inner); + return omit_one_operand_loc (loc, type, integer_zero_node, inner); else /* MIN (X, 0) > -1 -> X > -1 */ - return fold_build2 (GT_EXPR, type, inner, comp_const); + return fold_build2_loc (loc, GT_EXPR, type, inner, comp_const); default: return NULL_TREE; @@ -6231,7 +6403,9 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type, && !TREE_OVERFLOW (t1)) return extract_muldiv (build2 (tcode == LSHIFT_EXPR ? MULT_EXPR : FLOOR_DIV_EXPR, - ctype, fold_convert (ctype, op0), t1), + ctype, + fold_convert (ctype, op0), + t1), c, code, wide_type, strict_overflow_p); break; @@ -6361,7 +6535,8 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type, /* If these are the same operation types, we can associate them assuming no overflow. */ if (tcode == code - && 0 != (t1 = int_const_binop (MULT_EXPR, fold_convert (ctype, op1), + && 0 != (t1 = int_const_binop (MULT_EXPR, + fold_convert (ctype, op1), fold_convert (ctype, c), 1)) && 0 != (t1 = force_fit_type_double (ctype, TREE_INT_CST_LOW (t1), TREE_INT_CST_HIGH (t1), @@ -6440,7 +6615,8 @@ constant_boolean_node (int value, tree type) possible. */ static tree -fold_binary_op_with_conditional_arg (enum tree_code code, +fold_binary_op_with_conditional_arg (location_t loc, + enum tree_code code, tree type, tree op0, tree op1, tree cond, tree arg, int cond_first_p) { @@ -6477,26 +6653,26 @@ fold_binary_op_with_conditional_arg (enum tree_code code, false_value = constant_boolean_node (false, testtype); } - arg = fold_convert (arg_type, arg); + arg = fold_convert_loc (loc, arg_type, arg); if (lhs == 0) { - true_value = fold_convert (cond_type, true_value); + true_value = fold_convert_loc (loc, cond_type, true_value); if (cond_first_p) - lhs = fold_build2 (code, type, true_value, arg); + lhs = fold_build2_loc (loc, code, type, true_value, arg); else - lhs = fold_build2 (code, type, arg, true_value); + lhs = fold_build2_loc (loc, code, type, arg, true_value); } if (rhs == 0) { - false_value = fold_convert (cond_type, false_value); + false_value = fold_convert_loc (loc, cond_type, false_value); if (cond_first_p) - rhs = fold_build2 (code, type, false_value, arg); + rhs = fold_build2_loc (loc, code, type, false_value, arg); else - rhs = fold_build2 (code, type, arg, false_value); + rhs = fold_build2_loc (loc, code, type, arg, false_value); } - test = fold_build3 (COND_EXPR, type, test, lhs, rhs); - return fold_convert (type, test); + test = fold_build3_loc (loc, COND_EXPR, type, test, lhs, rhs); + return fold_convert_loc (loc, type, test); } @@ -6550,7 +6726,8 @@ fold_real_zero_addition_p (const_tree type, const_tree addend, int negate) can be made, and NULL_TREE otherwise. */ static tree -fold_mathfn_compare (enum built_in_function fcode, enum tree_code code, +fold_mathfn_compare (location_t loc, + enum built_in_function fcode, enum tree_code code, tree type, tree arg0, tree arg1) { REAL_VALUE_TYPE c; @@ -6565,15 +6742,15 @@ fold_mathfn_compare (enum built_in_function fcode, enum tree_code code, { /* sqrt(x) < y is always false, if y is negative. */ if (code == EQ_EXPR || code == LT_EXPR || code == LE_EXPR) - return omit_one_operand (type, integer_zero_node, arg); + return omit_one_operand_loc (loc, type, integer_zero_node, arg); /* sqrt(x) > y is always true, if y is negative and we don't care about NaNs, i.e. negative values of x. */ if (code == NE_EXPR || !HONOR_NANS (mode)) - return omit_one_operand (type, integer_one_node, arg); + return omit_one_operand_loc (loc, type, integer_one_node, arg); /* sqrt(x) > y is the same as x >= 0, if y is negative. */ - return fold_build2 (GE_EXPR, type, arg, + return fold_build2_loc (loc, GE_EXPR, type, arg, build_real (TREE_TYPE (arg), dconst0)); } else if (code == GT_EXPR || code == GE_EXPR) @@ -6587,16 +6764,16 @@ fold_mathfn_compare (enum built_in_function fcode, enum tree_code code, { /* sqrt(x) > y is x == +Inf, when y is very large. */ if (HONOR_INFINITIES (mode)) - return fold_build2 (EQ_EXPR, type, arg, + return fold_build2_loc (loc, EQ_EXPR, type, arg, build_real (TREE_TYPE (arg), c2)); /* sqrt(x) > y is always false, when y is very large and we don't care about infinities. */ - return omit_one_operand (type, integer_zero_node, arg); + return omit_one_operand_loc (loc, type, integer_zero_node, arg); } /* sqrt(x) > c is the same as x > c*c. */ - return fold_build2 (code, type, arg, + return fold_build2_loc (loc, code, type, arg, build_real (TREE_TYPE (arg), c2)); } else if (code == LT_EXPR || code == LE_EXPR) @@ -6611,18 +6788,18 @@ fold_mathfn_compare (enum built_in_function fcode, enum tree_code code, /* sqrt(x) < y is always true, when y is a very large value and we don't care about NaNs or Infinities. */ if (! HONOR_NANS (mode) && ! HONOR_INFINITIES (mode)) - return omit_one_operand (type, integer_one_node, arg); + return omit_one_operand_loc (loc, type, integer_one_node, arg); /* sqrt(x) < y is x != +Inf when y is very large and we don't care about NaNs. */ if (! HONOR_NANS (mode)) - return fold_build2 (NE_EXPR, type, arg, + return fold_build2_loc (loc, NE_EXPR, type, arg, build_real (TREE_TYPE (arg), c2)); /* sqrt(x) < y is x >= 0 when y is very large and we don't care about Infinities. */ if (! HONOR_INFINITIES (mode)) - return fold_build2 (GE_EXPR, type, arg, + return fold_build2_loc (loc, GE_EXPR, type, arg, build_real (TREE_TYPE (arg), dconst0)); /* sqrt(x) < y is x >= 0 && x != +Inf, when y is large. */ @@ -6631,18 +6808,18 @@ fold_mathfn_compare (enum built_in_function fcode, enum tree_code code, return NULL_TREE; arg = save_expr (arg); - return fold_build2 (TRUTH_ANDIF_EXPR, type, - fold_build2 (GE_EXPR, type, arg, + return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type, + fold_build2_loc (loc, GE_EXPR, type, arg, build_real (TREE_TYPE (arg), dconst0)), - fold_build2 (NE_EXPR, type, arg, + fold_build2_loc (loc, NE_EXPR, type, arg, build_real (TREE_TYPE (arg), c2))); } /* sqrt(x) < c is the same as x < c*c, if we ignore NaNs. */ if (! HONOR_NANS (mode)) - return fold_build2 (code, type, arg, + return fold_build2_loc (loc, code, type, arg, build_real (TREE_TYPE (arg), c2)); /* sqrt(x) < c is the same as x >= 0 && x < c*c. */ @@ -6650,11 +6827,11 @@ fold_mathfn_compare (enum built_in_function fcode, enum tree_code code, && ! CONTAINS_PLACEHOLDER_P (arg)) { arg = save_expr (arg); - return fold_build2 (TRUTH_ANDIF_EXPR, type, - fold_build2 (GE_EXPR, type, arg, + return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type, + fold_build2_loc (loc, GE_EXPR, type, arg, build_real (TREE_TYPE (arg), dconst0)), - fold_build2 (code, type, arg, + fold_build2_loc (loc, code, type, arg, build_real (TREE_TYPE (arg), c2))); } @@ -6675,7 +6852,8 @@ fold_mathfn_compare (enum built_in_function fcode, enum tree_code code, can be made, and NULL_TREE otherwise. */ static tree -fold_inf_compare (enum tree_code code, tree type, tree arg0, tree arg1) +fold_inf_compare (location_t loc, enum tree_code code, tree type, + tree arg0, tree arg1) { enum machine_mode mode; REAL_VALUE_TYPE max; @@ -6695,19 +6873,19 @@ fold_inf_compare (enum tree_code code, tree type, tree arg0, tree arg1) /* x > +Inf is always false, if with ignore sNANs. */ if (HONOR_SNANS (mode)) return NULL_TREE; - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); case LE_EXPR: /* x <= +Inf is always true, if we don't case about NaNs. */ if (! HONOR_NANS (mode)) - return omit_one_operand (type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, integer_one_node, arg0); /* x <= +Inf is the same as x == x, i.e. isfinite(x). */ if (lang_hooks.decls.global_bindings_p () == 0 && ! CONTAINS_PLACEHOLDER_P (arg0)) { arg0 = save_expr (arg0); - return fold_build2 (EQ_EXPR, type, arg0, arg0); + return fold_build2_loc (loc, EQ_EXPR, type, arg0, arg0); } break; @@ -6715,25 +6893,25 @@ fold_inf_compare (enum tree_code code, tree type, tree arg0, tree arg1) case GE_EXPR: /* x == +Inf and x >= +Inf are always equal to x > DBL_MAX. */ real_maxval (&max, neg, mode); - return fold_build2 (neg ? LT_EXPR : GT_EXPR, type, + return fold_build2_loc (loc, neg ? LT_EXPR : GT_EXPR, type, arg0, build_real (TREE_TYPE (arg0), max)); case LT_EXPR: /* x < +Inf is always equal to x <= DBL_MAX. */ real_maxval (&max, neg, mode); - return fold_build2 (neg ? GE_EXPR : LE_EXPR, type, + return fold_build2_loc (loc, neg ? GE_EXPR : LE_EXPR, type, arg0, build_real (TREE_TYPE (arg0), max)); case NE_EXPR: /* x != +Inf is always equal to !(x > DBL_MAX). */ real_maxval (&max, neg, mode); if (! HONOR_NANS (mode)) - return fold_build2 (neg ? GE_EXPR : LE_EXPR, type, + return fold_build2_loc (loc, neg ? GE_EXPR : LE_EXPR, type, arg0, build_real (TREE_TYPE (arg0), max)); - temp = fold_build2 (neg ? LT_EXPR : GT_EXPR, type, + temp = fold_build2_loc (loc, neg ? LT_EXPR : GT_EXPR, type, arg0, build_real (TREE_TYPE (arg0), max)); - return fold_build1 (TRUTH_NOT_EXPR, type, temp); + return fold_build1_loc (loc, TRUTH_NOT_EXPR, type, temp); default: break; @@ -6754,7 +6932,8 @@ fold_inf_compare (enum tree_code code, tree type, tree arg0, tree arg1) can be made, and NULL_TREE otherwise. */ static tree -fold_div_compare (enum tree_code code, tree type, tree arg0, tree arg1) +fold_div_compare (location_t loc, + enum tree_code code, tree type, tree arg0, tree arg1) { tree prod, tmp, hi, lo; tree arg00 = TREE_OPERAND (arg0, 0); @@ -6851,53 +7030,53 @@ fold_div_compare (enum tree_code code, tree type, tree arg0, tree arg1) { case EQ_EXPR: if (TREE_OVERFLOW (lo) && TREE_OVERFLOW (hi)) - return omit_one_operand (type, integer_zero_node, arg00); + return omit_one_operand_loc (loc, type, integer_zero_node, arg00); if (TREE_OVERFLOW (hi)) - return fold_build2 (GE_EXPR, type, arg00, lo); + return fold_build2_loc (loc, GE_EXPR, type, arg00, lo); if (TREE_OVERFLOW (lo)) - return fold_build2 (LE_EXPR, type, arg00, hi); - return build_range_check (type, arg00, 1, lo, hi); + return fold_build2_loc (loc, LE_EXPR, type, arg00, hi); + return build_range_check (loc, type, arg00, 1, lo, hi); case NE_EXPR: if (TREE_OVERFLOW (lo) && TREE_OVERFLOW (hi)) - return omit_one_operand (type, integer_one_node, arg00); + return omit_one_operand_loc (loc, type, integer_one_node, arg00); if (TREE_OVERFLOW (hi)) - return fold_build2 (LT_EXPR, type, arg00, lo); + return fold_build2_loc (loc, LT_EXPR, type, arg00, lo); if (TREE_OVERFLOW (lo)) - return fold_build2 (GT_EXPR, type, arg00, hi); - return build_range_check (type, arg00, 0, lo, hi); + return fold_build2_loc (loc, GT_EXPR, type, arg00, hi); + return build_range_check (loc, type, arg00, 0, lo, hi); case LT_EXPR: if (TREE_OVERFLOW (lo)) { tmp = neg_overflow ? integer_zero_node : integer_one_node; - return omit_one_operand (type, tmp, arg00); + return omit_one_operand_loc (loc, type, tmp, arg00); } - return fold_build2 (LT_EXPR, type, arg00, lo); + return fold_build2_loc (loc, LT_EXPR, type, arg00, lo); case LE_EXPR: if (TREE_OVERFLOW (hi)) { tmp = neg_overflow ? integer_zero_node : integer_one_node; - return omit_one_operand (type, tmp, arg00); + return omit_one_operand_loc (loc, type, tmp, arg00); } - return fold_build2 (LE_EXPR, type, arg00, hi); + return fold_build2_loc (loc, LE_EXPR, type, arg00, hi); case GT_EXPR: if (TREE_OVERFLOW (hi)) { tmp = neg_overflow ? integer_one_node : integer_zero_node; - return omit_one_operand (type, tmp, arg00); + return omit_one_operand_loc (loc, type, tmp, arg00); } - return fold_build2 (GT_EXPR, type, arg00, hi); + return fold_build2_loc (loc, GT_EXPR, type, arg00, hi); case GE_EXPR: if (TREE_OVERFLOW (lo)) { tmp = neg_overflow ? integer_one_node : integer_zero_node; - return omit_one_operand (type, tmp, arg00); + return omit_one_operand_loc (loc, type, tmp, arg00); } - return fold_build2 (GE_EXPR, type, arg00, lo); + return fold_build2_loc (loc, GE_EXPR, type, arg00, lo); default: break; @@ -6913,7 +7092,8 @@ fold_div_compare (enum tree_code code, tree type, tree arg0, tree arg1) result type. */ static tree -fold_single_bit_test_into_sign_test (enum tree_code code, tree arg0, tree arg1, +fold_single_bit_test_into_sign_test (location_t loc, + enum tree_code code, tree arg0, tree arg1, tree result_type) { /* If this is testing a single bit, we can optimize the test. */ @@ -6932,8 +7112,9 @@ fold_single_bit_test_into_sign_test (enum tree_code code, tree arg0, tree arg1, == GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (arg00)))) { tree stype = signed_type_for (TREE_TYPE (arg00)); - return fold_build2 (code == EQ_EXPR ? GE_EXPR : LT_EXPR, - result_type, fold_convert (stype, arg00), + return fold_build2_loc (loc, code == EQ_EXPR ? GE_EXPR : LT_EXPR, + result_type, + fold_convert_loc (loc, stype, arg00), build_int_cst (stype, 0)); } } @@ -6947,8 +7128,8 @@ fold_single_bit_test_into_sign_test (enum tree_code code, tree arg0, tree arg1, NULL. TYPE is the desired result type. */ tree -fold_single_bit_test (enum tree_code code, tree arg0, tree arg1, - tree result_type) +fold_single_bit_test (location_t loc, enum tree_code code, + tree arg0, tree arg1, tree result_type) { /* If this is testing a single bit, we can optimize the test. */ if ((code == NE_EXPR || code == EQ_EXPR) @@ -6965,7 +7146,7 @@ fold_single_bit_test (enum tree_code code, tree arg0, tree arg1, /* First, see if we can fold the single bit test into a sign-bit test. */ - tem = fold_single_bit_test_into_sign_test (code, arg0, arg1, + tem = fold_single_bit_test_into_sign_test (loc, code, arg0, arg1, result_type); if (tem) return tem; @@ -7000,7 +7181,7 @@ fold_single_bit_test (enum tree_code code, tree arg0, tree arg1, signed_type = lang_hooks.types.type_for_mode (operand_mode, 0); unsigned_type = lang_hooks.types.type_for_mode (operand_mode, 1); intermediate_type = ops_unsigned ? unsigned_type : signed_type; - inner = fold_convert (intermediate_type, inner); + inner = fold_convert_loc (loc, intermediate_type, inner); if (bitnum != 0) inner = build2 (RSHIFT_EXPR, intermediate_type, @@ -7009,13 +7190,13 @@ fold_single_bit_test (enum tree_code code, tree arg0, tree arg1, one = build_int_cst (intermediate_type, 1); if (code == EQ_EXPR) - inner = fold_build2 (BIT_XOR_EXPR, intermediate_type, inner, one); + inner = fold_build2_loc (loc, BIT_XOR_EXPR, intermediate_type, inner, one); /* Put the AND last so it can combine with more things. */ inner = build2 (BIT_AND_EXPR, intermediate_type, inner, one); /* Make sure to return the proper type. */ - inner = fold_convert (result_type, inner); + inner = fold_convert_loc (loc, result_type, inner); return inner; } @@ -7107,7 +7288,8 @@ tree_swap_operands_p (const_tree arg0, const_tree arg1, bool reorder) ARG0 is extended to a wider type. */ static tree -fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1) +fold_widened_comparison (location_t loc, enum tree_code code, + tree type, tree arg0, tree arg1) { tree arg0_unw = get_unwidened (arg0, NULL_TREE); tree arg1_unw; @@ -7145,8 +7327,8 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1) && (TREE_CODE (shorter_type) == INTEGER_TYPE || TREE_CODE (shorter_type) == BOOLEAN_TYPE) && int_fits_type_p (arg1_unw, shorter_type)))) - return fold_build2 (code, type, arg0_unw, - fold_convert (shorter_type, arg1_unw)); + return fold_build2_loc (loc, code, type, arg0_unw, + fold_convert_loc (loc, shorter_type, arg1_unw)); if (TREE_CODE (arg1_unw) != INTEGER_CST || TREE_CODE (shorter_type) != INTEGER_TYPE @@ -7168,27 +7350,27 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1) { case EQ_EXPR: if (above || below) - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); break; case NE_EXPR: if (above || below) - return omit_one_operand (type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, integer_one_node, arg0); break; case LT_EXPR: case LE_EXPR: if (above) - return omit_one_operand (type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, integer_one_node, arg0); else if (below) - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); case GT_EXPR: case GE_EXPR: if (above) - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); else if (below) - return omit_one_operand (type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, integer_one_node, arg0); default: break; @@ -7201,7 +7383,7 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1) ARG0 just the signedness is changed. */ static tree -fold_sign_changed_comparison (enum tree_code code, tree type, +fold_sign_changed_comparison (location_t loc, enum tree_code code, tree type, tree arg0, tree arg1) { tree arg0_inner; @@ -7242,20 +7424,21 @@ fold_sign_changed_comparison (enum tree_code code, tree type, TREE_INT_CST_HIGH (arg1), 0, TREE_OVERFLOW (arg1)); else - arg1 = fold_convert (inner_type, arg1); + arg1 = fold_convert_loc (loc, inner_type, arg1); - return fold_build2 (code, type, arg0_inner, arg1); + return fold_build2_loc (loc, code, type, arg0_inner, arg1); } /* Tries to replace &a[idx] p+ s * delta with &a[idx + delta], if s is - step of the array. Reconstructs s and delta in the case of s * delta - being an integer constant (and thus already folded). - ADDR is the address. MULT is the multiplicative expression. - If the function succeeds, the new address expression is returned. Otherwise - NULL_TREE is returned. */ + step of the array. Reconstructs s and delta in the case of s * + delta being an integer constant (and thus already folded). ADDR is + the address. MULT is the multiplicative expression. If the + function succeeds, the new address expression is returned. + Otherwise NULL_TREE is returned. LOC is the location of the + resulting expression. */ static tree -try_move_mult_to_index (tree addr, tree op1) +try_move_mult_to_index (location_t loc, tree addr, tree op1) { tree s, delta, step; tree ref = TREE_OPERAND (addr, 0), pref; @@ -7342,10 +7525,10 @@ try_move_mult_to_index (tree addr, tree op1) || TREE_CODE (TYPE_MAX_VALUE (itype)) != INTEGER_CST) continue; - tmp = fold_binary (PLUS_EXPR, itype, - fold_convert (itype, - TREE_OPERAND (ref, 1)), - fold_convert (itype, delta)); + tmp = fold_binary_loc (loc, PLUS_EXPR, itype, + fold_convert_loc (loc, itype, + TREE_OPERAND (ref, 1)), + fold_convert_loc (loc, itype, delta)); if (!tmp || TREE_CODE (tmp) != INTEGER_CST || tree_int_cst_lt (TYPE_MAX_VALUE (itype), tmp)) @@ -7366,6 +7549,7 @@ try_move_mult_to_index (tree addr, tree op1) pref = TREE_OPERAND (addr, 0); ret = copy_node (pref); + SET_EXPR_LOCATION (ret, loc); pos = ret; while (pref != ref) @@ -7375,12 +7559,12 @@ try_move_mult_to_index (tree addr, tree op1) pos = TREE_OPERAND (pos, 0); } - TREE_OPERAND (pos, 1) = fold_build2 (PLUS_EXPR, itype, - fold_convert (itype, - TREE_OPERAND (pos, 1)), - fold_convert (itype, delta)); + TREE_OPERAND (pos, 1) = fold_build2_loc (loc, PLUS_EXPR, itype, + fold_convert_loc (loc, itype, + TREE_OPERAND (pos, 1)), + fold_convert_loc (loc, itype, delta)); - return fold_build1 (ADDR_EXPR, TREE_TYPE (addr), ret); + return fold_build1_loc (loc, ADDR_EXPR, TREE_TYPE (addr), ret); } @@ -7389,7 +7573,7 @@ try_move_mult_to_index (tree addr, tree op1) A < X <= MAX. INEQ is A + 1 > Y, BOUND is A < X. */ static tree -fold_to_nonsharp_ineq_using_bound (tree ineq, tree bound) +fold_to_nonsharp_ineq_using_bound (location_t loc, tree ineq, tree bound) { tree a, typea, type = TREE_TYPE (ineq), a1, diff, y; @@ -7424,24 +7608,25 @@ fold_to_nonsharp_ineq_using_bound (tree ineq, tree bound) if (POINTER_TYPE_P (typea)) { /* Convert the pointer types into integer before taking the difference. */ - tree ta = fold_convert (ssizetype, a); - tree ta1 = fold_convert (ssizetype, a1); - diff = fold_binary (MINUS_EXPR, ssizetype, ta1, ta); + tree ta = fold_convert_loc (loc, ssizetype, a); + tree ta1 = fold_convert_loc (loc, ssizetype, a1); + diff = fold_binary_loc (loc, MINUS_EXPR, ssizetype, ta1, ta); } else - diff = fold_binary (MINUS_EXPR, typea, a1, a); + diff = fold_binary_loc (loc, MINUS_EXPR, typea, a1, a); if (!diff || !integer_onep (diff)) return NULL_TREE; - return fold_build2 (GE_EXPR, type, a, y); + return fold_build2_loc (loc, GE_EXPR, type, a, y); } /* Fold a sum or difference of at least one multiplication. Returns the folded tree or NULL if no simplification could be made. */ static tree -fold_plusminus_mult_expr (enum tree_code code, tree type, tree arg0, tree arg1) +fold_plusminus_mult_expr (location_t loc, enum tree_code code, tree type, + tree arg0, tree arg1) { tree arg00, arg01, arg10, arg11; tree alt0 = NULL_TREE, alt1 = NULL_TREE, same; @@ -7539,7 +7724,7 @@ fold_plusminus_mult_expr (enum tree_code code, tree type, tree arg0, tree arg1) increased the number of multiplications necessary. */ && TREE_CODE (arg10) != INTEGER_CST) { - alt0 = fold_build2 (MULT_EXPR, TREE_TYPE (arg00), arg00, + alt0 = fold_build2_loc (loc, MULT_EXPR, TREE_TYPE (arg00), arg00, build_int_cst (TREE_TYPE (arg00), int01 / int11)); alt1 = arg10; @@ -7550,11 +7735,11 @@ fold_plusminus_mult_expr (enum tree_code code, tree type, tree arg0, tree arg1) } if (same) - return fold_build2 (MULT_EXPR, type, - fold_build2 (code, type, - fold_convert (type, alt0), - fold_convert (type, alt1)), - fold_convert (type, same)); + return fold_build2_loc (loc, MULT_EXPR, type, + fold_build2_loc (loc, code, type, + fold_convert_loc (loc, type, alt0), + fold_convert_loc (loc, type, alt1)), + fold_convert_loc (loc, type, same)); return NULL_TREE; } @@ -7987,7 +8172,7 @@ fold_view_convert_expr (tree type, tree expr) to avoid confusing the gimplify process. */ tree -build_fold_addr_expr_with_type (tree t, tree ptrtype) +build_fold_addr_expr_with_type_loc (location_t loc, tree t, tree ptrtype) { /* The size of the object is not relevant when talking about its address. */ if (TREE_CODE (t) == WITH_SIZE_EXPR) @@ -8000,17 +8185,23 @@ build_fold_addr_expr_with_type (tree t, tree ptrtype) t = TREE_OPERAND (t, 0); if (TREE_TYPE (t) != ptrtype) - t = build1 (NOP_EXPR, ptrtype, t); + { + t = build1 (NOP_EXPR, ptrtype, t); + SET_EXPR_LOCATION (t, loc); + } } else if (TREE_CODE (t) == VIEW_CONVERT_EXPR) { - t = build_fold_addr_expr (TREE_OPERAND (t, 0)); + t = build_fold_addr_expr_loc (loc, TREE_OPERAND (t, 0)); if (TREE_TYPE (t) != ptrtype) - t = fold_convert (ptrtype, t); + t = fold_convert_loc (loc, ptrtype, t); } else - t = build1 (ADDR_EXPR, ptrtype, t); + { + t = build1 (ADDR_EXPR, ptrtype, t); + SET_EXPR_LOCATION (t, loc); + } return t; } @@ -8018,11 +8209,11 @@ build_fold_addr_expr_with_type (tree t, tree ptrtype) /* Build an expression for the address of T. */ tree -build_fold_addr_expr (tree t) +build_fold_addr_expr_loc (location_t loc, tree t) { tree ptrtype = build_pointer_type (TREE_TYPE (t)); - return build_fold_addr_expr_with_type (t, ptrtype); + return build_fold_addr_expr_with_type_loc (loc, t, ptrtype); } /* Fold a unary expression of code CODE and type TYPE with operand @@ -8030,7 +8221,7 @@ build_fold_addr_expr (tree t) Otherwise, return NULL_TREE. */ tree -fold_unary (enum tree_code code, tree type, tree op0) +fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) { tree tem; tree arg0; @@ -8070,20 +8261,22 @@ fold_unary (enum tree_code code, tree type, tree op0) { if (TREE_CODE (arg0) == COMPOUND_EXPR) return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg0, 0), - fold_build1 (code, type, - fold_convert (TREE_TYPE (op0), - TREE_OPERAND (arg0, 1)))); + fold_build1_loc (loc, code, type, + fold_convert_loc (loc, TREE_TYPE (op0), + TREE_OPERAND (arg0, 1)))); else if (TREE_CODE (arg0) == COND_EXPR) { tree arg01 = TREE_OPERAND (arg0, 1); tree arg02 = TREE_OPERAND (arg0, 2); if (! VOID_TYPE_P (TREE_TYPE (arg01))) - arg01 = fold_build1 (code, type, - fold_convert (TREE_TYPE (op0), arg01)); + arg01 = fold_build1_loc (loc, code, type, + fold_convert_loc (loc, + TREE_TYPE (op0), arg01)); if (! VOID_TYPE_P (TREE_TYPE (arg02))) - arg02 = fold_build1 (code, type, - fold_convert (TREE_TYPE (op0), arg02)); - tem = fold_build3 (COND_EXPR, type, TREE_OPERAND (arg0, 0), + arg02 = fold_build1_loc (loc, code, type, + fold_convert_loc (loc, + TREE_TYPE (op0), arg02)); + tem = fold_build3_loc (loc, COND_EXPR, type, TREE_OPERAND (arg0, 0), arg01, arg02); /* If this was a conversion, and all we did was to move into @@ -8109,13 +8302,16 @@ fold_unary (enum tree_code code, tree type, tree op0) (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (tem, 1), 0)))) && TYPE_PRECISION (TREE_TYPE (tem)) <= BITS_PER_WORD) || flag_syntax_only)) - tem = build1 (code, type, - build3 (COND_EXPR, - TREE_TYPE (TREE_OPERAND - (TREE_OPERAND (tem, 1), 0)), - TREE_OPERAND (tem, 0), - TREE_OPERAND (TREE_OPERAND (tem, 1), 0), - TREE_OPERAND (TREE_OPERAND (tem, 2), 0))); + { + tem = build1 (code, type, + build3 (COND_EXPR, + TREE_TYPE (TREE_OPERAND + (TREE_OPERAND (tem, 1), 0)), + TREE_OPERAND (tem, 0), + TREE_OPERAND (TREE_OPERAND (tem, 1), 0), + TREE_OPERAND (TREE_OPERAND (tem, 2), 0))); + SET_EXPR_LOCATION (tem, loc); + } return tem; } else if (COMPARISON_CLASS_P (arg0)) @@ -8127,10 +8323,10 @@ fold_unary (enum tree_code code, tree type, tree op0) return arg0; } else if (TREE_CODE (type) != INTEGER_TYPE) - return fold_build3 (COND_EXPR, type, arg0, - fold_build1 (code, type, + return fold_build3_loc (loc, COND_EXPR, type, arg0, + fold_build1_loc (loc, code, type, integer_one_node), - fold_build1 (code, type, + fold_build1_loc (loc, code, type, integer_zero_node)); } } @@ -8142,7 +8338,7 @@ fold_unary (enum tree_code code, tree type, tree op0) barriers can be removed. */ if (CONSTANT_CLASS_P (op0) || TREE_CODE (op0) == PAREN_EXPR) - return fold_convert (type, op0); + return fold_convert_loc (loc, type, op0); return NULL_TREE; CASE_CONVERT: @@ -8154,7 +8350,7 @@ fold_unary (enum tree_code code, tree type, tree op0) /* If we have (type) (a CMP b) and type is an integral type, return new expression involving the new type. */ if (COMPARISON_CLASS_P (op0) && INTEGRAL_TYPE_P (type)) - return fold_build2 (TREE_CODE (op0), type, TREE_OPERAND (op0, 0), + return fold_build2_loc (loc, TREE_CODE (op0), type, TREE_OPERAND (op0, 0), TREE_OPERAND (op0, 1)); /* Handle cases of two conversions in a row. */ @@ -8189,7 +8385,7 @@ fold_unary (enum tree_code code, tree type, tree op0) && (((inter_int || inter_ptr) && final_int) || (inter_float && final_float)) && inter_prec >= final_prec) - return fold_build1 (code, type, TREE_OPERAND (op0, 0)); + return fold_build1_loc (loc, code, type, TREE_OPERAND (op0, 0)); /* Likewise, if the intermediate and initial types are either both float or both integer, we don't need the middle conversion if the @@ -8207,14 +8403,14 @@ fold_unary (enum tree_code code, tree type, tree op0) && TYPE_MODE (type) == TYPE_MODE (inter_type)) && ! final_ptr && (! final_vec || inter_prec == inside_prec)) - return fold_build1 (code, type, TREE_OPERAND (op0, 0)); + return fold_build1_loc (loc, code, type, TREE_OPERAND (op0, 0)); /* If we have a sign-extension of a zero-extended value, we can replace that by a single zero-extension. */ if (inside_int && inter_int && final_int && inside_prec < inter_prec && inter_prec < final_prec && inside_unsignedp && !inter_unsignedp) - return fold_build1 (code, type, TREE_OPERAND (op0, 0)); + return fold_build1_loc (loc, code, type, TREE_OPERAND (op0, 0)); /* Two conversions in a row are not needed unless: - some conversion is floating-point (overstrict for now), or @@ -8239,7 +8435,7 @@ fold_unary (enum tree_code code, tree type, tree op0) && ! (final_ptr && inside_prec != inter_prec) && ! (final_prec != GET_MODE_BITSIZE (TYPE_MODE (type)) && TYPE_MODE (type) == TYPE_MODE (inter_type))) - return fold_build1 (code, type, TREE_OPERAND (op0, 0)); + return fold_build1_loc (loc, code, type, TREE_OPERAND (op0, 0)); } /* Handle (T *)&A.B.C for A being of type T and B and C @@ -8262,7 +8458,8 @@ fold_unary (enum tree_code code, tree type, tree op0) if (! offset && bitpos == 0 && TYPE_MAIN_VARIANT (TREE_TYPE (type)) == TYPE_MAIN_VARIANT (TREE_TYPE (base))) - return fold_convert (type, build_fold_addr_expr (base)); + return fold_convert_loc (loc, type, + build_fold_addr_expr_loc (loc, base)); } if (TREE_CODE (op0) == MODIFY_EXPR @@ -8274,11 +8471,12 @@ fold_unary (enum tree_code code, tree type, tree op0) { /* Don't leave an assignment inside a conversion unless assigning a bitfield. */ - tem = fold_build1 (code, type, TREE_OPERAND (op0, 1)); + tem = fold_build1_loc (loc, code, type, TREE_OPERAND (op0, 1)); /* First do the assignment, then return converted constant. */ tem = build2 (COMPOUND_EXPR, TREE_TYPE (tem), op0, tem); TREE_NO_WARNING (tem) = 1; TREE_USED (tem) = 1; + SET_EXPR_LOCATION (tem, loc); return tem; } @@ -8318,8 +8516,8 @@ fold_unary (enum tree_code code, tree type, tree op0) == ZERO_EXTEND)) { tree uns = unsigned_type_for (TREE_TYPE (and0)); - and0 = fold_convert (uns, and0); - and1 = fold_convert (uns, and1); + and0 = fold_convert_loc (loc, uns, and0); + and1 = fold_convert_loc (loc, uns, and1); } #endif } @@ -8328,8 +8526,8 @@ fold_unary (enum tree_code code, tree type, tree op0) tem = force_fit_type_double (type, TREE_INT_CST_LOW (and1), TREE_INT_CST_HIGH (and1), 0, TREE_OVERFLOW (and1)); - return fold_build2 (BIT_AND_EXPR, type, - fold_convert (type, and0), tem); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_convert_loc (loc, type, and0), tem); } } @@ -8345,8 +8543,10 @@ fold_unary (enum tree_code code, tree type, tree op0) tree arg00 = TREE_OPERAND (arg0, 0); tree arg01 = TREE_OPERAND (arg0, 1); - return fold_build2 (TREE_CODE (arg0), type, fold_convert (type, arg00), - fold_convert (sizetype, arg01)); + return fold_build2_loc (loc, + TREE_CODE (arg0), type, + fold_convert_loc (loc, type, arg00), + fold_convert_loc (loc, sizetype, arg01)); } /* Convert (T1)(~(T2)X) into ~(T1)X if T1 and T2 are integral types @@ -8361,7 +8561,8 @@ fold_unary (enum tree_code code, tree type, tree op0) tem = TREE_OPERAND (TREE_OPERAND (op0, 0), 0); if (INTEGRAL_TYPE_P (TREE_TYPE (tem)) && TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (tem))) - return fold_build1 (BIT_NOT_EXPR, type, fold_convert (type, tem)); + return fold_build1_loc (loc, BIT_NOT_EXPR, type, + fold_convert_loc (loc, type, tem)); } /* Convert (T1)(X * Y) into (T1)X * (T1)Y if T1 is narrower than the @@ -8380,12 +8581,12 @@ fold_unary (enum tree_code code, tree type, tree op0) if (TYPE_PRECISION (mult_type) < TYPE_PRECISION (TREE_TYPE (op0))) { - tem = fold_build2 (MULT_EXPR, mult_type, - fold_convert (mult_type, - TREE_OPERAND (op0, 0)), - fold_convert (mult_type, - TREE_OPERAND (op0, 1))); - return fold_convert (type, tem); + tem = fold_build2_loc (loc, MULT_EXPR, mult_type, + fold_convert_loc (loc, mult_type, + TREE_OPERAND (op0, 0)), + fold_convert_loc (loc, mult_type, + TREE_OPERAND (op0, 1))); + return fold_convert_loc (loc, type, tem); } } @@ -8400,7 +8601,8 @@ fold_unary (enum tree_code code, tree type, tree op0) if (TREE_TYPE (op0) == type) return op0; if (TREE_CODE (op0) == VIEW_CONVERT_EXPR) - return fold_build1 (VIEW_CONVERT_EXPR, type, TREE_OPERAND (op0, 0)); + return fold_build1_loc (loc, VIEW_CONVERT_EXPR, + type, TREE_OPERAND (op0, 0)); /* For integral conversions with the same precision or pointer conversions use a NOP_EXPR instead. */ @@ -8409,7 +8611,7 @@ fold_unary (enum tree_code code, tree type, tree op0) && (INTEGRAL_TYPE_P (TREE_TYPE (op0)) || POINTER_TYPE_P (TREE_TYPE (op0))) && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (op0))) - return fold_convert (type, op0); + return fold_convert_loc (loc, type, op0); /* Strip inner integral conversions that do not change the precision. */ if (CONVERT_EXPR_P (op0) @@ -8419,30 +8621,32 @@ fold_unary (enum tree_code code, tree type, tree op0) || POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (op0, 0)))) && (TYPE_PRECISION (TREE_TYPE (op0)) == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0))))) - return fold_build1 (VIEW_CONVERT_EXPR, type, TREE_OPERAND (op0, 0)); + return fold_build1_loc (loc, VIEW_CONVERT_EXPR, + type, TREE_OPERAND (op0, 0)); return fold_view_convert_expr (type, op0); case NEGATE_EXPR: - tem = fold_negate_expr (arg0); + tem = fold_negate_expr (loc, arg0); if (tem) - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); return NULL_TREE; case ABS_EXPR: if (TREE_CODE (arg0) == INTEGER_CST || TREE_CODE (arg0) == REAL_CST) return fold_abs_const (arg0, type); else if (TREE_CODE (arg0) == NEGATE_EXPR) - return fold_build1 (ABS_EXPR, type, TREE_OPERAND (arg0, 0)); + return fold_build1_loc (loc, ABS_EXPR, type, TREE_OPERAND (arg0, 0)); /* Convert fabs((double)float) into (double)fabsf(float). */ else if (TREE_CODE (arg0) == NOP_EXPR && TREE_CODE (type) == REAL_TYPE) { tree targ0 = strip_float_extensions (arg0); if (targ0 != arg0) - return fold_convert (type, fold_build1 (ABS_EXPR, - TREE_TYPE (targ0), - targ0)); + return fold_convert_loc (loc, type, + fold_build1_loc (loc, ABS_EXPR, + TREE_TYPE (targ0), + targ0)); } /* ABS_EXPR<ABS_EXPR<x>> = ABS_EXPR<x> even if flag_wrapv is on. */ else if (TREE_CODE (arg0) == ABS_EXPR) @@ -8455,40 +8659,42 @@ fold_unary (enum tree_code code, tree type, tree op0) { tem = fold_strip_sign_ops (arg0); if (tem) - return fold_build1 (ABS_EXPR, type, fold_convert (type, tem)); + return fold_build1_loc (loc, ABS_EXPR, type, + fold_convert_loc (loc, type, tem)); } return NULL_TREE; case CONJ_EXPR: if (TREE_CODE (TREE_TYPE (arg0)) != COMPLEX_TYPE) - return fold_convert (type, arg0); + return fold_convert_loc (loc, type, arg0); if (TREE_CODE (arg0) == COMPLEX_EXPR) { tree itype = TREE_TYPE (type); - tree rpart = fold_convert (itype, TREE_OPERAND (arg0, 0)); - tree ipart = fold_convert (itype, TREE_OPERAND (arg0, 1)); - return fold_build2 (COMPLEX_EXPR, type, rpart, negate_expr (ipart)); + tree rpart = fold_convert_loc (loc, itype, TREE_OPERAND (arg0, 0)); + tree ipart = fold_convert_loc (loc, itype, TREE_OPERAND (arg0, 1)); + return fold_build2_loc (loc, COMPLEX_EXPR, type, rpart, + negate_expr (ipart)); } if (TREE_CODE (arg0) == COMPLEX_CST) { tree itype = TREE_TYPE (type); - tree rpart = fold_convert (itype, TREE_REALPART (arg0)); - tree ipart = fold_convert (itype, TREE_IMAGPART (arg0)); + tree rpart = fold_convert_loc (loc, itype, TREE_REALPART (arg0)); + tree ipart = fold_convert_loc (loc, itype, TREE_IMAGPART (arg0)); return build_complex (type, rpart, negate_expr (ipart)); } if (TREE_CODE (arg0) == CONJ_EXPR) - return fold_convert (type, TREE_OPERAND (arg0, 0)); + return fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); return NULL_TREE; case BIT_NOT_EXPR: if (TREE_CODE (arg0) == INTEGER_CST) return fold_not_const (arg0, type); else if (TREE_CODE (arg0) == BIT_NOT_EXPR) - return fold_convert (type, TREE_OPERAND (arg0, 0)); + return fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); /* Convert ~ (-A) to A - 1. */ else if (INTEGRAL_TYPE_P (type) && TREE_CODE (arg0) == NEGATE_EXPR) - return fold_build2 (MINUS_EXPR, type, - fold_convert (type, TREE_OPERAND (arg0, 0)), + return fold_build2_loc (loc, MINUS_EXPR, type, + fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)), build_int_cst (type, 1)); /* Convert ~ (A - 1) or ~ (A + -1) to -A. */ else if (INTEGRAL_TYPE_P (type) @@ -8496,21 +8702,24 @@ fold_unary (enum tree_code code, tree type, tree op0) && integer_onep (TREE_OPERAND (arg0, 1))) || (TREE_CODE (arg0) == PLUS_EXPR && integer_all_onesp (TREE_OPERAND (arg0, 1))))) - return fold_build1 (NEGATE_EXPR, type, - fold_convert (type, TREE_OPERAND (arg0, 0))); + return fold_build1_loc (loc, NEGATE_EXPR, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0))); /* Convert ~(X ^ Y) to ~X ^ Y or X ^ ~Y if ~X or ~Y simplify. */ else if (TREE_CODE (arg0) == BIT_XOR_EXPR - && (tem = fold_unary (BIT_NOT_EXPR, type, - fold_convert (type, - TREE_OPERAND (arg0, 0))))) - return fold_build2 (BIT_XOR_EXPR, type, tem, - fold_convert (type, TREE_OPERAND (arg0, 1))); + && (tem = fold_unary_loc (loc, BIT_NOT_EXPR, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0))))) + return fold_build2_loc (loc, BIT_XOR_EXPR, type, tem, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 1))); else if (TREE_CODE (arg0) == BIT_XOR_EXPR - && (tem = fold_unary (BIT_NOT_EXPR, type, - fold_convert (type, - TREE_OPERAND (arg0, 1))))) - return fold_build2 (BIT_XOR_EXPR, type, - fold_convert (type, TREE_OPERAND (arg0, 0)), tem); + && (tem = fold_unary_loc (loc, BIT_NOT_EXPR, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 1))))) + return fold_build2_loc (loc, BIT_XOR_EXPR, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0)), tem); /* Perform BIT_NOT_EXPR on each element individually. */ else if (TREE_CODE (arg0) == VECTOR_CST) { @@ -8522,7 +8731,7 @@ fold_unary (enum tree_code code, tree type, tree op0) if (elements) { elem = TREE_VALUE (elements); - elem = fold_unary (BIT_NOT_EXPR, TREE_TYPE (type), elem); + elem = fold_unary_loc (loc, BIT_NOT_EXPR, TREE_TYPE (type), elem); if (elem == NULL_TREE) break; elements = TREE_CHAIN (elements); @@ -8540,40 +8749,41 @@ fold_unary (enum tree_code code, tree type, tree op0) case TRUTH_NOT_EXPR: /* The argument to invert_truthvalue must have Boolean type. */ if (TREE_CODE (TREE_TYPE (arg0)) != BOOLEAN_TYPE) - arg0 = fold_convert (boolean_type_node, arg0); + arg0 = fold_convert_loc (loc, boolean_type_node, arg0); /* Note that the operand of this must be an int and its values must be 0 or 1. ("true" is a fixed value perhaps depending on the language, but we don't handle values other than 1 correctly yet.) */ - tem = fold_truth_not_expr (arg0); + tem = fold_truth_not_expr (loc, arg0); if (!tem) return NULL_TREE; - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); case REALPART_EXPR: if (TREE_CODE (TREE_TYPE (arg0)) != COMPLEX_TYPE) - return fold_convert (type, arg0); + return fold_convert_loc (loc, type, arg0); if (TREE_CODE (arg0) == COMPLEX_EXPR) - return omit_one_operand (type, TREE_OPERAND (arg0, 0), + return omit_one_operand_loc (loc, type, TREE_OPERAND (arg0, 0), TREE_OPERAND (arg0, 1)); if (TREE_CODE (arg0) == COMPLEX_CST) - return fold_convert (type, TREE_REALPART (arg0)); + return fold_convert_loc (loc, type, TREE_REALPART (arg0)); if (TREE_CODE (arg0) == PLUS_EXPR || TREE_CODE (arg0) == MINUS_EXPR) { tree itype = TREE_TYPE (TREE_TYPE (arg0)); - tem = fold_build2 (TREE_CODE (arg0), itype, - fold_build1 (REALPART_EXPR, itype, + tem = fold_build2_loc (loc, TREE_CODE (arg0), itype, + fold_build1_loc (loc, REALPART_EXPR, itype, TREE_OPERAND (arg0, 0)), - fold_build1 (REALPART_EXPR, itype, + fold_build1_loc (loc, REALPART_EXPR, itype, TREE_OPERAND (arg0, 1))); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } if (TREE_CODE (arg0) == CONJ_EXPR) { tree itype = TREE_TYPE (TREE_TYPE (arg0)); - tem = fold_build1 (REALPART_EXPR, itype, TREE_OPERAND (arg0, 0)); - return fold_convert (type, tem); + tem = fold_build1_loc (loc, REALPART_EXPR, itype, + TREE_OPERAND (arg0, 0)); + return fold_convert_loc (loc, type, tem); } if (TREE_CODE (arg0) == CALL_EXPR) { @@ -8584,7 +8794,7 @@ fold_unary (enum tree_code code, tree type, tree op0) CASE_FLT_FN (BUILT_IN_CEXPI): fn = mathfn_built_in (type, BUILT_IN_COS); if (fn) - return build_call_expr (fn, 1, CALL_EXPR_ARG (arg0, 0)); + return build_call_expr_loc (loc, fn, 1, CALL_EXPR_ARG (arg0, 0)); break; default: @@ -8595,27 +8805,27 @@ fold_unary (enum tree_code code, tree type, tree op0) case IMAGPART_EXPR: if (TREE_CODE (TREE_TYPE (arg0)) != COMPLEX_TYPE) - return fold_convert (type, integer_zero_node); + return fold_convert_loc (loc, type, integer_zero_node); if (TREE_CODE (arg0) == COMPLEX_EXPR) - return omit_one_operand (type, TREE_OPERAND (arg0, 1), + return omit_one_operand_loc (loc, type, TREE_OPERAND (arg0, 1), TREE_OPERAND (arg0, 0)); if (TREE_CODE (arg0) == COMPLEX_CST) - return fold_convert (type, TREE_IMAGPART (arg0)); + return fold_convert_loc (loc, type, TREE_IMAGPART (arg0)); if (TREE_CODE (arg0) == PLUS_EXPR || TREE_CODE (arg0) == MINUS_EXPR) { tree itype = TREE_TYPE (TREE_TYPE (arg0)); - tem = fold_build2 (TREE_CODE (arg0), itype, - fold_build1 (IMAGPART_EXPR, itype, + tem = fold_build2_loc (loc, TREE_CODE (arg0), itype, + fold_build1_loc (loc, IMAGPART_EXPR, itype, TREE_OPERAND (arg0, 0)), - fold_build1 (IMAGPART_EXPR, itype, + fold_build1_loc (loc, IMAGPART_EXPR, itype, TREE_OPERAND (arg0, 1))); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } if (TREE_CODE (arg0) == CONJ_EXPR) { tree itype = TREE_TYPE (TREE_TYPE (arg0)); - tem = fold_build1 (IMAGPART_EXPR, itype, TREE_OPERAND (arg0, 0)); - return fold_convert (type, negate_expr (tem)); + tem = fold_build1_loc (loc, IMAGPART_EXPR, itype, TREE_OPERAND (arg0, 0)); + return fold_convert_loc (loc, type, negate_expr (tem)); } if (TREE_CODE (arg0) == CALL_EXPR) { @@ -8626,7 +8836,7 @@ fold_unary (enum tree_code code, tree type, tree op0) CASE_FLT_FN (BUILT_IN_CEXPI): fn = mathfn_built_in (type, BUILT_IN_SIN); if (fn) - return build_call_expr (fn, 1, CALL_EXPR_ARG (arg0, 0)); + return build_call_expr_loc (loc, fn, 1, CALL_EXPR_ARG (arg0, 0)); break; default: @@ -8646,9 +8856,10 @@ fold_unary (enum tree_code code, tree type, tree op0) have implementation defined behavior and retaining the TREE_OVERFLOW flag here would confuse later passes such as VRP. */ tree -fold_unary_ignore_overflow (enum tree_code code, tree type, tree op0) +fold_unary_ignore_overflow_loc (location_t loc, enum tree_code code, + tree type, tree op0) { - tree res = fold_unary (code, type, op0); + tree res = fold_unary_loc (loc, code, type, op0); if (res && TREE_CODE (res) == INTEGER_CST && TREE_CODE (op0) == INTEGER_CST @@ -8664,7 +8875,7 @@ fold_unary_ignore_overflow (enum tree_code code, tree type, tree op0) return NULL_TREE. */ static tree -fold_minmax (enum tree_code code, tree type, tree op0, tree op1) +fold_minmax (location_t loc, enum tree_code code, tree type, tree op0, tree op1) { enum tree_code compl_code; @@ -8678,25 +8889,25 @@ fold_minmax (enum tree_code code, tree type, tree op0, tree op1) /* MIN (MAX (a, b), b) == b. */ if (TREE_CODE (op0) == compl_code && operand_equal_p (TREE_OPERAND (op0, 1), op1, 0)) - return omit_one_operand (type, op1, TREE_OPERAND (op0, 0)); + return omit_one_operand_loc (loc, type, op1, TREE_OPERAND (op0, 0)); /* MIN (MAX (b, a), b) == b. */ if (TREE_CODE (op0) == compl_code && operand_equal_p (TREE_OPERAND (op0, 0), op1, 0) && reorder_operands_p (TREE_OPERAND (op0, 1), op1)) - return omit_one_operand (type, op1, TREE_OPERAND (op0, 1)); + return omit_one_operand_loc (loc, type, op1, TREE_OPERAND (op0, 1)); /* MIN (a, MAX (a, b)) == a. */ if (TREE_CODE (op1) == compl_code && operand_equal_p (op0, TREE_OPERAND (op1, 0), 0) && reorder_operands_p (op0, TREE_OPERAND (op1, 1))) - return omit_one_operand (type, op0, TREE_OPERAND (op1, 1)); + return omit_one_operand_loc (loc, type, op0, TREE_OPERAND (op1, 1)); /* MIN (a, MAX (b, a)) == a. */ if (TREE_CODE (op1) == compl_code && operand_equal_p (op0, TREE_OPERAND (op1, 1), 0) && reorder_operands_p (op0, TREE_OPERAND (op1, 0))) - return omit_one_operand (type, op0, TREE_OPERAND (op1, 0)); + return omit_one_operand_loc (loc, type, op0, TREE_OPERAND (op1, 0)); return NULL_TREE; } @@ -8710,7 +8921,7 @@ fold_minmax (enum tree_code code, tree type, tree op0, tree op1) valid if signed overflow is undefined. */ static tree -maybe_canonicalize_comparison_1 (enum tree_code code, tree type, +maybe_canonicalize_comparison_1 (location_t loc, enum tree_code code, tree type, tree arg0, tree arg1, bool *strict_overflow_p) { @@ -8803,13 +9014,13 @@ maybe_canonicalize_comparison_1 (enum tree_code code, tree type, t = int_const_binop (sgn0 == -1 ? PLUS_EXPR : MINUS_EXPR, cst0, build_int_cst (TREE_TYPE (cst0), 1), 0); if (code0 != INTEGER_CST) - t = fold_build2 (code0, TREE_TYPE (arg0), TREE_OPERAND (arg0, 0), t); + t = fold_build2_loc (loc, code0, TREE_TYPE (arg0), TREE_OPERAND (arg0, 0), t); /* If swapping might yield to a more canonical form, do so. */ if (swap) - return fold_build2 (swap_tree_comparison (code), type, arg1, t); + return fold_build2_loc (loc, swap_tree_comparison (code), type, arg1, t); else - return fold_build2 (code, type, t, arg1); + return fold_build2_loc (loc, code, type, t, arg1); } /* Canonicalize the comparison ARG0 CODE ARG1 with type TYPE with undefined @@ -8819,7 +9030,7 @@ maybe_canonicalize_comparison_1 (enum tree_code code, tree type, Returns the canonicalized tree if changed, otherwise NULL_TREE. */ static tree -maybe_canonicalize_comparison (enum tree_code code, tree type, +maybe_canonicalize_comparison (location_t loc, enum tree_code code, tree type, tree arg0, tree arg1) { tree t; @@ -8829,7 +9040,7 @@ maybe_canonicalize_comparison (enum tree_code code, tree type, /* Try canonicalization by simplifying arg0. */ strict_overflow_p = false; - t = maybe_canonicalize_comparison_1 (code, type, arg0, arg1, + t = maybe_canonicalize_comparison_1 (loc, code, type, arg0, arg1, &strict_overflow_p); if (t) { @@ -8842,7 +9053,7 @@ maybe_canonicalize_comparison (enum tree_code code, tree type, comparison. */ code = swap_tree_comparison (code); strict_overflow_p = false; - t = maybe_canonicalize_comparison_1 (code, type, arg1, arg0, + t = maybe_canonicalize_comparison_1 (loc, code, type, arg1, arg0, &strict_overflow_p); if (t && strict_overflow_p) fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MAGNITUDE); @@ -8914,7 +9125,8 @@ pointer_may_wrap_p (tree base, tree offset, HOST_WIDE_INT bitpos) the folded comparison or NULL_TREE. */ static tree -fold_comparison (enum tree_code code, tree type, tree op0, tree op1) +fold_comparison (location_t loc, enum tree_code code, tree type, + tree op0, tree op1) { tree arg0, arg1, tem; @@ -8930,7 +9142,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) /* If one arg is a real or integer constant, put it last. */ if (tree_swap_operands_p (arg0, arg1, true)) - return fold_build2 (swap_tree_comparison (code), type, op1, op0); + return fold_build2_loc (loc, swap_tree_comparison (code), type, op1, op0); /* Transform comparisons of the form X +- C1 CMP C2 to X CMP C2 +- C1. */ if ((TREE_CODE (arg0) == PLUS_EXPR || TREE_CODE (arg0) == MINUS_EXPR) @@ -8947,7 +9159,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) int lhs_add; lhs_add = TREE_CODE (arg0) != PLUS_EXPR; - lhs = fold_build2 (lhs_add ? PLUS_EXPR : MINUS_EXPR, + lhs = fold_build2_loc (loc, lhs_add ? PLUS_EXPR : MINUS_EXPR, TREE_TYPE (arg1), const2, const1); /* If the constant operation overflowed this can be @@ -8976,11 +9188,11 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) if (code2 == LT_EXPR || code2 == LE_EXPR || code2 == EQ_EXPR) - return omit_one_operand (type, boolean_false_node, variable); + return omit_one_operand_loc (loc, type, boolean_false_node, variable); else if (code2 == NE_EXPR || code2 == GE_EXPR || code2 == GT_EXPR) - return omit_one_operand (type, boolean_true_node, variable); + return omit_one_operand_loc (loc, type, boolean_true_node, variable); } if (TREE_CODE (lhs) == TREE_CODE (arg1) @@ -8991,7 +9203,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) "when changing X +- C1 cmp C2 to " "X cmp C1 +- C2"), WARN_STRICT_OVERFLOW_COMPARISON); - return fold_build2 (code, type, variable, lhs); + return fold_build2_loc (loc, code, type, variable, lhs); } } @@ -9112,11 +9324,13 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) if (offset0 == NULL_TREE) offset0 = build_int_cst (signed_size_type_node, 0); else - offset0 = fold_convert (signed_size_type_node, offset0); + offset0 = fold_convert_loc (loc, signed_size_type_node, + offset0); if (offset1 == NULL_TREE) offset1 = build_int_cst (signed_size_type_node, 0); else - offset1 = fold_convert (signed_size_type_node, offset1); + offset1 = fold_convert_loc (loc, signed_size_type_node, + offset1); if (code != EQ_EXPR && code != NE_EXPR @@ -9127,7 +9341,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) "P +- C2"), WARN_STRICT_OVERFLOW_COMPARISON); - return fold_build2 (code, type, offset0, offset1); + return fold_build2_loc (loc, code, type, offset0, offset1); } } /* For non-equal bases we can simplify if they are addresses @@ -9151,9 +9365,11 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) || CONSTANT_CLASS_P (base1))) { if (code == EQ_EXPR) - return omit_two_operands (type, boolean_false_node, arg0, arg1); + return omit_two_operands_loc (loc, type, boolean_false_node, + arg0, arg1); else if (code == NE_EXPR) - return omit_two_operands (type, boolean_true_node, arg0, arg1); + return omit_two_operands_loc (loc, type, boolean_true_node, + arg0, arg1); } /* For equal offsets we can simplify to a comparison of the base addresses. */ @@ -9167,10 +9383,10 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) && operand_equal_p (offset0, offset1, 0)))) { if (indirect_base0) - base0 = build_fold_addr_expr (base0); + base0 = build_fold_addr_expr_loc (loc, base0); if (indirect_base1) - base1 = build_fold_addr_expr (base1); - return fold_build2 (code, type, base0, base1); + base1 = build_fold_addr_expr_loc (loc, base1); + return fold_build2_loc (loc, code, type, base0, base1); } } @@ -9204,9 +9420,10 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) && tree_int_cst_compare (const2, cst) == tree_int_cst_sgn (const2)) { fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON); - return fold_build2 (code, type, + return fold_build2_loc (loc, code, type, variable1, - fold_build2 (TREE_CODE (arg1), TREE_TYPE (arg1), + fold_build2_loc (loc, + TREE_CODE (arg1), TREE_TYPE (arg1), variable2, cst)); } @@ -9217,8 +9434,8 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) && tree_int_cst_compare (const1, cst) == tree_int_cst_sgn (const1)) { fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON); - return fold_build2 (code, type, - fold_build2 (TREE_CODE (arg0), TREE_TYPE (arg0), + return fold_build2_loc (loc, code, type, + fold_build2_loc (loc, TREE_CODE (arg0), TREE_TYPE (arg0), variable1, cst), variable2); } @@ -9250,10 +9467,10 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) if (tree_int_cst_sgn (const1) < 0) cmp_code = swap_tree_comparison (cmp_code); - return fold_build2 (cmp_code, type, variable1, const2); + return fold_build2_loc (loc, cmp_code, type, variable1, const2); } - tem = maybe_canonicalize_comparison (code, type, op0, op1); + tem = maybe_canonicalize_comparison (loc, code, type, op0, op1); if (tem) return tem; @@ -9268,13 +9485,14 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) /* Fold (double)float1 CMP (double)float2 into float1 CMP float2. */ if (TYPE_PRECISION (newtype) < TYPE_PRECISION (TREE_TYPE (arg0))) - return fold_build2 (code, type, fold_convert (newtype, targ0), - fold_convert (newtype, targ1)); + return fold_build2_loc (loc, code, type, + fold_convert_loc (loc, newtype, targ0), + fold_convert_loc (loc, newtype, targ1)); /* (-a) CMP (-b) -> b CMP a */ if (TREE_CODE (arg0) == NEGATE_EXPR && TREE_CODE (arg1) == NEGATE_EXPR) - return fold_build2 (code, type, TREE_OPERAND (arg1, 0), + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg1, 0), TREE_OPERAND (arg0, 0)); if (TREE_CODE (arg1) == REAL_CST) @@ -9284,7 +9502,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) /* (-a) CMP CST -> a swap(CMP) (-CST) */ if (TREE_CODE (arg0) == NEGATE_EXPR) - return fold_build2 (swap_tree_comparison (code), type, + return fold_build2_loc (loc, swap_tree_comparison (code), type, TREE_OPERAND (arg0, 0), build_real (TREE_TYPE (arg1), REAL_VALUE_NEGATE (cst))); @@ -9292,7 +9510,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) /* IEEE doesn't distinguish +0 and -0 in comparisons. */ /* a CMP (-0) -> a CMP 0 */ if (REAL_VALUE_MINUS_ZERO (cst)) - return fold_build2 (code, type, arg0, + return fold_build2_loc (loc, code, type, arg0, build_real (TREE_TYPE (arg1), dconst0)); /* x != NaN is always true, other ops are always false. */ @@ -9300,14 +9518,14 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) && ! HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg1)))) { tem = (code == NE_EXPR) ? integer_one_node : integer_zero_node; - return omit_one_operand (type, tem, arg0); + return omit_one_operand_loc (loc, type, tem, arg0); } /* Fold comparisons against infinity. */ if (REAL_VALUE_ISINF (cst) && MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg1)))) { - tem = fold_inf_compare (code, type, arg0, arg1); + tem = fold_inf_compare (loc, code, type, arg0, arg1); if (tem != NULL_TREE) return tem; } @@ -9326,7 +9544,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) ? MINUS_EXPR : PLUS_EXPR, arg1, TREE_OPERAND (arg0, 1), 0)) && !TREE_OVERFLOW (tem)) - return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem); + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), tem); /* Likewise, we can simplify a comparison of a real constant with a MINUS_EXPR whose first operand is also a real constant, i.e. @@ -9339,7 +9557,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) && 0 != (tem = const_binop (MINUS_EXPR, TREE_OPERAND (arg0, 0), arg1, 0)) && !TREE_OVERFLOW (tem)) - return fold_build2 (swap_tree_comparison (code), type, + return fold_build2_loc (loc, swap_tree_comparison (code), type, TREE_OPERAND (arg0, 1), tem); /* Fold comparisons against built-in math functions. */ @@ -9351,7 +9569,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) if (fcode != END_BUILTINS) { - tem = fold_mathfn_compare (fcode, code, type, arg0, arg1); + tem = fold_mathfn_compare (loc, fcode, code, type, arg0, arg1); if (tem != NULL_TREE) return tem; } @@ -9364,12 +9582,12 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) /* If we are widening one operand of an integer comparison, see if the other operand is similarly being widened. Perhaps we can do the comparison in the narrower type. */ - tem = fold_widened_comparison (code, type, arg0, arg1); + tem = fold_widened_comparison (loc, code, type, arg0, arg1); if (tem) return tem; /* Or if we are changing signedness. */ - tem = fold_sign_changed_comparison (code, type, arg0, arg1); + tem = fold_sign_changed_comparison (loc, code, type, arg0, arg1); if (tem) return tem; } @@ -9381,7 +9599,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) || TREE_CODE (arg0) == MAX_EXPR) && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) { - tem = optimize_minmax_comparison (code, type, op0, op1); + tem = optimize_minmax_comparison (loc, code, type, op0, op1); if (tem) return tem; } @@ -9403,7 +9621,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) if (! FLOAT_TYPE_P (TREE_TYPE (arg0)) || ! HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))) return constant_boolean_node (1, type); - return fold_build2 (EQ_EXPR, type, arg0, arg1); + return fold_build2_loc (loc, EQ_EXPR, type, arg0, arg1); case NE_EXPR: /* For NE, we can only do this simplification if integer @@ -9457,18 +9675,18 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) was the same as ARG1. */ tree high_result - = fold_build2 (code, type, - eval_subst (arg0, cval1, maxval, + = fold_build2_loc (loc, code, type, + eval_subst (loc, arg0, cval1, maxval, cval2, minval), arg1); tree equal_result - = fold_build2 (code, type, - eval_subst (arg0, cval1, maxval, + = fold_build2_loc (loc, code, type, + eval_subst (loc, arg0, cval1, maxval, cval2, maxval), arg1); tree low_result - = fold_build2 (code, type, - eval_subst (arg0, cval1, minval, + = fold_build2_loc (loc, code, type, + eval_subst (loc, arg0, cval1, minval, cval2, maxval), arg1); @@ -9487,7 +9705,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) { case 0: /* Always false. */ - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); case 1: code = LT_EXPR; break; @@ -9508,12 +9726,16 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) break; case 7: /* Always true. */ - return omit_one_operand (type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, integer_one_node, arg0); } if (save_p) - return save_expr (build2 (code, type, cval1, cval2)); - return fold_build2 (code, type, cval1, cval2); + { + tem = save_expr (build2 (code, type, cval1, cval2)); + SET_EXPR_LOCATION (tem, loc); + return tem; + } + return fold_build2_loc (loc, code, type, cval1, cval2); } } } @@ -9528,7 +9750,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) && !TREE_OVERFLOW (TREE_OPERAND (arg0, 1)) && !TREE_OVERFLOW (arg1)) { - tem = fold_div_compare (code, type, arg0, arg1); + tem = fold_div_compare (loc, code, type, arg0, arg1); if (tem != NULL_TREE) return tem; } @@ -9538,8 +9760,9 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (arg1) == BIT_NOT_EXPR) { tree cmp_type = TREE_TYPE (TREE_OPERAND (arg0, 0)); - return fold_build2 (code, type, - fold_convert (cmp_type, TREE_OPERAND (arg1, 0)), + return fold_build2_loc (loc, code, type, + fold_convert_loc (loc, cmp_type, + TREE_OPERAND (arg1, 0)), TREE_OPERAND (arg0, 0)); } @@ -9548,10 +9771,10 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (arg1) == INTEGER_CST) { tree cmp_type = TREE_TYPE (TREE_OPERAND (arg0, 0)); - return fold_build2 (swap_tree_comparison (code), type, + return fold_build2_loc (loc, swap_tree_comparison (code), type, TREE_OPERAND (arg0, 0), - fold_build1 (BIT_NOT_EXPR, cmp_type, - fold_convert (cmp_type, arg1))); + fold_build1_loc (loc, BIT_NOT_EXPR, cmp_type, + fold_convert_loc (loc, cmp_type, arg1))); } return NULL_TREE; @@ -9563,7 +9786,7 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1) argument EXPR represents the expression "z" of type TYPE. */ static tree -fold_mult_zconjz (tree type, tree expr) +fold_mult_zconjz (location_t loc, tree type, tree expr) { tree itype = TREE_TYPE (type); tree rpart, ipart, tem; @@ -9581,17 +9804,17 @@ fold_mult_zconjz (tree type, tree expr) else { expr = save_expr (expr); - rpart = fold_build1 (REALPART_EXPR, itype, expr); - ipart = fold_build1 (IMAGPART_EXPR, itype, expr); + rpart = fold_build1_loc (loc, REALPART_EXPR, itype, expr); + ipart = fold_build1_loc (loc, IMAGPART_EXPR, itype, expr); } rpart = save_expr (rpart); ipart = save_expr (ipart); - tem = fold_build2 (PLUS_EXPR, itype, - fold_build2 (MULT_EXPR, itype, rpart, rpart), - fold_build2 (MULT_EXPR, itype, ipart, ipart)); - return fold_build2 (COMPLEX_EXPR, type, tem, - fold_convert (itype, integer_zero_node)); + tem = fold_build2_loc (loc, PLUS_EXPR, itype, + fold_build2_loc (loc, MULT_EXPR, itype, rpart, rpart), + fold_build2_loc (loc, MULT_EXPR, itype, ipart, ipart)); + return fold_build2_loc (loc, COMPLEX_EXPR, type, tem, + fold_convert_loc (loc, itype, integer_zero_node)); } @@ -9694,11 +9917,13 @@ get_pointer_modulus_and_residue (tree expr, unsigned HOST_WIDE_INT *residue, /* Fold a binary expression of code CODE and type TYPE with operands - OP0 and OP1. Return the folded expression if folding is - successful. Otherwise, return NULL_TREE. */ + OP0 and OP1. LOC is the location of the resulting expression. + Return the folded expression if folding is successful. Otherwise, + return NULL_TREE. */ tree -fold_binary (enum tree_code code, tree type, tree op0, tree op1) +fold_binary_loc (location_t loc, + enum tree_code code, tree type, tree op0, tree op1) { enum tree_code_class kind = TREE_CODE_CLASS (code); tree arg0, arg1, tem; @@ -9761,7 +9986,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (tem != NULL_TREE) { if (TREE_TYPE (tem) != type) - tem = fold_convert (type, tem); + tem = fold_convert_loc (loc, type, tem); return tem; } } @@ -9770,7 +9995,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) to ARG1 to reduce the number of tests below. */ if (commutative_tree_code (code) && tree_swap_operands_p (arg0, arg1, true)) - return fold_build2 (code, type, op1, op0); + return fold_build2_loc (loc, code, type, op1, op0); /* ARG0 is the first operand of EXPR, and ARG1 is the second operand. @@ -9799,38 +10024,45 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) || (TREE_CODE (arg0) == BIT_AND_EXPR && integer_onep (TREE_OPERAND (arg0, 1))))))) { - tem = fold_build2 (code == BIT_AND_EXPR ? TRUTH_AND_EXPR + tem = fold_build2_loc (loc, code == BIT_AND_EXPR ? TRUTH_AND_EXPR : code == BIT_IOR_EXPR ? TRUTH_OR_EXPR : TRUTH_XOR_EXPR, boolean_type_node, - fold_convert (boolean_type_node, arg0), - fold_convert (boolean_type_node, arg1)); + fold_convert_loc (loc, boolean_type_node, arg0), + fold_convert_loc (loc, boolean_type_node, arg1)); if (code == EQ_EXPR) - tem = invert_truthvalue (tem); + tem = invert_truthvalue_loc (loc, tem); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } if (TREE_CODE_CLASS (code) == tcc_binary || TREE_CODE_CLASS (code) == tcc_comparison) { if (TREE_CODE (arg0) == COMPOUND_EXPR) - return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg0, 0), - fold_build2 (code, type, - fold_convert (TREE_TYPE (op0), - TREE_OPERAND (arg0, 1)), - op1)); + { + tem = fold_build2_loc (loc, code, type, + fold_convert_loc (loc, TREE_TYPE (op0), + TREE_OPERAND (arg0, 1)), op1); + protected_set_expr_location (tem, loc); + tem = build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg0, 0), tem); + goto fold_binary_exit; + } if (TREE_CODE (arg1) == COMPOUND_EXPR && reorder_operands_p (arg0, TREE_OPERAND (arg1, 0))) - return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg1, 0), - fold_build2 (code, type, op0, - fold_convert (TREE_TYPE (op1), - TREE_OPERAND (arg1, 1)))); + { + tem = fold_build2_loc (loc, code, type, op0, + fold_convert_loc (loc, TREE_TYPE (op1), + TREE_OPERAND (arg1, 1))); + protected_set_expr_location (tem, loc); + tem = build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg1, 0), tem); + goto fold_binary_exit; + } if (TREE_CODE (arg0) == COND_EXPR || COMPARISON_CLASS_P (arg0)) { - tem = fold_binary_op_with_conditional_arg (code, type, op0, op1, + tem = fold_binary_op_with_conditional_arg (loc, code, type, op0, op1, arg0, arg1, /*cond_first_p=*/1); if (tem != NULL_TREE) @@ -9839,7 +10071,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (TREE_CODE (arg1) == COND_EXPR || COMPARISON_CLASS_P (arg1)) { - tem = fold_binary_op_with_conditional_arg (code, type, op0, op1, + tem = fold_binary_op_with_conditional_arg (loc, code, type, op0, op1, arg1, arg0, /*cond_first_p=*/0); if (tem != NULL_TREE) @@ -9852,51 +10084,57 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case POINTER_PLUS_EXPR: /* 0 +p index -> (type)index */ if (integer_zerop (arg0)) - return non_lvalue (fold_convert (type, arg1)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg1)); /* PTR +p 0 -> PTR */ if (integer_zerop (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* INT +p INT -> (PTR)(INT + INT). Stripping types allows for this. */ if (INTEGRAL_TYPE_P (TREE_TYPE (arg1)) && INTEGRAL_TYPE_P (TREE_TYPE (arg0))) - return fold_convert (type, fold_build2 (PLUS_EXPR, sizetype, - fold_convert (sizetype, arg1), - fold_convert (sizetype, arg0))); + return fold_convert_loc (loc, type, + fold_build2_loc (loc, PLUS_EXPR, sizetype, + fold_convert_loc (loc, sizetype, + arg1), + fold_convert_loc (loc, sizetype, + arg0))); /* index +p PTR -> PTR +p index */ if (POINTER_TYPE_P (TREE_TYPE (arg1)) && INTEGRAL_TYPE_P (TREE_TYPE (arg0))) - return fold_build2 (POINTER_PLUS_EXPR, type, - fold_convert (type, arg1), - fold_convert (sizetype, arg0)); + return fold_build2_loc (loc, POINTER_PLUS_EXPR, type, + fold_convert_loc (loc, type, arg1), + fold_convert_loc (loc, sizetype, arg0)); /* (PTR +p B) +p A -> PTR +p (B + A) */ if (TREE_CODE (arg0) == POINTER_PLUS_EXPR) { tree inner; - tree arg01 = fold_convert (sizetype, TREE_OPERAND (arg0, 1)); + tree arg01 = fold_convert_loc (loc, sizetype, TREE_OPERAND (arg0, 1)); tree arg00 = TREE_OPERAND (arg0, 0); - inner = fold_build2 (PLUS_EXPR, sizetype, - arg01, fold_convert (sizetype, arg1)); - return fold_convert (type, - fold_build2 (POINTER_PLUS_EXPR, - TREE_TYPE (arg00), arg00, inner)); + inner = fold_build2_loc (loc, PLUS_EXPR, sizetype, + arg01, fold_convert_loc (loc, sizetype, arg1)); + return fold_convert_loc (loc, type, + fold_build2_loc (loc, POINTER_PLUS_EXPR, + TREE_TYPE (arg00), + arg00, inner)); } /* PTR_CST +p CST -> CST1 */ if (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST) - return fold_build2 (PLUS_EXPR, type, arg0, fold_convert (type, arg1)); + return fold_build2_loc (loc, PLUS_EXPR, type, arg0, + fold_convert_loc (loc, type, arg1)); /* Try replacing &a[i1] +p c * i2 with &a[i1 + i2], if c is step of the array. Loop optimizer sometimes produce this type of expressions. */ if (TREE_CODE (arg0) == ADDR_EXPR) { - tem = try_move_mult_to_index (arg0, fold_convert (sizetype, arg1)); + tem = try_move_mult_to_index (loc, arg0, + fold_convert_loc (loc, sizetype, arg1)); if (tem) - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } return NULL_TREE; @@ -9904,23 +10142,26 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case PLUS_EXPR: /* A + (-B) -> A - B */ if (TREE_CODE (arg1) == NEGATE_EXPR) - return fold_build2 (MINUS_EXPR, type, - fold_convert (type, arg0), - fold_convert (type, TREE_OPERAND (arg1, 0))); + return fold_build2_loc (loc, MINUS_EXPR, type, + fold_convert_loc (loc, type, arg0), + fold_convert_loc (loc, type, + TREE_OPERAND (arg1, 0))); /* (-A) + B -> B - A */ if (TREE_CODE (arg0) == NEGATE_EXPR && reorder_operands_p (TREE_OPERAND (arg0, 0), arg1)) - return fold_build2 (MINUS_EXPR, type, - fold_convert (type, arg1), - fold_convert (type, TREE_OPERAND (arg0, 0))); + return fold_build2_loc (loc, MINUS_EXPR, type, + fold_convert_loc (loc, type, arg1), + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0))); if (INTEGRAL_TYPE_P (type)) { /* Convert ~A + 1 to -A. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR && integer_onep (arg1)) - return fold_build1 (NEGATE_EXPR, type, - fold_convert (type, TREE_OPERAND (arg0, 0))); + return fold_build1_loc (loc, NEGATE_EXPR, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0))); /* ~X + X is -1. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR @@ -9932,7 +10173,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (operand_equal_p (tem, arg1, 0)) { t1 = build_int_cst_type (type, -1); - return omit_one_operand (type, t1, arg1); + return omit_one_operand_loc (loc, type, t1, arg1); } } @@ -9946,7 +10187,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (operand_equal_p (arg0, tem, 0)) { t1 = build_int_cst_type (type, -1); - return omit_one_operand (type, t1, arg0); + return omit_one_operand_loc (loc, type, t1, arg0); } } @@ -9958,11 +10199,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { tree cst0 = TREE_OPERAND (TREE_OPERAND (arg1, 0), 1); tree cst1 = TREE_OPERAND (arg1, 1); - tree sum = fold_binary (PLUS_EXPR, TREE_TYPE (cst1), cst1, cst0); + tree sum = fold_binary_loc (loc, PLUS_EXPR, TREE_TYPE (cst1), + cst1, cst0); if (sum && integer_zerop (sum)) - return fold_convert (type, - fold_build2 (TRUNC_MOD_EXPR, - TREE_TYPE (arg0), arg0, cst0)); + return fold_convert_loc (loc, type, + fold_build2_loc (loc, TRUNC_MOD_EXPR, + TREE_TYPE (arg0), arg0, + cst0)); } } @@ -9974,7 +10217,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && !TYPE_SATURATING (type) && (!FLOAT_TYPE_P (type) || flag_associative_math)) { - tree tem = fold_plusminus_mult_expr (code, type, arg0, arg1); + tree tem = fold_plusminus_mult_expr (loc, code, type, arg0, arg1); if (tem) return tem; } @@ -9982,7 +10225,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (! FLOAT_TYPE_P (type)) { if (integer_zerop (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* If we are adding two BIT_AND_EXPR's, both of which are and'ing with a constant, and the two constants have no bits in common, @@ -10025,30 +10268,33 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (TREE_CODE (parg0) == MULT_EXPR && TREE_CODE (parg1) != MULT_EXPR) - return fold_build2 (pcode, type, - fold_build2 (PLUS_EXPR, type, - fold_convert (type, parg0), - fold_convert (type, marg)), - fold_convert (type, parg1)); + return fold_build2_loc (loc, pcode, type, + fold_build2_loc (loc, PLUS_EXPR, type, + fold_convert_loc (loc, type, + parg0), + fold_convert_loc (loc, type, + marg)), + fold_convert_loc (loc, type, parg1)); if (TREE_CODE (parg0) != MULT_EXPR && TREE_CODE (parg1) == MULT_EXPR) - return fold_build2 (PLUS_EXPR, type, - fold_convert (type, parg0), - fold_build2 (pcode, type, - fold_convert (type, marg), - fold_convert (type, - parg1))); + return + fold_build2_loc (loc, PLUS_EXPR, type, + fold_convert_loc (loc, type, parg0), + fold_build2_loc (loc, pcode, type, + fold_convert_loc (loc, type, marg), + fold_convert_loc (loc, type, + parg1))); } } else { /* See if ARG1 is zero and X + ARG1 reduces to X. */ if (fold_real_zero_addition_p (TREE_TYPE (arg0), arg1, 0)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* Likewise if the operands are reversed. */ if (fold_real_zero_addition_p (TREE_TYPE (arg1), arg0, 0)) - return non_lvalue (fold_convert (type, arg1)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg1)); /* Convert X + -C into X - C. */ if (TREE_CODE (arg1) == REAL_CST @@ -10056,9 +10302,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { tem = fold_negate_const (arg1, type); if (!TREE_OVERFLOW (arg1) || !flag_trapping_math) - return fold_build2 (MINUS_EXPR, type, - fold_convert (type, arg0), - fold_convert (type, tem)); + return fold_build2_loc (loc, MINUS_EXPR, type, + fold_convert_loc (loc, type, arg0), + fold_convert_loc (loc, type, tem)); } /* Fold __complex__ ( x, 0 ) + __complex__ ( 0, y ) @@ -10069,21 +10315,21 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && COMPLEX_FLOAT_TYPE_P (TREE_TYPE (arg0))) { tree rtype = TREE_TYPE (TREE_TYPE (arg0)); - tree arg0r = fold_unary (REALPART_EXPR, rtype, arg0); - tree arg0i = fold_unary (IMAGPART_EXPR, rtype, arg0); + tree arg0r = fold_unary_loc (loc, REALPART_EXPR, rtype, arg0); + tree arg0i = fold_unary_loc (loc, IMAGPART_EXPR, rtype, arg0); bool arg0rz = false, arg0iz = false; if ((arg0r && (arg0rz = real_zerop (arg0r))) || (arg0i && (arg0iz = real_zerop (arg0i)))) { - tree arg1r = fold_unary (REALPART_EXPR, rtype, arg1); - tree arg1i = fold_unary (IMAGPART_EXPR, rtype, arg1); + tree arg1r = fold_unary_loc (loc, REALPART_EXPR, rtype, arg1); + tree arg1i = fold_unary_loc (loc, IMAGPART_EXPR, rtype, arg1); if (arg0rz && arg1i && real_zerop (arg1i)) { tree rp = arg1r ? arg1r : build1 (REALPART_EXPR, rtype, arg1); tree ip = arg0i ? arg0i : build1 (IMAGPART_EXPR, rtype, arg0); - return fold_build2 (COMPLEX_EXPR, type, rp, ip); + return fold_build2_loc (loc, COMPLEX_EXPR, type, rp, ip); } else if (arg0iz && arg1r && real_zerop (arg1r)) { @@ -10091,7 +10337,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) : build1 (REALPART_EXPR, rtype, arg0); tree ip = arg1i ? arg1i : build1 (IMAGPART_EXPR, rtype, arg1); - return fold_build2 (COMPLEX_EXPR, type, rp, ip); + return fold_build2_loc (loc, COMPLEX_EXPR, type, rp, ip); } } } @@ -10099,13 +10345,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (flag_unsafe_math_optimizations && (TREE_CODE (arg0) == RDIV_EXPR || TREE_CODE (arg0) == MULT_EXPR) && (TREE_CODE (arg1) == RDIV_EXPR || TREE_CODE (arg1) == MULT_EXPR) - && (tem = distribute_real_division (code, type, arg0, arg1))) + && (tem = distribute_real_division (loc, code, type, arg0, arg1))) return tem; /* Convert x+x into x*2.0. */ if (operand_equal_p (arg0, arg1, 0) && SCALAR_FLOAT_TYPE_P (type)) - return fold_build2 (MULT_EXPR, type, arg0, + return fold_build2_loc (loc, MULT_EXPR, type, arg0, build_real (type, dconst2)); /* Convert a + (b*c + d*e) into (a + b*c) + d*e. @@ -10121,8 +10367,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (tree10) == MULT_EXPR) { tree tree0; - tree0 = fold_build2 (PLUS_EXPR, type, arg0, tree10); - return fold_build2 (PLUS_EXPR, type, tree0, tree11); + tree0 = fold_build2_loc (loc, PLUS_EXPR, type, arg0, tree10); + return fold_build2_loc (loc, PLUS_EXPR, type, tree0, tree11); } } /* Convert (b*c + d*e) + a into b*c + (d*e +a). @@ -10138,8 +10384,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (tree00) == MULT_EXPR) { tree tree0; - tree0 = fold_build2 (PLUS_EXPR, type, tree01, arg1); - return fold_build2 (PLUS_EXPR, type, tree00, tree0); + tree0 = fold_build2_loc (loc, PLUS_EXPR, type, tree01, arg1); + return fold_build2_loc (loc, PLUS_EXPR, type, tree00, tree0); } } } @@ -10179,12 +10425,15 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_INT_CST_HIGH (tree11) == 0 && ((TREE_INT_CST_LOW (tree01) + TREE_INT_CST_LOW (tree11)) == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (arg0, 0))))) - return fold_convert (type, - build2 (LROTATE_EXPR, - TREE_TYPE (TREE_OPERAND (arg0, 0)), - TREE_OPERAND (arg0, 0), - code0 == LSHIFT_EXPR - ? tree01 : tree11)); + { + tem = build2 (LROTATE_EXPR, + TREE_TYPE (TREE_OPERAND (arg0, 0)), + TREE_OPERAND (arg0, 0), + code0 == LSHIFT_EXPR + ? tree01 : tree11); + SET_EXPR_LOCATION (tem, loc); + return fold_convert_loc (loc, type, tem); + } else if (code11 == MINUS_EXPR) { tree tree110, tree111; @@ -10198,12 +10447,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) (TREE_TYPE (TREE_OPERAND (arg0, 0)))) && operand_equal_p (tree01, tree111, 0)) - return fold_convert (type, - build2 ((code0 == LSHIFT_EXPR - ? LROTATE_EXPR - : RROTATE_EXPR), - TREE_TYPE (TREE_OPERAND (arg0, 0)), - TREE_OPERAND (arg0, 0), tree01)); + return + fold_convert_loc (loc, type, + build2 ((code0 == LSHIFT_EXPR + ? LROTATE_EXPR + : RROTATE_EXPR), + TREE_TYPE (TREE_OPERAND (arg0, 0)), + TREE_OPERAND (arg0, 0), tree01)); } else if (code01 == MINUS_EXPR) { @@ -10218,12 +10468,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) (TREE_TYPE (TREE_OPERAND (arg0, 0)))) && operand_equal_p (tree11, tree011, 0)) - return fold_convert (type, - build2 ((code0 != LSHIFT_EXPR - ? LROTATE_EXPR - : RROTATE_EXPR), - TREE_TYPE (TREE_OPERAND (arg0, 0)), - TREE_OPERAND (arg0, 0), tree11)); + return fold_convert_loc + (loc, type, + build2 ((code0 != LSHIFT_EXPR + ? LROTATE_EXPR + : RROTATE_EXPR), + TREE_TYPE (TREE_OPERAND (arg0, 0)), + TREE_OPERAND (arg0, 0), tree11)); } } } @@ -10282,10 +10533,10 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (code == MINUS_EXPR) code = PLUS_EXPR; - var0 = associate_trees (var0, var1, code, type); - con0 = associate_trees (con0, con1, code, type); - lit0 = associate_trees (lit0, lit1, code, type); - minus_lit0 = associate_trees (minus_lit0, minus_lit1, code, type); + var0 = associate_trees (loc, var0, var1, code, type); + con0 = associate_trees (loc, con0, con1, code, type); + lit0 = associate_trees (loc, lit0, lit1, code, type); + minus_lit0 = associate_trees (loc, minus_lit0, minus_lit1, code, type); /* Preserve the MINUS_EXPR if the negative part of the literal is greater than the positive part. Otherwise, the multiplicative @@ -10298,13 +10549,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (minus_lit0) == INTEGER_CST && tree_int_cst_lt (lit0, minus_lit0)) { - minus_lit0 = associate_trees (minus_lit0, lit0, + minus_lit0 = associate_trees (loc, minus_lit0, lit0, MINUS_EXPR, type); lit0 = 0; } else { - lit0 = associate_trees (lit0, minus_lit0, + lit0 = associate_trees (loc, lit0, minus_lit0, MINUS_EXPR, type); minus_lit0 = 0; } @@ -10312,22 +10563,25 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (minus_lit0) { if (con0 == 0) - return fold_convert (type, - associate_trees (var0, minus_lit0, - MINUS_EXPR, type)); + return + fold_convert_loc (loc, type, + associate_trees (loc, var0, minus_lit0, + MINUS_EXPR, type)); else { - con0 = associate_trees (con0, minus_lit0, + con0 = associate_trees (loc, con0, minus_lit0, MINUS_EXPR, type); - return fold_convert (type, - associate_trees (var0, con0, - PLUS_EXPR, type)); + return + fold_convert_loc (loc, type, + associate_trees (loc, var0, con0, + PLUS_EXPR, type)); } } - con0 = associate_trees (con0, lit0, code, type); - return fold_convert (type, associate_trees (var0, con0, - code, type)); + con0 = associate_trees (loc, con0, lit0, code, type); + return + fold_convert_loc (loc, type, associate_trees (loc, var0, con0, + code, type)); } } @@ -10341,49 +10595,56 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (TREE_CODE (arg0) == POINTER_PLUS_EXPR && TREE_CODE (arg1) == POINTER_PLUS_EXPR) { - tree arg00 = fold_convert (type, TREE_OPERAND (arg0, 0)); - tree arg01 = fold_convert (type, TREE_OPERAND (arg0, 1)); - tree arg10 = fold_convert (type, TREE_OPERAND (arg1, 0)); - tree arg11 = fold_convert (type, TREE_OPERAND (arg1, 1)); - return fold_build2 (PLUS_EXPR, type, - fold_build2 (MINUS_EXPR, type, arg00, arg10), - fold_build2 (MINUS_EXPR, type, arg01, arg11)); + tree arg00 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); + tree arg01 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 1)); + tree arg10 = fold_convert_loc (loc, type, TREE_OPERAND (arg1, 0)); + tree arg11 = fold_convert_loc (loc, type, TREE_OPERAND (arg1, 1)); + return fold_build2_loc (loc, PLUS_EXPR, type, + fold_build2_loc (loc, MINUS_EXPR, type, + arg00, arg10), + fold_build2_loc (loc, MINUS_EXPR, type, + arg01, arg11)); } /* (PTR0 p+ A) - PTR1 -> (PTR0 - PTR1) + A, assuming PTR0 - PTR1 simplifies. */ else if (TREE_CODE (arg0) == POINTER_PLUS_EXPR) { - tree arg00 = fold_convert (type, TREE_OPERAND (arg0, 0)); - tree arg01 = fold_convert (type, TREE_OPERAND (arg0, 1)); - tree tmp = fold_binary (MINUS_EXPR, type, arg00, fold_convert (type, arg1)); + tree arg00 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); + tree arg01 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 1)); + tree tmp = fold_binary_loc (loc, MINUS_EXPR, type, arg00, + fold_convert_loc (loc, type, arg1)); if (tmp) - return fold_build2 (PLUS_EXPR, type, tmp, arg01); + return fold_build2_loc (loc, PLUS_EXPR, type, tmp, arg01); } } /* A - (-B) -> A + B */ if (TREE_CODE (arg1) == NEGATE_EXPR) - return fold_build2 (PLUS_EXPR, type, op0, - fold_convert (type, TREE_OPERAND (arg1, 0))); + return fold_build2_loc (loc, PLUS_EXPR, type, op0, + fold_convert_loc (loc, type, + TREE_OPERAND (arg1, 0))); /* (-A) - B -> (-B) - A where B is easily negated and we can swap. */ if (TREE_CODE (arg0) == NEGATE_EXPR && (FLOAT_TYPE_P (type) || INTEGRAL_TYPE_P (type)) && negate_expr_p (arg1) && reorder_operands_p (arg0, arg1)) - return fold_build2 (MINUS_EXPR, type, - fold_convert (type, negate_expr (arg1)), - fold_convert (type, TREE_OPERAND (arg0, 0))); + return fold_build2_loc (loc, MINUS_EXPR, type, + fold_convert_loc (loc, type, + negate_expr (arg1)), + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0))); /* Convert -A - 1 to ~A. */ if (INTEGRAL_TYPE_P (type) && TREE_CODE (arg0) == NEGATE_EXPR && integer_onep (arg1) && !TYPE_OVERFLOW_TRAPS (type)) - return fold_build1 (BIT_NOT_EXPR, type, - fold_convert (type, TREE_OPERAND (arg0, 0))); + return fold_build1_loc (loc, BIT_NOT_EXPR, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0))); /* Convert -1 - A to ~A. */ if (INTEGRAL_TYPE_P (type) && integer_all_onesp (arg0)) - return fold_build1 (BIT_NOT_EXPR, type, op1); + return fold_build1_loc (loc, BIT_NOT_EXPR, type, op1); /* X - (X / CST) * CST is X % CST. */ @@ -10394,16 +10655,17 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) TREE_OPERAND (TREE_OPERAND (arg1, 0), 0), 0) && operand_equal_p (TREE_OPERAND (TREE_OPERAND (arg1, 0), 1), TREE_OPERAND (arg1, 1), 0)) - return fold_convert (type, - fold_build2 (TRUNC_MOD_EXPR, TREE_TYPE (arg0), - arg0, TREE_OPERAND (arg1, 1))); + return + fold_convert_loc (loc, type, + fold_build2_loc (loc, TRUNC_MOD_EXPR, TREE_TYPE (arg0), + arg0, TREE_OPERAND (arg1, 1))); if (! FLOAT_TYPE_P (type)) { if (integer_zerop (arg0)) - return negate_expr (fold_convert (type, arg1)); + return negate_expr (fold_convert_loc (loc, type, arg1)); if (integer_zerop (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* Fold A - (A & B) into ~B & A. */ if (!TREE_SIDE_EFFECTS (arg0) @@ -10411,17 +10673,21 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { if (operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0)) { - tree arg10 = fold_convert (type, TREE_OPERAND (arg1, 0)); - return fold_build2 (BIT_AND_EXPR, type, - fold_build1 (BIT_NOT_EXPR, type, arg10), - fold_convert (type, arg0)); + tree arg10 = fold_convert_loc (loc, type, + TREE_OPERAND (arg1, 0)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_build1_loc (loc, BIT_NOT_EXPR, + type, arg10), + fold_convert_loc (loc, type, arg0)); } if (operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) { - tree arg11 = fold_convert (type, TREE_OPERAND (arg1, 1)); - return fold_build2 (BIT_AND_EXPR, type, - fold_build1 (BIT_NOT_EXPR, type, arg11), - fold_convert (type, arg0)); + tree arg11 = fold_convert_loc (loc, + type, TREE_OPERAND (arg1, 1)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_build1_loc (loc, BIT_NOT_EXPR, + type, arg11), + fold_convert_loc (loc, type, arg0)); } } @@ -10434,26 +10700,26 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { tree mask0 = TREE_OPERAND (arg0, 1); tree mask1 = TREE_OPERAND (arg1, 1); - tree tem = fold_build1 (BIT_NOT_EXPR, type, mask0); + tree tem = fold_build1_loc (loc, BIT_NOT_EXPR, type, mask0); if (operand_equal_p (tem, mask1, 0)) { - tem = fold_build2 (BIT_XOR_EXPR, type, + tem = fold_build2_loc (loc, BIT_XOR_EXPR, type, TREE_OPERAND (arg0, 0), mask1); - return fold_build2 (MINUS_EXPR, type, tem, mask1); + return fold_build2_loc (loc, MINUS_EXPR, type, tem, mask1); } } } /* See if ARG1 is zero and X - ARG1 reduces to X. */ else if (fold_real_zero_addition_p (TREE_TYPE (arg0), arg1, 1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* (ARG0 - ARG1) is the same as (-ARG1 + ARG0). So check whether ARG0 is zero and X + ARG0 reduces to X, since that would mean (-ARG1 + ARG0) reduces to -ARG1. */ else if (fold_real_zero_addition_p (TREE_TYPE (arg1), arg0, 0)) - return negate_expr (fold_convert (type, arg1)); + return negate_expr (fold_convert_loc (loc, type, arg1)); /* Fold __complex__ ( x, 0 ) - __complex__ ( 0, y ) to __complex__ ( x, -y ). This is not the same for SNaNs or if @@ -10463,31 +10729,31 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && COMPLEX_FLOAT_TYPE_P (TREE_TYPE (arg0))) { tree rtype = TREE_TYPE (TREE_TYPE (arg0)); - tree arg0r = fold_unary (REALPART_EXPR, rtype, arg0); - tree arg0i = fold_unary (IMAGPART_EXPR, rtype, arg0); + tree arg0r = fold_unary_loc (loc, REALPART_EXPR, rtype, arg0); + tree arg0i = fold_unary_loc (loc, IMAGPART_EXPR, rtype, arg0); bool arg0rz = false, arg0iz = false; if ((arg0r && (arg0rz = real_zerop (arg0r))) || (arg0i && (arg0iz = real_zerop (arg0i)))) { - tree arg1r = fold_unary (REALPART_EXPR, rtype, arg1); - tree arg1i = fold_unary (IMAGPART_EXPR, rtype, arg1); + tree arg1r = fold_unary_loc (loc, REALPART_EXPR, rtype, arg1); + tree arg1i = fold_unary_loc (loc, IMAGPART_EXPR, rtype, arg1); if (arg0rz && arg1i && real_zerop (arg1i)) { - tree rp = fold_build1 (NEGATE_EXPR, rtype, + tree rp = fold_build1_loc (loc, NEGATE_EXPR, rtype, arg1r ? arg1r : build1 (REALPART_EXPR, rtype, arg1)); tree ip = arg0i ? arg0i : build1 (IMAGPART_EXPR, rtype, arg0); - return fold_build2 (COMPLEX_EXPR, type, rp, ip); + return fold_build2_loc (loc, COMPLEX_EXPR, type, rp, ip); } else if (arg0iz && arg1r && real_zerop (arg1r)) { tree rp = arg0r ? arg0r : build1 (REALPART_EXPR, rtype, arg0); - tree ip = fold_build1 (NEGATE_EXPR, rtype, + tree ip = fold_build1_loc (loc, NEGATE_EXPR, rtype, arg1i ? arg1i : build1 (IMAGPART_EXPR, rtype, arg1)); - return fold_build2 (COMPLEX_EXPR, type, rp, ip); + return fold_build2_loc (loc, COMPLEX_EXPR, type, rp, ip); } } } @@ -10500,7 +10766,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if ((!FLOAT_TYPE_P (type) || !HONOR_NANS (TYPE_MODE (type))) && operand_equal_p (arg0, arg1, 0)) - return fold_convert (type, integer_zero_node); + return fold_convert_loc (loc, type, integer_zero_node); /* A - B -> A + (-B) if B is easily negatable. */ if (negate_expr_p (arg1) @@ -10509,9 +10775,10 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && (TREE_CODE (arg1) != REAL_CST || REAL_VALUE_NEGATIVE (TREE_REAL_CST (arg1)))) || INTEGRAL_TYPE_P (type))) - return fold_build2 (PLUS_EXPR, type, - fold_convert (type, arg0), - fold_convert (type, negate_expr (arg1))); + return fold_build2_loc (loc, PLUS_EXPR, type, + fold_convert_loc (loc, type, arg0), + fold_convert_loc (loc, type, + negate_expr (arg1))); /* Try folding difference of addresses. */ { @@ -10534,12 +10801,12 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (operand_equal_p (TREE_OPERAND (aref0, 0), TREE_OPERAND (aref1, 0), 0)) { - tree op0 = fold_convert (type, TREE_OPERAND (aref0, 1)); - tree op1 = fold_convert (type, TREE_OPERAND (aref1, 1)); + tree op0 = fold_convert_loc (loc, type, TREE_OPERAND (aref0, 1)); + tree op1 = fold_convert_loc (loc, type, TREE_OPERAND (aref1, 1)); tree esz = array_ref_element_size (aref0); tree diff = build2 (MINUS_EXPR, type, op0, op1); - return fold_build2 (MULT_EXPR, type, diff, - fold_convert (type, esz)); + return fold_build2_loc (loc, MULT_EXPR, type, diff, + fold_convert_loc (loc, type, esz)); } } @@ -10548,7 +10815,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && flag_unsafe_math_optimizations && (TREE_CODE (arg0) == RDIV_EXPR || TREE_CODE (arg0) == MULT_EXPR) && (TREE_CODE (arg1) == RDIV_EXPR || TREE_CODE (arg1) == MULT_EXPR) - && (tem = distribute_real_division (code, type, arg0, arg1))) + && (tem = distribute_real_division (loc, code, type, arg0, arg1))) return tem; /* Handle (A1 * C1) - (A2 * C2) with A1, A2 or C1, C2 being the @@ -10559,7 +10826,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && !TYPE_SATURATING (type) && (!FLOAT_TYPE_P (type) || flag_associative_math)) { - tree tem = fold_plusminus_mult_expr (code, type, arg0, arg1); + tree tem = fold_plusminus_mult_expr (loc, code, type, arg0, arg1); if (tem) return tem; } @@ -10569,42 +10836,48 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case MULT_EXPR: /* (-A) * (-B) -> A * B */ if (TREE_CODE (arg0) == NEGATE_EXPR && negate_expr_p (arg1)) - return fold_build2 (MULT_EXPR, type, - fold_convert (type, TREE_OPERAND (arg0, 0)), - fold_convert (type, negate_expr (arg1))); + return fold_build2_loc (loc, MULT_EXPR, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0)), + fold_convert_loc (loc, type, + negate_expr (arg1))); if (TREE_CODE (arg1) == NEGATE_EXPR && negate_expr_p (arg0)) - return fold_build2 (MULT_EXPR, type, - fold_convert (type, negate_expr (arg0)), - fold_convert (type, TREE_OPERAND (arg1, 0))); + return fold_build2_loc (loc, MULT_EXPR, type, + fold_convert_loc (loc, type, + negate_expr (arg0)), + fold_convert_loc (loc, type, + TREE_OPERAND (arg1, 0))); if (! FLOAT_TYPE_P (type)) { if (integer_zerop (arg1)) - return omit_one_operand (type, arg1, arg0); + return omit_one_operand_loc (loc, type, arg1, arg0); if (integer_onep (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* Transform x * -1 into -x. Make sure to do the negation on the original operand with conversions not stripped because we can only strip non-sign-changing conversions. */ if (integer_all_onesp (arg1)) - return fold_convert (type, negate_expr (op0)); + return fold_convert_loc (loc, type, negate_expr (op0)); /* Transform x * -C into -x * C if x is easily negatable. */ if (TREE_CODE (arg1) == INTEGER_CST && tree_int_cst_sgn (arg1) == -1 && negate_expr_p (arg0) && (tem = negate_expr (arg1)) != arg1 && !TREE_OVERFLOW (tem)) - return fold_build2 (MULT_EXPR, type, - fold_convert (type, negate_expr (arg0)), tem); + return fold_build2_loc (loc, MULT_EXPR, type, + fold_convert_loc (loc, type, + negate_expr (arg0)), + tem); /* (a * (1 << b)) is (a << b) */ if (TREE_CODE (arg1) == LSHIFT_EXPR && integer_onep (TREE_OPERAND (arg1, 0))) - return fold_build2 (LSHIFT_EXPR, type, op0, + return fold_build2_loc (loc, LSHIFT_EXPR, type, op0, TREE_OPERAND (arg1, 1)); if (TREE_CODE (arg0) == LSHIFT_EXPR && integer_onep (TREE_OPERAND (arg0, 0))) - return fold_build2 (LSHIFT_EXPR, type, op1, + return fold_build2_loc (loc, LSHIFT_EXPR, type, op1, TREE_OPERAND (arg0, 1)); /* (A + A) * C -> A * 2 * C */ @@ -10612,10 +10885,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (arg1) == INTEGER_CST && operand_equal_p (TREE_OPERAND (arg0, 0), TREE_OPERAND (arg0, 1), 0)) - return fold_build2 (MULT_EXPR, type, - omit_one_operand (type, TREE_OPERAND (arg0, 0), + return fold_build2_loc (loc, MULT_EXPR, type, + omit_one_operand_loc (loc, type, + TREE_OPERAND (arg0, 0), TREE_OPERAND (arg0, 1)), - fold_build2 (MULT_EXPR, type, + fold_build2_loc (loc, MULT_EXPR, type, build_int_cst (type, 2) , arg1)); strict_overflow_p = false; @@ -10628,16 +10902,16 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) "occur when simplifying " "multiplication"), WARN_STRICT_OVERFLOW_MISC); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } /* Optimize z * conj(z) for integer complex numbers. */ if (TREE_CODE (arg0) == CONJ_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) - return fold_mult_zconjz (type, arg1); + return fold_mult_zconjz (loc, type, arg1); if (TREE_CODE (arg1) == CONJ_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) - return fold_mult_zconjz (type, arg0); + return fold_mult_zconjz (loc, type, arg0); } else { @@ -10648,21 +10922,21 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) && !HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg0))) && real_zerop (arg1)) - return omit_one_operand (type, arg1, arg0); + return omit_one_operand_loc (loc, type, arg1, arg0); /* In IEEE floating point, x*1 is not equivalent to x for snans. Likewise for complex arithmetic with signed zeros. */ if (!HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0))) && (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg0))) || !COMPLEX_FLOAT_TYPE_P (TREE_TYPE (arg0))) && real_onep (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* Transform x * -1.0 into -x. */ if (!HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0))) && (!HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg0))) || !COMPLEX_FLOAT_TYPE_P (TREE_TYPE (arg0))) && real_minus_onep (arg1)) - return fold_convert (type, negate_expr (arg0)); + return fold_convert_loc (loc, type, negate_expr (arg0)); /* Convert (C1/X)*C2 into (C1*C2)/X. This transformation may change the result for floating point types due to rounding so it is applied @@ -10675,7 +10949,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree tem = const_binop (MULT_EXPR, TREE_OPERAND (arg0, 0), arg1, 0); if (tem) - return fold_build2 (RDIV_EXPR, type, tem, + return fold_build2_loc (loc, RDIV_EXPR, type, tem, TREE_OPERAND (arg0, 1)); } @@ -10685,8 +10959,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree tem = fold_strip_sign_ops (arg0); if (tem != NULL_TREE) { - tem = fold_convert (type, tem); - return fold_build2 (MULT_EXPR, type, tem, tem); + tem = fold_convert_loc (loc, type, tem); + return fold_build2_loc (loc, MULT_EXPR, type, tem, tem); } } @@ -10701,15 +10975,17 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { tree rtype = TREE_TYPE (TREE_TYPE (arg0)); if (real_onep (TREE_IMAGPART (arg1))) - return fold_build2 (COMPLEX_EXPR, type, - negate_expr (fold_build1 (IMAGPART_EXPR, - rtype, arg0)), - fold_build1 (REALPART_EXPR, rtype, arg0)); + return + fold_build2_loc (loc, COMPLEX_EXPR, type, + negate_expr (fold_build1_loc (loc, IMAGPART_EXPR, + rtype, arg0)), + fold_build1_loc (loc, REALPART_EXPR, rtype, arg0)); else if (real_minus_onep (TREE_IMAGPART (arg1))) - return fold_build2 (COMPLEX_EXPR, type, - fold_build1 (IMAGPART_EXPR, rtype, arg0), - negate_expr (fold_build1 (REALPART_EXPR, - rtype, arg0))); + return + fold_build2_loc (loc, COMPLEX_EXPR, type, + fold_build1_loc (loc, IMAGPART_EXPR, rtype, arg0), + negate_expr (fold_build1_loc (loc, REALPART_EXPR, + rtype, arg0))); } /* Optimize z * conj(z) for floating point complex numbers. @@ -10718,11 +10994,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (flag_unsafe_math_optimizations && TREE_CODE (arg0) == CONJ_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) - return fold_mult_zconjz (type, arg1); + return fold_mult_zconjz (loc, type, arg1); if (flag_unsafe_math_optimizations && TREE_CODE (arg1) == CONJ_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) - return fold_mult_zconjz (type, arg0); + return fold_mult_zconjz (loc, type, arg0); if (flag_unsafe_math_optimizations) { @@ -10744,18 +11020,18 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* Optimize root(x)*root(y) as root(x*y). */ rootfn = TREE_OPERAND (CALL_EXPR_FN (arg0), 0); - arg = fold_build2 (MULT_EXPR, type, arg00, arg10); - return build_call_expr (rootfn, 1, arg); + arg = fold_build2_loc (loc, MULT_EXPR, type, arg00, arg10); + return build_call_expr_loc (loc, rootfn, 1, arg); } /* Optimize expN(x)*expN(y) as expN(x+y). */ if (fcode0 == fcode1 && BUILTIN_EXPONENT_P (fcode0)) { tree expfn = TREE_OPERAND (CALL_EXPR_FN (arg0), 0); - tree arg = fold_build2 (PLUS_EXPR, type, + tree arg = fold_build2_loc (loc, PLUS_EXPR, type, CALL_EXPR_ARG (arg0, 0), CALL_EXPR_ARG (arg1, 0)); - return build_call_expr (expfn, 1, arg); + return build_call_expr_loc (loc, expfn, 1, arg); } /* Optimizations of pow(...)*pow(...). */ @@ -10772,16 +11048,18 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (operand_equal_p (arg01, arg11, 0)) { tree powfn = TREE_OPERAND (CALL_EXPR_FN (arg0), 0); - tree arg = fold_build2 (MULT_EXPR, type, arg00, arg10); - return build_call_expr (powfn, 2, arg, arg01); + tree arg = fold_build2_loc (loc, MULT_EXPR, type, + arg00, arg10); + return build_call_expr_loc (loc, powfn, 2, arg, arg01); } /* Optimize pow(x,y)*pow(x,z) as pow(x,y+z). */ if (operand_equal_p (arg00, arg10, 0)) { tree powfn = TREE_OPERAND (CALL_EXPR_FN (arg0), 0); - tree arg = fold_build2 (PLUS_EXPR, type, arg01, arg11); - return build_call_expr (powfn, 2, arg00, arg); + tree arg = fold_build2_loc (loc, PLUS_EXPR, type, + arg01, arg11); + return build_call_expr_loc (loc, powfn, 2, arg00, arg); } } @@ -10798,7 +11076,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree sinfn = mathfn_built_in (type, BUILT_IN_SIN); if (sinfn != NULL_TREE) - return build_call_expr (sinfn, 1, CALL_EXPR_ARG (arg0, 0)); + return build_call_expr_loc (loc, sinfn, 1, + CALL_EXPR_ARG (arg0, 0)); } /* Optimize x*pow(x,c) as pow(x,c+1). */ @@ -10819,7 +11098,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) c = TREE_REAL_CST (arg11); real_arithmetic (&c, PLUS_EXPR, &c, &dconst1); arg = build_real (type, c); - return build_call_expr (powfn, 2, arg0, arg); + return build_call_expr_loc (loc, powfn, 2, arg0, arg); } } @@ -10841,7 +11120,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) c = TREE_REAL_CST (arg01); real_arithmetic (&c, PLUS_EXPR, &c, &dconst1); arg = build_real (type, c); - return build_call_expr (powfn, 2, arg1, arg); + return build_call_expr_loc (loc, powfn, 2, arg1, arg); } } @@ -10854,7 +11133,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (powfn) { tree arg = build_real (type, dconst2); - return build_call_expr (powfn, 2, arg0, arg); + return build_call_expr_loc (loc, powfn, 2, arg0, arg); } } } @@ -10864,28 +11143,28 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case BIT_IOR_EXPR: bit_ior: if (integer_all_onesp (arg1)) - return omit_one_operand (type, arg1, arg0); + return omit_one_operand_loc (loc, type, arg1, arg0); if (integer_zerop (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); if (operand_equal_p (arg0, arg1, 0)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* ~X | X is -1. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) { - t1 = fold_convert (type, integer_zero_node); - t1 = fold_unary (BIT_NOT_EXPR, type, t1); - return omit_one_operand (type, t1, arg1); + t1 = fold_convert_loc (loc, type, integer_zero_node); + t1 = fold_unary_loc (loc, BIT_NOT_EXPR, type, t1); + return omit_one_operand_loc (loc, type, t1, arg1); } /* X | ~X is -1. */ if (TREE_CODE (arg1) == BIT_NOT_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) { - t1 = fold_convert (type, integer_zero_node); - t1 = fold_unary (BIT_NOT_EXPR, type, t1); - return omit_one_operand (type, t1, arg0); + t1 = fold_convert_loc (loc, type, integer_zero_node); + t1 = fold_unary_loc (loc, BIT_NOT_EXPR, type, t1); + return omit_one_operand_loc (loc, type, t1, arg0); } /* Canonicalize (X & C1) | C2. */ @@ -10902,7 +11181,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* If (C1&C2) == C1, then (X&C1)|C2 becomes (X,C2). */ if ((hi1 & hi2) == hi1 && (lo1 & lo2) == lo1) - return omit_one_operand (type, arg1, TREE_OPERAND (arg0, 0)); + return omit_one_operand_loc (loc, type, arg1, + TREE_OPERAND (arg0, 0)); if (width > HOST_BITS_PER_WIDE_INT) { @@ -10919,7 +11199,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* If (C1|C2) == ~0 then (X&C1)|C2 becomes X|C2. */ if ((~(hi1 | hi2) & mhi) == 0 && (~(lo1 | lo2) & mlo) == 0) - return fold_build2 (BIT_IOR_EXPR, type, + return fold_build2_loc (loc, BIT_IOR_EXPR, type, TREE_OPERAND (arg0, 0), arg1); /* Minimize the number of bits set in C1, i.e. C1 := C1 & ~C2, @@ -10946,8 +11226,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) } } if (hi3 != hi1 || lo3 != lo1) - return fold_build2 (BIT_IOR_EXPR, type, - fold_build2 (BIT_AND_EXPR, type, + return fold_build2_loc (loc, BIT_IOR_EXPR, type, + fold_build2_loc (loc, BIT_AND_EXPR, type, TREE_OPERAND (arg0, 0), build_int_cst_wide (type, lo3, hi3)), @@ -10957,24 +11237,24 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* (X & Y) | Y is (X, Y). */ if (TREE_CODE (arg0) == BIT_AND_EXPR && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) - return omit_one_operand (type, arg1, TREE_OPERAND (arg0, 0)); + return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 0)); /* (X & Y) | X is (Y, X). */ if (TREE_CODE (arg0) == BIT_AND_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) && reorder_operands_p (TREE_OPERAND (arg0, 1), arg1)) - return omit_one_operand (type, arg1, TREE_OPERAND (arg0, 1)); + return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 1)); /* X | (X & Y) is (Y, X). */ if (TREE_CODE (arg1) == BIT_AND_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0) && reorder_operands_p (arg0, TREE_OPERAND (arg1, 1))) - return omit_one_operand (type, arg0, TREE_OPERAND (arg1, 1)); + return omit_one_operand_loc (loc, type, arg0, TREE_OPERAND (arg1, 1)); /* X | (Y & X) is (Y, X). */ if (TREE_CODE (arg1) == BIT_AND_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0) && reorder_operands_p (arg0, TREE_OPERAND (arg1, 0))) - return omit_one_operand (type, arg0, TREE_OPERAND (arg1, 0)); + return omit_one_operand_loc (loc, type, arg0, TREE_OPERAND (arg1, 0)); - t1 = distribute_bit_expr (code, type, arg0, arg1); + t1 = distribute_bit_expr (loc, code, type, arg0, arg1); if (t1 != NULL_TREE) return t1; @@ -10987,12 +11267,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (TREE_CODE (arg0) == BIT_NOT_EXPR && TREE_CODE (arg1) == BIT_NOT_EXPR) { - return fold_build1 (BIT_NOT_EXPR, type, - build2 (BIT_AND_EXPR, type, - fold_convert (type, - TREE_OPERAND (arg0, 0)), - fold_convert (type, - TREE_OPERAND (arg1, 0)))); + return + fold_build1_loc (loc, BIT_NOT_EXPR, type, + build2 (BIT_AND_EXPR, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0)), + fold_convert_loc (loc, type, + TREE_OPERAND (arg1, 0)))); } /* See if this can be simplified into a rotate first. If that @@ -11001,28 +11282,28 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case BIT_XOR_EXPR: if (integer_zerop (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); if (integer_all_onesp (arg1)) - return fold_build1 (BIT_NOT_EXPR, type, op0); + return fold_build1_loc (loc, BIT_NOT_EXPR, type, op0); if (operand_equal_p (arg0, arg1, 0)) - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); /* ~X ^ X is -1. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) { - t1 = fold_convert (type, integer_zero_node); - t1 = fold_unary (BIT_NOT_EXPR, type, t1); - return omit_one_operand (type, t1, arg1); + t1 = fold_convert_loc (loc, type, integer_zero_node); + t1 = fold_unary_loc (loc, BIT_NOT_EXPR, type, t1); + return omit_one_operand_loc (loc, type, t1, arg1); } /* X ^ ~X is -1. */ if (TREE_CODE (arg1) == BIT_NOT_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) { - t1 = fold_convert (type, integer_zero_node); - t1 = fold_unary (BIT_NOT_EXPR, type, t1); - return omit_one_operand (type, t1, arg0); + t1 = fold_convert_loc (loc, type, integer_zero_node); + t1 = fold_unary_loc (loc, BIT_NOT_EXPR, type, t1); + return omit_one_operand_loc (loc, type, t1, arg0); } /* If we are XORing two BIT_AND_EXPR's, both of which are and'ing @@ -11046,10 +11327,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) { tree t2 = TREE_OPERAND (arg0, 1); - t1 = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (arg1), + t1 = fold_build1_loc (loc, BIT_NOT_EXPR, TREE_TYPE (arg1), arg1); - t1 = fold_build2 (BIT_AND_EXPR, type, fold_convert (type, t2), - fold_convert (type, t1)); + t1 = fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_convert_loc (loc, type, t2), + fold_convert_loc (loc, type, t1)); return t1; } @@ -11058,10 +11340,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) { tree t2 = TREE_OPERAND (arg0, 0); - t1 = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (arg1), + t1 = fold_build1_loc (loc, BIT_NOT_EXPR, TREE_TYPE (arg1), arg1); - t1 = fold_build2 (BIT_AND_EXPR, type, fold_convert (type, t2), - fold_convert (type, t1)); + t1 = fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_convert_loc (loc, type, t2), + fold_convert_loc (loc, type, t1)); return t1; } @@ -11070,10 +11353,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && operand_equal_p (TREE_OPERAND (arg1, 0), arg0, 0)) { tree t2 = TREE_OPERAND (arg1, 1); - t1 = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (arg0), + t1 = fold_build1_loc (loc, BIT_NOT_EXPR, TREE_TYPE (arg0), arg0); - t1 = fold_build2 (BIT_AND_EXPR, type, fold_convert (type, t2), - fold_convert (type, t1)); + t1 = fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_convert_loc (loc, type, t2), + fold_convert_loc (loc, type, t1)); return t1; } @@ -11082,71 +11366,75 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && operand_equal_p (TREE_OPERAND (arg1, 1), arg0, 0)) { tree t2 = TREE_OPERAND (arg1, 0); - t1 = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (arg0), + t1 = fold_build1_loc (loc, BIT_NOT_EXPR, TREE_TYPE (arg0), arg0); - t1 = fold_build2 (BIT_AND_EXPR, type, fold_convert (type, t2), - fold_convert (type, t1)); + t1 = fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_convert_loc (loc, type, t2), + fold_convert_loc (loc, type, t1)); return t1; } /* Convert ~X ^ ~Y to X ^ Y. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR && TREE_CODE (arg1) == BIT_NOT_EXPR) - return fold_build2 (code, type, - fold_convert (type, TREE_OPERAND (arg0, 0)), - fold_convert (type, TREE_OPERAND (arg1, 0))); + return fold_build2_loc (loc, code, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0)), + fold_convert_loc (loc, type, + TREE_OPERAND (arg1, 0))); /* Convert ~X ^ C to X ^ ~C. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR && TREE_CODE (arg1) == INTEGER_CST) - return fold_build2 (code, type, - fold_convert (type, TREE_OPERAND (arg0, 0)), - fold_build1 (BIT_NOT_EXPR, type, arg1)); + return fold_build2_loc (loc, code, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0)), + fold_build1_loc (loc, BIT_NOT_EXPR, type, arg1)); /* Fold (X & 1) ^ 1 as (X & 1) == 0. */ if (TREE_CODE (arg0) == BIT_AND_EXPR && integer_onep (TREE_OPERAND (arg0, 1)) && integer_onep (arg1)) - return fold_build2 (EQ_EXPR, type, arg0, + return fold_build2_loc (loc, EQ_EXPR, type, arg0, build_int_cst (TREE_TYPE (arg0), 0)); /* Fold (X & Y) ^ Y as ~X & Y. */ if (TREE_CODE (arg0) == BIT_AND_EXPR && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) { - tem = fold_convert (type, TREE_OPERAND (arg0, 0)); - return fold_build2 (BIT_AND_EXPR, type, - fold_build1 (BIT_NOT_EXPR, type, tem), - fold_convert (type, arg1)); + tem = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_build1_loc (loc, BIT_NOT_EXPR, type, tem), + fold_convert_loc (loc, type, arg1)); } /* Fold (X & Y) ^ X as ~Y & X. */ if (TREE_CODE (arg0) == BIT_AND_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) && reorder_operands_p (TREE_OPERAND (arg0, 1), arg1)) { - tem = fold_convert (type, TREE_OPERAND (arg0, 1)); - return fold_build2 (BIT_AND_EXPR, type, - fold_build1 (BIT_NOT_EXPR, type, tem), - fold_convert (type, arg1)); + tem = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 1)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_build1_loc (loc, BIT_NOT_EXPR, type, tem), + fold_convert_loc (loc, type, arg1)); } /* Fold X ^ (X & Y) as X & ~Y. */ if (TREE_CODE (arg1) == BIT_AND_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) { - tem = fold_convert (type, TREE_OPERAND (arg1, 1)); - return fold_build2 (BIT_AND_EXPR, type, - fold_convert (type, arg0), - fold_build1 (BIT_NOT_EXPR, type, tem)); + tem = fold_convert_loc (loc, type, TREE_OPERAND (arg1, 1)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_convert_loc (loc, type, arg0), + fold_build1_loc (loc, BIT_NOT_EXPR, type, tem)); } /* Fold X ^ (Y & X) as ~Y & X. */ if (TREE_CODE (arg1) == BIT_AND_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0) && reorder_operands_p (arg0, TREE_OPERAND (arg1, 0))) { - tem = fold_convert (type, TREE_OPERAND (arg1, 0)); - return fold_build2 (BIT_AND_EXPR, type, - fold_build1 (BIT_NOT_EXPR, type, tem), - fold_convert (type, arg0)); + tem = fold_convert_loc (loc, type, TREE_OPERAND (arg1, 0)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_build1_loc (loc, BIT_NOT_EXPR, type, tem), + fold_convert_loc (loc, type, arg0)); } /* See if this can be simplified into a rotate first. If that @@ -11155,55 +11443,57 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case BIT_AND_EXPR: if (integer_all_onesp (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); if (integer_zerop (arg1)) - return omit_one_operand (type, arg1, arg0); + return omit_one_operand_loc (loc, type, arg1, arg0); if (operand_equal_p (arg0, arg1, 0)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* ~X & X is always zero. */ if (TREE_CODE (arg0) == BIT_NOT_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) - return omit_one_operand (type, integer_zero_node, arg1); + return omit_one_operand_loc (loc, type, integer_zero_node, arg1); /* X & ~X is always zero. */ if (TREE_CODE (arg1) == BIT_NOT_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); /* Canonicalize (X | C1) & C2 as (X & C2) | (C1 & C2). */ if (TREE_CODE (arg0) == BIT_IOR_EXPR && TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) { - tree tmp1 = fold_convert (type, arg1); - tree tmp2 = fold_convert (type, TREE_OPERAND (arg0, 0)); - tree tmp3 = fold_convert (type, TREE_OPERAND (arg0, 1)); - tmp2 = fold_build2 (BIT_AND_EXPR, type, tmp2, tmp1); - tmp3 = fold_build2 (BIT_AND_EXPR, type, tmp3, tmp1); - return fold_convert (type, - fold_build2 (BIT_IOR_EXPR, type, tmp2, tmp3)); + tree tmp1 = fold_convert_loc (loc, type, arg1); + tree tmp2 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); + tree tmp3 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 1)); + tmp2 = fold_build2_loc (loc, BIT_AND_EXPR, type, tmp2, tmp1); + tmp3 = fold_build2_loc (loc, BIT_AND_EXPR, type, tmp3, tmp1); + return + fold_convert_loc (loc, type, + fold_build2_loc (loc, BIT_IOR_EXPR, + type, tmp2, tmp3)); } /* (X | Y) & Y is (X, Y). */ if (TREE_CODE (arg0) == BIT_IOR_EXPR && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) - return omit_one_operand (type, arg1, TREE_OPERAND (arg0, 0)); + return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 0)); /* (X | Y) & X is (Y, X). */ if (TREE_CODE (arg0) == BIT_IOR_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) && reorder_operands_p (TREE_OPERAND (arg0, 1), arg1)) - return omit_one_operand (type, arg1, TREE_OPERAND (arg0, 1)); + return omit_one_operand_loc (loc, type, arg1, TREE_OPERAND (arg0, 1)); /* X & (X | Y) is (Y, X). */ if (TREE_CODE (arg1) == BIT_IOR_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0) && reorder_operands_p (arg0, TREE_OPERAND (arg1, 1))) - return omit_one_operand (type, arg0, TREE_OPERAND (arg1, 1)); + return omit_one_operand_loc (loc, type, arg0, TREE_OPERAND (arg1, 1)); /* X & (Y | X) is (Y, X). */ if (TREE_CODE (arg1) == BIT_IOR_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0) && reorder_operands_p (arg0, TREE_OPERAND (arg1, 0))) - return omit_one_operand (type, arg0, TREE_OPERAND (arg1, 0)); + return omit_one_operand_loc (loc, type, arg0, TREE_OPERAND (arg1, 0)); /* Fold (X ^ 1) & 1 as (X & 1) == 0. */ if (TREE_CODE (arg0) == BIT_XOR_EXPR @@ -11211,8 +11501,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && integer_onep (arg1)) { tem = TREE_OPERAND (arg0, 0); - return fold_build2 (EQ_EXPR, type, - fold_build2 (BIT_AND_EXPR, TREE_TYPE (tem), tem, + return fold_build2_loc (loc, EQ_EXPR, type, + fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (tem), tem, build_int_cst (TREE_TYPE (tem), 1)), build_int_cst (TREE_TYPE (tem), 0)); } @@ -11221,8 +11511,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && integer_onep (arg1)) { tem = TREE_OPERAND (arg0, 0); - return fold_build2 (EQ_EXPR, type, - fold_build2 (BIT_AND_EXPR, TREE_TYPE (tem), tem, + return fold_build2_loc (loc, EQ_EXPR, type, + fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (tem), tem, build_int_cst (TREE_TYPE (tem), 1)), build_int_cst (TREE_TYPE (tem), 0)); } @@ -11231,42 +11521,42 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (TREE_CODE (arg0) == BIT_XOR_EXPR && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) { - tem = fold_convert (type, TREE_OPERAND (arg0, 0)); - return fold_build2 (BIT_AND_EXPR, type, - fold_build1 (BIT_NOT_EXPR, type, tem), - fold_convert (type, arg1)); + tem = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_build1_loc (loc, BIT_NOT_EXPR, type, tem), + fold_convert_loc (loc, type, arg1)); } /* Fold (X ^ Y) & X as ~Y & X. */ if (TREE_CODE (arg0) == BIT_XOR_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) && reorder_operands_p (TREE_OPERAND (arg0, 1), arg1)) { - tem = fold_convert (type, TREE_OPERAND (arg0, 1)); - return fold_build2 (BIT_AND_EXPR, type, - fold_build1 (BIT_NOT_EXPR, type, tem), - fold_convert (type, arg1)); + tem = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 1)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_build1_loc (loc, BIT_NOT_EXPR, type, tem), + fold_convert_loc (loc, type, arg1)); } /* Fold X & (X ^ Y) as X & ~Y. */ if (TREE_CODE (arg1) == BIT_XOR_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) { - tem = fold_convert (type, TREE_OPERAND (arg1, 1)); - return fold_build2 (BIT_AND_EXPR, type, - fold_convert (type, arg0), - fold_build1 (BIT_NOT_EXPR, type, tem)); + tem = fold_convert_loc (loc, type, TREE_OPERAND (arg1, 1)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_convert_loc (loc, type, arg0), + fold_build1_loc (loc, BIT_NOT_EXPR, type, tem)); } /* Fold X & (Y ^ X) as ~Y & X. */ if (TREE_CODE (arg1) == BIT_XOR_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0) && reorder_operands_p (arg0, TREE_OPERAND (arg1, 0))) { - tem = fold_convert (type, TREE_OPERAND (arg1, 0)); - return fold_build2 (BIT_AND_EXPR, type, - fold_build1 (BIT_NOT_EXPR, type, tem), - fold_convert (type, arg0)); + tem = fold_convert_loc (loc, type, TREE_OPERAND (arg1, 0)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_build1_loc (loc, BIT_NOT_EXPR, type, tem), + fold_convert_loc (loc, type, arg0)); } - t1 = distribute_bit_expr (code, type, arg0, arg1); + t1 = distribute_bit_expr (loc, code, type, arg0, arg1); if (t1 != NULL_TREE) return t1; /* Simplify ((int)c & 0377) into (int)c, if c is unsigned char. */ @@ -11279,7 +11569,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (prec < BITS_PER_WORD && prec < HOST_BITS_PER_WIDE_INT && (~TREE_INT_CST_LOW (arg1) & (((HOST_WIDE_INT) 1 << prec) - 1)) == 0) - return fold_convert (type, TREE_OPERAND (arg0, 0)); + return + fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); } /* Convert (and (not arg0) (not arg1)) to (not (or (arg0) (arg1))). @@ -11291,12 +11582,12 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (TREE_CODE (arg0) == BIT_NOT_EXPR && TREE_CODE (arg1) == BIT_NOT_EXPR) { - return fold_build1 (BIT_NOT_EXPR, type, + return fold_build1_loc (loc, BIT_NOT_EXPR, type, build2 (BIT_IOR_EXPR, type, - fold_convert (type, - TREE_OPERAND (arg0, 0)), - fold_convert (type, - TREE_OPERAND (arg1, 0)))); + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0)), + fold_convert_loc (loc, type, + TREE_OPERAND (arg1, 0)))); } /* If arg0 is derived from the address of an object or function, we may @@ -11378,7 +11669,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* ((X << 16) & 0xff00) is (X, 0). */ if ((mask & zerobits) == mask) - return omit_one_operand (type, build_int_cst (type, 0), arg0); + return omit_one_operand_loc (loc, type, + build_int_cst (type, 0), arg0); newmask = mask | zerobits; if (newmask != mask && (newmask & (newmask + 1)) == 0) @@ -11398,17 +11690,17 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (shift_type != TREE_TYPE (arg0)) { - tem = fold_build2 (TREE_CODE (arg0), shift_type, - fold_convert (shift_type, - TREE_OPERAND (arg0, 0)), + tem = fold_build2_loc (loc, TREE_CODE (arg0), shift_type, + fold_convert_loc (loc, shift_type, + TREE_OPERAND (arg0, 0)), TREE_OPERAND (arg0, 1)); - tem = fold_convert (type, tem); + tem = fold_convert_loc (loc, type, tem); } else tem = op0; newmaskt = build_int_cst_type (TREE_TYPE (op1), newmask); if (!tree_int_cst_equal (newmaskt, arg1)) - return fold_build2 (BIT_AND_EXPR, type, tem, newmaskt); + return fold_build2_loc (loc, BIT_AND_EXPR, type, tem, newmaskt); } } } @@ -11433,7 +11725,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { tree r = build_real (TREE_TYPE (arg0), dconst1); - return omit_two_operands (type, r, arg0, arg1); + return omit_two_operands_loc (loc, type, r, arg0, arg1); } /* The complex version of the above A / A optimization. */ @@ -11446,29 +11738,30 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { tree r = build_real (elem_type, dconst1); /* omit_two_operands will call fold_convert for us. */ - return omit_two_operands (type, r, arg0, arg1); + return omit_two_operands_loc (loc, type, r, arg0, arg1); } } /* (-A) / (-B) -> A / B */ if (TREE_CODE (arg0) == NEGATE_EXPR && negate_expr_p (arg1)) - return fold_build2 (RDIV_EXPR, type, + return fold_build2_loc (loc, RDIV_EXPR, type, TREE_OPERAND (arg0, 0), negate_expr (arg1)); if (TREE_CODE (arg1) == NEGATE_EXPR && negate_expr_p (arg0)) - return fold_build2 (RDIV_EXPR, type, + return fold_build2_loc (loc, RDIV_EXPR, type, negate_expr (arg0), TREE_OPERAND (arg1, 0)); /* In IEEE floating point, x/1 is not equivalent to x for snans. */ if (!HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0))) && real_onep (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* In IEEE floating point, x/-1 is not equivalent to -x for snans. */ if (!HONOR_SNANS (TYPE_MODE (TREE_TYPE (arg0))) && real_minus_onep (arg1)) - return non_lvalue (fold_convert (type, negate_expr (arg0))); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, + negate_expr (arg0))); /* If ARG1 is a constant, we can convert this to a multiply by the reciprocal. This does not have the same rounding properties, @@ -11480,7 +11773,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (flag_reciprocal_math && 0 != (tem = const_binop (code, build_real (type, dconst1), arg1, 0))) - return fold_build2 (MULT_EXPR, type, arg0, tem); + return fold_build2_loc (loc, MULT_EXPR, type, arg0, tem); /* Find the reciprocal if optimizing and the result is exact. */ if (optimize) { @@ -11489,23 +11782,23 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (exact_real_inverse (TYPE_MODE(TREE_TYPE(arg0)), &r)) { tem = build_real (type, r); - return fold_build2 (MULT_EXPR, type, - fold_convert (type, arg0), tem); + return fold_build2_loc (loc, MULT_EXPR, type, + fold_convert_loc (loc, type, arg0), tem); } } } /* Convert A/B/C to A/(B*C). */ if (flag_reciprocal_math && TREE_CODE (arg0) == RDIV_EXPR) - return fold_build2 (RDIV_EXPR, type, TREE_OPERAND (arg0, 0), - fold_build2 (MULT_EXPR, type, + return fold_build2_loc (loc, RDIV_EXPR, type, TREE_OPERAND (arg0, 0), + fold_build2_loc (loc, MULT_EXPR, type, TREE_OPERAND (arg0, 1), arg1)); /* Convert A/(B/C) to (A/B)*C. */ if (flag_reciprocal_math && TREE_CODE (arg1) == RDIV_EXPR) - return fold_build2 (MULT_EXPR, type, - fold_build2 (RDIV_EXPR, type, arg0, + return fold_build2_loc (loc, MULT_EXPR, type, + fold_build2_loc (loc, RDIV_EXPR, type, arg0, TREE_OPERAND (arg1, 0)), TREE_OPERAND (arg1, 1)); @@ -11518,7 +11811,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree tem = const_binop (RDIV_EXPR, arg0, TREE_OPERAND (arg1, 1), 0); if (tem) - return fold_build2 (RDIV_EXPR, type, tem, + return fold_build2_loc (loc, RDIV_EXPR, type, tem, TREE_OPERAND (arg1, 0)); } @@ -11537,7 +11830,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree tanfn = mathfn_built_in (type, BUILT_IN_TAN); if (tanfn != NULL_TREE) - return build_call_expr (tanfn, 1, CALL_EXPR_ARG (arg0, 0)); + return build_call_expr_loc (loc, tanfn, 1, CALL_EXPR_ARG (arg0, 0)); } /* Optimize cos(x)/sin(x) as 1.0/tan(x). */ @@ -11551,8 +11844,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (tanfn != NULL_TREE) { - tree tmp = build_call_expr (tanfn, 1, CALL_EXPR_ARG (arg0, 0)); - return fold_build2 (RDIV_EXPR, type, + tree tmp = build_call_expr_loc (loc, tanfn, 1, + CALL_EXPR_ARG (arg0, 0)); + return fold_build2_loc (loc, RDIV_EXPR, type, build_real (type, dconst1), tmp); } } @@ -11573,7 +11867,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree cosfn = mathfn_built_in (type, BUILT_IN_COS); if (cosfn != NULL_TREE) - return build_call_expr (cosfn, 1, arg00); + return build_call_expr_loc (loc, cosfn, 1, arg00); } } @@ -11594,8 +11888,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (cosfn != NULL_TREE) { - tree tmp = build_call_expr (cosfn, 1, arg00); - return fold_build2 (RDIV_EXPR, type, + tree tmp = build_call_expr_loc (loc, cosfn, 1, arg00); + return fold_build2_loc (loc, RDIV_EXPR, type, build_real (type, dconst1), tmp); } @@ -11620,7 +11914,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) c = TREE_REAL_CST (arg01); real_arithmetic (&c, MINUS_EXPR, &c, &dconst1); arg = build_real (type, c); - return build_call_expr (powfn, 2, arg1, arg); + return build_call_expr_loc (loc, powfn, 2, arg1, arg); } } @@ -11635,10 +11929,10 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree b = TREE_OPERAND (rootarg, 0); tree c = TREE_OPERAND (rootarg, 1); - tree tmp = fold_build2 (RDIV_EXPR, type, c, b); + tree tmp = fold_build2_loc (loc, RDIV_EXPR, type, c, b); - tmp = build_call_expr (rootfn, 1, tmp); - return fold_build2 (MULT_EXPR, type, arg0, tmp); + tmp = build_call_expr_loc (loc, rootfn, 1, tmp); + return fold_build2_loc (loc, MULT_EXPR, type, arg0, tmp); } } @@ -11647,8 +11941,10 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { tree expfn = TREE_OPERAND (CALL_EXPR_FN (arg1), 0); tree arg = negate_expr (CALL_EXPR_ARG (arg1, 0)); - arg1 = build_call_expr (expfn, 1, fold_convert (type, arg)); - return fold_build2 (MULT_EXPR, type, arg0, arg1); + arg1 = build_call_expr_loc (loc, + expfn, 1, + fold_convert_loc (loc, type, arg)); + return fold_build2_loc (loc, MULT_EXPR, type, arg0, arg1); } /* Optimize x/pow(y,z) into x*pow(y,-z). */ @@ -11659,9 +11955,10 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree powfn = TREE_OPERAND (CALL_EXPR_FN (arg1), 0); tree arg10 = CALL_EXPR_ARG (arg1, 0); tree arg11 = CALL_EXPR_ARG (arg1, 1); - tree neg11 = fold_convert (type, negate_expr (arg11)); - arg1 = build_call_expr (powfn, 2, arg10, neg11); - return fold_build2 (MULT_EXPR, type, arg0, arg1); + tree neg11 = fold_convert_loc (loc, type, + negate_expr (arg11)); + arg1 = build_call_expr_loc (loc, powfn, 2, arg10, neg11); + return fold_build2_loc (loc, MULT_EXPR, type, arg0, arg1); } } return NULL_TREE; @@ -11686,10 +11983,10 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) "occur when simplifying A / (B << N)"), WARN_STRICT_OVERFLOW_MISC); - sh_cnt = fold_build2 (PLUS_EXPR, TREE_TYPE (sh_cnt), + sh_cnt = fold_build2_loc (loc, PLUS_EXPR, TREE_TYPE (sh_cnt), sh_cnt, build_int_cst (NULL_TREE, pow2)); - return fold_build2 (RSHIFT_EXPR, type, - fold_convert (type, arg0), sh_cnt); + return fold_build2_loc (loc, RSHIFT_EXPR, type, + fold_convert_loc (loc, type, arg0), sh_cnt); } } @@ -11698,7 +11995,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) && code == FLOOR_DIV_EXPR) - return fold_build2 (TRUNC_DIV_EXPR, type, op0, op1); + return fold_build2_loc (loc, TRUNC_DIV_EXPR, type, op0, op1); /* Fall thru */ @@ -11706,7 +12003,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case CEIL_DIV_EXPR: case EXACT_DIV_EXPR: if (integer_onep (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); if (integer_zerop (arg1)) return NULL_TREE; /* X / -1 is -X. */ @@ -11714,7 +12011,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (arg1) == INTEGER_CST && TREE_INT_CST_LOW (arg1) == (unsigned HOST_WIDE_INT) -1 && TREE_INT_CST_HIGH (arg1) == -1) - return fold_convert (type, negate_expr (arg0)); + return fold_convert_loc (loc, type, negate_expr (arg0)); /* Convert -A / -B to A / B when the type is signed and overflow is undefined. */ @@ -11727,9 +12024,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) "when distributing negation across " "division"), WARN_STRICT_OVERFLOW_MISC); - return fold_build2 (code, type, - fold_convert (type, TREE_OPERAND (arg0, 0)), - fold_convert (type, negate_expr (arg1))); + return fold_build2_loc (loc, code, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0)), + fold_convert_loc (loc, type, + negate_expr (arg1))); } if ((!INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type)) && TREE_CODE (arg1) == NEGATE_EXPR @@ -11740,9 +12039,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) "when distributing negation across " "division"), WARN_STRICT_OVERFLOW_MISC); - return fold_build2 (code, type, - fold_convert (type, negate_expr (arg0)), - fold_convert (type, TREE_OPERAND (arg1, 0))); + return fold_build2_loc (loc, code, type, + fold_convert_loc (loc, type, + negate_expr (arg0)), + fold_convert_loc (loc, type, + TREE_OPERAND (arg1, 0))); } /* If arg0 is a multiple of arg1, then rewrite to the fastest div @@ -11753,7 +12054,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) after the last round to changes to the DIV code in expmed.c. */ if ((code == CEIL_DIV_EXPR || code == FLOOR_DIV_EXPR) && multiple_of_p (type, arg0, arg1)) - return fold_build2 (EXACT_DIV_EXPR, type, arg0, arg1); + return fold_build2_loc (loc, EXACT_DIV_EXPR, type, arg0, arg1); strict_overflow_p = false; if (TREE_CODE (arg1) == INTEGER_CST @@ -11764,7 +12065,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) fold_overflow_warning (("assuming signed overflow does not occur " "when simplifying division"), WARN_STRICT_OVERFLOW_MISC); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } return NULL_TREE; @@ -11776,7 +12077,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* X % 1 is always zero, but be sure to preserve any side effects in X. */ if (integer_onep (arg1)) - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); /* X % 0, return X % 0 unchanged so that we can get the proper warnings and errors. */ @@ -11786,14 +12087,14 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* 0 % X is always zero, but be sure to preserve any side effects in X. Place this after checking for X == 0. */ if (integer_zerop (arg0)) - return omit_one_operand (type, integer_zero_node, arg1); + return omit_one_operand_loc (loc, type, integer_zero_node, arg1); /* X % -1 is zero. */ if (!TYPE_UNSIGNED (type) && TREE_CODE (arg1) == INTEGER_CST && TREE_INT_CST_LOW (arg1) == (unsigned HOST_WIDE_INT) -1 && TREE_INT_CST_HIGH (arg1) == -1) - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); /* Optimize TRUNC_MOD_EXPR by a power of two into a BIT_AND_EXPR, i.e. "X % C" into "X & (C - 1)", if X and C are positive. */ @@ -11810,16 +12111,16 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (integer_pow2p (c) && tree_int_cst_sgn (c) > 0) { - tree mask = fold_build2 (MINUS_EXPR, TREE_TYPE (arg1), arg1, + tree mask = fold_build2_loc (loc, MINUS_EXPR, TREE_TYPE (arg1), arg1, build_int_cst (TREE_TYPE (arg1), 1)); if (strict_overflow_p) fold_overflow_warning (("assuming signed overflow does not " "occur when simplifying " "X % (power of two)"), WARN_STRICT_OVERFLOW_MISC); - return fold_build2 (BIT_AND_EXPR, type, - fold_convert (type, arg0), - fold_convert (type, mask)); + return fold_build2_loc (loc, BIT_AND_EXPR, type, + fold_convert_loc (loc, type, arg0), + fold_convert_loc (loc, type, mask)); } } @@ -11832,16 +12133,19 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && !TYPE_OVERFLOW_TRAPS (type) /* Avoid this transformation if C is INT_MIN, i.e. C == -C. */ && !sign_bit_p (arg1, arg1)) - return fold_build2 (code, type, fold_convert (type, arg0), - fold_convert (type, negate_expr (arg1))); + return fold_build2_loc (loc, code, type, + fold_convert_loc (loc, type, arg0), + fold_convert_loc (loc, type, + negate_expr (arg1))); /* X % -Y is the same as X % Y. */ if (code == TRUNC_MOD_EXPR && !TYPE_UNSIGNED (type) && TREE_CODE (arg1) == NEGATE_EXPR && !TYPE_OVERFLOW_TRAPS (type)) - return fold_build2 (code, type, fold_convert (type, arg0), - fold_convert (type, TREE_OPERAND (arg1, 0))); + return fold_build2_loc (loc, code, type, fold_convert_loc (loc, type, arg0), + fold_convert_loc (loc, type, + TREE_OPERAND (arg1, 0))); if (TREE_CODE (arg1) == INTEGER_CST && 0 != (tem = extract_muldiv (op0, arg1, code, NULL_TREE, @@ -11851,7 +12155,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) fold_overflow_warning (("assuming signed overflow does not occur " "when simplifying modulus"), WARN_STRICT_OVERFLOW_MISC); - return fold_convert (type, tem); + return fold_convert_loc (loc, type, tem); } return NULL_TREE; @@ -11859,22 +12163,22 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case LROTATE_EXPR: case RROTATE_EXPR: if (integer_all_onesp (arg0)) - return omit_one_operand (type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg0, arg1); goto shift; case RSHIFT_EXPR: /* Optimize -1 >> x for arithmetic right shifts. */ if (integer_all_onesp (arg0) && !TYPE_UNSIGNED (type) && tree_expr_nonnegative_p (arg1)) - return omit_one_operand (type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg0, arg1); /* ... fall through ... */ case LSHIFT_EXPR: shift: if (integer_zerop (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); if (integer_zerop (arg0)) - return omit_one_operand (type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg0, arg1); /* Since negative shift count is not well-defined, don't try to compute it in the compiler. */ @@ -11897,13 +12201,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (code == LROTATE_EXPR || code == RROTATE_EXPR) low = low % TYPE_PRECISION (type); else if (TYPE_UNSIGNED (type) || code == LSHIFT_EXPR) - return omit_one_operand (type, build_int_cst (type, 0), + return omit_one_operand_loc (loc, type, build_int_cst (type, 0), TREE_OPERAND (arg0, 0)); else low = TYPE_PRECISION (type) - 1; } - return fold_build2 (code, type, TREE_OPERAND (arg0, 0), + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), build_int_cst (type, low)); } @@ -11924,12 +12228,12 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (low0 == low1) { - arg00 = fold_convert (type, TREE_OPERAND (arg0, 0)); + arg00 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); lshift = build_int_cst (type, -1); lshift = int_const_binop (code, lshift, arg1, 0); - return fold_build2 (BIT_AND_EXPR, type, arg00, lshift); + return fold_build2_loc (loc, BIT_AND_EXPR, type, arg00, lshift); } } @@ -11940,7 +12244,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree tem = build_int_cst (TREE_TYPE (arg1), TYPE_PRECISION (type)); tem = const_binop (MINUS_EXPR, tem, arg1, 0); - return fold_build2 (RROTATE_EXPR, type, op0, tem); + return fold_build2_loc (loc, RROTATE_EXPR, type, op0, tem); } /* If we have a rotate of a bit operation with the rotate count and @@ -11951,10 +12255,10 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) || TREE_CODE (arg0) == BIT_IOR_EXPR || TREE_CODE (arg0) == BIT_XOR_EXPR) && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) - return fold_build2 (TREE_CODE (arg0), type, - fold_build2 (code, type, + return fold_build2_loc (loc, TREE_CODE (arg0), type, + fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), arg1), - fold_build2 (code, type, + fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 1), arg1)); /* Two consecutive rotates adding up to the precision of the @@ -11977,13 +12281,15 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) { - tree mask = fold_build2 (code, type, - fold_convert (type, TREE_OPERAND (arg0, 1)), + tree mask = fold_build2_loc (loc, code, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 1)), arg1); - tree shift = fold_build2 (code, type, - fold_convert (type, TREE_OPERAND (arg0, 0)), + tree shift = fold_build2_loc (loc, code, type, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0)), arg1); - tem = fold_binary (BIT_AND_EXPR, type, shift, mask); + tem = fold_binary_loc (loc, BIT_AND_EXPR, type, shift, mask); if (tem) return tem; } @@ -11992,23 +12298,23 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case MIN_EXPR: if (operand_equal_p (arg0, arg1, 0)) - return omit_one_operand (type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg0, arg1); if (INTEGRAL_TYPE_P (type) && operand_equal_p (arg1, TYPE_MIN_VALUE (type), OEP_ONLY_CONST)) - return omit_one_operand (type, arg1, arg0); - tem = fold_minmax (MIN_EXPR, type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg1, arg0); + tem = fold_minmax (loc, MIN_EXPR, type, arg0, arg1); if (tem) return tem; goto associate; case MAX_EXPR: if (operand_equal_p (arg0, arg1, 0)) - return omit_one_operand (type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg0, arg1); if (INTEGRAL_TYPE_P (type) && TYPE_MAX_VALUE (type) && operand_equal_p (arg1, TYPE_MAX_VALUE (type), OEP_ONLY_CONST)) - return omit_one_operand (type, arg1, arg0); - tem = fold_minmax (MAX_EXPR, type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg1, arg0); + tem = fold_minmax (loc, MAX_EXPR, type, arg0, arg1); if (tem) return tem; goto associate; @@ -12019,32 +12325,32 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) ("true" is a fixed value perhaps depending on the language.) */ /* If first arg is constant zero, return it. */ if (integer_zerop (arg0)) - return fold_convert (type, arg0); + return fold_convert_loc (loc, type, arg0); case TRUTH_AND_EXPR: /* If either arg is constant true, drop it. */ if (TREE_CODE (arg0) == INTEGER_CST && ! integer_zerop (arg0)) - return non_lvalue (fold_convert (type, arg1)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg1)); if (TREE_CODE (arg1) == INTEGER_CST && ! integer_zerop (arg1) /* Preserve sequence points. */ && (code != TRUTH_ANDIF_EXPR || ! TREE_SIDE_EFFECTS (arg0))) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* If second arg is constant zero, result is zero, but first arg must be evaluated. */ if (integer_zerop (arg1)) - return omit_one_operand (type, arg1, arg0); + return omit_one_operand_loc (loc, type, arg1, arg0); /* Likewise for first arg, but note that only the TRUTH_AND_EXPR case will be handled here. */ if (integer_zerop (arg0)) - return omit_one_operand (type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg0, arg1); /* !X && X is always false. */ if (TREE_CODE (arg0) == TRUTH_NOT_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) - return omit_one_operand (type, integer_zero_node, arg1); + return omit_one_operand_loc (loc, type, integer_zero_node, arg1); /* X && !X is always false. */ if (TREE_CODE (arg1) == TRUTH_NOT_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); /* A < X && A + 1 > Y ==> A < X && A >= Y. Normally A + 1 > Y means A >= Y && A != MAX, but in this case we know that @@ -12053,13 +12359,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (!TREE_SIDE_EFFECTS (arg0) && !TREE_SIDE_EFFECTS (arg1)) { - tem = fold_to_nonsharp_ineq_using_bound (arg0, arg1); + tem = fold_to_nonsharp_ineq_using_bound (loc, arg0, arg1); if (tem && !operand_equal_p (tem, arg0, 0)) - return fold_build2 (code, type, tem, arg1); + return fold_build2_loc (loc, code, type, tem, arg1); - tem = fold_to_nonsharp_ineq_using_bound (arg1, arg0); + tem = fold_to_nonsharp_ineq_using_bound (loc, arg1, arg0); if (tem && !operand_equal_p (tem, arg1, 0)) - return fold_build2 (code, type, arg0, tem); + return fold_build2_loc (loc, code, type, arg0, tem); } truth_andor: @@ -12090,38 +12396,38 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) || code == TRUTH_OR_EXPR)); if (operand_equal_p (a00, a10, 0)) - return fold_build2 (TREE_CODE (arg0), type, a00, - fold_build2 (code, type, a01, a11)); + return fold_build2_loc (loc, TREE_CODE (arg0), type, a00, + fold_build2_loc (loc, code, type, a01, a11)); else if (commutative && operand_equal_p (a00, a11, 0)) - return fold_build2 (TREE_CODE (arg0), type, a00, - fold_build2 (code, type, a01, a10)); + return fold_build2_loc (loc, TREE_CODE (arg0), type, a00, + fold_build2_loc (loc, code, type, a01, a10)); else if (commutative && operand_equal_p (a01, a10, 0)) - return fold_build2 (TREE_CODE (arg0), type, a01, - fold_build2 (code, type, a00, a11)); + return fold_build2_loc (loc, TREE_CODE (arg0), type, a01, + fold_build2_loc (loc, code, type, a00, a11)); /* This case if tricky because we must either have commutative operators or else A10 must not have side-effects. */ else if ((commutative || ! TREE_SIDE_EFFECTS (a10)) && operand_equal_p (a01, a11, 0)) - return fold_build2 (TREE_CODE (arg0), type, - fold_build2 (code, type, a00, a10), + return fold_build2_loc (loc, TREE_CODE (arg0), type, + fold_build2_loc (loc, code, type, a00, a10), a01); } /* See if we can build a range comparison. */ - if (0 != (tem = fold_range_test (code, type, op0, op1))) + if (0 != (tem = fold_range_test (loc, code, type, op0, op1))) return tem; /* Check for the possibility of merging component references. If our lhs is another similar operation, try to merge its rhs with our rhs. Then try to merge our lhs and rhs. */ if (TREE_CODE (arg0) == code - && 0 != (tem = fold_truthop (code, type, + && 0 != (tem = fold_truthop (loc, code, type, TREE_OPERAND (arg0, 1), arg1))) - return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem); + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), tem); - if ((tem = fold_truthop (code, type, arg0, arg1)) != 0) + if ((tem = fold_truthop (loc, code, type, arg0, arg1)) != 0) return tem; return NULL_TREE; @@ -12132,90 +12438,92 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) ("true" is a fixed value perhaps depending on the language.) */ /* If first arg is constant true, return it. */ if (TREE_CODE (arg0) == INTEGER_CST && ! integer_zerop (arg0)) - return fold_convert (type, arg0); + return fold_convert_loc (loc, type, arg0); case TRUTH_OR_EXPR: /* If either arg is constant zero, drop it. */ if (TREE_CODE (arg0) == INTEGER_CST && integer_zerop (arg0)) - return non_lvalue (fold_convert (type, arg1)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg1)); if (TREE_CODE (arg1) == INTEGER_CST && integer_zerop (arg1) /* Preserve sequence points. */ && (code != TRUTH_ORIF_EXPR || ! TREE_SIDE_EFFECTS (arg0))) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* If second arg is constant true, result is true, but we must evaluate first arg. */ if (TREE_CODE (arg1) == INTEGER_CST && ! integer_zerop (arg1)) - return omit_one_operand (type, arg1, arg0); + return omit_one_operand_loc (loc, type, arg1, arg0); /* Likewise for first arg, but note this only occurs here for TRUTH_OR_EXPR. */ if (TREE_CODE (arg0) == INTEGER_CST && ! integer_zerop (arg0)) - return omit_one_operand (type, arg0, arg1); + return omit_one_operand_loc (loc, type, arg0, arg1); /* !X || X is always true. */ if (TREE_CODE (arg0) == TRUTH_NOT_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) - return omit_one_operand (type, integer_one_node, arg1); + return omit_one_operand_loc (loc, type, integer_one_node, arg1); /* X || !X is always true. */ if (TREE_CODE (arg1) == TRUTH_NOT_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) - return omit_one_operand (type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, integer_one_node, arg0); goto truth_andor; case TRUTH_XOR_EXPR: /* If the second arg is constant zero, drop it. */ if (integer_zerop (arg1)) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* If the second arg is constant true, this is a logical inversion. */ if (integer_onep (arg1)) { /* Only call invert_truthvalue if operand is a truth value. */ if (TREE_CODE (TREE_TYPE (arg0)) != BOOLEAN_TYPE) - tem = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (arg0), arg0); + tem = fold_build1_loc (loc, TRUTH_NOT_EXPR, TREE_TYPE (arg0), arg0); else - tem = invert_truthvalue (arg0); - return non_lvalue (fold_convert (type, tem)); + tem = invert_truthvalue_loc (loc, arg0); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, tem)); } /* Identical arguments cancel to zero. */ if (operand_equal_p (arg0, arg1, 0)) - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); /* !X ^ X is always true. */ if (TREE_CODE (arg0) == TRUTH_NOT_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)) - return omit_one_operand (type, integer_one_node, arg1); + return omit_one_operand_loc (loc, type, integer_one_node, arg1); /* X ^ !X is always true. */ if (TREE_CODE (arg1) == TRUTH_NOT_EXPR && operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0)) - return omit_one_operand (type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, integer_one_node, arg0); return NULL_TREE; case EQ_EXPR: case NE_EXPR: - tem = fold_comparison (code, type, op0, op1); + tem = fold_comparison (loc, code, type, op0, op1); if (tem != NULL_TREE) return tem; /* bool_var != 0 becomes bool_var. */ if (TREE_CODE (TREE_TYPE (arg0)) == BOOLEAN_TYPE && integer_zerop (arg1) && code == NE_EXPR) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* bool_var == 1 becomes bool_var. */ if (TREE_CODE (TREE_TYPE (arg0)) == BOOLEAN_TYPE && integer_onep (arg1) && code == EQ_EXPR) - return non_lvalue (fold_convert (type, arg0)); + return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0)); /* bool_var != 1 becomes !bool_var. */ if (TREE_CODE (TREE_TYPE (arg0)) == BOOLEAN_TYPE && integer_onep (arg1) && code == NE_EXPR) - return fold_build1 (TRUTH_NOT_EXPR, type, fold_convert (type, arg0)); + return fold_build1_loc (loc, TRUTH_NOT_EXPR, type, + fold_convert_loc (loc, type, arg0)); /* bool_var == 0 becomes !bool_var. */ if (TREE_CODE (TREE_TYPE (arg0)) == BOOLEAN_TYPE && integer_zerop (arg1) && code == EQ_EXPR) - return fold_build1 (TRUTH_NOT_EXPR, type, fold_convert (type, arg0)); + return fold_build1_loc (loc, TRUTH_NOT_EXPR, type, + fold_convert_loc (loc, type, arg0)); /* If this is an equality comparison of the address of two non-weak, unaliased symbols neither of which are extern (since we do not @@ -12259,10 +12567,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST && 0 != (tem = const_binop (TREE_CODE (arg0) == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR, - fold_convert (TREE_TYPE (arg0), arg1), + fold_convert_loc (loc, TREE_TYPE (arg0), + arg1), TREE_OPERAND (arg0, 1), 0)) && !TREE_OVERFLOW (tem)) - return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem); + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), tem); /* Similarly for a NEGATE_EXPR. */ if (TREE_CODE (arg0) == NEGATE_EXPR @@ -12270,15 +12579,17 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && 0 != (tem = negate_expr (arg1)) && TREE_CODE (tem) == INTEGER_CST && !TREE_OVERFLOW (tem)) - return fold_build2 (code, type, TREE_OPERAND (arg0, 0), tem); + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), tem); /* Similarly for a BIT_XOR_EXPR; X ^ C1 == C2 is X == (C1 ^ C2). */ if (TREE_CODE (arg0) == BIT_XOR_EXPR && TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) - return fold_build2 (code, type, TREE_OPERAND (arg0, 0), - fold_build2 (BIT_XOR_EXPR, TREE_TYPE (arg0), - fold_convert (TREE_TYPE (arg0), arg1), + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), + fold_build2_loc (loc, BIT_XOR_EXPR, TREE_TYPE (arg0), + fold_convert_loc (loc, + TREE_TYPE (arg0), + arg1), TREE_OPERAND (arg0, 1))); /* Transform comparisons of the form X +- Y CMP X to Y CMP 0. */ @@ -12290,8 +12601,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) || POINTER_TYPE_P (TREE_TYPE (arg0)))) { tree val = TREE_OPERAND (arg0, 1); - return omit_two_operands (type, - fold_build2 (code, type, + return omit_two_operands_loc (loc, type, + fold_build2_loc (loc, code, type, val, build_int_cst (TREE_TYPE (val), 0)), @@ -12304,7 +12615,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0) && (TREE_INT_CST_LOW (TREE_OPERAND (arg0, 0)) & 1) == 1) { - return omit_two_operands (type, + return omit_two_operands_loc (loc, type, code == NE_EXPR ? boolean_true_node : boolean_false_node, TREE_OPERAND (arg0, 1), arg1); @@ -12314,13 +12625,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) for !=. Don't do this for ordered comparisons due to overflow. */ if (TREE_CODE (arg0) == MINUS_EXPR && integer_zerop (arg1)) - return fold_build2 (code, type, + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), TREE_OPERAND (arg0, 1)); /* Convert ABS_EXPR<x> == 0 or ABS_EXPR<x> != 0 to x == 0 or x != 0. */ if (TREE_CODE (arg0) == ABS_EXPR && (integer_zerop (arg1) || real_zerop (arg1))) - return fold_build2 (code, type, TREE_OPERAND (arg0, 0), arg1); + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), arg1); /* If this is an EQ or NE comparison with zero and ARG0 is (1 << foo) & bar, convert it to (bar >> foo) & 1. Both require @@ -12335,22 +12646,24 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (TREE_CODE (arg00) == LSHIFT_EXPR && integer_onep (TREE_OPERAND (arg00, 0))) { - tree tem = fold_build2 (RSHIFT_EXPR, TREE_TYPE (arg00), + tree tem = fold_build2_loc (loc, RSHIFT_EXPR, TREE_TYPE (arg00), arg01, TREE_OPERAND (arg00, 1)); - tem = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), tem, + tem = fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (arg0), tem, build_int_cst (TREE_TYPE (arg0), 1)); - return fold_build2 (code, type, - fold_convert (TREE_TYPE (arg1), tem), arg1); + return fold_build2_loc (loc, code, type, + fold_convert_loc (loc, TREE_TYPE (arg1), tem), + arg1); } else if (TREE_CODE (arg01) == LSHIFT_EXPR && integer_onep (TREE_OPERAND (arg01, 0))) { - tree tem = fold_build2 (RSHIFT_EXPR, TREE_TYPE (arg01), + tree tem = fold_build2_loc (loc, RSHIFT_EXPR, TREE_TYPE (arg01), arg00, TREE_OPERAND (arg01, 1)); - tem = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), tem, + tem = fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (arg0), tem, build_int_cst (TREE_TYPE (arg0), 1)); - return fold_build2 (code, type, - fold_convert (TREE_TYPE (arg1), tem), arg1); + return fold_build2_loc (loc, code, type, + fold_convert_loc (loc, TREE_TYPE (arg1), tem), + arg1); } } @@ -12366,14 +12679,14 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && integer_pow2p (TREE_OPERAND (arg0, 1))) { tree newtype = unsigned_type_for (TREE_TYPE (arg0)); - tree newmod = fold_build2 (TREE_CODE (arg0), newtype, - fold_convert (newtype, - TREE_OPERAND (arg0, 0)), - fold_convert (newtype, - TREE_OPERAND (arg0, 1))); + tree newmod = fold_build2_loc (loc, TREE_CODE (arg0), newtype, + fold_convert_loc (loc, newtype, + TREE_OPERAND (arg0, 0)), + fold_convert_loc (loc, newtype, + TREE_OPERAND (arg0, 1))); - return fold_build2 (code, type, newmod, - fold_convert (newtype, arg1)); + return fold_build2_loc (loc, code, type, newmod, + fold_convert_loc (loc, newtype, arg1)); } /* Fold ((X >> C1) & C2) == 0 and ((X >> C1) & C2) != 0 where @@ -12401,21 +12714,21 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) can be rewritten as (X & (C2 << C1)) != 0. */ if ((log2 + TREE_INT_CST_LOW (arg001)) < prec) { - tem = fold_build2 (LSHIFT_EXPR, itype, arg01, arg001); - tem = fold_build2 (BIT_AND_EXPR, itype, arg000, tem); - return fold_build2 (code, type, tem, arg1); + tem = fold_build2_loc (loc, LSHIFT_EXPR, itype, arg01, arg001); + tem = fold_build2_loc (loc, BIT_AND_EXPR, itype, arg000, tem); + return fold_build2_loc (loc, code, type, tem, arg1); } /* Otherwise, for signed (arithmetic) shifts, ((X >> C1) & C2) != 0 is rewritten as X < 0, and ((X >> C1) & C2) == 0 is rewritten as X >= 0. */ else if (!TYPE_UNSIGNED (itype)) - return fold_build2 (code == EQ_EXPR ? GE_EXPR : LT_EXPR, type, + return fold_build2_loc (loc, code == EQ_EXPR ? GE_EXPR : LT_EXPR, type, arg000, build_int_cst (itype, 0)); /* Otherwise, of unsigned (logical) shifts, ((X >> C1) & C2) != 0 is rewritten as (X,false), and ((X >> C1) & C2) == 0 is rewritten as (X,true). */ else - return omit_one_operand (type, + return omit_one_operand_loc (loc, type, code == EQ_EXPR ? integer_one_node : integer_zero_node, arg000); @@ -12428,20 +12741,20 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && integer_zerop (arg1) && TREE_CODE (arg0) == BIT_AND_EXPR && integer_onep (TREE_OPERAND (arg0, 1))) - return fold_convert (type, arg0); + return fold_convert_loc (loc, type, arg0); /* If we have (A & C) == C where C is a power of 2, convert this into (A & C) != 0. Similarly for NE_EXPR. */ if (TREE_CODE (arg0) == BIT_AND_EXPR && integer_pow2p (TREE_OPERAND (arg0, 1)) && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) - return fold_build2 (code == EQ_EXPR ? NE_EXPR : EQ_EXPR, type, - arg0, fold_convert (TREE_TYPE (arg0), - integer_zero_node)); + return fold_build2_loc (loc, code == EQ_EXPR ? NE_EXPR : EQ_EXPR, type, + arg0, fold_convert_loc (loc, TREE_TYPE (arg0), + integer_zero_node)); /* If we have (A & C) != 0 or (A & C) == 0 and C is the sign bit, then fold the expression into A < 0 or A >= 0. */ - tem = fold_single_bit_test_into_sign_test (code, arg0, arg1, type); + tem = fold_single_bit_test_into_sign_test (loc, code, arg0, arg1, type); if (tem) return tem; @@ -12451,14 +12764,14 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) { - tree notc = fold_build1 (BIT_NOT_EXPR, + tree notc = fold_build1_loc (loc, BIT_NOT_EXPR, TREE_TYPE (TREE_OPERAND (arg0, 1)), TREE_OPERAND (arg0, 1)); - tree dandnotc = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), + tree dandnotc = fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (arg0), arg1, notc); tree rslt = code == EQ_EXPR ? integer_zero_node : integer_one_node; if (integer_nonzerop (dandnotc)) - return omit_one_operand (type, rslt, arg0); + return omit_one_operand_loc (loc, type, rslt, arg0); } /* If we have (A | C) == D where C & ~D != 0, convert this into 0. @@ -12467,12 +12780,12 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) { - tree notd = fold_build1 (BIT_NOT_EXPR, TREE_TYPE (arg1), arg1); - tree candnotd = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), + tree notd = fold_build1_loc (loc, BIT_NOT_EXPR, TREE_TYPE (arg1), arg1); + tree candnotd = fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (arg0), TREE_OPERAND (arg0, 1), notd); tree rslt = code == EQ_EXPR ? integer_zero_node : integer_one_node; if (integer_nonzerop (candnotd)) - return omit_one_operand (type, rslt, arg0); + return omit_one_operand_loc (loc, type, rslt, arg0); } /* If this is a comparison of a field, we may be able to simplify it. */ @@ -12482,7 +12795,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) to make sure the warnings are given. */ && (optimize || TREE_CODE (arg1) == INTEGER_CST)) { - t1 = optimize_bit_field_compare (code, type, arg0, arg1); + t1 = optimize_bit_field_compare (loc, code, type, arg0, arg1); if (t1) return t1; } @@ -12504,8 +12817,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && call_expr_nargs (arg0) == 1 && TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (arg0, 0))) == POINTER_TYPE) { - tree iref = build_fold_indirect_ref (CALL_EXPR_ARG (arg0, 0)); - return fold_build2 (code, type, iref, + tree iref = build_fold_indirect_ref_loc (loc, + CALL_EXPR_ARG (arg0, 0)); + return fold_build2_loc (loc, code, type, iref, build_int_cst (TREE_TYPE (iref), 0)); } } @@ -12526,9 +12840,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (TYPE_UNSIGNED (itype)) { itype = signed_type_for (itype); - arg00 = fold_convert (itype, arg00); + arg00 = fold_convert_loc (loc, itype, arg00); } - return fold_build2 (code == EQ_EXPR ? GE_EXPR : LT_EXPR, + return fold_build2_loc (loc, code == EQ_EXPR ? GE_EXPR : LT_EXPR, type, arg00, build_int_cst (itype, 0)); } } @@ -12536,27 +12850,27 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* (X ^ Y) == 0 becomes X == Y, and (X ^ Y) != 0 becomes X != Y. */ if (integer_zerop (arg1) && TREE_CODE (arg0) == BIT_XOR_EXPR) - return fold_build2 (code, type, TREE_OPERAND (arg0, 0), + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), TREE_OPERAND (arg0, 1)); /* (X ^ Y) == Y becomes X == 0. We know that Y has no side-effects. */ if (TREE_CODE (arg0) == BIT_XOR_EXPR && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) - return fold_build2 (code, type, TREE_OPERAND (arg0, 0), + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), build_int_cst (TREE_TYPE (arg1), 0)); /* Likewise (X ^ Y) == X becomes Y == 0. X has no side-effects. */ if (TREE_CODE (arg0) == BIT_XOR_EXPR && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0) && reorder_operands_p (TREE_OPERAND (arg0, 1), arg1)) - return fold_build2 (code, type, TREE_OPERAND (arg0, 1), + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 1), build_int_cst (TREE_TYPE (arg1), 0)); /* (X ^ C1) op C2 can be rewritten as X op (C1 ^ C2). */ if (TREE_CODE (arg0) == BIT_XOR_EXPR && TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) - return fold_build2 (code, type, TREE_OPERAND (arg0, 0), - fold_build2 (BIT_XOR_EXPR, TREE_TYPE (arg1), + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), + fold_build2_loc (loc, BIT_XOR_EXPR, TREE_TYPE (arg1), TREE_OPERAND (arg0, 1), arg1)); /* Fold (~X & C) == 0 into (X & C) != 0 and (~X & C) != 0 into @@ -12566,10 +12880,10 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && integer_zerop (arg1) && integer_pow2p (TREE_OPERAND (arg0, 1))) { - tem = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), + tem = fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (arg0), TREE_OPERAND (TREE_OPERAND (arg0, 0), 0), TREE_OPERAND (arg0, 1)); - return fold_build2 (code == EQ_EXPR ? NE_EXPR : EQ_EXPR, + return fold_build2_loc (loc, code == EQ_EXPR ? NE_EXPR : EQ_EXPR, type, tem, arg1); } @@ -12583,7 +12897,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) TREE_OPERAND (arg0, 1), OEP_ONLY_CONST)) { tree arg00 = TREE_OPERAND (arg0, 0); - return fold_build2 (code == EQ_EXPR ? NE_EXPR : EQ_EXPR, type, + return fold_build2_loc (loc, code == EQ_EXPR ? NE_EXPR : EQ_EXPR, type, arg00, build_int_cst (TREE_TYPE (arg00), 0)); } @@ -12597,9 +12911,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) TREE_OPERAND (arg0, 1), OEP_ONLY_CONST)) { tree arg000 = TREE_OPERAND (TREE_OPERAND (arg0, 0), 0); - tem = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg000), + tem = fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (arg000), arg000, TREE_OPERAND (arg0, 1)); - return fold_build2 (code == EQ_EXPR ? NE_EXPR : EQ_EXPR, type, + return fold_build2_loc (loc, code == EQ_EXPR ? NE_EXPR : EQ_EXPR, type, tem, build_int_cst (TREE_TYPE (tem), 0)); } @@ -12607,13 +12921,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && tree_expr_nonzero_p (arg0)) { tree res = constant_boolean_node (code==NE_EXPR, type); - return omit_one_operand (type, res, arg0); + return omit_one_operand_loc (loc, type, res, arg0); } /* Fold -X op -Y as X op Y, where op is eq/ne. */ if (TREE_CODE (arg0) == NEGATE_EXPR && TREE_CODE (arg1) == NEGATE_EXPR) - return fold_build2 (code, type, + return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0), TREE_OPERAND (arg1, 0)); @@ -12628,33 +12942,37 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) tree itype = TREE_TYPE (arg0); if (operand_equal_p (arg01, arg11, 0)) - return fold_build2 (code, type, - fold_build2 (BIT_AND_EXPR, itype, - fold_build2 (BIT_XOR_EXPR, itype, + return fold_build2_loc (loc, code, type, + fold_build2_loc (loc, BIT_AND_EXPR, itype, + fold_build2_loc (loc, + BIT_XOR_EXPR, itype, arg00, arg10), arg01), build_int_cst (itype, 0)); if (operand_equal_p (arg01, arg10, 0)) - return fold_build2 (code, type, - fold_build2 (BIT_AND_EXPR, itype, - fold_build2 (BIT_XOR_EXPR, itype, + return fold_build2_loc (loc, code, type, + fold_build2_loc (loc, BIT_AND_EXPR, itype, + fold_build2_loc (loc, + BIT_XOR_EXPR, itype, arg00, arg11), arg01), build_int_cst (itype, 0)); if (operand_equal_p (arg00, arg11, 0)) - return fold_build2 (code, type, - fold_build2 (BIT_AND_EXPR, itype, - fold_build2 (BIT_XOR_EXPR, itype, + return fold_build2_loc (loc, code, type, + fold_build2_loc (loc, BIT_AND_EXPR, itype, + fold_build2_loc (loc, + BIT_XOR_EXPR, itype, arg01, arg10), arg00), build_int_cst (itype, 0)); if (operand_equal_p (arg00, arg10, 0)) - return fold_build2 (code, type, - fold_build2 (BIT_AND_EXPR, itype, - fold_build2 (BIT_XOR_EXPR, itype, + return fold_build2_loc (loc, code, type, + fold_build2_loc (loc, BIT_AND_EXPR, itype, + fold_build2_loc (loc, + BIT_XOR_EXPR, itype, arg01, arg11), arg00), build_int_cst (itype, 0)); @@ -12673,20 +12991,21 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) operand_equal_p guarantees no side-effects so we don't need to use omit_one_operand on Z. */ if (operand_equal_p (arg01, arg11, 0)) - return fold_build2 (code, type, arg00, arg10); + return fold_build2_loc (loc, code, type, arg00, arg10); if (operand_equal_p (arg01, arg10, 0)) - return fold_build2 (code, type, arg00, arg11); + return fold_build2_loc (loc, code, type, arg00, arg11); if (operand_equal_p (arg00, arg11, 0)) - return fold_build2 (code, type, arg01, arg10); + return fold_build2_loc (loc, code, type, arg01, arg10); if (operand_equal_p (arg00, arg10, 0)) - return fold_build2 (code, type, arg01, arg11); + return fold_build2_loc (loc, code, type, arg01, arg11); /* Optimize (X ^ C1) op (Y ^ C2) as (X ^ (C1 ^ C2)) op Y. */ if (TREE_CODE (arg01) == INTEGER_CST && TREE_CODE (arg11) == INTEGER_CST) - return fold_build2 (code, type, - fold_build2 (BIT_XOR_EXPR, itype, arg00, - fold_build2 (BIT_XOR_EXPR, itype, + return fold_build2_loc (loc, code, type, + fold_build2_loc (loc, BIT_XOR_EXPR, itype, arg00, + fold_build2_loc (loc, + BIT_XOR_EXPR, itype, arg01, arg11)), arg10); } @@ -12724,41 +13043,41 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) imag1 = TREE_IMAGPART (arg1); } - rcond = fold_binary (code, type, real0, real1); + rcond = fold_binary_loc (loc, code, type, real0, real1); if (rcond && TREE_CODE (rcond) == INTEGER_CST) { if (integer_zerop (rcond)) { if (code == EQ_EXPR) - return omit_two_operands (type, boolean_false_node, + return omit_two_operands_loc (loc, type, boolean_false_node, imag0, imag1); - return fold_build2 (NE_EXPR, type, imag0, imag1); + return fold_build2_loc (loc, NE_EXPR, type, imag0, imag1); } else { if (code == NE_EXPR) - return omit_two_operands (type, boolean_true_node, + return omit_two_operands_loc (loc, type, boolean_true_node, imag0, imag1); - return fold_build2 (EQ_EXPR, type, imag0, imag1); + return fold_build2_loc (loc, EQ_EXPR, type, imag0, imag1); } } - icond = fold_binary (code, type, imag0, imag1); + icond = fold_binary_loc (loc, code, type, imag0, imag1); if (icond && TREE_CODE (icond) == INTEGER_CST) { if (integer_zerop (icond)) { if (code == EQ_EXPR) - return omit_two_operands (type, boolean_false_node, + return omit_two_operands_loc (loc, type, boolean_false_node, real0, real1); - return fold_build2 (NE_EXPR, type, real0, real1); + return fold_build2_loc (loc, NE_EXPR, type, real0, real1); } else { if (code == NE_EXPR) - return omit_two_operands (type, boolean_true_node, + return omit_two_operands_loc (loc, type, boolean_true_node, real0, real1); - return fold_build2 (EQ_EXPR, type, real0, real1); + return fold_build2_loc (loc, EQ_EXPR, type, real0, real1); } } } @@ -12769,7 +13088,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case GT_EXPR: case LE_EXPR: case GE_EXPR: - tem = fold_comparison (code, type, op0, op1); + tem = fold_comparison (loc, code, type, op0, op1); if (tem != NULL_TREE) return tem; @@ -12962,16 +13281,16 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) switch (code) { case GT_EXPR: - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); case GE_EXPR: - return fold_build2 (EQ_EXPR, type, op0, op1); + return fold_build2_loc (loc, EQ_EXPR, type, op0, op1); case LE_EXPR: - return omit_one_operand (type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, integer_one_node, arg0); case LT_EXPR: - return fold_build2 (NE_EXPR, type, op0, op1); + return fold_build2_loc (loc, NE_EXPR, type, op0, op1); /* The GE_EXPR and LT_EXPR cases above are not normally reached because of previous transformations. */ @@ -12987,14 +13306,16 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case GT_EXPR: arg1 = const_binop (PLUS_EXPR, arg1, build_int_cst (TREE_TYPE (arg1), 1), 0); - return fold_build2 (EQ_EXPR, type, - fold_convert (TREE_TYPE (arg1), arg0), + return fold_build2_loc (loc, EQ_EXPR, type, + fold_convert_loc (loc, + TREE_TYPE (arg1), arg0), arg1); case LE_EXPR: arg1 = const_binop (PLUS_EXPR, arg1, build_int_cst (TREE_TYPE (arg1), 1), 0); - return fold_build2 (NE_EXPR, type, - fold_convert (TREE_TYPE (arg1), arg0), + return fold_build2_loc (loc, NE_EXPR, type, + fold_convert_loc (loc, TREE_TYPE (arg1), + arg0), arg1); default: break; @@ -13005,16 +13326,16 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) switch (code) { case LT_EXPR: - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); case LE_EXPR: - return fold_build2 (EQ_EXPR, type, op0, op1); + return fold_build2_loc (loc, EQ_EXPR, type, op0, op1); case GE_EXPR: - return omit_one_operand (type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, integer_one_node, arg0); case GT_EXPR: - return fold_build2 (NE_EXPR, type, op0, op1); + return fold_build2_loc (loc, NE_EXPR, type, op0, op1); default: break; @@ -13026,13 +13347,15 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { case GE_EXPR: arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0); - return fold_build2 (NE_EXPR, type, - fold_convert (TREE_TYPE (arg1), arg0), + return fold_build2_loc (loc, NE_EXPR, type, + fold_convert_loc (loc, + TREE_TYPE (arg1), arg0), arg1); case LT_EXPR: arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0); - return fold_build2 (EQ_EXPR, type, - fold_convert (TREE_TYPE (arg1), arg0), + return fold_build2_loc (loc, EQ_EXPR, type, + fold_convert_loc (loc, TREE_TYPE (arg1), + arg0), arg1); default: break; @@ -13055,8 +13378,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { tree st; st = signed_type_for (TREE_TYPE (arg1)); - return fold_build2 (code == LE_EXPR ? GE_EXPR : LT_EXPR, - type, fold_convert (st, arg0), + return fold_build2_loc (loc, + code == LE_EXPR ? GE_EXPR : LT_EXPR, + type, fold_convert_loc (loc, st, arg0), build_int_cst (st, 0)); } } @@ -13075,7 +13399,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && (0 != (tem = negate_expr (arg1))) && TREE_CODE (tem) == INTEGER_CST && !TREE_OVERFLOW (tem)) - return fold_build2 (TRUTH_ANDIF_EXPR, type, + return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type, build2 (GE_EXPR, type, TREE_OPERAND (arg0, 0), tem), build2 (LE_EXPR, type, @@ -13094,7 +13418,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) "when simplifying comparison of " "absolute value and zero"), WARN_STRICT_OVERFLOW_CONDITIONAL); - return omit_one_operand (type, integer_one_node, arg0); + return omit_one_operand_loc (loc, type, integer_one_node, arg0); } /* Convert ABS_EXPR<x> < 0 to false. */ @@ -13108,7 +13432,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) "when simplifying comparison of " "absolute value and zero"), WARN_STRICT_OVERFLOW_CONDITIONAL); - return omit_one_operand (type, integer_zero_node, arg0); + return omit_one_operand_loc (loc, type, integer_zero_node, arg0); } /* If X is unsigned, convert X < (1 << Y) into X >> Y == 0 @@ -13117,23 +13441,29 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TYPE_UNSIGNED (TREE_TYPE (arg0)) && TREE_CODE (arg1) == LSHIFT_EXPR && integer_onep (TREE_OPERAND (arg1, 0))) - return build2 (code == LT_EXPR ? EQ_EXPR : NE_EXPR, type, - build2 (RSHIFT_EXPR, TREE_TYPE (arg0), arg0, - TREE_OPERAND (arg1, 1)), - build_int_cst (TREE_TYPE (arg0), 0)); + { + tem = build2 (code == LT_EXPR ? EQ_EXPR : NE_EXPR, type, + build2 (RSHIFT_EXPR, TREE_TYPE (arg0), arg0, + TREE_OPERAND (arg1, 1)), + build_int_cst (TREE_TYPE (arg0), 0)); + goto fold_binary_exit; + } if ((code == LT_EXPR || code == GE_EXPR) && TYPE_UNSIGNED (TREE_TYPE (arg0)) && CONVERT_EXPR_P (arg1) && TREE_CODE (TREE_OPERAND (arg1, 0)) == LSHIFT_EXPR && integer_onep (TREE_OPERAND (TREE_OPERAND (arg1, 0), 0))) - return - build2 (code == LT_EXPR ? EQ_EXPR : NE_EXPR, type, - fold_convert (TREE_TYPE (arg0), - build2 (RSHIFT_EXPR, TREE_TYPE (arg0), arg0, - TREE_OPERAND (TREE_OPERAND (arg1, 0), - 1))), - build_int_cst (TREE_TYPE (arg0), 0)); + { + tem = build2 (code == LT_EXPR ? EQ_EXPR : NE_EXPR, type, + fold_convert_loc (loc, TREE_TYPE (arg0), + build2 (RSHIFT_EXPR, + TREE_TYPE (arg0), arg0, + TREE_OPERAND (TREE_OPERAND (arg1, 0), + 1))), + build_int_cst (TREE_TYPE (arg0), 0)); + goto fold_binary_exit; + } return NULL_TREE; @@ -13160,7 +13490,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) t1 = (code == ORDERED_EXPR || code == LTGT_EXPR) ? integer_zero_node : integer_one_node; - return omit_one_operand (type, t1, arg1); + return omit_one_operand_loc (loc, type, t1, arg1); } /* If the second operand is NaN, the result is constant. */ @@ -13171,7 +13501,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) t1 = (code == ORDERED_EXPR || code == LTGT_EXPR) ? integer_zero_node : integer_one_node; - return omit_one_operand (type, t1, arg0); + return omit_one_operand_loc (loc, type, t1, arg0); } /* Simplify unordered comparison of something with itself. */ @@ -13194,8 +13524,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) newtype = TREE_TYPE (targ1); if (TYPE_PRECISION (newtype) < TYPE_PRECISION (TREE_TYPE (arg0))) - return fold_build2 (code, type, fold_convert (newtype, targ0), - fold_convert (newtype, targ1)); + return fold_build2_loc (loc, code, type, + fold_convert_loc (loc, newtype, targ0), + fold_convert_loc (loc, newtype, targ1)); } return NULL_TREE; @@ -13207,8 +13538,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) return NULL_TREE; /* Don't let (0, 0) be null pointer constant. */ tem = integer_zerop (arg1) ? build1 (NOP_EXPR, type, arg1) - : fold_convert (type, arg1); - return pedantic_non_lvalue (tem); + : fold_convert_loc (loc, type, arg1); + return pedantic_non_lvalue_loc (loc, tem); case COMPLEX_EXPR: if ((TREE_CODE (arg0) == REAL_CST @@ -13225,6 +13556,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) default: return NULL_TREE; } /* switch (code) */ + fold_binary_exit: + protected_set_expr_location (tem, loc); + return tem; } /* Callback for walk_tree, looking for LABEL_EXPR. Return *TP if it is @@ -13264,7 +13598,8 @@ contains_label_p (tree st) successful. Otherwise, return NULL_TREE. */ tree -fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) +fold_ternary_loc (location_t loc, enum tree_code code, tree type, + tree op0, tree op1, tree op2) { tree tem; tree arg0 = NULL_TREE, arg1 = NULL_TREE; @@ -13324,11 +13659,11 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) || !contains_label_p (unused_op)) && (! VOID_TYPE_P (TREE_TYPE (tem)) || VOID_TYPE_P (type))) - return pedantic_non_lvalue (tem); + return pedantic_non_lvalue_loc (loc, tem); return NULL_TREE; } if (operand_equal_p (arg1, op2, 0)) - return pedantic_omit_one_operand (type, arg1, arg0); + return pedantic_omit_one_operand_loc (loc, type, arg1, arg0); /* If we have A op B ? A : C, we may be able to convert this to a simpler expression, depending on the operation and the values @@ -13341,7 +13676,7 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) arg1, TREE_OPERAND (arg0, 1)) && !HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (arg1)))) { - tem = fold_cond_expr_with_comparison (type, arg0, op1, op2); + tem = fold_cond_expr_with_comparison (loc, type, arg0, op1, op2); if (tem) return tem; } @@ -13352,10 +13687,10 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) TREE_OPERAND (arg0, 1)) && !HONOR_SIGNED_ZEROS (TYPE_MODE (TREE_TYPE (op2)))) { - tem = fold_truth_not_expr (arg0); + tem = fold_truth_not_expr (loc, arg0); if (tem && COMPARISON_CLASS_P (tem)) { - tem = fold_cond_expr_with_comparison (type, tem, op2, op1); + tem = fold_cond_expr_with_comparison (loc, type, tem, op2, op1); if (tem) return tem; } @@ -13369,9 +13704,9 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) /* See if this can be inverted. If it can't, possibly because it was a floating-point inequality comparison, don't do anything. */ - tem = fold_truth_not_expr (arg0); + tem = fold_truth_not_expr (loc, arg0); if (tem) - return fold_build3 (code, type, tem, op2, op1); + return fold_build3_loc (loc, code, type, tem, op2, op1); } /* Convert A ? 1 : 0 to simply A. */ @@ -13382,15 +13717,17 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) a COND, which will recurse. In that case, the COND_EXPR is probably the best choice, so leave it alone. */ && type == TREE_TYPE (arg0)) - return pedantic_non_lvalue (arg0); + return pedantic_non_lvalue_loc (loc, arg0); /* Convert A ? 0 : 1 to !A. This prefers the use of NOT_EXPR over COND_EXPR in cases such as floating point comparisons. */ if (integer_zerop (op1) && integer_onep (op2) && truth_value_p (TREE_CODE (arg0))) - return pedantic_non_lvalue (fold_convert (type, - invert_truthvalue (arg0))); + return pedantic_non_lvalue_loc (loc, + fold_convert_loc (loc, type, + invert_truthvalue_loc (loc, + arg0))); /* A < 0 ? <sign bit of A> : 0 is simply (A & <sign bit of A>). */ if (TREE_CODE (arg0) == LT_EXPR @@ -13445,24 +13782,26 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) && (TREE_INT_CST_LOW (arg1) & mask_lo) == mask_lo) { tem_type = signed_type_for (TREE_TYPE (tem)); - tem = fold_convert (tem_type, tem); + tem = fold_convert_loc (loc, tem_type, tem); } else if ((TREE_INT_CST_HIGH (arg1) & mask_hi) == 0 && (TREE_INT_CST_LOW (arg1) & mask_lo) == 0) { tem_type = unsigned_type_for (TREE_TYPE (tem)); - tem = fold_convert (tem_type, tem); + tem = fold_convert_loc (loc, tem_type, tem); } else tem = NULL; } if (tem) - return fold_convert (type, - fold_build2 (BIT_AND_EXPR, - TREE_TYPE (tem), tem, - fold_convert (TREE_TYPE (tem), - arg1))); + return + fold_convert_loc (loc, type, + fold_build2_loc (loc, BIT_AND_EXPR, + TREE_TYPE (tem), tem, + fold_convert_loc (loc, + TREE_TYPE (tem), + arg1))); } /* (A >> N) & 1 ? (1 << N) : 0 is simply A & (1 << N). A & 1 was @@ -13478,7 +13817,7 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST && (unsigned HOST_WIDE_INT) tree_log2 (arg1) == TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))) - return fold_build2 (BIT_AND_EXPR, type, + return fold_build2_loc (loc, BIT_AND_EXPR, type, TREE_OPERAND (tem, 0), arg1); } @@ -13493,15 +13832,16 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) && TREE_CODE (TREE_OPERAND (arg0, 0)) == BIT_AND_EXPR && operand_equal_p (TREE_OPERAND (TREE_OPERAND (arg0, 0), 1), arg1, OEP_ONLY_CONST)) - return pedantic_non_lvalue (fold_convert (type, - TREE_OPERAND (arg0, 0))); + return pedantic_non_lvalue_loc (loc, + fold_convert_loc (loc, type, + TREE_OPERAND (arg0, 0))); /* Convert A ? B : 0 into A && B if A and B are truth values. */ if (integer_zerop (op2) && truth_value_p (TREE_CODE (arg0)) && truth_value_p (TREE_CODE (arg1))) - return fold_build2 (TRUTH_ANDIF_EXPR, type, - fold_convert (type, arg0), + return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type, + fold_convert_loc (loc, type, arg0), arg1); /* Convert A ? B : 1 into !A || B if A and B are truth values. */ @@ -13510,10 +13850,10 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) && truth_value_p (TREE_CODE (arg1))) { /* Only perform transformation if ARG0 is easily inverted. */ - tem = fold_truth_not_expr (arg0); + tem = fold_truth_not_expr (loc, arg0); if (tem) - return fold_build2 (TRUTH_ORIF_EXPR, type, - fold_convert (type, tem), + return fold_build2_loc (loc, TRUTH_ORIF_EXPR, type, + fold_convert_loc (loc, type, tem), arg1); } @@ -13523,10 +13863,10 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) && truth_value_p (TREE_CODE (op2))) { /* Only perform transformation if ARG0 is easily inverted. */ - tem = fold_truth_not_expr (arg0); + tem = fold_truth_not_expr (loc, arg0); if (tem) - return fold_build2 (TRUTH_ANDIF_EXPR, type, - fold_convert (type, tem), + return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type, + fold_convert_loc (loc, type, tem), op2); } @@ -13534,8 +13874,8 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) if (integer_onep (arg1) && truth_value_p (TREE_CODE (arg0)) && truth_value_p (TREE_CODE (op2))) - return fold_build2 (TRUTH_ORIF_EXPR, type, - fold_convert (type, arg0), + return fold_build2_loc (loc, TRUTH_ORIF_EXPR, type, + fold_convert_loc (loc, type, arg0), op2); return NULL_TREE; @@ -13576,7 +13916,7 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) if (elements) return TREE_VALUE (elements); else - return fold_convert (type, integer_zero_node); + return fold_convert_loc (loc, type, integer_zero_node); } } @@ -13584,7 +13924,7 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2) if (INTEGRAL_TYPE_P (TREE_TYPE (arg0)) && TYPE_PRECISION (TREE_TYPE (arg0)) == tree_low_cst (arg1, 1) && integer_zerop (op2)) - return fold_convert (type, arg0); + return fold_convert_loc (loc, type, arg0); return NULL_TREE; @@ -13613,6 +13953,7 @@ fold (tree expr) enum tree_code code = TREE_CODE (t); enum tree_code_class kind = TREE_CODE_CLASS (code); tree tem; + location_t loc = EXPR_LOCATION (expr); /* Return right away if a constant. */ if (kind == tcc_constant) @@ -13624,7 +13965,7 @@ fold (tree expr) { if (code == CALL_EXPR) { - tem = fold_call_expr (expr, false); + tem = fold_call_expr (loc, expr, false); return tem ? tem : expr; } return expr; @@ -13639,18 +13980,18 @@ fold (tree expr) { case 1: op0 = TREE_OPERAND (t, 0); - tem = fold_unary (code, type, op0); + tem = fold_unary_loc (loc, code, type, op0); return tem ? tem : expr; case 2: op0 = TREE_OPERAND (t, 0); op1 = TREE_OPERAND (t, 1); - tem = fold_binary (code, type, op0, op1); + tem = fold_binary_loc (loc, code, type, op0, op1); return tem ? tem : expr; case 3: op0 = TREE_OPERAND (t, 0); op1 = TREE_OPERAND (t, 1); op2 = TREE_OPERAND (t, 2); - tem = fold_ternary (code, type, op0, op1, op2); + tem = fold_ternary_loc (loc, code, type, op0, op1, op2); return tem ? tem : expr; default: break; @@ -13944,12 +14285,13 @@ debug_fold_checksum (const_tree t) #endif /* Fold a unary tree expression with code CODE of type TYPE with an - operand OP0. Return a folded expression if successful. Otherwise, - return a tree expression with code CODE of type TYPE with an - operand OP0. */ + operand OP0. LOC is the location of the resulting expression. + Return a folded expression if successful. Otherwise, return a tree + expression with code CODE of type TYPE with an operand OP0. */ tree -fold_build1_stat (enum tree_code code, tree type, tree op0 MEM_STAT_DECL) +fold_build1_stat_loc (location_t loc, + enum tree_code code, tree type, tree op0 MEM_STAT_DECL) { tree tem; #ifdef ENABLE_FOLD_CHECKING @@ -13964,9 +14306,12 @@ fold_build1_stat (enum tree_code code, tree type, tree op0 MEM_STAT_DECL) htab_empty (ht); #endif - tem = fold_unary (code, type, op0); + tem = fold_unary_loc (loc, code, type, op0); if (!tem) - tem = build1_stat (code, type, op0 PASS_MEM_STAT); + { + tem = build1_stat (code, type, op0 PASS_MEM_STAT); + SET_EXPR_LOCATION (tem, loc); + } #ifdef ENABLE_FOLD_CHECKING md5_init_ctx (&ctx); @@ -13981,13 +14326,15 @@ fold_build1_stat (enum tree_code code, tree type, tree op0 MEM_STAT_DECL) } /* Fold a binary tree expression with code CODE of type TYPE with - operands OP0 and OP1. Return a folded expression if successful. - Otherwise, return a tree expression with code CODE of type TYPE - with operands OP0 and OP1. */ + operands OP0 and OP1. LOC is the location of the resulting + expression. Return a folded expression if successful. Otherwise, + return a tree expression with code CODE of type TYPE with operands + OP0 and OP1. */ tree -fold_build2_stat (enum tree_code code, tree type, tree op0, tree op1 - MEM_STAT_DECL) +fold_build2_stat_loc (location_t loc, + enum tree_code code, tree type, tree op0, tree op1 + MEM_STAT_DECL) { tree tem; #ifdef ENABLE_FOLD_CHECKING @@ -14010,9 +14357,12 @@ fold_build2_stat (enum tree_code code, tree type, tree op0, tree op1 htab_empty (ht); #endif - tem = fold_binary (code, type, op0, op1); + tem = fold_binary_loc (loc, code, type, op0, op1); if (!tem) - tem = build2_stat (code, type, op0, op1 PASS_MEM_STAT); + { + tem = build2_stat (code, type, op0, op1 PASS_MEM_STAT); + SET_EXPR_LOCATION (tem, loc); + } #ifdef ENABLE_FOLD_CHECKING md5_init_ctx (&ctx); @@ -14040,8 +14390,8 @@ fold_build2_stat (enum tree_code code, tree type, tree op0, tree op1 type TYPE with operands OP0, OP1, and OP2. */ tree -fold_build3_stat (enum tree_code code, tree type, tree op0, tree op1, tree op2 - MEM_STAT_DECL) +fold_build3_stat_loc (location_t loc, enum tree_code code, tree type, + tree op0, tree op1, tree op2 MEM_STAT_DECL) { tree tem; #ifdef ENABLE_FOLD_CHECKING @@ -14072,9 +14422,12 @@ fold_build3_stat (enum tree_code code, tree type, tree op0, tree op1, tree op2 #endif gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp); - tem = fold_ternary (code, type, op0, op1, op2); + tem = fold_ternary_loc (loc, code, type, op0, op1, op2); if (!tem) - tem = build3_stat (code, type, op0, op1, op2 PASS_MEM_STAT); + { + tem = build3_stat (code, type, op0, op1, op2 PASS_MEM_STAT); + SET_EXPR_LOCATION (tem, loc); + } #ifdef ENABLE_FOLD_CHECKING md5_init_ctx (&ctx); @@ -14110,7 +14463,8 @@ fold_build3_stat (enum tree_code code, tree type, tree op0, tree op1, tree op2 of type TYPE from the given operands as constructed by build_call_array. */ tree -fold_build_call_array (tree type, tree fn, int nargs, tree *argarray) +fold_build_call_array_loc (location_t loc, tree type, tree fn, + int nargs, tree *argarray) { tree tem; #ifdef ENABLE_FOLD_CHECKING @@ -14135,7 +14489,7 @@ fold_build_call_array (tree type, tree fn, int nargs, tree *argarray) htab_empty (ht); #endif - tem = fold_builtin_call_array (type, fn, nargs, argarray); + tem = fold_builtin_call_array (loc, type, fn, nargs, argarray); #ifdef ENABLE_FOLD_CHECKING md5_init_ctx (&ctx); @@ -14182,50 +14536,52 @@ fold_build_call_array (tree type, tree fn, int nargs, tree *argarray) folding_initializer = saved_folding_initializer; tree -fold_build1_initializer (enum tree_code code, tree type, tree op) +fold_build1_initializer_loc (location_t loc, enum tree_code code, + tree type, tree op) { tree result; START_FOLD_INIT; - result = fold_build1 (code, type, op); + result = fold_build1_loc (loc, code, type, op); END_FOLD_INIT; return result; } tree -fold_build2_initializer (enum tree_code code, tree type, tree op0, tree op1) +fold_build2_initializer_loc (location_t loc, enum tree_code code, + tree type, tree op0, tree op1) { tree result; START_FOLD_INIT; - result = fold_build2 (code, type, op0, op1); + result = fold_build2_loc (loc, code, type, op0, op1); END_FOLD_INIT; return result; } tree -fold_build3_initializer (enum tree_code code, tree type, tree op0, tree op1, - tree op2) +fold_build3_initializer_loc (location_t loc, enum tree_code code, + tree type, tree op0, tree op1, tree op2) { tree result; START_FOLD_INIT; - result = fold_build3 (code, type, op0, op1, op2); + result = fold_build3_loc (loc, code, type, op0, op1, op2); END_FOLD_INIT; return result; } tree -fold_build_call_array_initializer (tree type, tree fn, - int nargs, tree *argarray) +fold_build_call_array_initializer_loc (location_t loc, tree type, tree fn, + int nargs, tree *argarray) { tree result; START_FOLD_INIT; - result = fold_build_call_array (type, fn, nargs, argarray); + result = fold_build_call_array_loc (loc, type, fn, nargs, argarray); END_FOLD_INIT; return result; @@ -15238,13 +15594,14 @@ fold_read_from_constant_string (tree exp) tree exp1 = TREE_OPERAND (exp, 0); tree index; tree string; + location_t loc = EXPR_LOCATION (exp); if (TREE_CODE (exp) == INDIRECT_REF) string = string_constant (exp1, &index); else { tree low_bound = array_ref_low_bound (exp); - index = fold_convert (sizetype, TREE_OPERAND (exp, 1)); + index = fold_convert_loc (loc, sizetype, TREE_OPERAND (exp, 1)); /* Optimize the special-case of a zero lower bound. @@ -15254,7 +15611,8 @@ fold_read_from_constant_string (tree exp) +(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned char)1)) +INDEX), which becomes (ARRAY+255+INDEX). Oops!) */ if (! integer_zerop (low_bound)) - index = size_diffop (index, fold_convert (sizetype, low_bound)); + index = size_diffop_loc (loc, index, + fold_convert_loc (loc, sizetype, low_bound)); string = exp1; } @@ -15551,7 +15909,7 @@ fold_build_cleanup_point_expr (tree type, tree expr) possible. */ tree -fold_indirect_ref_1 (tree type, tree op0) +fold_indirect_ref_1 (location_t loc, tree type, tree op0) { tree sub = op0; tree subtype; @@ -15585,19 +15943,21 @@ fold_indirect_ref_1 (tree type, tree op0) tree min_val = size_zero_node; if (type_domain && TYPE_MIN_VALUE (type_domain)) min_val = TYPE_MIN_VALUE (type_domain); - return build4 (ARRAY_REF, type, op, min_val, NULL_TREE, NULL_TREE); + op0 = build4 (ARRAY_REF, type, op, min_val, NULL_TREE, NULL_TREE); + SET_EXPR_LOCATION (op0, loc); + return op0; } /* *(foo *)&complexfoo => __real__ complexfoo */ else if (TREE_CODE (optype) == COMPLEX_TYPE && type == TREE_TYPE (optype)) - return fold_build1 (REALPART_EXPR, type, op); + return fold_build1_loc (loc, REALPART_EXPR, type, op); /* *(foo *)&vectorfoo => BIT_FIELD_REF<vectorfoo,...> */ else if (TREE_CODE (optype) == VECTOR_TYPE && type == TREE_TYPE (optype)) { tree part_width = TYPE_SIZE (type); tree index = bitsize_int (0); - return fold_build3 (BIT_FIELD_REF, type, op, part_width, index); + return fold_build3_loc (loc, BIT_FIELD_REF, type, op, part_width, index); } } @@ -15622,7 +15982,8 @@ fold_indirect_ref_1 (tree type, tree op0) tree index = bitsize_int (indexi); if (offset/part_widthi <= TYPE_VECTOR_SUBPARTS (TREE_TYPE (op00type))) - return fold_build3 (BIT_FIELD_REF, type, TREE_OPERAND (op00, 0), + return fold_build3_loc (loc, + BIT_FIELD_REF, type, TREE_OPERAND (op00, 0), part_width, index); } @@ -15645,7 +16006,8 @@ fold_indirect_ref_1 (tree type, tree op0) { tree size = TYPE_SIZE_UNIT (type); if (tree_int_cst_equal (size, op01)) - return fold_build1 (IMAGPART_EXPR, type, TREE_OPERAND (op00, 0)); + return fold_build1_loc (loc, IMAGPART_EXPR, type, + TREE_OPERAND (op00, 0)); } } @@ -15655,11 +16017,13 @@ fold_indirect_ref_1 (tree type, tree op0) { tree type_domain; tree min_val = size_zero_node; - sub = build_fold_indirect_ref (sub); + sub = build_fold_indirect_ref_loc (loc, sub); type_domain = TYPE_DOMAIN (TREE_TYPE (sub)); if (type_domain && TYPE_MIN_VALUE (type_domain)) min_val = TYPE_MIN_VALUE (type_domain); - return build4 (ARRAY_REF, type, sub, min_val, NULL_TREE, NULL_TREE); + op0 = build4 (ARRAY_REF, type, sub, min_val, NULL_TREE, NULL_TREE); + SET_EXPR_LOCATION (op0, loc); + return op0; } return NULL_TREE; @@ -15669,23 +16033,25 @@ fold_indirect_ref_1 (tree type, tree op0) cases. */ tree -build_fold_indirect_ref (tree t) +build_fold_indirect_ref_loc (location_t loc, tree t) { tree type = TREE_TYPE (TREE_TYPE (t)); - tree sub = fold_indirect_ref_1 (type, t); + tree sub = fold_indirect_ref_1 (loc, type, t); if (sub) return sub; - else - return build1 (INDIRECT_REF, type, t); + + t = build1 (INDIRECT_REF, type, t); + SET_EXPR_LOCATION (t, loc); + return t; } /* Given an INDIRECT_REF T, return either T or a simplified version. */ tree -fold_indirect_ref (tree t) +fold_indirect_ref_loc (location_t loc, tree t) { - tree sub = fold_indirect_ref_1 (TREE_TYPE (t), TREE_OPERAND (t, 0)); + tree sub = fold_indirect_ref_1 (loc, TREE_TYPE (t), TREE_OPERAND (t, 0)); if (sub) return sub; @@ -15750,7 +16116,7 @@ fold_ignored_result (tree t) This can only be applied to objects of a sizetype. */ tree -round_up (tree value, int divisor) +round_up_loc (location_t loc, tree value, int divisor) { tree div = NULL_TREE; @@ -15801,17 +16167,17 @@ round_up (tree value, int divisor) tree t; t = build_int_cst (TREE_TYPE (value), divisor - 1); - value = size_binop (PLUS_EXPR, value, t); + value = size_binop_loc (loc, PLUS_EXPR, value, t); t = build_int_cst (TREE_TYPE (value), -divisor); - value = size_binop (BIT_AND_EXPR, value, t); + value = size_binop_loc (loc, BIT_AND_EXPR, value, t); } } else { if (!div) div = build_int_cst (TREE_TYPE (value), divisor); - value = size_binop (CEIL_DIV_EXPR, value, div); - value = size_binop (MULT_EXPR, value, div); + value = size_binop_loc (loc, CEIL_DIV_EXPR, value, div); + value = size_binop_loc (loc, MULT_EXPR, value, div); } return value; @@ -15820,7 +16186,7 @@ round_up (tree value, int divisor) /* Likewise, but round down. */ tree -round_down (tree value, int divisor) +round_down_loc (location_t loc, tree value, int divisor) { tree div = NULL_TREE; @@ -15846,14 +16212,14 @@ round_down (tree value, int divisor) tree t; t = build_int_cst (TREE_TYPE (value), -divisor); - value = size_binop (BIT_AND_EXPR, value, t); + value = size_binop_loc (loc, BIT_AND_EXPR, value, t); } else { if (!div) div = build_int_cst (TREE_TYPE (value), divisor); - value = size_binop (FLOOR_DIV_EXPR, value, div); - value = size_binop (MULT_EXPR, value, div); + value = size_binop_loc (loc, FLOOR_DIV_EXPR, value, div); + value = size_binop_loc (loc, MULT_EXPR, value, div); } return value; @@ -15871,13 +16237,14 @@ split_address_to_core_and_offset (tree exp, enum machine_mode mode; int unsignedp, volatilep; HOST_WIDE_INT bitsize; + location_t loc = EXPR_LOCATION (exp); if (TREE_CODE (exp) == ADDR_EXPR) { core = get_inner_reference (TREE_OPERAND (exp, 0), &bitsize, pbitpos, poffset, &mode, &unsignedp, &volatilep, false); - core = build_fold_addr_expr (core); + core = build_fold_addr_expr_loc (loc, core); } else { @@ -15940,6 +16307,7 @@ tree fold_strip_sign_ops (tree exp) { tree arg0, arg1; + location_t loc = EXPR_LOCATION (exp); switch (TREE_CODE (exp)) { @@ -15955,7 +16323,7 @@ fold_strip_sign_ops (tree exp) arg0 = fold_strip_sign_ops (TREE_OPERAND (exp, 0)); arg1 = fold_strip_sign_ops (TREE_OPERAND (exp, 1)); if (arg0 != NULL_TREE || arg1 != NULL_TREE) - return fold_build2 (TREE_CODE (exp), TREE_TYPE (exp), + return fold_build2_loc (loc, TREE_CODE (exp), TREE_TYPE (exp), arg0 ? arg0 : TREE_OPERAND (exp, 0), arg1 ? arg1 : TREE_OPERAND (exp, 1)); break; @@ -15964,14 +16332,15 @@ fold_strip_sign_ops (tree exp) arg0 = TREE_OPERAND (exp, 0); arg1 = fold_strip_sign_ops (TREE_OPERAND (exp, 1)); if (arg1) - return fold_build2 (COMPOUND_EXPR, TREE_TYPE (exp), arg0, arg1); + return fold_build2_loc (loc, COMPOUND_EXPR, TREE_TYPE (exp), arg0, arg1); break; case COND_EXPR: arg0 = fold_strip_sign_ops (TREE_OPERAND (exp, 1)); arg1 = fold_strip_sign_ops (TREE_OPERAND (exp, 2)); if (arg0 || arg1) - return fold_build3 (COND_EXPR, TREE_TYPE (exp), TREE_OPERAND (exp, 0), + return fold_build3_loc (loc, + COND_EXPR, TREE_TYPE (exp), TREE_OPERAND (exp, 0), arg0 ? arg0 : TREE_OPERAND (exp, 1), arg1 ? arg1 : TREE_OPERAND (exp, 2)); break; @@ -15985,7 +16354,7 @@ fold_strip_sign_ops (tree exp) /* Strip copysign function call, return the 1st argument. */ arg0 = CALL_EXPR_ARG (exp, 0); arg1 = CALL_EXPR_ARG (exp, 1); - return omit_one_operand (TREE_TYPE (exp), arg0, arg1); + return omit_one_operand_loc (loc, TREE_TYPE (exp), arg0, arg1); default: /* Strip sign ops from the argument of "odd" math functions. */ @@ -15993,7 +16362,7 @@ fold_strip_sign_ops (tree exp) { arg0 = fold_strip_sign_ops (CALL_EXPR_ARG (exp, 0)); if (arg0) - return build_call_expr (get_callee_fndecl (exp), 1, arg0); + return build_call_expr_loc (loc, get_callee_fndecl (exp), 1, arg0); } break; } diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index aaf2c882dc1..fcf194abc60 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,42 @@ +2009-07-19 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/40727 + * fortran/check.c (gfc_check_cmplx, gfc_check_dcmplx): Add check that + the optional second argument isn't of COMPLEX type. + +2009-07-17 Richard Guenther <rguenther@suse.de> + + PR c/40401 + * f95-lang.c (gfc_be_parse_file): Do not finalize the CU here. + * trans-decl.c (gfc_gimplify_function): Remove. + (build_entry_thunks): Do not gimplify here. + (create_main_function): Likewise. + (gfc_generate_function_code): Likewise. + +2009-07-17 Aldy Hernandez <aldyh@redhat.com> + Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR 40435 + * trans-expr.c, trans-array.c, trans-openmp.c, trans-stmt.c, + trans.c, trans-io.c, trans-decl.c, trans-intrinsic.c: Add location + argument to fold_{unary,binary,ternary}, fold_build[123], + build_call_expr, build_size_arg, build_fold_addr_expr, + build_call_array, non_lvalue, size_diffop, + fold_build1_initializer, fold_build2_initializer, + fold_build3_initializer, fold_build_call_array, + fold_build_call_array_initializer, fold_single_bit_test, + omit_one_operand, omit_two_operands, invert_truthvalue, + fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, + combine_comparisons, fold_builtin_*, fold_call_expr, + build_range_check, maybe_fold_offset_to_address, round_up, + round_down. + +2009-07-15 Janus Weil <janus@gcc.gnu.org> + + PR fortran/40743 + * resolve.c (resolve_symbol): Don't resolve the formal namespace of a + contained procedure. + 2009-07-14 Taras Glek <tglek@mozilla.com> Rafael Espindola <espindola@google.com> diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 8f949d2c093..e19f8124f09 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -819,6 +819,15 @@ gfc_check_cmplx (gfc_expr *x, gfc_expr *y, gfc_expr *kind) gfc_current_intrinsic, &y->where); return FAILURE; } + + if (y->ts.type == BT_COMPLEX) + { + gfc_error ("'%s' argument of '%s' intrinsic at %L must have a type " + "of either REAL or INTEGER", gfc_current_intrinsic_arg[1], + gfc_current_intrinsic, &y->where); + return FAILURE; + } + } if (kind_check (kind, 2, BT_COMPLEX) == FAILURE) @@ -977,6 +986,14 @@ gfc_check_dcmplx (gfc_expr *x, gfc_expr *y) gfc_current_intrinsic, &y->where); return FAILURE; } + + if (y->ts.type == BT_COMPLEX) + { + gfc_error ("'%s' argument of '%s' intrinsic at %L must have a type " + "of either REAL or INTEGER", gfc_current_intrinsic_arg[1], + gfc_current_intrinsic, &y->where); + return FAILURE; + } } return SUCCESS; diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index 97a071d06f9..f9d1878d379 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -241,9 +241,6 @@ gfc_be_parse_file (int set_yydebug ATTRIBUTE_UNUSED) gfc_parse_file (); gfc_generate_constructors (); - cgraph_finalize_compilation_unit (); - cgraph_optimize (); - /* Tell the frontend about any errors. */ gfc_get_errors (&warnings, &errors); errorcount += errors; diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 880dfd0e886..5b4fc2d6949 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -9842,7 +9842,8 @@ resolve_symbol (gfc_symbol *sym) formal_arg_flag = 0; /* Resolve formal namespaces. */ - if (sym->formal_ns && sym->formal_ns != gfc_current_ns) + if (sym->formal_ns && sym->formal_ns != gfc_current_ns + && !sym->attr.contained) gfc_resolve (sym->formal_ns); /* Make sure the formal namespace is present. */ diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 32858a7abcd..270835556ba 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -620,11 +620,13 @@ gfc_trans_allocate_array_storage (stmtblock_t * pre, stmtblock_t * post, gcc_assert (tmp == gfc_get_element_type (TREE_TYPE (desc))); packed = gfc_create_var (build_pointer_type (tmp), "data"); - tmp = build_call_expr (gfor_fndecl_in_pack, 1, initial); + tmp = build_call_expr_loc (input_location, + gfor_fndecl_in_pack, 1, initial); tmp = fold_convert (TREE_TYPE (packed), tmp); gfc_add_modify (pre, packed, tmp); - tmp = build_fold_indirect_ref (initial); + tmp = build_fold_indirect_ref_loc (input_location, + initial); source_data = gfc_conv_descriptor_data_get (tmp); /* internal_pack may return source->data without any allocation @@ -1084,7 +1086,8 @@ gfc_trans_array_ctor_element (stmtblock_t * pblock, tree desc, gfc_conv_expr (se, expr); /* Store the value. */ - tmp = build_fold_indirect_ref (gfc_conv_descriptor_data_get (desc)); + tmp = build_fold_indirect_ref_loc (input_location, + gfc_conv_descriptor_data_get (desc)); tmp = gfc_build_array_ref (tmp, offset, NULL); if (expr->ts.type == BT_CHARACTER) @@ -1353,14 +1356,16 @@ gfc_trans_array_constructor_value (stmtblock_t * pblock, tree type, /* Use BUILTIN_MEMCPY to assign the values. */ tmp = gfc_conv_descriptor_data_get (desc); - tmp = build_fold_indirect_ref (tmp); + tmp = build_fold_indirect_ref_loc (input_location, + tmp); tmp = gfc_build_array_ref (tmp, *poffset, NULL); tmp = gfc_build_addr_expr (NULL_TREE, tmp); init = gfc_build_addr_expr (NULL_TREE, init); size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)); bound = build_int_cst (NULL_TREE, n * size); - tmp = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3, + tmp = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMCPY], 3, tmp, init, bound); gfc_add_expr_to_block (&body, tmp); @@ -2408,7 +2413,8 @@ gfc_conv_array_index_offset (gfc_se * se, gfc_ss_info * info, int dim, int i, index, gfc_conv_array_stride (desc, 0)); /* Read the vector to get an index into info->descriptor. */ - data = build_fold_indirect_ref (gfc_conv_array_data (desc)); + data = build_fold_indirect_ref_loc (input_location, + gfc_conv_array_data (desc)); index = gfc_build_array_ref (data, index, NULL); index = gfc_evaluate_now (index, &se->pre); @@ -2482,7 +2488,8 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar) if (se->ss->expr && is_subref_array (se->ss->expr)) decl = se->ss->expr->symtree->n.sym->backend_decl; - tmp = build_fold_indirect_ref (info->data); + tmp = build_fold_indirect_ref_loc (input_location, + info->data); se->expr = gfc_build_array_ref (tmp, index, decl); } @@ -4461,7 +4468,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) type = TREE_TYPE (tmpdesc); gcc_assert (GFC_ARRAY_TYPE_P (type)); dumdesc = GFC_DECL_SAVED_DESCRIPTOR (tmpdesc); - dumdesc = build_fold_indirect_ref (dumdesc); + dumdesc = build_fold_indirect_ref_loc (input_location, + dumdesc); gfc_start_block (&block); if (sym->ts.type == BT_CHARACTER @@ -4513,7 +4521,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) gcc_assert (integer_onep (GFC_TYPE_ARRAY_STRIDE (type, 0))); /* A library call to repack the array if necessary. */ tmp = GFC_DECL_SAVED_DESCRIPTOR (tmpdesc); - stmt_unpacked = build_call_expr (gfor_fndecl_in_pack, 1, tmp); + stmt_unpacked = build_call_expr_loc (input_location, + gfor_fndecl_in_pack, 1, tmp); stride = gfc_index_one_node; @@ -4699,7 +4708,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) if (sym->attr.intent != INTENT_IN) { /* Copy the data back. */ - tmp = build_call_expr (gfor_fndecl_in_unpack, 2, dumdesc, tmpdesc); + tmp = build_call_expr_loc (input_location, + gfor_fndecl_in_unpack, 2, dumdesc, tmpdesc); gfc_add_expr_to_block (&cleanup, tmp); } @@ -4710,7 +4720,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) stmt = gfc_finish_block (&cleanup); /* Only do the cleanup if the array was repacked. */ - tmp = build_fold_indirect_ref (dumdesc); + tmp = build_fold_indirect_ref_loc (input_location, + dumdesc); tmp = gfc_conv_descriptor_data_get (tmp); tmp = fold_build2 (NE_EXPR, boolean_type_node, tmp, tmpdesc); stmt = build3_v (COND_EXPR, tmp, stmt, build_empty_stmt (input_location)); @@ -4753,7 +4764,8 @@ gfc_get_dataptr_offset (stmtblock_t *block, tree parm, tree desc, tree offset, } tmp = gfc_conv_array_data (desc); - tmp = build_fold_indirect_ref (tmp); + tmp = build_fold_indirect_ref_loc (input_location, + tmp); tmp = gfc_build_array_ref (tmp, offset, NULL); /* Offset the data pointer for pointer assignments from arrays with @@ -5178,7 +5190,8 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss) { gfc_conv_expr (&rse, expr); if (POINTER_TYPE_P (TREE_TYPE (rse.expr))) - rse.expr = build_fold_indirect_ref (rse.expr); + rse.expr = build_fold_indirect_ref_loc (input_location, + rse.expr); } else gfc_conv_expr_val (&rse, expr); @@ -5408,7 +5421,8 @@ array_parameter_size (tree desc, gfc_expr *expr, tree *size) if (GFC_ARRAY_TYPE_P (TREE_TYPE (desc))) *size = GFC_TYPE_ARRAY_SIZE (TREE_TYPE (desc)); else if (expr->rank > 1) - *size = build_call_expr (gfor_fndecl_size0, 1, + *size = build_call_expr_loc (input_location, + gfor_fndecl_size0, 1, gfc_build_addr_expr (NULL, desc)); else { @@ -5509,7 +5523,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, if (g77 && TREE_TYPE (TREE_TYPE (se->expr)) != NULL_TREE && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (TREE_TYPE (se->expr)))) - se->expr = gfc_conv_array_data (build_fold_indirect_ref (se->expr)); + se->expr = gfc_conv_array_data (build_fold_indirect_ref_loc (input_location, + se->expr)); return; } @@ -5519,7 +5534,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, se->want_pointer = 1; gfc_conv_expr_descriptor (se, expr, ss); if (size) - array_parameter_size (build_fold_indirect_ref (se->expr), + array_parameter_size (build_fold_indirect_ref_loc (input_location, + se->expr), expr, size); } @@ -5529,7 +5545,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, && expr->ts.derived->attr.alloc_comp && expr->expr_type != EXPR_VARIABLE) { - tmp = build_fold_indirect_ref (se->expr); + tmp = build_fold_indirect_ref_loc (input_location, + se->expr); tmp = gfc_deallocate_alloc_comp (expr->ts.derived, tmp, expr->rank); gfc_add_expr_to_block (&se->post, tmp); } @@ -5548,7 +5565,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, gfc_warning ("Creating array temporary at %L", &expr->where); } - ptr = build_call_expr (gfor_fndecl_in_pack, 1, desc); + ptr = build_call_expr_loc (input_location, + gfor_fndecl_in_pack, 1, desc); if (fsym && fsym->attr.optional && sym && sym->attr.optional) { @@ -5572,7 +5590,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, else asprintf (&msg, "An array temporary was created"); - tmp = build_fold_indirect_ref (desc); + tmp = build_fold_indirect_ref_loc (input_location, + desc); tmp = gfc_conv_array_data (tmp); tmp = fold_build2 (NE_EXPR, boolean_type_node, fold_convert (TREE_TYPE (tmp), ptr), tmp); @@ -5591,7 +5610,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, /* Copy the data back. */ if (fsym == NULL || fsym->attr.intent != INTENT_IN) { - tmp = build_call_expr (gfor_fndecl_in_unpack, 2, desc, ptr); + tmp = build_call_expr_loc (input_location, + gfor_fndecl_in_unpack, 2, desc, ptr); gfc_add_expr_to_block (&block, tmp); } @@ -5604,7 +5624,8 @@ gfc_conv_array_parameter (gfc_se * se, gfc_expr * expr, gfc_ss * ss, int g77, gfc_init_block (&block); /* Only if it was repacked. This code needs to be executed before the loop cleanup code. */ - tmp = build_fold_indirect_ref (desc); + tmp = build_fold_indirect_ref_loc (input_location, + desc); tmp = gfc_conv_array_data (tmp); tmp = fold_build2 (NE_EXPR, boolean_type_node, fold_convert (TREE_TYPE (tmp), ptr), tmp); @@ -5707,7 +5728,8 @@ gfc_duplicate_allocatable(tree dest, tree src, tree type, int rank) /* We know the temporary and the value will be the same length, so can use memcpy. */ tmp = built_in_decls[BUILT_IN_MEMCPY]; - tmp = build_call_expr (tmp, 3, gfc_conv_descriptor_data_get (dest), + tmp = build_call_expr_loc (input_location, + tmp, 3, gfc_conv_descriptor_data_get (dest), gfc_conv_descriptor_data_get (src), size); gfc_add_expr_to_block (&block, tmp); tmp = gfc_finish_block (&block); @@ -5750,7 +5772,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, gfc_init_block (&fnblock); if (POINTER_TYPE_P (TREE_TYPE (decl))) - decl = build_fold_indirect_ref (decl); + decl = build_fold_indirect_ref_loc (input_location, + decl); /* If this an array of derived types with allocatable components build a loop and recursively call this function. */ @@ -5758,7 +5781,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, || GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl))) { tmp = gfc_conv_array_data (decl); - var = build_fold_indirect_ref (tmp); + var = build_fold_indirect_ref_loc (input_location, + tmp); /* Get the number of elements - 1 and set the counter. */ if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl))) @@ -5797,7 +5821,8 @@ structure_alloc_comps (gfc_symbol * der_type, tree decl, tmp = gfc_duplicate_allocatable (dest, decl, TREE_TYPE(decl), rank); gfc_add_expr_to_block (&fnblock, tmp); } - tmp = build_fold_indirect_ref (gfc_conv_array_data (dest)); + tmp = build_fold_indirect_ref_loc (input_location, + gfc_conv_array_data (dest)); dref = gfc_build_array_ref (tmp, index, NULL); tmp = structure_alloc_comps (der_type, vref, dref, rank, purpose); } @@ -6022,7 +6047,8 @@ gfc_trans_deferred_array (gfc_symbol * sym, tree body) { /* If the backend_decl is not a descriptor, we must have a pointer to one. */ - descriptor = build_fold_indirect_ref (sym->backend_decl); + descriptor = build_fold_indirect_ref_loc (input_location, + sym->backend_decl); type = TREE_TYPE (descriptor); } diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 0d6dc6de975..5133888fa13 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -408,7 +408,8 @@ gfc_finish_cray_pointee (tree decl, gfc_symbol *sym) /* Parameters need to be dereferenced. */ if (sym->cp_pointer->attr.dummy) - ptr_decl = build_fold_indirect_ref (ptr_decl); + ptr_decl = build_fold_indirect_ref_loc (input_location, + ptr_decl); /* Check to see if we're dealing with a variable-sized array. */ if (sym->attr.dimension @@ -422,7 +423,8 @@ gfc_finish_cray_pointee (tree decl, gfc_symbol *sym) { ptr_decl = convert (build_pointer_type (TREE_TYPE (decl)), ptr_decl); - value = build_fold_indirect_ref (ptr_decl); + value = build_fold_indirect_ref_loc (input_location, + ptr_decl); } SET_DECL_VALUE_EXPR (decl, value); @@ -1837,30 +1839,6 @@ create_function_arglist (gfc_symbol * sym) DECL_ARGUMENTS (fndecl) = arglist; } -/* Convert FNDECL's code to GIMPLE and handle any nested functions. */ - -static void -gfc_gimplify_function (tree fndecl) -{ - struct cgraph_node *cgn; - - gimplify_function_tree (fndecl); - dump_function (TDI_generic, fndecl); - - /* Generate errors for structured block violations. */ - /* ??? Could be done as part of resolve_labels. */ - if (flag_openmp) - diagnose_omp_structured_block_errors (fndecl); - - /* Convert all nested functions to GIMPLE now. We do things in this order - so that items like VLA sizes are expanded properly in the context of the - correct function. */ - cgn = cgraph_node (fndecl); - for (cgn = cgn->nested; cgn; cgn = cgn->next_nested) - gfc_gimplify_function (cgn->decl); -} - - /* Do the setup necessary before generating the body of a function. */ static void @@ -1991,7 +1969,7 @@ build_entry_thunks (gfc_namespace * ns) args = nreverse (args); args = chainon (args, nreverse (string_args)); tmp = ns->proc_name->backend_decl; - tmp = build_function_call_expr (tmp, args); + tmp = build_function_call_expr (input_location, tmp, args); if (ns->proc_name->attr.mixed_entry_master) { tree union_decl, field; @@ -2058,7 +2036,6 @@ build_entry_thunks (gfc_namespace * ns) current_function_decl = NULL_TREE; - gfc_gimplify_function (thunk_fndecl); cgraph_finalize_function (thunk_fndecl, false); /* We share the symbols in the formal argument list with other entry @@ -4012,7 +3989,8 @@ create_main_function (tree fndecl) /* Call _gfortran_set_args (argc, argv). */ TREE_USED (argc) = 1; TREE_USED (argv) = 1; - tmp = build_call_expr (gfor_fndecl_set_args, 2, argc, argv); + tmp = build_call_expr_loc (input_location, + gfor_fndecl_set_args, 2, argc, argv); gfc_add_expr_to_block (&body, tmp); /* Add a call to set_options to set up the runtime library Fortran @@ -4060,7 +4038,8 @@ create_main_function (tree fndecl) DECL_INITIAL (var) = array; var = gfc_build_addr_expr (build_pointer_type (integer_type_node), var); - tmp = build_call_expr (gfor_fndecl_set_options, 2, + tmp = build_call_expr_loc (input_location, + gfor_fndecl_set_options, 2, build_int_cst (integer_type_node, 8), var); gfc_add_expr_to_block (&body, tmp); } @@ -4069,7 +4048,8 @@ create_main_function (tree fndecl) the library will raise a FPE when needed. */ if (gfc_option.fpe != 0) { - tmp = build_call_expr (gfor_fndecl_set_fpe, 1, + tmp = build_call_expr_loc (input_location, + gfor_fndecl_set_fpe, 1, build_int_cst (integer_type_node, gfc_option.fpe)); gfc_add_expr_to_block (&body, tmp); @@ -4080,7 +4060,8 @@ create_main_function (tree fndecl) if (gfc_option.convert != GFC_CONVERT_NATIVE) { - tmp = build_call_expr (gfor_fndecl_set_convert, 1, + tmp = build_call_expr_loc (input_location, + gfor_fndecl_set_convert, 1, build_int_cst (integer_type_node, gfc_option.convert)); gfc_add_expr_to_block (&body, tmp); @@ -4091,7 +4072,8 @@ create_main_function (tree fndecl) if (gfc_option.record_marker != 0) { - tmp = build_call_expr (gfor_fndecl_set_record_marker, 1, + tmp = build_call_expr_loc (input_location, + gfor_fndecl_set_record_marker, 1, build_int_cst (integer_type_node, gfc_option.record_marker)); gfc_add_expr_to_block (&body, tmp); @@ -4099,14 +4081,16 @@ create_main_function (tree fndecl) if (gfc_option.max_subrecord_length != 0) { - tmp = build_call_expr (gfor_fndecl_set_max_subrecord_length, 1, + tmp = build_call_expr_loc (input_location, + gfor_fndecl_set_max_subrecord_length, 1, build_int_cst (integer_type_node, gfc_option.max_subrecord_length)); gfc_add_expr_to_block (&body, tmp); } /* Call MAIN__(). */ - tmp = build_call_expr (fndecl, 0); + tmp = build_call_expr_loc (input_location, + fndecl, 0); gfc_add_expr_to_block (&body, tmp); /* Mark MAIN__ as used. */ @@ -4133,7 +4117,6 @@ create_main_function (tree fndecl) /* Output the GENERIC tree. */ dump_function (TDI_original, ftn_main); - gfc_gimplify_function (ftn_main); cgraph_finalize_function (ftn_main, false); if (old_context) @@ -4405,10 +4388,7 @@ gfc_generate_function_code (gfc_namespace * ns) added to our parent's nested function list. */ (void) cgraph_node (fndecl); else - { - gfc_gimplify_function (fndecl); - cgraph_finalize_function (fndecl, false); - } + cgraph_finalize_function (fndecl, false); gfc_trans_use_stmts (ns); gfc_traverse_ns (ns, gfc_emit_parameter_debug_info); @@ -4461,7 +4441,8 @@ gfc_generate_constructors (void) for (; gfc_static_ctors; gfc_static_ctors = TREE_CHAIN (gfc_static_ctors)) { - tmp = build_call_expr (TREE_VALUE (gfc_static_ctors), 0); + tmp = build_call_expr_loc (input_location, + TREE_VALUE (gfc_static_ctors), 0); DECL_SAVED_TREE (fndecl) = build_stmt (input_location, EXPR_STMT, tmp); } diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 787251d7627..03902420e04 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -158,7 +158,8 @@ gfc_conv_missing_dummy (gfc_se * se, gfc_expr * arg, gfc_typespec ts, int kind) { /* Create a temporary and convert it to the correct type. */ tmp = gfc_get_int_type (kind); - tmp = fold_convert (tmp, build_fold_indirect_ref (se->expr)); + tmp = fold_convert (tmp, build_fold_indirect_ref_loc (input_location, + se->expr)); /* Test for a NULL value. */ tmp = build3 (COND_EXPR, TREE_TYPE (tmp), present, tmp, @@ -381,7 +382,8 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind, if (TYPE_STRING_FLAG (TREE_TYPE (se->expr))) tmp = se->expr; else - tmp = build_fold_indirect_ref (se->expr); + tmp = build_fold_indirect_ref_loc (input_location, + se->expr); tmp = gfc_build_array_ref (tmp, start.expr, NULL); se->expr = gfc_build_addr_expr (type, tmp); } @@ -478,7 +480,8 @@ gfc_conv_component_ref (gfc_se * se, gfc_ref * ref) if ((c->attr.pointer && c->attr.dimension == 0 && c->ts.type != BT_CHARACTER) || c->attr.proc_pointer) - se->expr = build_fold_indirect_ref (se->expr); + se->expr = build_fold_indirect_ref_loc (input_location, + se->expr); } @@ -621,21 +624,24 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr) && (sym->attr.dummy || sym->attr.function || sym->attr.result)) - se->expr = build_fold_indirect_ref (se->expr); + se->expr = build_fold_indirect_ref_loc (input_location, + se->expr); } else if (!sym->attr.value) { /* Dereference non-character scalar dummy arguments. */ if (sym->attr.dummy && !sym->attr.dimension) - se->expr = build_fold_indirect_ref (se->expr); + se->expr = build_fold_indirect_ref_loc (input_location, + se->expr); /* Dereference scalar hidden result. */ if (gfc_option.flag_f2c && sym->ts.type == BT_COMPLEX && (sym->attr.function || sym->attr.result) && !sym->attr.dimension && !sym->attr.pointer && !sym->attr.always_explicit) - se->expr = build_fold_indirect_ref (se->expr); + se->expr = build_fold_indirect_ref_loc (input_location, + se->expr); /* Dereference non-character pointer variables. These must be dummies, results, or scalars. */ @@ -644,7 +650,8 @@ gfc_conv_variable (gfc_se * se, gfc_expr * expr) || sym->attr.function || sym->attr.result || !sym->attr.dimension)) - se->expr = build_fold_indirect_ref (se->expr); + se->expr = build_fold_indirect_ref_loc (input_location, + se->expr); } ref = expr->ref; @@ -1080,7 +1087,8 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr) break; } - se->expr = build_call_expr (fndecl, 2, lse.expr, rse.expr); + se->expr = build_call_expr_loc (input_location, + fndecl, 2, lse.expr, rse.expr); } @@ -1171,7 +1179,8 @@ gfc_conv_concat_op (gfc_se * se, gfc_expr * expr) else gcc_unreachable (); - tmp = build_call_expr (fndecl, 6, len, var, lse.string_length, lse.expr, + tmp = build_call_expr_loc (input_location, + fndecl, 6, len, var, lse.string_length, lse.expr, rse.string_length, rse.expr); gfc_add_expr_to_block (&se->pre, tmp); @@ -1378,7 +1387,8 @@ string_to_single_character (tree len, tree str, int kind) && TREE_INT_CST_HIGH (len) == 0) { str = fold_convert (gfc_get_pchar_type (kind), str); - return build_fold_indirect_ref (str); + return build_fold_indirect_ref_loc (input_location, + str); } return NULL_TREE; @@ -1481,7 +1491,8 @@ gfc_build_compare_string (tree len1, tree str1, tree len2, tree str2, int kind) else gcc_unreachable (); - tmp = build_call_expr (fndecl, 4, len1, str1, len2, str2); + tmp = build_call_expr_loc (input_location, + fndecl, 4, len1, str1, len2, str2); } return tmp; @@ -1498,7 +1509,8 @@ conv_function_val (gfc_se * se, gfc_symbol * sym, gfc_expr * expr) { tmp = gfc_get_symbol_decl (sym); if (sym->attr.proc_pointer) - tmp = build_fold_indirect_ref (tmp); + tmp = build_fold_indirect_ref_loc (input_location, + tmp); gcc_assert (TREE_CODE (TREE_TYPE (tmp)) == POINTER_TYPE && TREE_CODE (TREE_TYPE (TREE_TYPE (tmp))) == FUNCTION_TYPE); } @@ -1738,7 +1750,8 @@ gfc_add_interface_mapping (gfc_interface_mapping * mapping, tmp = gfc_get_character_type_len (sym->ts.kind, NULL); tmp = build_pointer_type (tmp); if (sym->attr.pointer) - value = build_fold_indirect_ref (se->expr); + value = build_fold_indirect_ref_loc (input_location, + se->expr); else value = se->expr; value = fold_convert (tmp, value); @@ -1747,11 +1760,13 @@ gfc_add_interface_mapping (gfc_interface_mapping * mapping, /* If the argument is a scalar, a pointer to an array or an allocatable, dereference it. */ else if (!sym->attr.dimension || sym->attr.pointer || sym->attr.allocatable) - value = build_fold_indirect_ref (se->expr); + value = build_fold_indirect_ref_loc (input_location, + se->expr); /* For character(*), use the actual argument's descriptor. */ else if (sym->ts.type == BT_CHARACTER && !new_sym->ts.cl->length) - value = build_fold_indirect_ref (se->expr); + value = build_fold_indirect_ref_loc (input_location, + se->expr); /* If the argument is an array descriptor, use it to determine information about the actual argument's shape. */ @@ -1759,7 +1774,8 @@ gfc_add_interface_mapping (gfc_interface_mapping * mapping, && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (TREE_TYPE (se->expr)))) { /* Get the actual argument's descriptor. */ - desc = build_fold_indirect_ref (se->expr); + desc = build_fold_indirect_ref_loc (input_location, + se->expr); /* Create the replacement variable. */ tmp = gfc_conv_descriptor_data_get (desc); @@ -2294,7 +2310,8 @@ gfc_conv_subref_array_arg (gfc_se * parmse, gfc_expr * expr, rse.loop->loopvar[0], offset); /* Now use the offset for the reference. */ - tmp = build_fold_indirect_ref (info->data); + tmp = build_fold_indirect_ref_loc (input_location, + info->data); rse.expr = gfc_build_array_ref (tmp, tmp_index, NULL); if (expr->ts.type == BT_CHARACTER) @@ -2703,7 +2720,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, if (fsym && fsym->attr.allocatable && fsym->attr.intent == INTENT_OUT) { - tmp = build_fold_indirect_ref (parmse.expr); + tmp = build_fold_indirect_ref_loc (input_location, + parmse.expr); tmp = gfc_trans_dealloc_allocated (tmp); gfc_add_expr_to_block (&se->pre, tmp); } @@ -2757,7 +2775,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, && (e->expr_type != EXPR_VARIABLE && !e->rank)) { int parm_rank; - tmp = build_fold_indirect_ref (parmse.expr); + tmp = build_fold_indirect_ref_loc (input_location, + parmse.expr); parm_rank = e->rank; switch (parm_kind) { @@ -2767,7 +2786,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, break; case (SCALAR_POINTER): - tmp = build_fold_indirect_ref (tmp); + tmp = build_fold_indirect_ref_loc (input_location, + tmp); break; } @@ -2948,7 +2968,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, && TREE_TYPE (TREE_TYPE (TREE_TYPE (se->expr))) && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (TREE_TYPE (TREE_TYPE (se->expr))))) - se->expr = build_fold_indirect_ref (se->expr); + se->expr = build_fold_indirect_ref_loc (input_location, + se->expr); retargs = gfc_chainon_list (retargs, se->expr); } @@ -3076,7 +3097,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, where f is pointer valued, we have to dereference the result. */ if (!se->want_pointer && !byref && sym->attr.pointer && !gfc_is_proc_ptr_comp (expr, NULL)) - se->expr = build_fold_indirect_ref (se->expr); + se->expr = build_fold_indirect_ref_loc (input_location, + se->expr); /* f2c calling conventions require a scalar default real function to return a double precision result. Convert this back to default @@ -3123,7 +3145,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, { /* Dereference for character pointer results. */ if (sym->attr.pointer || sym->attr.allocatable) - se->expr = build_fold_indirect_ref (var); + se->expr = build_fold_indirect_ref_loc (input_location, + var); else se->expr = var; @@ -3132,7 +3155,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, else { gcc_assert (sym->ts.type == BT_COMPLEX && gfc_option.flag_f2c); - se->expr = build_fold_indirect_ref (var); + se->expr = build_fold_indirect_ref_loc (input_location, + var); } } } @@ -3157,7 +3181,8 @@ fill_with_spaces (tree start, tree type, tree size) /* For a simple char type, we can call memset(). */ if (compare_tree_int (TYPE_SIZE_UNIT (type), 1) == 0) - return build_call_expr (built_in_decls[BUILT_IN_MEMSET], 3, start, + return build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMSET], 3, start, build_int_cst (gfc_get_int_type (gfc_c_int_kind), lang_hooks.to_target_charset (' ')), size); @@ -3318,11 +3343,13 @@ gfc_trans_string_copy (stmtblock_t * block, tree dlength, tree dest, /* Truncate string if source is too long. */ cond2 = fold_build2 (GE_EXPR, boolean_type_node, slen, dlen); - tmp2 = build_call_expr (built_in_decls[BUILT_IN_MEMMOVE], + tmp2 = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMMOVE], 3, dest, src, dlen); /* Else copy and pad with spaces. */ - tmp3 = build_call_expr (built_in_decls[BUILT_IN_MEMMOVE], + tmp3 = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMMOVE], 3, dest, src, slen); tmp4 = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (dest), dest, @@ -3465,7 +3492,7 @@ gfc_get_proc_ptr_comp (gfc_se *se, gfc_expr *e) e2 = gfc_copy_expr (e); e2->expr_type = EXPR_VARIABLE; gfc_conv_expr (&comp_se, e2); - comp_se.expr = build_fold_addr_expr (comp_se.expr); + comp_se.expr = build_fold_addr_expr_loc (input_location, comp_se.expr); return gfc_evaluate_now (comp_se.expr, &se->pre); } @@ -4192,11 +4219,13 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2) if (expr1->symtree->n.sym->attr.proc_pointer && expr1->symtree->n.sym->attr.dummy) - lse.expr = build_fold_indirect_ref (lse.expr); + lse.expr = build_fold_indirect_ref_loc (input_location, + lse.expr); if (expr2->symtree && expr2->symtree->n.sym->attr.proc_pointer && expr2->symtree->n.sym->attr.dummy) - rse.expr = build_fold_indirect_ref (rse.expr); + rse.expr = build_fold_indirect_ref_loc (input_location, + rse.expr); gfc_add_block_to_block (&block, &lse.pre); gfc_add_block_to_block (&block, &rse.pre); @@ -4594,7 +4623,8 @@ gfc_trans_zero_assign (gfc_expr * expr) len = fold_convert (size_type_node, len); /* Construct call to __builtin_memset. */ - tmp = build_call_expr (built_in_decls[BUILT_IN_MEMSET], + tmp = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMSET], 3, dest, integer_zero_node, len); return fold_convert (void_type_node, tmp); } @@ -4622,7 +4652,8 @@ gfc_build_memcpy_call (tree dst, tree src, tree len) len = fold_convert (size_type_node, len); /* Construct call to __builtin_memcpy. */ - tmp = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3, dst, src, len); + tmp = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMCPY], 3, dst, src, len); return fold_convert (void_type_node, tmp); } diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 89b98ec7279..bf8768e0572 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -273,7 +273,8 @@ gfc_conv_intrinsic_conversion (gfc_se * se, gfc_expr * expr) /* Call the library function that will perform the conversion. */ gcc_assert (nargs >= 2); - tmp = build_call_expr (fndecl, 3, addr, args[0], args[1]); + tmp = build_call_expr_loc (input_location, + fndecl, 3, addr, args[0], args[1]); gfc_add_expr_to_block (&se->pre, tmp); /* Free the temporary afterwards. */ @@ -363,7 +364,8 @@ build_round_expr (tree arg, tree restype) else gcc_unreachable (); - return fold_convert (restype, build_call_expr (fn, 1, arg)); + return fold_convert (restype, build_call_expr_loc (input_location, + fn, 1, arg)); } @@ -475,7 +477,8 @@ gfc_conv_intrinsic_aint (gfc_se * se, gfc_expr * expr, enum rounding_mode op) if (n != END_BUILTINS) { tmp = built_in_decls[n]; - se->expr = build_call_expr (tmp, 1, arg[0]); + se->expr = build_call_expr_loc (input_location, + tmp, 1, arg[0]); return; } @@ -745,7 +748,7 @@ gfc_conv_intrinsic_lib_function (gfc_se * se, gfc_expr * expr) rettype = TREE_TYPE (TREE_TYPE (fndecl)); fndecl = build_addr (fndecl, current_function_decl); - se->expr = build_call_array (rettype, fndecl, num_args, args); + se->expr = build_call_array_loc (input_location, rettype, fndecl, num_args, args); } @@ -808,7 +811,8 @@ gfc_conv_intrinsic_exponent (gfc_se *se, gfc_expr *expr) gfc_conv_intrinsic_function_args (se, expr, &arg, 1); res = gfc_create_var (integer_type_node, NULL); - tmp = build_call_expr (built_in_decls[frexp], 2, arg, + tmp = build_call_expr_loc (input_location, + built_in_decls[frexp], 2, arg, gfc_build_addr_expr (NULL_TREE, res)); gfc_add_expr_to_block (&se->pre, tmp); @@ -1054,7 +1058,8 @@ gfc_conv_intrinsic_abs (gfc_se * se, gfc_expr * expr) default: gcc_unreachable (); } - se->expr = build_call_expr (built_in_decls[n], 1, arg); + se->expr = build_call_expr_loc (input_location, + built_in_decls[n], 1, arg); break; default: @@ -1150,7 +1155,8 @@ gfc_conv_intrinsic_mod (gfc_se * se, gfc_expr * expr, int modulo) if (n != END_BUILTINS) { tmp = build_addr (built_in_decls[n], current_function_decl); - se->expr = build_call_array (TREE_TYPE (TREE_TYPE (built_in_decls[n])), + se->expr = build_call_array_loc (input_location, + TREE_TYPE (TREE_TYPE (built_in_decls[n])), tmp, 2, args); if (modulo == 0) return; @@ -1297,7 +1303,8 @@ gfc_conv_intrinsic_sign (gfc_se * se, gfc_expr * expr) build_call_expr (tmp, 2, args[0], args[1])); } else - se->expr = build_call_expr (tmp, 2, args[0], args[1]); + se->expr = build_call_expr_loc (input_location, + tmp, 2, args[0], args[1]); return; } @@ -1400,7 +1407,8 @@ gfc_conv_intrinsic_ctime (gfc_se * se, gfc_expr * expr) args[1] = gfc_build_addr_expr (NULL_TREE, len); fndecl = build_addr (gfor_fndecl_ctime, current_function_decl); - tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_ctime)), + tmp = build_call_array_loc (input_location, + TREE_TYPE (TREE_TYPE (gfor_fndecl_ctime)), fndecl, num_args, args); gfc_add_expr_to_block (&se->pre, tmp); @@ -1438,7 +1446,8 @@ gfc_conv_intrinsic_fdate (gfc_se * se, gfc_expr * expr) args[1] = gfc_build_addr_expr (NULL_TREE, len); fndecl = build_addr (gfor_fndecl_fdate, current_function_decl); - tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_fdate)), + tmp = build_call_array_loc (input_location, + TREE_TYPE (TREE_TYPE (gfor_fndecl_fdate)), fndecl, num_args, args); gfc_add_expr_to_block (&se->pre, tmp); @@ -1478,7 +1487,8 @@ gfc_conv_intrinsic_ttynam (gfc_se * se, gfc_expr * expr) args[1] = gfc_build_addr_expr (NULL_TREE, len); fndecl = build_addr (gfor_fndecl_ttynam, current_function_decl); - tmp = build_call_array (TREE_TYPE (TREE_TYPE (gfor_fndecl_ttynam)), + tmp = build_call_array_loc (input_location, + TREE_TYPE (TREE_TYPE (gfor_fndecl_ttynam)), fndecl, num_args, args); gfc_add_expr_to_block (&se->pre, tmp); @@ -1546,9 +1556,10 @@ gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, enum tree_code op) if (argexpr->expr->expr_type == EXPR_VARIABLE && argexpr->expr->symtree->n.sym->attr.optional && TREE_CODE (val) == INDIRECT_REF) - cond = fold_build2 - (NE_EXPR, boolean_type_node, TREE_OPERAND (val, 0), - build_int_cst (TREE_TYPE (TREE_OPERAND (val, 0)), 0)); + cond = fold_build2_loc (input_location, + NE_EXPR, boolean_type_node, + TREE_OPERAND (val, 0), + build_int_cst (TREE_TYPE (TREE_OPERAND (val, 0)), 0)); else { cond = NULL_TREE; @@ -1567,7 +1578,8 @@ gfc_conv_intrinsic_minmax (gfc_se * se, gfc_expr * expr, enum tree_code op) to help performance of programs that don't rely on IEEE semantics. */ if (FLOAT_TYPE_P (TREE_TYPE (mvar))) { - isnan = build_call_expr (built_in_decls[BUILT_IN_ISNAN], 1, mvar); + isnan = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_ISNAN], 1, mvar); tmp = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, tmp, fold_convert (boolean_type_node, isnan)); } @@ -1615,7 +1627,8 @@ gfc_conv_intrinsic_minmax_char (gfc_se * se, gfc_expr * expr, int op) /* Make the function call. */ fndecl = build_addr (function, current_function_decl); - tmp = build_call_array (TREE_TYPE (TREE_TYPE (function)), fndecl, + tmp = build_call_array_loc (input_location, + TREE_TYPE (TREE_TYPE (function)), fndecl, nargs + 4, args); gfc_add_expr_to_block (&se->pre, tmp); @@ -2692,7 +2705,8 @@ gfc_conv_intrinsic_ishftc (gfc_se * se, gfc_expr * expr) default: gcc_unreachable (); } - se->expr = build_call_expr (tmp, 3, args[0], args[1], args[2]); + se->expr = build_call_expr_loc (input_location, + tmp, 3, args[0], args[1], args[2]); /* Convert the result back to the original type, if we extended the first argument's width above. */ if (expr->ts.kind < 4) @@ -2840,7 +2854,8 @@ gfc_conv_intrinsic_trailz (gfc_se * se, gfc_expr *expr) result_type = gfc_get_int_type (gfc_default_integer_kind); /* Compute TRAILZ for the case i .ne. 0. */ - trailz = fold_convert (result_type, build_call_expr (func, 1, arg)); + trailz = fold_convert (result_type, build_call_expr_loc (input_location, + func, 1, arg)); /* Build BIT_SIZE. */ bit_size = build_int_cst (result_type, argsize); @@ -2991,7 +3006,8 @@ gfc_conv_intrinsic_len_trim (gfc_se * se, gfc_expr * expr) else gcc_unreachable (); - se->expr = build_call_expr (fndecl, 2, args[0], args[1]); + se->expr = build_call_expr_loc (input_location, + fndecl, 2, args[0], args[1]); se->expr = convert (type, se->expr); } @@ -3027,7 +3043,8 @@ gfc_conv_intrinsic_index_scan_verify (gfc_se * se, gfc_expr * expr, args[4] = convert (logical4_type_node, args[4]); fndecl = build_addr (function, current_function_decl); - se->expr = build_call_array (TREE_TYPE (TREE_TYPE (function)), fndecl, + se->expr = build_call_array_loc (input_location, + TREE_TYPE (TREE_TYPE (function)), fndecl, 5, args); se->expr = convert (type, se->expr); @@ -3045,7 +3062,8 @@ gfc_conv_intrinsic_ichar (gfc_se * se, gfc_expr * expr) args[1] = fold_build1 (NOP_EXPR, pchartype, args[1]); type = gfc_typenode_for_spec (&expr->ts); - se->expr = build_fold_indirect_ref (args[1]); + se->expr = build_fold_indirect_ref_loc (input_location, + args[1]); se->expr = convert (type, se->expr); } @@ -3058,7 +3076,8 @@ gfc_conv_intrinsic_isnan (gfc_se * se, gfc_expr * expr) tree arg; gfc_conv_intrinsic_function_args (se, expr, &arg, 1); - se->expr = build_call_expr (built_in_decls[BUILT_IN_ISNAN], 1, arg); + se->expr = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_ISNAN], 1, arg); STRIP_TYPE_NOPS (se->expr); se->expr = fold_convert (gfc_typenode_for_spec (&expr->ts), se->expr); } @@ -3149,7 +3168,8 @@ gfc_conv_intrinsic_fraction (gfc_se * se, gfc_expr * expr) type = gfc_typenode_for_spec (&expr->ts); gfc_conv_intrinsic_function_args (se, expr, &arg, 1); tmp = gfc_create_var (integer_type_node, NULL); - se->expr = build_call_expr (built_in_decls[frexp], 2, + se->expr = build_call_expr_loc (input_location, + built_in_decls[frexp], 2, fold_convert (type, arg), gfc_build_addr_expr (NULL_TREE, tmp)); se->expr = fold_convert (type, se->expr); @@ -3190,10 +3210,13 @@ gfc_conv_intrinsic_nearest (gfc_se * se, gfc_expr * expr) type = gfc_typenode_for_spec (&expr->ts); gfc_conv_intrinsic_function_args (se, expr, args, 2); - tmp = build_call_expr (built_in_decls[copysign], 2, - build_call_expr (built_in_decls[huge_val], 0), + tmp = build_call_expr_loc (input_location, + built_in_decls[copysign], 2, + build_call_expr_loc (input_location, + built_in_decls[huge_val], 0), fold_convert (type, args[1])); - se->expr = build_call_expr (built_in_decls[nextafter], 2, + se->expr = build_call_expr_loc (input_location, + built_in_decls[nextafter], 2, fold_convert (type, args[0]), tmp); se->expr = fold_convert (type, se->expr); } @@ -3258,15 +3281,17 @@ gfc_conv_intrinsic_spacing (gfc_se * se, gfc_expr * expr) /* Build the block for s /= 0. */ gfc_start_block (&block); - tmp = build_call_expr (built_in_decls[frexp], 2, arg, + tmp = build_call_expr_loc (input_location, + built_in_decls[frexp], 2, arg, gfc_build_addr_expr (NULL_TREE, e)); gfc_add_expr_to_block (&block, tmp); tmp = fold_build2 (MINUS_EXPR, integer_type_node, e, prec); gfc_add_modify (&block, e, fold_build2 (MAX_EXPR, integer_type_node, - tmp, emin)); + tmp, emin)); - tmp = build_call_expr (built_in_decls[scalbn], 2, + tmp = build_call_expr_loc (input_location, + built_in_decls[scalbn], 2, build_real_from_int_cst (type, integer_one_node), e); gfc_add_modify (&block, res, tmp); @@ -3332,17 +3357,20 @@ gfc_conv_intrinsic_rrspacing (gfc_se * se, gfc_expr * expr) e = gfc_create_var (integer_type_node, NULL); x = gfc_create_var (type, NULL); gfc_add_modify (&se->pre, x, - build_call_expr (built_in_decls[fabs], 1, arg)); + build_call_expr_loc (input_location, + built_in_decls[fabs], 1, arg)); gfc_start_block (&block); - tmp = build_call_expr (built_in_decls[frexp], 2, arg, + tmp = build_call_expr_loc (input_location, + built_in_decls[frexp], 2, arg, gfc_build_addr_expr (NULL_TREE, e)); gfc_add_expr_to_block (&block, tmp); tmp = fold_build2 (MINUS_EXPR, integer_type_node, build_int_cst (NULL_TREE, prec), e); - tmp = build_call_expr (built_in_decls[scalbn], 2, x, tmp); + tmp = build_call_expr_loc (input_location, + built_in_decls[scalbn], 2, x, tmp); gfc_add_modify (&block, x, tmp); stmt = gfc_finish_block (&block); @@ -3380,7 +3408,8 @@ gfc_conv_intrinsic_scale (gfc_se * se, gfc_expr * expr) type = gfc_typenode_for_spec (&expr->ts); gfc_conv_intrinsic_function_args (se, expr, args, 2); - se->expr = build_call_expr (built_in_decls[scalbn], 2, + se->expr = build_call_expr_loc (input_location, + built_in_decls[scalbn], 2, fold_convert (type, args[0]), fold_convert (integer_type_node, args[1])); se->expr = fold_convert (type, se->expr); @@ -3418,10 +3447,12 @@ gfc_conv_intrinsic_set_exponent (gfc_se * se, gfc_expr * expr) gfc_conv_intrinsic_function_args (se, expr, args, 2); tmp = gfc_create_var (integer_type_node, NULL); - tmp = build_call_expr (built_in_decls[frexp], 2, + tmp = build_call_expr_loc (input_location, + built_in_decls[frexp], 2, fold_convert (type, args[0]), gfc_build_addr_expr (NULL_TREE, tmp)); - se->expr = build_call_expr (built_in_decls[scalbn], 2, tmp, + se->expr = build_call_expr_loc (input_location, + built_in_decls[scalbn], 2, tmp, fold_convert (integer_type_node, args[1])); se->expr = fold_convert (type, se->expr); } @@ -3451,7 +3482,8 @@ gfc_conv_intrinsic_size (gfc_se * se, gfc_expr * expr) arg1 = gfc_evaluate_now (argse.expr, &se->pre); /* Build the call to size0. */ - fncall0 = build_call_expr (gfor_fndecl_size0, 1, arg1); + fncall0 = build_call_expr_loc (input_location, + gfor_fndecl_size0, 1, arg1); actual = actual->next; @@ -3470,7 +3502,8 @@ gfc_conv_intrinsic_size (gfc_se * se, gfc_expr * expr) { tree tmp; /* Build the call to size1. */ - fncall1 = build_call_expr (gfor_fndecl_size1, 2, + fncall1 = build_call_expr_loc (input_location, + gfor_fndecl_size1, 2, arg1, argse.expr); gfc_init_se (&argse, NULL); @@ -3503,7 +3536,8 @@ gfc_conv_intrinsic_size (gfc_se * se, gfc_expr * expr) { tree ubound, lbound; - arg1 = build_fold_indirect_ref (arg1); + arg1 = build_fold_indirect_ref_loc (input_location, + arg1); ubound = gfc_conv_descriptor_ubound_get (arg1, argse.expr); lbound = gfc_conv_descriptor_lbound_get (arg1, argse.expr); se->expr = fold_build2 (MINUS_EXPR, gfc_array_index_type, @@ -3561,7 +3595,8 @@ gfc_conv_intrinsic_sizeof (gfc_se *se, gfc_expr *expr) gfc_conv_expr_reference (&argse, arg); source = argse.expr; - type = TREE_TYPE (build_fold_indirect_ref (argse.expr)); + type = TREE_TYPE (build_fold_indirect_ref_loc (input_location, + argse.expr)); /* Obtain the source word length. */ if (arg->ts.type == BT_CHARACTER) @@ -3641,7 +3676,8 @@ gfc_conv_intrinsic_adjust (gfc_se * se, gfc_expr * expr, tree fndecl) var = gfc_conv_string_tmp (se, type, len); args[0] = var; - tmp = build_call_expr (fndecl, 3, args[0], args[1], args[2]); + tmp = build_call_expr_loc (input_location, + fndecl, 3, args[0], args[1], args[2]); gfc_add_expr_to_block (&se->pre, tmp); se->expr = var; se->string_length = len; @@ -3719,7 +3755,8 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr) gfc_conv_expr_reference (&argse, arg->expr); source = argse.expr; - source_type = TREE_TYPE (build_fold_indirect_ref (argse.expr)); + source_type = TREE_TYPE (build_fold_indirect_ref_loc (input_location, + argse.expr)); /* Obtain the source word length. */ if (arg->expr->ts.type == BT_CHARACTER) @@ -3745,7 +3782,8 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr) if (gfc_option.warn_array_temp) gfc_warning ("Creating array temporary at %L", &expr->where); - source = build_call_expr (gfor_fndecl_in_pack, 1, tmp); + source = build_call_expr_loc (input_location, + gfor_fndecl_in_pack, 1, tmp); source = gfc_evaluate_now (source, &argse.pre); /* Free the temporary. */ @@ -3811,7 +3849,8 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr) if (ss == gfc_ss_terminator) { gfc_conv_expr_reference (&argse, arg->expr); - mold_type = TREE_TYPE (build_fold_indirect_ref (argse.expr)); + mold_type = TREE_TYPE (build_fold_indirect_ref_loc (input_location, + argse.expr)); } else { @@ -3853,7 +3892,8 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr) gfc_init_se (&argse, NULL); gfc_conv_expr_reference (&argse, arg->expr); tmp = convert (gfc_array_index_type, - build_fold_indirect_ref (argse.expr)); + build_fold_indirect_ref_loc (input_location, + argse.expr)); gfc_add_block_to_block (&se->pre, &argse.pre); gfc_add_block_to_block (&se->post, &argse.post); } @@ -3918,7 +3958,8 @@ gfc_conv_intrinsic_transfer (gfc_se * se, gfc_expr * expr) tmp = fold_convert (pvoid_type_node, tmp); /* Use memcpy to do the transfer. */ - tmp = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], + tmp = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMCPY], 3, tmp, fold_convert (pvoid_type_node, source), @@ -3959,7 +4000,8 @@ scalar_transfer: tmp = gfc_call_malloc (&block, tmp, dest_word_len); gfc_add_modify (&block, tmpdecl, fold_convert (TREE_TYPE (ptr), tmp)); - tmp = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3, + tmp = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMCPY], 3, fold_convert (pvoid_type_node, tmpdecl), fold_convert (pvoid_type_node, ptr), extent); @@ -3983,7 +4025,8 @@ scalar_transfer: /* Use memcpy to do the transfer. */ tmp = gfc_build_addr_expr (NULL_TREE, tmpdecl); - tmp = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3, + tmp = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMCPY], 3, fold_convert (pvoid_type_node, tmp), fold_convert (pvoid_type_node, ptr), extent); @@ -4113,7 +4156,8 @@ gfc_conv_associated (gfc_se *se, gfc_expr *expr) gfc_conv_expr_descriptor (&arg2se, arg2->expr, ss2); gfc_add_block_to_block (&se->pre, &arg2se.pre); gfc_add_block_to_block (&se->post, &arg2se.post); - se->expr = build_call_expr (gfor_fndecl_associated, 2, + se->expr = build_call_expr_loc (input_location, + gfor_fndecl_associated, 2, arg1se.expr, arg2se.expr); se->expr = convert (boolean_type_node, se->expr); se->expr = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, @@ -4139,7 +4183,8 @@ gfc_conv_intrinsic_sc_kind (gfc_se *se, gfc_expr *expr) tree args[2]; gfc_conv_intrinsic_function_args (se, expr, args, 2); - se->expr = build_call_expr (gfor_fndecl_sc_kind, 2, args[0], args[1]); + se->expr = build_call_expr_loc (input_location, + gfor_fndecl_sc_kind, 2, args[0], args[1]); se->expr = fold_convert (gfc_typenode_for_spec (&expr->ts), se->expr); } @@ -4159,7 +4204,8 @@ gfc_conv_intrinsic_si_kind (gfc_se *se, gfc_expr *expr) /* Convert it to the required type. */ type = gfc_typenode_for_spec (&expr->ts); - se->expr = build_call_expr (gfor_fndecl_si_kind, 1, arg); + se->expr = build_call_expr_loc (input_location, + gfor_fndecl_si_kind, 1, arg); se->expr = fold_convert (type, se->expr); } @@ -4203,7 +4249,8 @@ gfc_conv_intrinsic_sr_kind (gfc_se *se, gfc_expr *expr) /* Convert it to the required type. */ type = gfc_typenode_for_spec (&expr->ts); - se->expr = build_function_call_expr (gfor_fndecl_sr_kind, args); + se->expr = build_function_call_expr (input_location, + gfor_fndecl_sr_kind, args); se->expr = fold_convert (type, se->expr); } @@ -4242,7 +4289,8 @@ gfc_conv_intrinsic_trim (gfc_se * se, gfc_expr * expr) gcc_unreachable (); fndecl = build_addr (function, current_function_decl); - tmp = build_call_array (TREE_TYPE (TREE_TYPE (function)), fndecl, + tmp = build_call_array_loc (input_location, + TREE_TYPE (TREE_TYPE (function)), fndecl, num_args, args); gfc_add_expr_to_block (&se->pre, tmp); @@ -4353,7 +4401,8 @@ gfc_conv_intrinsic_repeat (gfc_se * se, gfc_expr * expr) tmp = fold_build2 (POINTER_PLUS_EXPR, pvoid_type_node, fold_convert (pvoid_type_node, dest), fold_convert (sizetype, tmp)); - tmp = build_call_expr (built_in_decls[BUILT_IN_MEMMOVE], 3, tmp, src, + tmp = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMMOVE], 3, tmp, src, fold_build2 (MULT_EXPR, size_type_node, slen, fold_convert (size_type_node, size))); gfc_add_expr_to_block (&body, tmp); @@ -4392,7 +4441,8 @@ gfc_conv_intrinsic_iargc (gfc_se * se, gfc_expr * expr) /* Call the library function. This always returns an INTEGER(4). */ fndecl = gfor_fndecl_iargc; - tmp = build_call_expr (fndecl, 0); + tmp = build_call_expr_loc (input_location, + fndecl, 0); /* Convert it to the required type. */ type = gfc_typenode_for_spec (&expr->ts); diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c index 5263a67b754..35f87bc3e56 100644 --- a/gcc/fortran/trans-io.c +++ b/gcc/fortran/trans-io.c @@ -246,7 +246,8 @@ gfc_trans_io_runtime_check (tree cond, tree var, int error_code, gfc_build_localized_cstring_const (message)); gfc_free(message); - tmp = build_call_expr (gfor_fndecl_generate_error, 3, arg1, arg2, arg3); + tmp = build_call_expr_loc (input_location, + gfor_fndecl_generate_error, 3, arg1, arg2, arg3); gfc_add_expr_to_block (&block, tmp); @@ -261,7 +262,8 @@ gfc_trans_io_runtime_check (tree cond, tree var, int error_code, /* Tell the compiler that this isn't likely. */ cond = fold_convert (long_integer_type_node, cond); tmp = build_int_cst (long_integer_type_node, 0); - cond = build_call_expr (built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp); + cond = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp); cond = fold_convert (boolean_type_node, cond); tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt (input_location)); @@ -740,7 +742,8 @@ set_internal_unit (stmtblock_t * block, stmtblock_t * post_block, or substring array references. */ gfc_conv_subref_array_arg (&se, e, 0, last_dt == READ ? INTENT_IN : INTENT_OUT); - tmp = build_fold_indirect_ref (se.expr); + tmp = build_fold_indirect_ref_loc (input_location, + se.expr); se.expr = gfc_build_addr_expr (pchar_type_node, tmp); tmp = gfc_conv_descriptor_data_get (tmp); } @@ -964,7 +967,8 @@ gfc_trans_open (gfc_code * code) set_parameter_const (&block, var, IOPARM_common_unit, 0); tmp = gfc_build_addr_expr (NULL_TREE, var); - tmp = build_call_expr (iocall[IOCALL_OPEN], 1, tmp); + tmp = build_call_expr_loc (input_location, + iocall[IOCALL_OPEN], 1, tmp); gfc_add_expr_to_block (&block, tmp); gfc_add_block_to_block (&block, &post_block); @@ -1016,7 +1020,8 @@ gfc_trans_close (gfc_code * code) set_parameter_const (&block, var, IOPARM_common_unit, 0); tmp = gfc_build_addr_expr (NULL_TREE, var); - tmp = build_call_expr (iocall[IOCALL_CLOSE], 1, tmp); + tmp = build_call_expr_loc (input_location, + iocall[IOCALL_CLOSE], 1, tmp); gfc_add_expr_to_block (&block, tmp); gfc_add_block_to_block (&block, &post_block); @@ -1066,7 +1071,8 @@ build_filepos (tree function, gfc_code * code) set_parameter_const (&block, var, IOPARM_common_unit, 0); tmp = gfc_build_addr_expr (NULL_TREE, var); - tmp = build_call_expr (function, 1, tmp); + tmp = build_call_expr_loc (input_location, + function, 1, tmp); gfc_add_expr_to_block (&block, tmp); gfc_add_block_to_block (&block, &post_block); @@ -1323,7 +1329,8 @@ gfc_trans_inquire (gfc_code * code) set_parameter_const (&block, var, IOPARM_common_unit, 0); tmp = gfc_build_addr_expr (NULL_TREE, var); - tmp = build_call_expr (iocall[IOCALL_INQUIRE], 1, tmp); + tmp = build_call_expr_loc (input_location, + iocall[IOCALL_INQUIRE], 1, tmp); gfc_add_expr_to_block (&block, tmp); gfc_add_block_to_block (&block, &post_block); @@ -1372,7 +1379,8 @@ gfc_trans_wait (gfc_code * code) set_parameter_value (&block, var, IOPARM_common_unit, p->unit); tmp = gfc_build_addr_expr (NULL_TREE, var); - tmp = build_call_expr (iocall[IOCALL_WAIT], 1, tmp); + tmp = build_call_expr_loc (input_location, + iocall[IOCALL_WAIT], 1, tmp); gfc_add_expr_to_block (&block, tmp); gfc_add_block_to_block (&block, &post_block); @@ -1458,7 +1466,8 @@ nml_get_addr_expr (gfc_symbol * sym, gfc_component * c, dummy_arg_flagged = POINTER_TYPE_P (TREE_TYPE(tmp)); - itmp = (dummy_arg_flagged) ? build_fold_indirect_ref (tmp) : tmp; + itmp = (dummy_arg_flagged) ? build_fold_indirect_ref_loc (input_location, + tmp) : tmp; /* If an array, set flag and use indirect ref. if built. */ @@ -1490,7 +1499,8 @@ nml_get_addr_expr (gfc_symbol * sym, gfc_component * c, /* If scalar dummy, resolve indirect reference now. */ if (dummy_arg_flagged && !array_flagged) - tmp = build_fold_indirect_ref (tmp); + tmp = build_fold_indirect_ref_loc (input_location, + tmp); gcc_assert (tmp && POINTER_TYPE_P (TREE_TYPE (tmp))); @@ -1584,7 +1594,8 @@ transfer_namelist_element (stmtblock_t * block, const char * var_name, tmp = ts->cl->backend_decl; else tmp = build_int_cst (gfc_charlen_type_node, 0); - tmp = build_call_expr (iocall[IOCALL_SET_NML_VAL], 6, + tmp = build_call_expr_loc (input_location, + iocall[IOCALL_SET_NML_VAL], 6, dt_parm_addr, addr_expr, string, IARG (ts->kind), tmp, dtype); gfc_add_expr_to_block (block, tmp); @@ -1594,7 +1605,8 @@ transfer_namelist_element (stmtblock_t * block, const char * var_name, for ( n_dim = 0 ; n_dim < rank ; n_dim++ ) { - tmp = build_call_expr (iocall[IOCALL_SET_NML_VAL_DIM], 5, + tmp = build_call_expr_loc (input_location, + iocall[IOCALL_SET_NML_VAL_DIM], 5, dt_parm_addr, IARG (n_dim), GFC_TYPE_ARRAY_STRIDE (dt, n_dim), @@ -1609,7 +1621,8 @@ transfer_namelist_element (stmtblock_t * block, const char * var_name, /* Provide the RECORD_TYPE to build component references. */ - tree expr = build_fold_indirect_ref (addr_expr); + tree expr = build_fold_indirect_ref_loc (input_location, + addr_expr); for (cmp = ts->derived->components; cmp; cmp = cmp->next) { @@ -1789,7 +1802,8 @@ build_dt (tree function, gfc_code * code) set_parameter_const (&block, var, IOPARM_common_flags, mask); tmp = gfc_build_addr_expr (NULL_TREE, var); - tmp = build_call_expr (function, 1, tmp); + tmp = build_call_expr_loc (input_location, + function, 1, tmp); gfc_add_expr_to_block (&block, tmp); gfc_add_block_to_block (&block, &post_block); @@ -1869,7 +1883,8 @@ gfc_trans_dt_end (gfc_code * code) } tmp = gfc_build_addr_expr (NULL_TREE, dt_parm); - tmp = build_call_expr (function, 1, tmp); + tmp = build_call_expr_loc (input_location, + function, 1, tmp); gfc_add_expr_to_block (&block, tmp); gfc_add_block_to_block (&block, dt_post_end_block); gfc_init_block (dt_post_end_block); @@ -2043,7 +2058,8 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code) arg2 = se->string_length; else { - tmp = build_fold_indirect_ref (addr_expr); + tmp = build_fold_indirect_ref_loc (input_location, + addr_expr); gcc_assert (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE); arg2 = TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (tmp))); arg2 = fold_convert (gfc_charlen_type_node, arg2); @@ -2051,7 +2067,8 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code) arg3 = build_int_cst (NULL_TREE, kind); function = iocall[IOCALL_X_CHARACTER_WIDE]; tmp = gfc_build_addr_expr (NULL_TREE, dt_parm); - tmp = build_call_expr (function, 4, tmp, addr_expr, arg2, arg3); + tmp = build_call_expr_loc (input_location, + function, 4, tmp, addr_expr, arg2, arg3); gfc_add_expr_to_block (&se->pre, tmp); gfc_add_block_to_block (&se->pre, &se->post); return; @@ -2062,7 +2079,8 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code) arg2 = se->string_length; else { - tmp = build_fold_indirect_ref (addr_expr); + tmp = build_fold_indirect_ref_loc (input_location, + addr_expr); gcc_assert (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE); arg2 = TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (tmp))); } @@ -2072,14 +2090,16 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code) case BT_DERIVED: /* Recurse into the elements of the derived type. */ expr = gfc_evaluate_now (addr_expr, &se->pre); - expr = build_fold_indirect_ref (expr); + expr = build_fold_indirect_ref_loc (input_location, + expr); for (c = ts->derived->components; c; c = c->next) { field = c->backend_decl; gcc_assert (field && TREE_CODE (field) == FIELD_DECL); - tmp = fold_build3 (COMPONENT_REF, TREE_TYPE (field), + tmp = fold_build3_loc (UNKNOWN_LOCATION, + COMPONENT_REF, TREE_TYPE (field), expr, field, NULL_TREE); if (c->attr.dimension) @@ -2101,7 +2121,8 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code) } tmp = gfc_build_addr_expr (NULL_TREE, dt_parm); - tmp = build_call_expr (function, 3, tmp, addr_expr, arg2); + tmp = build_call_expr_loc (input_location, + function, 3, tmp, addr_expr, arg2); gfc_add_expr_to_block (&se->pre, tmp); gfc_add_block_to_block (&se->pre, &se->post); @@ -2124,7 +2145,8 @@ transfer_array_desc (gfc_se * se, gfc_typespec * ts, tree addr_expr) kind_arg = build_int_cst (NULL_TREE, ts->kind); tmp = gfc_build_addr_expr (NULL_TREE, dt_parm); - tmp = build_call_expr (iocall[IOCALL_X_ARRAY], 4, + tmp = build_call_expr_loc (input_location, + iocall[IOCALL_X_ARRAY], 4, tmp, addr_expr, kind_arg, charlen_arg); gfc_add_expr_to_block (&se->pre, tmp); gfc_add_block_to_block (&se->pre, &se->post); diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index a476487a0a2..56534ccdd38 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -218,7 +218,8 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src) build_int_cst (pvoid_type_node, 0), size, NULL, NULL); gfc_conv_descriptor_data_set (&block, dest, ptr); - call = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3, ptr, + call = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMCPY], 3, ptr, fold_convert (pvoid_type_node, gfc_conv_descriptor_data_get (src)), size); @@ -255,7 +256,8 @@ gfc_omp_clause_assign_op (tree clause ATTRIBUTE_UNUSED, tree dest, tree src) TYPE_SIZE_UNIT (gfc_get_element_type (type))); size = fold_build2 (MULT_EXPR, gfc_array_index_type, size, esize); size = gfc_evaluate_now (fold_convert (size_type_node, size), &block); - call = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3, + call = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMCPY], 3, fold_convert (pvoid_type_node, gfc_conv_descriptor_data_get (dest)), fold_convert (pvoid_type_node, @@ -1084,7 +1086,8 @@ gfc_trans_omp_atomic (gfc_code *code) lhsaddr = save_expr (lhsaddr); rhs = gfc_evaluate_now (rse.expr, &block); - x = convert (TREE_TYPE (rhs), build_fold_indirect_ref (lhsaddr)); + x = convert (TREE_TYPE (rhs), build_fold_indirect_ref_loc (input_location, + lhsaddr)); if (var_on_left) x = fold_build2 (op, TREE_TYPE (rhs), x, rhs); @@ -1108,7 +1111,7 @@ static tree gfc_trans_omp_barrier (void) { tree decl = built_in_decls [BUILT_IN_GOMP_BARRIER]; - return build_call_expr (decl, 0); + return build_call_expr_loc (input_location, decl, 0); } static tree @@ -1357,7 +1360,7 @@ static tree gfc_trans_omp_flush (void) { tree decl = built_in_decls [BUILT_IN_SYNCHRONIZE]; - return build_call_expr (decl, 0); + return build_call_expr_loc (input_location, decl, 0); } static tree @@ -1541,7 +1544,7 @@ static tree gfc_trans_omp_taskwait (void) { tree decl = built_in_decls [BUILT_IN_GOMP_TASKWAIT]; - return build_call_expr (decl, 0); + return build_call_expr_loc (input_location, decl, 0); } static tree diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 0e8ce67c443..6a1fb01cc60 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -314,13 +314,14 @@ gfc_conv_elemental_dependencies (gfc_se * se, gfc_se * loopse, tmp = fold_build2 (MULT_EXPR, gfc_array_index_type, loopse->loop->from[n], tmp); offset = fold_build2 (MINUS_EXPR, gfc_array_index_type, - offset, tmp); + offset, tmp); } info->offset = gfc_create_var (gfc_array_index_type, NULL); gfc_add_modify (&se->pre, info->offset, offset); /* Copy the result back using unpack. */ - tmp = build_call_expr (gfor_fndecl_in_unpack, 2, parmse.expr, data); + tmp = build_call_expr_loc (input_location, + gfor_fndecl_in_unpack, 2, parmse.expr, data); gfc_add_expr_to_block (&se->post, tmp); /* parmse.pre is already added above. */ @@ -539,12 +540,14 @@ gfc_trans_pause (gfc_code * code) if (code->expr1 == NULL) { tmp = build_int_cst (gfc_int4_type_node, code->ext.stop_code); - tmp = build_call_expr (gfor_fndecl_pause_numeric, 1, tmp); + tmp = build_call_expr_loc (input_location, + gfor_fndecl_pause_numeric, 1, tmp); } else { gfc_conv_expr_reference (&se, code->expr1); - tmp = build_call_expr (gfor_fndecl_pause_string, 2, + tmp = build_call_expr_loc (input_location, + gfor_fndecl_pause_string, 2, se.expr, se.string_length); } @@ -574,12 +577,14 @@ gfc_trans_stop (gfc_code * code) if (code->expr1 == NULL) { tmp = build_int_cst (gfc_int4_type_node, code->ext.stop_code); - tmp = build_call_expr (gfor_fndecl_stop_numeric, 1, tmp); + tmp = build_call_expr_loc (input_location, + gfor_fndecl_stop_numeric, 1, tmp); } else { gfc_conv_expr_reference (&se, code->expr1); - tmp = build_call_expr (gfor_fndecl_stop_string, 2, + tmp = build_call_expr_loc (input_location, + gfor_fndecl_stop_string, 2, se.expr, se.string_length); } @@ -1614,7 +1619,8 @@ gfc_trans_character_select (gfc_code *code) else gcc_unreachable (); - tmp = build_call_expr (fndecl, 4, init, build_int_cst (NULL_TREE, n), + tmp = build_call_expr_loc (input_location, + fndecl, 4, init, build_int_cst (NULL_TREE, n), se.expr, se.string_length); case_num = gfc_create_var (integer_type_node, "case_num"); gfc_add_modify (&block, case_num, tmp); @@ -1741,7 +1747,7 @@ forall_make_variable_temp (gfc_code *c, stmtblock_t *pre, stmtblock_t *post) gfc_conv_subref_array_arg (&tse, e, 0, INTENT_IN); gfc_add_block_to_block (pre, &tse.pre); gfc_add_block_to_block (post, &tse.post); - tse.expr = build_fold_indirect_ref (tse.expr); + tse.expr = build_fold_indirect_ref_loc (input_location, tse.expr); if (e->ts.type != BT_CHARACTER) { @@ -2441,7 +2447,7 @@ allocate_temp_for_forall_nest_1 (tree type, tree size, stmtblock_t * block, tmp = gfc_do_allocate (bytesize, size, ptemp1, block, type); if (*ptemp1) - tmp = build_fold_indirect_ref (tmp); + tmp = build_fold_indirect_ref_loc (input_location, tmp); return tmp; } @@ -4020,7 +4026,7 @@ gfc_trans_allocate (gfc_code * code) if (expr->ts.type == BT_DERIVED && expr->ts.derived->attr.alloc_comp) { - tmp = build_fold_indirect_ref (se.expr); + tmp = build_fold_indirect_ref_loc (input_location, se.expr); tmp = gfc_nullify_alloc_comp (expr->ts.derived, tmp, 0); gfc_add_expr_to_block (&se.pre, tmp); } @@ -4063,7 +4069,8 @@ gfc_trans_allocate (gfc_code * code) dlen = gfc_get_expr_charlen (code->expr2); slen = fold_build2 (MIN_EXPR, TREE_TYPE (slen), dlen, slen); - dlen = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3, + dlen = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMCPY], 3, gfc_build_addr_expr (pvoid_type_node, se.expr), errmsg, slen); tmp = fold_build2 (NE_EXPR, boolean_type_node, stat, @@ -4197,7 +4204,8 @@ gfc_trans_deallocate (gfc_code *code) dlen = gfc_get_expr_charlen (code->expr2); slen = fold_build2 (MIN_EXPR, TREE_TYPE (slen), dlen, slen); - dlen = build_call_expr (built_in_decls[BUILT_IN_MEMCPY], 3, + dlen = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MEMCPY], 3, gfc_build_addr_expr (pvoid_type_node, se.expr), errmsg, slen); tmp = fold_build2 (NE_EXPR, boolean_type_node, astat, diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index 319ae69edcc..35a786aef29 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -339,7 +339,7 @@ gfc_build_array_ref (tree base, tree offset, tree decl) tmp, fold_convert (sizetype, offset)); tmp = fold_convert (build_pointer_type (type), tmp); if (!TYPE_STRING_FLAG (type)) - tmp = build_fold_indirect_ref (tmp); + tmp = build_fold_indirect_ref_loc (input_location, tmp); return tmp; } else @@ -413,13 +413,14 @@ gfc_trans_runtime_error_vararg (bool error, locus* where, const char* msgid, va_end (ap); /* Build the function call to runtime_(warning,error)_at; because of the - variable number of arguments, we can't use build_call_expr directly. */ + variable number of arguments, we can't use build_call_expr_loc dinput_location, + irectly. */ if (error) fntype = TREE_TYPE (gfor_fndecl_runtime_error_at); else fntype = TREE_TYPE (gfor_fndecl_runtime_warning_at); - tmp = fold_builtin_call_array (TREE_TYPE (fntype), + tmp = fold_builtin_call_array (input_location, TREE_TYPE (fntype), fold_build1 (ADDR_EXPR, build_pointer_type (fntype), error @@ -482,7 +483,8 @@ gfc_trans_runtime_check (bool error, bool once, tree cond, stmtblock_t * pblock, cond = fold_convert (long_integer_type_node, cond); tmp = build_int_cst (long_integer_type_node, 0); - cond = build_call_expr (built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp); + cond = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp); cond = fold_convert (boolean_type_node, cond); tmp = build3_v (COND_EXPR, cond, body, build_empty_stmt (input_location)); @@ -515,7 +517,8 @@ gfc_call_malloc (stmtblock_t * block, tree type, tree size) msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const ("Attempt to allocate a negative amount of memory.")); tmp = fold_build3 (COND_EXPR, void_type_node, negative, - build_call_expr (gfor_fndecl_runtime_error, 1, msg), + build_call_expr_loc (input_location, + gfor_fndecl_runtime_error, 1, msg), build_empty_stmt (input_location)); gfc_add_expr_to_block (block, tmp); @@ -526,14 +529,16 @@ gfc_call_malloc (stmtblock_t * block, tree type, tree size) build_int_cst (size_type_node, 1)); gfc_add_modify (&block2, res, - build_call_expr (built_in_decls[BUILT_IN_MALLOC], 1, + build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MALLOC], 1, size)); null_result = fold_build2 (EQ_EXPR, boolean_type_node, res, build_int_cst (pvoid_type_node, 0)); msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const ("Memory allocation failed")); tmp = fold_build3 (COND_EXPR, void_type_node, null_result, - build_call_expr (gfor_fndecl_os_error, 1, msg), + build_call_expr_loc (input_location, + gfor_fndecl_os_error, 1, msg), build_empty_stmt (input_location)); gfc_add_expr_to_block (&block2, tmp); malloc_result = gfc_finish_block (&block2); @@ -615,7 +620,8 @@ gfc_allocate_with_status (stmtblock_t * block, tree size, tree status) msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const ("Attempt to allocate negative amount of memory. " "Possible integer overflow")); - error = build_call_expr (gfor_fndecl_runtime_error, 1, msg); + error = build_call_expr_loc (input_location, + gfor_fndecl_runtime_error, 1, msg); if (status != NULL_TREE && !integer_zerop (status)) { @@ -624,7 +630,7 @@ gfc_allocate_with_status (stmtblock_t * block, tree size, tree status) gfc_start_block (&set_status_block); gfc_add_modify (&set_status_block, - fold_build1 (INDIRECT_REF, status_type, status), + fold_build1 (INDIRECT_REF, status_type, status), build_int_cst (status_type, LIBERROR_ALLOCATION)); gfc_add_modify (&set_status_block, res, build_int_cst (pvoid_type_node, 0)); @@ -638,14 +644,16 @@ gfc_allocate_with_status (stmtblock_t * block, tree size, tree status) /* The allocation itself. */ gfc_start_block (&alloc_block); gfc_add_modify (&alloc_block, res, - build_call_expr (built_in_decls[BUILT_IN_MALLOC], 1, + build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_MALLOC], 1, fold_build2 (MAX_EXPR, size_type_node, size, build_int_cst (size_type_node, 1)))); msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const ("Out of memory")); - tmp = build_call_expr (gfor_fndecl_os_error, 1, msg); + tmp = build_call_expr_loc (input_location, + gfor_fndecl_os_error, 1, msg); if (status != NULL_TREE && !integer_zerop (status)) { @@ -750,7 +758,8 @@ gfc_allocate_array_with_status (stmtblock_t * block, tree mem, tree size, stmtblock_t set_status_block; gfc_start_block (&set_status_block); - tmp = build_call_expr (built_in_decls[BUILT_IN_FREE], 1, + tmp = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_FREE], 1, fold_convert (pvoid_type_node, mem)); gfc_add_expr_to_block (&set_status_block, tmp); @@ -788,7 +797,8 @@ gfc_call_free (tree var) var = gfc_evaluate_now (var, &block); cond = fold_build2 (NE_EXPR, boolean_type_node, var, build_int_cst (pvoid_type_node, 0)); - call = build_call_expr (built_in_decls[BUILT_IN_FREE], 1, var); + call = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_FREE], 1, var); tmp = fold_build3 (COND_EXPR, void_type_node, cond, call, build_empty_stmt (input_location)); gfc_add_expr_to_block (&block, tmp); @@ -873,7 +883,8 @@ gfc_deallocate_with_status (tree pointer, tree status, bool can_fail, /* When POINTER is not NULL, we free it. */ gfc_start_block (&non_null); - tmp = build_call_expr (built_in_decls[BUILT_IN_FREE], 1, + tmp = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_FREE], 1, fold_convert (pvoid_type_node, pointer)); gfc_add_expr_to_block (&non_null, tmp); @@ -935,12 +946,14 @@ gfc_call_realloc (stmtblock_t * block, tree mem, tree size) msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const ("Attempt to allocate a negative amount of memory.")); tmp = fold_build3 (COND_EXPR, void_type_node, negative, - build_call_expr (gfor_fndecl_runtime_error, 1, msg), + build_call_expr_loc (input_location, + gfor_fndecl_runtime_error, 1, msg), build_empty_stmt (input_location)); gfc_add_expr_to_block (block, tmp); /* Call realloc and check the result. */ - tmp = build_call_expr (built_in_decls[BUILT_IN_REALLOC], 2, + tmp = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_REALLOC], 2, fold_convert (pvoid_type_node, mem), size); gfc_add_modify (block, res, fold_convert (type, tmp)); null_result = fold_build2 (EQ_EXPR, boolean_type_node, res, @@ -952,7 +965,8 @@ gfc_call_realloc (stmtblock_t * block, tree mem, tree size) msg = gfc_build_addr_expr (pchar_type_node, gfc_build_localized_cstring_const ("Out of memory")); tmp = fold_build3 (COND_EXPR, void_type_node, null_result, - build_call_expr (gfor_fndecl_os_error, 1, msg), + build_call_expr_loc (input_location, + gfor_fndecl_os_error, 1, msg), build_empty_stmt (input_location)); gfc_add_expr_to_block (block, tmp); diff --git a/gcc/gcc.c b/gcc/gcc.c index f1dcc42df73..5c028f986be 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1180,6 +1180,7 @@ static const struct option_map option_map[] = {"--library-directory", "-L", "a"}, {"--machine", "-m", "aj"}, {"--machine-", "-m", "*j"}, + {"--no-canonical-prefixes", "-no-canonical-prefixes", 0}, {"--no-integrated-cpp", "-no-integrated-cpp", 0}, {"--no-line-commands", "-P", 0}, {"--no-precompiled-includes", "-noprecomp", 0}, @@ -3370,6 +3371,9 @@ display_help (void) fputs (_(" -combine Pass multiple source files to compiler at once\n"), stdout); fputs (_(" -save-temps Do not delete intermediate files\n"), stdout); fputs (_(" -save-temps=<arg> Do not delete intermediate files\n"), stdout); + fputs (_("\ + -no-canonical-prefixes Do not canonicalize paths when building relative\n\ + prefixes to other gcc components\n"), stdout); fputs (_(" -pipe Use pipes rather than intermediate files\n"), stdout); fputs (_(" -time Time the execution of each subprocess\n"), stdout); fputs (_(" -specs=<file> Override built-in specs with the contents of <file>\n"), stdout); @@ -3462,6 +3466,8 @@ process_command (int argc, const char **argv) unsigned int j; #endif const char *tooldir_prefix; + char *(*get_relative_prefix) (const char *, const char *, + const char *) = NULL; GET_ENVIRONMENT (gcc_exec_prefix, "GCC_EXEC_PREFIX"); @@ -3557,6 +3563,32 @@ process_command (int argc, const char **argv) exit (status); } + /* Convert new-style -- options to old-style. */ + translate_options (&argc, + CONST_CAST2 (const char *const **, const char ***, + &argv)); + + /* Do language-specific adjustment/addition of flags. */ + lang_specific_driver (&argc, + CONST_CAST2 (const char *const **, const char ***, + &argv), + &added_libraries); + + /* Handle any -no-canonical-prefixes flag early, to assign the function + that builds relative prefixes. This function creates default search + paths that are needed later in normal option handling. */ + + for (i = 1; i < argc; i++) + { + if (! strcmp (argv[i], "-no-canonical-prefixes")) + { + get_relative_prefix = make_relative_prefix_ignore_links; + break; + } + } + if (! get_relative_prefix) + get_relative_prefix = make_relative_prefix; + /* Set up the default search paths. If there is no GCC_EXEC_PREFIX, see if we can create it from the pathname specified in argv[0]. */ @@ -3565,11 +3597,12 @@ process_command (int argc, const char **argv) /* FIXME: make_relative_prefix doesn't yet work for VMS. */ if (!gcc_exec_prefix) { - gcc_exec_prefix = make_relative_prefix (argv[0], standard_bindir_prefix, - standard_exec_prefix); - gcc_libexec_prefix = make_relative_prefix (argv[0], - standard_bindir_prefix, - standard_libexec_prefix); + gcc_exec_prefix = get_relative_prefix (argv[0], + standard_bindir_prefix, + standard_exec_prefix); + gcc_libexec_prefix = get_relative_prefix (argv[0], + standard_bindir_prefix, + standard_libexec_prefix); if (gcc_exec_prefix) xputenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL)); } @@ -3580,9 +3613,9 @@ process_command (int argc, const char **argv) / (which is ignored by make_relative_prefix), so append a program name. */ char *tmp_prefix = concat (gcc_exec_prefix, "gcc", NULL); - gcc_libexec_prefix = make_relative_prefix (tmp_prefix, - standard_exec_prefix, - standard_libexec_prefix); + gcc_libexec_prefix = get_relative_prefix (tmp_prefix, + standard_exec_prefix, + standard_libexec_prefix); /* The path is unrelocated, so fallback to the original setting. */ if (!gcc_libexec_prefix) @@ -3720,17 +3753,6 @@ process_command (int argc, const char **argv) } } - /* Convert new-style -- options to old-style. */ - translate_options (&argc, - CONST_CAST2 (const char *const **, const char ***, - &argv)); - - /* Do language-specific adjustment/addition of flags. */ - lang_specific_driver (&argc, - CONST_CAST2 (const char *const **, const char ***, - &argv), - &added_libraries); - /* Scan argv twice. Here, the first time, just count how many switches there will be in their vector, and how many input files in theirs. Here we also parse the switches that cc itself uses (e.g. -v). */ @@ -3958,6 +3980,9 @@ process_command (int argc, const char **argv) else fatal ("'%s' is an unknown -save-temps option", argv[i]); } + else if (strcmp (argv[i], "-no-canonical-prefixes") == 0) + /* Already handled as a special case, so ignored here. */ + ; else if (strcmp (argv[i], "-combine") == 0) { combine_flag = 1; @@ -4305,9 +4330,9 @@ process_command (int argc, const char **argv) ``make_relative_prefix'' is not compiled for VMS, so don't call it. */ if (target_system_root && gcc_exec_prefix) { - char *tmp_prefix = make_relative_prefix (argv[0], - standard_bindir_prefix, - target_system_root); + char *tmp_prefix = get_relative_prefix (argv[0], + standard_bindir_prefix, + target_system_root); if (tmp_prefix && access_check (tmp_prefix, F_OK) == 0) { target_system_root = tmp_prefix; @@ -4349,6 +4374,8 @@ process_command (int argc, const char **argv) ; else if (! strncmp (argv[i], "-Wp,", 4)) ; + else if (! strcmp (argv[i], "-no-canonical-prefixes")) + ; else if (! strcmp (argv[i], "-pass-exit-codes")) ; else if (! strcmp (argv[i], "-print-search-dirs")) diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c index e096c00dd21..8d7ead680ce 100644 --- a/gcc/gimple-low.c +++ b/gcc/gimple-low.c @@ -813,16 +813,16 @@ lower_builtin_setjmp (gimple_stmt_iterator *gsi) arg = build_addr (next_label, current_function_decl); t = implicit_built_in_decls[BUILT_IN_SETJMP_SETUP]; g = gimple_build_call (t, 2, gimple_call_arg (stmt, 0), arg); - gimple_set_location (g, gimple_location (stmt)); + gimple_set_location (g, loc); gimple_set_block (g, gimple_block (stmt)); gsi_insert_before (gsi, g, GSI_SAME_STMT); /* Build 'DEST = 0' and insert. */ if (dest) { - g = gimple_build_assign (dest, fold_convert (TREE_TYPE (dest), - integer_zero_node)); - gimple_set_location (g, gimple_location (stmt)); + g = gimple_build_assign (dest, fold_convert_loc (loc, TREE_TYPE (dest), + integer_zero_node)); + gimple_set_location (g, loc); gimple_set_block (g, gimple_block (stmt)); gsi_insert_before (gsi, g, GSI_SAME_STMT); } @@ -839,16 +839,16 @@ lower_builtin_setjmp (gimple_stmt_iterator *gsi) arg = build_addr (next_label, current_function_decl); t = implicit_built_in_decls[BUILT_IN_SETJMP_RECEIVER]; g = gimple_build_call (t, 1, arg); - gimple_set_location (g, gimple_location (stmt)); + gimple_set_location (g, loc); gimple_set_block (g, gimple_block (stmt)); gsi_insert_before (gsi, g, GSI_SAME_STMT); /* Build 'DEST = 1' and insert. */ if (dest) { - g = gimple_build_assign (dest, fold_convert (TREE_TYPE (dest), - integer_one_node)); - gimple_set_location (g, gimple_location (stmt)); + g = gimple_build_assign (dest, fold_convert_loc (loc, TREE_TYPE (dest), + integer_one_node)); + gimple_set_location (g, loc); gimple_set_block (g, gimple_block (stmt)); gsi_insert_before (gsi, g, GSI_SAME_STMT); } diff --git a/gcc/gimple.c b/gcc/gimple.c index 56108312431..aa30a2e31c0 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -487,6 +487,7 @@ void gimple_cond_get_ops_from_tree (tree cond, enum tree_code *code_p, tree *lhs_p, tree *rhs_p) { + location_t loc = EXPR_LOCATION (cond); gcc_assert (TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison || TREE_CODE (cond) == TRUTH_NOT_EXPR || is_gimple_min_invariant (cond) @@ -499,14 +500,14 @@ gimple_cond_get_ops_from_tree (tree cond, enum tree_code *code_p, { *code_p = EQ_EXPR; gcc_assert (*lhs_p && *rhs_p == NULL_TREE); - *rhs_p = fold_convert (TREE_TYPE (*lhs_p), integer_zero_node); + *rhs_p = fold_convert_loc (loc, TREE_TYPE (*lhs_p), integer_zero_node); } /* Canonicalize conditionals of the form 'if (VAL)' */ else if (TREE_CODE_CLASS (*code_p) != tcc_comparison) { *code_p = NE_EXPR; gcc_assert (*lhs_p && *rhs_p == NULL_TREE); - *rhs_p = fold_convert (TREE_TYPE (*lhs_p), integer_zero_node); + *rhs_p = fold_convert_loc (loc, TREE_TYPE (*lhs_p), integer_zero_node); } } @@ -1897,10 +1898,11 @@ gimple_set_bb (gimple stmt, basic_block bb) tree gimple_fold (const_gimple stmt) { + location_t loc = gimple_location (stmt); switch (gimple_code (stmt)) { case GIMPLE_COND: - return fold_binary (gimple_cond_code (stmt), + return fold_binary_loc (loc, gimple_cond_code (stmt), boolean_type_node, gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); @@ -1909,11 +1911,11 @@ gimple_fold (const_gimple stmt) switch (get_gimple_rhs_class (gimple_assign_rhs_code (stmt))) { case GIMPLE_UNARY_RHS: - return fold_unary (gimple_assign_rhs_code (stmt), + return fold_unary_loc (loc, gimple_assign_rhs_code (stmt), TREE_TYPE (gimple_assign_lhs (stmt)), gimple_assign_rhs1 (stmt)); case GIMPLE_BINARY_RHS: - return fold_binary (gimple_assign_rhs_code (stmt), + return fold_binary_loc (loc, gimple_assign_rhs_code (stmt), TREE_TYPE (gimple_assign_lhs (stmt)), gimple_assign_rhs1 (stmt), gimple_assign_rhs2 (stmt)); diff --git a/gcc/gimple.h b/gcc/gimple.h index 2010109bc4e..2f16c60538a 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -979,7 +979,6 @@ extern gimple_predicate rhs_predicate_for (tree); extern tree canonicalize_cond_expr_cond (tree); /* In omp-low.c. */ -extern void diagnose_omp_structured_block_errors (tree); extern tree omp_reduction_init (tree, tree); /* In tree-nested.c. */ @@ -1884,7 +1883,7 @@ gimple_call_set_fndecl (gimple gs, tree decl) { GIMPLE_CHECK (gs, GIMPLE_CALL); gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); - gimple_set_op (gs, 1, build_fold_addr_expr (decl)); + gimple_set_op (gs, 1, build_fold_addr_expr_loc (gimple_location (gs), decl)); } diff --git a/gcc/gimplify.c b/gcc/gimplify.c index b20c8ac3e5e..dc8d0c089a4 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. If not see #include "splay-tree.h" #include "vec.h" #include "gimple.h" +#include "tree-pass.h" enum gimplify_omp_var_data @@ -1786,6 +1787,7 @@ static enum gimplify_status gimplify_conversion (tree *expr_p) { tree tem; + location_t loc = EXPR_LOCATION (*expr_p); gcc_assert (CONVERT_EXPR_P (*expr_p)); /* Then strip away all but the outermost conversion. */ @@ -1826,9 +1828,9 @@ gimplify_conversion (tree *expr_p) /* If we have a conversion to a non-register type force the use of a VIEW_CONVERT_EXPR instead. */ - if (!is_gimple_reg_type (TREE_TYPE (*expr_p))) - *expr_p = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (*expr_p), - TREE_OPERAND (*expr_p, 0)); + if (CONVERT_EXPR_P (*expr_p) && !is_gimple_reg_type (TREE_TYPE (*expr_p))) + *expr_p = fold_build1_loc (loc, VIEW_CONVERT_EXPR, TREE_TYPE (*expr_p), + TREE_OPERAND (*expr_p, 0)); return GS_OK; } @@ -1933,6 +1935,7 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, VEC(tree,heap) *stack; enum gimplify_status ret = GS_OK, tret; int i; + location_t loc = EXPR_LOCATION (*expr_p); /* Create a stack of the subexpressions so later we can walk them in order from inner to outer. */ @@ -1944,7 +1947,7 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, restart: /* Fold INDIRECT_REFs now to turn them into ARRAY_REFs. */ if (TREE_CODE (*p) == INDIRECT_REF) - *p = fold_indirect_ref (*p); + *p = fold_indirect_ref_loc (loc, *p); if (handled_component_p (*p)) ; @@ -2003,7 +2006,7 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, /* Divide the element size by the alignment of the element type (above). */ - elmt_size = size_binop (EXACT_DIV_EXPR, elmt_size, factor); + elmt_size = size_binop_loc (loc, EXACT_DIV_EXPR, elmt_size, factor); if (!is_gimple_min_invariant (elmt_size)) { @@ -2026,7 +2029,7 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, = size_int (DECL_OFFSET_ALIGN (field) / BITS_PER_UNIT); /* Divide the offset by its alignment. */ - offset = size_binop (EXACT_DIV_EXPR, offset, factor); + offset = size_binop_loc (loc, EXACT_DIV_EXPR, offset, factor); if (!is_gimple_min_invariant (offset)) { @@ -2116,6 +2119,7 @@ gimplify_self_mod_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, bool postfix; enum tree_code arith_code; enum gimplify_status ret; + location_t loc = EXPR_LOCATION (*expr_p); code = TREE_CODE (*expr_p); @@ -2159,9 +2163,9 @@ gimplify_self_mod_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, if (!is_gimple_min_lval (lvalue)) { mark_addressable (lvalue); - lvalue = build_fold_addr_expr (lvalue); + lvalue = build_fold_addr_expr_loc (input_location, lvalue); gimplify_expr (&lvalue, pre_p, post_p, is_gimple_val, fb_rvalue); - lvalue = build_fold_indirect_ref (lvalue); + lvalue = build_fold_indirect_ref_loc (input_location, lvalue); } ret = gimplify_expr (&lhs, pre_p, post_p, is_gimple_val, fb_rvalue); if (ret == GS_ERROR) @@ -2171,9 +2175,9 @@ gimplify_self_mod_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, /* For POINTERs increment, use POINTER_PLUS_EXPR. */ if (POINTER_TYPE_P (TREE_TYPE (lhs))) { - rhs = fold_convert (sizetype, rhs); + rhs = fold_convert_loc (loc, sizetype, rhs); if (arith_code == MINUS_EXPR) - rhs = fold_build1 (NEGATE_EXPR, TREE_TYPE (rhs), rhs); + rhs = fold_build1_loc (loc, NEGATE_EXPR, TREE_TYPE (rhs), rhs); arith_code = POINTER_PLUS_EXPR; } @@ -2268,6 +2272,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value) int i, nargs; gimple call; bool builtin_va_start_p = FALSE; + location_t loc = EXPR_LOCATION (*expr_p); gcc_assert (TREE_CODE (*expr_p) == CALL_EXPR); @@ -2291,7 +2296,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value) fndecl = get_callee_fndecl (*expr_p); if (fndecl && DECL_BUILT_IN (fndecl)) { - tree new_tree = fold_call_expr (*expr_p, !want_value); + tree new_tree = fold_call_expr (input_location, *expr_p, !want_value); if (new_tree && new_tree != *expr_p) { @@ -2364,8 +2369,9 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value) tree call = *expr_p; --nargs; - *expr_p = build_call_array (TREE_TYPE (call), CALL_EXPR_FN (call), - nargs, CALL_EXPR_ARGP (call)); + *expr_p = build_call_array_loc (loc, TREE_TYPE (call), + CALL_EXPR_FN (call), + nargs, CALL_EXPR_ARGP (call)); /* Copy all CALL_EXPR flags, location and block, except CALL_EXPR_VA_ARG_PACK flag. */ @@ -2405,10 +2411,18 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value) } } + /* Verify the function result. */ + if (want_value && fndecl + && VOID_TYPE_P (TREE_TYPE (TREE_TYPE (fndecl)))) + { + error_at (loc, "using result of function returning %<void%>"); + ret = GS_ERROR; + } + /* Try this again in case gimplification exposed something. */ if (ret != GS_ERROR) { - tree new_tree = fold_call_expr (*expr_p, !want_value); + tree new_tree = fold_call_expr (input_location, *expr_p, !want_value); if (new_tree && new_tree != *expr_p) { @@ -2749,6 +2763,7 @@ tree gimple_boolify (tree expr) { tree type = TREE_TYPE (expr); + location_t loc = EXPR_LOCATION (expr); if (TREE_CODE (type) == BOOLEAN_TYPE) return expr; @@ -2777,7 +2792,7 @@ gimple_boolify (tree expr) default: /* Other expressions that get here must have boolean values, but might need to be converted to the appropriate mode. */ - return fold_convert (boolean_type_node, expr); + return fold_convert_loc (loc, boolean_type_node, expr); } } @@ -2860,6 +2875,7 @@ gimplify_cond_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback) gimple gimple_cond; enum tree_code pred_code; gimple_seq seq = NULL; + location_t loc = EXPR_LOCATION (*expr_p); type = TREE_TYPE (expr); @@ -2893,18 +2909,18 @@ gimplify_cond_expr (tree *expr_p, gimple_seq *pre_p, fallback_t fallback) if (TREE_TYPE (TREE_OPERAND (expr, 1)) != void_type_node) TREE_OPERAND (expr, 1) = - build_fold_addr_expr (TREE_OPERAND (expr, 1)); + build_fold_addr_expr_loc (loc, TREE_OPERAND (expr, 1)); if (TREE_TYPE (TREE_OPERAND (expr, 2)) != void_type_node) TREE_OPERAND (expr, 2) = - build_fold_addr_expr (TREE_OPERAND (expr, 2)); + build_fold_addr_expr_loc (loc, TREE_OPERAND (expr, 2)); tmp = create_tmp_var (type, "iftmp"); expr = build3 (COND_EXPR, void_type_node, TREE_OPERAND (expr, 0), TREE_OPERAND (expr, 1), TREE_OPERAND (expr, 2)); - result = build_fold_indirect_ref (tmp); + result = build_fold_indirect_ref_loc (loc, tmp); } /* Build the then clause, 't1 = a;'. But don't build an assignment @@ -3083,17 +3099,18 @@ gimplify_modify_expr_to_memcpy (tree *expr_p, tree size, bool want_value, { tree t, to, to_ptr, from, from_ptr; gimple gs; + location_t loc = EXPR_LOCATION (*expr_p); to = TREE_OPERAND (*expr_p, 0); from = TREE_OPERAND (*expr_p, 1); mark_addressable (from); - from_ptr = build_fold_addr_expr (from); - gimplify_arg (&from_ptr, seq_p, EXPR_LOCATION (*expr_p)); + from_ptr = build_fold_addr_expr_loc (loc, from); + gimplify_arg (&from_ptr, seq_p, loc); mark_addressable (to); - to_ptr = build_fold_addr_expr (to); - gimplify_arg (&to_ptr, seq_p, EXPR_LOCATION (*expr_p)); + to_ptr = build_fold_addr_expr_loc (loc, to); + gimplify_arg (&to_ptr, seq_p, loc); t = implicit_built_in_decls[BUILT_IN_MEMCPY]; @@ -3125,6 +3142,7 @@ gimplify_modify_expr_to_memset (tree *expr_p, tree size, bool want_value, { tree t, from, to, to_ptr; gimple gs; + location_t loc = EXPR_LOCATION (*expr_p); /* Assert our assumptions, to abort instead of producing wrong code silently if they are not met. Beware that the RHS CONSTRUCTOR might @@ -3139,8 +3157,8 @@ gimplify_modify_expr_to_memset (tree *expr_p, tree size, bool want_value, /* Now proceed. */ to = TREE_OPERAND (*expr_p, 0); - to_ptr = build_fold_addr_expr (to); - gimplify_arg (&to_ptr, seq_p, EXPR_LOCATION (*expr_p)); + to_ptr = build_fold_addr_expr_loc (loc, to); + gimplify_arg (&to_ptr, seq_p, loc); t = implicit_built_in_decls[BUILT_IN_MEMSET]; gs = gimple_build_call (t, 3, to_ptr, integer_zero_node, size); @@ -4296,6 +4314,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, tree *to_p = &TREE_OPERAND (*expr_p, 0); enum gimplify_status ret = GS_UNHANDLED; gimple assign; + location_t loc = EXPR_LOCATION (*expr_p); gcc_assert (TREE_CODE (*expr_p) == MODIFY_EXPR || TREE_CODE (*expr_p) == INIT_EXPR); @@ -4308,7 +4327,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, { STRIP_USELESS_TYPE_CONVERSION (*from_p); if (!useless_type_conversion_p (TREE_TYPE (*to_p), TREE_TYPE (*from_p))) - *from_p = fold_convert (TREE_TYPE (*to_p), *from_p); + *from_p = fold_convert_loc (loc, TREE_TYPE (*to_p), *from_p); } /* See if any simplifications can be done based on what the RHS is. */ @@ -4450,14 +4469,15 @@ gimplify_variable_sized_compare (tree *expr_p) tree op0 = TREE_OPERAND (*expr_p, 0); tree op1 = TREE_OPERAND (*expr_p, 1); tree t, arg, dest, src; + location_t loc = EXPR_LOCATION (*expr_p); arg = TYPE_SIZE_UNIT (TREE_TYPE (op0)); arg = unshare_expr (arg); arg = SUBSTITUTE_PLACEHOLDER_IN_EXPR (arg, op0); - src = build_fold_addr_expr (op1); - dest = build_fold_addr_expr (op0); + src = build_fold_addr_expr_loc (loc, op1); + dest = build_fold_addr_expr_loc (loc, op0); t = implicit_built_in_decls[BUILT_IN_MEMCMP]; - t = build_call_expr (t, 3, dest, src, arg); + t = build_call_expr_loc (loc, t, 3, dest, src, arg); *expr_p = build2 (TREE_CODE (*expr_p), TREE_TYPE (*expr_p), t, integer_zero_node); @@ -4470,17 +4490,18 @@ gimplify_variable_sized_compare (tree *expr_p) static enum gimplify_status gimplify_scalar_mode_aggregate_compare (tree *expr_p) { + location_t loc = EXPR_LOCATION (*expr_p); tree op0 = TREE_OPERAND (*expr_p, 0); tree op1 = TREE_OPERAND (*expr_p, 1); tree type = TREE_TYPE (op0); tree scalar_type = lang_hooks.types.type_for_mode (TYPE_MODE (type), 1); - op0 = fold_build1 (VIEW_CONVERT_EXPR, scalar_type, op0); - op1 = fold_build1 (VIEW_CONVERT_EXPR, scalar_type, op1); + op0 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, scalar_type, op0); + op1 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, scalar_type, op1); *expr_p - = fold_build2 (TREE_CODE (*expr_p), TREE_TYPE (*expr_p), op0, op1); + = fold_build2_loc (loc, TREE_CODE (*expr_p), TREE_TYPE (*expr_p), op0, op1); return GS_OK; } @@ -4502,8 +4523,8 @@ gimplify_boolean_expr (tree *expr_p, location_t locus) tree type = TREE_TYPE (*expr_p); *expr_p = build3 (COND_EXPR, type, *expr_p, - fold_convert (type, boolean_true_node), - fold_convert (type, boolean_false_node)); + fold_convert_loc (locus, type, boolean_true_node), + fold_convert_loc (locus, type, boolean_false_node)); SET_EXPR_LOCATION (*expr_p, locus); @@ -4607,6 +4628,7 @@ gimplify_addr_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) tree expr = *expr_p; tree op0 = TREE_OPERAND (expr, 0); enum gimplify_status ret; + location_t loc = EXPR_LOCATION (*expr_p); switch (TREE_CODE (op0)) { @@ -4628,7 +4650,7 @@ gimplify_addr_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) tree t_op00 = TREE_TYPE (op00); if (!useless_type_conversion_p (t_expr, t_op00)) - op00 = fold_convert (TREE_TYPE (expr), op00); + op00 = fold_convert_loc (loc, TREE_TYPE (expr), op00); *expr_p = op00; ret = GS_OK; } @@ -4647,8 +4669,9 @@ gimplify_addr_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) if (tree_ssa_useless_type_conversion (TREE_OPERAND (op0, 0))) op0 = TREE_OPERAND (op0, 0); - *expr_p = fold_convert (TREE_TYPE (expr), - build_fold_addr_expr (TREE_OPERAND (op0, 0))); + *expr_p = fold_convert_loc (loc, TREE_TYPE (expr), + build_fold_addr_expr_loc (loc, + TREE_OPERAND (op0, 0))); ret = GS_OK; break; @@ -4899,14 +4922,18 @@ gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) for (link = ASM_CLOBBERS (expr); link; ++i, link = TREE_CHAIN (link)) VEC_safe_push (tree, gc, clobbers, link); - - stmt = gimple_build_asm_vec (TREE_STRING_POINTER (ASM_STRING (expr)), - inputs, outputs, clobbers); - gimple_asm_set_volatile (stmt, ASM_VOLATILE_P (expr)); - gimple_asm_set_input (stmt, ASM_INPUT_P (expr)); + /* Do not add ASMs with errors to the gimple IL stream. */ + if (ret != GS_ERROR) + { + stmt = gimple_build_asm_vec (TREE_STRING_POINTER (ASM_STRING (expr)), + inputs, outputs, clobbers); + + gimple_asm_set_volatile (stmt, ASM_VOLATILE_P (expr)); + gimple_asm_set_input (stmt, ASM_INPUT_P (expr)); - gimplify_seq_add_stmt (pre_p, stmt); + gimplify_seq_add_stmt (pre_p, stmt); + } return ret; } @@ -6556,7 +6583,7 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, break; case INDIRECT_REF: - *expr_p = fold_indirect_ref (*expr_p); + *expr_p = fold_indirect_ref_loc (input_location, *expr_p); if (*expr_p != save_expr) break; /* else fall through. */ @@ -7161,7 +7188,7 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, /* An lvalue will do. Take the address of the expression, store it in a temporary, and replace the expression with an INDIRECT_REF of that temporary. */ - tmp = build_fold_addr_expr (*expr_p); + tmp = build_fold_addr_expr_loc (input_location, *expr_p); gimplify_expr (&tmp, pre_p, post_p, is_gimple_reg, fb_rvalue); *expr_p = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (tmp)), tmp); } @@ -7468,6 +7495,8 @@ gimplify_function_tree (tree fndecl) gimple_seq seq; gimple bind; + gcc_assert (!gimple_body (fndecl)); + oldfn = current_function_decl; current_function_decl = fndecl; if (DECL_STRUCT_FUNCTION (fndecl)) @@ -7534,6 +7563,7 @@ gimplify_function_tree (tree fndecl) } DECL_SAVED_TREE (fndecl) = NULL_TREE; + cfun->curr_properties = PROP_gimple_any; current_function_decl = oldfn; pop_cfun (); diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 9e7e5f517eb..d6c87f45a10 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,18 @@ +2009-07-17 Richard Guenther <rguenther@suse.de> + + PR c/40401 + * java-gimplify.c (java_genericize): Do not gimplify here. + But replace all local references. + (java_gimplify_expr): Do not replace local references here. + (java_gimplify_modify_expr): Likewise. + * jcf-parse.c (java_parse_file): Do not finalize the CU or + optimize the cgraph here. + * decl.c (java_replace_reference): Make static. + (java_replace_references): New function. + (end_java_method): Clear base_decl_map. + * java-tree.h (java_replace_references): Declare. + (java_replace_reference): Remove. + 2009-07-14 Taras Glek <tglek@mozilla.com> Rafael Espindola <espindola@google.com> diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 3c1e7eaef9c..8c327fa97d3 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -306,13 +306,13 @@ find_local_variable (int index, tree type, int pc ATTRIBUTE_UNUSED) return decl; } -/* Called during gimplification for every variable. If the variable +/* Called during genericization for every variable. If the variable is a temporary of pointer type, replace it with a common variable thath is used to hold all pointer types that are ever stored in that slot. Set WANT_LVALUE if you want a variable that is to be written to. */ -tree +static tree java_replace_reference (tree var_decl, bool want_lvalue) { tree decl_type; @@ -341,6 +341,39 @@ java_replace_reference (tree var_decl, bool want_lvalue) return var_decl; } +/* Helper for java_genericize. */ + +tree +java_replace_references (tree *tp, int *walk_subtrees, + void *data ATTRIBUTE_UNUSED) +{ + if (TREE_CODE (*tp) == MODIFY_EXPR) + { + tree lhs = TREE_OPERAND (*tp, 0); + /* This is specific to the bytecode compiler. If a variable has + LOCAL_SLOT_P set, replace an assignment to it with an assignment + to the corresponding variable that holds all its aliases. */ + if (TREE_CODE (lhs) == VAR_DECL + && DECL_LANG_SPECIFIC (lhs) + && LOCAL_SLOT_P (lhs) + && TREE_CODE (TREE_TYPE (lhs)) == POINTER_TYPE) + { + tree new_lhs = java_replace_reference (lhs, /* want_lvalue */ true); + tree new_rhs = build1 (NOP_EXPR, TREE_TYPE (new_lhs), + TREE_OPERAND (*tp, 1)); + *tp = build2 (MODIFY_EXPR, TREE_TYPE (new_lhs), + new_lhs, new_rhs); + *tp = build1 (NOP_EXPR, TREE_TYPE (lhs), *tp); + } + } + if (TREE_CODE (*tp) == VAR_DECL) + { + *tp = java_replace_reference (*tp, /* want_lvalue */ false); + *walk_subtrees = 0; + } + + return NULL_TREE; +} /* Same as find_local_index, except that INDEX is a stack index. */ @@ -1877,6 +1910,7 @@ end_java_method (void) finish_method (fndecl); current_function_decl = NULL_TREE; + base_decl_map = NULL_TREE; } /* Prepare a method for expansion. */ diff --git a/gcc/java/java-gimplify.c b/gcc/java/java-gimplify.c index c460e5b0941..dd75fb995c2 100644 --- a/gcc/java/java-gimplify.c +++ b/gcc/java/java-gimplify.c @@ -44,12 +44,8 @@ static void dump_java_tree (enum tree_dump_index, tree); void java_genericize (tree fndecl) { + walk_tree (&DECL_SAVED_TREE (fndecl), java_replace_references, NULL, NULL); dump_java_tree (TDI_original, fndecl); - - /* Genericize with the gimplifier. */ - gimplify_function_tree (fndecl); - - dump_function (TDI_generic, fndecl); } /* Gimplify a Java tree. */ @@ -65,23 +61,9 @@ java_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) *expr_p = java_gimplify_block (*expr_p); break; - case VAR_DECL: - *expr_p = java_replace_reference (*expr_p, /* want_lvalue */ false); - return GS_UNHANDLED; - case MODIFY_EXPR: return java_gimplify_modify_expr (expr_p); - case SAVE_EXPR: - /* Note that we can see <save_expr NULL> if the save_expr was - already handled by gimplify_save_expr. */ - if (TREE_OPERAND (*expr_p, 0) != NULL_TREE - && TREE_CODE (TREE_OPERAND (*expr_p, 0)) == VAR_DECL) - TREE_OPERAND (*expr_p, 0) - = java_replace_reference (TREE_OPERAND (*expr_p, 0), - /* want_lvalue */ false); - return GS_UNHANDLED; - case POSTINCREMENT_EXPR: case POSTDECREMENT_EXPR: case PREINCREMENT_EXPR: @@ -110,27 +92,12 @@ java_gimplify_modify_expr (tree *modify_expr_p) tree rhs = TREE_OPERAND (modify_expr, 1); tree lhs_type = TREE_TYPE (lhs); - /* This is specific to the bytecode compiler. If a variable has - LOCAL_SLOT_P set, replace an assignment to it with an assignment - to the corresponding variable that holds all its aliases. */ - if (TREE_CODE (lhs) == VAR_DECL - && DECL_LANG_SPECIFIC (lhs) - && LOCAL_SLOT_P (lhs) - && TREE_CODE (lhs_type) == POINTER_TYPE) - { - tree new_lhs = java_replace_reference (lhs, /* want_lvalue */ true); - tree new_rhs = build1 (NOP_EXPR, TREE_TYPE (new_lhs), rhs); - modify_expr = build2 (MODIFY_EXPR, TREE_TYPE (new_lhs), - new_lhs, new_rhs); - modify_expr = build1 (NOP_EXPR, lhs_type, modify_expr); - } - else if (lhs_type != TREE_TYPE (rhs)) + if (lhs_type != TREE_TYPE (rhs)) /* Fix up type mismatches to make legal GIMPLE. These are generated in several places, in particular null pointer assignment and subclass assignment. */ TREE_OPERAND (modify_expr, 1) = convert (lhs_type, rhs); - *modify_expr_p = modify_expr; return GS_UNHANDLED; } diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index 6bf2ecd8217..e68b136db71 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -1119,7 +1119,7 @@ extern int find_class_or_string_constant (struct CPool *, int, tree); extern tree pushdecl_top_level (tree); extern tree pushdecl_function_level (tree); -extern tree java_replace_reference (tree, bool); +extern tree java_replace_references (tree *, int *, void *); extern int alloc_class_constant (tree); extern void init_expr_processing (void); extern void push_super_field (tree, tree); diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index f7b2cb20896..1a2de9ee8b0 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -1982,11 +1982,6 @@ java_parse_file (int set_yydebug ATTRIBUTE_UNUSED) /* Arrange for any necessary initialization to happen. */ java_emit_static_constructor (); gcc_assert (global_bindings_p ()); - - /* Only finalize the compilation unit after we've told cgraph which - functions have their addresses stored. */ - cgraph_finalize_compilation_unit (); - cgraph_optimize (); } diff --git a/gcc/langhooks.c b/gcc/langhooks.c index ff20dd16600..194993f7ab3 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see #include "langhooks-def.h" #include "ggc.h" #include "diagnostic.h" +#include "cgraph.h" /* Do nothing; in many cases the default hook. */ @@ -305,15 +306,20 @@ lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED) void write_global_declarations (void) { + tree globals, decl, *vec; + int len, i; + + /* This lang hook is dual-purposed, and also finalizes the + compilation unit. */ + cgraph_finalize_compilation_unit (); + /* Really define vars that have had only a tentative definition. Really output inline functions that must actually be callable and have not been output so far. */ - tree globals = lang_hooks.decls.getdecls (); - int len = list_length (globals); - tree *vec = XNEWVEC (tree, len); - int i; - tree decl; + globals = lang_hooks.decls.getdecls (); + len = list_length (globals); + vec = XNEWVEC (tree, len); /* Process the decls in reverse order--earliest first. Put them into VEC from back to front, then take out from front. */ diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c index dbe77d9c54c..5176880a016 100644 --- a/gcc/modulo-sched.c +++ b/gcc/modulo-sched.c @@ -1157,12 +1157,14 @@ sms_schedule (void) ps = sms_schedule_by_order (g, mii, maxii, node_order); - if (ps) + if (ps){ stage_count = PS_STAGE_COUNT (ps); + gcc_assert(stage_count >= 1); + } /* Stage count of 1 means that there is no interleaving between iterations, let the scheduling passes do the job. */ - if (stage_count < 1 + if (stage_count <= 1 || (count_init && (loop_count <= stage_count)) || (flag_branch_probabilities && (trip_count <= stage_count))) { diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index 13d537e4316..55065e33636 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,10 @@ +2009-07-17 Aldy Hernandez <aldyh@redhat.com> + Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR 40435 + * objc-act.c: Add location argument to all calls to + build_fold_addr_expr. + 2009-07-14 Taras Glek <tglek@mozilla.com> Rafael Espindola <espindola@google.com> diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 23aae280e6b..c110c79d331 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -3554,7 +3554,7 @@ static tree next_sjlj_build_try_exit (void) { tree t; - t = build_fold_addr_expr (cur_try_context->stack_decl); + t = build_fold_addr_expr_loc (input_location, cur_try_context->stack_decl); t = tree_cons (NULL, t, NULL); t = build_function_call (input_location, objc_exception_try_exit_decl, t); @@ -3575,14 +3575,14 @@ next_sjlj_build_enter_and_setjmp (void) { tree t, enter, sj, cond; - t = build_fold_addr_expr (cur_try_context->stack_decl); + t = build_fold_addr_expr_loc (input_location, cur_try_context->stack_decl); t = tree_cons (NULL, t, NULL); enter = build_function_call (input_location, objc_exception_try_enter_decl, t); t = objc_build_component_ref (cur_try_context->stack_decl, get_identifier ("buf")); - t = build_fold_addr_expr (t); + t = build_fold_addr_expr_loc (input_location, t); #ifdef OBJCPLUS /* Convert _setjmp argument to type that is expected. */ if (TYPE_ARG_TYPES (TREE_TYPE (objc_setjmp_decl))) @@ -3611,7 +3611,7 @@ next_sjlj_build_exc_extract (tree decl) { tree t; - t = build_fold_addr_expr (cur_try_context->stack_decl); + t = build_fold_addr_expr_loc (input_location, cur_try_context->stack_decl); t = tree_cons (NULL, t, NULL); t = build_function_call (input_location, objc_exception_extract_decl, t); @@ -6623,7 +6623,7 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype, method_params = tree_cons (NULL_TREE, lookup_object, tree_cons (NULL_TREE, selector, method_params)); - method = build_fold_addr_expr (sender); + method = build_fold_addr_expr_loc (input_location, sender); } else { @@ -6637,8 +6637,7 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype, t = tree_cons (NULL_TREE, selector, NULL_TREE); t = tree_cons (NULL_TREE, lookup_object, t); - method = build_function_call (loc, - sender, t); + method = build_function_call (loc, sender, t); /* Pass the object to the method. */ method_params = tree_cons (NULL_TREE, object, diff --git a/gcc/omp-low.c b/gcc/omp-low.c index e5649b1f88a..82827bf762a 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -222,6 +222,7 @@ extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd, struct omp_for_data_loop *loop; int i; struct omp_for_data_loop dummy_loop; + location_t loc = gimple_location (for_stmt); fd->for_stmt = for_stmt; fd->pre = NULL; @@ -309,19 +310,23 @@ extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd, break; case LE_EXPR: if (POINTER_TYPE_P (TREE_TYPE (loop->n2))) - loop->n2 = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (loop->n2), + loop->n2 = fold_build2_loc (loc, + POINTER_PLUS_EXPR, TREE_TYPE (loop->n2), loop->n2, size_one_node); else - loop->n2 = fold_build2 (PLUS_EXPR, TREE_TYPE (loop->n2), loop->n2, + loop->n2 = fold_build2_loc (loc, + PLUS_EXPR, TREE_TYPE (loop->n2), loop->n2, build_int_cst (TREE_TYPE (loop->n2), 1)); loop->cond_code = LT_EXPR; break; case GE_EXPR: if (POINTER_TYPE_P (TREE_TYPE (loop->n2))) - loop->n2 = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (loop->n2), + loop->n2 = fold_build2_loc (loc, + POINTER_PLUS_EXPR, TREE_TYPE (loop->n2), loop->n2, size_int (-1)); else - loop->n2 = fold_build2 (MINUS_EXPR, TREE_TYPE (loop->n2), loop->n2, + loop->n2 = fold_build2_loc (loc, + MINUS_EXPR, TREE_TYPE (loop->n2), loop->n2, build_int_cst (TREE_TYPE (loop->n2), 1)); loop->cond_code = GT_EXPR; break; @@ -339,7 +344,8 @@ extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd, break; case MINUS_EXPR: loop->step = TREE_OPERAND (t, 1); - loop->step = fold_build1 (NEGATE_EXPR, TREE_TYPE (loop->step), + loop->step = fold_build1_loc (loc, + NEGATE_EXPR, TREE_TYPE (loop->step), loop->step); break; default: @@ -357,7 +363,8 @@ extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd, tree n; if (loop->cond_code == LT_EXPR) - n = fold_build2 (PLUS_EXPR, TREE_TYPE (loop->v), + n = fold_build2_loc (loc, + PLUS_EXPR, TREE_TYPE (loop->v), loop->n2, loop->step); else n = loop->n1; @@ -373,12 +380,14 @@ extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd, if (loop->cond_code == LT_EXPR) { n1 = loop->n1; - n2 = fold_build2 (PLUS_EXPR, TREE_TYPE (loop->v), + n2 = fold_build2_loc (loc, + PLUS_EXPR, TREE_TYPE (loop->v), loop->n2, loop->step); } else { - n1 = fold_build2 (MINUS_EXPR, TREE_TYPE (loop->v), + n1 = fold_build2_loc (loc, + MINUS_EXPR, TREE_TYPE (loop->v), loop->n2, loop->step); n2 = loop->n1; } @@ -404,24 +413,26 @@ extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd, itype = lang_hooks.types.type_for_size (TYPE_PRECISION (itype), 0); t = build_int_cst (itype, (loop->cond_code == LT_EXPR ? -1 : 1)); - t = fold_build2 (PLUS_EXPR, itype, - fold_convert (itype, loop->step), t); - t = fold_build2 (PLUS_EXPR, itype, t, - fold_convert (itype, loop->n2)); - t = fold_build2 (MINUS_EXPR, itype, t, - fold_convert (itype, loop->n1)); + t = fold_build2_loc (loc, + PLUS_EXPR, itype, + fold_convert_loc (loc, itype, loop->step), t); + t = fold_build2_loc (loc, PLUS_EXPR, itype, t, + fold_convert_loc (loc, itype, loop->n2)); + t = fold_build2_loc (loc, MINUS_EXPR, itype, t, + fold_convert_loc (loc, itype, loop->n1)); if (TYPE_UNSIGNED (itype) && loop->cond_code == GT_EXPR) - t = fold_build2 (TRUNC_DIV_EXPR, itype, - fold_build1 (NEGATE_EXPR, itype, t), - fold_build1 (NEGATE_EXPR, itype, - fold_convert (itype, - loop->step))); + t = fold_build2_loc (loc, TRUNC_DIV_EXPR, itype, + fold_build1_loc (loc, NEGATE_EXPR, itype, t), + fold_build1_loc (loc, NEGATE_EXPR, itype, + fold_convert_loc (loc, itype, + loop->step))); else - t = fold_build2 (TRUNC_DIV_EXPR, itype, t, - fold_convert (itype, loop->step)); - t = fold_convert (long_long_unsigned_type_node, t); + t = fold_build2_loc (loc, TRUNC_DIV_EXPR, itype, t, + fold_convert_loc (loc, itype, loop->step)); + t = fold_convert_loc (loc, long_long_unsigned_type_node, t); if (count != NULL_TREE) - count = fold_build2 (MULT_EXPR, long_long_unsigned_type_node, + count = fold_build2_loc (loc, + MULT_EXPR, long_long_unsigned_type_node, count, t); else count = t; @@ -448,7 +459,7 @@ extract_omp_for_data (gimple for_stmt, struct omp_for_data *fd, if (collapse_count && *collapse_count == NULL) { if (count) - *collapse_count = fold_convert (iter_type, count); + *collapse_count = fold_convert_loc (loc, iter_type, count); else *collapse_count = create_tmp_var (iter_type, ".count"); } @@ -550,6 +561,7 @@ static tree get_ws_args_for (gimple ws_stmt) { tree t; + location_t loc = gimple_location (ws_stmt); if (gimple_code (ws_stmt) == GIMPLE_OMP_FOR) { @@ -561,17 +573,17 @@ get_ws_args_for (gimple ws_stmt) ws_args = NULL_TREE; if (fd.chunk_size) { - t = fold_convert (long_integer_type_node, fd.chunk_size); + t = fold_convert_loc (loc, long_integer_type_node, fd.chunk_size); ws_args = tree_cons (NULL, t, ws_args); } - t = fold_convert (long_integer_type_node, fd.loop.step); + t = fold_convert_loc (loc, long_integer_type_node, fd.loop.step); ws_args = tree_cons (NULL, t, ws_args); - t = fold_convert (long_integer_type_node, fd.loop.n2); + t = fold_convert_loc (loc, long_integer_type_node, fd.loop.n2); ws_args = tree_cons (NULL, t, ws_args); - t = fold_convert (long_integer_type_node, fd.loop.n1); + t = fold_convert_loc (loc, long_integer_type_node, fd.loop.n1); ws_args = tree_cons (NULL, t, ws_args); return ws_args; @@ -1560,7 +1572,6 @@ create_omp_child_function (omp_context *ctx, bool task_copy) decl = build_decl (gimple_location (ctx->stmt), FUNCTION_DECL, name, type); - decl = lang_hooks.decls.pushdecl (decl); if (!task_copy) ctx->cb.dst_fn = decl; @@ -1669,6 +1680,7 @@ scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx) omp_context *ctx; tree name, t; gimple stmt = gsi_stmt (*gsi); + location_t loc = gimple_location (stmt); /* Ignore task directives with empty bodies. */ if (optimize > 0 @@ -1733,7 +1745,7 @@ scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx) fixup_child_record_type (ctx); if (ctx->srecord_type) layout_type (ctx->srecord_type); - t = fold_convert (long_integer_type_node, + t = fold_convert_loc (loc, long_integer_type_node, TYPE_SIZE_UNIT (ctx->record_type)); gimple_omp_task_set_arg_size (stmt, t); t = build_int_cst (long_integer_type_node, @@ -2142,6 +2154,7 @@ maybe_lookup_decl_in_outer_ctx (tree decl, omp_context *ctx) tree omp_reduction_init (tree clause, tree type) { + location_t loc = OMP_CLAUSE_LOCATION (clause); switch (OMP_CLAUSE_REDUCTION_CODE (clause)) { case PLUS_EXPR: @@ -2152,16 +2165,16 @@ omp_reduction_init (tree clause, tree type) case TRUTH_ORIF_EXPR: case TRUTH_XOR_EXPR: case NE_EXPR: - return fold_convert (type, integer_zero_node); + return fold_convert_loc (loc, type, integer_zero_node); case MULT_EXPR: case TRUTH_AND_EXPR: case TRUTH_ANDIF_EXPR: case EQ_EXPR: - return fold_convert (type, integer_one_node); + return fold_convert_loc (loc, type, integer_one_node); case BIT_AND_EXPR: - return fold_convert (type, integer_minus_one_node); + return fold_convert_loc (loc, type, integer_minus_one_node); case MAX_EXPR: if (SCALAR_FLOAT_TYPE_P (type)) @@ -2233,6 +2246,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, enum omp_clause_code c_kind = OMP_CLAUSE_CODE (c); tree var, new_var; bool by_ref; + location_t clause_loc = OMP_CLAUSE_LOCATION (c); switch (c_kind) { @@ -2299,7 +2313,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, gimple_seq_add_stmt (ilist, stmt); - x = fold_convert (TREE_TYPE (ptr), tmp); + x = fold_convert_loc (clause_loc, TREE_TYPE (ptr), tmp); gimplify_assign (ptr, x, ilist); } } @@ -2320,7 +2334,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, if (c_kind == OMP_CLAUSE_FIRSTPRIVATE && is_task_ctx (ctx)) { x = build_receiver_ref (var, false, ctx); - x = build_fold_addr_expr (x); + x = build_fold_addr_expr_loc (clause_loc, x); } else if (TREE_CONSTANT (x)) { @@ -2332,17 +2346,18 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, name); gimple_add_tmp_var (x); TREE_ADDRESSABLE (x) = 1; - x = build_fold_addr_expr (x); + x = build_fold_addr_expr_loc (clause_loc, x); } else { - x = build_call_expr (built_in_decls[BUILT_IN_ALLOCA], 1, x); + x = build_call_expr_loc (clause_loc, + built_in_decls[BUILT_IN_ALLOCA], 1, x); } - x = fold_convert (TREE_TYPE (new_var), x); + x = fold_convert_loc (clause_loc, TREE_TYPE (new_var), x); gimplify_assign (new_var, x, ilist); - new_var = build_fold_indirect_ref (new_var); + new_var = build_fold_indirect_ref_loc (clause_loc, new_var); } else if (c_kind == OMP_CLAUSE_REDUCTION && OMP_CLAUSE_REDUCTION_PLACEHOLDER (c)) @@ -2446,7 +2461,7 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, x = build_outer_var_ref (var, ctx); if (is_reference (var)) - x = build_fold_addr_expr (x); + x = build_fold_addr_expr_loc (clause_loc, x); SET_DECL_VALUE_EXPR (placeholder, x); DECL_HAS_VALUE_EXPR_P (placeholder) = 1; lower_omp (OMP_CLAUSE_REDUCTION_GIMPLE_INIT (c), ctx); @@ -2543,6 +2558,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list, for (c = clauses; c ;) { tree var, new_var; + location_t clause_loc = OMP_CLAUSE_LOCATION (c); if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE) { @@ -2559,7 +2575,7 @@ lower_lastprivate_clauses (tree clauses, tree predicate, gimple_seq *stmt_list, x = build_outer_var_ref (var, ctx); if (is_reference (var)) - new_var = build_fold_indirect_ref (new_var); + new_var = build_fold_indirect_ref_loc (clause_loc, new_var); x = lang_hooks.decls.omp_clause_assign_op (c, x, new_var); gimplify_and_add (x, stmt_list); } @@ -2618,6 +2634,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx) { tree var, ref, new_var; enum tree_code code; + location_t clause_loc = OMP_CLAUSE_LOCATION (c); if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION) continue; @@ -2625,7 +2642,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx) var = OMP_CLAUSE_DECL (c); new_var = lookup_decl (var, ctx); if (is_reference (var)) - new_var = build_fold_indirect_ref (new_var); + new_var = build_fold_indirect_ref_loc (clause_loc, new_var); ref = build_outer_var_ref (var, ctx); code = OMP_CLAUSE_REDUCTION_CODE (c); @@ -2636,11 +2653,11 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx) if (count == 1) { - tree addr = build_fold_addr_expr (ref); + tree addr = build_fold_addr_expr_loc (clause_loc, ref); addr = save_expr (addr); ref = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (addr)), addr); - x = fold_build2 (code, TREE_TYPE (ref), ref, new_var); + x = fold_build2_loc (clause_loc, code, TREE_TYPE (ref), ref, new_var); x = build2 (OMP_ATOMIC, void_type_node, addr, x); gimplify_and_add (x, stmt_seqp); return; @@ -2651,7 +2668,7 @@ lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx) tree placeholder = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c); if (is_reference (var)) - ref = build_fold_addr_expr (ref); + ref = build_fold_addr_expr_loc (clause_loc, ref); SET_DECL_VALUE_EXPR (placeholder, ref); DECL_HAS_VALUE_EXPR_P (placeholder) = 1; lower_omp (OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (c), ctx); @@ -2689,6 +2706,7 @@ lower_copyprivate_clauses (tree clauses, gimple_seq *slist, gimple_seq *rlist, { tree var, ref, x; bool by_ref; + location_t clause_loc = OMP_CLAUSE_LOCATION (c); if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_COPYPRIVATE) continue; @@ -2698,14 +2716,14 @@ lower_copyprivate_clauses (tree clauses, gimple_seq *slist, gimple_seq *rlist, ref = build_sender_ref (var, ctx); x = lookup_decl_in_outer_ctx (var, ctx); - x = by_ref ? build_fold_addr_expr (x) : x; + x = by_ref ? build_fold_addr_expr_loc (clause_loc, x) : x; gimplify_assign (ref, x, slist); ref = build_receiver_ref (var, by_ref, ctx); if (is_reference (var)) { - ref = build_fold_indirect_ref (ref); - var = build_fold_indirect_ref (var); + ref = build_fold_indirect_ref_loc (clause_loc, ref); + var = build_fold_indirect_ref_loc (clause_loc, var); } x = lang_hooks.decls.omp_clause_assign_op (c, var, ref); gimplify_and_add (x, rlist); @@ -2726,6 +2744,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, gimple_seq *olist, { tree val, ref, x, var; bool by_ref, do_in = false, do_out = false; + location_t clause_loc = OMP_CLAUSE_LOCATION (c); switch (OMP_CLAUSE_CODE (c)) { @@ -2787,7 +2806,7 @@ lower_send_clauses (tree clauses, gimple_seq *ilist, gimple_seq *olist, if (do_in) { ref = build_sender_ref (val, ctx); - x = by_ref ? build_fold_addr_expr (var) : var; + x = by_ref ? build_fold_addr_expr_loc (clause_loc, var) : var; gimplify_assign (ref, x, ilist); if (is_task_ctx (ctx)) DECL_ABSTRACT_ORIGIN (TREE_OPERAND (ref, 1)) = NULL; @@ -2883,6 +2902,7 @@ expand_parallel_call (struct omp_region *region, basic_block bb, gimple_stmt_iterator gsi; gimple stmt; int start_ix; + location_t clause_loc; clauses = gimple_omp_parallel_clauses (entry_stmt); @@ -2919,10 +2939,15 @@ expand_parallel_call (struct omp_region *region, basic_block bb, c = find_omp_clause (clauses, OMP_CLAUSE_NUM_THREADS); if (c) - val = OMP_CLAUSE_NUM_THREADS_EXPR (c); + { + val = OMP_CLAUSE_NUM_THREADS_EXPR (c); + clause_loc = OMP_CLAUSE_LOCATION (c); + } + else + clause_loc = gimple_location (entry_stmt); /* Ensure 'val' is of the correct type. */ - val = fold_convert (unsigned_type_node, val); + val = fold_convert_loc (clause_loc, unsigned_type_node, val); /* If we found the clause 'if (cond)', build either (cond != 0) or (cond ? val : 1u). */ @@ -2933,7 +2958,8 @@ expand_parallel_call (struct omp_region *region, basic_block bb, cond = gimple_boolify (cond); if (integer_zerop (val)) - val = fold_build2 (EQ_EXPR, unsigned_type_node, cond, + val = fold_build2_loc (clause_loc, + EQ_EXPR, unsigned_type_node, cond, build_int_cst (TREE_TYPE (cond), 0)); else { @@ -3012,7 +3038,8 @@ expand_parallel_call (struct omp_region *region, basic_block bb, tree args = tree_cons (NULL, t2, tree_cons (NULL, t1, tree_cons (NULL, val, ws_args))); - t = build_function_call_expr (built_in_decls[start_ix], args); + t = build_function_call_expr (UNKNOWN_LOCATION, + built_in_decls[start_ix], args); } else t = build_call_expr (built_in_decls[start_ix], 3, t2, t1, val); @@ -3025,11 +3052,13 @@ expand_parallel_call (struct omp_region *region, basic_block bb, t = null_pointer_node; else t = build_fold_addr_expr (t); - t = build_call_expr (gimple_omp_parallel_child_fn (entry_stmt), 1, t); + t = build_call_expr_loc (gimple_location (entry_stmt), + gimple_omp_parallel_child_fn (entry_stmt), 1, t); force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, false, GSI_CONTINUE_LINKING); - t = build_call_expr (built_in_decls[BUILT_IN_GOMP_PARALLEL_END], 0); + t = build_call_expr_loc (gimple_location (entry_stmt), + built_in_decls[BUILT_IN_GOMP_PARALLEL_END], 0); force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, false, GSI_CONTINUE_LINKING); } @@ -3043,6 +3072,7 @@ expand_task_call (basic_block bb, gimple entry_stmt) { tree t, t1, t2, t3, flags, cond, c, clauses; gimple_stmt_iterator gsi; + location_t loc = gimple_location (entry_stmt); clauses = gimple_omp_task_clauses (entry_stmt); @@ -3060,13 +3090,13 @@ expand_task_call (basic_block bb, gimple entry_stmt) if (t == NULL) t2 = null_pointer_node; else - t2 = build_fold_addr_expr (t); - t1 = build_fold_addr_expr (gimple_omp_task_child_fn (entry_stmt)); + t2 = build_fold_addr_expr_loc (loc, t); + t1 = build_fold_addr_expr_loc (loc, gimple_omp_task_child_fn (entry_stmt)); t = gimple_omp_task_copy_fn (entry_stmt); if (t == NULL) t3 = null_pointer_node; else - t3 = build_fold_addr_expr (t); + t3 = build_fold_addr_expr_loc (loc, t); t = build_call_expr (built_in_decls[BUILT_IN_GOMP_TASK], 7, t1, t2, t3, gimple_omp_task_arg_size (entry_stmt), @@ -4887,6 +4917,7 @@ expand_omp_atomic_fetch_op (basic_block load_bb, basic_block store_bb = single_succ (load_bb); gimple_stmt_iterator gsi; gimple stmt; + location_t loc; /* We expect to find the following sequences: @@ -4904,6 +4935,7 @@ expand_omp_atomic_fetch_op (basic_block load_bb, gsi = gsi_after_labels (store_bb); stmt = gsi_stmt (gsi); + loc = gimple_location (stmt); if (!is_gimple_assign (stmt)) return false; gsi_next (&gsi); @@ -4957,8 +4989,10 @@ expand_omp_atomic_fetch_op (basic_block load_bb, gsi = gsi_last_bb (load_bb); gcc_assert (gimple_code (gsi_stmt (gsi)) == GIMPLE_OMP_ATOMIC_LOAD); - call = build_call_expr (decl, 2, addr, fold_convert (itype, rhs)); - call = fold_convert (void_type_node, call); + call = build_call_expr_loc (loc, + decl, 2, addr, + fold_convert_loc (loc, itype, rhs)); + call = fold_convert_loc (loc, void_type_node, call); force_gimple_operand_gsi (&gsi, call, true, NULL_TREE, true, GSI_SAME_STMT); gsi_remove (&gsi, true); @@ -5180,7 +5214,7 @@ expand_omp_atomic_mutex (basic_block load_bb, basic_block store_bb, gcc_assert (gimple_code (gsi_stmt (si)) == GIMPLE_OMP_ATOMIC_LOAD); t = built_in_decls[BUILT_IN_GOMP_ATOMIC_START]; - t = build_function_call_expr (t, 0); + t = build_function_call_expr (UNKNOWN_LOCATION, t, 0); force_gimple_operand_gsi (&si, t, true, NULL_TREE, true, GSI_SAME_STMT); stmt = gimple_build_assign (loaded_val, build_fold_indirect_ref (addr)); @@ -5195,7 +5229,7 @@ expand_omp_atomic_mutex (basic_block load_bb, basic_block store_bb, gsi_insert_before (&si, stmt, GSI_SAME_STMT); t = built_in_decls[BUILT_IN_GOMP_ATOMIC_END]; - t = build_function_call_expr (t, 0); + t = build_function_call_expr (UNKNOWN_LOCATION, t, 0); force_gimple_operand_gsi (&si, t, true, NULL_TREE, true, GSI_SAME_STMT); gsi_remove (&si, true); @@ -5618,7 +5652,8 @@ lower_omp_single_simple (gimple single_stmt, gimple_seq *pre_p) gimple_seq_add_stmt (pre_p, call); cond = gimple_build_cond (EQ_EXPR, lhs, - fold_convert (TREE_TYPE (lhs), boolean_true_node), + fold_convert_loc (loc, TREE_TYPE (lhs), + boolean_true_node), tlabel, flabel); gimple_seq_add_stmt (pre_p, cond); gimple_seq_add_stmt (pre_p, gimple_build_label (tlabel)); @@ -5672,8 +5707,8 @@ lower_omp_single_copy (gimple single_stmt, gimple_seq *pre_p, omp_context *ctx) l1 = create_artificial_label (loc); l2 = create_artificial_label (loc); - t = build_call_expr (built_in_decls[BUILT_IN_GOMP_SINGLE_COPY_START], 0); - t = fold_convert (ptr_type, t); + t = build_call_expr_loc (loc, built_in_decls[BUILT_IN_GOMP_SINGLE_COPY_START], 0); + t = fold_convert_loc (loc, ptr_type, t); gimplify_assign (ctx->receiver_decl, t, pre_p); t = build2 (EQ_EXPR, boolean_type_node, ctx->receiver_decl, @@ -5690,8 +5725,9 @@ lower_omp_single_copy (gimple single_stmt, gimple_seq *pre_p, omp_context *ctx) lower_copyprivate_clauses (gimple_omp_single_clauses (single_stmt), pre_p, ©in_seq, ctx); - t = build_fold_addr_expr (ctx->sender_decl); - t = build_call_expr (built_in_decls[BUILT_IN_GOMP_SINGLE_COPY_END], 1, t); + t = build_fold_addr_expr_loc (loc, ctx->sender_decl); + t = build_call_expr_loc (loc, built_in_decls[BUILT_IN_GOMP_SINGLE_COPY_END], + 1, t); gimplify_and_add (t, pre_p); t = build_and_jump (&l2); @@ -5760,6 +5796,7 @@ lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx) { tree block, lab = NULL, x; gimple stmt = gsi_stmt (*gsi_p), bind; + location_t loc = gimple_location (stmt); gimple_seq tseq; struct gimplify_ctx gctx; @@ -5769,7 +5806,7 @@ lower_omp_master (gimple_stmt_iterator *gsi_p, omp_context *ctx) bind = gimple_build_bind (NULL, gimple_seq_alloc_with_stmt (stmt), block); - x = build_call_expr (built_in_decls[BUILT_IN_OMP_GET_THREAD_NUM], 0); + x = build_call_expr_loc (loc, built_in_decls[BUILT_IN_OMP_GET_THREAD_NUM], 0); x = build2 (EQ_EXPR, boolean_type_node, x, integer_zero_node); x = build3 (COND_EXPR, void_type_node, x, NULL, build_and_jump (&lab)); tseq = NULL; @@ -5843,6 +5880,7 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx) tree block; tree name, lock, unlock; gimple stmt = gsi_stmt (*gsi_p), bind; + location_t loc = gimple_location (stmt); gimple_seq tbody; struct gimplify_ctx gctx; @@ -5880,18 +5918,19 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx) decl = (tree) n->value; lock = built_in_decls[BUILT_IN_GOMP_CRITICAL_NAME_START]; - lock = build_call_expr (lock, 1, build_fold_addr_expr (decl)); + lock = build_call_expr_loc (loc, lock, 1, build_fold_addr_expr_loc (loc, decl)); unlock = built_in_decls[BUILT_IN_GOMP_CRITICAL_NAME_END]; - unlock = build_call_expr (unlock, 1, build_fold_addr_expr (decl)); + unlock = build_call_expr_loc (loc, unlock, 1, + build_fold_addr_expr_loc (loc, decl)); } else { lock = built_in_decls[BUILT_IN_GOMP_CRITICAL_START]; - lock = build_call_expr (lock, 0); + lock = build_call_expr_loc (loc, lock, 0); unlock = built_in_decls[BUILT_IN_GOMP_CRITICAL_END]; - unlock = build_call_expr (unlock, 0); + unlock = build_call_expr_loc (loc, unlock, 0); } push_gimplify_context (&gctx); @@ -6152,6 +6191,7 @@ create_task_copyfn (gimple task_stmt, omp_context *ctx) splay_tree_node n; struct omp_taskcopy_context tcctx; struct gimplify_ctx gctx; + location_t loc = gimple_location (task_stmt); child_fn = gimple_omp_task_copy_fn (task_stmt); child_cfun = DECL_STRUCT_FUNCTION (child_fn); @@ -6233,7 +6273,7 @@ create_task_copyfn (gimple task_stmt, omp_context *ctx) n = splay_tree_lookup (ctx->sfield_map, (splay_tree_key) decl); sf = (tree) n->value; sf = *(tree *) pointer_map_contains (tcctx.cb.decl_map, sf); - src = build_fold_indirect_ref (sarg); + src = build_fold_indirect_ref_loc (loc, sarg); src = build3 (COMPONENT_REF, TREE_TYPE (sf), src, sf, NULL); t = build2 (MODIFY_EXPR, TREE_TYPE (*p), *p, src); append_to_statement_list (t, &list); @@ -6256,9 +6296,9 @@ create_task_copyfn (gimple task_stmt, omp_context *ctx) sf = (tree) n->value; if (tcctx.cb.decl_map) sf = *(tree *) pointer_map_contains (tcctx.cb.decl_map, sf); - src = build_fold_indirect_ref (sarg); + src = build_fold_indirect_ref_loc (loc, sarg); src = build3 (COMPONENT_REF, TREE_TYPE (sf), src, sf, NULL); - dst = build_fold_indirect_ref (arg); + dst = build_fold_indirect_ref_loc (loc, arg); dst = build3 (COMPONENT_REF, TREE_TYPE (f), dst, f, NULL); t = build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); append_to_statement_list (t, &list); @@ -6279,14 +6319,14 @@ create_task_copyfn (gimple task_stmt, omp_context *ctx) sf = (tree) n->value; if (tcctx.cb.decl_map) sf = *(tree *) pointer_map_contains (tcctx.cb.decl_map, sf); - src = build_fold_indirect_ref (sarg); + src = build_fold_indirect_ref_loc (loc, sarg); src = build3 (COMPONENT_REF, TREE_TYPE (sf), src, sf, NULL); if (use_pointer_for_field (decl, NULL) || is_reference (decl)) - src = build_fold_indirect_ref (src); + src = build_fold_indirect_ref_loc (loc, src); } else src = decl; - dst = build_fold_indirect_ref (arg); + dst = build_fold_indirect_ref_loc (loc, arg); dst = build3 (COMPONENT_REF, TREE_TYPE (f), dst, f, NULL); t = lang_hooks.decls.omp_clause_copy_ctor (c, dst, src); append_to_statement_list (t, &list); @@ -6305,14 +6345,14 @@ create_task_copyfn (gimple task_stmt, omp_context *ctx) sf = (tree) n->value; if (tcctx.cb.decl_map) sf = *(tree *) pointer_map_contains (tcctx.cb.decl_map, sf); - src = build_fold_indirect_ref (sarg); + src = build_fold_indirect_ref_loc (loc, sarg); src = build3 (COMPONENT_REF, TREE_TYPE (sf), src, sf, NULL); if (use_pointer_for_field (decl, NULL)) - src = build_fold_indirect_ref (src); + src = build_fold_indirect_ref_loc (loc, src); } else src = decl; - dst = build_fold_indirect_ref (arg); + dst = build_fold_indirect_ref_loc (loc, arg); dst = build3 (COMPONENT_REF, TREE_TYPE (f), dst, f, NULL); t = build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); append_to_statement_list (t, &list); @@ -6344,10 +6384,10 @@ create_task_copyfn (gimple task_stmt, omp_context *ctx) (splay_tree_key) TREE_OPERAND (ind, 0)); sf = (tree) n->value; sf = *(tree *) pointer_map_contains (tcctx.cb.decl_map, sf); - src = build_fold_indirect_ref (sarg); + src = build_fold_indirect_ref_loc (loc, sarg); src = build3 (COMPONENT_REF, TREE_TYPE (sf), src, sf, NULL); - src = build_fold_indirect_ref (src); - dst = build_fold_indirect_ref (arg); + src = build_fold_indirect_ref_loc (loc, src); + dst = build_fold_indirect_ref_loc (loc, arg); dst = build3 (COMPONENT_REF, TREE_TYPE (f), dst, f, NULL); t = lang_hooks.decls.omp_clause_copy_ctor (c, dst, src); append_to_statement_list (t, &list); @@ -6355,10 +6395,10 @@ create_task_copyfn (gimple task_stmt, omp_context *ctx) (splay_tree_key) TREE_OPERAND (ind, 0)); df = (tree) n->value; df = *(tree *) pointer_map_contains (tcctx.cb.decl_map, df); - ptr = build_fold_indirect_ref (arg); + ptr = build_fold_indirect_ref_loc (loc, arg); ptr = build3 (COMPONENT_REF, TREE_TYPE (df), ptr, df, NULL); t = build2 (MODIFY_EXPR, TREE_TYPE (ptr), ptr, - build_fold_addr_expr (dst)); + build_fold_addr_expr_loc (loc, dst)); append_to_statement_list (t, &list); } @@ -6385,6 +6425,7 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx) gimple par_bind, bind; gimple_seq par_body, olist, ilist, par_olist, par_ilist, new_body; struct gimplify_ctx gctx; + location_t loc = gimple_location (stmt); clauses = gimple_omp_taskreg_clauses (stmt); par_bind = gimple_seq_first_stmt (gimple_omp_body (stmt)); @@ -6441,9 +6482,9 @@ lower_omp_taskreg (gimple_stmt_iterator *gsi_p, omp_context *ctx) if (ctx->record_type) { - t = build_fold_addr_expr (ctx->sender_decl); + t = build_fold_addr_expr_loc (loc, ctx->sender_decl); /* fixup_child_record_type might have changed receiver_decl's type. */ - t = fold_convert (TREE_TYPE (ctx->receiver_decl), t); + t = fold_convert_loc (loc, TREE_TYPE (ctx->receiver_decl), t); gimple_seq_add_stmt (&new_body, gimple_build_assign (ctx->receiver_decl, t)); } @@ -6853,16 +6894,11 @@ diagnose_sb_2 (gimple_stmt_iterator *gsi_p, bool *handled_ops_p, return NULL_TREE; } -void -diagnose_omp_structured_block_errors (tree fndecl) +static unsigned int +diagnose_omp_structured_block_errors (void) { - tree save_current = current_function_decl; struct walk_stmt_info wi; - struct function *old_cfun = cfun; - gimple_seq body = gimple_body (fndecl); - - current_function_decl = fndecl; - set_cfun (DECL_STRUCT_FUNCTION (fndecl)); + gimple_seq body = gimple_body (current_function_decl); all_labels = splay_tree_new (splay_tree_compare_pointers, 0, 0); @@ -6876,8 +6912,32 @@ diagnose_omp_structured_block_errors (tree fndecl) splay_tree_delete (all_labels); all_labels = NULL; - set_cfun (old_cfun); - current_function_decl = save_current; + return 0; +} + +static bool +gate_diagnose_omp_blocks (void) +{ + return flag_openmp != 0; } +struct gimple_opt_pass pass_diagnose_omp_blocks = +{ + { + GIMPLE_PASS, + "diagnose_omp_blocks", /* name */ + gate_diagnose_omp_blocks, /* gate */ + diagnose_omp_structured_block_errors, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + TV_NONE, /* tv_id */ + PROP_gimple_any, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ + } +}; + #include "gt-omp-low.h" diff --git a/gcc/opts.c b/gcc/opts.c index 94e70ba9676..33635dd979d 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -362,6 +362,9 @@ DEF_VEC_ALLOC_P(const_char_p,heap); static VEC(const_char_p,heap) *ignored_options; +/* Language specific warning pass for unused results. */ +bool flag_warn_unused_result = false; + /* Input file names. */ const char **in_fnames; unsigned num_in_fnames; diff --git a/gcc/passes.c b/gcc/passes.c index bb52dc7eb3c..9ad672c477a 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -509,6 +509,8 @@ init_optimization_passes (void) backend might produce already lowered functions that are not processed by these passes. */ p = &all_lowering_passes; + NEXT_PASS (pass_warn_unused_result); + NEXT_PASS (pass_diagnose_omp_blocks); NEXT_PASS (pass_remove_useless_stmts); NEXT_PASS (pass_mudflap_1); NEXT_PASS (pass_lower_omp); @@ -821,7 +823,6 @@ init_optimization_passes (void) /* Register the passes with the tree dump code. */ register_dump_files (all_lowering_passes, PROP_gimple_any); - all_lowering_passes->todo_flags_start |= TODO_set_props; register_dump_files (all_ipa_passes, PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh | PROP_cfg); @@ -1261,9 +1262,6 @@ execute_one_pass (struct opt_pass *pass) if (!quiet_flag && !cfun) fprintf (stderr, " <%s>", pass->name ? pass->name : ""); - if (pass->todo_flags_start & TODO_set_props) - cfun->curr_properties = pass->properties_required; - /* Note that the folders should only create gimple expressions. This is a hack until the new folder is ready. */ in_gimple_form = (cfun && (cfun->curr_properties & PROP_trees)) != 0; diff --git a/gcc/real.h b/gcc/real.h index 0fc915cae5b..884a663c83f 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -26,6 +26,9 @@ #include <mpfr.h> #ifdef HAVE_mpc #include <mpc.h> +# if MPC_VERSION >= MPC_VERSION_NUM(0,6,1) +# define HAVE_mpc_pow +# endif #endif #endif #include "machmode.h" diff --git a/gcc/resource.c b/gcc/resource.c index 846f8ef2b41..08a805519cd 100644 --- a/gcc/resource.c +++ b/gcc/resource.c @@ -945,10 +945,11 @@ mark_target_live_regs (rtx insns, rtx target, struct resources *res) /* If we found a basic block, get the live registers from it and update them with anything set or killed between its start and the insn before - TARGET. Otherwise, we must assume everything is live. */ + TARGET; this custom life analysis is really about registers so we need + to use the LR problem. Otherwise, we must assume everything is live. */ if (b != -1) { - regset regs_live = df_get_live_in (BASIC_BLOCK (b)); + regset regs_live = DF_LR_IN (BASIC_BLOCK (b)); rtx start_insn, stop_insn; /* Compute hard regs live at start of block. */ @@ -1052,7 +1053,7 @@ mark_target_live_regs (rtx insns, rtx target, struct resources *res) { HARD_REG_SET extra_live; - REG_SET_TO_HARD_REG_SET (extra_live, df_get_live_in (bb)); + REG_SET_TO_HARD_REG_SET (extra_live, DF_LR_IN (bb)); IOR_HARD_REG_SET (current_live_regs, extra_live); } } diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 84f65e1d246..47ce848b170 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -342,7 +342,7 @@ self_referential_size (tree size) VEC_safe_push (tree, gc, size_functions, fndecl); /* Replace the original expression with a call to the size function. */ - return build_function_call_expr (fndecl, arg_list); + return build_function_call_expr (input_location, fndecl, arg_list); } /* Take, queue and compile all the size functions. It is essential that @@ -515,6 +515,7 @@ layout_decl (tree decl, unsigned int known_align) tree type = TREE_TYPE (decl); enum tree_code code = TREE_CODE (decl); rtx rtl = NULL_RTX; + location_t loc = DECL_SOURCE_LOCATION (decl); if (code == CONST_DECL) return; @@ -548,8 +549,9 @@ layout_decl (tree decl, unsigned int known_align) } else if (DECL_SIZE_UNIT (decl) == 0) DECL_SIZE_UNIT (decl) - = fold_convert (sizetype, size_binop (CEIL_DIV_EXPR, DECL_SIZE (decl), - bitsize_unit_node)); + = fold_convert_loc (loc, sizetype, + size_binop_loc (loc, CEIL_DIV_EXPR, DECL_SIZE (decl), + bitsize_unit_node)); if (code != FIELD_DECL) /* For non-fields, update the alignment from the type. */ @@ -994,7 +996,7 @@ place_union_field (record_layout_info rli, tree field) if (TREE_CODE (rli->t) == UNION_TYPE) rli->offset = size_binop (MAX_EXPR, rli->offset, DECL_SIZE_UNIT (field)); else if (TREE_CODE (rli->t) == QUAL_UNION_TYPE) - rli->offset = fold_build3 (COND_EXPR, sizetype, + rli->offset = fold_build3_loc (input_location, COND_EXPR, sizetype, DECL_QUALIFIER (field), DECL_SIZE_UNIT (field), rli->offset); } @@ -1181,7 +1183,7 @@ place_field (record_layout_info rli, tree field) field); } else - rli->bitpos = round_up (rli->bitpos, type_align); + rli->bitpos = round_up_loc (input_location, rli->bitpos, type_align); } if (! DECL_PACKED (field)) @@ -1361,7 +1363,7 @@ place_field (record_layout_info rli, tree field) if (maximum_field_alignment != 0) type_align = MIN (type_align, maximum_field_alignment); - rli->bitpos = round_up (rli->bitpos, type_align); + rli->bitpos = round_up_loc (input_location, rli->bitpos, type_align); /* If we really aligned, don't allow subsequent bitfields to undo that. */ @@ -1475,9 +1477,10 @@ finalize_record_size (record_layout_info rli) = size_binop (PLUS_EXPR, unpadded_size_unit, size_one_node); /* Round the size up to be a multiple of the required alignment. */ - TYPE_SIZE (rli->t) = round_up (unpadded_size, TYPE_ALIGN (rli->t)); + TYPE_SIZE (rli->t) = round_up_loc (input_location, unpadded_size, + TYPE_ALIGN (rli->t)); TYPE_SIZE_UNIT (rli->t) - = round_up (unpadded_size_unit, TYPE_ALIGN_UNIT (rli->t)); + = round_up_loc (input_location, unpadded_size_unit, TYPE_ALIGN_UNIT (rli->t)); if (TREE_CONSTANT (unpadded_size) && simple_cst_equal (unpadded_size, TYPE_SIZE (rli->t)) == 0) @@ -1496,7 +1499,7 @@ finalize_record_size (record_layout_info rli) rli->unpacked_align = MAX (TYPE_ALIGN (rli->t), rli->unpacked_align); #endif - unpacked_size = round_up (TYPE_SIZE (rli->t), rli->unpacked_align); + unpacked_size = round_up_loc (input_location, TYPE_SIZE (rli->t), rli->unpacked_align); if (simple_cst_equal (unpacked_size, TYPE_SIZE (rli->t))) { TYPE_PACKED (rli->t) = 0; @@ -1650,8 +1653,9 @@ finalize_type_size (tree type) if (TYPE_SIZE (type) != 0) { - TYPE_SIZE (type) = round_up (TYPE_SIZE (type), TYPE_ALIGN (type)); - TYPE_SIZE_UNIT (type) = round_up (TYPE_SIZE_UNIT (type), + TYPE_SIZE (type) = round_up_loc (input_location, + TYPE_SIZE (type), TYPE_ALIGN (type)); + TYPE_SIZE_UNIT (type) = round_up_loc (input_location, TYPE_SIZE_UNIT (type), TYPE_ALIGN_UNIT (type)); } @@ -1959,7 +1963,8 @@ layout_type (tree type) that (possible) negative values are handled appropriately. */ length = size_binop (PLUS_EXPR, size_one_node, fold_convert (sizetype, - fold_build2 (MINUS_EXPR, + fold_build2_loc (input_location, + MINUS_EXPR, TREE_TYPE (lb), ub, lb))); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 140bb9e863e..187dae19618 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,149 @@ +2009-07-19 Janne Blomqvist <jb@gcc.gnu.org> + Jerry DeLisle <jvdelisle@gcc.gnu.org> + + PR libfortran/40714 + * gfortran.dg/eof_3.f90: New test. + +2009-07-18 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/40727 + * gfortran.dg/intrinsic_cmplx.f90: New test. + +2009-07-19 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR libfortran/34670 + PR libfortran/36874 + * gfortran.dg/cshift_bounds_1.f90: New test. + * gfortran.dg/cshift_bounds_2.f90: New test. + * gfortran.dg/cshift_bounds_3.f90: New test. + * gfortran.dg/cshift_bounds_4.f90: New test. + * gfortran.dg/eoshift_bounds_1.f90: New test. + * gfortran.dg/maxloc_bounds_4.f90: Correct typo in error message. + * gfortran.dg/maxloc_bounds_5.f90: Correct typo in error message. + * gfortran.dg/maxloc_bounds_7.f90: Correct typo in error message. + +2009-07-19 Jan Hubicka <jh@suse.cz> + + PR tree-optimization/40676 + * gcc.c-torture/compile/pr40676.c: New testcase. + +2009-07-18 Adam Nemet <anemet@caviumnetworks.com> + + * gcc.target/mips/ext-2.c: New test. + +2009-07-18 Adam Nemet <anemet@caviumnetworks.com> + + * gcc.target/mips/octeon-exts-7.c: New test. + * gcc.target/mips/octeon-exts-2.c: Revert previous change. + * gcc.target/mips/octeon-exts-5.c: Likewise. + +2009-07-18 Richard Guenther <rguenther@suse.de> + + PR testsuite/40798 + * gcc.dg/tree-ssa/loop-2.c: Tighten pattern. + +2009-07-18 Richard Guenther <rguenther@suse.de> + + PR c/40787 + * gcc.dg/pr35899.c: Adjust. + +2009-07-18 Richard Sandiford <r.sandiford@uk.ibm.com> + + * gcc.target/powerpc/asm-es-1.c: New test. + * gcc.target/powerpc/asm-es-2.c: Likewise. + +2009-07-17 Richard Guenther <rguenther@suse.de> + + PR c/40401 + * g++.dg/rtti/crash4.C: New testcase. + * g++.dg/torture/20090706-1.C: Likewise. + * gcc.dg/redecl-17.c: Likewise. + * gfortran.dg/missing_optional_dummy_5.f90: Adjust pattern. + * gcc.dg/declspec-9.c: Expect extra error. + * gcc.dg/declspec-10.c: Likewise. + * gcc.dg/declspec-11.c: Likewise. + * gcc.dg/redecl-10.c: Expect extra warnings. + * gcc.target/i386/pr39082-1.c: Adjust diagnostic location. + * gcc.target/i386/pr39545-1.c: Likewise. + * g++.dg/ext/asm3.C: Expect more errors. + * g++.dg/gomp/block-1.C: Likewise. + * g++.dg/gomp/block-2.C: Likewise. + * g++.dg/gomp/block-3.C: Likewise. + * g++.dg/gomp/block-5.C: Likewise. + * g++.old-deja/g++.jason/report.C: Expect extra warnings. + * g++.dg/warn/unused-result1.C: XFAIL. + +2009-07-17 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/40321 + * gcc.c-torture/compile/pr40321.c: New testcase. + * g++.dg/torture/pr40321.C: Likewise. + +2009-07-17 Jakub Jelinek <jakub@redhat.com> + + PR c++/40780 + * g++.dg/template/ptrmem19.C: New test. + +2009-07-17 Aldy Hernandez <aldyh@redhat.com> + Manuel López-Ibáñez <manu@gcc.gnu.org> + + PR 40435 + * gcc.dg/pr36902.c: Add column info. + * g++.dg/gcov/gcov-2.C: Change count for definition. + +2009-07-16 Jason Merrill <jason@redhat.com> + + PR libstdc++/37907 + * g++.dg/cpp0x/std-layout1.C: New. + * g++.dg/ext/has_nothrow_assign.C: Fix. + * g++.dg/ext/has_nothrow_copy.C: Fix. + * g++.dg/ext/has_trivial_assign.C: Fix. + * g++.dg/ext/has_trivial_copy.C: Fix. + * g++.dg/ext/is_pod.C: Fix. + * g++.dg/other/offsetof3.C: Adjust. + * g++.dg/overload/ellipsis1.C: Adjust. + * g++.dg/warn/var-args1.C: Adjust. + * g++.old-deja/g++.brendan/crash63.C: Adjust. + * g++.old-deja/g++.brendan/crash64.C: Adjust. + * g++.old-deja/g++.brendan/overload8.C: Adjust. + * g++.old-deja/g++.other/vaarg3.C: Adjust. + * g++.old-deja/g++.pt/vaarg3.C: Adjust. + +2009-07-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * gcc.dg/torture/builtin-math-5.c: Add more cases. + * gcc.dg/torture/builtin-math-6.c: Likewise. Depend on + effective target "mpc_pow". + * lib/target-supports.exp (check_effective_target_mpc_pow): New. + +2009-07-16 Richard Henderson <rth@redhat.com> + + * g++.dg/opt/eh4.C: New test. + +2009-07-16 Jakub Jelinek <jakub@redhat.com> + + * obj-c++.dg/defs.mm (abort): Make it extern "C". + +2009-07-15 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/40747 + * gcc.c-torture/execute/pr40747.c: New test. + +2009-07-15 Richard Guenther <rguenther@suse.de> + + PR middle-end/40753 + * gcc.c-torture/compile/pr40753.c: New testcase. + +2009-07-15 Janus Weil <janus@gcc.gnu.org> + + PR fortran/40743 + * gfortran.dg/interface_assignment_4.f90: New. + +2009-07-15 Gerald Pfeifer <gerald@pfeifer.com> + + * gcc.dg/builtins-config.h (HAVE_C99_RUNTIME): Do not define + for FreeBSD up to and including version 8. + 2009-07-14 Taras Glek <tglek@mozilla.com> Rafael Espindola <espindola@google.com> diff --git a/gcc/testsuite/g++.dg/cpp0x/std-layout1.C b/gcc/testsuite/g++.dg/cpp0x/std-layout1.C new file mode 100644 index 00000000000..bdad8211145 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/std-layout1.C @@ -0,0 +1,91 @@ +// { dg-options "-std=c++0x" } + +// [basic.types]/10: +// Scalar types, standard-layout class types (Clause 9), arrays of such +// types and cv-qualified versions of these types (3.9.3) are collectively +// called standard-layout types. + +// [class]/7: +// A standard-layout class is a class that: +// * has no non-static data members of type non-standard-layout class (or +// array of such types) or reference, +// * has no virtual functions (10.3) and no virtual base classes (10.1), +// * has the same access control (Clause 11) for all non-static data members, +// * has no non-standard-layout base classes, +// * either has no non-static data members in the most-derived class and at +// most one base class with non-static data members, or has no base classes +// with non-static data members, and +// * has no base classes of the same type as the first non-static data member. + +#include <type_traits> + +#define TRY(expr) static_assert (expr, #expr) +#define YES(type) TRY(std::is_standard_layout<type>::value); \ + TRY(std::is_standard_layout<type[]>::value); \ + TRY(std::is_standard_layout<const volatile type>::value); +#define NO(type) TRY(!std::is_standard_layout<type>::value); \ + TRY(!std::is_standard_layout<type[]>::value); \ + TRY(!std::is_standard_layout<const volatile type>::value); +#define NONPOD(type) TRY(!std::is_pod<type>::value); \ + TRY(!std::is_pod<type[]>::value); \ + TRY(!std::is_pod<const volatile type>::value); + +struct A; + +YES(int); +YES(__complex int); +YES(void *); +YES(int A::*); +typedef int (A::*pmf)(); +YES(pmf); + +struct A { ~A(); }; +YES(A); +NONPOD(A); +struct F: public A { int i; }; +YES(F); +NONPOD(F); +struct G: public A { A a; }; +NO(G); +struct M { A a; }; +YES(M); + +class B +{ + int i; + __complex int c; + void *p; + double ar[4]; + int A::* pm; + int (A::*pmf)(); +}; +YES(B); +struct D: public B { }; +YES(D); +struct E: public B { int q; }; +NO(E); +struct D2: public B { }; +YES(D2); +struct I: public D, public D2 { }; +NO(I); + +struct C +{ + int i; +private: + int j; +}; +NO(C); +struct H: public C { }; +NO(H); +struct N { C c; }; +NO(N); + +struct J { virtual void f(); }; +struct J2: J { }; +NO(J); +NO(J2); +struct K { }; +struct L: virtual K {}; +YES(K); +NO(L); diff --git a/gcc/testsuite/g++.dg/cpp0x/trivial1.C b/gcc/testsuite/g++.dg/cpp0x/trivial1.C new file mode 100644 index 00000000000..62173ac0caf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/trivial1.C @@ -0,0 +1,82 @@ +// { dg-options "-std=c++0x" } + +// [basic.types]/10: +// Scalar types, trivial class types (Clause 9), arrays of such types and +// cv-qualified versions of these types (3.9.3) are collectively called +// trivial types. + +// [class]/6: +// A trivially copyable class is a class that: +// * has no non-trivial copy constructors (12.8), +// * has no non-trivial copy assignment operators (13.5.3, 12.8), and +// * has a trivial destructor (12.4). +// A trivial class is a class that has a trivial default constructor (12.1) +// and is trivially copyable. + +#include <type_traits> + +#define TRY(expr) static_assert (expr, #expr) +#define YES(type) TRY(std::is_trivial<type>::value); \ + TRY(std::is_trivial<type[]>::value); \ + TRY(std::is_trivial<const volatile type>::value); +#define NO(type) TRY(!std::is_trivial<type>::value); \ + TRY(!std::is_trivial<type[]>::value); \ + TRY(!std::is_trivial<const volatile type>::value); + +struct A; + +YES(int); +YES(__complex int); +YES(void *); +YES(int A::*); +typedef int (A::*pmf)(); +YES(pmf); + +struct A { ~A(); }; +NO(A); +struct F: public A { int i; }; +NO(F); +struct G: public A { A a; }; +NO(G); +struct M { A a; }; +NO(M); + +class B +{ + int i; + __complex int c; + void *p; + double ar[4]; + int A::* pm; + int (A::*pmf)(); +}; +YES(B); +struct D: public B { }; +YES(D); +struct E: public B { int q; }; +YES(E); +struct D2: public B { }; +YES(D2); +struct I: public D, public D2 { }; +YES(I); + +struct C +{ + int i; +private: + int j; +}; +YES(C); +struct H: public C { }; +YES(H); +struct N { C c; }; +YES(N); + +struct J { virtual void f(); }; +struct J2: J { }; +NO(J); +NO(J2); +struct K { }; +struct L: virtual K {}; +YES(K); +NO(L); diff --git a/gcc/testsuite/g++.dg/ext/asm3.C b/gcc/testsuite/g++.dg/ext/asm3.C index 5eff16ffe7c..090218fe61f 100644 --- a/gcc/testsuite/g++.dg/ext/asm3.C +++ b/gcc/testsuite/g++.dg/ext/asm3.C @@ -8,6 +8,8 @@ int two(int in) { register int out; - __asm__ ("" : "r" (out) : "r" (in)); // { dg-error "" "" } + __asm__ ("" : "r" (out) : "r" (in)); return out; } + +// { dg-message "error:" "" { target *-*-* } 11 } diff --git a/gcc/testsuite/g++.dg/ext/has_nothrow_assign.C b/gcc/testsuite/g++.dg/ext/has_nothrow_assign.C index 73a904eac25..f3b4a8b2556 100644 --- a/gcc/testsuite/g++.dg/ext/has_nothrow_assign.C +++ b/gcc/testsuite/g++.dg/ext/has_nothrow_assign.C @@ -134,7 +134,7 @@ int main() assert (PTEST (A)); assert (PTEST (B)); assert (PTEST (C)); - assert (NTEST (C[])); + assert (PTEST (C[])); assert (PTEST (D)); assert (NTEST (E)); assert (NTEST (E1)); diff --git a/gcc/testsuite/g++.dg/ext/has_nothrow_copy-1.C b/gcc/testsuite/g++.dg/ext/has_nothrow_copy-1.C index e8507cf582c..056c9be61f6 100644 --- a/gcc/testsuite/g++.dg/ext/has_nothrow_copy-1.C +++ b/gcc/testsuite/g++.dg/ext/has_nothrow_copy-1.C @@ -124,7 +124,7 @@ int main() assert (PTEST (A)); assert (PTEST (B)); assert (PTEST (C)); - assert (NTEST (C[])); + assert (PTEST (C[])); assert (PTEST (D)); assert (NTEST (E)); assert (NTEST (E1)); diff --git a/gcc/testsuite/g++.dg/ext/has_trivial_assign.C b/gcc/testsuite/g++.dg/ext/has_trivial_assign.C index 97bcbf23997..46d8c34bb3f 100644 --- a/gcc/testsuite/g++.dg/ext/has_trivial_assign.C +++ b/gcc/testsuite/g++.dg/ext/has_trivial_assign.C @@ -96,7 +96,7 @@ int main() assert (NTEST (C)); assert (NTEST (D)); assert (PTEST (E)); - assert (NTEST (E[])); + assert (PTEST (E[])); assert (PTEST (F)); assert (NTEST (G)); assert (NTEST (const A)); diff --git a/gcc/testsuite/g++.dg/ext/has_trivial_copy.C b/gcc/testsuite/g++.dg/ext/has_trivial_copy.C index ca2eeec4bdb..4b8cc154147 100644 --- a/gcc/testsuite/g++.dg/ext/has_trivial_copy.C +++ b/gcc/testsuite/g++.dg/ext/has_trivial_copy.C @@ -96,7 +96,7 @@ int main() assert (NTEST (C)); assert (NTEST (D)); assert (PTEST (E)); - assert (NTEST (E[])); + assert (PTEST (E[])); assert (PTEST (F)); assert (NTEST (G)); assert (PTEST (B&)); diff --git a/gcc/testsuite/g++.dg/ext/is_pod.C b/gcc/testsuite/g++.dg/ext/is_pod.C index 5c1f0cd3bcd..c984283a0e9 100644 --- a/gcc/testsuite/g++.dg/ext/is_pod.C +++ b/gcc/testsuite/g++.dg/ext/is_pod.C @@ -68,8 +68,8 @@ int main() assert (PTEST (A)); assert (PTEST (A[])); assert (NTEST (B)); - assert (NTEST (C)); - assert (NTEST (C[])); + assert (PTEST (C)); + assert (PTEST (C[])); return 0; } diff --git a/gcc/testsuite/g++.dg/gcov/gcov-2.C b/gcc/testsuite/g++.dg/gcov/gcov-2.C index 66d8af39bce..6d002f5d2cd 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov-2.C +++ b/gcc/testsuite/g++.dg/gcov/gcov-2.C @@ -20,7 +20,7 @@ private: void foo() { - C c; /* count(1) */ + C c; /* count(2) */ c.seti (1); /* count(1) */ } diff --git a/gcc/testsuite/g++.dg/gomp/block-1.C b/gcc/testsuite/g++.dg/gomp/block-1.C index 50a8c0e9ead..d2b86645af8 100644 --- a/gcc/testsuite/g++.dg/gomp/block-1.C +++ b/gcc/testsuite/g++.dg/gomp/block-1.C @@ -20,3 +20,6 @@ void foo() { ok1: break; } } } + +// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 7 } +// { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 9 } diff --git a/gcc/testsuite/g++.dg/gomp/block-2.C b/gcc/testsuite/g++.dg/gomp/block-2.C index 621a90d7bc4..17d98d845a5 100644 --- a/gcc/testsuite/g++.dg/gomp/block-2.C +++ b/gcc/testsuite/g++.dg/gomp/block-2.C @@ -30,3 +30,6 @@ void foo() for (i = 0; i < 10; ++i) continue; } + +// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 14 } +// { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 16 } diff --git a/gcc/testsuite/g++.dg/gomp/block-3.C b/gcc/testsuite/g++.dg/gomp/block-3.C index 8e036e45364..aeb0c7795a0 100644 --- a/gcc/testsuite/g++.dg/gomp/block-3.C +++ b/gcc/testsuite/g++.dg/gomp/block-3.C @@ -55,3 +55,7 @@ void foo() } } } + +// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 21 } +// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 26 } +// { dg-message "error: invalid entry to OpenMP structured block" "" { target *-*-* } 30 } diff --git a/gcc/testsuite/g++.dg/gomp/block-5.C b/gcc/testsuite/g++.dg/gomp/block-5.C index 67ed72c8daa..391f8b660a6 100644 --- a/gcc/testsuite/g++.dg/gomp/block-5.C +++ b/gcc/testsuite/g++.dg/gomp/block-5.C @@ -13,3 +13,5 @@ void foo() return; // { dg-error "invalid exit" } } } + +// { dg-message "error: invalid branch to/from an OpenMP structured block" "" { target *-*-* } 7 } diff --git a/gcc/testsuite/g++.dg/opt/eh4.C b/gcc/testsuite/g++.dg/opt/eh4.C new file mode 100644 index 00000000000..0a62ee2db27 --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/eh4.C @@ -0,0 +1,59 @@ +// { dg-do run } +// { dg-options "-O3" } + +// Make sure that the call to terminate within F2 is not eliminated +// by incorrect MUST_NOT_THROW optimization. Note that we expect F1 +// to be inlined into F2 in order to expose this case. + +#include <cstdlib> +#include <exception> + +static volatile int zero = 0; + +// Note that we need F0 to not be marked nothrow, though we don't actually +// want a throw to happen at runtime here. The noinline tag is merely to +// make sure the assembly in F0 is not unnecessarily complex. +static void __attribute__((noinline)) f0() +{ + if (zero != 0) + throw 0; +} + +struct S1 +{ + S1() { } + ~S1() { f0(); } +}; + +static void f1() +{ + S1 s1; + throw 1; +} + +struct S2 +{ + S2() { } + ~S2() { f1(); } +}; + +static void __attribute__((noinline)) f2() +{ + S2 s2; + throw 2; +} + +static void pass() +{ + exit (0); +} + +int main() +{ + std::set_terminate (pass); + try { + f2(); + } catch (...) { + } + abort (); +} diff --git a/gcc/testsuite/g++.dg/other/offsetof3.C b/gcc/testsuite/g++.dg/other/offsetof3.C index 1e83af98071..5946c812ced 100644 --- a/gcc/testsuite/g++.dg/other/offsetof3.C +++ b/gcc/testsuite/g++.dg/other/offsetof3.C @@ -1,16 +1,17 @@ -/* Verify that offsetof warns if given a non-POD */ +/* Verify that offsetof warns if given a non-standard-layout class */ /* Copyright (C) 2003 Free Software Foundation, Inc. */ /* Contributed by Matt Austern <austern@apple.com> 15 May 2003 */ /* { dg-do compile } */ struct X { - X() : x(3), y(4) { } int x, y; +protected: + int z; }; typedef X* pX; typedef __SIZE_TYPE__ size_t; size_t yoff = size_t(&(pX(0)->y)); /* { dg-warning "invalid access" "" } */ -/* { dg-warning "macro was used incorrectly" "macro" { target *-*-* } 15 } */ +/* { dg-warning "macro was used incorrectly" "macro" { target *-*-* } 16 } */ diff --git a/gcc/testsuite/g++.dg/overload/ellipsis1.C b/gcc/testsuite/g++.dg/overload/ellipsis1.C index bdd3cd2311b..3dedaa6be4a 100644 --- a/gcc/testsuite/g++.dg/overload/ellipsis1.C +++ b/gcc/testsuite/g++.dg/overload/ellipsis1.C @@ -1,9 +1,6 @@ // PR c++/15142 // Bug: We were aborting after giving a warning about passing a non-POD. -// Suppress the warning about undefined behavior. -// { dg-options "-w" } - struct B { B() throw() { } B(const B&) throw() { } @@ -17,5 +14,5 @@ struct X { struct S { S(...); }; void SillyFunc() { - throw S(X()); + throw S(X()); // { dg-error "copy" } } diff --git a/gcc/testsuite/g++.dg/rtti/crash4.C b/gcc/testsuite/g++.dg/rtti/crash4.C new file mode 100644 index 00000000000..49807e99f08 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/crash4.C @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +class ios_base { +public: + virtual ~ios_base(); +}; +template<typename _CharT> +class basic_ostream : virtual public ios_base { +public: + virtual ~basic_ostream() { } +}; +extern template class basic_ostream<char>; +template <typename _CharT> +class basic_ostringstream : public basic_ostream<_CharT> { }; +template class basic_ostringstream<char>; diff --git a/gcc/testsuite/g++.dg/template/ptrmem19.C b/gcc/testsuite/g++.dg/template/ptrmem19.C new file mode 100644 index 00000000000..52711c6cb68 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ptrmem19.C @@ -0,0 +1,19 @@ +// PR c++/40780 +// { dg-do compile } + +template <class T1, typename T2, typename T3> +struct A +{ + typedef T2 (T1::*m) (T3); + A (m) {} +}; +struct B; +struct C +{ + void foo (B *); +}; +typedef A <C, void, B *> D; +typedef void (C::*E) (B *); +struct F; +typedef void (C::*G) (F); +D d ((E) (G) & C::foo); diff --git a/gcc/testsuite/g++.dg/torture/20090706-1.C b/gcc/testsuite/g++.dg/torture/20090706-1.C new file mode 100644 index 00000000000..43a59f0e682 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/20090706-1.C @@ -0,0 +1,41 @@ +/* { dg-do compile } */ + +namespace std __attribute__ ((__visibility__ ("default"))) { + template<typename _Tp> class new_allocator { }; + template<typename _Tp> class allocator: public new_allocator<_Tp> { }; + template<typename _Tp, typename _Alloc> struct _Vector_base { }; + template<typename _Tp, typename _Alloc = std::allocator<_Tp> > + class vector : protected _Vector_base<_Tp, _Alloc> { }; +}; +template<int Dim> class Vector { }; +enum CenteringType { VertexType, EdgeType, FaceType, CellType }; +enum ContinuityType { XDim = 1, YDim = XDim << 1, ZDim = YDim << 1 }; +template <int Dim> class Centering { +public: + typedef Vector<Dim> Position; + typedef std::vector<Position> Positions; + Centering(const Positions &positions); + Positions positions_m; +}; +template <int Dim> class CanonicalCentering { + CanonicalCentering(); + template <class T> static T combine(const T &op1, const T &op2); + static Centering<Dim>*** centering_table_m; +}; +template <int Dim> CanonicalCentering<Dim>::CanonicalCentering() +{ + typename Centering<Dim>::Positions positions[Dim][2]; + enum { x = 0, y, z }; + int cont = 0; + if (Dim > 1) + { + centering_table_m[EdgeType][cont][YDim] = Centering<Dim>(positions[y][cont]); + centering_table_m[EdgeType][cont][XDim|YDim] = Centering<Dim>(combine(positions[x][cont], positions[y][cont])); + } + if (Dim > 2) + { + centering_table_m[EdgeType][cont][ZDim] = Centering<Dim>(positions[z][cont]); + centering_table_m[EdgeType][cont][XDim|ZDim] = Centering<Dim>(combine(positions[x][cont], positions[z][cont])); + } +} +template class CanonicalCentering<2>; diff --git a/gcc/testsuite/g++.dg/torture/pr40321.C b/gcc/testsuite/g++.dg/torture/pr40321.C new file mode 100644 index 00000000000..9177431098e --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr40321.C @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +struct VectorD2 +{ + VectorD2() : x(0), y(0) { } + VectorD2(int _x, int _y) : x(_x), y(_y) { } + int x, y; + int GetLength2() const { return x*x + y*y; }; + VectorD2 operator+(const VectorD2 vec) const { + return VectorD2(x+vec.x,y+vec.y); + } +}; +struct Shape +{ + enum Type { ST_RECT, ST_CIRCLE } type; + VectorD2 pos; + VectorD2 radius; + bool CollisionWith(const Shape& s) const; +}; +bool Shape::CollisionWith(const Shape& s) const +{ + if(type == ST_CIRCLE && s.type == ST_RECT) + return s.CollisionWith(*this); + return (pos + s.pos).GetLength2() < (radius + s.radius).GetLength2(); +} diff --git a/gcc/testsuite/g++.dg/warn/unused-result1.C b/gcc/testsuite/g++.dg/warn/unused-result1.C index 1b9ef8af786..466c99e7d97 100644 --- a/gcc/testsuite/g++.dg/warn/unused-result1.C +++ b/gcc/testsuite/g++.dg/warn/unused-result1.C @@ -6,5 +6,5 @@ public: }; class QString { QByteArray toLocal8Bit() const __attribute__ ((warn_unused_result)); - void fooWarnHere() const { toLocal8Bit(); } // { dg-warning "ignoring" } + void fooWarnHere() const { toLocal8Bit(); } // { dg-warning "ignoring" "" { xfail *-*-* } } }; diff --git a/gcc/testsuite/g++.dg/warn/var-args1.C b/gcc/testsuite/g++.dg/warn/var-args1.C index aadac20e84a..9bd84a7dd55 100644 --- a/gcc/testsuite/g++.dg/warn/var-args1.C +++ b/gcc/testsuite/g++.dg/warn/var-args1.C @@ -6,6 +6,6 @@ void foo(int, ...) { va_list va; int i; - i = va_arg(va, int&); /* { dg-warning "cannot receive objects" } */ + i = va_arg(va, int&); /* { dg-error "cannot receive objects" } */ } diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash63.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash63.C index 13f8339b342..89685fcaeb5 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash63.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash63.C @@ -4,6 +4,7 @@ class String { public: String (const char *str); + String (const String&); }; class UnitList @@ -12,4 +13,4 @@ class UnitList UnitList (...); }; -UnitList unit_list (String("keV")); // { dg-warning "" } cannot pass non-pod +UnitList unit_list (String("keV")); // { dg-error "" } cannot pass non-pod diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C index 6046cb1c9ee..3c986928331 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash64.C @@ -16,4 +16,4 @@ struct metatype { int base_list; }; static _type_desc _type_metatype("metatype", sizeof(metatype), (RF_Ptr)0, 0, 1, 1, - _im_pers_mem_spec( ((size_t)&((( metatype *)0)-> base_list )) , 1)); // { dg-warning "" } cannot pass non-pod + _im_pers_mem_spec( ((size_t)&((( metatype *)0)-> base_list )) , 1)); diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/overload8.C b/gcc/testsuite/g++.old-deja/g++.brendan/overload8.C index fc1b23b75b4..bf129b02c2b 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/overload8.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/overload8.C @@ -6,4 +6,4 @@ class Complex{public:double re,im; void zxcvbnm(int n,...){n=1;} int main(){complex c; Complex C; zxcvbnm(1,c); -zxcvbnm(1,C);} // { dg-warning "" } cannot pass non pod +zxcvbnm(1,C);} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/report.C b/gcc/testsuite/g++.old-deja/g++.jason/report.C index e1079cfb0aa..b595662c228 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/report.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/report.C @@ -72,3 +72,6 @@ int darg (char X::*p) { undef3 (1); // { dg-error "" } implicit declaration } // { dg-warning "no return statement" } + +// { dg-message "warning: control reaches end of non-void function" "" { target *-*-* } 36 } +// { dg-message "warning: control reaches end of non-void function" "" { target *-*-* } 65 } diff --git a/gcc/testsuite/g++.old-deja/g++.other/vaarg3.C b/gcc/testsuite/g++.old-deja/g++.other/vaarg3.C index f852b08ce5a..3408a181188 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/vaarg3.C +++ b/gcc/testsuite/g++.old-deja/g++.other/vaarg3.C @@ -9,14 +9,14 @@ #include <stdarg.h> struct X {int m;}; -struct Y : X {int m;}; +struct Y { Y(const Y&); }; struct Z; // { dg-error "forward decl" } void fn1(va_list args) { int i = va_arg (args, int); - Y x = va_arg (args, Y); // { dg-warning "cannot receive" } - Y y = va_arg (args, struct Y); // { dg-warning "cannot receive" } - int &r = va_arg (args, int &); // { dg-warning "cannot receive" } + Y x = va_arg (args, Y); // { dg-error "cannot receive" } + Y y = va_arg (args, struct Y); // { dg-error "cannot receive" } + int &r = va_arg (args, int &); // { dg-error "cannot receive" } Z z1 = va_arg (args, Z); // { dg-error "incomplete" } const Z &z2 = va_arg (args, Z); // { dg-error "incomplete" } @@ -25,7 +25,8 @@ void fn1(va_list args) // { dg-message "should pass" "pass" { target *-*-* } 24 } // { dg-message "abort" "abort" { target *-*-* } 24 } va_arg (args, int []); // { dg-error "array with unspecified bounds" } promote - va_arg (args, int ()); // { dg-warning "non-POD" } promote + va_arg (args, int ()); // { dg-warning "promoted" } promote + // { dg-message "abort" "abort" { target *-*-* } 28 } va_arg (args, bool); // { dg-warning "promote" "promote" } - // { dg-message "abort" "abort" { target *-*-* } 29 } + // { dg-message "abort" "abort" { target *-*-* } 30 } } diff --git a/gcc/testsuite/g++.old-deja/g++.pt/vaarg3.C b/gcc/testsuite/g++.old-deja/g++.pt/vaarg3.C index dced89d17ab..07fb18d77d8 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/vaarg3.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/vaarg3.C @@ -14,14 +14,14 @@ void PrintArgs (Type somearg, ...) va_list argp; va_start (argp, somearg); Type value; -value = va_arg (argp, Type); // { dg-warning "non-POD" } cannot pass non-POD +value = va_arg (argp, Type); // { dg-error "cannot receive" } cannot pass non-POD va_end (argp); } int main (void) { A dummy; -PrintArgs (dummy, dummy); // { dg-warning "non-POD" } cannot pass non-POD +PrintArgs (dummy, dummy); // { dg-error "cannot pass" } cannot pass non-POD // { dg-message "instantiated" "inst" { target *-*-* } 24 } return 0; } diff --git a/gcc/testsuite/gcc.c-torture/compile/pr40321.c b/gcc/testsuite/gcc.c-torture/compile/pr40321.c new file mode 100644 index 00000000000..a2f83ed8d84 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr40321.c @@ -0,0 +1,12 @@ +struct X { int flag; int pos; }; +int foo(struct X *a, struct X *b) +{ + while (1) + { + if (a->flag) + break; + ({ struct X *tmp = a; a = b; b = tmp; }); + } + + return a->pos + b->pos; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr40676.c b/gcc/testsuite/gcc.c-torture/compile/pr40676.c new file mode 100644 index 00000000000..b0426288292 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr40676.c @@ -0,0 +1,33 @@ +extern int f1(); +extern int f2(void*); +extern void* f3(int); +int xmsih; +typedef unsigned short XWCHAR; + +inline unsigned int xstrlenW( const XWCHAR *str ) +{ + const XWCHAR *s = str; + while (*s) s++; + return s - str; +} + + +static int msi_dialog_register_class( void ) +{ + int cls; + + if( !f2( &cls ) ) + return 0; + if( !f2( &cls ) ) + return 0; + xmsih = f1(); + if( !xmsih ) + return 0; + return 1; +} + +void *xmsi_dialog_create(const XWCHAR* szDialogName) +{ + msi_dialog_register_class(); + return f3(xstrlenW(szDialogName)); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr40753.c b/gcc/testsuite/gcc.c-torture/compile/pr40753.c new file mode 100644 index 00000000000..507303dac72 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr40753.c @@ -0,0 +1,20 @@ +typedef struct { + unsigned nargs; +} ffi_cif; +typedef struct { + char tramp[24]; + ffi_cif *cif; +} ffi_closure; +extern void *memcpy (void *, const void *, __SIZE_TYPE__); +extern void ffi_closure_LINUX64 (void); + +int +ffi_prep_closure_loc (ffi_closure *closure, ffi_cif *cif) +{ + void **tramp = (void **) &closure->tramp[0]; + + memcpy (tramp, (char *) ffi_closure_LINUX64, 16); + closure->cif = cif; + + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr40747.c b/gcc/testsuite/gcc.c-torture/execute/pr40747.c new file mode 100644 index 00000000000..1c75be3fcc5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr40747.c @@ -0,0 +1,22 @@ +/* PR middle-end/40747 */ + +extern void abort (void); + +int +foo (int i) +{ + return (i < 4 && i >= 0) ? i : 4; +} + +int +main () +{ + if (foo (-1) != 4) abort (); + if (foo (0) != 0) abort (); + if (foo (1) != 1) abort (); + if (foo (2) != 2) abort (); + if (foo (3) != 3) abort (); + if (foo (4) != 4) abort (); + if (foo (5) != 4) abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/builtins-config.h b/gcc/testsuite/gcc.dg/builtins-config.h index 7e375b8d693..487da415c76 100644 --- a/gcc/testsuite/gcc.dg/builtins-config.h +++ b/gcc/testsuite/gcc.dg/builtins-config.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation. +/* Copyright (C) 2003, 2004, 2005, 2006, 2009 Free Software Foundation. Define macros useful in tests for bulitin functions. */ @@ -15,8 +15,8 @@ /* Irix6 doesn't have the entire C99 runtime. */ #elif defined(__AVR__) /* AVR doesn't have the entire C99 runtime. */ -#elif defined(__FreeBSD__) && (__FreeBSD__ < 5) -/* FreeBSD before version 5 doesn't have the entire C99 runtime. */ +#elif defined(__FreeBSD__) && (__FreeBSD__ < 9) +/* FreeBSD up to version 8 lacks support for cexp and friends. */ #elif defined(__netware__) /* NetWare doesn't have the entire C99 runtime. */ #elif defined(__vxworks) diff --git a/gcc/testsuite/gcc.dg/declspec-10.c b/gcc/testsuite/gcc.dg/declspec-10.c index f938bf10e7a..ddc60646ab0 100644 --- a/gcc/testsuite/gcc.dg/declspec-10.c +++ b/gcc/testsuite/gcc.dg/declspec-10.c @@ -43,3 +43,5 @@ void i (void) { auto void y (void) {} } /* { dg-warning "ISO C forbids nested fu /* { dg-warning "function definition declared 'auto'" "nested" { target *-*-* } 42 } */ inline int main (void) { return 0; } /* { dg-warning "cannot inline function 'main'" } */ + +/* { dg-message "error: register name not specified for 'y'" "" { target *-*-* } 19 } */ diff --git a/gcc/testsuite/gcc.dg/declspec-11.c b/gcc/testsuite/gcc.dg/declspec-11.c index c3fec469a81..9dfe63f99e3 100644 --- a/gcc/testsuite/gcc.dg/declspec-11.c +++ b/gcc/testsuite/gcc.dg/declspec-11.c @@ -43,3 +43,5 @@ void i (void) { auto void y (void) {} } /* { dg-error "ISO C forbids nested func /* { dg-error "function definition declared 'auto'" "nested" { target *-*-* } 42 } */ inline int main (void) { return 0; } /* { dg-error "cannot inline function 'main'" } */ + +/* { dg-message "error: register name not specified for 'y'" "" { target *-*-* } 19 } */ diff --git a/gcc/testsuite/gcc.dg/declspec-9.c b/gcc/testsuite/gcc.dg/declspec-9.c index ece47c66fb1..7766ed6a4b8 100644 --- a/gcc/testsuite/gcc.dg/declspec-9.c +++ b/gcc/testsuite/gcc.dg/declspec-9.c @@ -17,7 +17,7 @@ void f6 (static int); /* { dg-error "storage class specified for unnamed paramet void f7 (typedef int); /* { dg-error "storage class specified for unnamed parameter" } */ auto int x; /* { dg-error "file-scope declaration of 'x' specifies 'auto'" } */ -register int y; +register int y; /* { dg-error "register name not specified for 'y'" } */ void h (void) { extern void x (void) {} } /* { dg-error "nested function 'x' declared 'extern'" } */ diff --git a/gcc/testsuite/gcc.dg/pr35899.c b/gcc/testsuite/gcc.dg/pr35899.c index 4ce4ac589f1..0dc4ffaa317 100644 --- a/gcc/testsuite/gcc.dg/pr35899.c +++ b/gcc/testsuite/gcc.dg/pr35899.c @@ -5,7 +5,7 @@ int foo (void) { - int a = bar (); /* { dg-message "note: previous implicit declaration" } */ + int a = bar (); /* { dg-error "returning 'void'" } */ return a; } @@ -13,3 +13,5 @@ void bar (void) /* { dg-warning "conflicting types for" } */ { } + +/* { dg-message "note: previous implicit declaration" "" { target *-*-* } 8 } */ diff --git a/gcc/testsuite/gcc.dg/pr36902.c b/gcc/testsuite/gcc.dg/pr36902.c index 43a2d14f981..8b4ba6fcdb2 100644 --- a/gcc/testsuite/gcc.dg/pr36902.c +++ b/gcc/testsuite/gcc.dg/pr36902.c @@ -44,7 +44,7 @@ foo2(unsigned char * to, const unsigned char * from, int n) *to = *from; break; case 5: - to[4] = from [4]; /* { dg-warning "array subscript is above array bounds" } */ + to[4] = from [4]; /* { dg-warning "20:array subscript is above array bounds" } */ break; } return to; diff --git a/gcc/testsuite/gcc.dg/redecl-10.c b/gcc/testsuite/gcc.dg/redecl-10.c index 88d804e6cfd..525961e7e3a 100644 --- a/gcc/testsuite/gcc.dg/redecl-10.c +++ b/gcc/testsuite/gcc.dg/redecl-10.c @@ -12,7 +12,7 @@ f (void) extern int w[] = { 1, 2 }; /* { dg-error "has both" } */ } -int x[]; +int x[]; /* { dg-warning "array 'x' assumed to have one element" } */ void g (void) { @@ -26,7 +26,7 @@ h (void) extern int y[] = { 6 }; /* { dg-error "has both" } */ } -int z[]; +int z[]; /* { dg-warning "array 'z' assumed to have one element" } */ void i (void) { diff --git a/gcc/testsuite/gcc.dg/redecl-17.c b/gcc/testsuite/gcc.dg/redecl-17.c new file mode 100644 index 00000000000..686ebc58971 --- /dev/null +++ b/gcc/testsuite/gcc.dg/redecl-17.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +void (*fp)(const int i); +void (*fp)(int i); + +void foo() +{ + (*fp)(0); +} + diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-5.c b/gcc/testsuite/gcc.dg/torture/builtin-math-5.c index d266e50aff0..259164107d8 100644 --- a/gcc/testsuite/gcc.dg/torture/builtin-math-5.c +++ b/gcc/testsuite/gcc.dg/torture/builtin-math-5.c @@ -18,6 +18,12 @@ extern void fool (_Complex long double); fool (__builtin_##FUNC##l (ARG##L)); \ } while (0) +#define TESTIT2(FUNC, ARG0, ARG1) do { \ + foof (__builtin_##FUNC##f (ARG0##F, ARG1##F)); \ + foo (__builtin_##FUNC (ARG0, ARG1)); \ + fool (__builtin_##FUNC##l (ARG0##L, ARG1##L)); \ +} while (0) + void bar() { /* An argument of NaN is not evaluated at compile-time. */ @@ -38,9 +44,80 @@ void bar() #endif foo (__builtin_csqrt (-__builtin_inf())); fool (__builtin_csqrtl (-__builtin_infl())); + + /* Check for overflow/underflow. */ + TESTIT (cexp, 1e20); + TESTIT (cexp, -1e20); + + /* An argument of NaN is not evaluated at compile-time. */ +#ifndef __SPU__ + foof (__builtin_cpowf (__builtin_nanf(""), 2.5F)); +#endif + foo (__builtin_cpow (__builtin_nan(""), 2.5)); + fool (__builtin_cpowl (__builtin_nanl(""), 2.5L)); +#ifndef __SPU__ + foof (__builtin_cpowf (2.5F, __builtin_nanf(""))); +#endif + foo (__builtin_cpow (2.5, __builtin_nan(""))); + fool (__builtin_cpowl (2.5L, __builtin_nanl(""))); + + /* An argument of Inf/-Inf is not evaluated at compile-time. */ +#ifndef __SPU__ + foof (__builtin_cpowf (__builtin_inff(), 2.5F)); +#endif + foo (__builtin_cpow (__builtin_inf(), 2.5)); + fool (__builtin_cpowl (__builtin_infl(), 2.5L)); +#ifndef __SPU__ + foof (__builtin_cpowf (-__builtin_inff(), 2.5F)); +#endif + foo (__builtin_cpow (-__builtin_inf(), 2.5)); + fool (__builtin_cpowl (-__builtin_infl(), 2.5L)); +#ifndef __SPU__ + foof (__builtin_cpowf (2.5F, __builtin_inff())); +#endif + foo (__builtin_cpow (2.5, __builtin_inf())); + fool (__builtin_cpowl (2.5L, __builtin_infl())); +#ifndef __SPU__ + foof (__builtin_cpowf (2.5F, -__builtin_inff())); +#endif + foo (__builtin_cpow (2.5, -__builtin_inf())); + fool (__builtin_cpowl (2.5L, -__builtin_infl())); + + /* Check for Inv/NaN return values. */ + TESTIT2 (cpow, -0.0, -4.5); /* Returns Inf */ + TESTIT2 (cpow, 0.0, -4.5); /* Returns Inf */ + + /* Check for overflow/underflow. */ + foof (__builtin_cpowf (__FLT_MAX__, 3.5F)); + foof (__builtin_cpowf (__FLT_MAX__ * 1.FI, 3.5F)); + foo (__builtin_cpow (__DBL_MAX__, 3.5)); + foo (__builtin_cpow (__DBL_MAX__ * 1.I, 3.5)); + fool (__builtin_cpowl (__LDBL_MAX__, 3.5L)); + fool (__builtin_cpowl (__LDBL_MAX__ * 1.LI, 3.5L)); + TESTIT2 (cpow, 2.0, 0x1p50); + TESTIT2 (cpow, 2.0, 0x1p28); + TESTIT2 (cpow, 2.0, 0x1p24); + foof (__builtin_cpowf (__FLT_MAX__, -3.5F)); + foof (__builtin_cpowf (__FLT_MAX__ * 1.FI, -3.5F)); + foo (__builtin_cpow (__DBL_MAX__, -3.5)); + foo (__builtin_cpow (__DBL_MAX__ * 1.I, -3.5)); + fool (__builtin_cpowl (__LDBL_MAX__, -3.5L)); + fool (__builtin_cpowl (__LDBL_MAX__ * 1.LI, -3.5L)); + TESTIT2 (cpow, 2.0, -0x1p50); + TESTIT2 (cpow, 2.0, -0x1p28); + TESTIT2 (cpow, 2.0, -0x1p24); + } -/* { dg-final { scan-tree-dump-times "csqrtf" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "csqrtf" 3 "original" { target { ! { spu*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times "csqrtf" 0 "original" { target { spu*-*-* } } } } */ /* { dg-final { scan-tree-dump-times "csqrt " 3 "original" } } */ /* { dg-final { scan-tree-dump-times "csqrtl" 3 "original" } } */ +/* { dg-final { scan-tree-dump-times "cexpf" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "cexp " 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "cexpl" 2 "original" } } */ +/* { dg-final { scan-tree-dump-times "cpowf" 18 "original" { target { ! { spu*-*-* } } } } } */ +/* { dg-final { scan-tree-dump-times "cpowf" 12 "original" { target { spu*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times "cpow " 18 "original" } } */ +/* { dg-final { scan-tree-dump-times "cpowl" 18 "original" } } */ /* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc/testsuite/gcc.dg/torture/builtin-math-6.c b/gcc/testsuite/gcc.dg/torture/builtin-math-6.c index 7fd1f729e2c..2c9b02b63d1 100644 --- a/gcc/testsuite/gcc.dg/torture/builtin-math-6.c +++ b/gcc/testsuite/gcc.dg/torture/builtin-math-6.c @@ -6,11 +6,13 @@ Origin: Kaveh R. Ghazi, January 28, 2009. */ /* { dg-do link } */ -/* { dg-require-effective-target mpc } */ +/* { dg-require-effective-target mpc_pow } */ /* All references to link_error should go away at compile-time. */ extern void link_error(int); +#define CONJ(X) __builtin_conjf(X) + /* Return TRUE if the signs of floating point values X and Y are not equal. This is important when comparing signed zeros. */ #define CKSGN_F(X,Y) \ @@ -42,6 +44,59 @@ extern void link_error(int); link_error(__LINE__); \ } while (0) +/* For complex numbers, call the TESTIT_COMPLEX macro for all + combinations of neg and conj. */ +#define TESTIT_COMPLEX_ALLNEG(FUNC, ARG, RES1, RES2, RES3, RES4) do { \ + TESTIT_COMPLEX(FUNC, (_Complex float)(ARG), RES1); \ + TESTIT_COMPLEX(FUNC, -CONJ(ARG), RES2); \ + TESTIT_COMPLEX(FUNC, CONJ(ARG), RES3); \ + TESTIT_COMPLEX(FUNC, -(_Complex float)(ARG), RES4); \ +} while (0) + +/* For complex numbers, call the TESTIT_COMPLEX_R macro for all + combinations of neg and conj. */ +#define TESTIT_COMPLEX_R_ALLNEG(FUNC, ARG, RES1, RES2, RES3, RES4) do { \ + TESTIT_COMPLEX_R(FUNC, (_Complex float)(ARG), RES1); \ + TESTIT_COMPLEX_R(FUNC, -CONJ(ARG), RES2); \ + TESTIT_COMPLEX_R(FUNC, CONJ(ARG), RES3); \ + TESTIT_COMPLEX_R(FUNC, -(_Complex float)(ARG), RES4); \ +} while (0) + +/* For complex numbers, test that FUNC(ARG0, ARG1) == (RES). */ +#define TESTIT_COMPLEX2(FUNC, ARG0, ARG1, RES) do { \ + if (__builtin_##FUNC##f(ARG0, ARG1) != (RES) \ + || COMPLEX_CKSGN_F(__builtin_##FUNC##f(ARG0, ARG1), (RES))) \ + link_error(__LINE__); \ + if (__builtin_##FUNC(ARG0, ARG1) != (RES) \ + || COMPLEX_CKSGN(__builtin_##FUNC(ARG0, ARG1), (RES))) \ + link_error(__LINE__); \ + if (__builtin_##FUNC##l(ARG0, ARG1) != (RES) \ + || COMPLEX_CKSGN_L(__builtin_##FUNC##l(ARG0, ARG1), (RES))) \ + link_error(__LINE__); \ + } while (0) + +/* For complex numbers, call the TESTIT_COMPLEX2 macro for all + combinations of neg and conj. */ +#define TESTIT_COMPLEX2_ALLNEG(FUNC, ARG0, ARG1, RES1, RES2, RES3, RES4, RES5,\ + RES6, RES7, RES8, RES9, RES10, RES11, RES12, RES13, RES14, RES15, RES16) do{ \ + TESTIT_COMPLEX2(FUNC, (_Complex float)(ARG0),(_Complex float)(ARG1), RES1);\ + TESTIT_COMPLEX2(FUNC, (_Complex float)(ARG0),CONJ(ARG1), RES2); \ + TESTIT_COMPLEX2(FUNC, (_Complex float)(ARG0),-(_Complex float)(ARG1), RES3); \ + TESTIT_COMPLEX2(FUNC, (_Complex float)(ARG0),-CONJ(ARG1), RES4); \ + TESTIT_COMPLEX2(FUNC, -(_Complex float)(ARG0),(_Complex float)(ARG1), RES5); \ + TESTIT_COMPLEX2(FUNC, -(_Complex float)(ARG0),CONJ(ARG1), RES6); \ + TESTIT_COMPLEX2(FUNC, -(_Complex float)(ARG0),-(_Complex float)(ARG1), RES7); \ + TESTIT_COMPLEX2(FUNC, -(_Complex float)(ARG0),-CONJ(ARG1), RES8); \ + TESTIT_COMPLEX2(FUNC, CONJ(ARG0),(_Complex float)(ARG1), RES9); \ + TESTIT_COMPLEX2(FUNC, CONJ(ARG0),CONJ(ARG1), RES10); \ + TESTIT_COMPLEX2(FUNC, CONJ(ARG0),-(_Complex float)(ARG1), RES11); \ + TESTIT_COMPLEX2(FUNC, CONJ(ARG0),-CONJ(ARG1), RES12); \ + TESTIT_COMPLEX2(FUNC, -CONJ(ARG0),(_Complex float)(ARG1), RES13); \ + TESTIT_COMPLEX2(FUNC, -CONJ(ARG0),CONJ(ARG1), RES14); \ + TESTIT_COMPLEX2(FUNC, -CONJ(ARG0),-(_Complex float)(ARG1), RES15); \ + TESTIT_COMPLEX2(FUNC, -CONJ(ARG0),-CONJ(ARG1), RES16); \ +} while (0) + /* Return TRUE if X differs from EXPECTED by more than 1%. If EXPECTED is zero, then any difference may return TRUE. We don't worry about signed zeros. */ @@ -81,87 +136,126 @@ extern void link_error(int); link_error(__LINE__); \ } while (0) +/* Range test, for complex numbers check that FUNC(ARG0, ARG1) is + within 1% of RES. This is NOT a test for accuracy to the last-bit, + we're merely checking that we get relatively sane results. + I.e. the GCC builtin is hooked up to the correct MPC function call. + We first check the magnitude and then the sign. */ +#define TESTIT_COMPLEX_R2(FUNC, ARG0, ARG1, RES) do { \ + if (COMPLEX_DIFF1PCT_F (__builtin_##FUNC##f(ARG0, ARG1), (RES)) \ + || COMPLEX_CKSGN_F (__builtin_##FUNC##f(ARG0, ARG1), (RES))) \ + link_error(__LINE__); \ + if (COMPLEX_DIFF1PCT (__builtin_##FUNC(ARG0, ARG1), (RES)) \ + || COMPLEX_CKSGN (__builtin_##FUNC(ARG0, ARG1), (RES))) \ + link_error(__LINE__); \ + if (COMPLEX_DIFF1PCT_L (__builtin_##FUNC##l(ARG0, ARG1), (RES)) \ + || COMPLEX_CKSGN_L (__builtin_##FUNC##l(ARG0, ARG1), (RES))) \ + link_error(__LINE__); \ + } while (0) + +/* For complex numbers, call the TESTIT_COMPLEX_R2 macro for all + combinations of neg and conj. */ +#define TESTIT_COMPLEX_R2_ALLNEG(FUNC, ARG0, ARG1, RES1, RES2, RES3, RES4, RES5,\ + RES6, RES7, RES8, RES9, RES10, RES11, RES12, RES13, RES14, RES15, RES16) do{ \ + TESTIT_COMPLEX_R2(FUNC, (_Complex float)(ARG0),(_Complex float)(ARG1), RES1);\ + TESTIT_COMPLEX_R2(FUNC, (_Complex float)(ARG0),CONJ(ARG1), RES2); \ + TESTIT_COMPLEX_R2(FUNC, (_Complex float)(ARG0),-(_Complex float)(ARG1), RES3); \ + TESTIT_COMPLEX_R2(FUNC, (_Complex float)(ARG0),-CONJ(ARG1), RES4); \ + TESTIT_COMPLEX_R2(FUNC, -(_Complex float)(ARG0),(_Complex float)(ARG1), RES5); \ + TESTIT_COMPLEX_R2(FUNC, -(_Complex float)(ARG0),CONJ(ARG1), RES6); \ + TESTIT_COMPLEX_R2(FUNC, -(_Complex float)(ARG0),-(_Complex float)(ARG1), RES7); \ + TESTIT_COMPLEX_R2(FUNC, -(_Complex float)(ARG0),-CONJ(ARG1), RES8); \ + TESTIT_COMPLEX_R2(FUNC, CONJ(ARG0),(_Complex float)(ARG1), RES9); \ + TESTIT_COMPLEX_R2(FUNC, CONJ(ARG0),CONJ(ARG1), RES10); \ + TESTIT_COMPLEX_R2(FUNC, CONJ(ARG0),-(_Complex float)(ARG1), RES11); \ + TESTIT_COMPLEX_R2(FUNC, CONJ(ARG0),-CONJ(ARG1), RES12); \ + TESTIT_COMPLEX_R2(FUNC, -CONJ(ARG0),(_Complex float)(ARG1), RES13); \ + TESTIT_COMPLEX_R2(FUNC, -CONJ(ARG0),CONJ(ARG1), RES14); \ + TESTIT_COMPLEX_R2(FUNC, -CONJ(ARG0),-(_Complex float)(ARG1), RES15); \ + TESTIT_COMPLEX_R2(FUNC, -CONJ(ARG0),-CONJ(ARG1), RES16); \ +} while (0) + int main (void) { - TESTIT_COMPLEX (csin, 0.0F, 0.0F); - TESTIT_COMPLEX (csin, -0.0F, -0.0F); - TESTIT_COMPLEX (csin, __builtin_conjf(0.0F), __builtin_conjf(0.0F)); - TESTIT_COMPLEX (csin, __builtin_conjf(-0.0F), __builtin_conjf(-0.0F)); - - TESTIT_COMPLEX_R (csin, 3.45678F + 2.34567FI, -1.633059F - 4.917448FI); - TESTIT_COMPLEX_R (csin, 3.45678F - 2.34567FI, -1.633059F + 4.917448FI); - TESTIT_COMPLEX_R (csin, -3.45678F + 2.34567FI, 1.633059F - 4.917448FI); - TESTIT_COMPLEX_R (csin, -3.45678F - 2.34567FI, 1.633059F + 4.917448FI); + TESTIT_COMPLEX_ALLNEG (csin, 0, + 0, -0.F, + CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (csin, 3.45678F + 2.34567FI, + -1.633059F - 4.917448FI, 1.633059F - 4.917448FI, + -1.633059F + 4.917448FI, 1.633059F + 4.917448FI); + + TESTIT_COMPLEX_ALLNEG (ccos, 0, + CONJ(1), 1, 1, CONJ(1)); + TESTIT_COMPLEX_R_ALLNEG (ccos, 3.45678F + 2.34567FI, + -5.008512F + 1.603367FI, -5.008512F - 1.603367FI, + -5.008512F - 1.603367FI, -5.008512F + 1.603367FI); + + TESTIT_COMPLEX_ALLNEG (ctan, 0, + 0, -0.F, CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (ctan, 3.45678F + 2.34567FI, + 0.010657F + 0.985230FI, -0.010657F + 0.985230FI, + 0.010657F - 0.985230FI, -0.010657F - 0.985230FI); + + TESTIT_COMPLEX_ALLNEG (csinh, 0, + 0, -0.F, CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (csinh, 3.45678F + 2.34567FI, + -11.083178F + 11.341487FI, 11.083178F +11.341487FI, + -11.083178F - 11.341487FI, 11.083178F -11.341487FI); - TESTIT_COMPLEX (ccos, 0.0F, __builtin_conjf(1.0F)); - TESTIT_COMPLEX (ccos, -0.0F, 1.0F); - TESTIT_COMPLEX (ccos, __builtin_conjf(0.0F), 1.0F); - TESTIT_COMPLEX (ccos, __builtin_conjf(-0.0F), __builtin_conjf(1.0F)); - - TESTIT_COMPLEX_R (ccos, 3.45678F + 2.34567FI, -5.008512F + 1.603367FI); - TESTIT_COMPLEX_R (ccos, 3.45678F - 2.34567FI, -5.008512F - 1.603367FI); - TESTIT_COMPLEX_R (ccos, -3.45678F + 2.34567FI, -5.008512F - 1.603367FI); - TESTIT_COMPLEX_R (ccos, -3.45678F - 2.34567FI, -5.008512F + 1.603367FI); - - TESTIT_COMPLEX (ctan, 0.0F, 0.0F); - TESTIT_COMPLEX (ctan, -0.0F, -0.0F); - TESTIT_COMPLEX (ctan, __builtin_conjf(0.0F), __builtin_conjf(0.0F)); - TESTIT_COMPLEX (ctan, __builtin_conjf(-0.0F), __builtin_conjf(-0.0F)); - - TESTIT_COMPLEX_R (ctan, 3.45678F + 2.34567FI, 0.010657F + 0.985230FI); - TESTIT_COMPLEX_R (ctan, 3.45678F - 2.34567FI, 0.010657F - 0.985230FI); - TESTIT_COMPLEX_R (ctan, -3.45678F + 2.34567FI, -0.010657F + 0.985230FI); - TESTIT_COMPLEX_R (ctan, -3.45678F - 2.34567FI, -0.010657F - 0.985230FI); - - TESTIT_COMPLEX (csinh, 0.0F, 0.0F); - TESTIT_COMPLEX (csinh, -0.0F, -0.0F); - TESTIT_COMPLEX (csinh, __builtin_conjf(0.0F), __builtin_conjf(0.0F)); - TESTIT_COMPLEX (csinh, __builtin_conjf(-0.0F), __builtin_conjf(-0.0F)); - - TESTIT_COMPLEX_R (csinh, 3.45678F + 2.34567FI, -11.083178F + 11.341487FI); - TESTIT_COMPLEX_R (csinh, 3.45678F - 2.34567FI, -11.083178F - 11.341487FI); - TESTIT_COMPLEX_R (csinh, -3.45678F + 2.34567FI, 11.083178F + 11.341487FI); - TESTIT_COMPLEX_R (csinh, -3.45678F - 2.34567FI, 11.083178F - 11.341487FI); - - TESTIT_COMPLEX (ccosh, 0.0F, 1.0F); - TESTIT_COMPLEX (ccosh, -0.0F, __builtin_conjf(1.0F)); - TESTIT_COMPLEX (ccosh, __builtin_conjf(0.0F), __builtin_conjf(1.0F)); - TESTIT_COMPLEX (ccosh, __builtin_conjf(-0.0F), 1.0F); - - TESTIT_COMPLEX_R (ccosh, 3.45678F + 2.34567FI, -11.105238F + 11.318958FI); - TESTIT_COMPLEX_R (ccosh, 3.45678F - 2.34567FI, -11.105238F - 11.318958FI); - TESTIT_COMPLEX_R (ccosh, -3.45678F + 2.34567FI, -11.105238F - 11.318958FI); - TESTIT_COMPLEX_R (ccosh, -3.45678F - 2.34567FI, -11.105238F + 11.318958FI); - - TESTIT_COMPLEX (ctanh, 0.0F, 0.0F); - TESTIT_COMPLEX (ctanh, -0.0F, -0.0F); - TESTIT_COMPLEX (ctanh, __builtin_conjf(0.0F), __builtin_conjf(0.0F)); - TESTIT_COMPLEX (ctanh, __builtin_conjf(-0.0F), __builtin_conjf(-0.0F)); - - TESTIT_COMPLEX_R (ctanh, 3.45678F + 2.34567FI, 1.000040F - 0.001988FI); - TESTIT_COMPLEX_R (ctanh, 3.45678F - 2.34567FI, 1.000040F + 0.001988FI); - TESTIT_COMPLEX_R (ctanh, -3.45678F + 2.34567FI, -1.000040F - 0.001988FI); - TESTIT_COMPLEX_R (ctanh, -3.45678F - 2.34567FI, -1.000040F + 0.001988FI); - - TESTIT_COMPLEX (clog, 1.0F, 0.0F); - TESTIT_COMPLEX_R (clog, -1.0F, 3.141593FI); - TESTIT_COMPLEX (clog, __builtin_conjf(1.0F), __builtin_conjf(0.0F)); /* Fails with mpc-0.6. */ - TESTIT_COMPLEX_R (clog, __builtin_conjf(-1.0F), __builtin_conjf(3.141593FI)); /* Fails with mpc-0.6. */ - - TESTIT_COMPLEX_R (clog, 3.45678F + 2.34567FI, 1.429713F + 0.596199FI); - TESTIT_COMPLEX_R (clog, 3.45678F - 2.34567FI, 1.429713F - 0.596199FI); - TESTIT_COMPLEX_R (clog, -3.45678F + 2.34567FI, 1.429713F + 2.545394FI); - TESTIT_COMPLEX_R (clog, -3.45678F - 2.34567FI, 1.429713F - 2.545394FI); - - TESTIT_COMPLEX (csqrt, 0.0F, 0.0F); - TESTIT_COMPLEX (csqrt, -0.0F, 0.0F); - TESTIT_COMPLEX (csqrt, __builtin_conjf(0.0F), __builtin_conjf(0.0F)); - TESTIT_COMPLEX (csqrt, __builtin_conjf(-0.0F), __builtin_conjf(0.0F)); - - TESTIT_COMPLEX_R (csqrt, 3.45678F + 2.34567FI, 1.953750F + 0.600299FI); - TESTIT_COMPLEX_R (csqrt, 3.45678F - 2.34567FI, 1.953750F - 0.600299FI); - TESTIT_COMPLEX_R (csqrt, -3.45678F + 2.34567FI, 0.600299F + 1.953750FI); - TESTIT_COMPLEX_R (csqrt, -3.45678F - 2.34567FI, 0.600299F - 1.953750FI); + TESTIT_COMPLEX_ALLNEG (ccosh, 0, + 1, CONJ(1), CONJ(1), 1); + TESTIT_COMPLEX_R_ALLNEG (ccosh, 3.45678F + 2.34567FI, + -11.105238F + 11.318958FI,-11.105238F -11.318958FI, + -11.105238F - 11.318958FI,-11.105238F +11.318958FI); + + TESTIT_COMPLEX_ALLNEG (ctanh, 0, + 0, -0.F, CONJ(0), CONJ(-0.F)); + TESTIT_COMPLEX_R_ALLNEG (ctanh, 3.45678F + 2.34567FI, + 1.000040F - 0.001988FI, -1.000040F - 0.001988FI, + 1.000040F + 0.001988FI, -1.000040F + 0.001988FI); + + TESTIT_COMPLEX (clog, 1, 0); + TESTIT_COMPLEX_R (clog, -1, 3.141593FI); + TESTIT_COMPLEX (clog, CONJ(1), CONJ(0)); /* Fails with mpc-0.6. */ + TESTIT_COMPLEX_R (clog, CONJ(-1), CONJ(3.141593FI)); /* Fails with mpc-0.6. */ + TESTIT_COMPLEX_R_ALLNEG (clog, 3.45678F + 2.34567FI, + 1.429713F + 0.596199FI, 1.429713F + 2.545394FI, + 1.429713F - 0.596199FI, 1.429713F - 2.545394FI); + + TESTIT_COMPLEX_ALLNEG (csqrt, 0, + 0, 0, CONJ(0), CONJ(0)); + TESTIT_COMPLEX_R_ALLNEG (csqrt, 3.45678F + 2.34567FI, + 1.953750F + 0.600299FI, 0.600299F + 1.953750FI, + 1.953750F - 0.600299FI, 0.600299F - 1.953750FI); + + TESTIT_COMPLEX2_ALLNEG (cpow, 1, 0, + 1, 1, CONJ(1), CONJ(1), 1, CONJ(1), 1, 1, + CONJ(1), CONJ(1), 1, 1, 1, 1, CONJ(1), 1); + TESTIT_COMPLEX2_ALLNEG (cpow, 1.FI, 0, + 1, 1, CONJ(1), 1, 1, CONJ(1), 1, 1, + 1, CONJ(1), 1, 1, 1, 1, CONJ(1), 1); + TESTIT_COMPLEX_R2_ALLNEG (cpow, 2, 3, + 8, 8, CONJ(1/8.F), 1/8.F, CONJ(-8), -8, -1/8.F, -1/8.F, + 8, CONJ(8), 1/8.F, 1/8.F, -8, -8, -1/8.F, CONJ(-1/8.F)); + TESTIT_COMPLEX_R2_ALLNEG (cpow, 3, 4, + 81, 81, CONJ(1/81.F), 1/81.F, 81, 81, CONJ(1/81.F), 1/81.F, + 81, CONJ(81), 1/81.F, 1/81.F, 81, CONJ(81), 1/81.F, 1/81.F); + TESTIT_COMPLEX_R2_ALLNEG (cpow, 3, 5, + 243, 243, CONJ(1/243.F), 1/243.F, CONJ(-243), -243, -1/243.F, -1/243.F, + 243, CONJ(243), 1/243.F, 1/243.F, -243, -243, -1/243.F, CONJ(-1/243.F)); + TESTIT_COMPLEX_R2_ALLNEG (cpow, 4, 2, + 16, 16, CONJ(1/16.F), 1/16.F, 16, 16, CONJ(1/16.F), 1/16.F, + 16, CONJ(16), 1/16.F, 1/16.F, 16, CONJ(16), 1/16.F, 1/16.F); + TESTIT_COMPLEX_R2_ALLNEG (cpow, 1.5, 3, + 3.375F, 3.375F, CONJ(1/3.375F), 1/3.375F, CONJ(-3.375F), -3.375F, -1/3.375F, -1/3.375F, + 3.375F, CONJ(3.375F), 1/3.375F, 1/3.375F, -3.375F, -3.375F, -1/3.375F, CONJ(-1/3.375F)); + + TESTIT_COMPLEX2 (cpow, 16, 0.25F, 2); + TESTIT_COMPLEX_R2 (cpow, 3.45678F + 2.34567FI, 1.23456 + 4.56789FI, 0.212485F + 0.319304FI); + TESTIT_COMPLEX_R2 (cpow, 3.45678F - 2.34567FI, 1.23456 + 4.56789FI, 78.576402F + -41.756208FI); + TESTIT_COMPLEX_R2 (cpow, -1.23456F + 2.34567FI, 2.34567 - 1.23456FI, -110.629847F + -57.021655FI); + TESTIT_COMPLEX_R2 (cpow, -1.23456F - 2.34567FI, 2.34567 - 1.23456FI, 0.752336F + 0.199095FI); + return 0; } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c b/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c index 8f319594f84..3426827783c 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/loop-2.c @@ -38,7 +38,7 @@ void xxx(void) and replaced by comparison of one of the newly created ivs. */ /* { dg-final { scan-tree-dump-times "iter" 0 "optimized" } } */ -/* { dg-final { scan-tree-dump-times "99" 0 "optimized" } } */ -/* { dg-final { scan-tree-dump-times "100" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "= 99" 0 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "< 100" 0 "optimized" } } */ /* { dg-final { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr39082-1.c b/gcc/testsuite/gcc.target/i386/pr39082-1.c index 4c4e2547a88..81b5bb66d2b 100644 --- a/gcc/testsuite/gcc.target/i386/pr39082-1.c +++ b/gcc/testsuite/gcc.target/i386/pr39082-1.c @@ -13,7 +13,7 @@ extern int bar1 (union un); extern union un bar2 (int); int -foo1 (union un u) /* { dg-message "note: The ABI of passing union with long double has changed in GCC 4.4" } */ +foo1 (union un u) { bar1 (u); return u.i; @@ -30,6 +30,6 @@ foo2 (void) int foo3 (int x) { - union un u = bar2 (x); + union un u = bar2 (x); /* { dg-message "note: The ABI of passing union with long double has changed in GCC 4.4" } */ return u.i; } diff --git a/gcc/testsuite/gcc.target/i386/pr39545-1.c b/gcc/testsuite/gcc.target/i386/pr39545-1.c index 62bc33fa21d..281c8cbf369 100644 --- a/gcc/testsuite/gcc.target/i386/pr39545-1.c +++ b/gcc/testsuite/gcc.target/i386/pr39545-1.c @@ -10,14 +10,14 @@ struct flex }; int -foo (struct flex s) /* { dg-message "note: The ABI of passing struct with a flexible array member has changed in GCC 4.4" } */ +foo (struct flex s) { return s.i; } struct flex bar (int x) -{ +{ /* { dg-message "note: The ABI of passing struct with a flexible array member has changed in GCC 4.4" } */ struct flex s; s.i = x; return s; diff --git a/gcc/testsuite/gcc.target/mips/ext-2.c b/gcc/testsuite/gcc.target/mips/ext-2.c new file mode 100644 index 00000000000..8d502b21b10 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/ext-2.c @@ -0,0 +1,14 @@ +/* Turn the truncate,zero_extend,lshiftrt sequence before the or into a + zero_extract. The truncate is due to TARGET_PROMOTE_PROTOTYPES, the + zero_extend to PROMOTE_MODE. */ +/* { dg-do compile } */ +/* { dg-options "-O isa_rev>=2 -mgp64" } */ +/* { dg-final { scan-assembler "\tdext\t" } } */ +/* { dg-final { scan-assembler-not "and" } } */ +/* { dg-final { scan-assembler-not "srl" } } */ + +void +f (unsigned char x, unsigned char *r) +{ + *r = 0x50 | (x >> 4); +} diff --git a/gcc/testsuite/gcc.target/mips/octeon-exts-2.c b/gcc/testsuite/gcc.target/mips/octeon-exts-2.c index 42f2a3f8586..fc5df639d02 100644 --- a/gcc/testsuite/gcc.target/mips/octeon-exts-2.c +++ b/gcc/testsuite/gcc.target/mips/octeon-exts-2.c @@ -1,7 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O -march=octeon -meb -dp" } */ -/* Don't match exts in sign-extension. */ -/* { dg-final { scan-assembler-times "\texts\t\[^\\n\]*extv" 4 } } */ +/* { dg-options "-O -march=octeon -meb" } */ +/* { dg-final { scan-assembler-times "\texts\t" 4 } } */ struct bar { diff --git a/gcc/testsuite/gcc.target/mips/octeon-exts-5.c b/gcc/testsuite/gcc.target/mips/octeon-exts-5.c index 6ec7ac7296f..e7a4738b96f 100644 --- a/gcc/testsuite/gcc.target/mips/octeon-exts-5.c +++ b/gcc/testsuite/gcc.target/mips/octeon-exts-5.c @@ -1,8 +1,7 @@ /* -mel version of octeon-exts-2.c. */ /* { dg-do compile } */ -/* { dg-options "-O -march=octeon -mel -dp" } */ -/* Don't match exts in sign-extension. */ -/* { dg-final { scan-assembler-times "\texts\t\[^\\n\]*extv" 4 } } */ +/* { dg-options "-O -march=octeon -mel" } */ +/* { dg-final { scan-assembler-times "\texts\t" 4 } } */ struct bar { diff --git a/gcc/testsuite/gcc.target/mips/octeon-exts-7.c b/gcc/testsuite/gcc.target/mips/octeon-exts-7.c new file mode 100644 index 00000000000..04805d06de4 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/octeon-exts-7.c @@ -0,0 +1,17 @@ +/* Remove the redundant sign-extension after the sign-extraction. */ +/* { dg-do compile } */ +/* { dg-options "-O -march=octeon -mgp64" } */ +/* { dg-final { scan-assembler-times "\texts\t" 1 } } */ +/* { dg-final { scan-assembler-not "sll|sra" } } */ + +struct bar +{ + long long a:18; + long long b:14; +}; + +NOMIPS16 int +f1 (struct bar *s) +{ + return s->b; +} diff --git a/gcc/testsuite/gcc.target/powerpc/asm-es-1.c b/gcc/testsuite/gcc.target/powerpc/asm-es-1.c new file mode 100644 index 00000000000..fe3e899d5a2 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/asm-es-1.c @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +static inline void __attribute__((always_inline)) +f1 (void) +{ + long unused; + asm volatile ("" : "=es" (unused) :: "memory"); +} + +static void __attribute__((noinline)) +f2 (long *val) +{ + *val = 0x1234; +} + +static long __attribute__((noinline)) +test (void) +{ + f1 (); + { + long val; + f2 (&val); + return val; + } +} + +int +main (void) +{ + return test () != 0x1234; +} diff --git a/gcc/testsuite/gcc.target/powerpc/asm-es-2.c b/gcc/testsuite/gcc.target/powerpc/asm-es-2.c new file mode 100644 index 00000000000..e9319654cc7 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/asm-es-2.c @@ -0,0 +1,37 @@ +/* { dg-options "-O2" } */ +void +f1 (int *p, int x) +{ + asm ("asm1 %0" : "=es" (p[x])); +} + +void +f2 (int *p) +{ + while (1) + { + p += 4; + asm ("asm2%U0 %0" : "=m" (*p)); + } +} + +void +f3 (int *p) +{ + while (1) + { + p += 4; + asm ("asm3%U0 %0" : "=es" (*p)); + } +} + +void +f4 (int *p) +{ + asm ("asm4 %0" : "=es" (p[100])); +} + +/* { dg-final { scan-assembler "asm1 3,4" } } */ +/* { dg-final { scan-assembler "asm2u 16\\(3\\)" } } */ +/* { dg-final { scan-assembler "asm3 0\\(3\\)" } } */ +/* { dg-final { scan-assembler "asm4 400\\(3\\)" } } */ diff --git a/gcc/testsuite/gfortran.dg/cshift_bounds_1.f90 b/gcc/testsuite/gfortran.dg/cshift_bounds_1.f90 new file mode 100644 index 00000000000..5932004f2f3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/cshift_bounds_1.f90 @@ -0,0 +1,24 @@ +! { dg-do run } +! { dg-options "-fbounds-check" } +! Check that empty arrays are handled correctly in +! cshift and eoshift +program main + character(len=50) :: line + character(len=3), dimension(2,2) :: a, b + integer :: n1, n2 + line = '-1-2' + read (line,'(2I2)') n1, n2 + call foo(a, b, n1, n2) + a = 'abc' + write (line,'(4A)') eoshift(a, 3) + write (line,'(4A)') cshift(a, 3) + write (line,'(4A)') cshift(a(:,1:n1), 3) + write (line,'(4A)') eoshift(a(1:n2,:), 3) +end program main + +subroutine foo(a, b, n1, n2) + character(len=3), dimension(2, n1) :: a + character(len=3), dimension(n2, 2) :: b + a = cshift(b,1) + a = eoshift(b,1) +end subroutine foo diff --git a/gcc/testsuite/gfortran.dg/cshift_bounds_2.f90 b/gcc/testsuite/gfortran.dg/cshift_bounds_2.f90 new file mode 100644 index 00000000000..8d7e779eacd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/cshift_bounds_2.f90 @@ -0,0 +1,11 @@ +! { dg-do run } +! { dg-options "-fbounds-check" } +! { dg-shouldfail "Incorrect extent in return value of CSHIFT intrinsic in dimension 2: is 3, should be 2" } +program main + integer, dimension(:,:), allocatable :: a, b + allocate (a(2,2)) + allocate (b(2,3)) + a = 1 + b = cshift(a,1) +end program main +! { dg-output "Fortran runtime error: Incorrect extent in return value of CSHIFT intrinsic in dimension 2: is 3, should be 2" } diff --git a/gcc/testsuite/gfortran.dg/cshift_bounds_3.f90 b/gcc/testsuite/gfortran.dg/cshift_bounds_3.f90 new file mode 100644 index 00000000000..33e387f3248 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/cshift_bounds_3.f90 @@ -0,0 +1,12 @@ +! { dg-do run } +! { dg-options "-fbounds-check" } +! { dg-shouldfail "Incorrect size in SHIFT argument of CSHIFT intrinsic: should not be zero-sized" } +program main + real, dimension(1,0) :: a, b, c + integer :: sp(3), i + a = 4.0 + sp = 1 + i = 1 + b = cshift (a,sp(1:i)) ! Invalid +end program main +! { dg-output "Fortran runtime error: Incorrect size in SHIFT argument of CSHIFT intrinsic: should not be zero-sized" } diff --git a/gcc/testsuite/gfortran.dg/cshift_bounds_4.f90 b/gcc/testsuite/gfortran.dg/cshift_bounds_4.f90 new file mode 100644 index 00000000000..4a3fcfbd1de --- /dev/null +++ b/gcc/testsuite/gfortran.dg/cshift_bounds_4.f90 @@ -0,0 +1,13 @@ +! { dg-do run } +! { dg-shouldfail "Incorrect extent in SHIFT argument of CSHIFT intrinsic in dimension 1: is 3, should be 2" } +! { dg-options "-fbounds-check" } +program main + integer, dimension(:,:), allocatable :: a, b + integer, dimension(:), allocatable :: sh + allocate (a(2,2)) + allocate (b(2,2)) + allocate (sh(3)) + a = 1 + b = cshift(a,sh) +end program main +! { dg-output "Fortran runtime error: Incorrect extent in SHIFT argument of CSHIFT intrinsic in dimension 1: is 3, should be 2" } diff --git a/gcc/testsuite/gfortran.dg/eof_3.f90 b/gcc/testsuite/gfortran.dg/eof_3.f90 new file mode 100644 index 00000000000..83d652912bc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/eof_3.f90 @@ -0,0 +1,8 @@ +! { dg-do run } +! PR40714 A read hitting EOF should leave the unit structure in a correct state +program test +open(unit=32,status="scratch",access="sequential",form="unformatted") +read(32,end=100) +100 continue +write (32) +end program test diff --git a/gcc/testsuite/gfortran.dg/eoshift_bounds_1.f90 b/gcc/testsuite/gfortran.dg/eoshift_bounds_1.f90 new file mode 100644 index 00000000000..f3234155636 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/eoshift_bounds_1.f90 @@ -0,0 +1,12 @@ +! { dg-do run } +! { dg-options "-fbounds-check" } +! { dg-shouldfail "Incorrect size in SHIFT argument of EOSHIFT intrinsic: should not be zero-sized" } +program main + real, dimension(1,0) :: a, b, c + integer :: sp(3), i + a = 4.0 + sp = 1 + i = 1 + b = eoshift (a,sp(1:i)) ! Invalid +end program main +! { dg-output "Fortran runtime error: Incorrect size in SHIFT argument of EOSHIFT intrinsic: should not be zero-sized" } diff --git a/gcc/testsuite/gfortran.dg/interface_assignment_4.f90 b/gcc/testsuite/gfortran.dg/interface_assignment_4.f90 new file mode 100644 index 00000000000..535e8842549 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/interface_assignment_4.f90 @@ -0,0 +1,35 @@ +! { dg-do compile } +! +! PR 40743: [4.5 Regression] ICE when compiling iso_varying_string.f95 at revision 149591 +! +! Reduced from http://www.fortran.com/iso_varying_string.f95 +! Contributed by Janus Weil <janus@gcc.gnu.org> + + implicit none + + type :: varying_string + end type + + interface assignment(=) + procedure op_assign_VS_CH + end interface + +contains + + subroutine op_assign_VS_CH (var, exp) + type(varying_string), intent(out) :: var + character(LEN=*), intent(in) :: exp + end subroutine + + subroutine split_VS + type(varying_string) :: string + call split_CH(string) + end subroutine + + subroutine split_CH (string) + type(varying_string) :: string + string = "" + end subroutine + +end + diff --git a/gcc/testsuite/gfortran.dg/intrinsic_cmplx.f90 b/gcc/testsuite/gfortran.dg/intrinsic_cmplx.f90 new file mode 100644 index 00000000000..744e77a85a4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/intrinsic_cmplx.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/40727 +program test + integer, parameter :: sp = kind(1.e0), dp = kind(1.d0) + complex(sp) :: s + complex(dp) :: d + s = cmplx(0.e0, cmplx(0.e0,0.e0)) ! { dg-error "either REAL or INTEGER" } + d = dcmplx(0.d0, cmplx(0.d0,0.d0)) ! { dg-error "either REAL or INTEGER" } +end program test diff --git a/gcc/testsuite/gfortran.dg/maxloc_bounds_4.f90 b/gcc/testsuite/gfortran.dg/maxloc_bounds_4.f90 index 5a38813a72e..7ba103d6168 100644 --- a/gcc/testsuite/gfortran.dg/maxloc_bounds_4.f90 +++ b/gcc/testsuite/gfortran.dg/maxloc_bounds_4.f90 @@ -1,6 +1,6 @@ ! { dg-do run } ! { dg-options "-fbounds-check" } -! { dg-shouldfail "Incorrect extent in return value of MAXLOC intrnisic: is 3, should be 2" } +! { dg-shouldfail "Incorrect extent in return value of MAXLOC intrinsic: is 3, should be 2" } module tst contains subroutine foo(res) @@ -18,6 +18,6 @@ program main integer :: res(3) call foo(res) end program main -! { dg-output "Fortran runtime error: Incorrect extent in return value of MAXLOC intrnisic: is 3, should be 2" } +! { dg-output "Fortran runtime error: Incorrect extent in return value of MAXLOC intrinsic: is 3, should be 2" } ! { dg-final { cleanup-modules "tst" } } diff --git a/gcc/testsuite/gfortran.dg/maxloc_bounds_5.f90 b/gcc/testsuite/gfortran.dg/maxloc_bounds_5.f90 index 42e19e5a1e0..34d06da55ac 100644 --- a/gcc/testsuite/gfortran.dg/maxloc_bounds_5.f90 +++ b/gcc/testsuite/gfortran.dg/maxloc_bounds_5.f90 @@ -1,6 +1,6 @@ ! { dg-do run } ! { dg-options "-fbounds-check" } -! { dg-shouldfail "Incorrect extent in return value of MAXLOC intrnisic: is 3, should be 2" } +! { dg-shouldfail "Incorrect extent in return value of MAXLOC intrinsic: is 3, should be 2" } module tst contains subroutine foo(res) @@ -18,5 +18,5 @@ program main integer :: res(3) call foo(res) end program main -! { dg-output "Fortran runtime error: Incorrect extent in return value of MAXLOC intrnisic: is 3, should be 2" } +! { dg-output "Fortran runtime error: Incorrect extent in return value of MAXLOC intrinsic: is 3, should be 2" } ! { dg-final { cleanup-modules "tst" } } diff --git a/gcc/testsuite/gfortran.dg/maxloc_bounds_7.f90 b/gcc/testsuite/gfortran.dg/maxloc_bounds_7.f90 index 2194eee35a4..817bf8fac39 100644 --- a/gcc/testsuite/gfortran.dg/maxloc_bounds_7.f90 +++ b/gcc/testsuite/gfortran.dg/maxloc_bounds_7.f90 @@ -1,6 +1,6 @@ ! { dg-do run } ! { dg-options "-fbounds-check" } -! { dg-shouldfail "Incorrect extent in return value of MAXLOC intrnisic: is 3, should be 2" } +! { dg-shouldfail "Incorrect extent in return value of MAXLOC intrinsic: is 3, should be 2" } module tst contains subroutine foo(res) @@ -18,5 +18,5 @@ program main integer :: res(3) call foo(res) end program main -! { dg-output "Fortran runtime error: Incorrect extent in return value of MAXLOC intrnisic: is 3, should be 2" } +! { dg-output "Fortran runtime error: Incorrect extent in return value of MAXLOC intrinsic: is 3, should be 2" } ! { dg-final { cleanup-modules "tst" } } diff --git a/gcc/testsuite/gfortran.dg/missing_optional_dummy_5.f90 b/gcc/testsuite/gfortran.dg/missing_optional_dummy_5.f90 index 4ad399e8a98..29a9d70f899 100644 --- a/gcc/testsuite/gfortran.dg/missing_optional_dummy_5.f90 +++ b/gcc/testsuite/gfortran.dg/missing_optional_dummy_5.f90 @@ -23,7 +23,7 @@ contains end function tm_doit end module krmod -! { dg-final { scan-tree-dump " tm_doit \\(&parm.\(6|7\), 0B, 0\\);" "original" } } +! { dg-final { scan-tree-dump " tm_doit \\(&parm\.., 0B, 0\\);" "original" } } ! { dg-final { cleanup-tree-dump "original" } } ! { dg-final { cleanup-modules "krmod" } } diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index d34f4156f7a..306e78fcbb1 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -2998,3 +2998,16 @@ proc check_effective_target_mpc { } { } }] } + +# Return 1 if the MPC library with mpc_pow is integrated with GCC, 0 otherwise. + +proc check_effective_target_mpc_pow { } { + return [check_no_compiler_messages mpc executable { + extern void link_error(void); + int main () + { + if (__builtin_cpow(1,1) != 1) + link_error(); + } + }] +} diff --git a/gcc/testsuite/obj-c++.dg/defs.mm b/gcc/testsuite/obj-c++.dg/defs.mm index 3027985ed0c..8b67aab4b9a 100644 --- a/gcc/testsuite/obj-c++.dg/defs.mm +++ b/gcc/testsuite/obj-c++.dg/defs.mm @@ -8,7 +8,7 @@ #include <objc/objc.h> #include <objc/Object.h> -extern void abort(void); +extern "C" void abort(void); @interface A : Object { diff --git a/gcc/toplev.c b/gcc/toplev.c index 717fbcb7c9e..c6d491e93f8 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1046,6 +1046,8 @@ compile_file (void) ggc_protect_identifiers = false; + /* This must also call cgraph_finalize_compilation_unit and + cgraph_optimize. */ lang_hooks.decls.final_write_globals (); if (errorcount || sorrycount) diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index dd38134802b..964a537266f 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -476,11 +476,12 @@ fold_cond_expr_cond (void) if (stmt && gimple_code (stmt) == GIMPLE_COND) { + location_t loc = gimple_location (stmt); tree cond; bool zerop, onep; fold_defer_overflow_warnings (); - cond = fold_binary (gimple_cond_code (stmt), boolean_type_node, + cond = fold_binary_loc (loc, gimple_cond_code (stmt), boolean_type_node, gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); if (cond) { @@ -7196,8 +7197,9 @@ gimplify_build3 (gimple_stmt_iterator *gsi, enum tree_code code, tree type, tree a, tree b, tree c) { tree ret; + location_t loc = gimple_location (gsi_stmt (*gsi)); - ret = fold_build3 (code, type, a, b, c); + ret = fold_build3_loc (loc, code, type, a, b, c); STRIP_NOPS (ret); return force_gimple_operand_gsi (gsi, ret, true, NULL, true, @@ -7213,7 +7215,7 @@ gimplify_build2 (gimple_stmt_iterator *gsi, enum tree_code code, { tree ret; - ret = fold_build2 (code, type, a, b); + ret = fold_build2_loc (gimple_location (gsi_stmt (*gsi)), code, type, a, b); STRIP_NOPS (ret); return force_gimple_operand_gsi (gsi, ret, true, NULL, true, @@ -7229,7 +7231,7 @@ gimplify_build1 (gimple_stmt_iterator *gsi, enum tree_code code, tree type, { tree ret; - ret = fold_build1 (code, type, a); + ret = fold_build1_loc (gimple_location (gsi_stmt (*gsi)), code, type, a); STRIP_NOPS (ret); return force_gimple_operand_gsi (gsi, ret, true, NULL, true, @@ -7368,3 +7370,100 @@ struct gimple_opt_pass pass_warn_function_noreturn = 0 /* todo_flags_finish */ } }; + + +/* Walk a gimplified function and warn for functions whose return value is + ignored and attribute((warn_unused_result)) is set. This is done before + inlining, so we don't have to worry about that. */ + +static void +do_warn_unused_result (gimple_seq seq) +{ + tree fdecl, ftype; + gimple_stmt_iterator i; + + for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i)) + { + gimple g = gsi_stmt (i); + + switch (gimple_code (g)) + { + case GIMPLE_BIND: + do_warn_unused_result (gimple_bind_body (g)); + break; + case GIMPLE_TRY: + do_warn_unused_result (gimple_try_eval (g)); + do_warn_unused_result (gimple_try_cleanup (g)); + break; + case GIMPLE_CATCH: + do_warn_unused_result (gimple_catch_handler (g)); + break; + case GIMPLE_EH_FILTER: + do_warn_unused_result (gimple_eh_filter_failure (g)); + break; + + case GIMPLE_CALL: + if (gimple_call_lhs (g)) + break; + + /* This is a naked call, as opposed to a GIMPLE_CALL with an + LHS. All calls whose value is ignored should be + represented like this. Look for the attribute. */ + fdecl = gimple_call_fndecl (g); + ftype = TREE_TYPE (TREE_TYPE (gimple_call_fn (g))); + + if (lookup_attribute ("warn_unused_result", TYPE_ATTRIBUTES (ftype))) + { + location_t loc = gimple_location (g); + + if (fdecl) + warning_at (loc, OPT_Wunused_result, + "ignoring return value of %qD, " + "declared with attribute warn_unused_result", + fdecl); + else + warning_at (loc, OPT_Wunused_result, + "ignoring return value of function " + "declared with attribute warn_unused_result"); + } + break; + + default: + /* Not a container, not a call, or a call whose value is used. */ + break; + } + } +} + +static unsigned int +run_warn_unused_result (void) +{ + do_warn_unused_result (gimple_body (current_function_decl)); + return 0; +} + +static bool +gate_warn_unused_result (void) +{ + return flag_warn_unused_result; +} + +struct gimple_opt_pass pass_warn_unused_result = +{ + { + GIMPLE_PASS, + "warn_unused_result", /* name */ + gate_warn_unused_result, /* gate */ + run_warn_unused_result, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + TV_NONE, /* tv_id */ + PROP_gimple_any, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ + } +}; + diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c index 3f1992b716b..f6918056a68 100644 --- a/gcc/tree-complex.c +++ b/gcc/tree-complex.c @@ -1109,7 +1109,8 @@ expand_complex_div_wide (gimple_stmt_iterator *gsi, tree inner_type, /* Examine |br| < |bi|, and branch. */ t1 = gimplify_build1 (gsi, ABS_EXPR, inner_type, br); t2 = gimplify_build1 (gsi, ABS_EXPR, inner_type, bi); - compare = fold_build2 (LT_EXPR, boolean_type_node, t1, t2); + compare = fold_build2_loc (gimple_location (gsi_stmt (*gsi)), + LT_EXPR, boolean_type_node, t1, t2); STRIP_NOPS (compare); bb_cond = bb_true = bb_false = bb_join = NULL; @@ -1130,7 +1131,8 @@ expand_complex_div_wide (gimple_stmt_iterator *gsi, tree inner_type, gsi_insert_before (gsi, stmt, GSI_SAME_STMT); - cond = fold_build2 (EQ_EXPR, boolean_type_node, tmp, boolean_true_node); + cond = fold_build2_loc (gimple_location (stmt), + EQ_EXPR, boolean_type_node, tmp, boolean_true_node); stmt = gimple_build_cond_from_tree (cond, NULL_TREE, NULL_TREE); gsi_insert_before (gsi, stmt, GSI_SAME_STMT); diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index c1b05328fa6..bfd0c293156 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -271,10 +271,11 @@ tree_if_convert_cond_stmt (struct loop *loop, gimple stmt, tree cond, { tree c, c2; edge true_edge, false_edge; + location_t loc = gimple_location (stmt); gcc_assert (gimple_code (stmt) == GIMPLE_COND); - c = fold_build2 (gimple_cond_code (stmt), boolean_type_node, + c = fold_build2_loc (loc, gimple_cond_code (stmt), boolean_type_node, gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); extract_true_false_edges_from_block (gimple_bb (stmt), @@ -286,7 +287,7 @@ tree_if_convert_cond_stmt (struct loop *loop, gimple stmt, tree cond, add_to_dst_predicate_list (loop, true_edge, cond, c, gsi); /* If 'c' is false then FALSE_EDGE is taken. */ - c2 = invert_truthvalue (unshare_expr (c)); + c2 = invert_truthvalue_loc (loc, unshare_expr (c)); add_to_dst_predicate_list (loop, false_edge, cond, c2, gsi); /* Now this conditional statement is redundant. Remove it. @@ -615,7 +616,8 @@ add_to_predicate_list (basic_block bb, tree new_cond) tree cond = (tree) bb->aux; if (cond) - cond = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, + cond = fold_build2_loc (EXPR_LOCATION (cond), + TRUTH_OR_EXPR, boolean_type_node, unshare_expr (cond), new_cond); else cond = new_cond; diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 648e30b47b3..a28f0a4cbbc 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -603,7 +603,12 @@ copy_statement_list (tree *tp) *tp = new_tree; for (; !tsi_end_p (oi); tsi_next (&oi)) - tsi_link_after (&ni, tsi_stmt (oi), TSI_NEW_STMT); + { + tree stmt = tsi_stmt (oi); + if (TREE_CODE (stmt) == STATEMENT_LIST) + copy_statement_list (&stmt); + tsi_link_after (&ni, stmt, TSI_CONTINUE_LINKING); + } } static void @@ -778,7 +783,8 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data) { if (TREE_CODE (new_tree) == ADDR_EXPR) { - *tp = fold_indirect_ref_1 (type, new_tree); + *tp = fold_indirect_ref_1 (EXPR_LOCATION (new_tree), + type, new_tree); /* ??? We should either assert here or build a VIEW_CONVERT_EXPR instead of blindly leaking incompatible types to our IL. */ @@ -920,7 +926,8 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) } else if (TREE_CODE (*tp) == STATEMENT_LIST) copy_statement_list (tp); - else if (TREE_CODE (*tp) == SAVE_EXPR) + else if (TREE_CODE (*tp) == SAVE_EXPR + || TREE_CODE (*tp) == TARGET_EXPR) remap_save_expr (tp, id->decl_map, walk_subtrees); else if (TREE_CODE (*tp) == LABEL_DECL && (! DECL_CONTEXT (*tp) @@ -1010,7 +1017,8 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data) { if (TREE_CODE (new_tree) == ADDR_EXPR) { - *tp = fold_indirect_ref_1 (type, new_tree); + *tp = fold_indirect_ref_1 (EXPR_LOCATION (new_tree), + type, new_tree); /* ??? We should either assert here or build a VIEW_CONVERT_EXPR instead of blindly leaking incompatible types to our IL. */ @@ -3917,7 +3925,8 @@ unsave_r (tree *tp, int *walk_subtrees, void *data) gcc_unreachable (); else if (TREE_CODE (*tp) == BIND_EXPR) copy_bind_expr (tp, walk_subtrees, id); - else if (TREE_CODE (*tp) == SAVE_EXPR) + else if (TREE_CODE (*tp) == SAVE_EXPR + || TREE_CODE (*tp) == TARGET_EXPR) remap_save_expr (tp, st, walk_subtrees); else { diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index a5c73165cb4..575025473cb 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -219,15 +219,15 @@ generate_loops_for_partition (struct loop *loop, bitmap partition, bool copy_p) /* Build the size argument for a memset call. */ static inline tree -build_size_arg (tree nb_iter, tree op, gimple_seq* stmt_list) +build_size_arg_loc (location_t loc, tree nb_iter, tree op, gimple_seq* stmt_list) { tree nb_bytes; gimple_seq stmts = NULL; - nb_bytes = fold_build2 (MULT_EXPR, size_type_node, - fold_convert (size_type_node, nb_iter), - fold_convert (size_type_node, - TYPE_SIZE_UNIT (TREE_TYPE (op)))); + nb_bytes = fold_build2_loc (loc, MULT_EXPR, size_type_node, + fold_convert_loc (loc, size_type_node, nb_iter), + fold_convert_loc (loc, size_type_node, + TYPE_SIZE_UNIT (TREE_TYPE (op)))); nb_bytes = force_gimple_operand (nb_bytes, &stmts, true, NULL); gimple_seq_add_seq (stmt_list, stmts); @@ -248,6 +248,7 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter, tree mem, fndecl, fntype, fn; gimple_stmt_iterator i; struct data_reference *dr = XCNEW (struct data_reference); + location_t loc = gimple_location (stmt); DR_STMT (dr) = stmt; DR_REF (dr) = op0; @@ -255,31 +256,32 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter, goto end; /* Test for a positive stride, iterating over every element. */ - if (integer_zerop (fold_build2 (MINUS_EXPR, integer_type_node, DR_STEP (dr), + if (integer_zerop (fold_build2_loc (loc, + MINUS_EXPR, integer_type_node, DR_STEP (dr), TYPE_SIZE_UNIT (TREE_TYPE (op0))))) { - tree offset = fold_convert (sizetype, - size_binop (PLUS_EXPR, - DR_OFFSET (dr), - DR_INIT (dr))); - addr_base = fold_build2 (POINTER_PLUS_EXPR, + tree offset = fold_convert_loc (loc, sizetype, + size_binop_loc (loc, PLUS_EXPR, + DR_OFFSET (dr), + DR_INIT (dr))); + addr_base = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (DR_BASE_ADDRESS (dr)), DR_BASE_ADDRESS (dr), offset); } /* Test for a negative stride, iterating over every element. */ - else if (integer_zerop (fold_build2 (PLUS_EXPR, integer_type_node, + else if (integer_zerop (fold_build2_loc (loc, PLUS_EXPR, integer_type_node, TYPE_SIZE_UNIT (TREE_TYPE (op0)), DR_STEP (dr)))) { - nb_bytes = build_size_arg (nb_iter, op0, &stmt_list); - addr_base = size_binop (PLUS_EXPR, DR_OFFSET (dr), DR_INIT (dr)); - addr_base = fold_build2 (MINUS_EXPR, sizetype, addr_base, - fold_convert (sizetype, nb_bytes)); + nb_bytes = build_size_arg_loc (loc, nb_iter, op0, &stmt_list); + addr_base = size_binop_loc (loc, PLUS_EXPR, DR_OFFSET (dr), DR_INIT (dr)); + addr_base = fold_build2_loc (loc, MINUS_EXPR, sizetype, addr_base, + fold_convert_loc (loc, sizetype, nb_bytes)); addr_base = force_gimple_operand (addr_base, &stmts, true, NULL); gimple_seq_add_seq (&stmt_list, stmts); - addr_base = fold_build2 (POINTER_PLUS_EXPR, + addr_base = fold_build2_loc (loc, POINTER_PLUS_EXPR, TREE_TYPE (DR_BASE_ADDRESS (dr)), DR_BASE_ADDRESS (dr), addr_base); } @@ -294,7 +296,7 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter, fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl); if (!nb_bytes) - nb_bytes = build_size_arg (nb_iter, op0, &stmt_list); + nb_bytes = build_size_arg_loc (loc, nb_iter, op0, &stmt_list); fn_call = gimple_build_call (fn, 3, mem, integer_zero_node, nb_bytes); gimple_seq_add_stmt (&stmt_list, fn_call); diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c index 8fcafca4b8f..381b029d45f 100644 --- a/gcc/tree-mudflap.c +++ b/gcc/tree-mudflap.c @@ -581,7 +581,8 @@ mf_build_check_statement_for (tree base, tree limit, /* Build: __mf_base = (uintptr_t) <base address expression>. */ seq = gimple_seq_alloc (); - t = fold_convert (mf_uintptr_type, unshare_expr (base)); + t = fold_convert_loc (location, mf_uintptr_type, + unshare_expr (base)); t = force_gimple_operand (t, &stmts, false, NULL_TREE); gimple_seq_add_seq (&seq, stmts); g = gimple_build_assign (mf_base, t); @@ -589,7 +590,8 @@ mf_build_check_statement_for (tree base, tree limit, gimple_seq_add_stmt (&seq, g); /* Build: __mf_limit = (uintptr_t) <limit address expression>. */ - t = fold_convert (mf_uintptr_type, unshare_expr (limit)); + t = fold_convert_loc (location, mf_uintptr_type, + unshare_expr (limit)); t = force_gimple_operand (t, &stmts, false, NULL_TREE); gimple_seq_add_seq (&seq, stmts); g = gimple_build_assign (mf_limit, t); @@ -693,8 +695,9 @@ mf_build_check_statement_for (tree base, tree limit, /* u is a string, so it is already a gimple value. */ u = mf_file_function_line_tree (location); /* NB: we pass the overall [base..limit] range to mf_check. */ - v = fold_build2 (PLUS_EXPR, mf_uintptr_type, - fold_build2 (MINUS_EXPR, mf_uintptr_type, mf_limit, mf_base), + v = fold_build2_loc (location, PLUS_EXPR, mf_uintptr_type, + fold_build2_loc (location, + MINUS_EXPR, mf_uintptr_type, mf_limit, mf_base), build_int_cst (mf_uintptr_type, 1)); v = force_gimple_operand (v, &stmts, true, NULL_TREE); gimple_seq_add_seq (&seq, stmts); @@ -863,16 +866,16 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, if (elt) elt = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (elt)), elt); - addr = fold_convert (ptr_type_node, elt ? elt : base); - addr = fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, - addr, fold_convert (sizetype, - byte_position (field))); + addr = fold_convert_loc (location, ptr_type_node, elt ? elt : base); + addr = fold_build2_loc (location, POINTER_PLUS_EXPR, ptr_type_node, + addr, fold_convert_loc (location, sizetype, + byte_position (field))); } else addr = build1 (ADDR_EXPR, build_pointer_type (type), t); - limit = fold_build2 (MINUS_EXPR, mf_uintptr_type, - fold_build2 (PLUS_EXPR, mf_uintptr_type, + limit = fold_build2_loc (location, MINUS_EXPR, mf_uintptr_type, + fold_build2_loc (location, PLUS_EXPR, mf_uintptr_type, convert (mf_uintptr_type, addr), size), integer_one_node); @@ -882,8 +885,9 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, case INDIRECT_REF: addr = TREE_OPERAND (t, 0); base = addr; - limit = fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, - fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, base, + limit = fold_build2_loc (location, POINTER_PLUS_EXPR, ptr_type_node, + fold_build2_loc (location, + POINTER_PLUS_EXPR, ptr_type_node, base, size), size_int (-1)); break; @@ -891,8 +895,9 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, case TARGET_MEM_REF: addr = tree_mem_ref_addr (ptr_type_node, t); base = addr; - limit = fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, - fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, base, + limit = fold_build2_loc (location, POINTER_PLUS_EXPR, ptr_type_node, + fold_build2_loc (location, + POINTER_PLUS_EXPR, ptr_type_node, base, size), size_int (-1)); break; @@ -914,21 +919,26 @@ mf_xform_derefs_1 (gimple_stmt_iterator *iter, tree *tp, bpu = bitsize_int (BITS_PER_UNIT); ofs = convert (bitsizetype, TREE_OPERAND (t, 2)); - rem = size_binop (TRUNC_MOD_EXPR, ofs, bpu); - ofs = fold_convert (sizetype, size_binop (TRUNC_DIV_EXPR, ofs, bpu)); + rem = size_binop_loc (location, TRUNC_MOD_EXPR, ofs, bpu); + ofs = fold_convert_loc (location, + sizetype, + size_binop_loc (location, + TRUNC_DIV_EXPR, ofs, bpu)); size = convert (bitsizetype, TREE_OPERAND (t, 1)); - size = size_binop (PLUS_EXPR, size, rem); - size = size_binop (CEIL_DIV_EXPR, size, bpu); + size = size_binop_loc (location, PLUS_EXPR, size, rem); + size = size_binop_loc (location, CEIL_DIV_EXPR, size, bpu); size = convert (sizetype, size); addr = TREE_OPERAND (TREE_OPERAND (t, 0), 0); addr = convert (ptr_type_node, addr); - addr = fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, addr, ofs); + addr = fold_build2_loc (location, POINTER_PLUS_EXPR, + ptr_type_node, addr, ofs); base = addr; - limit = fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, - fold_build2 (POINTER_PLUS_EXPR, ptr_type_node, + limit = fold_build2_loc (location, POINTER_PLUS_EXPR, ptr_type_node, + fold_build2_loc (location, + POINTER_PLUS_EXPR, ptr_type_node, base, size), size_int (-1)); } diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c index 80041ec66a7..7c55c8adc23 100644 --- a/gcc/tree-nested.c +++ b/gcc/tree-nested.c @@ -2443,6 +2443,17 @@ free_nesting_tree (struct nesting_info *root) while (root); } +/* Gimplify a function and all its nested functions. */ +static void +gimplify_all_functions (struct cgraph_node *root) +{ + struct cgraph_node *iter; + if (!gimple_body (root->decl)) + gimplify_function_tree (root->decl); + for (iter = root->nested; iter; iter = iter->next_nested) + gimplify_all_functions (iter); +} + /* Main entry point for this pass. Process FNDECL and all of its nested subroutines and turn them into something less tightly bound. */ @@ -2457,6 +2468,8 @@ lower_nested_functions (tree fndecl) if (!cgn->nested) return; + gimplify_all_functions (cgn); + bitmap_obstack_initialize (&nesting_info_bitmap_obstack); root = create_nesting_tree (cgn); walk_all_functions (convert_nonlocal_reference_stmt, diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index db3ebce28cc..a68cb16350b 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -279,10 +279,6 @@ struct dump_file_info and the memory footprint for VAR_DECLs. */ #define TODO_remove_unused_locals (1 << 15) -/* Internally used for the first in a sequence of passes. It is set - for the passes that are handed to register_dump_files. */ -#define TODO_set_props (1 << 16) - /* Call df_finish at the end of the pass. This is done after all of the dumpers have been allowed to run so that they have access to the instance before it is destroyed. */ @@ -370,6 +366,7 @@ extern struct gimple_opt_pass pass_lower_complex; extern struct gimple_opt_pass pass_lower_vector; extern struct gimple_opt_pass pass_lower_vector_ssa; extern struct gimple_opt_pass pass_lower_omp; +extern struct gimple_opt_pass pass_diagnose_omp_blocks; extern struct gimple_opt_pass pass_expand_omp; extern struct gimple_opt_pass pass_expand_omp_ssa; extern struct gimple_opt_pass pass_object_sizes; @@ -406,6 +403,7 @@ extern struct gimple_opt_pass pass_remove_cgraph_callee_edges; extern struct gimple_opt_pass pass_build_cgraph_edges; extern struct gimple_opt_pass pass_local_pure_const; extern struct gimple_opt_pass pass_tracer; +extern struct gimple_opt_pass pass_warn_unused_result; /* IPA Passes */ extern struct ipa_opt_pass_d pass_ipa_inline; diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 2381ac34d1e..a7bb017b476 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -1123,11 +1123,13 @@ static bool build_ref_for_offset (tree *expr, tree type, HOST_WIDE_INT offset, tree exp_type, bool allow_ptr) { + location_t loc = expr ? EXPR_LOCATION (*expr) : UNKNOWN_LOCATION; + if (allow_ptr && POINTER_TYPE_P (type)) { type = TREE_TYPE (type); if (expr) - *expr = fold_build1 (INDIRECT_REF, type, *expr); + *expr = fold_build1_loc (loc, INDIRECT_REF, type, *expr); } return build_ref_for_offset_1 (expr, type, offset, exp_type); @@ -1968,6 +1970,7 @@ load_assign_lhs_subreplacements (struct access *lacc, struct access *top_racc, enum unscalarized_data_handling *refreshed, tree lhs) { + location_t loc = EXPR_LOCATION (lacc->expr); do { if (lacc->grp_to_be_replaced) @@ -1982,7 +1985,7 @@ load_assign_lhs_subreplacements (struct access *lacc, struct access *top_racc, { rhs = get_access_replacement (racc); if (!useless_type_conversion_p (lacc->type, racc->type)) - rhs = fold_build1 (VIEW_CONVERT_EXPR, lacc->type, rhs); + rhs = fold_build1_loc (loc, VIEW_CONVERT_EXPR, lacc->type, rhs); } else { @@ -2080,6 +2083,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi, tree lhs, rhs; bool modify_this_stmt = false; bool force_gimple_rhs = false; + location_t loc = gimple_location (*stmt); if (!gimple_assign_single_p (*stmt)) return SRA_SA_NONE; @@ -2152,7 +2156,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi, } if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) { - rhs = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lhs), rhs); + rhs = fold_build1_loc (loc, VIEW_CONVERT_EXPR, TREE_TYPE (lhs), rhs); if (!is_gimple_reg (lhs)) force_gimple_rhs = true; } diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 3c88766a998..c507f4572e6 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -910,6 +910,7 @@ may_propagate_address_into_dereference (tree addr, tree deref) static tree ccp_fold (gimple stmt) { + location_t loc = gimple_location (stmt); switch (gimple_code (stmt)) { case GIMPLE_ASSIGN: @@ -992,7 +993,8 @@ ccp_fold (gimple stmt) { prop_value_t *val = get_value (TREE_OPERAND (rhs, 0)); if (val->lattice_val == CONSTANT) - return fold_unary (TREE_CODE (rhs), + return fold_unary_loc (EXPR_LOCATION (rhs), + TREE_CODE (rhs), TREE_TYPE (rhs), val->value); } else if (TREE_CODE (rhs) == INDIRECT_REF @@ -1048,15 +1050,16 @@ ccp_fold (gimple stmt) if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (op0)) && ((tem = maybe_fold_offset_to_address - (gimple_location (stmt), + (loc, op0, integer_zero_node, TREE_TYPE (lhs))) != NULL_TREE)) return tem; return op0; } - return fold_unary_ignore_overflow (subcode, - gimple_expr_type (stmt), op0); + return + fold_unary_ignore_overflow_loc (loc, subcode, + gimple_expr_type (stmt), op0); } case GIMPLE_BINARY_RHS: @@ -1087,12 +1090,13 @@ ccp_fold (gimple stmt) { tree lhs = gimple_assign_lhs (stmt); tree tem = maybe_fold_offset_to_address - (gimple_location (stmt), op0, op1, TREE_TYPE (lhs)); + (loc, op0, op1, TREE_TYPE (lhs)); if (tem != NULL_TREE) return tem; } - return fold_binary (subcode, gimple_expr_type (stmt), op0, op1); + return fold_binary_loc (loc, subcode, + gimple_expr_type (stmt), op0, op1); } default: @@ -1129,9 +1133,10 @@ ccp_fold (gimple stmt) args[i] = val->value; } } - call = build_call_array (gimple_call_return_type (stmt), - fn, gimple_call_num_args (stmt), args); - retval = fold_call_expr (call, false); + call = build_call_array_loc (loc, + gimple_call_return_type (stmt), + fn, gimple_call_num_args (stmt), args); + retval = fold_call_expr (EXPR_LOCATION (call), call, false); if (retval) /* fold_call_expr wraps the result inside a NOP_EXPR. */ STRIP_NOPS (retval); @@ -1162,7 +1167,7 @@ ccp_fold (gimple stmt) op1 = val->value; } - return fold_binary (code, boolean_type_node, op0, op1); + return fold_binary_loc (loc, code, boolean_type_node, op0, op1); } case GIMPLE_SWITCH: @@ -1344,7 +1349,8 @@ fold_const_aggregate_ref (tree t) { tree c = fold_const_aggregate_ref (TREE_OPERAND (t, 0)); if (c && TREE_CODE (c) == COMPLEX_CST) - return fold_build1 (TREE_CODE (t), TREE_TYPE (t), c); + return fold_build1_loc (EXPR_LOCATION (t), + TREE_CODE (t), TREE_TYPE (t), c); break; } @@ -2049,9 +2055,7 @@ maybe_fold_offset_to_address (location_t loc, tree addr, tree offset, ptr_type = build_pointer_type (TREE_TYPE (t)); if (!useless_type_conversion_p (orig_type, ptr_type)) return NULL_TREE; - t = build_fold_addr_expr_with_type (t, ptr_type); - protected_set_expr_location (t, loc); - return t; + return build_fold_addr_expr_with_type_loc (loc, t, ptr_type); } return NULL_TREE; @@ -2471,6 +2475,7 @@ ccp_fold_builtin (gimple stmt) bitmap visited; bool ignore; int nargs; + location_t loc = gimple_location (stmt); gcc_assert (is_gimple_call (stmt)); @@ -2567,7 +2572,7 @@ ccp_fold_builtin (gimple stmt) case BUILT_IN_STRCPY: if (val[1] && is_gimple_val (val[1]) && nargs == 2) - result = fold_builtin_strcpy (callee, + result = fold_builtin_strcpy (loc, callee, gimple_call_arg (stmt, 0), gimple_call_arg (stmt, 1), val[1]); @@ -2575,7 +2580,7 @@ ccp_fold_builtin (gimple stmt) case BUILT_IN_STRNCPY: if (val[1] && is_gimple_val (val[1]) && nargs == 3) - result = fold_builtin_strncpy (callee, + result = fold_builtin_strncpy (loc, callee, gimple_call_arg (stmt, 0), gimple_call_arg (stmt, 1), gimple_call_arg (stmt, 2), @@ -2584,14 +2589,14 @@ ccp_fold_builtin (gimple stmt) case BUILT_IN_FPUTS: if (nargs == 2) - result = fold_builtin_fputs (gimple_call_arg (stmt, 0), + result = fold_builtin_fputs (loc, gimple_call_arg (stmt, 0), gimple_call_arg (stmt, 1), ignore, false, val[0]); break; case BUILT_IN_FPUTS_UNLOCKED: if (nargs == 2) - result = fold_builtin_fputs (gimple_call_arg (stmt, 0), + result = fold_builtin_fputs (loc, gimple_call_arg (stmt, 0), gimple_call_arg (stmt, 1), ignore, true, val[0]); break; @@ -2601,7 +2606,7 @@ ccp_fold_builtin (gimple stmt) case BUILT_IN_MEMMOVE_CHK: case BUILT_IN_MEMSET_CHK: if (val[2] && is_gimple_val (val[2]) && nargs == 4) - result = fold_builtin_memory_chk (callee, + result = fold_builtin_memory_chk (loc, callee, gimple_call_arg (stmt, 0), gimple_call_arg (stmt, 1), gimple_call_arg (stmt, 2), @@ -2613,7 +2618,7 @@ ccp_fold_builtin (gimple stmt) case BUILT_IN_STRCPY_CHK: case BUILT_IN_STPCPY_CHK: if (val[1] && is_gimple_val (val[1]) && nargs == 3) - result = fold_builtin_stxcpy_chk (callee, + result = fold_builtin_stxcpy_chk (loc, callee, gimple_call_arg (stmt, 0), gimple_call_arg (stmt, 1), gimple_call_arg (stmt, 2), @@ -2623,7 +2628,7 @@ ccp_fold_builtin (gimple stmt) case BUILT_IN_STRNCPY_CHK: if (val[2] && is_gimple_val (val[2]) && nargs == 4) - result = fold_builtin_strncpy_chk (gimple_call_arg (stmt, 0), + result = fold_builtin_strncpy_chk (loc, gimple_call_arg (stmt, 0), gimple_call_arg (stmt, 1), gimple_call_arg (stmt, 2), gimple_call_arg (stmt, 3), @@ -2656,6 +2661,7 @@ fold_gimple_assign (gimple_stmt_iterator *si) { gimple stmt = gsi_stmt (*si); enum tree_code subcode = gimple_assign_rhs_code (stmt); + location_t loc = gimple_location (stmt); tree result = NULL_TREE; @@ -2671,11 +2677,13 @@ fold_gimple_assign (gimple_stmt_iterator *si) tree op0 = COND_EXPR_COND (rhs); tree tem; bool set = false; + location_t cond_loc = EXPR_LOCATION (rhs); if (COMPARISON_CLASS_P (op0)) { fold_defer_overflow_warnings (); - tem = fold_binary (TREE_CODE (op0), TREE_TYPE (op0), + tem = fold_binary_loc (cond_loc, + TREE_CODE (op0), TREE_TYPE (op0), TREE_OPERAND (op0, 0), TREE_OPERAND (op0, 1)); /* This is actually a conditional expression, not a GIMPLE @@ -2694,7 +2702,7 @@ fold_gimple_assign (gimple_stmt_iterator *si) return NULL_TREE; if (set) - result = fold_build3 (COND_EXPR, TREE_TYPE (rhs), tem, + result = fold_build3_loc (cond_loc, COND_EXPR, TREE_TYPE (rhs), tem, COND_EXPR_THEN (rhs), COND_EXPR_ELSE (rhs)); } @@ -2709,7 +2717,7 @@ fold_gimple_assign (gimple_stmt_iterator *si) tree tem = maybe_fold_reference (TREE_OPERAND (rhs, 0), true); if (tem) result = fold_convert (TREE_TYPE (rhs), - build_fold_addr_expr (tem)); + build_fold_addr_expr_loc (loc, tem)); } else if (TREE_CODE (rhs) == CONSTRUCTOR @@ -2752,7 +2760,7 @@ fold_gimple_assign (gimple_stmt_iterator *si) { tree rhs = gimple_assign_rhs1 (stmt); - result = fold_unary (subcode, gimple_expr_type (stmt), rhs); + result = fold_unary_loc (loc, subcode, gimple_expr_type (stmt), rhs); if (result) { /* If the operation was a conversion do _not_ mark a @@ -2774,7 +2782,7 @@ fold_gimple_assign (gimple_stmt_iterator *si) && POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (stmt)))) { tree type = gimple_expr_type (stmt); - tree t = maybe_fold_offset_to_address (gimple_location (stmt), + tree t = maybe_fold_offset_to_address (loc, gimple_assign_rhs1 (stmt), integer_zero_node, type); if (t) @@ -2802,7 +2810,7 @@ fold_gimple_assign (gimple_stmt_iterator *si) } if (!result) - result = fold_binary (subcode, + result = fold_binary_loc (loc, subcode, TREE_TYPE (gimple_assign_lhs (stmt)), gimple_assign_rhs1 (stmt), gimple_assign_rhs2 (stmt)); @@ -2841,7 +2849,8 @@ fold_gimple_assign (gimple_stmt_iterator *si) static bool fold_gimple_cond (gimple stmt) { - tree result = fold_binary (gimple_cond_code (stmt), + tree result = fold_binary_loc (gimple_location (stmt), + gimple_cond_code (stmt), boolean_type_node, gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); @@ -3120,6 +3129,7 @@ optimize_stdarg_builtin (gimple call) { tree callee, lhs, rhs, cfun_va_list; bool va_list_simple_ptr; + location_t loc = gimple_location (call); if (gimple_code (call) != GIMPLE_CALL) return NULL_TREE; @@ -3148,10 +3158,10 @@ optimize_stdarg_builtin (gimple call) != TYPE_MAIN_VARIANT (cfun_va_list)) return NULL_TREE; - lhs = build_fold_indirect_ref (lhs); - rhs = build_call_expr (built_in_decls[BUILT_IN_NEXT_ARG], + lhs = build_fold_indirect_ref_loc (loc, lhs); + rhs = build_call_expr_loc (loc, built_in_decls[BUILT_IN_NEXT_ARG], 1, integer_zero_node); - rhs = fold_convert (TREE_TYPE (lhs), rhs); + rhs = fold_convert_loc (loc, TREE_TYPE (lhs), rhs); return build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, rhs); case BUILT_IN_VA_COPY: @@ -3167,13 +3177,13 @@ optimize_stdarg_builtin (gimple call) != TYPE_MAIN_VARIANT (cfun_va_list)) return NULL_TREE; - lhs = build_fold_indirect_ref (lhs); + lhs = build_fold_indirect_ref_loc (loc, lhs); rhs = gimple_call_arg (call, 1); if (TYPE_MAIN_VARIANT (TREE_TYPE (rhs)) != TYPE_MAIN_VARIANT (cfun_va_list)) return NULL_TREE; - rhs = fold_convert (TREE_TYPE (lhs), rhs); + rhs = fold_convert_loc (loc, TREE_TYPE (lhs), rhs); return build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, rhs); case BUILT_IN_VA_END: diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index d919681fb1a..ea0291c49c5 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -514,6 +514,7 @@ static enum ssa_prop_result copy_prop_visit_cond_stmt (gimple stmt, edge *taken_edge_p) { enum ssa_prop_result retval = SSA_PROP_VARYING; + location_t loc = gimple_location (stmt); tree op0 = gimple_cond_lhs (stmt); tree op1 = gimple_cond_rhs (stmt); @@ -537,7 +538,7 @@ copy_prop_visit_cond_stmt (gimple stmt, edge *taken_edge_p) the same SSA_NAME on both sides of a comparison operator. */ if (op0 == op1) { - tree folded_cond = fold_binary (gimple_cond_code (stmt), + tree folded_cond = fold_binary_loc (loc, gimple_cond_code (stmt), boolean_type_node, op0, op1); if (folded_cond) { diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index fdfdda5e95f..bbf37f7a028 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -873,7 +873,8 @@ remove_dead_phis (basic_block bb) FOR_EACH_IMM_USE_STMT (use_stmt, iter, vdef) FOR_EACH_IMM_USE_ON_STMT (use_p, iter) SET_USE (use_p, vuse); - if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (vdef)) + if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (vdef) + && TREE_CODE (vuse) == SSA_NAME) SSA_NAME_OCCURS_IN_ABNORMAL_PHI (vuse) = 1; } else @@ -1137,7 +1138,8 @@ eliminate_unnecessary_stmts (void) for (bb = ENTRY_BLOCK_PTR->next_bb; bb != EXIT_BLOCK_PTR; bb = next_bb) { next_bb = bb->next_bb; - if (!(bb->flags & BB_REACHABLE)) + if (!TEST_BIT (bb_contains_live_stmts, bb->index) + || !(bb->flags & BB_REACHABLE)) { for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) if (!is_gimple_reg (gimple_phi_result (gsi_stmt (gsi)))) @@ -1159,7 +1161,8 @@ eliminate_unnecessary_stmts (void) if (found) mark_virtual_phi_result_for_renaming (gsi_stmt (gsi)); } - delete_basic_block (bb); + if (!(bb->flags & BB_REACHABLE)) + delete_basic_block (bb); } } } diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 0a2c4900e8e..2fa8da25eb6 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -1485,6 +1485,7 @@ record_edge_info (basic_block bb) if (! gsi_end_p (gsi)) { gimple stmt = gsi_stmt (gsi); + location_t loc = gimple_location (stmt); if (gimple_code (stmt) == GIMPLE_SWITCH) { @@ -1517,7 +1518,8 @@ record_edge_info (basic_block bb) if (label != NULL && label != error_mark_node) { - tree x = fold_convert (TREE_TYPE (index), CASE_LOW (label)); + tree x = fold_convert_loc (loc, TREE_TYPE (index), + CASE_LOW (label)); edge_info = allocate_edge_info (e); edge_info->lhs = index; edge_info->rhs = x; @@ -1581,7 +1583,7 @@ record_edge_info (basic_block bb) || is_gimple_min_invariant (op1))) { tree cond = build2 (code, boolean_type_node, op0, op1); - tree inverted = invert_truthvalue (cond); + tree inverted = invert_truthvalue_loc (loc, cond); struct edge_info *edge_info; edge_info = allocate_edge_info (true_edge); @@ -1608,7 +1610,7 @@ record_edge_info (basic_block bb) || TREE_CODE (op1) == SSA_NAME)) { tree cond = build2 (code, boolean_type_node, op0, op1); - tree inverted = invert_truthvalue (cond); + tree inverted = invert_truthvalue_loc (loc, cond); struct edge_info *edge_info; edge_info = allocate_edge_info (true_edge); @@ -2218,7 +2220,8 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si) tree val = NULL; if (gimple_code (stmt) == GIMPLE_COND) - val = fold_binary (gimple_cond_code (stmt), boolean_type_node, + val = fold_binary_loc (gimple_location (stmt), + gimple_cond_code (stmt), boolean_type_node, gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); else if (gimple_code (stmt) == GIMPLE_SWITCH) val = gimple_switch_index (stmt); @@ -2637,7 +2640,8 @@ propagate_rhs_into_lhs (gimple stmt, tree lhs, tree rhs, bitmap interesting_name tree val; if (gimple_code (use_stmt) == GIMPLE_COND) - val = fold_binary (gimple_cond_code (use_stmt), + val = fold_binary_loc (gimple_location (use_stmt), + gimple_cond_code (use_stmt), boolean_type_node, gimple_cond_lhs (use_stmt), gimple_cond_rhs (use_stmt)); diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index bbce3304c4e..26a82461600 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -339,9 +339,10 @@ remove_prop_source_from_use (tree name, gimple up_to_stmt) static tree rhs_to_tree (tree type, gimple stmt) { + location_t loc = gimple_location (stmt); enum tree_code code = gimple_assign_rhs_code (stmt); if (get_gimple_rhs_class (code) == GIMPLE_BINARY_RHS) - return fold_build2 (code, type, gimple_assign_rhs1 (stmt), + return fold_build2_loc (loc, code, type, gimple_assign_rhs1 (stmt), gimple_assign_rhs2 (stmt)); else if (get_gimple_rhs_class (code) == GIMPLE_UNARY_RHS) return build1 (code, type, gimple_assign_rhs1 (stmt)); @@ -358,14 +359,14 @@ rhs_to_tree (tree type, gimple stmt) considered simplified. */ static tree -combine_cond_expr_cond (enum tree_code code, tree type, +combine_cond_expr_cond (location_t loc, enum tree_code code, tree type, tree op0, tree op1, bool invariant_only) { tree t; gcc_assert (TREE_CODE_CLASS (code) == tcc_comparison); - t = fold_binary (code, type, op0, op1); + t = fold_binary_loc (loc, code, type, op0, op1); if (!t) return NULL_TREE; @@ -392,7 +393,8 @@ combine_cond_expr_cond (enum tree_code code, tree type, static int forward_propagate_into_gimple_cond (gimple stmt) { - int did_something = 0; + int did_something = 0; + location_t loc = gimple_location (stmt); do { tree tmp = NULL_TREE; @@ -413,7 +415,7 @@ forward_propagate_into_gimple_cond (gimple stmt) { tree op1 = gimple_cond_rhs (stmt); rhs0 = rhs_to_tree (TREE_TYPE (op1), def_stmt); - tmp = combine_cond_expr_cond (code, boolean_type_node, rhs0, + tmp = combine_cond_expr_cond (loc, code, boolean_type_node, rhs0, op1, !single_use0_p); } /* If that wasn't successful, try the second operand. */ @@ -427,15 +429,17 @@ forward_propagate_into_gimple_cond (gimple stmt) return did_something; rhs1 = rhs_to_tree (TREE_TYPE (op0), def_stmt); - tmp = combine_cond_expr_cond (code, boolean_type_node, op0, rhs1, - !single_use1_p); + tmp = combine_cond_expr_cond (loc, code, boolean_type_node, op0, + rhs1, !single_use1_p); } /* If that wasn't successful either, try both operands. */ if (tmp == NULL_TREE && rhs0 != NULL_TREE && rhs1 != NULL_TREE) - tmp = combine_cond_expr_cond (code, boolean_type_node, rhs0, - fold_convert (TREE_TYPE (rhs0), rhs1), + tmp = combine_cond_expr_cond (loc, code, boolean_type_node, rhs0, + fold_convert_loc (loc, + TREE_TYPE (rhs0), + rhs1), !(single_use0_p && single_use1_p)); } @@ -487,6 +491,7 @@ static int forward_propagate_into_cond (gimple_stmt_iterator *gsi_p) { gimple stmt = gsi_stmt (*gsi_p); + location_t loc = gimple_location (stmt); int did_something = 0; do { @@ -508,7 +513,8 @@ forward_propagate_into_cond (gimple_stmt_iterator *gsi_p) { tree op1 = TREE_OPERAND (cond, 1); rhs0 = rhs_to_tree (TREE_TYPE (op1), def_stmt); - tmp = combine_cond_expr_cond (TREE_CODE (cond), boolean_type_node, + tmp = combine_cond_expr_cond (loc, TREE_CODE (cond), + boolean_type_node, rhs0, op1, !single_use0_p); } /* If that wasn't successful, try the second operand. */ @@ -522,16 +528,20 @@ forward_propagate_into_cond (gimple_stmt_iterator *gsi_p) return did_something; rhs1 = rhs_to_tree (TREE_TYPE (op0), def_stmt); - tmp = combine_cond_expr_cond (TREE_CODE (cond), boolean_type_node, + tmp = combine_cond_expr_cond (loc, TREE_CODE (cond), + boolean_type_node, op0, rhs1, !single_use1_p); } /* If that wasn't successful either, try both operands. */ if (tmp == NULL_TREE && rhs0 != NULL_TREE && rhs1 != NULL_TREE) - tmp = combine_cond_expr_cond (TREE_CODE (cond), boolean_type_node, - rhs0, fold_convert (TREE_TYPE (rhs0), - rhs1), + tmp = combine_cond_expr_cond (loc, TREE_CODE (cond), + boolean_type_node, + rhs0, + fold_convert_loc (loc, + TREE_TYPE (rhs0), + rhs1), !(single_use0_p && single_use1_p)); } else if (TREE_CODE (cond) == SSA_NAME) @@ -542,7 +552,7 @@ forward_propagate_into_cond (gimple_stmt_iterator *gsi_p) return did_something; rhs0 = gimple_assign_rhs1 (def_stmt); - tmp = combine_cond_expr_cond (NE_EXPR, boolean_type_node, rhs0, + tmp = combine_cond_expr_cond (loc, NE_EXPR, boolean_type_node, rhs0, build_int_cst (TREE_TYPE (rhs0), 0), false); } @@ -1042,7 +1052,9 @@ forward_propagate_comparison (gimple stmt) gimple_assign_rhs1 (stmt), gimple_assign_rhs2 (stmt)); - tmp = combine_cond_expr_cond (code, TREE_TYPE (lhs), cond, cst, false); + tmp = combine_cond_expr_cond (gimple_location (use_stmt), + code, TREE_TYPE (lhs), + cond, cst, false); if (tmp == NULL_TREE) return false; } @@ -1214,7 +1226,8 @@ simplify_bitwise_and (gimple_stmt_iterator *gsi, gimple stmt) } } - res = fold_binary (BIT_AND_EXPR, TREE_TYPE (gimple_assign_lhs (stmt)), + res = fold_binary_loc (gimple_location (stmt), + BIT_AND_EXPR, TREE_TYPE (gimple_assign_lhs (stmt)), arg1, arg2); if (res && is_gimple_min_invariant (res)) { diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c index e6dc78a8c69..8cb9c1e4944 100644 --- a/gcc/tree-ssa-ifcombine.c +++ b/gcc/tree-ssa-ifcombine.c @@ -392,7 +392,8 @@ ifcombine_ifandif (basic_block inner_cond_bb, basic_block outer_cond_bb) enum tree_code code2 = gimple_cond_code (outer_cond); tree t; - if (!(t = combine_comparisons (TRUTH_ANDIF_EXPR, code1, code2, + if (!(t = combine_comparisons (UNKNOWN_LOCATION, + TRUTH_ANDIF_EXPR, code1, code2, boolean_type_node, gimple_cond_lhs (outer_cond), gimple_cond_rhs (outer_cond)))) @@ -541,7 +542,8 @@ ifcombine_iforif (basic_block inner_cond_bb, basic_block outer_cond_bb) enum tree_code code2 = gimple_cond_code (outer_cond); tree t; - if (!(t = combine_comparisons (TRUTH_ORIF_EXPR, code1, code2, + if (!(t = combine_comparisons (UNKNOWN_LOCATION, + TRUTH_ORIF_EXPR, code1, code2, boolean_type_node, gimple_cond_lhs (outer_cond), gimple_cond_rhs (outer_cond)))) diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 11640a8895e..96ca5edb0f3 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -1996,8 +1996,7 @@ vro_valid_in_sets (bitmap_set_t set1, bitmap_set_t set2, ONLY SET2 CAN BE NULL. This means that we have a leader for each part of the expression (if it consists of values), or the expression is an SSA_NAME. - For loads/calls, we also see if the vuse is killed in this block. -*/ + For loads/calls, we also see if the vuse is killed in this block. */ static bool valid_in_sets (bitmap_set_t set1, bitmap_set_t set2, pre_expr expr, @@ -3625,11 +3624,7 @@ insert (void) } -/* Add OP to EXP_GEN (block), and possibly to the maximal set if it is - not defined by a phi node. - PHI nodes can't go in the maximal sets because they are not in - TMP_GEN, so it is possible to get into non-monotonic situations - during ANTIC calculation, because it will *add* bits. */ +/* Add OP to EXP_GEN (block), and possibly to the maximal set. */ static void add_to_exp_gen (basic_block block, tree op) @@ -3641,9 +3636,7 @@ add_to_exp_gen (basic_block block, tree op) return; result = get_or_alloc_expr_for_name (op); bitmap_value_insert_into_set (EXP_GEN (block), result); - if (TREE_CODE (op) != SSA_NAME - || gimple_code (SSA_NAME_DEF_STMT (op)) != GIMPLE_PHI) - bitmap_value_insert_into_set (maximal_set, result); + bitmap_value_insert_into_set (maximal_set, result); } } @@ -3662,6 +3655,20 @@ make_values_for_phi (gimple phi, basic_block block) add_to_value (get_expr_value_id (e), e); bitmap_insert_into_set (PHI_GEN (block), e); bitmap_value_insert_into_set (AVAIL_OUT (block), e); + if (!in_fre) + { + unsigned i; + for (i = 0; i < gimple_phi_num_args (phi); ++i) + { + tree arg = gimple_phi_arg_def (phi, i); + if (TREE_CODE (arg) == SSA_NAME) + { + e = get_or_alloc_expr_for_name (arg); + add_to_value (get_expr_value_id (e), e); + bitmap_value_insert_into_set (maximal_set, e); + } + } + } } } @@ -4509,11 +4516,12 @@ execute_pre (bool do_fre ATTRIBUTE_UNUSED) FOR_ALL_BB (bb) { print_bitmap_set (dump_file, EXP_GEN (bb), "exp_gen", bb->index); - print_bitmap_set (dump_file, TMP_GEN (bb), "tmp_gen", - bb->index); - print_bitmap_set (dump_file, AVAIL_OUT (bb), "avail_out", - bb->index); + print_bitmap_set (dump_file, PHI_GEN (bb), "phi_gen", bb->index); + print_bitmap_set (dump_file, TMP_GEN (bb), "tmp_gen", bb->index); + print_bitmap_set (dump_file, AVAIL_OUT (bb), "avail_out", bb->index); } + + print_bitmap_set (dump_file, maximal_set, "maximal", 0); } /* Insert can get quite slow on an incredibly large number of basic diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 7e7e8e424c0..a9eef0bc1ec 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -3388,6 +3388,7 @@ make_constraint_from_heapvar (varinfo_t lhs, const char *name) vi->is_artificial_var = true; vi->is_heap_var = true; vi->is_unknown_size_var = true; + vi->offset = 0; vi->fullsize = ~0; vi->size = ~0; vi->is_full_var = true; diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 2e6808b7a4d..a5494827b37 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -552,6 +552,7 @@ build_arrays (gimple swtch) gimple stmt; gimple_stmt_iterator gsi; int i; + location_t loc = gimple_location (swtch); gsi = gsi_for_stmt (swtch); @@ -559,9 +560,10 @@ build_arrays (gimple swtch) tmp = create_tmp_var (TREE_TYPE (info.index_expr), "csti"); add_referenced_var (tmp); tidx = make_ssa_name (tmp, NULL); - sub = fold_build2 (MINUS_EXPR, TREE_TYPE (info.index_expr), info.index_expr, - fold_convert (TREE_TYPE (info.index_expr), - info.range_min)); + sub = fold_build2_loc (loc, MINUS_EXPR, + TREE_TYPE (info.index_expr), info.index_expr, + fold_convert_loc (loc, TREE_TYPE (info.index_expr), + info.range_min)); sub = force_gimple_operand_gsi (&gsi, sub, false, NULL, true, GSI_SAME_STMT); stmt = gimple_build_assign (tidx, sub); @@ -684,6 +686,7 @@ gen_inbound_check (gimple swtch) gimple_stmt_iterator gsi; basic_block bb0, bb1, bb2, bbf, bbd; edge e01, e02, e21, e1d, e1f, e2f; + location_t loc = gimple_location (swtch); gcc_assert (info.default_values); bb0 = gimple_bb (swtch); @@ -700,14 +703,14 @@ gen_inbound_check (gimple swtch) add_referenced_var (tmp_u_var); tmp_u_1 = make_ssa_name (tmp_u_var, NULL); - cast = fold_convert (utype, info.index_expr); + cast = fold_convert_loc (loc, utype, info.index_expr); cast_assign = gimple_build_assign (tmp_u_1, cast); SSA_NAME_DEF_STMT (tmp_u_1) = cast_assign; gsi_insert_before (&gsi, cast_assign, GSI_SAME_STMT); update_stmt (cast_assign); - ulb = fold_convert (utype, info.range_min); - minus = fold_build2 (MINUS_EXPR, utype, tmp_u_1, ulb); + ulb = fold_convert_loc (loc, utype, info.range_min); + minus = fold_build2_loc (loc, MINUS_EXPR, utype, tmp_u_1, ulb); minus = force_gimple_operand_gsi (&gsi, minus, false, NULL, true, GSI_SAME_STMT); tmp_u_2 = make_ssa_name (tmp_u_var, NULL); @@ -716,7 +719,7 @@ gen_inbound_check (gimple swtch) gsi_insert_before (&gsi, minus_assign, GSI_SAME_STMT); update_stmt (minus_assign); - bound = fold_convert (utype, info.range_size); + bound = fold_convert_loc (loc, utype, info.range_size); cond_stmt = gimple_build_cond (LE_EXPR, tmp_u_2, bound, NULL_TREE, NULL_TREE); gsi_insert_before (&gsi, cond_stmt, GSI_SAME_STMT); update_stmt (cond_stmt); diff --git a/gcc/tree.c b/gcc/tree.c index 7c5f154ad38..b32e209e83e 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -8537,7 +8537,8 @@ build_call_valist (tree return_type, tree fn, int nargs, va_list args) which are specified as a tree array ARGS. */ tree -build_call_array (tree return_type, tree fn, int nargs, const tree *args) +build_call_array_loc (location_t loc, tree return_type, tree fn, + int nargs, const tree *args) { tree t; int i; @@ -8549,6 +8550,7 @@ build_call_array (tree return_type, tree fn, int nargs, const tree *args) for (i = 0; i < nargs; i++) CALL_EXPR_ARG (t, i) = args[i]; process_call_operands (t); + SET_EXPR_LOCATION (t, loc); return t; } diff --git a/gcc/tree.h b/gcc/tree.h index 809c6e68ab8..fbae2080c04 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3838,7 +3838,9 @@ extern tree build_vl_exp_stat (enum tree_code, int MEM_STAT_DECL); extern tree build_call_list (tree, tree, tree); extern tree build_call_nary (tree, tree, int, ...); extern tree build_call_valist (tree, tree, int, va_list); -extern tree build_call_array (tree, tree, int, const tree *); +#define build_call_array(T1,T2,N,T3)\ + build_call_array_loc (UNKNOWN_LOCATION, T1, T2, N, T3) +extern tree build_call_array_loc (location_t, tree, tree, int, const tree *); extern tree build_call_vec (tree, tree, VEC(tree,gc) *); /* Construct various nodes representing data types. */ @@ -4166,7 +4168,8 @@ extern enum machine_mode mode_for_size_tree (const_tree, enum mode_class, int); /* Return an expr equal to X but certainly not valid as an lvalue. */ -extern tree non_lvalue (tree); +#define non_lvalue(T) non_lvalue_loc (UNKNOWN_LOCATION, T) +extern tree non_lvalue_loc (location_t, tree); extern tree convert (tree, tree); extern unsigned int expr_align (const_tree); @@ -4199,16 +4202,22 @@ extern GTY(()) tree sizetype_tab[(int) TYPE_KIND_LAST]; #define sbitsizetype sizetype_tab[(int) SBITSIZETYPE] extern tree size_int_kind (HOST_WIDE_INT, enum size_type_kind); -extern tree size_binop (enum tree_code, tree, tree); -extern tree size_diffop (tree, tree); +#define size_binop(CODE,T1,T2)\ + size_binop_loc (UNKNOWN_LOCATION, CODE, T1, T2) +extern tree size_binop_loc (location_t, enum tree_code, tree, tree); +#define size_diffop(T1,T2)\ + size_diffop_loc (UNKNOWN_LOCATION, T1, T2) +extern tree size_diffop_loc (location_t, tree, tree); #define size_int(L) size_int_kind (L, SIZETYPE) #define ssize_int(L) size_int_kind (L, SSIZETYPE) #define bitsize_int(L) size_int_kind (L, BITSIZETYPE) #define sbitsize_int(L) size_int_kind (L, SBITSIZETYPE) -extern tree round_up (tree, int); -extern tree round_down (tree, int); +#define round_up(T,N) round_up_loc (UNKNOWN_LOCATION, T, N) +extern tree round_up_loc (location_t, tree, int); +#define round_down(T,N) round_down_loc (UNKNOWN_LOCATION, T, N) +extern tree round_down_loc (location_t, tree, int); extern tree get_pending_sizes (void); extern void put_pending_size (tree); extern void put_pending_sizes (tree); @@ -4649,27 +4658,53 @@ extern tree native_interpret_expr (tree, const unsigned char *, int); subexpressions are not changed. */ extern tree fold (tree); -extern tree fold_unary (enum tree_code, tree, tree); -extern tree fold_unary_ignore_overflow (enum tree_code, tree, tree); -extern tree fold_binary (enum tree_code, tree, tree, tree); -extern tree fold_ternary (enum tree_code, tree, tree, tree, tree); -extern tree fold_build1_stat (enum tree_code, tree, tree MEM_STAT_DECL); -#define fold_build1(c,t1,t2) fold_build1_stat (c, t1, t2 MEM_STAT_INFO) -extern tree fold_build2_stat (enum tree_code, tree, tree, tree MEM_STAT_DECL); -#define fold_build2(c,t1,t2,t3) fold_build2_stat (c, t1, t2, t3 MEM_STAT_INFO) -extern tree fold_build3_stat (enum tree_code, tree, tree, tree, tree MEM_STAT_DECL); -#define fold_build3(c,t1,t2,t3,t4) fold_build3_stat (c, t1, t2, t3, t4 MEM_STAT_INFO) -extern tree fold_build1_initializer (enum tree_code, tree, tree); -extern tree fold_build2_initializer (enum tree_code, tree, tree, tree); -extern tree fold_build3_initializer (enum tree_code, tree, tree, tree, tree); -extern tree fold_build_call_array (tree, tree, int, tree *); -extern tree fold_build_call_array_initializer (tree, tree, int, tree *); +#define fold_unary(CODE,T1,T2)\ + fold_unary_loc (UNKNOWN_LOCATION, CODE, T1, T2) +extern tree fold_unary_loc (location_t, enum tree_code, tree, tree); +#define fold_unary_ignore_overflow(CODE,T1,T2)\ + fold_unary_ignore_overflow_loc (UNKNOWN_LOCATION, CODE, T1, T2) +extern tree fold_unary_ignore_overflow_loc (location_t, enum tree_code, tree, tree); +#define fold_binary(CODE,T1,T2,T3)\ + fold_binary_loc (UNKNOWN_LOCATION, CODE, T1, T2, T3) +extern tree fold_binary_loc (location_t, enum tree_code, tree, tree, tree); +#define fold_ternary(CODE,T1,T2,T3,T4)\ + fold_ternary_loc (UNKNOWN_LOCATION, CODE, T1, T2, T3, T4) +extern tree fold_ternary_loc (location_t, enum tree_code, tree, tree, tree, tree); +#define fold_build1(c,t1,t2)\ + fold_build1_stat_loc (UNKNOWN_LOCATION, c, t1, t2 MEM_STAT_INFO) +#define fold_build1_loc(l,c,t1,t2)\ + fold_build1_stat_loc (l, c, t1, t2 MEM_STAT_INFO) +extern tree fold_build1_stat_loc (location_t, enum tree_code, tree, + tree MEM_STAT_DECL); +#define fold_build2(c,t1,t2,t3)\ + fold_build2_stat_loc (UNKNOWN_LOCATION, c, t1, t2, t3 MEM_STAT_INFO) +#define fold_build2_loc(l,c,t1,t2,t3)\ + fold_build2_stat_loc (l, c, t1, t2, t3 MEM_STAT_INFO) +extern tree fold_build2_stat_loc (location_t, enum tree_code, tree, tree, + tree MEM_STAT_DECL); +#define fold_build3(c,t1,t2,t3,t4)\ + fold_build3_stat_loc (UNKNOWN_LOCATION, c, t1, t2, t3, t4 MEM_STAT_INFO) +#define fold_build3_loc(l,c,t1,t2,t3,t4)\ + fold_build3_stat_loc (l, c, t1, t2, t3, t4 MEM_STAT_INFO) +extern tree fold_build3_stat_loc (location_t, enum tree_code, tree, tree, tree, + tree MEM_STAT_DECL); +extern tree fold_build1_initializer_loc (location_t, enum tree_code, tree, tree); +extern tree fold_build2_initializer_loc (location_t, enum tree_code, tree, tree, tree); +extern tree fold_build3_initializer_loc (location_t, enum tree_code, tree, tree, tree, tree); +#define fold_build_call_array(T1,T2,N,T4)\ + fold_build_call_array_loc (UNKNOWN_LOCATION, T1, T2, N, T4) +extern tree fold_build_call_array_loc (location_t, tree, tree, int, tree *); +#define fold_build_call_array_initializer(T1,T2,N,T4)\ + fold_build_call_array_initializer_loc (UNKNOWN_LOCATION, T1, T2, N, T4) +extern tree fold_build_call_array_initializer_loc (location_t, tree, tree, int, tree *); extern bool fold_convertible_p (const_tree, const_tree); -extern tree fold_convert (tree, tree); -extern tree fold_single_bit_test (enum tree_code, tree, tree, tree); +#define fold_convert(T1,T2)\ + fold_convert_loc(UNKNOWN_LOCATION, T1, T2) +extern tree fold_convert_loc (location_t, tree, tree); +extern tree fold_single_bit_test (location_t, enum tree_code, tree, tree, tree); extern tree fold_ignored_result (tree); extern tree fold_abs_const (tree, tree); -extern tree fold_indirect_ref_1 (tree, tree); +extern tree fold_indirect_ref_1 (location_t, tree, tree); extern void fold_defer_overflow_warnings (void); extern void fold_undefer_overflow_warnings (bool, const_gimple, int); extern void fold_undefer_and_ignore_overflow_warnings (void); @@ -4721,20 +4756,34 @@ enum operand_equal_flag extern int operand_equal_p (const_tree, const_tree, unsigned int); extern int multiple_of_p (tree, const_tree, const_tree); -extern tree omit_one_operand (tree, tree, tree); -extern tree omit_two_operands (tree, tree, tree, tree); -extern tree invert_truthvalue (tree); -extern tree fold_truth_not_expr (tree); +#define omit_one_operand(T1,T2,T3)\ + omit_one_operand_loc (UNKNOWN_LOCATION, T1, T2, T3) +extern tree omit_one_operand_loc (location_t, tree, tree, tree); +#define omit_two_operands(T1,T2,T3,T4)\ + omit_two_operands_loc (UNKNOWN_LOCATION, T1, T2, T3, T4) +extern tree omit_two_operands_loc (location_t, tree, tree, tree, tree); +#define invert_truthvalue(T)\ + invert_truthvalue_loc(UNKNOWN_LOCATION, T) +extern tree invert_truthvalue_loc (location_t, tree); +extern tree fold_truth_not_expr (location_t, tree); extern tree fold_unary_to_constant (enum tree_code, tree, tree); extern tree fold_binary_to_constant (enum tree_code, tree, tree, tree); extern tree fold_read_from_constant_string (tree); extern tree int_const_binop (enum tree_code, const_tree, const_tree, int); -extern tree build_fold_addr_expr (tree); +#define build_fold_addr_expr(T)\ + build_fold_addr_expr_loc (UNKNOWN_LOCATION, (T)) +extern tree build_fold_addr_expr_loc (location_t, tree); +#define build_fold_addr_expr_with_type(T,TYPE)\ + build_fold_addr_expr_with_type_loc (UNKNOWN_LOCATION, (T), TYPE) +extern tree build_fold_addr_expr_with_type_loc (location_t, tree, tree); extern tree fold_build_cleanup_point_expr (tree type, tree expr); extern tree fold_strip_sign_ops (tree); -extern tree build_fold_addr_expr_with_type (tree, tree); -extern tree build_fold_indirect_ref (tree); -extern tree fold_indirect_ref (tree); +#define build_fold_indirect_ref(T)\ + build_fold_indirect_ref_loc (UNKNOWN_LOCATION, T) +extern tree build_fold_indirect_ref_loc (location_t, tree); +#define fold_indirect_ref(T)\ + fold_indirect_ref_loc (UNKNOWN_LOCATION, T) +extern tree fold_indirect_ref_loc (location_t, tree); extern tree constant_boolean_node (int, tree); extern tree div_if_zero_remainder (enum tree_code, const_tree, const_tree); @@ -4759,7 +4808,7 @@ extern bool tree_call_nonnegative_warnv_p (tree, tree, tree, tree, bool *); extern bool tree_expr_nonzero_warnv_p (tree, bool *); extern bool fold_real_zero_addition_p (const_tree, const_tree, int); -extern tree combine_comparisons (enum tree_code, enum tree_code, +extern tree combine_comparisons (location_t, enum tree_code, enum tree_code, enum tree_code, tree, tree, tree); extern void debug_fold_checksum (const_tree); @@ -4775,21 +4824,23 @@ truth_value_p (enum tree_code code) /* In builtins.c */ -extern tree fold_call_expr (tree, bool); -extern tree fold_builtin_fputs (tree, tree, bool, bool, tree); -extern tree fold_builtin_strcpy (tree, tree, tree, tree); -extern tree fold_builtin_strncpy (tree, tree, tree, tree, tree); -extern tree fold_builtin_memory_chk (tree, tree, tree, tree, tree, tree, bool, +extern tree fold_call_expr (location_t, tree, bool); +extern tree fold_builtin_fputs (location_t, tree, tree, bool, bool, tree); +extern tree fold_builtin_strcpy (location_t, tree, tree, tree, tree); +extern tree fold_builtin_strncpy (location_t, tree, tree, tree, tree, tree); +extern tree fold_builtin_memory_chk (location_t, tree, tree, tree, tree, tree, tree, bool, enum built_in_function); -extern tree fold_builtin_stxcpy_chk (tree, tree, tree, tree, tree, bool, +extern tree fold_builtin_stxcpy_chk (location_t, tree, tree, tree, tree, tree, bool, enum built_in_function); -extern tree fold_builtin_strncpy_chk (tree, tree, tree, tree, tree); -extern tree fold_builtin_snprintf_chk (tree, tree, enum built_in_function); +extern tree fold_builtin_strncpy_chk (location_t, tree, tree, tree, tree, tree); +extern tree fold_builtin_snprintf_chk (location_t, tree, tree, enum built_in_function); extern bool fold_builtin_next_arg (tree, bool); extern enum built_in_function builtin_mathfn_code (const_tree); -extern tree build_function_call_expr (tree, tree); -extern tree fold_builtin_call_array (tree, tree, int, tree *); -extern tree build_call_expr (tree, int, ...); +extern tree build_function_call_expr (location_t, tree, tree); +extern tree fold_builtin_call_array (location_t, tree, tree, int, tree *); +#define build_call_expr(...)\ + build_call_expr_loc (UNKNOWN_LOCATION, __VA_ARGS__) +extern tree build_call_expr_loc (location_t, tree, int, ...); extern tree mathfn_built_in (tree, enum built_in_function fn); extern tree c_strlen (tree, int); extern tree std_gimplify_va_arg_expr (tree, tree, gimple_seq *, gimple_seq *); @@ -4804,7 +4855,7 @@ extern int get_object_alignment (tree, unsigned int, unsigned int); extern tree fold_call_stmt (gimple, bool); extern tree gimple_fold_builtin_snprintf_chk (gimple, tree, enum built_in_function); extern tree make_range (tree, int *, tree *, tree *, bool *); -extern tree build_range_check (tree, tree, int, tree, tree); +extern tree build_range_check (location_t, tree, tree, int, tree, tree); extern bool merge_ranges (int *, tree *, tree *, int, tree, tree, int, tree, tree); diff --git a/gcc/varasm.c b/gcc/varasm.c index 6e81db4ba01..729cc078066 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -445,7 +445,7 @@ emutls_common_1 (void **loc, void *xstmts) args = tree_cons (NULL, x, args); x = built_in_decls[BUILT_IN_EMUTLS_REGISTER_COMMON]; - x = build_function_call_expr (x, args); + x = build_function_call_expr (UNKNOWN_LOCATION, x, args); append_to_statement_list (x, pstmts); return 1; diff --git a/include/ChangeLog b/include/ChangeLog index ef802e57fda..2c14069740b 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,10 @@ +2009-07-17 Jan Kratochvil <jan.kratochvil@redhat.com> + + * demangle.h + (enum demangle_component_type <DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS>) + (enum demangle_component_type <DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS>): + New. + 2009-07-09 Jakub Jelinek <jakub@redhat.com> * dwarf2.h (enum dwarf_location_atom): Add DW_OP_implicit_value diff --git a/include/demangle.h b/include/demangle.h index eb39c7c13c4..0bcae2fdbbb 100644 --- a/include/demangle.h +++ b/include/demangle.h @@ -377,6 +377,10 @@ enum demangle_component_type DEMANGLE_COMPONENT_CHARACTER, /* A decltype type. */ DEMANGLE_COMPONENT_DECLTYPE, + /* Global constructors keyed to name. */ + DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS, + /* Global destructors keyed to name. */ + DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, /* A pack expansion. */ DEMANGLE_COMPONENT_PACK_EXPANSION }; diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index e2171b0fb7b..57ba6779feb 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,30 @@ +2009-07-17 Jerry Quinn <jlquinn@optonline.net> + + * directives.c (do_linemarker, do_line): Use CPP_STRING for + ignored enum value. + * files.c (find_file_in_dir): Add cast from void* to char*. + * symtab.c (ht_lookup_with_hash): Add cast from void* to char*. + * Makefile.in: (WARN_CFLAGS): Use general and C-specific + warnings. + (CXX, CXXFLAGS, WARN_CXXFLAGS, ALL_CXXFLAGS, + ENABLE_BUILD_WITH_CXX, CCDEPMODE, CXXDEPMODE, COMPILER, + COMPILER_FLAGS): New. + (DEPMODE): Set from CCDEPMODE or CXXDEPMODE. + (COMPILE.base): Use COMPILER instead of CC. Use COMPILER_FLAGS + instead of ALL_CFLAGS. + * configure.ac: Invoke AC_PROG_CXX. Separate C-specific warnings + from other warnings. Add -Wc++-compat to C-specific warnings. + Check for --enable-build-with-cxx. Set and substitute + ENABLE_BUILD_WITH_CXX. Invoke ZW_PROG_COMPILER_DEPENDENCIES + according to ENABLE_BUILD_WITH_CXX. Invoke AC_LANG before + AC_CHECK_HEADERS. + * configure: Rebuild. + * include/cpp-id-data.h: Remove extern "C". + * include/line-map.h: Likewise. + * include/mkdeps.h: Likewise. + * include/symtab.h: Likewise. + * internal.h: Likewise. + 2009-06-23 Manuel Lopez-Ibanez <manu@gcc.gnu.org> * directives.c (parse_include): Add location argument. Update all diff --git a/libcpp/Makefile.in b/libcpp/Makefile.in index 68f5892d088..268d1baaca2 100644 --- a/libcpp/Makefile.in +++ b/libcpp/Makefile.in @@ -33,7 +33,10 @@ AUTOHEADER = @AUTOHEADER@ CATALOGS = $(patsubst %,po/%,@CATALOGS@) CC = @CC@ CFLAGS = @CFLAGS@ -WARN_CFLAGS = @WARN_CFLAGS@ @WARN_PEDANTIC@ @WERROR@ +WARN_CFLAGS = @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@ +CXX = @CXX@ +CXXFLAGS = @CXXFLAGS@ +WARN_CXXFLAGS = @warn@ @WARN_PEDANTIC@ @WERROR@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ EXEEXT = @EXEEXT@ @@ -50,7 +53,8 @@ RANLIB = @RANLIB@ SHELL = @SHELL@ USED_CATALOGS = @USED_CATALOGS@ XGETTEXT = @XGETTEXT@ -DEPMODE = @CCDEPMODE@ +CCDEPMODE = @CCDEPMODE@ +CXXDEPMODE = @CXXDEPMODE@ DEPDIR = @DEPDIR@ datarootdir = @datarootdir@ @@ -68,6 +72,20 @@ INCLUDES = -I$(srcdir) -I. -I$(srcdir)/../include @INCINTL@ \ -I$(srcdir)/include ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS) +ALL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(INCLUDES) $(CPPFLAGS) + +# The name of the compiler to use. +ENABLE_BUILD_WITH_CXX = @ENABLE_BUILD_WITH_CXX@ +ifneq ($(ENABLE_BUILD_WITH_CXX),yes) +COMPILER = $(CC) +COMPILER_FLAGS = $(ALL_CFLAGS) +DEPMODE = $(CCDEPMODE) +else +COMPILER = $(CXX) +COMPILER_FLAGS = $(ALL_CXXFLAGS) +DEPMODE = $(CXXDEPMODE) +endif + libcpp_a_OBJS = charset.o directives.o directives-only.o errors.o \ expr.o files.o identifiers.o init.o lex.o line-map.o macro.o \ @@ -189,7 +207,7 @@ update-po: $(CATALOGS:.gmo=.pox) install-man update-po install-html # Dependency rule. -COMPILE.base = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(ALL_CFLAGS) -c +COMPILE.base = $(COMPILER) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(COMPILER_FLAGS) -c ifeq ($(DEPMODE),depmode=gcc3) # Note that we put the dependencies into a .Tpo file, then move them # into place if the compile succeeds. We need this because gcc does diff --git a/libcpp/aclocal.m4 b/libcpp/aclocal.m4 index 978a2417d14..66d80b5c3c3 100644 --- a/libcpp/aclocal.m4 +++ b/libcpp/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.10.1 -*- Autoconf -*- +# generated automatically by aclocal 1.10.2 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008 Free Software Foundation, Inc. diff --git a/libcpp/configure b/libcpp/configure index 9a4f30ddfc0..35fb663bf87 100755 --- a/libcpp/configure +++ b/libcpp/configure @@ -311,7 +311,7 @@ ac_includes_default="\ # include <unistd.h> #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT RANLIB ac_ct_RANLIB ACLOCAL AUTOCONF AUTOHEADER WARN_CFLAGS WARN_PEDANTIC WERROR am__leading_dot DEPDIR CCDEPMODE CPP EGREP LIBOBJS ALLOCA USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT LIBICONV LTLIBICONV PACKAGE USED_CATALOGS MAINT LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX RANLIB ac_ct_RANLIB ENABLE_BUILD_WITH_CXX ACLOCAL AUTOCONF AUTOHEADER warn c_warn WARN_PEDANTIC WERROR am__leading_dot DEPDIR CCDEPMODE CXXDEPMODE CPP EGREP CXXCPP LIBOBJS ALLOCA USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT LIBICONV LTLIBICONV PACKAGE USED_CATALOGS MAINT LTLIBOBJS' ac_subst_files='' ac_pwd=`pwd` @@ -769,10 +769,22 @@ ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CXX_set=${CXX+set} +ac_env_CXX_value=$CXX +ac_cv_env_CXX_set=${CXX+set} +ac_cv_env_CXX_value=$CXX +ac_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_env_CXXFLAGS_value=$CXXFLAGS +ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} +ac_cv_env_CXXFLAGS_value=$CXXFLAGS ac_env_CPP_set=${CPP+set} ac_env_CPP_value=$CPP ac_cv_env_CPP_set=${CPP+set} ac_cv_env_CPP_value=$CPP +ac_env_CXXCPP_set=${CXXCPP+set} +ac_env_CXXCPP_value=$CXXCPP +ac_cv_env_CXXCPP_set=${CXXCPP+set} +ac_cv_env_CXXCPP_value=$CXXCPP # # Report the --help message. @@ -850,6 +862,7 @@ if test -n "$ac_init_help"; then Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-build-with-cxx build with C++ compiler instead of C compiler --enable-werror-always enable -Werror despite compiler version --disable-rpath do not hardcode runtime library paths --enable-maintainer-mode enable rules only needed by maintainers @@ -869,7 +882,10 @@ Some influential environment variables: nonstandard directory <lib dir> CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> + CXX C++ compiler command + CXXFLAGS C++ compiler flags CPP C preprocessor + CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -2515,6 +2531,361 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CXX" && break +done +test -n "$ac_ct_CXX" || ac_ct_CXX="g++" + + CXX=$ac_ct_CXX +fi + + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C++ compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 + (eval $ac_compiler --version </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5 + (eval $ac_compiler -v </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5 + (eval $ac_compiler -V </dev/null >&5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +CXXFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cxx_g=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +for ac_declaration in \ + '' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +#include <stdlib.h> +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 @@ -2596,6 +2967,17 @@ else fi +# See if we are building gcc with C++. +# Do this early so setting lang to C++ affects following tests +# Check whether --enable-build-with-cxx or --disable-build-with-cxx was given. +if test "${enable_build_with_cxx+set}" = set; then + enableval="$enable_build_with_cxx" + ENABLE_BUILD_WITH_CXX=$enableval +else + ENABLE_BUILD_WITH_CXX=no +fi; + + MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing for ac_prog in aclocal do @@ -2725,10 +3107,9 @@ test -n "$AUTOHEADER" || AUTOHEADER="$MISSING autoheader" # See config/warnings.m4 for details. -WARN_CFLAGS= +warn= save_CFLAGS="$CFLAGS" -for option in -W -Wall -Wwrite-strings -Wstrict-prototypes \ - -Wmissing-prototypes -Wold-style-definition \ +for option in -W -Wall -Wwrite-strings \ -Wmissing-format-attribute; do as_acx_Woption=`echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh` @@ -2788,7 +3169,75 @@ fi echo "$as_me:$LINENO: result: `eval echo '${'$as_acx_Woption'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_acx_Woption'}'`" >&6 if test `eval echo '${'$as_acx_Woption'}'` = yes; then - WARN_CFLAGS="$WARN_CFLAGS${WARN_CFLAGS:+ }$option" + warn="$warn${warn:+ }$option" +fi + + done +CFLAGS="$save_CFLAGS" + +c_warn= +save_CFLAGS="$CFLAGS" +for option in -Wstrict-prototypes -Wmissing-prototypes \ + -Wold-style-definition -Wc++-compat; do + as_acx_Woption=`echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh` + + echo "$as_me:$LINENO: checking whether $CC supports $option" >&5 +echo $ECHO_N "checking whether $CC supports $option... $ECHO_C" >&6 +if eval "test \"\${$as_acx_Woption+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + CFLAGS="$option" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_acx_Woption=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_acx_Woption=no" +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_acx_Woption'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_acx_Woption'}'`" >&6 + if test `eval echo '${'$as_acx_Woption'}'` = yes; then + c_warn="$c_warn${c_warn:+ }$option" fi done @@ -2893,6 +3342,7 @@ DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depdir" +if test "$ENABLE_BUILD_WITH_CXX" == "no"; then depcc="$CC" am_compiler_list= am_depcomp=$ac_aux_dir/depcomp @@ -2991,6 +3441,106 @@ else CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type fi +else +depcc="$CXX" am_compiler_list= + +am_depcomp=$ac_aux_dir/depcomp +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + if test $depmode = none; then break; fi + + echo "$as_me:$LINENO: trying $depmode" >&5 + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "include sub/conftest.Po" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + depcmd="depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c" + echo "| $depcmd" | sed -e 's/ */ /g' >&5 + if env $depcmd > conftest.err 2>&1 && + grep sub/conftst6.h sub/conftest.Po >>conftest.err 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po >>conftest.err 2>&1 && + ${MAKE-make} -s -f confmf >>conftest.err 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + echo "$as_me:$LINENO: success" >&5 + break + fi + fi + echo "$as_me:$LINENO: failure, diagnostics are:" >&5 + sed -e 's/^/| /' < conftest.err >&5 + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6 +if test x${am_cv_CXX_dependencies_compiler_type-none} = xnone +then { { echo "$as_me:$LINENO: error: no usable dependency style found" >&5 +echo "$as_me: error: no usable dependency style found" >&2;} + { (exit 1); exit 1; }; } +else CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + +fi + +fi # Checks for header files. echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 @@ -3120,7 +3670,18 @@ _ACEOF fi -ac_ext=c + +# AC_CHECK_HEADERS is repeated to work around apparent autoconf 2.59 bug. If +# AC_CHECK_HEADERS comes after the if clause, the last AC_LANG call gets used, +# no matter which branch is taken. +if test "$ENABLE_BUILD_WITH_CXX" == "no"; then + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' @@ -3769,6 +4330,407 @@ fi done +else + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 +echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 +if test -z "$CXXCPP"; then + if test "${ac_cv_prog_CXXCPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +echo "$as_me:$LINENO: result: $CXXCPP" >&5 +echo "${ECHO_T}$CXXCPP" >&6 +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } +fi + +ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + + + + + + + + +for ac_header in locale.h fcntl.h limits.h stddef.h \ + stdlib.h strings.h string.h sys/file.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( + cat <<\_ASBOX +## ----------------------------------- ## +## Report this to gcc-bugs@gcc.gnu.org ## +## ----------------------------------- ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +fi # Checks for typedefs, structures, and compiler characteristics. echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 @@ -3846,7 +4808,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -3907,7 +4869,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -3978,7 +4940,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4052,7 +5014,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4118,7 +5080,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4184,7 +5146,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4249,7 +5211,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4313,7 +5275,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4376,7 +5338,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4417,7 +5379,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4474,7 +5436,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4515,7 +5477,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4580,7 +5542,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4733,7 +5695,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4796,7 +5758,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4837,7 +5799,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4894,7 +5856,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -4935,7 +5897,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5000,7 +5962,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5206,7 +6168,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5271,7 +6233,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5341,7 +6303,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5411,7 +6373,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5481,7 +6443,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5551,7 +6513,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5621,7 +6583,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5691,7 +6653,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5761,7 +6723,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5831,7 +6793,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5901,7 +6863,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -5971,7 +6933,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6041,7 +7003,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6111,7 +7073,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6181,7 +7143,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6251,7 +7213,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6321,7 +7283,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6391,7 +7353,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6461,7 +7423,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6531,7 +7493,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6601,7 +7563,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6671,7 +7633,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6741,7 +7703,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6814,7 +7776,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -6896,7 +7858,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -7038,7 +8000,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -7175,7 +8137,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -7338,7 +8300,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -7477,7 +8439,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -8117,7 +9079,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -8168,7 +9130,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -8259,7 +9221,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 @@ -9037,19 +9999,26 @@ s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t +s,@CXX@,$CXX,;t t +s,@CXXFLAGS@,$CXXFLAGS,;t t +s,@ac_ct_CXX@,$ac_ct_CXX,;t t s,@RANLIB@,$RANLIB,;t t s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@ENABLE_BUILD_WITH_CXX@,$ENABLE_BUILD_WITH_CXX,;t t s,@ACLOCAL@,$ACLOCAL,;t t s,@AUTOCONF@,$AUTOCONF,;t t s,@AUTOHEADER@,$AUTOHEADER,;t t -s,@WARN_CFLAGS@,$WARN_CFLAGS,;t t +s,@warn@,$warn,;t t +s,@c_warn@,$c_warn,;t t s,@WARN_PEDANTIC@,$WARN_PEDANTIC,;t t s,@WERROR@,$WERROR,;t t s,@am__leading_dot@,$am__leading_dot,;t t s,@DEPDIR@,$DEPDIR,;t t s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@CXXDEPMODE@,$CXXDEPMODE,;t t s,@CPP@,$CPP,;t t s,@EGREP@,$EGREP,;t t +s,@CXXCPP@,$CXXCPP,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@ALLOCA@,$ALLOCA,;t t s,@USE_NLS@,$USE_NLS,;t t diff --git a/libcpp/configure.ac b/libcpp/configure.ac index 833eb435980..a3ab8f551c3 100644 --- a/libcpp/configure.ac +++ b/libcpp/configure.ac @@ -11,8 +11,17 @@ AC_CANONICAL_SYSTEM AC_PROG_MAKE_SET AC_PROG_INSTALL AC_PROG_CC +AC_PROG_CXX AC_PROG_RANLIB +# See if we are building gcc with C++. +# Do this early so setting lang to C++ affects following tests +AC_ARG_ENABLE(build-with-cxx, +[ --enable-build-with-cxx build with C++ compiler instead of C compiler], +ENABLE_BUILD_WITH_CXX=$enableval, +ENABLE_BUILD_WITH_CXX=no) +AC_SUBST(ENABLE_BUILD_WITH_CXX) + MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal]) AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf]) @@ -21,9 +30,10 @@ AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader]) # Figure out what compiler warnings we can enable. # See config/warnings.m4 for details. -ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \ - -Wmissing-prototypes -Wold-style-definition \ - -Wmissing-format-attribute]) +ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings \ + -Wmissing-format-attribute], [warn]) +ACX_PROG_CC_WARNING_OPTS([-Wstrict-prototypes -Wmissing-prototypes \ + -Wold-style-definition -Wc++-compat], [c_warn]) ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long]) # Only enable with --enable-werror-always until existing warnings are @@ -32,13 +42,28 @@ ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual]) # Dependency checking. ZW_CREATE_DEPDIR +if test "$ENABLE_BUILD_WITH_CXX" == "no"; then ZW_PROG_COMPILER_DEPENDENCIES([CC]) +else +ZW_PROG_COMPILER_DEPENDENCIES([CXX]) +fi # Checks for header files. AC_HEADER_TIME ACX_HEADER_STRING -AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \ + +# AC_CHECK_HEADERS is repeated to work around apparent autoconf 2.59 bug. If +# AC_CHECK_HEADERS comes after the if clause, the last AC_LANG call gets used, +# no matter which branch is taken. +if test "$ENABLE_BUILD_WITH_CXX" == "no"; then + AC_LANG(C) + AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \ stdlib.h strings.h string.h sys/file.h unistd.h) +else + AC_LANG(C++) + AC_CHECK_HEADERS(locale.h fcntl.h limits.h stddef.h \ + stdlib.h strings.h string.h sys/file.h unistd.h) +fi # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST diff --git a/libcpp/directives.c b/libcpp/directives.c index 23d89259bc9..9c988dfa136 100644 --- a/libcpp/directives.c +++ b/libcpp/directives.c @@ -918,7 +918,7 @@ do_line (cpp_reader *pfile) { cpp_string s = { 0, 0 }; if (cpp_interpret_string_notranslate (pfile, &token->val.str, 1, - &s, false)) + &s, CPP_STRING)) new_file = (const char *)s.text; check_eol (pfile, true); } @@ -974,7 +974,7 @@ do_linemarker (cpp_reader *pfile) { cpp_string s = { 0, 0 }; if (cpp_interpret_string_notranslate (pfile, &token->val.str, - 1, &s, false)) + 1, &s, CPP_STRING)) new_file = (const char *)s.text; new_sysp = 0; diff --git a/libcpp/files.c b/libcpp/files.c index c8c19021f56..69aa7895361 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -381,8 +381,8 @@ find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch) /* We copy the path name onto an obstack partly so that we don't leak the memory, but mostly so that we don't fragment the heap. */ - copy = obstack_copy0 (&pfile->nonexistent_file_ob, path, - strlen (path)); + copy = (char *) obstack_copy0 (&pfile->nonexistent_file_ob, path, + strlen (path)); free (path); pp = htab_find_slot_with_hash (pfile->nonexistent_file_hash, copy, hv, INSERT); @@ -1144,7 +1144,7 @@ file_hash_eq (const void *p, const void *q) static int nonexistent_file_hash_eq (const void *p, const void *q) { - return strcmp (p, q) == 0; + return strcmp ((const char *) p, (const char *) q) == 0; } /* Initialize everything in this source file. */ diff --git a/libcpp/include/cpp-id-data.h b/libcpp/include/cpp-id-data.h index d2adbfaebdf..a57edad521d 100644 --- a/libcpp/include/cpp-id-data.h +++ b/libcpp/include/cpp-id-data.h @@ -18,10 +18,6 @@ along with this program; see the file COPYING3. If not see #include "cpplib.h" -#ifdef __cplusplus -extern "C" { -#endif - #if !defined (HAVE_UCHAR) && !defined (IN_GCC) typedef unsigned char uchar; #endif @@ -83,7 +79,3 @@ struct GTY(()) cpp_macro { tokens. */ unsigned int extra_tokens : 1; }; - -#ifdef __cplusplus -} -#endif diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index d39b80e2a5a..71c7ef26351 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -28,10 +28,6 @@ along with this program; see the file COPYING3. If not see #include "symtab.h" #include "line-map.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef struct cpp_reader cpp_reader; typedef struct cpp_buffer cpp_buffer; typedef struct cpp_options cpp_options; @@ -933,8 +929,4 @@ extern void cpp_prepare_state (cpp_reader *, struct save_macro_data **); extern int cpp_read_state (cpp_reader *, const char *, FILE *, struct save_macro_data *); -#ifdef __cplusplus -} -#endif - #endif /* ! LIBCPP_CPPLIB_H */ diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 09e72f14d4b..31ac8e5d4c3 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -23,10 +23,6 @@ along with this program; see the file COPYING3. If not see #ifndef LIBCPP_LINE_MAP_H #define LIBCPP_LINE_MAP_H -#ifdef __cplusplus -extern "C" { -#endif - #ifndef GTY #define GTY(x) /* nothing */ #endif @@ -191,8 +187,4 @@ extern const struct line_map *linemap_lookup extern source_location linemap_position_for_column (struct line_maps *set, unsigned int to_column); -#ifdef __cplusplus -} -#endif - #endif /* !LIBCPP_LINE_MAP_H */ diff --git a/libcpp/include/mkdeps.h b/libcpp/include/mkdeps.h index def7b5641f8..50bcee40726 100644 --- a/libcpp/include/mkdeps.h +++ b/libcpp/include/mkdeps.h @@ -23,10 +23,6 @@ along with this program; see the file COPYING3. If not see #ifndef LIBCPP_MKDEPS_H #define LIBCPP_MKDEPS_H -#ifdef __cplusplus -extern "C" { -#endif - /* This is the data structure used by all the functions in mkdeps.c. It's quite straightforward, but should be treated as opaque. */ @@ -80,8 +76,4 @@ extern int deps_restore (struct deps *, FILE *, const char *); automatic dependency schemes. */ extern void deps_phony_targets (const struct deps *, FILE *); -#ifdef __cplusplus -} -#endif - #endif /* ! LIBCPP_MKDEPS_H */ diff --git a/libcpp/include/symtab.h b/libcpp/include/symtab.h index e1bc00cb6f6..ebb56007a03 100644 --- a/libcpp/include/symtab.h +++ b/libcpp/include/symtab.h @@ -21,10 +21,6 @@ along with this program; see the file COPYING3. If not see #include "obstack.h" -#ifdef __cplusplus -extern "C" { -#endif - #ifndef GTY #define GTY(x) /* nothing */ #endif @@ -104,8 +100,4 @@ extern void ht_load (hash_table *ht, hashnode *entries, /* Dump allocation statistics to stderr. */ extern void ht_dump_statistics (hash_table *); -#ifdef __cplusplus -} -#endif - #endif /* LIBCPP_SYMTAB_H */ diff --git a/libcpp/symtab.c b/libcpp/symtab.c index 086d775d599..48a5338b1f8 100644 --- a/libcpp/symtab.c +++ b/libcpp/symtab.c @@ -163,7 +163,7 @@ ht_lookup_with_hash (hash_table *table, const unsigned char *str, if (table->alloc_subobject) { - char *chars = table->alloc_subobject (len + 1); + char *chars = (char *) table->alloc_subobject (len + 1); memcpy (chars, str, len); chars[len] = '\0'; HT_STR (node) = (const unsigned char *) chars; diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 932c85efd7c..8231ed1588c 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,197 @@ +2009-07-19 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR libfortran/34670 + PR libfortran/36874 + * Makefile.am: Add bounds.c + * libgfortran.h (bounds_equal_extents): Add prototype. + (bounds_iforeach_return): Likewise. + (bounds_ifunction_return): Likewise. + (bounds_reduced_extents): Likewise. + * runtime/bounds.c: New file. + (bounds_iforeach_return): New function; correct typo in + error message. + (bounds_ifunction_return): New function. + (bounds_equal_extents): New function. + (bounds_reduced_extents): Likewise. + * intrinsics/cshift0.c (cshift0): Use new functions + for bounds checking. + * intrinsics/eoshift0.c (eoshift0): Likewise. + * intrinsics/eoshift2.c (eoshift2): Likewise. + * m4/iforeach.m4: Likewise. + * m4/eoshift1.m4: Likewise. + * m4/eoshift3.m4: Likewise. + * m4/cshift1.m4: Likewise. + * m4/ifunction.m4: Likewise. + * Makefile.in: Regenerated. + * generated/cshift1_16.c: Regenerated. + * generated/cshift1_4.c: Regenerated. + * generated/cshift1_8.c: Regenerated. + * generated/eoshift1_16.c: Regenerated. + * generated/eoshift1_4.c: Regenerated. + * generated/eoshift1_8.c: Regenerated. + * generated/eoshift3_16.c: Regenerated. + * generated/eoshift3_4.c: Regenerated. + * generated/eoshift3_8.c: Regenerated. + * generated/maxloc0_16_i1.c: Regenerated. + * generated/maxloc0_16_i16.c: Regenerated. + * generated/maxloc0_16_i2.c: Regenerated. + * generated/maxloc0_16_i4.c: Regenerated. + * generated/maxloc0_16_i8.c: Regenerated. + * generated/maxloc0_16_r10.c: Regenerated. + * generated/maxloc0_16_r16.c: Regenerated. + * generated/maxloc0_16_r4.c: Regenerated. + * generated/maxloc0_16_r8.c: Regenerated. + * generated/maxloc0_4_i1.c: Regenerated. + * generated/maxloc0_4_i16.c: Regenerated. + * generated/maxloc0_4_i2.c: Regenerated. + * generated/maxloc0_4_i4.c: Regenerated. + * generated/maxloc0_4_i8.c: Regenerated. + * generated/maxloc0_4_r10.c: Regenerated. + * generated/maxloc0_4_r16.c: Regenerated. + * generated/maxloc0_4_r4.c: Regenerated. + * generated/maxloc0_4_r8.c: Regenerated. + * generated/maxloc0_8_i1.c: Regenerated. + * generated/maxloc0_8_i16.c: Regenerated. + * generated/maxloc0_8_i2.c: Regenerated. + * generated/maxloc0_8_i4.c: Regenerated. + * generated/maxloc0_8_i8.c: Regenerated. + * generated/maxloc0_8_r10.c: Regenerated. + * generated/maxloc0_8_r16.c: Regenerated. + * generated/maxloc0_8_r4.c: Regenerated. + * generated/maxloc0_8_r8.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/minloc0_16_i1.c: Regenerated. + * generated/minloc0_16_i16.c: Regenerated. + * generated/minloc0_16_i2.c: Regenerated. + * generated/minloc0_16_i4.c: Regenerated. + * generated/minloc0_16_i8.c: Regenerated. + * generated/minloc0_16_r10.c: Regenerated. + * generated/minloc0_16_r16.c: Regenerated. + * generated/minloc0_16_r4.c: Regenerated. + * generated/minloc0_16_r8.c: Regenerated. + * generated/minloc0_4_i1.c: Regenerated. + * generated/minloc0_4_i16.c: Regenerated. + * generated/minloc0_4_i2.c: Regenerated. + * generated/minloc0_4_i4.c: Regenerated. + * generated/minloc0_4_i8.c: Regenerated. + * generated/minloc0_4_r10.c: Regenerated. + * generated/minloc0_4_r16.c: Regenerated. + * generated/minloc0_4_r4.c: Regenerated. + * generated/minloc0_4_r8.c: Regenerated. + * generated/minloc0_8_i1.c: Regenerated. + * generated/minloc0_8_i16.c: Regenerated. + * generated/minloc0_8_i2.c: Regenerated. + * generated/minloc0_8_i4.c: Regenerated. + * generated/minloc0_8_i8.c: Regenerated. + * generated/minloc0_8_r10.c: Regenerated. + * generated/minloc0_8_r16.c: Regenerated. + * generated/minloc0_8_r4.c: Regenerated. + * generated/minloc0_8_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. + +2009-07-17 Janne Blomqvist <jb@gcc.gnu.org> + Jerry DeLisle <jvdelisle@gcc.gnu.org> + + PR libfortran/40714 + * io/transfer.c (finalize_transfer): Set current_record to 0 + before returning in case of error. + 2009-07-12 Tobias Burnus <burnus@net-b.de> PR libfortran/22423 diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am index f5f92dfb432..4a974ba0066 100644 --- a/libgfortran/Makefile.am +++ b/libgfortran/Makefile.am @@ -122,6 +122,7 @@ runtime/in_unpack_generic.c gfor_src= \ runtime/backtrace.c \ +runtime/bounds.c \ runtime/compile_options.c \ runtime/convert_char.c \ runtime/environ.c \ diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in index ce2b5a21cb1..7741c324aaf 100644 --- a/libgfortran/Makefile.in +++ b/libgfortran/Makefile.in @@ -78,7 +78,7 @@ myexeclibLTLIBRARIES_INSTALL = $(INSTALL) toolexeclibLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(myexeclib_LTLIBRARIES) $(toolexeclib_LTLIBRARIES) libgfortran_la_LIBADD = -am__libgfortran_la_SOURCES_DIST = runtime/backtrace.c \ +am__libgfortran_la_SOURCES_DIST = runtime/backtrace.c runtime/bounds.c \ runtime/compile_options.c runtime/convert_char.c \ runtime/environ.c runtime/error.c runtime/fpu.c runtime/main.c \ runtime/memory.c runtime/pause.c runtime/stop.c \ @@ -580,9 +580,9 @@ am__libgfortran_la_SOURCES_DIST = runtime/backtrace.c \ $(srcdir)/generated/misc_specifics.F90 intrinsics/dprod_r8.f90 \ intrinsics/f2c_specifics.F90 libgfortran_c.c $(filter-out \ %.c,$(prereq_SRC)) -am__objects_1 = backtrace.lo compile_options.lo convert_char.lo \ - environ.lo error.lo fpu.lo main.lo memory.lo pause.lo stop.lo \ - string.lo select.lo +am__objects_1 = backtrace.lo bounds.lo compile_options.lo \ + convert_char.lo environ.lo error.lo fpu.lo main.lo memory.lo \ + pause.lo stop.lo string.lo select.lo am__objects_2 = all_l1.lo all_l2.lo all_l4.lo all_l8.lo all_l16.lo am__objects_3 = any_l1.lo any_l2.lo any_l4.lo any_l8.lo any_l16.lo am__objects_4 = count_1_l.lo count_2_l.lo count_4_l.lo count_8_l.lo \ @@ -1050,6 +1050,7 @@ runtime/in_unpack_generic.c gfor_src = \ runtime/backtrace.c \ +runtime/bounds.c \ runtime/compile_options.c \ runtime/convert_char.c \ runtime/environ.c \ @@ -1806,6 +1807,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/associated.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backtrace.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bit_intrinsics.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bounds.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c99_functions.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chdir.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chmod.Plo@am__quote@ @@ -2678,6 +2680,13 @@ backtrace.lo: runtime/backtrace.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o backtrace.lo `test -f 'runtime/backtrace.c' || echo '$(srcdir)/'`runtime/backtrace.c +bounds.lo: runtime/bounds.c +@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bounds.lo -MD -MP -MF "$(DEPDIR)/bounds.Tpo" -c -o bounds.lo `test -f 'runtime/bounds.c' || echo '$(srcdir)/'`runtime/bounds.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/bounds.Tpo" "$(DEPDIR)/bounds.Plo"; else rm -f "$(DEPDIR)/bounds.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runtime/bounds.c' object='bounds.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bounds.lo `test -f 'runtime/bounds.c' || echo '$(srcdir)/'`runtime/bounds.c + compile_options.lo: runtime/compile_options.c @am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT compile_options.lo -MD -MP -MF "$(DEPDIR)/compile_options.Tpo" -c -o compile_options.lo `test -f 'runtime/compile_options.c' || echo '$(srcdir)/'`runtime/compile_options.c; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/compile_options.Tpo" "$(DEPDIR)/compile_options.Plo"; else rm -f "$(DEPDIR)/compile_options.Tpo"; exit 1; fi diff --git a/libgfortran/generated/cshift1_16.c b/libgfortran/generated/cshift1_16.c index df97dfa6b76..b2cb7f17ce4 100644 --- a/libgfortran/generated/cshift1_16.c +++ b/libgfortran/generated/cshift1_16.c @@ -98,6 +98,17 @@ cshift1 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } } + else if (unlikely (compile_options.bounds_check)) + { + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "CSHIFT"); + } + + if (unlikely (compile_options.bounds_check)) + { + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "CSHIFT"); + } if (arraysize == 0) return; diff --git a/libgfortran/generated/cshift1_4.c b/libgfortran/generated/cshift1_4.c index f048e8e401f..30f3d99dc35 100644 --- a/libgfortran/generated/cshift1_4.c +++ b/libgfortran/generated/cshift1_4.c @@ -98,6 +98,17 @@ cshift1 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } } + else if (unlikely (compile_options.bounds_check)) + { + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "CSHIFT"); + } + + if (unlikely (compile_options.bounds_check)) + { + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "CSHIFT"); + } if (arraysize == 0) return; diff --git a/libgfortran/generated/cshift1_8.c b/libgfortran/generated/cshift1_8.c index 9667728f392..c3bf473e49c 100644 --- a/libgfortran/generated/cshift1_8.c +++ b/libgfortran/generated/cshift1_8.c @@ -98,6 +98,17 @@ cshift1 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } } + else if (unlikely (compile_options.bounds_check)) + { + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "CSHIFT"); + } + + if (unlikely (compile_options.bounds_check)) + { + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "CSHIFT"); + } if (arraysize == 0) return; diff --git a/libgfortran/generated/eoshift1_16.c b/libgfortran/generated/eoshift1_16.c index 02365cc2375..a14bd292715 100644 --- a/libgfortran/generated/eoshift1_16.c +++ b/libgfortran/generated/eoshift1_16.c @@ -62,6 +62,7 @@ eoshift1 (gfc_array_char * const restrict ret, index_type len; index_type n; index_type size; + index_type arraysize; int which; GFC_INTEGER_16 sh; GFC_INTEGER_16 delta; @@ -82,11 +83,12 @@ eoshift1 (gfc_array_char * const restrict ret, extent[0] = 1; count[0] = 0; + arraysize = size0 ((array_t *) array); if (ret->data == NULL) { int i; - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); + ret->data = internal_malloc_size (size * arraysize); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -104,13 +106,27 @@ eoshift1 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } - else + else if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); } + if (unlikely (compile_options.bounds_check)) + { + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "EOSHIFT"); + } + + if (arraysize == 0) + return; + n = 0; for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++) { diff --git a/libgfortran/generated/eoshift1_4.c b/libgfortran/generated/eoshift1_4.c index e703db47786..06bc309c4a8 100644 --- a/libgfortran/generated/eoshift1_4.c +++ b/libgfortran/generated/eoshift1_4.c @@ -62,6 +62,7 @@ eoshift1 (gfc_array_char * const restrict ret, index_type len; index_type n; index_type size; + index_type arraysize; int which; GFC_INTEGER_4 sh; GFC_INTEGER_4 delta; @@ -82,11 +83,12 @@ eoshift1 (gfc_array_char * const restrict ret, extent[0] = 1; count[0] = 0; + arraysize = size0 ((array_t *) array); if (ret->data == NULL) { int i; - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); + ret->data = internal_malloc_size (size * arraysize); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -104,13 +106,27 @@ eoshift1 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } - else + else if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); } + if (unlikely (compile_options.bounds_check)) + { + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "EOSHIFT"); + } + + if (arraysize == 0) + return; + n = 0; for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++) { diff --git a/libgfortran/generated/eoshift1_8.c b/libgfortran/generated/eoshift1_8.c index f8922b344a5..3e9162d0f08 100644 --- a/libgfortran/generated/eoshift1_8.c +++ b/libgfortran/generated/eoshift1_8.c @@ -62,6 +62,7 @@ eoshift1 (gfc_array_char * const restrict ret, index_type len; index_type n; index_type size; + index_type arraysize; int which; GFC_INTEGER_8 sh; GFC_INTEGER_8 delta; @@ -82,11 +83,12 @@ eoshift1 (gfc_array_char * const restrict ret, extent[0] = 1; count[0] = 0; + arraysize = size0 ((array_t *) array); if (ret->data == NULL) { int i; - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); + ret->data = internal_malloc_size (size * arraysize); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -104,13 +106,27 @@ eoshift1 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } - else + else if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); } + if (unlikely (compile_options.bounds_check)) + { + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "EOSHIFT"); + } + + if (arraysize == 0) + return; + n = 0; for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++) { diff --git a/libgfortran/generated/eoshift3_16.c b/libgfortran/generated/eoshift3_16.c index c3efae9acbf..ec21d1ec14d 100644 --- a/libgfortran/generated/eoshift3_16.c +++ b/libgfortran/generated/eoshift3_16.c @@ -66,6 +66,7 @@ eoshift3 (gfc_array_char * const restrict ret, index_type len; index_type n; index_type size; + index_type arraysize; int which; GFC_INTEGER_16 sh; GFC_INTEGER_16 delta; @@ -76,6 +77,7 @@ eoshift3 (gfc_array_char * const restrict ret, soffset = 0; roffset = 0; + arraysize = size0 ((array_t *) array); size = GFC_DESCRIPTOR_SIZE(array); if (pwhich) @@ -87,7 +89,7 @@ eoshift3 (gfc_array_char * const restrict ret, { int i; - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); + ret->data = internal_malloc_size (size * arraysize); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -105,13 +107,26 @@ eoshift3 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } - else + else if (unlikely (compile_options.bounds_check)) + { + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); + } + + if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "EOSHIFT"); } + if (arraysize == 0) + return; extent[0] = 1; count[0] = 0; diff --git a/libgfortran/generated/eoshift3_4.c b/libgfortran/generated/eoshift3_4.c index 5038c0916bd..ce4cede1f1d 100644 --- a/libgfortran/generated/eoshift3_4.c +++ b/libgfortran/generated/eoshift3_4.c @@ -66,6 +66,7 @@ eoshift3 (gfc_array_char * const restrict ret, index_type len; index_type n; index_type size; + index_type arraysize; int which; GFC_INTEGER_4 sh; GFC_INTEGER_4 delta; @@ -76,6 +77,7 @@ eoshift3 (gfc_array_char * const restrict ret, soffset = 0; roffset = 0; + arraysize = size0 ((array_t *) array); size = GFC_DESCRIPTOR_SIZE(array); if (pwhich) @@ -87,7 +89,7 @@ eoshift3 (gfc_array_char * const restrict ret, { int i; - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); + ret->data = internal_malloc_size (size * arraysize); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -105,13 +107,26 @@ eoshift3 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } - else + else if (unlikely (compile_options.bounds_check)) + { + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); + } + + if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "EOSHIFT"); } + if (arraysize == 0) + return; extent[0] = 1; count[0] = 0; diff --git a/libgfortran/generated/eoshift3_8.c b/libgfortran/generated/eoshift3_8.c index f745a1d268f..4af36f72bb4 100644 --- a/libgfortran/generated/eoshift3_8.c +++ b/libgfortran/generated/eoshift3_8.c @@ -66,6 +66,7 @@ eoshift3 (gfc_array_char * const restrict ret, index_type len; index_type n; index_type size; + index_type arraysize; int which; GFC_INTEGER_8 sh; GFC_INTEGER_8 delta; @@ -76,6 +77,7 @@ eoshift3 (gfc_array_char * const restrict ret, soffset = 0; roffset = 0; + arraysize = size0 ((array_t *) array); size = GFC_DESCRIPTOR_SIZE(array); if (pwhich) @@ -87,7 +89,7 @@ eoshift3 (gfc_array_char * const restrict ret, { int i; - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); + ret->data = internal_malloc_size (size * arraysize); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -105,13 +107,26 @@ eoshift3 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } - else + else if (unlikely (compile_options.bounds_check)) + { + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); + } + + if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "EOSHIFT"); } + if (arraysize == 0) + return; extent[0] = 1; count[0] = 0; diff --git a/libgfortran/generated/maxloc0_16_i1.c b/libgfortran/generated/maxloc0_16_i1.c index b43f08337c7..c9f58e33ea6 100644 --- a/libgfortran/generated/maxloc0_16_i1.c +++ b/libgfortran/generated/maxloc0_16_i1.c @@ -63,21 +63,8 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_16_i1 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_16_i1 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_16_i16.c b/libgfortran/generated/maxloc0_16_i16.c index 26941a741f9..8adbc932279 100644 --- a/libgfortran/generated/maxloc0_16_i16.c +++ b/libgfortran/generated/maxloc0_16_i16.c @@ -63,21 +63,8 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_16_i16 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_16_i16 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_16_i2.c b/libgfortran/generated/maxloc0_16_i2.c index e1d329c583c..16849c27363 100644 --- a/libgfortran/generated/maxloc0_16_i2.c +++ b/libgfortran/generated/maxloc0_16_i2.c @@ -63,21 +63,8 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_16_i2 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_16_i2 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_16_i4.c b/libgfortran/generated/maxloc0_16_i4.c index 4d1d0a11acd..a6e979ce489 100644 --- a/libgfortran/generated/maxloc0_16_i4.c +++ b/libgfortran/generated/maxloc0_16_i4.c @@ -63,21 +63,8 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_16_i4 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_16_i4 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_16_i8.c b/libgfortran/generated/maxloc0_16_i8.c index 12147a0e2fa..8e2d4bc0a35 100644 --- a/libgfortran/generated/maxloc0_16_i8.c +++ b/libgfortran/generated/maxloc0_16_i8.c @@ -63,21 +63,8 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_16_i8 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_16_i8 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_16_r10.c b/libgfortran/generated/maxloc0_16_r10.c index 33c73083cc7..d76e947aa0d 100644 --- a/libgfortran/generated/maxloc0_16_r10.c +++ b/libgfortran/generated/maxloc0_16_r10.c @@ -63,21 +63,8 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_16_r10 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_16_r10 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_16_r16.c b/libgfortran/generated/maxloc0_16_r16.c index 4f4f290fee9..2e6dcf1dcfa 100644 --- a/libgfortran/generated/maxloc0_16_r16.c +++ b/libgfortran/generated/maxloc0_16_r16.c @@ -63,21 +63,8 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_16_r16 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_16_r16 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_16_r4.c b/libgfortran/generated/maxloc0_16_r4.c index 86cedb3a420..5d1fe355faf 100644 --- a/libgfortran/generated/maxloc0_16_r4.c +++ b/libgfortran/generated/maxloc0_16_r4.c @@ -63,21 +63,8 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_16_r4 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_16_r4 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_16_r8.c b/libgfortran/generated/maxloc0_16_r8.c index 378024bff76..dc489f31116 100644 --- a/libgfortran/generated/maxloc0_16_r8.c +++ b/libgfortran/generated/maxloc0_16_r8.c @@ -63,21 +63,8 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_16_r8 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_16_r8 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_4_i1.c b/libgfortran/generated/maxloc0_4_i1.c index 7475059164c..7cdd813391e 100644 --- a/libgfortran/generated/maxloc0_4_i1.c +++ b/libgfortran/generated/maxloc0_4_i1.c @@ -63,21 +63,8 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_4_i1 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_4_i1 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_4_i16.c b/libgfortran/generated/maxloc0_4_i16.c index 268f09af8de..b2bc05307eb 100644 --- a/libgfortran/generated/maxloc0_4_i16.c +++ b/libgfortran/generated/maxloc0_4_i16.c @@ -63,21 +63,8 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_4_i16 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_4_i16 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_4_i2.c b/libgfortran/generated/maxloc0_4_i2.c index 47fb135c50d..fb3b40bd791 100644 --- a/libgfortran/generated/maxloc0_4_i2.c +++ b/libgfortran/generated/maxloc0_4_i2.c @@ -63,21 +63,8 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_4_i2 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_4_i2 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_4_i4.c b/libgfortran/generated/maxloc0_4_i4.c index 55bc2752131..2a84c7f4897 100644 --- a/libgfortran/generated/maxloc0_4_i4.c +++ b/libgfortran/generated/maxloc0_4_i4.c @@ -63,21 +63,8 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_4_i4 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_4_i4 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_4_i8.c b/libgfortran/generated/maxloc0_4_i8.c index f598f050fd4..2e1fa6daef8 100644 --- a/libgfortran/generated/maxloc0_4_i8.c +++ b/libgfortran/generated/maxloc0_4_i8.c @@ -63,21 +63,8 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_4_i8 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_4_i8 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_4_r10.c b/libgfortran/generated/maxloc0_4_r10.c index 5c99198b201..934337a6ac0 100644 --- a/libgfortran/generated/maxloc0_4_r10.c +++ b/libgfortran/generated/maxloc0_4_r10.c @@ -63,21 +63,8 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_4_r10 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_4_r10 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_4_r16.c b/libgfortran/generated/maxloc0_4_r16.c index c7609c35dc3..c2660258a31 100644 --- a/libgfortran/generated/maxloc0_4_r16.c +++ b/libgfortran/generated/maxloc0_4_r16.c @@ -63,21 +63,8 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_4_r16 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_4_r16 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_4_r4.c b/libgfortran/generated/maxloc0_4_r4.c index 50f3c3b6d1a..a3499531d27 100644 --- a/libgfortran/generated/maxloc0_4_r4.c +++ b/libgfortran/generated/maxloc0_4_r4.c @@ -63,21 +63,8 @@ maxloc0_4_r4 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_4_r4 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_4_r4 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_4_r8.c b/libgfortran/generated/maxloc0_4_r8.c index 30dc2976c3e..7180bf8ce60 100644 --- a/libgfortran/generated/maxloc0_4_r8.c +++ b/libgfortran/generated/maxloc0_4_r8.c @@ -63,21 +63,8 @@ maxloc0_4_r8 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_4_r8 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_4_r8 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_8_i1.c b/libgfortran/generated/maxloc0_8_i1.c index eb1737d23e3..a850603e5c5 100644 --- a/libgfortran/generated/maxloc0_8_i1.c +++ b/libgfortran/generated/maxloc0_8_i1.c @@ -63,21 +63,8 @@ maxloc0_8_i1 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_8_i1 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_8_i1 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_8_i16.c b/libgfortran/generated/maxloc0_8_i16.c index 6690c2da4b7..73683d89589 100644 --- a/libgfortran/generated/maxloc0_8_i16.c +++ b/libgfortran/generated/maxloc0_8_i16.c @@ -63,21 +63,8 @@ maxloc0_8_i16 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_8_i16 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_8_i16 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_8_i2.c b/libgfortran/generated/maxloc0_8_i2.c index b9bb230589f..3b8e793e4ce 100644 --- a/libgfortran/generated/maxloc0_8_i2.c +++ b/libgfortran/generated/maxloc0_8_i2.c @@ -63,21 +63,8 @@ maxloc0_8_i2 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_8_i2 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_8_i2 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_8_i4.c b/libgfortran/generated/maxloc0_8_i4.c index 57781469089..1b0bc42bf69 100644 --- a/libgfortran/generated/maxloc0_8_i4.c +++ b/libgfortran/generated/maxloc0_8_i4.c @@ -63,21 +63,8 @@ maxloc0_8_i4 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_8_i4 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_8_i4 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_8_i8.c b/libgfortran/generated/maxloc0_8_i8.c index ef7dedeb984..5bf95201d7c 100644 --- a/libgfortran/generated/maxloc0_8_i8.c +++ b/libgfortran/generated/maxloc0_8_i8.c @@ -63,21 +63,8 @@ maxloc0_8_i8 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_8_i8 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_8_i8 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_8_r10.c b/libgfortran/generated/maxloc0_8_r10.c index 0c08d8e803a..28008d4a0c4 100644 --- a/libgfortran/generated/maxloc0_8_r10.c +++ b/libgfortran/generated/maxloc0_8_r10.c @@ -63,21 +63,8 @@ maxloc0_8_r10 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_8_r10 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_8_r10 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_8_r16.c b/libgfortran/generated/maxloc0_8_r16.c index da61d2b6983..04bfd57e1fc 100644 --- a/libgfortran/generated/maxloc0_8_r16.c +++ b/libgfortran/generated/maxloc0_8_r16.c @@ -63,21 +63,8 @@ maxloc0_8_r16 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_8_r16 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_8_r16 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_8_r4.c b/libgfortran/generated/maxloc0_8_r4.c index a26b110220d..238b8699bac 100644 --- a/libgfortran/generated/maxloc0_8_r4.c +++ b/libgfortran/generated/maxloc0_8_r4.c @@ -63,21 +63,8 @@ maxloc0_8_r4 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_8_r4 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_8_r4 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc0_8_r8.c b/libgfortran/generated/maxloc0_8_r8.c index 1198d624c54..16d9a45331a 100644 --- a/libgfortran/generated/maxloc0_8_r8.c +++ b/libgfortran/generated/maxloc0_8_r8.c @@ -63,21 +63,8 @@ maxloc0_8_r8 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mmaxloc0_8_r8 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MAXLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MAXLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } @@ -340,22 +300,10 @@ smaxloc0_8_r8 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MAXLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/maxloc1_16_i1.c b/libgfortran/generated/maxloc1_16_i1.c index a776f4f1c7a..9be5cdd6d45 100644 --- a/libgfortran/generated/maxloc1_16_i1.c +++ b/libgfortran/generated/maxloc1_16_i1.c @@ -120,19 +120,8 @@ maxloc1_16_i1 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_16_i16.c b/libgfortran/generated/maxloc1_16_i16.c index 827b3e6708c..9118f85c73c 100644 --- a/libgfortran/generated/maxloc1_16_i16.c +++ b/libgfortran/generated/maxloc1_16_i16.c @@ -120,19 +120,8 @@ maxloc1_16_i16 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_16_i2.c b/libgfortran/generated/maxloc1_16_i2.c index 24a34e3343f..66b24b0fadf 100644 --- a/libgfortran/generated/maxloc1_16_i2.c +++ b/libgfortran/generated/maxloc1_16_i2.c @@ -120,19 +120,8 @@ maxloc1_16_i2 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_16_i4.c b/libgfortran/generated/maxloc1_16_i4.c index 0194f28fc27..3f6c952ebe6 100644 --- a/libgfortran/generated/maxloc1_16_i4.c +++ b/libgfortran/generated/maxloc1_16_i4.c @@ -120,19 +120,8 @@ maxloc1_16_i4 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_16_i8.c b/libgfortran/generated/maxloc1_16_i8.c index bb1750028f1..141dc5142ef 100644 --- a/libgfortran/generated/maxloc1_16_i8.c +++ b/libgfortran/generated/maxloc1_16_i8.c @@ -120,19 +120,8 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_16_r10.c b/libgfortran/generated/maxloc1_16_r10.c index dc8cd5dd425..74bc4d30562 100644 --- a/libgfortran/generated/maxloc1_16_r10.c +++ b/libgfortran/generated/maxloc1_16_r10.c @@ -120,19 +120,8 @@ maxloc1_16_r10 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_16_r16.c b/libgfortran/generated/maxloc1_16_r16.c index 1664edb4b35..cadca8bedb2 100644 --- a/libgfortran/generated/maxloc1_16_r16.c +++ b/libgfortran/generated/maxloc1_16_r16.c @@ -120,19 +120,8 @@ maxloc1_16_r16 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_16_r4.c b/libgfortran/generated/maxloc1_16_r4.c index 58bfcc0f8ec..f2afd83ab32 100644 --- a/libgfortran/generated/maxloc1_16_r4.c +++ b/libgfortran/generated/maxloc1_16_r4.c @@ -120,19 +120,8 @@ maxloc1_16_r4 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_16_r8.c b/libgfortran/generated/maxloc1_16_r8.c index d646d2547f8..3da10665b72 100644 --- a/libgfortran/generated/maxloc1_16_r8.c +++ b/libgfortran/generated/maxloc1_16_r8.c @@ -120,19 +120,8 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_4_i1.c b/libgfortran/generated/maxloc1_4_i1.c index 39291ff4db3..3a76e0ee626 100644 --- a/libgfortran/generated/maxloc1_4_i1.c +++ b/libgfortran/generated/maxloc1_4_i1.c @@ -120,19 +120,8 @@ maxloc1_4_i1 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_4_i16.c b/libgfortran/generated/maxloc1_4_i16.c index 059cacb22e5..7c3bc2dd3fb 100644 --- a/libgfortran/generated/maxloc1_4_i16.c +++ b/libgfortran/generated/maxloc1_4_i16.c @@ -120,19 +120,8 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_4_i2.c b/libgfortran/generated/maxloc1_4_i2.c index 64cee3e8725..cdcdfa4383a 100644 --- a/libgfortran/generated/maxloc1_4_i2.c +++ b/libgfortran/generated/maxloc1_4_i2.c @@ -120,19 +120,8 @@ maxloc1_4_i2 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_4_i4.c b/libgfortran/generated/maxloc1_4_i4.c index f8a843e5c5b..bf60007dd23 100644 --- a/libgfortran/generated/maxloc1_4_i4.c +++ b/libgfortran/generated/maxloc1_4_i4.c @@ -120,19 +120,8 @@ maxloc1_4_i4 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_4_i8.c b/libgfortran/generated/maxloc1_4_i8.c index 293c2a9cb2e..18edc044d99 100644 --- a/libgfortran/generated/maxloc1_4_i8.c +++ b/libgfortran/generated/maxloc1_4_i8.c @@ -120,19 +120,8 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_4_r10.c b/libgfortran/generated/maxloc1_4_r10.c index 89982795e81..bae17fe5f36 100644 --- a/libgfortran/generated/maxloc1_4_r10.c +++ b/libgfortran/generated/maxloc1_4_r10.c @@ -120,19 +120,8 @@ maxloc1_4_r10 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_4_r16.c b/libgfortran/generated/maxloc1_4_r16.c index 191ba998242..811f01c2176 100644 --- a/libgfortran/generated/maxloc1_4_r16.c +++ b/libgfortran/generated/maxloc1_4_r16.c @@ -120,19 +120,8 @@ maxloc1_4_r16 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_4_r4.c b/libgfortran/generated/maxloc1_4_r4.c index 1f445e7306a..065770f1a7a 100644 --- a/libgfortran/generated/maxloc1_4_r4.c +++ b/libgfortran/generated/maxloc1_4_r4.c @@ -120,19 +120,8 @@ maxloc1_4_r4 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_4_r8.c b/libgfortran/generated/maxloc1_4_r8.c index 170e3dfce1a..e0835079345 100644 --- a/libgfortran/generated/maxloc1_4_r8.c +++ b/libgfortran/generated/maxloc1_4_r8.c @@ -120,19 +120,8 @@ maxloc1_4_r8 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_8_i1.c b/libgfortran/generated/maxloc1_8_i1.c index 9924b718847..b1d1f0e8dc8 100644 --- a/libgfortran/generated/maxloc1_8_i1.c +++ b/libgfortran/generated/maxloc1_8_i1.c @@ -120,19 +120,8 @@ maxloc1_8_i1 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_8_i16.c b/libgfortran/generated/maxloc1_8_i16.c index 97946f3dd52..3028b2de6fb 100644 --- a/libgfortran/generated/maxloc1_8_i16.c +++ b/libgfortran/generated/maxloc1_8_i16.c @@ -120,19 +120,8 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_8_i2.c b/libgfortran/generated/maxloc1_8_i2.c index d343b0b36c3..74d7fb306b4 100644 --- a/libgfortran/generated/maxloc1_8_i2.c +++ b/libgfortran/generated/maxloc1_8_i2.c @@ -120,19 +120,8 @@ maxloc1_8_i2 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_8_i4.c b/libgfortran/generated/maxloc1_8_i4.c index 682de41af38..fcf11b8ffbf 100644 --- a/libgfortran/generated/maxloc1_8_i4.c +++ b/libgfortran/generated/maxloc1_8_i4.c @@ -120,19 +120,8 @@ maxloc1_8_i4 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c index e17ecc49915..1210fb12a82 100644 --- a/libgfortran/generated/maxloc1_8_i8.c +++ b/libgfortran/generated/maxloc1_8_i8.c @@ -120,19 +120,8 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_8_r10.c b/libgfortran/generated/maxloc1_8_r10.c index cb4b69201ee..e0873d2590e 100644 --- a/libgfortran/generated/maxloc1_8_r10.c +++ b/libgfortran/generated/maxloc1_8_r10.c @@ -120,19 +120,8 @@ maxloc1_8_r10 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_8_r16.c b/libgfortran/generated/maxloc1_8_r16.c index 5a99dafa388..83d84c58ef1 100644 --- a/libgfortran/generated/maxloc1_8_r16.c +++ b/libgfortran/generated/maxloc1_8_r16.c @@ -120,19 +120,8 @@ maxloc1_8_r16 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_8_r4.c b/libgfortran/generated/maxloc1_8_r4.c index ba88d8ee418..94250d30a9d 100644 --- a/libgfortran/generated/maxloc1_8_r4.c +++ b/libgfortran/generated/maxloc1_8_r4.c @@ -120,19 +120,8 @@ maxloc1_8_r4 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxloc1_8_r8.c b/libgfortran/generated/maxloc1_8_r8.c index 6d05b43051d..4b759782227 100644 --- a/libgfortran/generated/maxloc1_8_r8.c +++ b/libgfortran/generated/maxloc1_8_r8.c @@ -120,19 +120,8 @@ maxloc1_8_r8 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXLOC"); } } diff --git a/libgfortran/generated/maxval_i1.c b/libgfortran/generated/maxval_i1.c index 10193fdf95d..cbffa3021aa 100644 --- a/libgfortran/generated/maxval_i1.c +++ b/libgfortran/generated/maxval_i1.c @@ -119,19 +119,8 @@ maxval_i1 (gfc_array_i1 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mmaxval_i1 (gfc_array_i1 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXVAL"); } } diff --git a/libgfortran/generated/maxval_i16.c b/libgfortran/generated/maxval_i16.c index 884ed6678f2..e0e53411e36 100644 --- a/libgfortran/generated/maxval_i16.c +++ b/libgfortran/generated/maxval_i16.c @@ -119,19 +119,8 @@ maxval_i16 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXVAL"); } } diff --git a/libgfortran/generated/maxval_i2.c b/libgfortran/generated/maxval_i2.c index 3abe6579749..293a75f57cf 100644 --- a/libgfortran/generated/maxval_i2.c +++ b/libgfortran/generated/maxval_i2.c @@ -119,19 +119,8 @@ maxval_i2 (gfc_array_i2 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mmaxval_i2 (gfc_array_i2 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXVAL"); } } diff --git a/libgfortran/generated/maxval_i4.c b/libgfortran/generated/maxval_i4.c index 57aea5fb429..4d105a0d57f 100644 --- a/libgfortran/generated/maxval_i4.c +++ b/libgfortran/generated/maxval_i4.c @@ -119,19 +119,8 @@ maxval_i4 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXVAL"); } } diff --git a/libgfortran/generated/maxval_i8.c b/libgfortran/generated/maxval_i8.c index 9d7f57c1cba..2ff17283e79 100644 --- a/libgfortran/generated/maxval_i8.c +++ b/libgfortran/generated/maxval_i8.c @@ -119,19 +119,8 @@ maxval_i8 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXVAL"); } } diff --git a/libgfortran/generated/maxval_r10.c b/libgfortran/generated/maxval_r10.c index 2259e8e2be5..356998b3027 100644 --- a/libgfortran/generated/maxval_r10.c +++ b/libgfortran/generated/maxval_r10.c @@ -119,19 +119,8 @@ maxval_r10 (gfc_array_r10 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mmaxval_r10 (gfc_array_r10 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXVAL"); } } diff --git a/libgfortran/generated/maxval_r16.c b/libgfortran/generated/maxval_r16.c index 7efdd65718c..cf281085a16 100644 --- a/libgfortran/generated/maxval_r16.c +++ b/libgfortran/generated/maxval_r16.c @@ -119,19 +119,8 @@ maxval_r16 (gfc_array_r16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mmaxval_r16 (gfc_array_r16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXVAL"); } } diff --git a/libgfortran/generated/maxval_r4.c b/libgfortran/generated/maxval_r4.c index 623c25c7f8e..b2541a2dc1b 100644 --- a/libgfortran/generated/maxval_r4.c +++ b/libgfortran/generated/maxval_r4.c @@ -119,19 +119,8 @@ maxval_r4 (gfc_array_r4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mmaxval_r4 (gfc_array_r4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXVAL"); } } diff --git a/libgfortran/generated/maxval_r8.c b/libgfortran/generated/maxval_r8.c index bdbb26f06d0..8eb0b8684fb 100644 --- a/libgfortran/generated/maxval_r8.c +++ b/libgfortran/generated/maxval_r8.c @@ -119,19 +119,8 @@ maxval_r8 (gfc_array_r8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mmaxval_r8 (gfc_array_r8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MAXVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MAXVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MAXVAL"); } } diff --git a/libgfortran/generated/minloc0_16_i1.c b/libgfortran/generated/minloc0_16_i1.c index 961beb924d3..7a505126bcd 100644 --- a/libgfortran/generated/minloc0_16_i1.c +++ b/libgfortran/generated/minloc0_16_i1.c @@ -63,21 +63,8 @@ minloc0_16_i1 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_16_i1 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_16_i1 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_16_i16.c b/libgfortran/generated/minloc0_16_i16.c index 7303592131c..cfb4115b34f 100644 --- a/libgfortran/generated/minloc0_16_i16.c +++ b/libgfortran/generated/minloc0_16_i16.c @@ -63,21 +63,8 @@ minloc0_16_i16 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_16_i16 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_16_i16 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_16_i2.c b/libgfortran/generated/minloc0_16_i2.c index ee9f46c00b0..6dbbfbb5105 100644 --- a/libgfortran/generated/minloc0_16_i2.c +++ b/libgfortran/generated/minloc0_16_i2.c @@ -63,21 +63,8 @@ minloc0_16_i2 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_16_i2 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_16_i2 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_16_i4.c b/libgfortran/generated/minloc0_16_i4.c index 6d07bbe2669..811ad1fe324 100644 --- a/libgfortran/generated/minloc0_16_i4.c +++ b/libgfortran/generated/minloc0_16_i4.c @@ -63,21 +63,8 @@ minloc0_16_i4 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_16_i4 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_16_i4 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_16_i8.c b/libgfortran/generated/minloc0_16_i8.c index bbacc119ec1..583f489d30c 100644 --- a/libgfortran/generated/minloc0_16_i8.c +++ b/libgfortran/generated/minloc0_16_i8.c @@ -63,21 +63,8 @@ minloc0_16_i8 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_16_i8 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_16_i8 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_16_r10.c b/libgfortran/generated/minloc0_16_r10.c index a77efcdc5c7..fa29e93e2f5 100644 --- a/libgfortran/generated/minloc0_16_r10.c +++ b/libgfortran/generated/minloc0_16_r10.c @@ -63,21 +63,8 @@ minloc0_16_r10 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_16_r10 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_16_r10 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_16_r16.c b/libgfortran/generated/minloc0_16_r16.c index 1d29e07f297..304ca7e95fc 100644 --- a/libgfortran/generated/minloc0_16_r16.c +++ b/libgfortran/generated/minloc0_16_r16.c @@ -63,21 +63,8 @@ minloc0_16_r16 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_16_r16 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_16_r16 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_16_r4.c b/libgfortran/generated/minloc0_16_r4.c index 1c451e9f76b..0ce5e08a673 100644 --- a/libgfortran/generated/minloc0_16_r4.c +++ b/libgfortran/generated/minloc0_16_r4.c @@ -63,21 +63,8 @@ minloc0_16_r4 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_16_r4 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_16_r4 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_16_r8.c b/libgfortran/generated/minloc0_16_r8.c index d6c70869584..8346be1ff4b 100644 --- a/libgfortran/generated/minloc0_16_r8.c +++ b/libgfortran/generated/minloc0_16_r8.c @@ -63,21 +63,8 @@ minloc0_16_r8 (gfc_array_i16 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_16_r8 (gfc_array_i16 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_16_r8 (gfc_array_i16 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_16) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_4_i1.c b/libgfortran/generated/minloc0_4_i1.c index 418eb30d240..3a0b22ba71a 100644 --- a/libgfortran/generated/minloc0_4_i1.c +++ b/libgfortran/generated/minloc0_4_i1.c @@ -63,21 +63,8 @@ minloc0_4_i1 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_4_i1 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_4_i1 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_4_i16.c b/libgfortran/generated/minloc0_4_i16.c index 9a23b27e3d8..cd947eb6f05 100644 --- a/libgfortran/generated/minloc0_4_i16.c +++ b/libgfortran/generated/minloc0_4_i16.c @@ -63,21 +63,8 @@ minloc0_4_i16 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_4_i16 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_4_i16 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_4_i2.c b/libgfortran/generated/minloc0_4_i2.c index df081acb814..6d65cfb2421 100644 --- a/libgfortran/generated/minloc0_4_i2.c +++ b/libgfortran/generated/minloc0_4_i2.c @@ -63,21 +63,8 @@ minloc0_4_i2 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_4_i2 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_4_i2 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_4_i4.c b/libgfortran/generated/minloc0_4_i4.c index b076dcf5955..938d2e48208 100644 --- a/libgfortran/generated/minloc0_4_i4.c +++ b/libgfortran/generated/minloc0_4_i4.c @@ -63,21 +63,8 @@ minloc0_4_i4 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_4_i4 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_4_i4 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_4_i8.c b/libgfortran/generated/minloc0_4_i8.c index 944694c5c9d..b64024e45fc 100644 --- a/libgfortran/generated/minloc0_4_i8.c +++ b/libgfortran/generated/minloc0_4_i8.c @@ -63,21 +63,8 @@ minloc0_4_i8 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_4_i8 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_4_i8 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_4_r10.c b/libgfortran/generated/minloc0_4_r10.c index 03b8fd43afb..e130e21d3c2 100644 --- a/libgfortran/generated/minloc0_4_r10.c +++ b/libgfortran/generated/minloc0_4_r10.c @@ -63,21 +63,8 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_4_r10 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_4_r16.c b/libgfortran/generated/minloc0_4_r16.c index 88059c623fe..45ccb614ecb 100644 --- a/libgfortran/generated/minloc0_4_r16.c +++ b/libgfortran/generated/minloc0_4_r16.c @@ -63,21 +63,8 @@ minloc0_4_r16 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_4_r16 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_4_r16 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_4_r4.c b/libgfortran/generated/minloc0_4_r4.c index 0b1e642ba23..6d8f74e2991 100644 --- a/libgfortran/generated/minloc0_4_r4.c +++ b/libgfortran/generated/minloc0_4_r4.c @@ -63,21 +63,8 @@ minloc0_4_r4 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_4_r4 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_4_r8.c b/libgfortran/generated/minloc0_4_r8.c index a6843b1d804..eb01e685620 100644 --- a/libgfortran/generated/minloc0_4_r8.c +++ b/libgfortran/generated/minloc0_4_r8.c @@ -63,21 +63,8 @@ minloc0_4_r8 (gfc_array_i4 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_4_r8 (gfc_array_i4 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_4_r8 (gfc_array_i4 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_8_i1.c b/libgfortran/generated/minloc0_8_i1.c index 5617affe49b..d4924e48f19 100644 --- a/libgfortran/generated/minloc0_8_i1.c +++ b/libgfortran/generated/minloc0_8_i1.c @@ -63,21 +63,8 @@ minloc0_8_i1 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_8_i1 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_8_i1 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_8_i16.c b/libgfortran/generated/minloc0_8_i16.c index bc2454a1367..dad459a898f 100644 --- a/libgfortran/generated/minloc0_8_i16.c +++ b/libgfortran/generated/minloc0_8_i16.c @@ -63,21 +63,8 @@ minloc0_8_i16 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_8_i16 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_8_i16 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_8_i2.c b/libgfortran/generated/minloc0_8_i2.c index 198c9b90cb9..20cb1f20b9b 100644 --- a/libgfortran/generated/minloc0_8_i2.c +++ b/libgfortran/generated/minloc0_8_i2.c @@ -63,21 +63,8 @@ minloc0_8_i2 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_8_i2 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_8_i2 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_8_i4.c b/libgfortran/generated/minloc0_8_i4.c index c62fbcb1166..ca02f4fe379 100644 --- a/libgfortran/generated/minloc0_8_i4.c +++ b/libgfortran/generated/minloc0_8_i4.c @@ -63,21 +63,8 @@ minloc0_8_i4 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_8_i4 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_8_i4 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_8_i8.c b/libgfortran/generated/minloc0_8_i8.c index ffc790088f9..dffaec6861b 100644 --- a/libgfortran/generated/minloc0_8_i8.c +++ b/libgfortran/generated/minloc0_8_i8.c @@ -63,21 +63,8 @@ minloc0_8_i8 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_8_i8 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_8_i8 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_8_r10.c b/libgfortran/generated/minloc0_8_r10.c index 68eb7b6ecab..fe31ea91ec4 100644 --- a/libgfortran/generated/minloc0_8_r10.c +++ b/libgfortran/generated/minloc0_8_r10.c @@ -63,21 +63,8 @@ minloc0_8_r10 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_8_r10 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_8_r10 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_8_r16.c b/libgfortran/generated/minloc0_8_r16.c index da7ae066704..365403c87f0 100644 --- a/libgfortran/generated/minloc0_8_r16.c +++ b/libgfortran/generated/minloc0_8_r16.c @@ -63,21 +63,8 @@ minloc0_8_r16 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_8_r16 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_8_r16 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_8_r4.c b/libgfortran/generated/minloc0_8_r4.c index fbf5bab98af..53c89b13f7f 100644 --- a/libgfortran/generated/minloc0_8_r4.c +++ b/libgfortran/generated/minloc0_8_r4.c @@ -63,21 +63,8 @@ minloc0_8_r4 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_8_r4 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_8_r4 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc0_8_r8.c b/libgfortran/generated/minloc0_8_r8.c index 2dd4cfdf406..ab553b24005 100644 --- a/libgfortran/generated/minloc0_8_r8.c +++ b/libgfortran/generated/minloc0_8_r8.c @@ -63,21 +63,8 @@ minloc0_8_r8 (gfc_array_i8 * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -186,38 +173,11 @@ mminloc0_8_r8 (gfc_array_i8 * const restrict retarray, { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " MINLOC intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in MINLOC intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } @@ -340,22 +300,10 @@ sminloc0_8_r8 (gfc_array_i8 * const restrict retarray, retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_8) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "MINLOC"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/generated/minloc1_16_i1.c b/libgfortran/generated/minloc1_16_i1.c index 5a5ff5e39e2..9177230a5ae 100644 --- a/libgfortran/generated/minloc1_16_i1.c +++ b/libgfortran/generated/minloc1_16_i1.c @@ -120,19 +120,8 @@ minloc1_16_i1 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_16_i16.c b/libgfortran/generated/minloc1_16_i16.c index 25d4ceaae51..5ffebe29a48 100644 --- a/libgfortran/generated/minloc1_16_i16.c +++ b/libgfortran/generated/minloc1_16_i16.c @@ -120,19 +120,8 @@ minloc1_16_i16 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_16_i2.c b/libgfortran/generated/minloc1_16_i2.c index 228a582ed09..f1110c1b254 100644 --- a/libgfortran/generated/minloc1_16_i2.c +++ b/libgfortran/generated/minloc1_16_i2.c @@ -120,19 +120,8 @@ minloc1_16_i2 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_16_i4.c b/libgfortran/generated/minloc1_16_i4.c index c8652722a86..86c0acf5a0c 100644 --- a/libgfortran/generated/minloc1_16_i4.c +++ b/libgfortran/generated/minloc1_16_i4.c @@ -120,19 +120,8 @@ minloc1_16_i4 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_16_i8.c b/libgfortran/generated/minloc1_16_i8.c index fa124441dd6..7e965bee56d 100644 --- a/libgfortran/generated/minloc1_16_i8.c +++ b/libgfortran/generated/minloc1_16_i8.c @@ -120,19 +120,8 @@ minloc1_16_i8 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_16_r10.c b/libgfortran/generated/minloc1_16_r10.c index 15862a89cb5..e57462634c5 100644 --- a/libgfortran/generated/minloc1_16_r10.c +++ b/libgfortran/generated/minloc1_16_r10.c @@ -120,19 +120,8 @@ minloc1_16_r10 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_16_r16.c b/libgfortran/generated/minloc1_16_r16.c index f0b452fa09d..08815d322f5 100644 --- a/libgfortran/generated/minloc1_16_r16.c +++ b/libgfortran/generated/minloc1_16_r16.c @@ -120,19 +120,8 @@ minloc1_16_r16 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_16_r4.c b/libgfortran/generated/minloc1_16_r4.c index 692259db8c8..7f2967d6eb4 100644 --- a/libgfortran/generated/minloc1_16_r4.c +++ b/libgfortran/generated/minloc1_16_r4.c @@ -120,19 +120,8 @@ minloc1_16_r4 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_16_r8.c b/libgfortran/generated/minloc1_16_r8.c index c0189da58f7..4d6fa8b43ee 100644 --- a/libgfortran/generated/minloc1_16_r8.c +++ b/libgfortran/generated/minloc1_16_r8.c @@ -120,19 +120,8 @@ minloc1_16_r8 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_4_i1.c b/libgfortran/generated/minloc1_4_i1.c index 164f7ec31a2..107ebea06cd 100644 --- a/libgfortran/generated/minloc1_4_i1.c +++ b/libgfortran/generated/minloc1_4_i1.c @@ -120,19 +120,8 @@ minloc1_4_i1 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_4_i16.c b/libgfortran/generated/minloc1_4_i16.c index 899f2029bd3..b84c52461e7 100644 --- a/libgfortran/generated/minloc1_4_i16.c +++ b/libgfortran/generated/minloc1_4_i16.c @@ -120,19 +120,8 @@ minloc1_4_i16 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_4_i2.c b/libgfortran/generated/minloc1_4_i2.c index f900506de74..641b15d1d69 100644 --- a/libgfortran/generated/minloc1_4_i2.c +++ b/libgfortran/generated/minloc1_4_i2.c @@ -120,19 +120,8 @@ minloc1_4_i2 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_4_i4.c b/libgfortran/generated/minloc1_4_i4.c index 7dedb8f1c5b..c1daa5771b1 100644 --- a/libgfortran/generated/minloc1_4_i4.c +++ b/libgfortran/generated/minloc1_4_i4.c @@ -120,19 +120,8 @@ minloc1_4_i4 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_4_i8.c b/libgfortran/generated/minloc1_4_i8.c index 70eaefa8ed6..2229fc49a0d 100644 --- a/libgfortran/generated/minloc1_4_i8.c +++ b/libgfortran/generated/minloc1_4_i8.c @@ -120,19 +120,8 @@ minloc1_4_i8 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_4_r10.c b/libgfortran/generated/minloc1_4_r10.c index 1a0bdfa7ac1..ade388b399d 100644 --- a/libgfortran/generated/minloc1_4_r10.c +++ b/libgfortran/generated/minloc1_4_r10.c @@ -120,19 +120,8 @@ minloc1_4_r10 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_4_r16.c b/libgfortran/generated/minloc1_4_r16.c index b8849a56d35..e6cf58be551 100644 --- a/libgfortran/generated/minloc1_4_r16.c +++ b/libgfortran/generated/minloc1_4_r16.c @@ -120,19 +120,8 @@ minloc1_4_r16 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_4_r4.c b/libgfortran/generated/minloc1_4_r4.c index cc382dba224..6aa23040294 100644 --- a/libgfortran/generated/minloc1_4_r4.c +++ b/libgfortran/generated/minloc1_4_r4.c @@ -120,19 +120,8 @@ minloc1_4_r4 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_4_r8.c b/libgfortran/generated/minloc1_4_r8.c index c36567ffee6..ccc93f5e00e 100644 --- a/libgfortran/generated/minloc1_4_r8.c +++ b/libgfortran/generated/minloc1_4_r8.c @@ -120,19 +120,8 @@ minloc1_4_r8 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_8_i1.c b/libgfortran/generated/minloc1_8_i1.c index 6e46c82b863..86003e572e9 100644 --- a/libgfortran/generated/minloc1_8_i1.c +++ b/libgfortran/generated/minloc1_8_i1.c @@ -120,19 +120,8 @@ minloc1_8_i1 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_8_i16.c b/libgfortran/generated/minloc1_8_i16.c index 8e8410aa669..8dab74cbd1f 100644 --- a/libgfortran/generated/minloc1_8_i16.c +++ b/libgfortran/generated/minloc1_8_i16.c @@ -120,19 +120,8 @@ minloc1_8_i16 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_8_i2.c b/libgfortran/generated/minloc1_8_i2.c index 2a33e3c1fb7..ba76fc1c269 100644 --- a/libgfortran/generated/minloc1_8_i2.c +++ b/libgfortran/generated/minloc1_8_i2.c @@ -120,19 +120,8 @@ minloc1_8_i2 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_8_i4.c b/libgfortran/generated/minloc1_8_i4.c index 70cdef68bc6..03b57de804e 100644 --- a/libgfortran/generated/minloc1_8_i4.c +++ b/libgfortran/generated/minloc1_8_i4.c @@ -120,19 +120,8 @@ minloc1_8_i4 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_8_i8.c b/libgfortran/generated/minloc1_8_i8.c index c1a01e9e436..dc1c1fff4d2 100644 --- a/libgfortran/generated/minloc1_8_i8.c +++ b/libgfortran/generated/minloc1_8_i8.c @@ -120,19 +120,8 @@ minloc1_8_i8 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_8_r10.c b/libgfortran/generated/minloc1_8_r10.c index b5a6c8d2d26..15f22542ec2 100644 --- a/libgfortran/generated/minloc1_8_r10.c +++ b/libgfortran/generated/minloc1_8_r10.c @@ -120,19 +120,8 @@ minloc1_8_r10 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_8_r16.c b/libgfortran/generated/minloc1_8_r16.c index 0f4b036461d..64d1b26a7ee 100644 --- a/libgfortran/generated/minloc1_8_r16.c +++ b/libgfortran/generated/minloc1_8_r16.c @@ -120,19 +120,8 @@ minloc1_8_r16 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_8_r4.c b/libgfortran/generated/minloc1_8_r4.c index 300b5bebf0d..00977886a97 100644 --- a/libgfortran/generated/minloc1_8_r4.c +++ b/libgfortran/generated/minloc1_8_r4.c @@ -120,19 +120,8 @@ minloc1_8_r4 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minloc1_8_r8.c b/libgfortran/generated/minloc1_8_r8.c index da498f661ac..05359143142 100644 --- a/libgfortran/generated/minloc1_8_r8.c +++ b/libgfortran/generated/minloc1_8_r8.c @@ -120,19 +120,8 @@ minloc1_8_r8 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); } for (n = 0; n < rank; n++) @@ -313,29 +302,10 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINLOC intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINLOC"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINLOC"); } } diff --git a/libgfortran/generated/minval_i1.c b/libgfortran/generated/minval_i1.c index 437232a89da..3f1c0a53571 100644 --- a/libgfortran/generated/minval_i1.c +++ b/libgfortran/generated/minval_i1.c @@ -119,19 +119,8 @@ minval_i1 (gfc_array_i1 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mminval_i1 (gfc_array_i1 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINVAL"); } } diff --git a/libgfortran/generated/minval_i16.c b/libgfortran/generated/minval_i16.c index f0bd16fe003..6d0f20a7ea5 100644 --- a/libgfortran/generated/minval_i16.c +++ b/libgfortran/generated/minval_i16.c @@ -119,19 +119,8 @@ minval_i16 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mminval_i16 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINVAL"); } } diff --git a/libgfortran/generated/minval_i2.c b/libgfortran/generated/minval_i2.c index 08fd3a60b77..c09e4535450 100644 --- a/libgfortran/generated/minval_i2.c +++ b/libgfortran/generated/minval_i2.c @@ -119,19 +119,8 @@ minval_i2 (gfc_array_i2 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mminval_i2 (gfc_array_i2 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINVAL"); } } diff --git a/libgfortran/generated/minval_i4.c b/libgfortran/generated/minval_i4.c index d7e1ef93966..72c63705b50 100644 --- a/libgfortran/generated/minval_i4.c +++ b/libgfortran/generated/minval_i4.c @@ -119,19 +119,8 @@ minval_i4 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mminval_i4 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINVAL"); } } diff --git a/libgfortran/generated/minval_i8.c b/libgfortran/generated/minval_i8.c index 7b6fdc5e5ae..fbdcec9c93b 100644 --- a/libgfortran/generated/minval_i8.c +++ b/libgfortran/generated/minval_i8.c @@ -119,19 +119,8 @@ minval_i8 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mminval_i8 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINVAL"); } } diff --git a/libgfortran/generated/minval_r10.c b/libgfortran/generated/minval_r10.c index 1f6a75f0f6c..8e1ba756548 100644 --- a/libgfortran/generated/minval_r10.c +++ b/libgfortran/generated/minval_r10.c @@ -119,19 +119,8 @@ minval_r10 (gfc_array_r10 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mminval_r10 (gfc_array_r10 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINVAL"); } } diff --git a/libgfortran/generated/minval_r16.c b/libgfortran/generated/minval_r16.c index 555d86fd66f..b028029583c 100644 --- a/libgfortran/generated/minval_r16.c +++ b/libgfortran/generated/minval_r16.c @@ -119,19 +119,8 @@ minval_r16 (gfc_array_r16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mminval_r16 (gfc_array_r16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINVAL"); } } diff --git a/libgfortran/generated/minval_r4.c b/libgfortran/generated/minval_r4.c index a7f729ee732..d0236848eb1 100644 --- a/libgfortran/generated/minval_r4.c +++ b/libgfortran/generated/minval_r4.c @@ -119,19 +119,8 @@ minval_r4 (gfc_array_r4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mminval_r4 (gfc_array_r4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINVAL"); } } diff --git a/libgfortran/generated/minval_r8.c b/libgfortran/generated/minval_r8.c index 69afca1bc50..a86ce9403e0 100644 --- a/libgfortran/generated/minval_r8.c +++ b/libgfortran/generated/minval_r8.c @@ -119,19 +119,8 @@ minval_r8 (gfc_array_r8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); } for (n = 0; n < rank; n++) @@ -307,29 +296,10 @@ mminval_r8 (gfc_array_r8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " MINVAL intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "MINVAL"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "MINVAL"); } } diff --git a/libgfortran/generated/product_c10.c b/libgfortran/generated/product_c10.c index 69f7f8b7026..1f834f85d24 100644 --- a/libgfortran/generated/product_c10.c +++ b/libgfortran/generated/product_c10.c @@ -119,19 +119,8 @@ product_c10 (gfc_array_c10 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_c10 (gfc_array_c10 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_c16.c b/libgfortran/generated/product_c16.c index efaed2cebdb..20119fae10f 100644 --- a/libgfortran/generated/product_c16.c +++ b/libgfortran/generated/product_c16.c @@ -119,19 +119,8 @@ product_c16 (gfc_array_c16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_c16 (gfc_array_c16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_c4.c b/libgfortran/generated/product_c4.c index 505647ecd2e..231947f34aa 100644 --- a/libgfortran/generated/product_c4.c +++ b/libgfortran/generated/product_c4.c @@ -119,19 +119,8 @@ product_c4 (gfc_array_c4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_c4 (gfc_array_c4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_c8.c b/libgfortran/generated/product_c8.c index 16c776ad839..e6f8dbbafa1 100644 --- a/libgfortran/generated/product_c8.c +++ b/libgfortran/generated/product_c8.c @@ -119,19 +119,8 @@ product_c8 (gfc_array_c8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_c8 (gfc_array_c8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_i1.c b/libgfortran/generated/product_i1.c index cbc1ab120af..4f9b5eb3b96 100644 --- a/libgfortran/generated/product_i1.c +++ b/libgfortran/generated/product_i1.c @@ -119,19 +119,8 @@ product_i1 (gfc_array_i1 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_i1 (gfc_array_i1 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_i16.c b/libgfortran/generated/product_i16.c index e3b8c2a07e0..a23a96a8323 100644 --- a/libgfortran/generated/product_i16.c +++ b/libgfortran/generated/product_i16.c @@ -119,19 +119,8 @@ product_i16 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_i16 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_i2.c b/libgfortran/generated/product_i2.c index 507d956cb81..40bbe7233e5 100644 --- a/libgfortran/generated/product_i2.c +++ b/libgfortran/generated/product_i2.c @@ -119,19 +119,8 @@ product_i2 (gfc_array_i2 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_i2 (gfc_array_i2 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_i4.c b/libgfortran/generated/product_i4.c index d5af3679561..0510fca4aba 100644 --- a/libgfortran/generated/product_i4.c +++ b/libgfortran/generated/product_i4.c @@ -119,19 +119,8 @@ product_i4 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_i4 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_i8.c b/libgfortran/generated/product_i8.c index 3308d91dff9..b9bce58921c 100644 --- a/libgfortran/generated/product_i8.c +++ b/libgfortran/generated/product_i8.c @@ -119,19 +119,8 @@ product_i8 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_i8 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_r10.c b/libgfortran/generated/product_r10.c index 7bae90414b6..afbf756f544 100644 --- a/libgfortran/generated/product_r10.c +++ b/libgfortran/generated/product_r10.c @@ -119,19 +119,8 @@ product_r10 (gfc_array_r10 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_r10 (gfc_array_r10 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_r16.c b/libgfortran/generated/product_r16.c index bb678725d7c..1b0723ed15a 100644 --- a/libgfortran/generated/product_r16.c +++ b/libgfortran/generated/product_r16.c @@ -119,19 +119,8 @@ product_r16 (gfc_array_r16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_r16 (gfc_array_r16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_r4.c b/libgfortran/generated/product_r4.c index 333c13d2ffe..2f5a8916e45 100644 --- a/libgfortran/generated/product_r4.c +++ b/libgfortran/generated/product_r4.c @@ -119,19 +119,8 @@ product_r4 (gfc_array_r4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_r4 (gfc_array_r4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/product_r8.c b/libgfortran/generated/product_r8.c index 46258c00bbc..88c49ff85da 100644 --- a/libgfortran/generated/product_r8.c +++ b/libgfortran/generated/product_r8.c @@ -119,19 +119,8 @@ product_r8 (gfc_array_r8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ mproduct_r8 (gfc_array_r8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " PRODUCT intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "PRODUCT"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "PRODUCT"); } } diff --git a/libgfortran/generated/sum_c10.c b/libgfortran/generated/sum_c10.c index c63bc695266..9e32c8636b3 100644 --- a/libgfortran/generated/sum_c10.c +++ b/libgfortran/generated/sum_c10.c @@ -119,19 +119,8 @@ sum_c10 (gfc_array_c10 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_c10 (gfc_array_c10 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_c16.c b/libgfortran/generated/sum_c16.c index 9871d2d5d6a..ade7d761ceb 100644 --- a/libgfortran/generated/sum_c16.c +++ b/libgfortran/generated/sum_c16.c @@ -119,19 +119,8 @@ sum_c16 (gfc_array_c16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_c16 (gfc_array_c16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_c4.c b/libgfortran/generated/sum_c4.c index 920a6fb4920..ac37cc88ec6 100644 --- a/libgfortran/generated/sum_c4.c +++ b/libgfortran/generated/sum_c4.c @@ -119,19 +119,8 @@ sum_c4 (gfc_array_c4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_c4 (gfc_array_c4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_c8.c b/libgfortran/generated/sum_c8.c index c3e79237fb3..91db496587f 100644 --- a/libgfortran/generated/sum_c8.c +++ b/libgfortran/generated/sum_c8.c @@ -119,19 +119,8 @@ sum_c8 (gfc_array_c8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_c8 (gfc_array_c8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_i1.c b/libgfortran/generated/sum_i1.c index 913d732fa7f..b6e10909aa7 100644 --- a/libgfortran/generated/sum_i1.c +++ b/libgfortran/generated/sum_i1.c @@ -119,19 +119,8 @@ sum_i1 (gfc_array_i1 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_i1 (gfc_array_i1 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_i16.c b/libgfortran/generated/sum_i16.c index 060d45aa9ce..481ef8e51fb 100644 --- a/libgfortran/generated/sum_i16.c +++ b/libgfortran/generated/sum_i16.c @@ -119,19 +119,8 @@ sum_i16 (gfc_array_i16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_i16 (gfc_array_i16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_i2.c b/libgfortran/generated/sum_i2.c index 5318283ccb8..a0d97890d6c 100644 --- a/libgfortran/generated/sum_i2.c +++ b/libgfortran/generated/sum_i2.c @@ -119,19 +119,8 @@ sum_i2 (gfc_array_i2 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_i2 (gfc_array_i2 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_i4.c b/libgfortran/generated/sum_i4.c index e8c60c3870e..06f2dee4d7b 100644 --- a/libgfortran/generated/sum_i4.c +++ b/libgfortran/generated/sum_i4.c @@ -119,19 +119,8 @@ sum_i4 (gfc_array_i4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_i4 (gfc_array_i4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_i8.c b/libgfortran/generated/sum_i8.c index 9ee3e934bc7..9171c4c716e 100644 --- a/libgfortran/generated/sum_i8.c +++ b/libgfortran/generated/sum_i8.c @@ -119,19 +119,8 @@ sum_i8 (gfc_array_i8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_i8 (gfc_array_i8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_r10.c b/libgfortran/generated/sum_r10.c index 6a283049bfa..8d122129cc7 100644 --- a/libgfortran/generated/sum_r10.c +++ b/libgfortran/generated/sum_r10.c @@ -119,19 +119,8 @@ sum_r10 (gfc_array_r10 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_r10 (gfc_array_r10 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_r16.c b/libgfortran/generated/sum_r16.c index 35296c1d0d8..2cd6150e0f3 100644 --- a/libgfortran/generated/sum_r16.c +++ b/libgfortran/generated/sum_r16.c @@ -119,19 +119,8 @@ sum_r16 (gfc_array_r16 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_r16 (gfc_array_r16 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_r4.c b/libgfortran/generated/sum_r4.c index e7e2fe31b3a..b8a5e68e629 100644 --- a/libgfortran/generated/sum_r4.c +++ b/libgfortran/generated/sum_r4.c @@ -119,19 +119,8 @@ sum_r4 (gfc_array_r4 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_r4 (gfc_array_r4 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/generated/sum_r8.c b/libgfortran/generated/sum_r8.c index 86ae1092420..da9cec22372 100644 --- a/libgfortran/generated/sum_r8.c +++ b/libgfortran/generated/sum_r8.c @@ -119,19 +119,8 @@ sum_r8 (gfc_array_r8 * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); } for (n = 0; n < rank; n++) @@ -306,29 +295,10 @@ msum_r8 (gfc_array_r8 * const restrict retarray, if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " SUM intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "SUM"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "SUM"); } } diff --git a/libgfortran/intrinsics/cshift0.c b/libgfortran/intrinsics/cshift0.c index 1b7dbc1cec9..6adea76da3a 100644 --- a/libgfortran/intrinsics/cshift0.c +++ b/libgfortran/intrinsics/cshift0.c @@ -87,14 +87,17 @@ cshift0 (gfc_array_char * ret, const gfc_array_char * array, if (arraysize > 0) ret->data = internal_malloc_size (size * arraysize); else - { - ret->data = internal_malloc_size (1); - return; - } + ret->data = internal_malloc_size (1); } - + else if (unlikely (compile_options.bounds_check)) + { + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "CSHIFT"); + } + if (arraysize == 0) return; + type_size = GFC_DTYPE_TYPE_SIZE (array); switch(type_size) diff --git a/libgfortran/intrinsics/eoshift0.c b/libgfortran/intrinsics/eoshift0.c index 4b8082fdeca..74ba5ab7a97 100644 --- a/libgfortran/intrinsics/eoshift0.c +++ b/libgfortran/intrinsics/eoshift0.c @@ -54,6 +54,7 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * array, index_type dim; index_type len; index_type n; + index_type arraysize; /* The compiler cannot figure out that these are set, initialize them to avoid warnings. */ @@ -61,11 +62,12 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * array, soffset = 0; roffset = 0; + arraysize = size0 ((array_t *) array); + if (ret->data == NULL) { int i; - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -83,13 +85,22 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * array, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } + + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } - else + else if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); } + if (arraysize == 0) + return; + which = which - 1; extent[0] = 1; diff --git a/libgfortran/intrinsics/eoshift2.c b/libgfortran/intrinsics/eoshift2.c index aa5ef5ad90f..2fbf62e118c 100644 --- a/libgfortran/intrinsics/eoshift2.c +++ b/libgfortran/intrinsics/eoshift2.c @@ -75,7 +75,6 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array, { int i; - ret->data = internal_malloc_size (size * arraysize); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -92,15 +91,20 @@ eoshift2 (gfc_array_char *ret, const gfc_array_char *array, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } } - else + else if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); } - if (arraysize == 0 && filler == NULL) + if (arraysize == 0) return; which = which - 1; diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 7d833b78013..59f88d4fb9b 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -3103,7 +3103,11 @@ finalize_transfer (st_parameter_dt *dtp) } if ((dtp->common.flags & IOPARM_LIBRETURN_MASK) != IOPARM_LIBRETURN_OK) - return; + { + if (dtp->u.p.current_unit && current_mode (dtp) == UNFORMATTED_SEQUENTIAL) + dtp->u.p.current_unit->current_record = 0; + return; + } if ((dtp->u.p.ionml != NULL) && (cf & IOPARM_DT_HAS_NAMELIST_NAME) != 0) diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h index 517ee76d91d..acb02c413b2 100644 --- a/libgfortran/libgfortran.h +++ b/libgfortran/libgfortran.h @@ -1242,6 +1242,23 @@ typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t; extern index_type size0 (const array_t * array); iexport_proto(size0); +/* bounds.c */ + +extern void bounds_equal_extents (array_t *, array_t *, const char *, + const char *); +internal_proto(bounds_equal_extents); + +extern void bounds_reduced_extents (array_t *, array_t *, int, const char *, + const char *intrinsic); +internal_proto(bounds_reduced_extents); + +extern void bounds_iforeach_return (array_t *, array_t *, const char *); +internal_proto(bounds_iforeach_return); + +extern void bounds_ifunction_return (array_t *, const index_type *, + const char *, const char *); +internal_proto(bounds_ifunction_return); + /* Internal auxiliary functions for cshift */ void cshift0_i1 (gfc_array_i1 *, const gfc_array_i1 *, ssize_t, int); diff --git a/libgfortran/m4/cshift1.m4 b/libgfortran/m4/cshift1.m4 index 22b61854ffe..49a4f73404a 100644 --- a/libgfortran/m4/cshift1.m4 +++ b/libgfortran/m4/cshift1.m4 @@ -99,6 +99,17 @@ cshift1 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } } + else if (unlikely (compile_options.bounds_check)) + { + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "CSHIFT"); + } + + if (unlikely (compile_options.bounds_check)) + { + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "CSHIFT"); + } if (arraysize == 0) return; diff --git a/libgfortran/m4/eoshift1.m4 b/libgfortran/m4/eoshift1.m4 index 831277cf413..be9b1008a60 100644 --- a/libgfortran/m4/eoshift1.m4 +++ b/libgfortran/m4/eoshift1.m4 @@ -63,6 +63,7 @@ eoshift1 (gfc_array_char * const restrict ret, index_type len; index_type n; index_type size; + index_type arraysize; int which; 'atype_name` sh; 'atype_name` delta; @@ -83,11 +84,12 @@ eoshift1 (gfc_array_char * const restrict ret, extent[0] = 1; count[0] = 0; + arraysize = size0 ((array_t *) array); if (ret->data == NULL) { int i; - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); + ret->data = internal_malloc_size (size * arraysize); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -105,13 +107,27 @@ eoshift1 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } - else + else if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); } + if (unlikely (compile_options.bounds_check)) + { + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "EOSHIFT"); + } + + if (arraysize == 0) + return; + n = 0; for (dim = 0; dim < GFC_DESCRIPTOR_RANK (array); dim++) { diff --git a/libgfortran/m4/eoshift3.m4 b/libgfortran/m4/eoshift3.m4 index e6b29599ef0..6fa3bd2f7dc 100644 --- a/libgfortran/m4/eoshift3.m4 +++ b/libgfortran/m4/eoshift3.m4 @@ -67,6 +67,7 @@ eoshift3 (gfc_array_char * const restrict ret, index_type len; index_type n; index_type size; + index_type arraysize; int which; 'atype_name` sh; 'atype_name` delta; @@ -77,6 +78,7 @@ eoshift3 (gfc_array_char * const restrict ret, soffset = 0; roffset = 0; + arraysize = size0 ((array_t *) array); size = GFC_DESCRIPTOR_SIZE(array); if (pwhich) @@ -88,7 +90,7 @@ eoshift3 (gfc_array_char * const restrict ret, { int i; - ret->data = internal_malloc_size (size * size0 ((array_t *)array)); + ret->data = internal_malloc_size (size * arraysize); ret->offset = 0; ret->dtype = array->dtype; for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++) @@ -106,13 +108,26 @@ eoshift3 (gfc_array_char * const restrict ret, GFC_DIMENSION_SET(ret->dim[i], 0, ub, str); } + if (arraysize > 0) + ret->data = internal_malloc_size (size * arraysize); + else + ret->data = internal_malloc_size (1); + } - else + else if (unlikely (compile_options.bounds_check)) + { + bounds_equal_extents ((array_t *) ret, (array_t *) array, + "return value", "EOSHIFT"); + } + + if (unlikely (compile_options.bounds_check)) { - if (size0 ((array_t *) ret) == 0) - return; + bounds_reduced_extents ((array_t *) h, (array_t *) array, which, + "SHIFT argument", "EOSHIFT"); } + if (arraysize == 0) + return; extent[0] = 1; count[0] = 0; diff --git a/libgfortran/m4/iforeach.m4 b/libgfortran/m4/iforeach.m4 index 0960d22aeb4..d86d298a3af 100644 --- a/libgfortran/m4/iforeach.m4 +++ b/libgfortran/m4/iforeach.m4 @@ -35,21 +35,8 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray, else { if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " u_name intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "u_name"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); @@ -150,38 +137,11 @@ void { if (unlikely (compile_options.bounds_check)) { - int ret_rank, mask_rank; - index_type ret_extent; - int n; - index_type array_extent, mask_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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("Incorrect extent in return value of" - " u_name intrnisic: is %ld, should be %ld", - (long int) ret_extent, (long int) rank); - - mask_rank = GFC_DESCRIPTOR_RANK (mask); - if (rank != mask_rank) - runtime_error ("rank of MASK argument in u_name intrnisic" - "should be %ld, is %ld", (long int) rank, - (long int) mask_rank); - for (n=0; n<rank; n++) - { - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " u_name intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "u_name"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "u_name"); } } @@ -303,22 +263,10 @@ void retarray->offset = 0; retarray->data = internal_malloc_size (sizeof (rtype_name) * rank); } - else + else if (unlikely (compile_options.bounds_check)) { - if (unlikely (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 = GFC_DESCRIPTOR_EXTENT(retarray,0); - if (ret_extent != rank) - runtime_error ("dimension of return array incorrect"); - } + bounds_iforeach_return ((array_t *) retarray, (array_t *) array, + "u_name"); } dstride = GFC_DESCRIPTOR_STRIDE(retarray,0); diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4 index 6785eb3c43f..66b1d98b1ad 100644 --- a/libgfortran/m4/ifunction.m4 +++ b/libgfortran/m4/ifunction.m4 @@ -107,19 +107,8 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray, (long int) rank); if (unlikely (compile_options.bounds_check)) - { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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]); - } - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "u_name"); } for (n = 0; n < rank; n++) @@ -294,29 +283,10 @@ void if (unlikely (compile_options.bounds_check)) { - for (n=0; n < rank; n++) - { - index_type ret_extent; - - ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,n); - 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++) - { - index_type mask_extent, array_extent; - - array_extent = GFC_DESCRIPTOR_EXTENT(array,n); - mask_extent = GFC_DESCRIPTOR_EXTENT(mask,n); - if (array_extent != mask_extent) - runtime_error ("Incorrect extent in MASK argument of" - " u_name intrinsic in dimension %ld:" - " is %ld, should be %ld", (long int) n + 1, - (long int) mask_extent, (long int) array_extent); - } + bounds_ifunction_return ((array_t *) retarray, extent, + "return value", "u_name"); + bounds_equal_extents ((array_t *) mask, (array_t *) array, + "MASK argument", "u_name"); } } diff --git a/libgfortran/runtime/bounds.c b/libgfortran/runtime/bounds.c new file mode 100644 index 00000000000..8a7affd2e18 --- /dev/null +++ b/libgfortran/runtime/bounds.c @@ -0,0 +1,199 @@ +/* Copyright (C) 2009 + Free Software Foundation, Inc. + Contributed by Thomas Koenig + +This file is part of the GNU Fortran runtime library (libgfortran). + +Libgfortran 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, or (at your option) +any later version. + +Libgfortran 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. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + +#include "libgfortran.h" +#include <assert.h> + +/* Auxiliary functions for bounds checking, mostly to reduce library size. */ + +/* Bounds checking for the return values of the iforeach functions (such + as maxloc and minloc). The extent of ret_array must + must match the rank of array. */ + +void +bounds_iforeach_return (array_t *retarray, array_t *array, const char *name) +{ + index_type rank; + index_type ret_rank; + index_type ret_extent; + + ret_rank = GFC_DESCRIPTOR_RANK (retarray); + + if (ret_rank != 1) + runtime_error ("Incorrect rank of return array in %s intrinsic:" + "is %ld, should be 1", name, (long int) ret_rank); + + rank = GFC_DESCRIPTOR_RANK (array); + ret_extent = GFC_DESCRIPTOR_EXTENT(retarray,0); + if (ret_extent != rank) + runtime_error ("Incorrect extent in return value of" + " %s intrinsic: is %ld, should be %ld", + name, (long int) ret_extent, (long int) rank); + +} + +/* Check the return of functions generated from ifunction.m4. + We check the array descriptor "a" against the extents precomputed + from ifunction.m4, and complain about the argument a_name in the + intrinsic function. */ + +void +bounds_ifunction_return (array_t * a, const index_type * extent, + const char * a_name, const char * intrinsic) +{ + int empty; + int n; + int rank; + index_type a_size; + + rank = GFC_DESCRIPTOR_RANK (a); + a_size = size0 (a); + + empty = 0; + for (n = 0; n < rank; n++) + { + if (extent[n] == 0) + empty = 1; + } + if (empty) + { + if (a_size != 0) + runtime_error ("Incorrect size in %s of %s" + " intrinsic: should be zero-sized", + a_name, intrinsic); + } + else + { + if (a_size == 0) + runtime_error ("Incorrect size of %s in %s" + " intrinsic: should not be zero-sized", + a_name, intrinsic); + + for (n = 0; n < rank; n++) + { + index_type a_extent; + a_extent = GFC_DESCRIPTOR_EXTENT(a, n); + if (a_extent != extent[n]) + runtime_error("Incorrect extent in %s of %s" + " intrinsic in dimension %ld: is %ld," + " should be %ld", a_name, intrinsic, (long int) n + 1, + (long int) a_extent, (long int) extent[n]); + + } + } +} + +/* Check that two arrays have equal extents, or are both zero-sized. Abort + with a runtime error if this is not the case. Complain that a has the + wrong size. */ + +void +bounds_equal_extents (array_t *a, array_t *b, const char *a_name, + const char *intrinsic) +{ + index_type a_size, b_size, n; + + assert (GFC_DESCRIPTOR_RANK(a) == GFC_DESCRIPTOR_RANK(b)); + + a_size = size0 (a); + b_size = size0 (b); + + if (b_size == 0) + { + if (a_size != 0) + runtime_error ("Incorrect size of %s in %s" + " intrinsic: should be zero-sized", + a_name, intrinsic); + } + else + { + if (a_size == 0) + runtime_error ("Incorrect size of %s of %s" + " intrinsic: Should not be zero-sized", + a_name, intrinsic); + + for (n = 0; n < GFC_DESCRIPTOR_RANK (b); n++) + { + index_type a_extent, b_extent; + + a_extent = GFC_DESCRIPTOR_EXTENT(a, n); + b_extent = GFC_DESCRIPTOR_EXTENT(b, n); + if (a_extent != b_extent) + runtime_error("Incorrect extent in %s of %s" + " intrinsic in dimension %ld: is %ld," + " should be %ld", a_name, intrinsic, (long int) n + 1, + (long int) a_extent, (long int) b_extent); + } + } +} + +/* Check that the extents of a and b agree, except that a has a missing + dimension in argument which. Complain about a if anything is wrong. */ + +void +bounds_reduced_extents (array_t *a, array_t *b, int which, const char *a_name, + const char *intrinsic) +{ + + index_type i, n, a_size, b_size; + + assert (GFC_DESCRIPTOR_RANK(a) == GFC_DESCRIPTOR_RANK(b) - 1); + + a_size = size0 (a); + b_size = size0 (b); + + if (b_size == 0) + { + if (a_size != 0) + runtime_error ("Incorrect size in %s of %s" + " intrinsic: should not be zero-sized", + a_name, intrinsic); + } + else + { + if (a_size == 0) + runtime_error ("Incorrect size of %s of %s" + " intrinsic: should be zero-sized", + a_name, intrinsic); + + i = 0; + for (n = 0; n < GFC_DESCRIPTOR_RANK (b); n++) + { + index_type a_extent, b_extent; + + if (n != which) + { + a_extent = GFC_DESCRIPTOR_EXTENT(a, i); + b_extent = GFC_DESCRIPTOR_EXTENT(b, n); + if (a_extent != b_extent) + runtime_error("Incorrect extent in %s of %s" + " intrinsic in dimension %ld: is %ld," + " should be %ld", a_name, intrinsic, (long int) i + 1, + (long int) a_extent, (long int) b_extent); + i++; + } + } + } +} diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 89157021e97..5ef1785e213 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,7 @@ +2009-07-16 Joseph Myers <joseph@codesourcery.com> + + * configure: Regenerate. + 2009-07-11 Richard Sandiford <rdsandiford@googlemail.com> PR testsuite/40699 diff --git a/libgomp/configure b/libgomp/configure index 6fd7d6ebf3c..cadb9322974 100755 --- a/libgomp/configure +++ b/libgomp/configure @@ -17859,6 +17859,7 @@ fi # See if we support thread-local storage. + # Check whether --enable-tls or --disable-tls was given. if test "${enable_tls+set}" = set; then enableval="$enable_tls" @@ -17906,6 +17907,64 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then + chktls_save_LDFLAGS="$LDFLAGS" + case $host in + *-*-linux*) + LDFLAGS="-shared -Wl,--no-undefined $LDFLAGS" + ;; + esac + chktls_save_CFLAGS="$CFLAGS" + CFLAGS="-fPIC $CFLAGS" + cat >conftest.$ac_ext <<_ACEOF +int f() { return 0; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cat >conftest.$ac_ext <<_ACEOF +__thread int a; int b; int f() { return a = b; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then gcc_cv_have_tls=yes else echo "$as_me: failed program was:" >&5 @@ -17915,6 +17974,24 @@ gcc_cv_have_tls=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=yes +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$chktls_save_CFLAGS" + LDFLAGS="$chktls_save_LDFLAGS" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext else diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index eb7c913b838..83f85e723c2 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,12 @@ +2009-07-17 Jan Kratochvil <jan.kratochvil@redhat.com> + + * cp-demangle.c (d_print_comp <DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS>) + (d_print_comp <DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS): New. + (d_make_comp <DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS>) + (d_make_comp <DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS): New. + (d_demangle_callback): The variable type is now declared as enum. + Replace parser of _GLOBAL_ symbols by a d_make_comp call. + 2009-06-21 Jakub Jelinek <jakub@redhat.com> * hashtab.c (htab_traverse): Don't call htab_expand for diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 4f309ef992b..2c7296f7eef 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -819,6 +819,8 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_JAVA_RESOURCE: case DEMANGLE_COMPONENT_DECLTYPE: case DEMANGLE_COMPONENT_PACK_EXPANSION: + case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: + case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: if (left == NULL) return NULL; break; @@ -4054,6 +4056,16 @@ d_print_comp (struct d_print_info *dpi, return; } + case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: + d_append_string (dpi, "global constructors keyed to "); + d_print_comp (dpi, dc->u.s_binary.left); + return; + + case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: + d_append_string (dpi, "global destructors keyed to "); + d_print_comp (dpi, dc->u.s_binary.left); + return; + default: d_print_error (dpi); return; @@ -4484,33 +4496,30 @@ static int d_demangle_callback (const char *mangled, int options, demangle_callbackref callback, void *opaque) { - int type; + enum + { + DCT_TYPE, + DCT_MANGLED, + DCT_GLOBAL_CTORS, + DCT_GLOBAL_DTORS + } + type; struct d_info di; struct demangle_component *dc; int status; if (mangled[0] == '_' && mangled[1] == 'Z') - type = 0; + type = DCT_MANGLED; else if (strncmp (mangled, "_GLOBAL_", 8) == 0 && (mangled[8] == '.' || mangled[8] == '_' || mangled[8] == '$') && (mangled[9] == 'D' || mangled[9] == 'I') && mangled[10] == '_') - { - const char *intro; - - intro = (mangled[9] == 'I') - ? "global constructors keyed to " - : "global destructors keyed to "; - - callback (intro, strlen (intro), opaque); - callback (mangled + 11, strlen (mangled + 11), opaque); - return 1; - } + type = mangled[9] == 'I' ? DCT_GLOBAL_CTORS : DCT_GLOBAL_DTORS; else { if ((options & DMGL_TYPES) == 0) return 0; - type = 1; + type = DCT_TYPE; } cplus_demangle_init_info (mangled, options, strlen (mangled), &di); @@ -4527,10 +4536,26 @@ d_demangle_callback (const char *mangled, int options, di.subs = alloca (di.num_subs * sizeof (*di.subs)); #endif - if (type) - dc = cplus_demangle_type (&di); - else - dc = cplus_demangle_mangled_name (&di, 1); + switch (type) + { + case DCT_TYPE: + dc = cplus_demangle_type (&di); + break; + case DCT_MANGLED: + dc = cplus_demangle_mangled_name (&di, 1); + break; + case DCT_GLOBAL_CTORS: + case DCT_GLOBAL_DTORS: + d_advance (&di, 11); + dc = d_make_comp (&di, + (type == DCT_GLOBAL_CTORS + ? DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS + : DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS), + d_make_name (&di, d_str (&di), strlen (d_str (&di))), + NULL); + d_advance (&di, strlen (d_str (&di))); + break; + } /* If DMGL_PARAMS is set, then if we didn't consume the entire mangled string, then we didn't successfully demangle it. If diff --git a/libjava/ChangeLog b/libjava/ChangeLog index cad3e377fe7..d838e26fabe 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,12 @@ +2009-07-17 Joseph Myers <joseph@codesourcery.com> + + PR other/40784 + * configure: Regenerate. + +2009-07-16 Joseph Myers <joseph@codesourcery.com> + + * configure: Regenerate. + 2009-07-11 Richard Sandiford <rdsandiford@googlemail.com> PR testsuite/40699 diff --git a/libjava/configure b/libjava/configure index 8a2e8a1a9c1..168bb51073a 100755 --- a/libjava/configure +++ b/libjava/configure @@ -27611,6 +27611,7 @@ fi # See if we support thread-local storage. + # Check whether --enable-tls or --disable-tls was given. if test "${enable_tls+set}" = set; then enableval="$enable_tls" @@ -27663,6 +27664,74 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then + chktls_save_LDFLAGS="$LDFLAGS" + case $host in + *-*-linux*) + LDFLAGS="-shared -Wl,--no-undefined $LDFLAGS" + ;; + esac + chktls_save_CFLAGS="$CFLAGS" + CFLAGS="-fPIC $CFLAGS" + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +int f() { return 0; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +__thread int a; int b; int f() { return a = b; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then gcc_cv_have_tls=yes else echo "$as_me: failed program was:" >&5 @@ -27672,6 +27741,24 @@ gcc_cv_have_tls=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=yes +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$chktls_save_CFLAGS" + LDFLAGS="$chktls_save_LDFLAGS" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext else diff --git a/libmudflap/ChangeLog b/libmudflap/ChangeLog index 78507bc017b..edb0958cd40 100644 --- a/libmudflap/ChangeLog +++ b/libmudflap/ChangeLog @@ -1,3 +1,7 @@ +2009-07-16 Joseph Myers <joseph@codesourcery.com> + + * configure: Regenerate. + 2009-07-11 Richard Sandiford <rdsandiford@googlemail.com> PR testsuite/40699 diff --git a/libmudflap/configure b/libmudflap/configure index 67f38261f1d..954ffa1e7cb 100755 --- a/libmudflap/configure +++ b/libmudflap/configure @@ -12740,6 +12740,7 @@ fi # See if we support thread-local storage. + # Check whether --enable-tls or --disable-tls was given. if test "${enable_tls+set}" = set; then enableval="$enable_tls" @@ -12787,6 +12788,64 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then + chktls_save_LDFLAGS="$LDFLAGS" + case $host in + *-*-linux*) + LDFLAGS="-shared -Wl,--no-undefined $LDFLAGS" + ;; + esac + chktls_save_CFLAGS="$CFLAGS" + CFLAGS="-fPIC $CFLAGS" + cat >conftest.$ac_ext <<_ACEOF +int f() { return 0; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cat >conftest.$ac_ext <<_ACEOF +__thread int a; int b; int f() { return a = b; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then gcc_cv_have_tls=yes else echo "$as_me: failed program was:" >&5 @@ -12796,6 +12855,24 @@ gcc_cv_have_tls=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=yes +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$chktls_save_CFLAGS" + LDFLAGS="$chktls_save_LDFLAGS" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext else diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 97a165d7127..c769be5a283 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,76 @@ +2009-07-18 Paolo Carlini <paolo.carlini@oracle.com> + + PR libstdc++/40712 + * config/locale/gnu/numeric_members.cc (numpunct<>:: + _M_initialize_numpunct): Dynamically allocate _M_data->_M_grouping + and copy the langinfo data into it. + (numpunct<>::~numpunct): Free the allocated memory. + * config/locale/gnu/monetary_members.cc (moneypunct<>:: + _M_initialize_moneypunct): Dynamically allocate _M_data->_M_grouping, + _M_data->_M_positive_sign, _M_data->_M_negative_sign, + _M_data->_M_curr_symbol. + (moneypunct<>::~moneypunct): Free the allocated memory. + * testsuite/22_locale/moneypunct/40712.cc: New. + + * include/bits/locale_facets.tcc (__numpunct_cache<>::_M_cache): + Do not leak memory if new throws. + * include/bits/locale_facets_nonio.tcc + (__moneypunct_cache<>::_M_cache): Likewise. + +2009-07-17 Joseph Myers <joseph@codesourcery.com> + + PR other/40784 + * configure: Regenerate. + +2009-07-16 Benjamin Kosnik <bkoz@redhat.com> + + * testsuite/util/testsuite_common_types.h (standard_layout): Activate. + * testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Adjust + line numbers. + * testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Same. + * testsuite/29_atomics/atomic/cons/assign_neg.cc: Same. + * testsuite/29_atomics/atomic/cons/copy_neg.cc: Same. + +2009-07-16 Joseph Myers <joseph@codesourcery.com> + + * configure: Regenerate. + +2009-07-16 Jason Merrill <jason@redhat.com> + + PR libstdc++/37907 + * include/std/type_traits: Add is_standard_layout, is_trivial. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc, + testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: + Update line numbers. + +2009-07-16 Phil Muldoon <pmuldoon@redhat.com> + Tom Tromey <tromey@redhat.com> + + * python/libstdcxx/v6/printers.py (StdStringPrinter.to_string): + Fetch std::string to the given length. + +2009-07-16 Paolo Carlini <paolo.carlini@oracle.com> + + * include/bits/istream.tcc (basic_istream<>::operator>>(short&), + basic_istream<>::operator>>(int&)): Implement resolution of DR 696, + [Ready] in Frankfurt. + * include/tr1_impl/regex (regex_traits<>::value): Adjust. + * testsuite/27_io/basic_istream/extractors_arithmetic/char/dr696.cc: + New. + * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/dr696.cc: + Likewise. + * testsuite/27_io/basic_istream/extractors_arithmetic/char/13.cc: + Adjust. + * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc: + Likewise. + * doc/xml/manual/intro.xml: Add an entry for DR 696. + + * include/bits/istream.tcc: Minor clean-up to the initializers of the + __err locals. + * include/bits/ostream.tcc: Likewise. + * src/compatibility.cc: Likewise. + * src/istream.cc: Likewise. + 2009-07-12 Paolo Carlini <paolo.carlini@oracle.com> * include/std/type_traits (common_type): Remove workaround for diff --git a/libstdc++-v3/config/locale/gnu/monetary_members.cc b/libstdc++-v3/config/locale/gnu/monetary_members.cc index c5ec8575391..02e48240ba9 100644 --- a/libstdc++-v3/config/locale/gnu/monetary_members.cc +++ b/libstdc++-v3/config/locale/gnu/monetary_members.cc @@ -236,23 +236,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __cloc)); _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, __cloc)); - _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); - _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign); - - // Check for NULL, which implies no grouping. - if (_M_data->_M_thousands_sep == '\0') - { - // Like in "C" locale. - _M_data->_M_grouping = ""; - _M_data->_M_grouping_size = 0; - _M_data->_M_use_grouping = false; - _M_data->_M_thousands_sep = ','; - } - else - { - _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); - _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); - } // Check for NULL, which implies no fractional digits. if (_M_data->_M_decimal_point == '\0') @@ -265,25 +248,104 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, __cloc)); - char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc)); - if (!__nposn) - _M_data->_M_negative_sign = "()"; - else - _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, - __cloc); - _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign); - + const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc); + const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); + const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); // _Intl == true - _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc); - _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol); + const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc); + + char* __group = 0; + char* __ps = 0; + char* __ns = 0; + const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc)); + __try + { + size_t __len; + + // Check for NULL, which implies no grouping. + if (_M_data->_M_thousands_sep == '\0') + { + // Like in "C" locale. + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _M_data->_M_thousands_sep = ','; + } + else + { + __len = strlen(__cgroup); + if (__len) + { + __group = new char[__len + 1]; + memcpy(__group, __cgroup, __len + 1); + _M_data->_M_grouping = __group; + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; + } + + __len = strlen(__cpossign); + if (__len) + { + __ps = new char[__len + 1]; + memcpy(__ps, __cpossign, __len + 1); + _M_data->_M_positive_sign = __ps; + } + else + _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = __len; + + if (!__nposn) + { + _M_data->_M_negative_sign = "()"; + _M_data->_M_negative_sign_size = 2; + } + else + { + __len = strlen(__cnegsign); + if (__len) + { + __ns = new char[__len + 1]; + memcpy(__ns, __cnegsign, __len + 1); + _M_data->_M_negative_sign = __ns; + } + else + _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = __len; + } + + __len = strlen(__ccurr); + if (__len) + { + char* __curr = new char[__len + 1]; + memcpy(__curr, __ccurr, __len + 1); + _M_data->_M_curr_symbol = __curr; + } + else + _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = __len; + } + __catch(...) + { + delete _M_data; + _M_data = 0; + delete [] __group; + delete [] __ps; + delete [] __ns; + } + char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc)); - _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc)); - _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); } } @@ -324,23 +386,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __cloc)); _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP, __cloc)); - _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); - _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign); - - // Check for NULL, which implies no grouping. - if (_M_data->_M_thousands_sep == '\0') - { - // Like in "C" locale. - _M_data->_M_grouping = ""; - _M_data->_M_grouping_size = 0; - _M_data->_M_use_grouping = false; - _M_data->_M_thousands_sep = ','; - } - else - { - _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); - _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); - } // Check for NULL, which implies no fractional digits. if (_M_data->_M_decimal_point == '\0') @@ -353,36 +398,137 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc)); - char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc)); - if (!__nposn) - _M_data->_M_negative_sign = "()"; - else - _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN, - __cloc); - _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign); - + const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc); + const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); + const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); // _Intl == false - _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc); - _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol); + const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc); + + char* __group = 0; + char* __ps = 0; + char* __ns = 0; + const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc)); + __try + { + size_t __len; + + // Check for NULL, which implies no grouping. + if (_M_data->_M_thousands_sep == '\0') + { + // Like in "C" locale. + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _M_data->_M_thousands_sep = ','; + } + else + { + __len = strlen(__cgroup); + if (__len) + { + __group = new char[__len + 1]; + memcpy(__group, __cgroup, __len + 1); + _M_data->_M_grouping = __group; + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; + } + + __len = strlen(__cpossign); + if (__len) + { + __ps = new char[__len + 1]; + memcpy(__ps, __cpossign, __len + 1); + _M_data->_M_positive_sign = __ps; + } + else + _M_data->_M_positive_sign = ""; + _M_data->_M_positive_sign_size = __len; + + if (!__nposn) + { + _M_data->_M_negative_sign = "()"; + _M_data->_M_negative_sign_size = 2; + } + else + { + __len = strlen(__cnegsign); + if (__len) + { + __ns = new char[__len + 1]; + memcpy(__ns, __cnegsign, __len + 1); + _M_data->_M_negative_sign = __ns; + } + else + _M_data->_M_negative_sign = ""; + _M_data->_M_negative_sign_size = __len; + } + + __len = strlen(__ccurr); + if (__len) + { + char* __curr = new char[__len + 1]; + memcpy(__curr, __ccurr, __len + 1); + _M_data->_M_curr_symbol = __curr; + } + else + _M_data->_M_curr_symbol = ""; + _M_data->_M_curr_symbol_size = __len; + } + __catch(...) + { + delete _M_data; + _M_data = 0; + delete [] __group; + delete [] __ps; + delete [] __ns; + } + char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc)); - _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc)); - _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); } } template<> moneypunct<char, true>::~moneypunct() - { delete _M_data; } + { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; + if (_M_data->_M_positive_sign_size) + delete [] _M_data->_M_positive_sign; + if (_M_data->_M_negative_sign_size + && strcmp(_M_data->_M_negative_sign, "()") != 0) + delete [] _M_data->_M_negative_sign; + if (_M_data->_M_curr_symbol_size) + delete [] _M_data->_M_curr_symbol; + delete _M_data; + } template<> moneypunct<char, false>::~moneypunct() - { delete _M_data; } + { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; + if (_M_data->_M_positive_sign_size) + delete [] _M_data->_M_positive_sign; + if (_M_data->_M_negative_sign_size + && strcmp(_M_data->_M_negative_sign, "()") != 0) + delete [] _M_data->_M_negative_sign; + if (_M_data->_M_curr_symbol_size) + delete [] _M_data->_M_curr_symbol; + delete _M_data; + } #ifdef _GLIBCXX_USE_WCHAR_T template<> @@ -441,21 +587,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc); _M_data->_M_thousands_sep = __u.__w; - // Check for NULL, which implies no grouping. - if (_M_data->_M_thousands_sep == L'\0') - { - // Like in "C" locale. - _M_data->_M_grouping = ""; - _M_data->_M_grouping_size = 0; - _M_data->_M_use_grouping = false; - _M_data->_M_thousands_sep = L','; - } - else - { - _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); - _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); - } - // Check for NULL, which implies no fractional digits. if (_M_data->_M_decimal_point == L'\0') { @@ -467,52 +598,81 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS, __cloc)); + const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc); const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc); + char* __group = 0; wchar_t* __wcs_ps = 0; wchar_t* __wcs_ns = 0; const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc)); __try { + size_t __len; + + // Check for NULL, which implies no grouping. + if (_M_data->_M_thousands_sep == L'\0') + { + // Like in "C" locale. + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _M_data->_M_thousands_sep = L','; + } + else + { + __len = strlen(__cgroup); + if (__len) + { + __group = new char[__len + 1]; + memcpy(__group, __cgroup, __len + 1); + _M_data->_M_grouping = __group; + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; + } + mbstate_t __state; - size_t __len = strlen(__cpossign); + __len = strlen(__cpossign); if (__len) { - ++__len; memset(&__state, 0, sizeof(mbstate_t)); - __wcs_ps = new wchar_t[__len]; - mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state); + __wcs_ps = new wchar_t[__len + 1]; + mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state); _M_data->_M_positive_sign = __wcs_ps; } else _M_data->_M_positive_sign = L""; - _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign); + _M_data->_M_positive_sign_size = + wcslen(_M_data->_M_positive_sign); __len = strlen(__cnegsign); if (!__nposn) _M_data->_M_negative_sign = L"()"; else if (__len) - { - ++__len; + { memset(&__state, 0, sizeof(mbstate_t)); - __wcs_ns = new wchar_t[__len]; - mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state); + __wcs_ns = new wchar_t[__len + 1]; + mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state); _M_data->_M_negative_sign = __wcs_ns; } else _M_data->_M_negative_sign = L""; - _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign); + _M_data->_M_negative_sign_size = + wcslen(_M_data->_M_negative_sign); // _Intl == true. __len = strlen(__ccurr); if (__len) { - ++__len; memset(&__state, 0, sizeof(mbstate_t)); - wchar_t* __wcs = new wchar_t[__len]; - mbsrtowcs(__wcs, &__ccurr, __len, &__state); + wchar_t* __wcs = new wchar_t[__len + 1]; + mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state); _M_data->_M_curr_symbol = __wcs; } else @@ -523,6 +683,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { delete _M_data; _M_data = 0; + delete [] __group; delete [] __wcs_ps; delete [] __wcs_ns; #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) @@ -537,11 +698,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc)); - _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc)); - _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) @@ -609,21 +770,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc); _M_data->_M_thousands_sep = __u.__w; - // Check for NULL, which implies no grouping. - if (_M_data->_M_thousands_sep == L'\0') - { - // Like in "C" locale. - _M_data->_M_grouping = ""; - _M_data->_M_grouping_size = 0; - _M_data->_M_use_grouping = false; - _M_data->_M_thousands_sep = L','; - } - else - { - _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc); - _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); - } - // Check for NULL, which implies no fractional digits. if (_M_data->_M_decimal_point == L'\0') { @@ -635,53 +781,81 @@ _GLIBCXX_BEGIN_NAMESPACE(std) _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc)); + const char* __cgroup = __nl_langinfo_l(__MON_GROUPING, __cloc); const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc); const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc); const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc); + char* __group = 0; wchar_t* __wcs_ps = 0; wchar_t* __wcs_ns = 0; const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc)); __try { + size_t __len; + + // Check for NULL, which implies no grouping. + if (_M_data->_M_thousands_sep == L'\0') + { + // Like in "C" locale. + _M_data->_M_grouping = ""; + _M_data->_M_grouping_size = 0; + _M_data->_M_use_grouping = false; + _M_data->_M_thousands_sep = L','; + } + else + { + __len = strlen(__cgroup); + if (__len) + { + __group = new char[__len + 1]; + memcpy(__group, __cgroup, __len + 1); + _M_data->_M_grouping = __group; + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; + } + mbstate_t __state; - size_t __len; __len = strlen(__cpossign); if (__len) { - ++__len; memset(&__state, 0, sizeof(mbstate_t)); - __wcs_ps = new wchar_t[__len]; - mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state); + __wcs_ps = new wchar_t[__len + 1]; + mbsrtowcs(__wcs_ps, &__cpossign, __len + 1, &__state); _M_data->_M_positive_sign = __wcs_ps; } else _M_data->_M_positive_sign = L""; - _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign); - + _M_data->_M_positive_sign_size = + wcslen(_M_data->_M_positive_sign); + __len = strlen(__cnegsign); if (!__nposn) _M_data->_M_negative_sign = L"()"; else if (__len) - { - ++__len; + { memset(&__state, 0, sizeof(mbstate_t)); - __wcs_ns = new wchar_t[__len]; - mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state); + __wcs_ns = new wchar_t[__len + 1]; + mbsrtowcs(__wcs_ns, &__cnegsign, __len + 1, &__state); _M_data->_M_negative_sign = __wcs_ns; } else _M_data->_M_negative_sign = L""; - _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign); + _M_data->_M_negative_sign_size = + wcslen(_M_data->_M_negative_sign); // _Intl == true. __len = strlen(__ccurr); if (__len) { - ++__len; memset(&__state, 0, sizeof(mbstate_t)); - wchar_t* __wcs = new wchar_t[__len]; - mbsrtowcs(__wcs, &__ccurr, __len, &__state); + wchar_t* __wcs = new wchar_t[__len + 1]; + mbsrtowcs(__wcs, &__ccurr, __len + 1, &__state); _M_data->_M_curr_symbol = __wcs; } else @@ -692,6 +866,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { delete _M_data; _M_data = 0; + delete [] __group; delete [] __wcs_ps; delete [] __wcs_ns; #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) @@ -706,11 +881,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc)); char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc)); char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc)); - _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, + _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace, __pposn); char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc)); char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc)); - _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, + _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) @@ -725,6 +900,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<> moneypunct<wchar_t, true>::~moneypunct() { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; if (_M_data->_M_positive_sign_size) delete [] _M_data->_M_positive_sign; if (_M_data->_M_negative_sign_size @@ -738,6 +915,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<> moneypunct<wchar_t, false>::~moneypunct() { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; if (_M_data->_M_positive_sign_size) delete [] _M_data->_M_positive_sign; if (_M_data->_M_negative_sign_size diff --git a/libstdc++-v3/config/locale/gnu/numeric_members.cc b/libstdc++-v3/config/locale/gnu/numeric_members.cc index 769c47f9ff5..637cd59b711 100644 --- a/libstdc++-v3/config/locale/gnu/numeric_members.cc +++ b/libstdc++-v3/config/locale/gnu/numeric_members.cc @@ -76,8 +76,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std) } else { - _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); - _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); + const char* __src = __nl_langinfo_l(GROUPING, __cloc); + const size_t __len = strlen(__src); + if (__len) + { + __try + { + char* __dst = new char[__len + 1]; + memcpy(__dst, __src, __len + 1); + _M_data->_M_grouping = __dst; + } + __catch(...) + { + delete _M_data; + _M_data = 0; + __throw_exception_again; + } + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; } } @@ -92,7 +113,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<> numpunct<char>::~numpunct() - { delete _M_data; } + { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; + delete _M_data; + } #ifdef _GLIBCXX_USE_WCHAR_T template<> @@ -143,8 +168,29 @@ _GLIBCXX_BEGIN_NAMESPACE(std) } else { - _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc); - _M_data->_M_grouping_size = strlen(_M_data->_M_grouping); + const char* __src = __nl_langinfo_l(GROUPING, __cloc); + const size_t __len = strlen(__src); + if (__len) + { + __try + { + char* __dst = new char[__len + 1]; + memcpy(__dst, __src, __len + 1); + _M_data->_M_grouping = __dst; + } + __catch(...) + { + delete _M_data; + _M_data = 0; + __throw_exception_again; + } + } + else + { + _M_data->_M_grouping = ""; + _M_data->_M_use_grouping = false; + } + _M_data->_M_grouping_size = __len; } } @@ -159,7 +205,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template<> numpunct<wchar_t>::~numpunct() - { delete _M_data; } + { + if (_M_data->_M_grouping_size) + delete [] _M_data->_M_grouping; + delete _M_data; + } #endif _GLIBCXX_END_NAMESPACE diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 0f19ba59f5c..13f477ed34b 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -40678,6 +40678,7 @@ _ACEOF # For TLS support. + # Check whether --enable-tls or --disable-tls was given. if test "${enable_tls+set}" = set; then enableval="$enable_tls" @@ -40730,6 +40731,74 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then + chktls_save_LDFLAGS="$LDFLAGS" + case $host in + *-*-linux*) + LDFLAGS="-shared -Wl,--no-undefined $LDFLAGS" + ;; + esac + chktls_save_CFLAGS="$CFLAGS" + CFLAGS="-fPIC $CFLAGS" + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +int f() { return 0; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +__thread int a; int b; int f() { return a = b; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then gcc_cv_have_tls=yes else echo "$as_me: failed program was:" >&5 @@ -40739,6 +40808,24 @@ gcc_cv_have_tls=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=yes +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$chktls_save_CFLAGS" + LDFLAGS="$chktls_save_LDFLAGS" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext else @@ -94326,6 +94413,7 @@ _ACEOF + # Check whether --enable-tls or --disable-tls was given. if test "${enable_tls+set}" = set; then enableval="$enable_tls" @@ -94378,6 +94466,74 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then + chktls_save_LDFLAGS="$LDFLAGS" + case $host in + *-*-linux*) + LDFLAGS="-shared -Wl,--no-undefined $LDFLAGS" + ;; + esac + chktls_save_CFLAGS="$CFLAGS" + CFLAGS="-fPIC $CFLAGS" + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +int f() { return 0; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +__thread int a; int b; int f() { return a = b; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then gcc_cv_have_tls=yes else echo "$as_me: failed program was:" >&5 @@ -94387,6 +94543,24 @@ gcc_cv_have_tls=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=yes +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$chktls_save_CFLAGS" + LDFLAGS="$chktls_save_LDFLAGS" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext else @@ -111941,6 +112115,7 @@ done _ACEOF + # Check whether --enable-tls or --disable-tls was given. if test "${enable_tls+set}" = set; then enableval="$enable_tls" @@ -111993,6 +112168,74 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then + chktls_save_LDFLAGS="$LDFLAGS" + case $host in + *-*-linux*) + LDFLAGS="-shared -Wl,--no-undefined $LDFLAGS" + ;; + esac + chktls_save_CFLAGS="$CFLAGS" + CFLAGS="-fPIC $CFLAGS" + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +int f() { return 0; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +__thread int a; int b; int f() { return a = b; } +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then gcc_cv_have_tls=yes else echo "$as_me: failed program was:" >&5 @@ -112002,6 +112245,24 @@ gcc_cv_have_tls=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=yes +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$chktls_save_CFLAGS" + LDFLAGS="$chktls_save_LDFLAGS" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +gcc_cv_have_tls=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext else diff --git a/libstdc++-v3/doc/xml/manual/intro.xml b/libstdc++-v3/doc/xml/manual/intro.xml index dca08c2b9e1..45a7c6bda4f 100644 --- a/libstdc++-v3/doc/xml/manual/intro.xml +++ b/libstdc++-v3/doc/xml/manual/intro.xml @@ -736,6 +736,12 @@ requirements of the license of GCC. <listitem><para>Make the member functions table and classic_table public. </para></listitem></varlistentry> + <varlistentry><term><ulink url="../ext/lwg-active.html#696">696</ulink>: + <emphasis>istream::operator>>(int&) broken</emphasis> + </term> + <listitem><para>Implement the straightforward resolution. + </para></listitem></varlistentry> + <varlistentry><term><ulink url="../ext/lwg-defects.html#761">761</ulink>: <emphasis>unordered_map needs an at() member function</emphasis> </term> diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index 5d60791ec98..d005f736f03 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -46,7 +46,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) basic_istream<_CharT, _Traits>::sentry:: sentry(basic_istream<_CharT, _Traits>& __in, bool __noskip) : _M_ok(false) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; if (__in.good()) { if (__in.tie()) @@ -89,7 +89,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, false); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const __num_get_type& __ng = __check_facet(this->_M_num_get); @@ -97,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) } __catch(__cxxabiv1::__forced_unwind&) { - this->_M_setstate(ios_base::badbit); + this->_M_setstate(ios_base::badbit); __throw_exception_again; } __catch(...) @@ -115,19 +115,44 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 118. basic_istream uses nonexistent num_get member functions. - long __l; - _M_extract(__l); - if (!this->fail()) + sentry __cerb(*this, false); + if (__cerb) { - if (__gnu_cxx::__numeric_traits<short>::__min <= __l - && __l <= __gnu_cxx::__numeric_traits<short>::__max) - __n = short(__l); - else - this->setstate(ios_base::failbit); + ios_base::iostate __err = ios_base::goodbit; + __try + { + long __l; + const __num_get_type& __ng = __check_facet(this->_M_num_get); + __ng.get(*this, 0, *this, __err, __l); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 696. istream::operator>>(int&) broken. + if (__l < __gnu_cxx::__numeric_traits<short>::__min) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits<short>::__min; + } + else if (__l > __gnu_cxx::__numeric_traits<short>::__max) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits<short>::__max; + } + else + __n = short(__l); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } return *this; } - + template<typename _CharT, typename _Traits> basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>:: @@ -135,15 +160,40 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 118. basic_istream uses nonexistent num_get member functions. - long __l; - _M_extract(__l); - if (!this->fail()) + sentry __cerb(*this, false); + if (__cerb) { - if (__gnu_cxx::__numeric_traits<int>::__min <= __l - && __l <= __gnu_cxx::__numeric_traits<int>::__max) - __n = int(__l); - else - this->setstate(ios_base::failbit); + ios_base::iostate __err = ios_base::goodbit; + __try + { + long __l; + const __num_get_type& __ng = __check_facet(this->_M_num_get); + __ng.get(*this, 0, *this, __err, __l); + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 696. istream::operator>>(int&) broken. + if (__l < __gnu_cxx::__numeric_traits<int>::__min) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits<int>::__min; + } + else if (__l > __gnu_cxx::__numeric_traits<int>::__max) + { + __err |= ios_base::failbit; + __n = __gnu_cxx::__numeric_traits<int>::__max; + } + else + __n = int(__l); + } + __catch(__cxxabiv1::__forced_unwind&) + { + this->_M_setstate(ios_base::badbit); + __throw_exception_again; + } + __catch(...) + { this->_M_setstate(ios_base::badbit); } + if (__err) + this->setstate(__err); } return *this; } @@ -153,7 +203,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) basic_istream<_CharT, _Traits>:: operator>>(__streambuf_type* __sbout) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; sentry __cerb(*this, false); if (__cerb && __sbout) { @@ -188,7 +238,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const int_type __eof = traits_type::eof(); int_type __c = __eof; _M_gcount = 0; - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; sentry __cerb(*this, true); if (__cerb) { @@ -222,7 +272,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) get(char_type& __c) { _M_gcount = 0; - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; sentry __cerb(*this, true); if (__cerb) { @@ -259,7 +309,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) get(char_type* __s, streamsize __n, char_type __delim) { _M_gcount = 0; - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; sentry __cerb(*this, true); if (__cerb) { @@ -306,7 +356,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) get(__streambuf_type& __sb, char_type __delim) { _M_gcount = 0; - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; sentry __cerb(*this, true); if (__cerb) { @@ -350,7 +400,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) getline(char_type* __s, streamsize __n, char_type __delim) { _M_gcount = 0; - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; sentry __cerb(*this, true); if (__cerb) { @@ -413,7 +463,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const int_type __eof = traits_type::eof(); @@ -446,7 +496,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb && __n > 0) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const int_type __eof = traits_type::eof(); @@ -508,7 +558,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb && __n > 0) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const int_type __eof = traits_type::eof(); @@ -574,7 +624,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { __c = this->rdbuf()->sgetc(); @@ -603,7 +653,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { _M_gcount = this->rdbuf()->sgetn(__s, __n); @@ -632,7 +682,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { // Cannot compare int_type with streamsize generically. @@ -666,7 +716,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const int_type __eof = traits_type::eof(); @@ -699,7 +749,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const int_type __eof = traits_type::eof(); @@ -732,7 +782,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { __streambuf_type* __sb = this->rdbuf(); @@ -788,7 +838,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR60. Do not change _M_gcount. - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { if (!this->fail()) @@ -821,7 +871,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR60. Do not change _M_gcount. - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { if (!this->fail()) @@ -858,7 +908,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) typename __istream_type::sentry __cerb(__in, false); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const __int_type __cb = __in.rdbuf()->sbumpc(); @@ -891,7 +941,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) typedef ctype<_CharT> __ctype_type; streamsize __extracted = 0; - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; typename __istream_type::sentry __cerb(__in, false); if (__cerb) { diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc index 85b4ec646bb..1608e2c42da 100644 --- a/libstdc++-v3/include/bits/locale_facets.tcc +++ b/libstdc++-v3/include/bits/locale_facets.tcc @@ -81,33 +81,48 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); - _M_grouping_size = __np.grouping().size(); - char* __grouping = new char[_M_grouping_size]; - __np.grouping().copy(__grouping, _M_grouping_size); - _M_grouping = __grouping; - _M_use_grouping = (_M_grouping_size - && static_cast<signed char>(_M_grouping[0]) > 0 - && (_M_grouping[0] - != __gnu_cxx::__numeric_traits<char>::__max)); - - _M_truename_size = __np.truename().size(); - _CharT* __truename = new _CharT[_M_truename_size]; - __np.truename().copy(__truename, _M_truename_size); - _M_truename = __truename; - - _M_falsename_size = __np.falsename().size(); - _CharT* __falsename = new _CharT[_M_falsename_size]; - __np.falsename().copy(__falsename, _M_falsename_size); - _M_falsename = __falsename; - - _M_decimal_point = __np.decimal_point(); - _M_thousands_sep = __np.thousands_sep(); - - const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc); - __ct.widen(__num_base::_S_atoms_out, - __num_base::_S_atoms_out + __num_base::_S_oend, _M_atoms_out); - __ct.widen(__num_base::_S_atoms_in, - __num_base::_S_atoms_in + __num_base::_S_iend, _M_atoms_in); + char* __grouping = 0; + _CharT* __truename = 0; + _CharT* __falsename = 0; + __try + { + _M_grouping_size = __np.grouping().size(); + __grouping = new char[_M_grouping_size]; + __np.grouping().copy(__grouping, _M_grouping_size); + _M_grouping = __grouping; + _M_use_grouping = (_M_grouping_size + && static_cast<signed char>(_M_grouping[0]) > 0 + && (_M_grouping[0] + != __gnu_cxx::__numeric_traits<char>::__max)); + + _M_truename_size = __np.truename().size(); + __truename = new _CharT[_M_truename_size]; + __np.truename().copy(__truename, _M_truename_size); + _M_truename = __truename; + + _M_falsename_size = __np.falsename().size(); + __falsename = new _CharT[_M_falsename_size]; + __np.falsename().copy(__falsename, _M_falsename_size); + _M_falsename = __falsename; + + _M_decimal_point = __np.decimal_point(); + _M_thousands_sep = __np.thousands_sep(); + + const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc); + __ct.widen(__num_base::_S_atoms_out, + __num_base::_S_atoms_out + + __num_base::_S_oend, _M_atoms_out); + __ct.widen(__num_base::_S_atoms_in, + __num_base::_S_atoms_in + + __num_base::_S_iend, _M_atoms_in); + } + __catch(...) + { + delete [] __grouping; + delete [] __truename; + delete [] __falsename; + __throw_exception_again; + } } // Used by both numeric and monetary facets. diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc index 06bbfcf4447..96feeafc759 100644 --- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc +++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc @@ -71,40 +71,55 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const moneypunct<_CharT, _Intl>& __mp = use_facet<moneypunct<_CharT, _Intl> >(__loc); - _M_grouping_size = __mp.grouping().size(); - char* __grouping = new char[_M_grouping_size]; - __mp.grouping().copy(__grouping, _M_grouping_size); - _M_grouping = __grouping; - _M_use_grouping = (_M_grouping_size - && static_cast<signed char>(_M_grouping[0]) > 0 - && (_M_grouping[0] - != __gnu_cxx::__numeric_traits<char>::__max)); - _M_decimal_point = __mp.decimal_point(); _M_thousands_sep = __mp.thousands_sep(); _M_frac_digits = __mp.frac_digits(); - - _M_curr_symbol_size = __mp.curr_symbol().size(); - _CharT* __curr_symbol = new _CharT[_M_curr_symbol_size]; - __mp.curr_symbol().copy(__curr_symbol, _M_curr_symbol_size); - _M_curr_symbol = __curr_symbol; - - _M_positive_sign_size = __mp.positive_sign().size(); - _CharT* __positive_sign = new _CharT[_M_positive_sign_size]; - __mp.positive_sign().copy(__positive_sign, _M_positive_sign_size); - _M_positive_sign = __positive_sign; - - _M_negative_sign_size = __mp.negative_sign().size(); - _CharT* __negative_sign = new _CharT[_M_negative_sign_size]; - __mp.negative_sign().copy(__negative_sign, _M_negative_sign_size); - _M_negative_sign = __negative_sign; - - _M_pos_format = __mp.pos_format(); - _M_neg_format = __mp.neg_format(); - const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc); - __ct.widen(money_base::_S_atoms, - money_base::_S_atoms + money_base::_S_end, _M_atoms); + char* __grouping = 0; + _CharT* __curr_symbol = 0; + _CharT* __positive_sign = 0; + _CharT* __negative_sign = 0; + __try + { + _M_grouping_size = __mp.grouping().size(); + __grouping = new char[_M_grouping_size]; + __mp.grouping().copy(__grouping, _M_grouping_size); + _M_grouping = __grouping; + _M_use_grouping = (_M_grouping_size + && static_cast<signed char>(_M_grouping[0]) > 0 + && (_M_grouping[0] + != __gnu_cxx::__numeric_traits<char>::__max)); + + _M_curr_symbol_size = __mp.curr_symbol().size(); + __curr_symbol = new _CharT[_M_curr_symbol_size]; + __mp.curr_symbol().copy(__curr_symbol, _M_curr_symbol_size); + _M_curr_symbol = __curr_symbol; + + _M_positive_sign_size = __mp.positive_sign().size(); + __positive_sign = new _CharT[_M_positive_sign_size]; + __mp.positive_sign().copy(__positive_sign, _M_positive_sign_size); + _M_positive_sign = __positive_sign; + + _M_negative_sign_size = __mp.negative_sign().size(); + __negative_sign = new _CharT[_M_negative_sign_size]; + __mp.negative_sign().copy(__negative_sign, _M_negative_sign_size); + _M_negative_sign = __negative_sign; + + _M_pos_format = __mp.pos_format(); + _M_neg_format = __mp.neg_format(); + + const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc); + __ct.widen(money_base::_S_atoms, + money_base::_S_atoms + money_base::_S_end, _M_atoms); + } + __catch(...) + { + delete [] __grouping; + delete [] __curr_symbol; + delete [] __positive_sign; + delete [] __negative_sign; + __throw_exception_again; + } } _GLIBCXX_BEGIN_LDBL_NAMESPACE diff --git a/libstdc++-v3/include/bits/ostream.tcc b/libstdc++-v3/include/bits/ostream.tcc index e2cbb585a89..1147212aa14 100644 --- a/libstdc++-v3/include/bits/ostream.tcc +++ b/libstdc++-v3/include/bits/ostream.tcc @@ -66,7 +66,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const __num_put_type& __np = __check_facet(this->_M_num_put); @@ -119,7 +119,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) basic_ostream<_CharT, _Traits>:: operator<<(__streambuf_type* __sbin) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; sentry __cerb(*this); if (__cerb && __sbin) { @@ -157,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this); if (__cerb) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const int_type __put = this->rdbuf()->sputc(__c); @@ -213,7 +213,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) // _GLIBCXX_RESOLVE_LIB_DEFECTS // DR 60. What is a formatted input function? // basic_ostream::flush() is *not* an unformatted output function. - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { if (this->rdbuf() && this->rdbuf()->pubsync() == -1) @@ -257,7 +257,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) basic_ostream<_CharT, _Traits>:: seekp(pos_type __pos) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { if (!this->fail()) @@ -289,7 +289,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) basic_ostream<_CharT, _Traits>:: seekp(off_type __off, ios_base::seekdir __dir) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { if (!this->fail()) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 94c40df97b8..dd26bb84dbf 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -173,11 +173,18 @@ namespace std // Member introspection. /// is_pod + // Could use is_standard_layout && is_trivial instead of the builtin. template<typename _Tp> struct is_pod : public integral_constant<bool, __is_pod(_Tp)> { }; + /// is_standard_layout + template<typename _Tp> + struct is_standard_layout + : public integral_constant<bool, __is_standard_layout(_Tp)> + { }; + /// has_trivial_default_constructor template<typename _Tp> struct has_trivial_default_constructor @@ -202,6 +209,12 @@ namespace std : public integral_constant<bool, __has_trivial_destructor(_Tp)> { }; + /// is_trivial + template<typename _Tp> + struct is_trivial + : public integral_constant<bool, __is_trivial(_Tp)> + { }; + /// has_nothrow_default_constructor template<typename _Tp> struct has_nothrow_default_constructor diff --git a/libstdc++-v3/include/tr1_impl/regex b/libstdc++-v3/include/tr1_impl/regex index 9352bc13732..6f76a981419 100644 --- a/libstdc++-v3/include/tr1_impl/regex +++ b/libstdc++-v3/include/tr1_impl/regex @@ -688,13 +688,13 @@ namespace regex_constants value(_Ch_type __ch, int __radix) const { std::basic_istringstream<_Ch_type> __is(string_type(1, __ch)); - int __v = -1; + int __v; if (__radix == 8) __is >> std::oct; else if (__radix == 16) __is >> std::hex; __is >> __v; - return __v; + return __is.fail() ? -1 : __v; } // [7.8] Class basic_regex diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index e2bb231e15a..a3d2ef13991 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -452,7 +452,21 @@ class StdStringPrinter: encoding = gdb.parameter('target-charset') elif encoding == 1: encoding = gdb.parameter('target-wide-charset') - return self.val['_M_dataplus']['_M_p'].string(encoding) + + # Make sure &string works, too. + type = self.val.type + if type.code == gdb.TYPE_CODE_REF: + type = type.target () + + # Calculate the length of the string so that to_string returns + # the string according to length, not according to first null + # encountered. + ptr = self.val ['_M_dataplus']['_M_p'] + realtype = type.unqualified ().strip_typedefs () + reptype = gdb.lookup_type (str (realtype) + '::_Rep').pointer () + header = ptr.cast(reptype) - 1 + len = header.dereference ()['_M_length'] + return self.val['_M_dataplus']['_M_p'].string (encoding, length = len) def display_hint (self): return 'string' diff --git a/libstdc++-v3/src/compatibility.cc b/libstdc++-v3/src/compatibility.cc index 6b3c19b31e4..73432681ecf 100644 --- a/libstdc++-v3/src/compatibility.cc +++ b/libstdc++-v3/src/compatibility.cc @@ -64,7 +64,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb && __n > 0) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const int_type __eof = traits_type::eof(); @@ -136,7 +136,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb && __n > 0) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const int_type __eof = traits_type::eof(); diff --git a/libstdc++-v3/src/istream.cc b/libstdc++-v3/src/istream.cc index 6b06df2594d..7b7f0bf9278 100644 --- a/libstdc++-v3/src/istream.cc +++ b/libstdc++-v3/src/istream.cc @@ -37,7 +37,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) getline(char_type* __s, streamsize __n, char_type __delim) { _M_gcount = 0; - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; sentry __cerb(*this, true); if (__cerb) { @@ -118,7 +118,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb && __n > 0) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const char_type __cdelim = traits_type::to_char_type(__delim); @@ -203,7 +203,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) typedef __istream_type::__ctype_type __ctype_type; streamsize __extracted = 0; - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __istream_type::sentry __cerb(__in, false); if (__cerb) { @@ -286,7 +286,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) typedef __string_type::size_type __size_type; __size_type __extracted = 0; - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __istream_type::sentry __cerb(__in, false); if (__cerb) { @@ -368,7 +368,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __size_type __extracted = 0; const __size_type __n = __str.max_size(); - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __istream_type::sentry __cerb(__in, true); if (__cerb) { @@ -444,7 +444,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) getline(char_type* __s, streamsize __n, char_type __delim) { _M_gcount = 0; - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; sentry __cerb(*this, true); if (__cerb) { @@ -525,7 +525,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) sentry __cerb(*this, true); if (__cerb && __n > 0) { - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __try { const char_type __cdelim = traits_type::to_char_type(__delim); @@ -614,7 +614,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __size_type __extracted = 0; const __size_type __n = __str.max_size(); - ios_base::iostate __err = ios_base::iostate(ios_base::goodbit); + ios_base::iostate __err = ios_base::goodbit; __istream_type::sentry __cerb(__in, true); if (__cerb) { diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index ca7ee97af0c..3455462869b 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -48,8 +48,8 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 557 } -// { dg-error "declaration of" "" { target *-*-* } 519 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 570 } +// { dg-error "declaration of" "" { target *-*-* } 532 } // { dg-excess-errors "At global scope" } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index ac9fef16e77..3d3a10a9ba8 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -48,8 +48,8 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 478 } -// { dg-error "declaration of" "" { target *-*-* } 440 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 491 } +// { dg-error "declaration of" "" { target *-*-* } 453 } // { dg-excess-errors "At global scope" } // { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/22_locale/moneypunct/40712.cc b/libstdc++-v3/testsuite/22_locale/moneypunct/40712.cc new file mode 100644 index 00000000000..49eb21c0f92 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/moneypunct/40712.cc @@ -0,0 +1,41 @@ +// { dg-require-namedlocale "" } + +// 2009-07-18 Paolo Carlini <paolo.carlini@oracle.com> + +// Copyright (C) 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library 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, or (at your option) +// any later version. + +// This library 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 library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 22.2.6.3 Template class moneypunct + +#include <locale> + +// libstdc++/40712 +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + locale loc(locale("C"), "en_US", locale::monetary); + + use_facet<moneypunct<char> >(loc).grouping(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/13.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/13.cc index b2c3336a006..ac5533a496e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/13.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/13.cc @@ -58,8 +58,8 @@ void test13() i = 0; iss2.str(digits); iss2.clear(); - iss2 >> i; - VERIFY( i == 0 ); + iss2 >> i; + VERIFY( i == numeric_limits<int>::max() ); VERIFY( iss2.fail() ); } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/dr696.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/dr696.cc new file mode 100644 index 00000000000..a1a71cc571f --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/dr696.cc @@ -0,0 +1,101 @@ +// 2009-07-15 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library 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, or (at your option) +// any later version. + +// This library 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 library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 27.6.1.2.2 arithmetic extractors + +#include <sstream> +#include <limits> +#include <testsuite_hooks.h> + +// DR 696. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + short s1 = 0; + ostringstream oss1; + oss1 << numeric_limits<short>::max(); + istringstream iss1(oss1.str()); + iss1 >> s1; + VERIFY( s1 == numeric_limits<short>::max() ); + VERIFY( !iss1.fail() && iss1.eof() ); + + short s2 = 0; + ostringstream oss2; + oss2 << static_cast<long long>(numeric_limits<short>::max()) + 1; + istringstream iss2(oss2.str()); + iss2 >> s2; + VERIFY( s2 == numeric_limits<short>::max() ); + VERIFY( iss2.fail() && iss2.eof() ); + + short s3 = 0; + ostringstream oss3; + oss3 << numeric_limits<short>::min(); + istringstream iss3(oss3.str()); + iss3 >> s3; + VERIFY( s3 == numeric_limits<short>::min() ); + VERIFY( !iss3.fail() && iss3.eof() ); + + short s4 = 0; + ostringstream oss4; + oss4 << static_cast<long long>(numeric_limits<short>::min()) - 1; + istringstream iss4(oss4.str()); + iss4 >> s4; + VERIFY( s4 == numeric_limits<short>::min() ); + VERIFY( iss4.fail() && iss4.eof() ); + + int i1 = 0; + ostringstream oss5; + oss5 << numeric_limits<int>::max(); + istringstream iss5(oss5.str()); + iss5 >> i1; + VERIFY( i1 == numeric_limits<int>::max() ); + VERIFY( !iss5.fail() && iss5.eof() ); + + int i2 = 0; + ostringstream oss6; + oss6 << static_cast<long long>(numeric_limits<int>::max()) + 1; + istringstream iss6(oss6.str()); + iss6 >> i2; + VERIFY( i1 == numeric_limits<int>::max() ); + VERIFY( iss6.fail() && iss6.eof() ); + + int i3 = 0; + ostringstream oss7; + oss7 << numeric_limits<int>::min(); + istringstream iss7(oss7.str()); + iss7 >> i3; + VERIFY( i3 == numeric_limits<int>::min() ); + VERIFY( !iss7.fail() && iss7.eof() ); + + int i4 = 0; + ostringstream oss8; + oss8 << static_cast<long long>(numeric_limits<int>::min()) - 1; + istringstream iss8(oss8.str()); + iss8 >> i4; + VERIFY( i4 == numeric_limits<int>::min() ); + VERIFY( iss8.fail() && iss8.eof() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc index ed8f57eb5f3..0a44b1ffb09 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/13.cc @@ -56,7 +56,7 @@ void test13() iss2.str(digits); iss2.clear(); iss2 >> i; - VERIFY( i == 0 ); + VERIFY( i == numeric_limits<int>::max() ); VERIFY( iss2.fail() ); } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/dr696.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/dr696.cc new file mode 100644 index 00000000000..2ed5b309b0e --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/dr696.cc @@ -0,0 +1,101 @@ +// 2009-07-15 Paolo Carlini <paolo.carlini@oracle.com> +// +// Copyright (C) 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library 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, or (at your option) +// any later version. + +// This library 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 library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 27.6.1.2.2 arithmetic extractors + +#include <sstream> +#include <limits> +#include <testsuite_hooks.h> + +// DR 696. +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + short s1 = 0; + wostringstream oss1; + oss1 << numeric_limits<short>::max(); + wistringstream iss1(oss1.str()); + iss1 >> s1; + VERIFY( s1 == numeric_limits<short>::max() ); + VERIFY( !iss1.fail() && iss1.eof() ); + + short s2 = 0; + wostringstream oss2; + oss2 << static_cast<long long>(numeric_limits<short>::max()) + 1; + wistringstream iss2(oss2.str()); + iss2 >> s2; + VERIFY( s2 == numeric_limits<short>::max() ); + VERIFY( iss2.fail() && iss2.eof() ); + + short s3 = 0; + wostringstream oss3; + oss3 << numeric_limits<short>::min(); + wistringstream iss3(oss3.str()); + iss3 >> s3; + VERIFY( s3 == numeric_limits<short>::min() ); + VERIFY( !iss3.fail() && iss3.eof() ); + + short s4 = 0; + wostringstream oss4; + oss4 << static_cast<long long>(numeric_limits<short>::min()) - 1; + wistringstream iss4(oss4.str()); + iss4 >> s4; + VERIFY( s4 == numeric_limits<short>::min() ); + VERIFY( iss4.fail() && iss4.eof() ); + + int i1 = 0; + wostringstream oss5; + oss5 << numeric_limits<int>::max(); + wistringstream iss5(oss5.str()); + iss5 >> i1; + VERIFY( i1 == numeric_limits<int>::max() ); + VERIFY( !iss5.fail() && iss5.eof() ); + + int i2 = 0; + wostringstream oss6; + oss6 << static_cast<long long>(numeric_limits<int>::max()) + 1; + wistringstream iss6(oss6.str()); + iss6 >> i2; + VERIFY( i1 == numeric_limits<int>::max() ); + VERIFY( iss6.fail() && iss6.eof() ); + + int i3 = 0; + wostringstream oss7; + oss7 << numeric_limits<int>::min(); + wistringstream iss7(oss7.str()); + iss7 >> i3; + VERIFY( i3 == numeric_limits<int>::min() ); + VERIFY( !iss7.fail() && iss7.eof() ); + + int i4 = 0; + wostringstream oss8; + oss8 << static_cast<long long>(numeric_limits<int>::min()) - 1; + wistringstream iss8(oss8.str()); + iss8 >> i4; + VERIFY( i4 == numeric_limits<int>::min() ); + VERIFY( iss8.fail() && iss8.eof() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc index 0b73b080fbe..e580d807585 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/assign_neg.cc @@ -29,7 +29,7 @@ int main() return 0; } -// { dg-error "used here" "" { target *-*-* } 525 } +// { dg-error "used here" "" { target *-*-* } 521 } // { dg-error "deleted function" "" { target *-*-* } 239 } // { dg-error "deleted function" "" { target *-*-* } 257 } // { dg-error "deleted function" "" { target *-*-* } 275 } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc index a261a84c968..9108b4bc1ac 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/copy_neg.cc @@ -29,7 +29,7 @@ int main() return 0; } -// { dg-error "used here" "" { target *-*-* } 564 } +// { dg-error "used here" "" { target *-*-* } 560 } // { dg-error "deleted function" "" { target *-*-* } 238 } // { dg-error "deleted function" "" { target *-*-* } 256 } // { dg-error "deleted function" "" { target *-*-* } 274 } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc index a488cb06d14..cf69ab2ee56 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/assign_neg.cc @@ -30,11 +30,11 @@ int main() return 0; } -// { dg-error "used here" "" { target *-*-* } 525 } +// { dg-error "used here" "" { target *-*-* } 521 } // { dg-excess-errors "deleted function" } // { dg-excess-errors "deleted function" } // { dg-error "instantiated from" "" { target *-*-* } 29 } -// { dg-error "instantiated from" "" { target *-*-* } 532 } +// { dg-error "instantiated from" "" { target *-*-* } 528 } // { dg-error "instantiated from" "" { target *-*-* } 170 } // { dg-error "instantiated from" "" { target *-*-* } 399 } // { dg-error "instantiated from" "" { target *-*-* } 168 } diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc index 71eb282fcd8..369cba826f4 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic_integral/cons/copy_neg.cc @@ -30,11 +30,11 @@ int main() return 0; } -// { dg-error "used here" "" { target *-*-* } 564 } +// { dg-error "used here" "" { target *-*-* } 560 } // { dg-excess-errors "deleted function" } // { dg-excess-errors "deleted function" } // { dg-error "instantiated from" "" { target *-*-* } 29 } -// { dg-error "instantiated from" "" { target *-*-* } 570 } +// { dg-error "instantiated from" "" { target *-*-* } 566 } // { dg-error "instantiated from" "" { target *-*-* } 170 } // { dg-error "instantiated from" "" { target *-*-* } 399 } // { dg-error "instantiated from" "" { target *-*-* } 168 } diff --git a/libstdc++-v3/testsuite/util/testsuite_common_types.h b/libstdc++-v3/testsuite/util/testsuite_common_types.h index c6c00689f3d..a6c58be6f31 100644 --- a/libstdc++-v3/testsuite/util/testsuite_common_types.h +++ b/libstdc++-v3/testsuite/util/testsuite_common_types.h @@ -474,12 +474,8 @@ namespace __gnu_test { void __constraint() { - // libstdc++/37907 - // typedef std::is_standard_layout<_Tp> standard_layout_p; - // static_assert(standard_layout_p::value, "not standard_layout"); - - typedef std::has_virtual_destructor<_Tp> ctor_p; - static_assert(!ctor_p::value, "has virtual destructor"); + typedef std::is_standard_layout<_Tp> standard_layout_p; + static_assert(standard_layout_p::value, "not standard_layout"); } }; |