aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/expr.c
AgeCommit message (Collapse)AuthorFilesLines
2008-08-28gfortran.h (enum expr_t): New value `EXPR_COMPCALL'.Daniel Kraft1-6/+20
2008-08-28 Daniel Kraft <d@domob.eu> * gfortran.h (enum expr_t): New value `EXPR_COMPCALL'. (gfc_get_typebound_proc): New macro. (struct gfc_expr): New union-member `compcall' for EXPR_COMPCALL. (enum gfc_exec_op): New value `EXEC_COMPCALL'. (gfc_find_typebound_proc): New argument. (gfc_copy_ref), (gfc_match_varspec): Made public. * decl.c (match_procedure_in_type): Use gfc_get_typebound_proc. * expr.c (free_expr0), (gfc_copy_expr): Handle EXPR_COMPCALL. (gfc_copy_ref): Made public and use new name. (simplify_const_ref): Use new name of gfc_copy_ref. (simplify_parameter_variable): Ditto. (gfc_simplify_expr): gcc_unreachable for EXPR_COMPCALL. * match.c (match_typebound_call): New method. (gfc_match_call): Allow for CALL's to typebound procedures. * module.c (binding_passing), (binding_overriding): New variables. (expr_types): Add EXPR_COMPCALL. (mio_expr): gcc_unreachable for EXPR_COMPCALL. (mio_typebound_proc), (mio_typebound_symtree): New methods. (mio_f2k_derived): Handle type-bound procedures. * primary.c (gfc_match_varspec): Made public and parse trailing references to type-bound procedures; new argument `sub_flag'. (gfc_match_rvalue): New name and argument of gfc_match_varspec. (match_variable): Ditto. * resolve.c (update_arglist_pass): New method. (update_compcall_arglist), (resolve_typebound_static): New methods. (resolve_typebound_call), (resolve_compcall): New methods. (gfc_resolve_expr): Handle EXPR_COMPCALL. (resolve_code): Handle EXEC_COMPCALL. (resolve_fl_derived): New argument to gfc_find_typebound_proc. (resolve_typebound_procedure): Ditto and removed not-implemented error. * st.c (gfc_free_statement): Handle EXEC_COMPCALL. * symbol.c (gfc_find_typebound_proc): New argument `noaccess' and implement access-checking. * trans-expr.c (gfc_apply_interface_mapping_to_expr): gcc_unreachable on EXPR_COMPCALL. * trans-intrinsic.c (gfc_conv_intrinsic_bound): Add missing break. * trans-openmp.c (gfc_trans_omp_array_reduction): Add missing intialization of ref->type. 2008-08-28 Daniel Kraft <d@domob.eu> * gfortran.dg/typebound_call_1.f03: New test. * gfortran.dg/typebound_call_2.f03: New test. * gfortran.dg/typebound_call_3.f03: New test. * gfortran.dg/typebound_call_4.f03: New test. * gfortran.dg/typebound_call_5.f03: New test. * gfortran.dg/typebound_call_6.f03: New test. * gfortran.dg/typebound_proc_1.f08: Don't expect not-implemented error. * gfortran.dg/typebound_proc_2.f90: Ditto. * gfortran.dg/typebound_proc_5.f03: Ditto. * gfortran.dg/typebound_proc_6.f03: Ditto. * gfortran.dg/typebound_proc_7.f03: Ditto. * gfortran.dg/typebound_proc_8.f03: Ditto. From-SVN: r139724
2008-08-23gfortran.h (gfc_component): Add field "symbol_attribute attr"...Janus Weil1-4/+4
2008-08-23 Janus Weil <janus@gcc.gnu.org> * gfortran.h (gfc_component): Add field "symbol_attribute attr", remove fields "pointer", "allocatable", "dimension", "access". Remove functions "gfc_set_component_attr" and "gfc_get_component_attr". * interface.c (gfc_compare_derived_types): Ditto. * trans-array.c (gfc_array_allocate,structure_alloc_comps): Ditto. * trans-expr.c (gfc_conv_component_ref,gfc_trans_subcomponent_assign, gfc_conv_structure): Ditto. * symbol.c (gfc_find_component,free_components,gfc_set_component_attr, gfc_get_component_attr,verify_bind_c_derived_type, generate_isocbinding_symbol): Ditto. * decl.c (build_struct): Ditto. * dump-parse-tree.c (show_components): Ditto. * trans-stmt.c (gfc_trans_deallocate): Ditto. * expr.c (gfc_check_assign,gfc_check_pointer_assign, gfc_default_initializer): Ditto. * module.c (mio_component): Ditto. * trans-types.c (copy_dt_decls_ifequal,gfc_get_derived_type): Ditto. * resolve.c (has_default_initializer,resolve_structure_cons, gfc_iso_c_func_interface,find_array_spec,resolve_ref, resolve_deallocate_expr,resolve_allocate_expr,resolve_fl_derived, resolve_equivalence_derived): Ditto. * trans-io.c (transfer_expr): Ditto. * parse.c (parse_derived): Ditto. * dependency.c (gfc_check_dependency): Ditto. * primary.c (gfc_variable_attr): Ditto. From-SVN: r139524
2008-08-22gfortran.h (in_prefix): Removed from this header.Daniel Kraft1-55/+23
2008-08-22 Daniel Kraft <d@domob.eu> * gfortran.h (in_prefix): Removed from this header. * match.h (gfc_matching_prefix): Moved and renamed from `in_prefix'. * decl.c (in_prefix): Removed from here. (gfc_match_prefix): Use new name of `gfc_matching_prefix'. * symbol.c (gfc_check_symbol_typed): Ditto. * expr.c (check_typed_ns): New helper variable. (expr_check_typed_help): New helper method. (gfc_expr_check_typed): Rewrote to use gfc_traverse_expr to do the work, fixing a minor problem. * match.c (gfc_matching_prefix): New variable. From-SVN: r139435
2008-08-22re PR fortran/32095 (Accepts invalid character(len(a)),dimension(1) :: a)Daniel Kraft1-0/+75
2008-08-22 Daniel Kraft <d@domob.eu> PR fortran/32095 PR fortran/34228 * gfortran.h (in_prefix): New global. (gfc_check_symbol_typed), (gfc_check_expr_typed): New methods. * array.c (match_array_element_spec): Check that bounds-expressions don't have symbols not-yet-typed in them. * decl.c (var_element): Check that variable used is already typed. (char_len_param_value): Check that expression does not contain not-yet-typed symbols. (in_prefix): New global. (gfc_match_prefix): Record using `in_prefix' if we're at the moment parsing a prefix or not. * expr.c (gfc_expr_check_typed): New method. * parse.c (verify_st_order): New argument to disable error output. (check_function_result_typed): New helper method. (parse_spec): Check that the function-result declaration, if given in a prefix, contains no not-yet-typed symbols when the IMPLICIT rules are parsed. * symbol.c (gfc_check_symbol_typed): Check that a symbol already has a type associated to it, otherwise use the IMPLICIT rules or signal an error. 2008-08-22 Daniel Kraft <d@domob.eu> PR fortran/32095 PR fortran/34228 * gfortran.dg/used_before_typed_1.f90: New test. * gfortran.dg/used_before_typed_2.f90: New test. * gfortran.dg/used_before_typed_3.f90: New test. * gfortran.dg/array_constructor_26.f03: Add -std=gnu to not enable legacy-behaviour for the new check. * gfortran.dg/array_constructor_27.f03: Ditto. * gfortran.dg/blockdata_4.f90: Ditto. * gfortran.dg/bound_2.f90: Reordered declarations to satisfy the check. * gfortran.dg/result_in_spec_1.f90: Ditto. * gfortran.dg/argument_checking_7.f90: Adapted expected error messages. From-SVN: r139425
2008-07-29gfortran.h (try): Remove macro.Kaveh R. Ghazi1-32/+32
* gfortran.h (try): Remove macro. Replace try with gfc_try throughout. * array.c: Likewise. * check.c: Likewise. * cpp.c: Likewise. * cpp.h: Likewise. * data.c: Likewise. * data.h: Likewise. * decl.c: Likewise. * error.c: Likewise. * expr.c: Likewise. * interface.c: Likewise. * intrinsic.c: Likewise. * intrinsic.h: Likewise. * io.c: Likewise. * match.h: Likewise. * parse.c: Likewise. * parse.h: Likewise. * resolve.c: Likewise. * scanner.c: Likewise. * simplify.c: Likewise. * symbol.c: Likewise. * trans-openmp.c: Likewise. * trans-types.c: Likewise. From-SVN: r138226
2008-07-24re PR fortran/33141 (Intrinsic procedures: Improve warning/error with -std=*)Daniel Kraft1-3/+7
2008-07-24 Daniel Kraft <d@domob.eu> PR fortran/33141 * lang.opt (Wnonstd-intrinsics): Removed option. (Wintrinsics-std), (Wintrinsic-shadow): New options. * invoke.texi (Option Summary): Removed -Wnonstd-intrinsics from the list and added -Wintrinsics-std and -Wintrinsic-shadow. (Error and Warning Options): Documented the new options and removed the documentation for -Wnonstd-intrinsics. * gfortran.h (gfc_option_t): New members warn_intrinsic_shadow and warn_intrinsics_std, removed warn_nonstd_intrinsics. (gfc_is_intrinsic): Renamed from gfc_intrinsic_name. (gfc_warn_intrinsic_shadow), (gfc_check_intrinsic_standard): New. * decl.c (match_procedure_decl): Replaced gfc_intrinsic_name by the new name gfc_is_intrinsic. (warn_intrinsic_shadow): New helper method. (gfc_match_function_decl), (gfc_match_subroutine): Call the new method warn_intrinsic_shadow to check the just-parsed procedure. * expr.c (check_init_expr): Call new gfc_is_intrinsic to check whether the function called is really an intrinsic in the selected standard. * intrinsic.c (gfc_is_intrinsic): Renamed from gfc_intrinsic_name and extended to take into account the selected standard settings when trying to find out whether a symbol is an intrinsic or not. (gfc_check_intrinsic_standard): Made public and extended. (gfc_intrinsic_func_interface), (gfc_intrinsic_sub_interface): Removed the calls to check_intrinsic_standard, this check now happens inside gfc_is_intrinsic. (gfc_warn_intrinsic_shadow): New method defined. * options.c (gfc_init_options): Initialize new warning flags to false and removed intialization of Wnonstd-intrinsics flag. (gfc_post_options): Removed logic for Wnonstd-intrinsics flag. (set_Wall): Set new warning flags and removed Wnonstd-intrinsics flag. (gfc_handle_option): Handle the new flags and removed handling of the old Wnonstd-intrinsics flag. * primary.c (gfc_match_rvalue): Replaced call to gfc_intrinsic_name by the new name gfc_is_intrinsic. * resolve.c (resolve_actual_arglist): Ditto. (resolve_generic_f), (resolve_unknown_f): Ditto. (is_external_proc): Ditto. (resolve_generic_s), (resolve_unknown_s): Ditto. (resolve_symbol): Ditto and ensure for symbols declared INTRINSIC that they are really available in the selected standard setting. 2008-07-24 Daniel Kraft <d@domob.eu> PR fortran/33141 * gfortran.dg/intrinsic_shadow_1.f03: New test for -Wintrinsic-shadow. * gfortran.dg/intrinsic_shadow_2.f03: Ditto. * gfortran.dg/intrinsic_shadow_3.f03: Ditto. * gfortran.dg/intrinsic_std_1.f90: New test for -Wintrinsics-std. * gfortran.dg/intrinsic_std_2.f90: Ditto. * gfortran.dg/intrinsic_std_3.f90: Ditto. * gfortran.dg/intrinsic_std_4.f90: Ditto. * gfortran.dg/warn_std_1.f90: Removed option -Wnonstd-intrinsics. * gfortran.dg/warn_std_2.f90: Replaced -Wnonstd-intrinsics by -Wintrinsics-std and adapted expected errors/warnings. * gfortran.dg/warn_std_3.f90: Ditto. * gfortran.dg/c_sizeof_2.f90: Adapted expected error/warning message. * gfortran.dg/gamma_2.f90: Ditto. * gfortran.dg/selected_char_kind_3.f90: Ditto. * gfortran.dg/fmt_g0_2.f08: Call with -fall-intrinsics to allow abort. From-SVN: r138122
2008-07-21fmt_g0_3.f08: Fix typo in expected error message.Ralf Wildenhues1-1/+1
gcc/testsuite/ * gfortran.dg/fmt_g0_3.f08: Fix typo in expected error message. gcc/fortran/ * expr.c (gfc_check_pointer_assign): Fix typo in string. * io.c (check_format): Fix typo in string. Fix comment typos. * parse.c (gfc_global_used): Likewise. * resolve.c (resolve_allocate_expr): Likewise. * symbol.c (gfc_set_default_type): Likewise. * arith.c: Fix typos in comments. * array.c: Likewise. * data.c: Likewise. * decl.c: Likewise. * dependency.c: Likewise. * f95-lang.c: Likewise. * gfortran.h: Likewise. * matchexp.c: Likewise. * module.c: Likewise. * primary.c: Likewise. * scanner.c: Likewise. * trans-array.c: Likewise. * trans-common.c: Likewise. * trans-decl.c: Likewise. * trans-expr.c: Likewise. * trans-intrinsic.c: Likewise. * trans-types.c: Likewise. * trans.c: Likewise. * trans.h: Likewise. From-SVN: r138040
2008-07-19gfortran.h (new): Remove macro.Kaveh R. Ghazi1-8/+8
* gfortran.h (new): Remove macro. * array.c (gfc_append_constructor, match_array_list, gfc_match_array_constructor): Likewise. * bbt.c (insert, gfc_insert_bbt): Likewise. * decl.c (var_element, top_var_list, top_val_list, gfc_match_data, get_proc_name): Likewise. * expr.c (gfc_copy_actual_arglist): Likewise. * interface.c (compare_actual_formal, check_new_interface, gfc_add_interface): Likewise. * intrinsic.c gfc_convert_type_warn, gfc_convert_chartype): Likewise. * io.c (match_io_iterator, match_io_list): Likewise. * match.c (match_forall_header): Likewise. * matchexp.c (build_node): Likewise. * module.c (gfc_match_use): Likewise. * scanner.c (load_file): Likewise. * st.c (gfc_append_code): Likewise. * symbol.c (save_symbol_data, gfc_get_sym_tree, gfc_undo_symbols, gfc_commit_symbols): Likewise. * trans-common.c (build_field): Likewise. * trans-decl.c (gfc_finish_var_decl): Likewise. * trans-expr.c (gfc_free_interface_mapping, gfc_get_interface_mapping_charlen, gfc_add_interface_mapping, gfc_finish_interface_mapping, gfc_apply_interface_mapping_to_expr): Likewise. * trans.h (gfc_interface_sym_mapping): Likewise. From-SVN: r137982
2008-07-19gfortran.h (operator): Remove macro.Kaveh R. Ghazi1-6/+6
* gfortran.h (operator): Remove macro. (gfc_namespace, gfc_expr): Avoid C++ keywords. * arith.c (eval_intrinsic, eval_intrinsic_f2, eval_intrinsic_f3): Likewise. * decl.c (access_attr_decl): Likewise. * dependency.c (gfc_dep_compare_expr): Likewise. * dump-parse-tree.c (show_expr, show_uop, show_namespace): Likewise. * expr.c (gfc_copy_expr, gfc_type_convert_binary, simplify_intrinsic_op, check_intrinsic_op): Likewise. * interface.c (fold_unary, gfc_match_generic_spec, gfc_match_interface, gfc_match_end_interface, check_operator_interface, check_uop_interfaces, gfc_check_interfaces, gfc_extend_expr, gfc_extend_assign, gfc_add_interface, gfc_current_interface_head, gfc_set_current_interface_head): Likewise. * iresolve.c (gfc_resolve_dot_product, gfc_resolve_matmul): Likewise. * matchexp.c (gfc_get_parentheses, build_node): Likewise. * module.c (gfc_use_rename, gfc_match_use, find_use_name_n, number_use_names, mio_expr, load_operator_interfaces, read_module, write_operator, write_module): Likewise. * openmp.c (resolve_omp_atomic): Likewise. * resolve.c (resolve_operator, gfc_resolve_character_operator, gfc_resolve_uops): Likewise. * symbol.c (free_uop_tree, gfc_free_namespace): Likewise. * trans-expr.c (gfc_conv_expr_op): Likewise. * trans-openmp.c (gfc_trans_omp_atomic): Likewise. From-SVN: r137981
2008-07-19gfortran.h (protected): Remove macro.Kaveh R. Ghazi1-1/+1
* gfortran.h (protected): Remove macro. * dump-parse-tree.c (show_attr): Avoid C++ keywords. * expr.c (gfc_check_pointer_assign): Likewise. * interface.c (compare_parameter_protected): Likewise. * intrinsic.c (enum class, add_sym, add_sym_0, add_sym_1, add_sym_1s, add_sym_1m, add_sym_2, add_sym_2s, add_sym_3, add_sym_3ml, add_sym_3red, add_sym_3s, add_sym_4, add_sym_4s, add_sym_5s): Likewise. * match.c (gfc_match_assignment, gfc_match_pointer_assignment): Likewise. * module.c (mio_symbol_attribute): Likewise. * primary.c (match_variable): Likewise. * resolve.c (resolve_equivalence): Likewise. * symbol.c (check_conflict, gfc_add_protected, gfc_copy_attr): Likewise. * trans-types.c (gfc_get_array_type_bounds): Likewise. From-SVN: r137980
2008-07-02re PR fortran/32580 (iso_c_binding c_f_procpointer / procedure pointers)Janus Weil1-3/+9
2008-07-02 Janus Weil <janus@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> Paul Thomas <pault@gcc.gnu.org> PR fortran/32580 * gfortran.h (struct gfc_symbol): New member "proc_pointer". * check.c (gfc_check_associated,gfc_check_null): Implement procedure pointers. * decl.c (match_procedure_decl): Ditto. * expr.c (gfc_check_pointer_assign,gfc_check_assign_symbol): Ditto. * interface.c (compare_actual_formal): Ditto. * match.h: Ditto. * match.c (gfc_match_pointer_assignment): Ditto. * parse.c (parse_interface): Ditto. * primary.c (gfc_match_rvalue,match_variable): Ditto. * resolve.c (resolve_fl_procedure): Ditto. * symbol.c (check_conflict,gfc_add_external,gfc_add_pointer, gfc_copy_attr,gen_fptr_param,build_formal_args): Ditto. * trans-decl.c (get_proc_pointer_decl,gfc_get_extern_function_decl, create_function_arglist): Ditto. * trans-expr.c (gfc_conv_variable,gfc_conv_function_val, gfc_conv_function_call,gfc_trans_pointer_assignment): Ditto. 2008-07-02 Janus Weil <janus@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> PR fortran/32580 * gfortran.dg/c_f_pointer_tests_3.f90: Updated. * gfortran.dg/proc_decl_1.f90: Updated. * gfortran.dg/proc_ptr_1.f90: New. * gfortran.dg/proc_ptr_2.f90: New. * gfortran.dg/proc_ptr_3.f90: New. * gfortran.dg/proc_ptr_4.f90: New. * gfortran.dg/proc_ptr_5.f90: New. * gfortran.dg/proc_ptr_6.f90: New. * gfortran.dg/proc_ptr_7.f90: New. * gfortran.dg/proc_ptr_8.f90: New. Co-Authored-By: Paul Thomas <pault@gcc.gnu.org> Co-Authored-By: Tobias Burnus <burnus@net-b.de> From-SVN: r137386
2008-06-24re PR fortran/36371 (Wrong locus for errors in DATA statement)Paul Thomas1-3/+4
2008-06-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/34371 * expr.c (gfc_check_assign): Change message and locus for error when conform == 0. 2008-06-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/36371 * gfortran.dg/data_array_5.f90: New test. From-SVN: r137088
2008-06-20arith.c (hollerith2representation): Fix for -Wc++-compat.Kaveh R. Ghazi1-2/+2
* arith.c (hollerith2representation): Fix for -Wc++-compat. * array.c (gfc_get_constructor): Likewise. * decl.c (gfc_get_data_variable, gfc_get_data_value, gfc_get_data, create_enum_history, gfc_match_final_decl): Likewise. * error.c (error_char): Likewise. * expr.c (gfc_get_expr, gfc_copy_expr): Likewise. * gfortran.h (gfc_get_charlen, gfc_get_array_spec, gfc_get_component, gfc_get_formal_arglist, gfc_get_actual_arglist, gfc_get_namelist, gfc_get_omp_clauses, gfc_get_interface, gfc_get_common_head, gfc_get_dt_list, gfc_get_array_ref, gfc_get_ref, gfc_get_equiv, gfc_get_case, gfc_get_iterator, gfc_get_alloc, gfc_get_wide_string): Likewise. * interface.c (count_types_test): Likewise. * intrinsic.c (add_char_conversions, gfc_intrinsic_init_1): Likewise. * io.c (gfc_match_open, gfc_match_close, match_filepos, match_io, gfc_match_inquire, gfc_match_wait): Likewise. * match.c (gfc_match, match_forall_iterator): Likewise. * module.c (gfc_get_pointer_info, gfc_get_use_rename, add_fixup, add_true_name, parse_string, write_atom, quote_string, mio_symtree_ref, mio_gmp_real, write_common_0): Likewise. * options.c (gfc_post_options): Likewise. * primary.c (match_integer_constant, match_hollerith_constant, match_boz_constant, match_real_constant, gfc_get_structure_ctor_component, gfc_match_structure_constructor): Likewise. * scanner.c (gfc_widechar_to_char, add_path_to_list, add_file_change, load_line, get_file, preprocessor_line, load_file, unescape_filename, gfc_read_orig_filename): Likewise. * simplify.c (gfc_simplify_ibits, gfc_simplify_ishft, gfc_simplify_ishftc): Likewise. * symbol.c (gfc_get_st_label, gfc_get_namespace, gfc_new_symtree, gfc_get_uop, gfc_new_symbol, save_symbol_data, gfc_get_gsymbol): Likewise. * target-memory.c (gfc_target_interpret_expr): Likewise. * trans-const.c (gfc_build_wide_string_const): Likewise. * trans-expr.c (gfc_add_interface_mapping): Likewise. * trans-intrinsic.c (gfc_conv_intrinsic_conversion, gfc_conv_intrinsic_int, gfc_conv_intrinsic_lib_function, gfc_conv_intrinsic_cmplx, gfc_conv_intrinsic_ctime, gfc_conv_intrinsic_fdate, gfc_conv_intrinsic_ttynam, gfc_conv_intrinsic_minmax, gfc_conv_intrinsic_minmax_char, gfc_conv_intrinsic_ishftc, gfc_conv_intrinsic_index_scan_verify, gfc_conv_intrinsic_merge, gfc_conv_intrinsic_trim): Likewise. * trans.c (gfc_get_backend_locus): Likewise. * trans.h (gfc_get_ss): Likewise. From-SVN: r136982
2008-05-18intrinsic.c (char_conversions, ncharconv): New static variables.Francois-Xavier Coudert1-0/+10
* intrinsic.c (char_conversions, ncharconv): New static variables. (find_char_conv): New function. (add_functions): Add simplification functions for ADJUSTL and ADJUSTR. Don't check the kind of their argument. Add checking for LGE, LLE, LGT and LLT. (add_subroutines): Fix argument type for SLEEP. Fix argument name for SYSTEM. (add_char_conversions): New function. (gfc_intrinsic_init_1): Call add_char_conversions. (gfc_intrinsic_done_1): Free char_conversions. (check_arglist): Use kind == 0 as a signal that we don't want the kind value to be checked. (do_simplify): Also simplify character functions. (gfc_convert_chartype): New function * trans-array.c (gfc_trans_array_ctor_element): Don't force the use of default character type. (gfc_trans_array_constructor_value): Likewise. (get_array_ctor_var_strlen): Use integer kind to build an integer instead of a character kind! (gfc_build_constant_array_constructor): Don't force the use of default character type. (gfc_conv_loop_setup): Likewise. * trans-expr.c (gfc_conv_string_tmp): Don't force the use of default character type. Allocate enough memory for wide strings. (gfc_conv_concat_op): Make sure operand kind are the same. (string_to_single_character): Remove gfc_ prefix. Reindent. Don't force the use of default character type. (gfc_conv_scalar_char_value): Likewise. (gfc_build_compare_string): Call string_to_single_character. (fill_with_spaces): New function (gfc_trans_string_copy): Add kind arguments. Use them to deal with wide character kinds. (gfc_conv_statement_function): Whitespace fix. Call gfc_trans_string_copy with new kind arguments. (gfc_conv_substring_expr): Call gfc_build_wide_string_const instead of using gfc_widechar_to_char. (gfc_conv_string_parameter): Don't force the use of default character type. (gfc_trans_scalar_assign): Pass kind args to gfc_trans_string_copy. * intrinsic.h (gfc_check_lge_lgt_lle_llt, gfc_convert_char_constant, gfc_resolve_adjustl, gfc_resolve_adjustr): New prototypes. * decl.c (gfc_set_constant_character_len): Don't assert the existence of a single character kind. * trans-array.h (gfc_trans_string_copy): New prototype. * gfortran.h (gfc_check_character_range, gfc_convert_chartype): New prototypes. * error.c (print_wide_char_into_buffer): New function lifting code from gfc_print_wide_char. Fix order to output '\x??' instead of 'x\??'. (gfc_print_wide_char): Call print_wide_char_into_buffer. (show_locus): Call print_wide_char_into_buffer with buffer local to this function. * trans-const.c (gfc_build_wide_string_const): New function. (gfc_conv_string_init): Deal with wide characters strings constructors. (gfc_conv_constant_to_tree): Call gfc_build_wide_string_const. * trans-stmt.c (gfc_trans_label_assign): Likewise. (gfc_trans_character_select): Deal with wide strings. * expr.c (gfc_check_assign): Allow conversion between character kinds on assignment. * trans-const.h (gfc_build_wide_string_const): New prototype. * trans-types.c (gfc_get_character_type_len_for_eltype, gfc_get_character_type_len): Create too variants of the old gfc_get_character_type_len, one getting kind argument and the other one directly taking a type tree. * trans.h (gfor_fndecl_select_string_char4, gfor_fndecl_convert_char1_to_char4, gfor_fndecl_convert_char4_to_char1): New prototypes. * trans-types.h (gfc_get_character_type_len_for_eltype): New prototype. * resolve.c (resolve_operator): Exit early when kind mismatches are detected, because that makes us issue an error message later. (validate_case_label_expr): Fix wording of error message. * iresolve.c (gfc_resolve_adjustl, gfc_resolve_adjustr): New functions. (gfc_resolve_pack): Call _char4 variants of library function when dealing with wide characters. (gfc_resolve_reshape): Likewise. (gfc_resolve_spread): Likewise. (gfc_resolve_transpose): Likewise. (gfc_resolve_unpack): Likewise. * target-memory.c (size_character): Take character kind bit size correctly into account (not that it changes anything for now, but it's more generic). (gfc_encode_character): Added gfc_ prefix. Encoding each character of a string by calling native_encode_expr for the corresponding unsigned integer. (gfc_target_encode_expr): Add gfc_ prefix to encode_character. * trans-decl.c (gfc_build_intrinsic_function_decls): Build gfor_fndecl_select_string_char4, gfor_fndecl_convert_char1_to_char4 and gfor_fndecl_convert_char4_to_char1. * target-memory.h (gfc_encode_character): New prototype. * arith.c (gfc_check_character_range): New function. (eval_intrinsic): Allow non-default character kinds. * check.c (gfc_check_access_func): Only allow default character kind arguments. (gfc_check_chdir): Likewise. (gfc_check_chdir_sub): Likewise. (gfc_check_chmod): Likewise. (gfc_check_chmod_sub): Likewise. (gfc_check_lge_lgt_lle_llt): New function. (gfc_check_link): Likewise. (gfc_check_link_sub): Likewise. (gfc_check_symlnk): Likewise. (gfc_check_symlnk_sub): Likewise. (gfc_check_rename): Likewise. (gfc_check_rename_sub): Likewise. (gfc_check_fgetputc_sub): Likewise. (gfc_check_fgetput_sub): Likewise. (gfc_check_stat): Likewise. (gfc_check_stat_sub): Likewise. (gfc_check_date_and_time): Likewise. (gfc_check_ctime_sub): Likewise. (gfc_check_fdate_sub): Likewise. (gfc_check_gerror): Likewise. (gfc_check_getcwd_sub): Likewise. (gfc_check_getarg): Likewise. (gfc_check_getlog): Likewise. (gfc_check_hostnm): Likewise. (gfc_check_hostnm_sub): Likewise. (gfc_check_ttynam_sub): Likewise. (gfc_check_perror): Likewise. (gfc_check_unlink): Likewise. (gfc_check_unlink_sub): Likewise. (gfc_check_system_sub): Likewise. * primary.c (got_delim): Perform correct character range checking for all kinds. * trans-intrinsic.c (gfc_conv_intrinsic_conversion): Generate calls to library functions convert_char4_to_char1 and convert_char1_to_char4 for character conversions. (gfc_conv_intrinsic_char): Allow all character kings. (gfc_conv_intrinsic_strcmp): Fix whitespace. (gfc_conv_intrinsic_repeat): Take care of all character kinds. * intrinsic.texi: For all GNU intrinsics accepting character arguments, mention that they're restricted to the default kind. * simplify.c (simplify_achar_char): New function. (gfc_simplify_achar, gfc_simplify_char): Call simplify_achar_char. gfc_simplify_ichar): Don't error out for wide characters. (gfc_convert_char_constant): New function. * gfortran.dg/achar_3.f90: Adjust error messages. * gfortran.dg/achar_5.f90: New test. * gfortran.dg/achar_6.F90: New test. * gfortran.dg/widechar_1.f90: New test. * gfortran.dg/widechar_2.f90: New test. * gfortran.dg/widechar_3.f90: New test. * gfortran.dg/widechar_4.f90: New test. * gfortran.dg/widechar_intrinsics_1.f90: New test. * gfortran.dg/widechar_intrinsics_2.f90: New test. * gfortran.dg/widechar_intrinsics_3.f90: New test. * gfortran.dg/widechar_intrinsics_4.f90: New test. * gfortran.dg/widechar_intrinsics_5.f90: New test. * gfortran.dg/widechar_select_1.f90: New test. * gfortran.dg/widechar_select_2.f90: New test. From-SVN: r135515
2008-05-16re PR fortran/34325 (Wrong error message for syntax error)Jerry DeLisle1-1/+2
2008-05-16 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/34325 * decl.c (match_attr_spec): Check for matching pairs of parenthesis. * expr.c (gfc_specification_expr): Supplement the error message with the type that was found. * resolve.c (gfc_resolve_index): Likewise. * match.c (gfc_match_parens): Clarify error message with "at or before". (gfc_match_do): Check for matching pairs of parenthesis. From-SVN: r135428
2008-05-06arith.c: (gfc_arith_concat...Francois-Xavier Coudert1-20/+22
* arith.c: (gfc_arith_concat, gfc_compare_string, gfc_compare_with_Cstring, hollerith2representation, gfc_hollerith2int, gfc_hollerith2real, gfc_hollerith2complex, gfc_hollerith2character, gfc_hollerith2logical): Use wide characters for character constants. * data.c (create_character_intializer): Likewise. * decl.c (gfc_set_constant_character_len): Likewise. * dump-parse-tree.c (show_char_const): Correctly dump wide character strings. error.c (print_wide_char): Rename into gfc_print_wide_char. (show_locus): Adapt to new prototype of gfc_print_wide_char. expr.c (free_expr0): Representation is now disjunct from character string value, so we always free it. (gfc_copy_expr, find_substring_ref, gfc_simplify_expr): Adapt to wide character strings. * gfortran.h (gfc_expr): Make value.character.string a wide string. (gfc_wide_toupper, gfc_wide_strncasecmp, gfc_wide_memset, gfc_widechar_to_char, gfc_char_to_widechar): New prototypes. (gfc_get_wide_string): New macro. (gfc_print_wide_char): New prototype. * io.c (format_string): Make a wide string. (next_char, gfc_match_format, compare_to_allowed_values, gfc_match_open): Deal with wide strings. * module.c (mio_expr): Convert between wide strings and ASCII ones. * primary.c (match_hollerith_constant, match_charkind_name): Handle wide strings. * resolve.c (build_default_init_expr): Likewise. * scanner.c (gfc_wide_toupper, gfc_wide_memset, gfc_char_to_widechar): New functions. (wide_strchr, gfc_widechar_to_char, gfc_wide_strncasecmp): Changes in prototypes. (gfc_define_undef_line, load_line, preprocessor_line, include_line, load_file, gfc_read_orig_filename): Handle wide strings. * simplify.c (gfc_simplify_achar, gfc_simplify_adjustl, gfc_simplify_adjustr, gfc_simplify_char, gfc_simplify_iachar, gfc_simplify_ichar, simplify_min_max, gfc_simplify_new_line, gfc_simplify_repeat): Handle wide strings. (wide_strspn, wide_strcspn): New helper functions. (gfc_simplify_scan, gfc_simplify_trim, gfc_simplify_verify): Handle wide strings. * symbol.c (generate_isocbinding_symbol): Likewise. * target-memory.c (size_character, gfc_target_expr_size, encode_character, gfc_target_encode_expr, gfc_interpret_character, gfc_target_interpret_expr): Handle wide strings. * trans-const.c (gfc_conv_string_init): Lower wide strings to narrow ones. (gfc_conv_constant_to_tree): Likewise. * trans-expr.c (gfc_conv_substring_expr): Handle wide strings. * trans-io.c (gfc_new_nml_name_expr): Likewise. * trans-stmt.c (gfc_trans_label_assign): Likewise. From-SVN: r135006
2008-04-15re PR fortran/35864 (Revision 133965 broke gfortran.dg/initialization_1.f90)Paul Thomas1-6/+5
2008-04-15 Paul Thomas <pault@gcc.gnu.org> PR fortran/35864 * expr.c (scalarize_intrinsic_call): Reorder identification of array argument so that if one is not found a segfault does not occur. Return FAILURE if all scalar arguments. From-SVN: r134329
2008-04-06Index...Paul Thomas1-18/+30
Index: gcc/fortran/trans-stmt.c =================================================================== *** gcc/fortran/trans-stmt.c (revision 133728) --- gcc/fortran/trans-stmt.c (working copy) *************** gfc_trans_where_2 (gfc_code * code, tree *** 3540,3547 **** /* Translate a simple WHERE construct or statement without dependencies. CBLOCK is the "then" clause of the WHERE statement, where CBLOCK->EXPR ! is the mask condition, and EBLOCK if non-NULL is the "else" clause. ! Currently both CBLOCK and EBLOCK are restricted to single assignments. */ static tree gfc_trans_where_3 (gfc_code * cblock, gfc_code * eblock) --- 3540,3550 ---- /* Translate a simple WHERE construct or statement without dependencies. CBLOCK is the "then" clause of the WHERE statement, where CBLOCK->EXPR ! is the mask condition, and EBLOCK if non-NULL is the "then" clause of ! the ELSWHERE. As required by 7.5.3.2, the WHERE and ELSEWHERE are ! executed with separate loops. It should be noted that the mask expression ! is evaluated for both loops. Currently both CBLOCK and EBLOCK are ! restricted to single assignments. */ static tree gfc_trans_where_3 (gfc_code * cblock, gfc_code * eblock) *************** gfc_trans_where_3 (gfc_code * cblock, gf *** 3561,3566 **** --- 3564,3570 ---- edst = eblock ? eblock->next->expr : NULL; esrc = eblock ? eblock->next->expr2 : NULL; + /*---------------First do the WHERE part.----------------*/ gfc_start_block (&block); gfc_init_loopinfo (&loop); *************** gfc_trans_where_3 (gfc_code * cblock, gf *** 3584,3619 **** gfc_add_ss_to_loop (&loop, tdss); gfc_add_ss_to_loop (&loop, tsss); - if (eblock) - { - /* Handle the else clause. */ - gfc_init_se (&edse, NULL); - gfc_init_se (&esse, NULL); - edss = gfc_walk_expr (edst); - esss = gfc_walk_expr (esrc); - if (esss == gfc_ss_terminator) - { - esss = gfc_get_ss (); - esss->next = gfc_ss_terminator; - esss->type = GFC_SS_SCALAR; - esss->expr = esrc; - } - gfc_add_ss_to_loop (&loop, edss); - gfc_add_ss_to_loop (&loop, esss); - } - gfc_conv_ss_startstride (&loop); gfc_conv_loop_setup (&loop); gfc_mark_ss_chain_used (css, 1); gfc_mark_ss_chain_used (tdss, 1); gfc_mark_ss_chain_used (tsss, 1); ! if (eblock) ! { ! gfc_mark_ss_chain_used (edss, 1); ! gfc_mark_ss_chain_used (esss, 1); ! } ! gfc_start_scalarized_body (&loop, &body); gfc_copy_loopinfo_to_se (&cse, &loop); --- 3588,3600 ---- gfc_add_ss_to_loop (&loop, tdss); gfc_add_ss_to_loop (&loop, tsss); gfc_conv_ss_startstride (&loop); gfc_conv_loop_setup (&loop); gfc_mark_ss_chain_used (css, 1); gfc_mark_ss_chain_used (tdss, 1); gfc_mark_ss_chain_used (tsss, 1); ! gfc_start_scalarized_body (&loop, &body); gfc_copy_loopinfo_to_se (&cse, &loop); *************** gfc_trans_where_3 (gfc_code * cblock, gf *** 3622,3637 **** cse.ss = css; tdse.ss = tdss; tsse.ss = tsss; - if (eblock) - { - gfc_copy_loopinfo_to_se (&edse, &loop); - gfc_copy_loopinfo_to_se (&esse, &loop); - edse.ss = edss; - esse.ss = esss; - } gfc_conv_expr (&cse, cond); ! gfc_add_block_to_block (&body, &cse.pre); cexpr = cse.expr; gfc_conv_expr (&tsse, tsrc); --- 3603,3611 ---- cse.ss = css; tdse.ss = tdss; tsse.ss = tsss; gfc_conv_expr (&cse, cond); ! gfc_add_block_to_block (&block, &cse.pre); cexpr = cse.expr; gfc_conv_expr (&tsse, tsrc); *************** gfc_trans_where_3 (gfc_code * cblock, gf *** 3643,3650 **** --- 3617,3678 ---- else gfc_conv_expr (&tdse, tdst); + /* Make the assignment on condition 'cond'. */ + tstmt = gfc_trans_scalar_assign (&tdse, &tsse, tdst->ts, false, false); + tmp = build3_v (COND_EXPR, cexpr, tstmt, build_empty_stmt ()); + gfc_add_expr_to_block (&body, tmp); + gfc_add_block_to_block (&body, &cse.post); + + gfc_trans_scalarizing_loops (&loop, &body); + gfc_add_block_to_block (&block, &loop.pre); + gfc_add_block_to_block (&block, &loop.post); + gfc_cleanup_loop (&loop); + + /*---------------Now do the ELSEWHERE.--------------*/ if (eblock) { + gfc_init_loopinfo (&loop); + + /* Handle the condition. */ + gfc_init_se (&cse, NULL); + css = gfc_walk_expr (cond); + gfc_add_ss_to_loop (&loop, css); + + /* Handle the then-clause. */ + gfc_init_se (&edse, NULL); + gfc_init_se (&esse, NULL); + edss = gfc_walk_expr (edst); + esss = gfc_walk_expr (esrc); + if (esss == gfc_ss_terminator) + { + esss = gfc_get_ss (); + esss->next = gfc_ss_terminator; + esss->type = GFC_SS_SCALAR; + esss->expr = esrc; + } + gfc_add_ss_to_loop (&loop, edss); + gfc_add_ss_to_loop (&loop, esss); + + gfc_conv_ss_startstride (&loop); + gfc_conv_loop_setup (&loop); + + gfc_mark_ss_chain_used (css, 1); + gfc_mark_ss_chain_used (edss, 1); + gfc_mark_ss_chain_used (esss, 1); + + gfc_start_scalarized_body (&loop, &body); + + gfc_copy_loopinfo_to_se (&cse, &loop); + gfc_copy_loopinfo_to_se (&edse, &loop); + gfc_copy_loopinfo_to_se (&esse, &loop); + cse.ss = css; + edse.ss = edss; + esse.ss = esss; + + gfc_conv_expr (&cse, cond); + gfc_add_block_to_block (&body, &cse.pre); + cexpr = cse.expr; + gfc_conv_expr (&esse, esrc); if (edss != gfc_ss_terminator && loop.temp_ss != NULL) { *************** gfc_trans_where_3 (gfc_code * cblock, gf *** 3653,3672 **** } else gfc_conv_expr (&edse, edst); } - tstmt = gfc_trans_scalar_assign (&tdse, &tsse, tdst->ts, false, false); - estmt = eblock ? gfc_trans_scalar_assign (&edse, &esse, edst->ts, false, false) - : build_empty_stmt (); - tmp = build3_v (COND_EXPR, cexpr, tstmt, estmt); - gfc_add_expr_to_block (&body, tmp); - gfc_add_block_to_block (&body, &cse.post); - - gfc_trans_scalarizing_loops (&loop, &body); - gfc_add_block_to_block (&block, &loop.pre); - gfc_add_block_to_block (&block, &loop.post); - gfc_cleanup_loop (&loop); - return gfc_finish_block (&block); } --- 3681,3700 ---- } else gfc_conv_expr (&edse, edst); + + /* Make the assignment on condition 'NOT.cond'. */ + estmt = gfc_trans_scalar_assign (&edse, &esse, edst->ts, false, false); + cexpr = fold_build1 (TRUTH_NOT_EXPR, boolean_type_node, cexpr); + tmp = build3_v (COND_EXPR, cexpr, estmt, build_empty_stmt ()); + gfc_add_expr_to_block (&body, tmp); + gfc_add_block_to_block (&body, &cse.post); + + gfc_trans_scalarizing_loops (&loop, &body); + gfc_add_block_to_block (&block, &loop.pre); + gfc_add_block_to_block (&block, &loop.post); + gfc_cleanup_loop (&loop); } return gfc_finish_block (&block); } *************** gfc_trans_where (gfc_code * code) *** 3698,3708 **** cblock->next->expr2, 0)) return gfc_trans_where_3 (cblock, NULL); } else if (!eblock->expr && !eblock->block && eblock->next && eblock->next->op == EXEC_ASSIGN ! && !eblock->next->next) { /* A simple "WHERE (cond) x1 = y1 ELSEWHERE x2 = y2 ENDWHERE" block is dependence free if cond is not dependent on writes --- 3726,3739 ---- cblock->next->expr2, 0)) return gfc_trans_where_3 (cblock, NULL); } + /* Since gfc_trans_where_3 evaluates the condition expression + twice, do not use it if the condition is not a variable. */ else if (!eblock->expr && !eblock->block && eblock->next && eblock->next->op == EXEC_ASSIGN ! && !eblock->next->next ! && cblock->expr->expr_type == EXPR_VARIABLE) { /* A simple "WHERE (cond) x1 = y1 ELSEWHERE x2 = y2 ENDWHERE" block is dependence free if cond is not dependent on writes Index: gcc/testsuite/gfortran.dg/where_1.f90 =================================================================== *** gcc/testsuite/gfortran.dg/where_1.f90 (revision 0) --- gcc/testsuite/gfortran.dg/where_1.f90 (revision 0) *************** *** 0 **** --- 1,61 ---- + ! { dg-do run } + ! { dg-options "-fdump-tree-original" } + ! Tests the fix for PR35759, in which the simple WHERE was logically + ! wrong. 7.5.3.2 requires that the WHERE and ELSEWHERE are execute in + ! separate loops, whereas gfortran was implementing them as a single + ! loop with an 'if' and 'else'. Since the condition expression is + ! evaluated twice with the fix, the use of anything other than a + ! variable or parameter array for the condition will trigger the more + ! comprehensive implementation of WHERE. This is checked by the + ! check of the declaration of temp.15 in the 'original' code. + ! + ! Contributed by Dick Hendrickson <dick.hendrickson@gmail.com> + ! + program RG0023 + + integer UDA1L(6) + integer :: UDA1R(6), expected(6) = (/2,0,5,0,3,0/) + LOGICAL LDA(5) + LOGICAL, parameter :: PDA(5) = (/ (i/2*2 .ne. I, i=1,5) /) + + UDA1L(1:6) = 0 + uda1r = (/1,2,3,4,5,6/) + lda = pda + + WHERE (lda) ! expected + UDA1L(1:5) = UDA1R(2:6) ! uda1l = 2,0,4,0,6,0 + ELSEWHERE + UDA1L(2:6) = UDA1R(6:2:-1) !uda1l = 2,0,5,0,3,0 + ENDWHERE + + if (any (uda1l /= expected)) call abort () + + uda1l = 0 + + WHERE (pda) ! expected + UDA1L(1:5) = UDA1R(2:6) ! uda1l = 2,0,4,0,6,0 + ELSEWHERE + UDA1L(2:6) = UDA1R(6:2:-1) !uda1l = 2,0,5,0,3,0 + ENDWHERE + + if (any (uda1l /= expected)) call abort () + + uda1l = 0 + + WHERE (lfoo ()) ! expected + UDA1L(1:5) = UDA1R(2:6) ! uda1l = 2,0,4,0,6,0 + ELSEWHERE + UDA1L(2:6) = UDA1R(6:2:-1) !uda1l = 2,0,5,0,3,0 + ENDWHERE + + if (any (uda1l /= expected)) call abort () + + contains + + function lfoo () result (ltmp) + logical ltmp(5) + ltmp = lda + end function lfoo + END + ! { dg-final { scan-tree-dump-times "temp.18\\\[5\\\]" 1 "original" } } + ! { dg-final { cleanup-tree-dump "original" } } From-SVN: r133965
2008-02-29re PR fortran/35059 (Seg fault when max constructor limit reached)Jerry DeLisle1-13/+14
2008-02-29 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/35059 * expr.c (find_array_element): Modify traversing the constructor to avoid trying to access NULL memory pointed to by next for the last element. (find_array_section): Exit while loop if cons->next is NULL. * trans-expr.c (gfc_conv_scalar_char_value): Initialize gfc_typespec. (gfc_conv_function_call): Same. * decl.c (gfc_match_implicit): Same. * trans-intrinsic.c (gfc_conv_intrinsic_sr_kind): Same. From-SVN: r132782
2008-02-24arith.c: Update copyright years.Tobias Schlüter1-1/+1
* arith.c: Update copyright years. * arith.h: Likewise. * array.c: Likewise. * bbt.c: Likewise. * check.c: Likewise. * data.c: Likewise. * data.h: Likewise. * decl.c: Likewise. * dependency.c: Likewise. * dependency.h: Likewise. * dump-parse-tree.c: Likewise. * error.c: Likewise. * expr.c: Likewise. * gfc-internals.texi: Likewise. * gfortran.h: Likewise. * gfortran.texi: Likewise. * gfortranspec.c: Likewise. * interface.c: Likewise. * intrinsic.c: Likewise. * intrinsic.h: Likewise. * intrinsic.texi: Likewise. * invoke.texi: Likewise. * io.c: Likewise. * iresolve.c: Likewise. * iso-c-binding.def: Likewise. * iso-fortran-env.def: Likewise. * lang-specs.h: Likewise. * lang.opt: Likewise. * libgfortran.h: Likewise. * match.c: Likewise. * match.h: Likewise. * matchexp.c: Likewise. * misc.c: Likewise. * module.c: Likewise. * openmp.c: Likewise. * options.c: Likewise. * parse.c: Likewise. * parse.h: Likewise. * primary.c: Likewise. * resolve.c: Likewise. * scanner.c: Likewise. * simplify.c: Likewise. * st.c: Likewise. * symbol.c: Likewise. * target-memory.c: Likewise. * target-memory.h: Likewise. * trans-array.h: Likewise. * trans-const.h: Likewise. * trans-stmt.h: Likewise. * trans-types.c: Likewise. * trans-types.h: Likewise. * types.def: Likewise. From-SVN: r132600
2008-02-19re PR fortran/35030 (add type/kind information to pointer assignments)Daniel Franke1-4/+5
2008-02-19 Daniel Franke <franke.daniel@gmail.com> PR fortran/35030 * expr.c (gfc_check_pointer_assign): Add type and kind information to type-mismatch message. (gfc_check_assign): Unify error messages. From-SVN: r132442
2008-01-31re PR fortran/34910 (ICE on invalid assignments in doubly-contained functions)Paul Thomas1-0/+9
2008-01-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/34910 * expr.c (gfc_check_assign): It is an error to assign to a sibling procedure. 2008-01-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/34910 * gfortran.dg/proc_assign_2.f90: New test. From-SVN: r131985
2008-01-22re PR fortran/34915 (-std=f95 rejects len_trim() and index() in init ↵Daniel Franke1-1/+2
expressions) gcc/fortran: 2008-01-22 Daniel Franke <franke.daniel@gmail.com> PR fortran/34915 * expr.c (check_elemental): Fix check for valid data types. gcc/testsuite: 2008-01-22 Daniel Franke <franke.daniel@gmail.com> PR fortran/34915 * gfortran.dg/initialization_18.f90: New test. From-SVN: r131715
2008-01-08re PR fortran/34476 (Parameters: Bogus out of bounds error in array constructor)Paul Thomas1-7/+11
2008-01-08 Paul Thomas <pault@gcc.gnu.org> PR fortran/34476 * expr.c (find_array_element): Check that the array bounds are constant before using them. Use lower, as well as upper bound. (check_restricted): Allow implied index variable. 2008-01-08 Paul Thomas <pault@gcc.gnu.org> PR fortran/34476 * gfortran.dg/parameter_array_init_3.f90: New test. From-SVN: r131396
2007-12-20re PR fortran/34482 (FAIL: gfortran.dg/nan_4.f90 -O tests for errors)Tobias Burnus1-1/+2
2007-12-20 Tobias Burnus <burnus@net-b.de> PR fortran/34482 * gfortran.texi (BOZ): Document behavior for complex numbers. * target-memory.h (gfc_convert_boz): Update prototype. * target-memory.c (gfc_convert_boz): Add error check and convert BOZ to smallest possible bit size. * resolve.c (resolve_ordinary_assign): Check return value. * expr.c (gfc_check_assign): Ditto. * simplify.c (simplify_cmplx, gfc_simplify_dble, gfc_simplify_float, gfc_simplify_real): Ditto. 2007-12-20 Tobias Burnus <burnus@net-b.de> PR fortran/34482 * gfortran.dg/boz_8.f90: Add error-check check. * gfortran.dg/boz_9.f90: Shorten BOZ where needed, replace stop by call abort. From-SVN: r131098
2007-12-18re PR fortran/34495 (accepts invalid initialization expressions withTRANSFER)Daniel Franke1-1/+18
gcc/fortran: 2007-12-19 Daniel Franke <franke.daniel@gmail.com> PR fortran/34495 * expr.c (check_init_expr): Check whether variables with flavor FL_PARAMETER do have a value assigned. Added error messages where appropriate. * simplify.c (gfc_simplify_transfer): Added check if the MOLD argument is a constant if working with initialization expressions. gcc/testsuite: 2007-12-19 Daniel Franke <franke.daniel@gmail.com> PR fortran/34495 * gfortran.dg/transfer_simplify_2.f90: Fixed invalid initialization expressions. * gfortran.dg/transfer_simplify_7.f90: New test. From-SVN: r131047
2007-12-14re PR fortran/34398 (BOZ literals: Range checks)Tobias Burnus1-0/+17
2007-12-14 Tobias Burnus <burnus@net-b.de> PR fortran/34398 * expr.c (gfc_check_assign): Add range checks for assignments of * BOZs. * resolve.c (resolve_ordinary_assign): Ditto. * arith.c (gfc_range_check): Fix return value for complex * numbers. 2007-12-14 Tobias Burnus <burnus@net-b.de> PR fortran/34398 * gfortran.dg/nan_4.f90: New. From-SVN: r130932
2007-12-09re PR fortran/32129 (ICE: Procedure call with array-section-actual to scalar ↵Paul Thomas1-2/+17
dummy) 2007-12-09 Paul Thomas <pault@gcc.gnu.org> PR fortran/32129 * dump-parse-tree.c (gfc_show_expr_n): New function for debugging. * gfortran.h : Add prototype for gfc_show_expr_n. * expr.c (simplify_constructor): Copy the constructor expression and try to simplify that. If success, replace the original. Otherwise discard the copy, keep going through the structure and return success. PR fortran/31487 * decl.c (build_struct): Pad out default initializers with spaces to the component character length. 2007-12-09 Paul Thomas <pault@gcc.gnu.org> PR fortran/32129 * gfortran.dg/derived_comp_array_ref_6.f90: New test. * gfortran.dg/derived_comp_array_ref_7.f90: New test. PR fortran/31487 * gfortran.dg/char_component_initializer_1.f90: New test. From-SVN: r130719
2007-12-08re PR fortran/34342 (BOZ extensions not diagnosed as such with -std=f95)Tobias Burnus1-0/+24
2007-12-08 Tobias Burnus <burnus@net-b.de> PR fortran/34342 PR fortran/34345 PR fortran/18026 PR fortran/29471 * gfortran.texi (BOZ literal constants): Improve documentation and adapt for BOZ changes. * Make-lang.ini (resolve.o): Add target-memory.h dependency. * gfortran.h (gfc_expr): Add is_boz flag. * expr.c: Include target-memory.h. (gfc_check_assign): Support transferring BOZ for real/cmlx. * resolve.c: Include target-memory.h (resolve_ordinary_assign): Support transferring BOZ for real/cmlx. * target-memory.c (gfc_convert_boz): New function. * target-memory.c (gfc_convert_boz): Add prototype. * primary.c (match_boz_constant): Set is_boz, enable F95 error also without -pedantic, and allow for Fortran 2003 BOZ. (match_real_constant): Fix comment. * simplify.c * (simplify_cmplx,gfc_simplify_dble,gfc_simplify_float, gfc_simplify_real): Support Fortran 2003 BOZ. 2007-12-08 Tobias Burnus <burnus@net-b.de> PR fortran/34342 PR fortran/34345 PR fortran/18026 PR fortran/29471 * gfortran.dg/boz_8.f90: New. * gfortran.dg/boz_9.f90: New. * gfortran.dg/boz_10.f90: New. * gfortran.dg/boz_7.f90: Update dg-warning. * gfortran.dg/pr16433.f: Add dg-error. * gfortan.dg/ibits.f90: Update dg-warning. * gfortran.dg/unf_io_convert_1.f90: Update/delete dg-warning. * gfortran.dg/unf_io_convert_2.f90: Ditto. From-SVN: r130713
2007-11-27re PR fortran/29389 (Statement functions are not recognized as pure when ↵Paul Thomas1-9/+49
they are) 2007-11-27 Paul Thomas <pault@gcc.gnu.org> PR fortran/29389 *resolve.c (resolve_ordinary_assign): Use find_sym_in_expr to test if a temporary should be written for a vector subscript on the lhs. PR fortran/33850 * restore.c (pure_stmt_function): Add prototype and new function. Calls impure_stmt_fcn. (pure_function): Call it. (impure_stmt_fcn): New function. * expr.c (gfc_traverse_expr): Call *func for all expression types, not just variables. Add traversal of character lengths, iterators and component character lengths and arrayspecs. (expr_set_symbols_referenced): Return false if not a variable. * trans-stmt.c (forall_replace, forall_restore): Ditto. * resolve.c (forall_index): Ditto. (sym_in_expr): New function. (find_sym_in_expr): Rewrite to traverse expression calling sym_in_expr. *trans-decl.c (expr_decls): New function. (generate_expr_decls): Rewrite to traverse expression calling expr_decls. *match.c (check_stmt_fcn): New function. (recursive_stmt_fcn): Rewrite to traverse expression calling check_stmt_fcn. 2007-11-27 Paul Thomas <pault@gcc.gnu.org> PR fortran/29389 * gfortran.dg/stfunc_6.f90: New test. PR fortran/33850 * gfortran.dg/assign_10.f90: New test. From-SVN: r130472
2007-11-16re PR fortran/33957 (gfortran rejects valid initialization expression)Francois-Xavier Coudert1-5/+1
PR fortran/33957 * gfortran.dg/initialization_15.f90 : New test. * expr.c (check_inquiry): Don't call gfc_error now. From-SVN: r130246
2007-10-29[multiple changes]Paul Thomas1-30/+68
2007-10-29 Paul Thomas <pault@gcc.gnu.org> PR fortran/31217 PR fortran/33811 PR fortran/33686 * trans-array.c (gfc_conv_loop_setup): Send a complete type to gfc_trans_create_temp_array if the temporary is character. * trans-stmt.c (gfc_trans_assign_need_temp): Do likewise for allocate_temp_for_forall_nest. (forall_replace): New function. (forall_replace_symtree): New function. (forall_restore): New function. (forall_restore_symtree): New function. (forall_make_variable_temp): New function. (check_forall_dependencies): New function. (cleanup_forall_symtrees): New function. gfc_trans_forall_1): Add and initialize pre and post blocks. Call check_forall_dependencies to check for all dependencies and either trigger second forall block to copy temporary or copy lval, outside the forall construct and replace all dependent references. After assignment clean-up and coalesce the blocks at the end of the function. * gfortran.h : Add prototypes for gfc_traverse_expr and find_forall_index. expr.c (gfc_traverse_expr): New function to traverse expression and visit all subexpressions, under control of a logical flag, a symbol and an integer pointer. The slave function is caller defined and is only called on EXPR_VARIABLE. (expr_set_symbols_referenced): Called by above to set symbols referenced. (gfc_expr_set_symbols_referenced): Rework of this function to use two new functions above. * resolve.c (find_forall_index): Rework with gfc_traverse_expr, using forall_index. (forall_index): New function used by previous. * dependency.c (gfc_check_dependency): Use gfc_dep_resolver for all references, not just REF_ARRAY. (gfc_dep_resolver): Correct the logic for substrings so that overlapping arrays are handled correctly. 2007-10-29 Paul Thomas <pault@gcc.gnu.org> PR fortran/31217 PR fortran/33811 * gfortran.dg/forall_12.f90: New test. PR fortran/33686 * gfortran.dg/forall_13.f90: New test. From-SVN: r129720
2007-10-17re PR fortran/33760 (Bind(C): Using C_PTR as structure constructor gives an ICE)Christopher D. Rickett1-1/+4
2007-10-17 Christopher D. Rickett <crickett@lanl.gov> PR fortran/33760 * symbol.c (gen_special_c_interop_ptr): Remove code to create constructor for c_null_ptr and c_null_funptr with value of 0. * expr.c (check_init_expr): Prevent check on constructors for iso_c_binding derived types. * resolve.c (resolve_structure_cons): Verify that the user isn't trying to invoke a structure constructor for one of the iso_c_binding derived types. 2007-10-17 Christopher D. Rickett <crickett@lanl.gov> PR fortran/33760 * gfortran.dg/c_ptr_tests_13.f03: New test case. From-SVN: r129402
2007-10-12re PR fortran/33664 (crash on invalid program)Paul Thomas1-0/+12
2007-10-12 Paul Thomas <pault@gcc.gnu.org> PR fortran/33664 * expr.c (gfc_specification_expr): If a function is not external, intrinsic or pure is an error. Set the symbol pure to prevent repeat errors. 2007-10-12 Paul Thomas <pault@gcc.gnu.org> PR fortran/33664 * gfortran.dg/impure_spec_expr_1.f90: New test. * gfortran.dg/char_result_7.f90: Remove illegal test. From-SVN: r129267
2007-10-10re PR fortran/33636 (Rejects valid use of vector subscript in derived type ↵Francois-Xavier Coudert1-1/+1
parameter) PR fortran/33636 * expr.c (find_array_section): Check for constructor constantness. From-SVN: r129208
2007-10-07re PR fortran/20851 (dummy argument may not appear in specification ↵Tobias Schlüter1-4/+17
expression in elemental procedure) PR fortran/20851 fortran/ * expr.c (check_inquiry): Typo fix in error message. (check_init_expr): Same * 3. (check_restricted): Verify that no dummy arguments appear in restricted expressions in ELEMENTAL procedures. * resolve.c (resolve_fl_variable): Exchange order of checks to avoid side-effect. testsuite/ * initialization_1.f90: Fix dg-error annotations. * initialization_14.f90: New. * initialization_7.f90: Fix dg-error annotations. * initialization_9.f90: Likewise. From-SVN: r129069
2007-09-27arith.c (reduce_binary_aa): Fix capitalization.Tobias Schlüter1-10/+8
fortran/ * arith.c (reduce_binary_aa): Fix capitalization. * check.c (gfc_check_dot_product): Likewise. (gfc_check_matmul): Likewise. * expr.c (gfc_check_conformance): Likewise. (gfc_check_assign): Likewise. (gfc_default_initializer): Simplify logic. * trans.c (gfc_msg_bounds): Make const. (gfc_msg_fault): Likewise. (gfc_msg_wrong_return): Likewise. * trans.h: Add const to corresponding extern declarations. testsuite/ * gfortran.dg/array_initializer_3.f90: Adapt error annotations for fixed capitalizations. * gfortran.dg/compliant_elemental_intrinsics_1.f90: Likewise. * gfortran.dg/compliant_elemental_intrinsics_2.f90: Likewise. * gfortran.dg/elemental_subroutine_4.f90: Likewise. * gfortran.dg/intrinsic_argument_conformance_1.f90: Likewise. * gfortran.dg/maxloc_shape_1.f90: Likewise. * gfortran.dg/maxval_maxloc_conformance_1.f90: Likewise. * gfortran.dg/min_max_conformance.f90: Likewise. From-SVN: r128849
2007-09-16re PR fortran/29396 (segfault with character pointer association)Paul Thomas1-0/+32
2007-09-16 Paul Thomas <pault@gcc.gnu.org> PR fortran/29396 PR fortran/29606 PR fortran/30625 PR fortran/30871 * trans.h : Add extra argument to gfc_build_array_ref. Rename gfc_conv_aliased_arg to gfc_conv_subref_array_arg. Move prototype of is_aliased_array to gfortran.h and rename it gfc_is_subref_array. Add field span to lang_decl, add a new decl lang specific flag accessed by GFC_DECL_SUBREF_ARRAY_P and a new type flag GFC_DECL_SUBREF_ARRAY_P. * trans.c (gfc_build_array_ref): Add the new argument, decl. If this is a subreference array pointer, use the lang_decl field 'span' to calculate the offset in bytes and use pointer arithmetic to address the element. * trans-array.c (gfc_conv_scalarized_array_ref, gfc_conv_array_ref): Add the backend declaration as the third field, if it is likely to be a subreference array pointer. (gfc_conv_descriptor_dimension, gfc_trans_array_ctor_element, gfc_trans_array_constructor_element, structure_alloc_comps, gfc_conv_array_index_offset): For all other references to gfc_build_array_ref, set the third argument to NULL. (gfc_get_dataptr_offset): New function. (gfc_conv_expr_descriptor): If the rhs of a pointer assignment is a subreference array, then calculate the offset to the subreference of the first element and set the descriptor data pointer to this, using gfc_get_dataptr_offset. trans-expr.c (gfc_get_expr_charlen): Use the expression for the character length for a character subreference. (gfc_conv_substring, gfc_conv_subref_array_arg): Add NULL for third argument in call to gfc_build_array_ref. (gfc_conv_aliased_arg): Rename to gfc_conv_subref_array_arg. (is_aliased_array): Remove. (gfc_conv_function_call): Change reference to is_aliased_array to gfc_is_subref_array and reference to gfc_conv_aliased_arg to gfc_conv_subref_array_arg. (gfc_trans_pointer_assignment): Add the array element length to the lang_decl 'span' field. * gfortran.h : Add subref_array_pointer to symbol_attribute and add the prototype for gfc_is_subref_array. * trans-stmt.c : Add NULL for third argument in all references to gfc_build_array_ref. * expr.c (gfc_is_subref_array): Renamed is_aliased_array. If this is a subreference array pointer, return true. (gfc_check_pointer_assign): If the rhs is a subreference array, set the lhs subreference_array_pointer attribute. * trans-decl.c (gfc_get_symbol_decl): Allocate the lang_decl field if the symbol is a subreference array pointer and set an initial value of zero for the 'span' field. * trans-io.c (set_internal_unit): Refer to is_subref_array and gfc_conv_subref_array_arg. (nml_get_addr_expr): Add NULL third argument to gfc_build_array_ref. (gfc_trans_transfer): Use the scalarizer for a subreference array. 2007-09-16 Paul Thomas <pault@gcc.gnu.org> PR fortran/29396 PR fortran/29606 PR fortran/30625 PR fortran/30871 * gfortran.dg/subref_array_pointer_1.f90: New test. * gfortran.dg/subref_array_pointer_2.f90: New test. From-SVN: r128523
2007-09-13re PR fortran/33343 (ICE (segfault) on invalid code with wrongly shaped ↵Tobias Burnus1-3/+3
arguments to elemental procedures) 2007-09-13 Tobias Burnus <burnus@net-b.de> PR fortran/33343 * expr.c (gfc_check_conformance): Print ranks in the error message. * resolve.c (resolve_elemental_actual): Check also conformance of the actual arguments for elemental functions. 2007-09-13 Tobias Burnus <burnus@net-b.de> PR fortran/33343 * gfortran.dg/elemental_args_check_1.f90: New. * gfortran.dg/assumed_size_refs_1.f90: Update error message. * gfortran.dg/elemental_subroutine_4.f90: Ditto. From-SVN: r128473
2007-09-02dump-parse-tree.c (show_char_const): New function.Tobias Schlüter1-4/+8
fortran/ * dump-parse-tree.c (show_char_const): New function. (gfc_show_expr): Use it. * expr.c (find_substring_ref): Rework to not keep characters dangling beyond end of string. testsuite/ * gfortran.dg/substr_6.f90: New test. From-SVN: r128027
2007-08-18re PR fortran/32881 (PURE attribute escapes from contained procedure)Paul Thomas1-1/+2
2007-08-18 Paul Thomas <pault@gcc.gnu.org> PR fortran/32881 * expr.c (gfc_check_pointer_assign): If the rhs is the initialization expression for the rhs, there is no error. 2007-08-18 Paul Thomas <pault@gcc.gnu.org> PR fortran/32881 * gfortran.dg/pure_initializer_1.f90: New test. From-SVN: r127611
2007-08-14re PR fortran/32594 (substring simplification leads to ICE)Francois-Xavier Coudert1-5/+15
PR fortran/32594 * trans-expr.c (gfc_conv_substring_expr): Only call gfc_conv_substring if expr->ref is not NULL. * expr.c (gfc_is_constant_expr): If e->ref is NULL, the substring expression might be a constant. (gfc_simplify_expr): Handle missing start and end, as well as missing ref. * gfortran.dg/substr_5.f90: New test. From-SVN: r127478
2007-08-01arith.c: Change copyright header to refer to version 3 of the GNU General ↵Nick Clifton1-4/+3
Public... * arith.c: Change copyright header to refer to version 3 of the GNU General Public License and to point readers at the COPYING3 file and the FSF's license web page. * openmp.c, interface.c, intrinsic.c, trans-array.c, trans-expr.c, symbol.c, iso-fortran-env.def, intrinsic.h, decl.c, trans-array.h, matchexp.c, dump-parse-tree.c, trans-common.c, array.c, Make-lang.in, trans-openmp.c, gfortran.h, error.c, iso-c-binding.def, lang.opt, data.c, trans-const.c, trans-stmt.c, expr.c, trans-const.h, trans-stmt.h, module.c, trans.c, scanner.c, trans-types.c, trans.h, gfortranspec.c, trans-types.h, lang-specs.h, io.c, bbt.c, resolve.c, f95-lang.c, st.c, iresolve.c, match.c, trans-decl.c, trans-io.c, target-memory.c, match.h, target-memory.h, parse.c, arith.h, check.c, dependency.c, parse.h, types.def, convert.c, dependency.h, primary.c, trans-intrinsic.c, options.c, misc.c, simplify.c: Likewise. From-SVN: r127129
2007-08-01re PR fortran/32945 (ICE with initialization expressions)Daniel Franke1-0/+4
gcc/fortran: 2007-08-01 Daniel Franke <franke.daniel@gmail.com> PR fortran/32945 * expr.c (check_specification_function): Skip check if no symtree is available. gcc/testsuite: 2007-08-01 Daniel Franke <franke.daniel@gmail.com> PR fortran/32945 * gfortran.dg/initialization_12.f90: New test. From-SVN: r127124
2007-07-24re PR fortran/32867 (ICE on nested initialization expressions)Daniel Franke1-1/+1
gcc/fortran: 2007-07-24 Daniel Franke <franke.daniel@gmail.com> PR fortran/32867 * expr.c (check_init_expr): Simplify matched functions. gcc/testsuite: 2007-07-24 Daniel Franke <franke.daniel@gmail.com> PR fortran/32867 * fortran.dg/initialization_10.f90: New test. From-SVN: r126882
2007-07-23re PR fortran/25104 ([F2003] Non-initialization expr. as case-selector)Daniel Franke1-6/+17
gcc/fortran: 2007-07-23 Daniel Franke <franke.daniel@gmail.com> PR fortran/25104 PR fortran/31639 * expr.c (check_transformational): Reject valid transformational intrinsics to avoid ICE. (check_inquiry): Report error for assumed character lengths for all supported standards. (check_init_expr): Whitespace fix. gcc/testsuite: 2007-07-23 Daniel Franke <franke.daniel@gmail.com> PR fortran/31639 * gfortran.dg/initialization_9.f90: New test. From-SVN: r126858
2007-07-22re PR fortran/29962 (Initialization expressions)Daniel Franke1-73/+246
gcc/fortran: 2007-07-22 Daniel Franke <franke.daniel@gmail.com> PR fortran/29962 PR fortran/31253 PR fortran/31265 PR fortran/31639 * gfortran.h (gfc_intrinsic_sym): Changed members elemental, pure, generic, specific, actual_ok, noreturn into bits of a bitfield, added bits for inquiry, transformational, conversion. * check.c (non_init_transformational): Removed, removed all callers. * intrinsic.c (enum class): New. (add_sym*): Replaced argument elemetal by enum class. Changed all callers. (add_functions): Assign appropriate classes to intrinsic functions. (add_subroutines): Assign appropriate classes to intrinsic subroutines. (add_conv): Set conversion attribute. (gfc_init_expr_extensions): Removed, removed all callers. (gfc_intrinsic_func_interface): Reimplemented check for non-standard initializatione expressions. * expr.c (check_specification_function): New. (gfc_is_constant_expr): Added check for specification functions. (check_init_expr_arguments): New. (check_inquiry): Changed return value to MATCH, added checks for inquiry functions defined by F2003. (check_transformational): New. (check_null): New. (check_elemental): New. (check_conversion): New. (check_init_expr): Call new check functions, add more specific error messages. gcc/testsuite: 2007-07-22 Daniel Franke <franke.daniel@gmail.com> PR fortran/29962 * gfortran.dg/array_initializer_1.f90: Removed warning. * gfortran.dg/initialization_1.f90: Adjusted messages. * gfortran.dg/nested_modules_6.f90: Removed warning. PR fortran/31253 * gfortran.dg/initialization_7.f90: New test. PR fortran/31639 * gfortran.dg/initialization_8.f90: New test. From-SVN: r126826
2007-07-08re PR fortran/17711 (Wrong operator name in error message)Daniel Franke1-7/+21
gcc/fortran: 2007-07-08 Daniel Franke <franke.daniel@gmail.com> Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de> PR fortran/17711 * gfortran.h (gfc_intrinsic_op): Added INTRINSIC_EQ_OS, INTRINSIC_NE_OS, INTRINSIC_GT_OS, INTRINSIC_GE_OS, INTRINSIC_LT_OS and INTRINSIC_LE_OS. * arith.c (eval_intrinsic, eval_type_intrinsic0): Likewise. * arith.h (gfc_eq, gfc_ne, gfc_gt, gfc_ge, gfc_lt, gfc_le): Added gfc_intrinsic_op as third argument type. * dump-parse-tree.c (gfc_show_expr): Account for new enum values. * expr.c (simplify_intrinsic_op, check_intrinsic_op): Likewise. * interface.c (check_operator_interface): Likewise. (gfc_check_interfaces): Added cross-checks for FORTRAN 77 and Fortran 90 style operators using new enum values. (gfc_extend_expr): Likewise. (gfc_add_interface): Likewise. * match.c (intrinsic_operators): Distinguish FORTRAN 77 style operators from Fortran 90 style operators using new enum values. * matchexp.c (match_level_4): Account for new enum values. * module.c (mio_expr): Likewise. * resolve.c (resolve_operator): Deal with new enum values, fix inconsistent error messages. * trans-expr.c (gfc_conv_expr_op): Account for new enum values. gcc/testsuite: 2007-07-08 Daniel Franke <franke.daniel@gmail.com> PR fortran/17711 * gfortran.dg/operator_4.f90: New test. * gfortran.dg/operator_5.f90: New test. * gfortran.dg/logical_comp.f90: Adjusted error messages. * gfortran.dg/module_md5_1.f90: Adjusted MD5 sum. Co-Authored-By: Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de> From-SVN: r126468
2007-07-02[multiple changes]Christopher D. Rickett1-3/+16
2007-07-01 Christopher D. Rickett <crickett@lanl.gov> * interface.c (gfc_compare_derived_types): Special case for comparing derived types across namespaces. (gfc_compare_types): Deal with BT_VOID. (compare_parameter): Use BT_VOID to accept ISO C Binding pointers. * trans-expr.c (gfc_conv_function_call): Remove setting parm_kind to SCALAR (gfc_conv_initializer): Deal with ISO C Binding NULL_PTR and NULL_FUNPTR. (gfc_conv_expr): Convert expressions for ISO C Binding derived types. * symbol.c (gfc_set_default_type): BIND(C) variables should not be implicitly declared. (check_conflict): Add BIND(C) and check for conflicts. (gfc_add_explicit_interface): Whitespace. (gfc_add_is_bind_c): New function. (gfc_copy_attr): Use it. (gfc_new_symbol): Initialize ISO C Binding objects. (get_iso_c_binding_dt): New function. (verify_bind_c_derived_type): Ditto. (gen_special_c_interop_ptr): Ditto. (add_formal_arg): Ditto. (gen_cptr_param): Ditto. (gen_fptr_param): Ditto. (gen_shape_param): Ditto. (add_proc_interface): Ditto. (build_formal_args): Ditto. (generate_isocbinding_symbol): Ditto. (get_iso_c_sym): Ditto. * decl.c (num_idents_on_line, has_name_equals): New variables. (verify_c_interop_param): New function. (build_sym): Finish binding labels and deal with COMMON blocks. (add_init_expr_to_sym): Check if the initialized expression is an iso_c_binding named constants (variable_decl): Set ISO C Binding type_spec components. (gfc_match_kind_spec): Check match for C interoperable kind. (match_char_spec): Fix comment. Chnage gfc_match_small_int to gfc_match_small_int_expr. Check for C interoperable kind. (match_type_spec): Clear the current binding label. (match_attr_spec): Add DECL_IS_BIND_C. If BIND(C) is found, use it to set attributes. (set_binding_label): New function. (set_com_block_bind_c): Ditto. (verify_c_interop): Ditto. (verify_com_block_vars_c_interop): Ditto. (verify_bind_c_sym): Ditto. (set_verify_bind_c_sym): Ditto. (set_verify_bind_c_com_block): Ditto. (get_bind_c_idents): Ditto. (gfc_match_bind_c_stmt): Ditto. (gfc_match_data_decl): Use num_idents_on_line. (match_result): Deal with right paren in BIND(C). (gfc_match_suffix): New function. (gfc_match_function_decl): Use it. Code is re-arranged to deal with ISO C Binding result clauses. (gfc_match_subroutine): Deal with BIND(C). (gfc_match_bind_c): New function. (gfc_get_type_attr_spec): New function. Code is re-arranged in and taken from gfc_match_derived_decl. (gfc_match_derived_decl): Add check for BIND(C). * trans-common.c: Forward declare gfc_get_common. (gfc_sym_mangled_common_id): Change arg from 'const char *name' to 'gfc_common_head *com'. Check for ISO C Binding of the common block. (build_common_decl): 'com->name' to 'com in SET_DECL_ASSEMBLER_NAME. * gfortran.h: Add GFC_MAX_BINDING_LABEL_LEN (bt): Add BT_VOID (sym_flavor): Add FL_VOID. (iso_fortran_env_symbol, iso_c_binding_symbol, intmod_id): New enum (CInteropKind_t): New struct. (c_interop_kinds_table): Use it. Declare an array of structs. (symbol_attribute): Add is_bind_c, is_c_interop, and is_iso_c bitfields. (gfc_typespec): Add is_c_interop; is_iso_c, and f90_type members. (gfc_symbol): Add from_intmod, intmod_sym_id, binding_label, and common_block members. (gfc_common_head): Add binding_label and is_bind_c members. (gfc_gsymbol): Add sym_name, mod_name, and binding_label members. Add prototypes for get_c_kind, gfc_validate_c_kind, gfc_check_any_c_kind, gfc_add_is_bind_c, gfc_add_value, verify_c_interop, verify_c_interop_param, verify_bind_c_sym, verify_bind_c_derived_type, verify_com_block_vars_c_interop, generate_isocbinding_symbol, get_iso_c_sym, gfc_iso_c_sub_interface * iso-c-binding.def: New file. This file contains the definitions of the types provided by the Fortran 2003 ISO_C_BINDING intrinsic module. * trans-const.c (gfc_conv_constant_to_tree): Deal with C_NULL_PTR or C_NULL_FUNPTR expressions. * expr.c (gfc_copy_expr): Add BT_VOID case. For BT_CHARACTER, the ISO C Binding requires a minimum string length of 1 for '\0'. * module.c (intmod_sym): New struct. (pointer_info): Add binding_label member. (write_atom): Set len to 0 for NULL pointers. Check for NULL p and *p. (ab_attribute): Add AB_IS_BIND_C, AB_IS_C_INTEROP and AB_IS_ISO_C. (attr_bits): Add "IS_BIND_C", "IS_C_INTEROP", and "IS_ISO_C". (mio_symbol_attribute): Deal with ISO C Binding attributes. (bt_types): Add "VOID". (mio_typespec): Deal with ISO C Binding components. (mio_namespace_ref): Add intmod variable. (mio_symbol): Check for symbols from an intrinsic module. (load_commons): Check for BIND(C) common block. (read_module): Read binding_label and use it. (write_common): Add label. Write BIND(C) info. (write_blank_common): Blank commons are not BIND(C). Explicitly set is_bind_c=0. (write_symbol): Deal with binding_label. (sort_iso_c_rename_list): New function. (import_iso_c_binding_module): Ditto. (create_int_parameter): Add to args. (use_iso_fortran_env_module): Adjust to deal with iso_c_binding intrinsic module. * trans-types.c (c_interop_kinds_table): new array of structs. (gfc_validate_c_kind): New function. (gfc_check_any_c_kind): Ditto. (get_real_kind_from_node): Ditto. (get_int_kind_from_node): Ditto. (get_int_kind_from_width): Ditto. (get_int_kind_from_minimal_width): Ditto. (init_c_interop_kinds): Ditto. (gfc_init_kinds): call init_c_interop_kinds. (gfc_typenode_for_spec): Adjust for BT_VOID and ISO C Binding pointers. Adjust handling of BT_DERIVED. (gfc_sym_type): Whitespace. (gfc_get_derived_type): Account for iso_c_binding derived types * resolve.c (is_scalar_expr_ptr): New function. (gfc_iso_c_func_interface): Ditto. (resolve_function): Use gfc_iso_c_func_interface. (set_name_and_label): New function. (gfc_iso_c_sub_interface): Ditto. (resolve_specific_s0): Use gfc_iso_c_sub_interface. (resolve_bind_c_comms): New function. (resolve_bind_c_derived_types): Ditto. (gfc_verify_binding_labels): Ditto. (resolve_fl_procedure): Check for ISO C interoperability. (resolve_symbol): Check C interoperability. (resolve_types): Walk the namespace. Check COMMON blocks. * trans-decl.c (gfc_sym_mangled_identifier): Prevent the mangling of identifiers that have an assigned binding label. (gfc_sym_mangled_function_id): Use the binding label rather than the mangled name. (gfc_finish_var_decl): Put variables that are BIND(C) into a common segment of the object file, because this is what C would do. (gfc_create_module_variable): Conver to proper types (set_tree_decl_type_code): New function. (generate_local_decl): Check dummy variables and derived types for ISO C Binding attributes. * match.c (gfc_match_small_int_expr): New function. (gfc_match_name_C): Ditto. (match_common_name): Deal with ISO C Binding in COMMON blocks * trans-io.c (transfer_expr): Deal with C_NULL_PTR or C_NULL_FUNPTR expressions * match.h: Add prototypes for gfc_match_small_int_expr, gfc_match_name_C, match_common_name, set_com_block_bind_c, set_binding_label, set_verify_bind_c_sym, set_verify_bind_c_com_block, get_bind_c_idents, gfc_match_bind_c_stmt, gfc_match_suffix, gfc_match_bind_c, gfc_get_type_attr_spec * parse.c (decode_statement): Use gfc_match_bind_c_stmt (parse_derived): Init *derived_sym = NULL, and gfc_current_block later for valiadation. * primary.c (got_delim): Set ISO C Binding components of ts. (match_logical_constant): Ditto. (match_complex_constant): Ditto. (match_complex_constant): Ditto. (gfc_match_rvalue): Check for existence of at least one arg for C_LOC, C_FUNLOC, and C_ASSOCIATED. * misc.c (gfc_clear_ts): Clear ISO C Bindoing components in ts. (get_c_kind): New function. 2007-07-01 Christopher D. Rickett <crickett@lanl.gov> * Makefile.in: Add support for iso_c_generated_procs.c and iso_c_binding.c. * Makefile.am: Ditto. * intrinsics/iso_c_generated_procs.c: New file containing helper functions. * intrinsics/iso_c_binding.c: Ditto. * intrinsics/iso_c_binding.h: New file * gfortran.map: Include the __iso_c_binding_c_* functions. * libgfortran.h: define GFC_NUM_RANK_BITS. 2007-06-23 Christopher D. Rickett <crickett@lanl.gov> * bind_c_array_params.f03: New files for Fortran 2003 ISO C Binding. * bind_c_coms.f90: Ditto. * bind_c_coms_driver.c: Ditto. * bind_c_dts.f90: Ditto. * bind_c_dts_2.f03: Ditto. * bind_c_dts_2_driver.c: Ditto. * bind_c_dts_3.f03: Ditto. * bind_c_dts_4.f03: Ditto. * bind_c_dts_driver.c: Ditto. * bind_c_implicit_vars.f03: Ditto. * bind_c_procs.f03: Ditto. * bind_c_usage_2.f03: Ditto. * bind_c_usage_3.f03: Ditto. * bind_c_usage_5.f03: Ditto. * bind_c_usage_6.f03: Ditto. * bind_c_usage_7.f03: Ditto. * bind_c_vars.f90: Ditto. * bind_c_vars_driver.c: Ditto. * binding_c_table_15_1.f03: Ditto. * binding_label_tests.f03: Ditto. * binding_label_tests_10.f03: Ditto. * binding_label_tests_10_main.f03: Ditto. * binding_label_tests_11.f03: Ditto. * binding_label_tests_11_main.f03: Ditto. * binding_label_tests_12.f03: Ditto. * binding_label_tests_13.f03: Ditto. * binding_label_tests_13_main.f03: Ditto. * binding_label_tests_14.f03: Ditto. * binding_label_tests_2.f03: Ditto. * binding_label_tests_3.f03: Ditto. * binding_label_tests_4.f03: Ditto. * binding_label_tests_5.f03: Ditto. * binding_label_tests_6.f03: Ditto. * binding_label_tests_7.f03: Ditto. * binding_label_tests_8.f03: Ditto. * binding_label_tests_9.f03: Ditto. * c_assoc.f90: Ditto. * c_assoc_2.f03: Ditto. * c_f_pointer_shape_test.f90: Ditto. * c_f_pointer_tests.f90: Ditto. * c_f_tests_driver.c: Ditto. * c_funloc_tests.f03: Ditto. * c_funloc_tests_2.f03: Ditto. * c_funloc_tests_3.f03: Ditto. * c_funloc_tests_3_funcs.c: Ditto. * c_kind_params.f90: Ditto. * c_kind_tests_2.f03: Ditto. * c_kinds.c: Ditto. * c_loc_driver.c: Ditto. * c_loc_test.f90: Ditto. * c_loc_tests_2.f03: Ditto. * c_loc_tests_2_funcs.c: Ditto. * c_loc_tests_3.f03: Ditto. * c_loc_tests_4.f03: Ditto. * c_loc_tests_5.f03: Ditto. * c_loc_tests_6.f03: Ditto. * c_loc_tests_7.f03: Ditto. * c_loc_tests_8.f03: Ditto. * c_ptr_tests.f03: Ditto. * c_ptr_tests_10.f03: Ditto. * c_ptr_tests_5.f03: Ditto. * c_ptr_tests_7.f03: Ditto. * c_ptr_tests_7_driver.c: Ditto. * c_ptr_tests_8.f03: Ditto. * c_ptr_tests_8_funcs.c: Ditto. * c_ptr_tests_9.f03: Ditto. * c_ptr_tests_driver.c: Ditto. * c_size_t_driver.c: Ditto. * c_size_t_test.f03: Ditto. * com_block_driver.f90: Ditto. * global_vars_c_init.f90: Ditto. * global_vars_c_init_driver.c: Ditto. * global_vars_f90_init.f90: Ditto. * global_vars_f90_init_driver.c: Ditto. * interop_params.f03: Ditto. * iso_c_binding_only.f03: Ditto. * iso_c_binding_rename_1.f03: Ditto. * iso_c_binding_rename_1_driver.c: Ditto. * iso_c_binding_rename_2.f03: Ditto. * iso_c_binding_rename_2_driver.c: Ditto. * kind_tests_2.f03: Ditto. * kind_tests_3.f03: Ditto. * module_md5_1.f90: Ditto. * only_clause_main.c: Ditto. * print_c_kinds.f90: Ditto. * test_bind_c_parens.f03: Ditto. * test_c_assoc.c: Ditto. * test_com_block.f90: Ditto. * test_common_binding_labels.f03: Ditto. * test_common_binding_labels_2.f03: Ditto. * test_common_binding_labels_2_main.f03: Ditto. * test_common_binding_labels_3.f03: Ditto. * test_common_binding_labels_3_main.f03: Ditto. * test_only_clause.f90: Ditto. * use_iso_c_binding.f90: Ditto. * value_5.f90: Ditto. * value_test.f90: Ditto. * value_tests_f03.f90: Ditto. From-SVN: r126185
2007-06-22re PR fortran/32360 (GFORTRAN WON'T COMPILE 'DATA PTR1 /NULL ()/' WHEN PTR1 ↵Jerry DeLisle1-6/+12
HAS POINTER ATTRIBUTE) 2007-06-22 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/32360 * expr.c (gfc_check_assign): If the rvalue expression type is NULL_EXPR, check to see if the lvalue has attribute pointer and data. From-SVN: r125949