- 04 Jul, 2009 1 commit
-
-
janus authored
PR fortran/40593 * interface.c (compare_actual_formal): Take care of proc-pointer-valued functions as actual arguments. * trans-expr.c (gfc_conv_procedure_call): Ditto. * resolve.c (resolve_specific_f0): Use the correct ts. 2009-07-04 Janus Weil <janus@gcc.gnu.org> PR fortran/40593 * gfortran.dg/proc_ptr_result_6.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149227 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 29 Jun, 2009 2 commits
-
-
burnus authored
PR fortran/40580 * trans-expr.c (gfc_conv_procedure_call): Add -fcheck=pointer * check. * libgfortran.h: Add GFC_RTCHECK_POINTER. * invoke.texi (-fcheck): Document new pointer option. * options.c (gfc_handle_runtime_check_option): Handle pointer * option. * gfortran.texi (C Binding): Improve wording. * iso-c-binding.def: Remove obsolete comment. 2009-06-29 Tobias Burnus <burnus@net-b.de> PR fortran/40580 * pointer_check_1.f90: New test. * pointer_check_2.f90: New test. * pointer_check_3.f90: New test. * pointer_check_4.f90: New test. * pointer_check_5.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149063 138bc75d-0d04-0410-961f-82ee72b054a4
-
pault authored
PR fortran/40551 * dependency.h : Add second bool* argument to prototype of gfc_full_array_ref_p. * dependency.c (gfc_full_array_ref_p): If second argument is present, return true if last dimension of reference is an element or has unity stride. * trans-array.c : Add NULL second argument to references to gfc_full_array_ref_p. * trans-expr.c : The same, except for; (gfc_trans_arrayfunc_assign): Return fail if lhs reference is not a full array or a contiguous section. 2009-06-29 Paul Thomas <pault@gcc.gnu.org> PR fortran/40551 * gfortran.dg/func_assign_2.f90 : New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149062 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 19 Jun, 2009 3 commits
-
-
pault authored
PR fortran/40440 * trans-expr.c (gfc_conv_procedure_call): Do not deallocate allocatable components if the argument is a pointer. 2009-06-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/40440 * gfortran.dg/alloc_comp_result_2.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148731 138bc75d-0d04-0410-961f-82ee72b054a4
-
ghazi authored
* arith.c, dump-parse-tree.c, expr.c, module.c, resolve.c, simplify.c, target-memory.c, target-memory.h, trans-const.c, trans-expr.c: Convert to mpc_t throughout. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148711 138bc75d-0d04-0410-961f-82ee72b054a4
-
janus authored
PR fortran/40450 * trans-expr.c (gfc_conv_procedure_call): Only add an extra addr_expr to a procedure pointer actual argument, if it is not itself a dummy arg. 2009-06-19 Janus Weil <janus@gcc.gnu.org> PR fortran/40450 * gfortran.dg/proc_ptr_20.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148690 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 12 Jun, 2009 1 commit
-
-
aldyh authored
* java-gimplify.c (java_gimplify_block): New argument to build_empty_stmt. * expr.c (force_evaluation_order): Same. * typeck.c: Add location to build_decl or PUSH_FIELD calls. * class.c: Same. * decl.c: Same. * jcf-parse.c: Same. * constants.c: Same. * resource.c: Same. * except.c: Same. * builtins.c: Same. * expr.c: Same. * java-tree.h (PUSH_FIELD): Add location field. gcc/objc/ * objc-act.c (finish_var_decl): Pass location to finish_decl. (objc_get_parm_info): Same. (get_super_receiver): Same. * objc-act.c (objc_build_component_ref): Pass location to build_compound_ref. (build_module_initializer_routine): Pass location to c_end_compound_stmt. (objc_generate_static_init_call): Pass location to build_stmt. (build_typed_selector_reference): New location argument. (build_selector_reference): Same. (objc_substitute_decl): Pass location to build_array_ref. (next_sjlj_build_try_catch_finally): Pass location to build_stmt. (objc_begin_catch_clause): Same. (objc_finish_try_stmt): Same. (objc_finish_catch_clause): Pass location to c_end_compound_stmt. (objc_build_throw_stmt): New argument. (generate_shared_structures): Pass location to build_c_cast. (objc_build_message_expr): Use local location. (objc_finish_message_expr): Use input_location. (build_objc_method_call): New argument. (objc_build_selector_expr): Same. (get_super_receiver): Pass location to build_c_cast, build_modify_expr, build_compound_expr. * objc-act.c: Add location to all calls to start_struct, build_decl, finish_struct. gcc/ * tree-pretty-print.c (dump_generic_node): Dump column numbers. * gimple-pretty-print.c (dump_gimple_stmt): Same. * gimplify.c (gimplify_modify_expr): Set location for GIMPLE_ASSIGNs created. * c-parser.c (c_parser_binary_expression): Use current column while building binary operations. * common.opt (fshow-column): Enable by default. * tree-vrp.c (check_array_ref): Use warning_at. (check_array_bounds): Use location from call back if expr has no location. * tree.h: Add location argument to maybe_fold_*. * tree-ssa-ccp.c (ccp_fold): Pass location to maybe_fold_*. (maybe_fold_offset_to_array_ref): Add location argument and use it. (maybe_fold_offset_to_component_ref): Same. (maybe_fold_offset_to_reference): Same. (maybe_fold_offset_to_address): Same. (maybe_fold_stmt_indirect): Same. (maybe_fold_stmt_addition): Same. (fold_stmt_r): Pass location to maybe_fold_*. (fold_gimple_assign): Same. * c-tree.h: Add location argument to finish_decl, default_function_array_conversion, store_init_value. * c-decl.c (define_label): Use error_at. (c_make_fname_decl): Pass location to finish_decl. (finish_decl): New location argument. (build_compound_literal): Pass location to store_init_value. (grokdeclarator): Pass location to finish_decl. (grokfield): Same. * c-typeck.c (array_to_pointer_conversion): New location argument. (function_to_pointer_conversion): Same. (default_function_array_conversion): Same. (parser_build_unary_op): Pass location to overflow_warning. (parser_build_binary_op): Same. Use warning_at. (build_unary_op): Pass location to array_to_pointer_conversion. (build_c_cast): Pass location to digest_init. (build_modify_expr): New location argument. (convert_for_assignment): Same. (store_init_value): Same. (digest_init): Same. (output_init_element): Pass location to digest_init and array_to_pointer_conversion. (c_finish_return): Pass location to convert_for_assignment. * gimplify.c (gimplify_conversion): Pass location to maybe_fold_offset_to_address. * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Pass location to maybe_fold_stmt_addition. * c-omp.c (c_finish_omp_atomic): Pass new location to build_modify_expr. (c_finish_omp_for): Same. * c-common.c (overflow_warning): New argument. * c-common.h: New argument to build_modify_expr, overflow_warning. * c-parser.c (c_parser_declaration_or_fndef): Pass location to finish_decl. (c_parser_initializer): Pass location to default_function_array_conversion. (c_parser_initelt): Same. (c_parser_initval): Same. (c_parser_asm_operands): Same. (c_parser_expr_no_commas): Same. Pass location to build_modify_expr. (c_parser_conditional_expression): Same. (c_parser_binary_expression): Add location info to stack. Use it. (c_parser_unary_expression): Pass location to default_function_array_conversion, parser_build_unary_op, build_indirect_ref, c_parser_postfix_expression_after_primary. (c_parser_postfix_expression_after_primary): New location argument. Use it. (c_parser_expression_conv): Pass location to default_function_array_conversion. (c_parser_expr_list): Same. (c_parser_omp_atomic): Same. (c_parser_omp_for_loop): Same. * c-tree.h: (struct c_declarator): Add comment to id_loc. (build_array_declarator): New argument. * c-decl.c (build_array_declarator): Add location argument. (grokdeclarator): Set id_loc for cdk_array. * c-parser.c (c_parser_direct_declarator_inner): Pass location to build_array_declarator. * tree.c (build_omp_clause): Add location argument. * tree.h (OMP_CLAUSE_HAS_LOCATION): New macro. (OMP_CLAUSE_LOCATION): New macro. (struct tree_omp_clause): Add location field. (build_omp_clause): Add argument. * testsuite/gcc.dg/gomp/for-1.c: Fix column. * cp/pt.c (tsubst_omp_for_iterator): Pass location to build_omp_clause. * cp/parser.c (cp_parser_omp_var_list_no_open): Same. (cp_parser_omp_clause_collapse): Same. (cp_parser_omp_clause_default): Same. (cp_parser_omp_clause_if): Same. (cp_parser_omp_clause_nowait): Same. (cp_parser_omp_clause_num_threads): Same. (cp_parser_omp_clause_ordered): Same. (cp_parser_omp_clause_schedule): Same. (cp_parser_omp_clause_untied): Same. (cp_parser_omp_for_loop): Same. (cp_parser_omp_parallel): Pass location to c_split_parallel_clauses. * c-tree.h (c_start_case): Add location argument. (c_process_expr_stmt): Same. (c_finish_goto_*): Same. * tree-parloops.c (initialize_reductions): Pass location to build_omp_clause. (create_parallel_loop): Same. * fortran/trans-openmp.c (gfc_trans_omp_variable_list): Same. (gfc_trans_omp_reduction_list): Same. (gfc_trans_omp_clauses): Same. (gfc_trans_omp_do): Same. * c-typeck.c (c_finish_goto_label): Same. (c_finish_goto_ptr): New location argument. (c_start_case): Same. (emit_side_effect_warnings): Same. (c_process_expr_stmt): Same. (c_finish_stmt_expr): Same. (c_finish_omp_clauses): Use error_at instead of error. * gimplify.c (gimplify_adjust_omp_clauses_1): Pass location to build_omp_clause. * c-omp.c (c_split_parallel_clauses): New location argument. * tree-nested.c (convert_nonlocal_reference_stmt): Pass location to build_omp_clause. (convert_local_reference_stmt): Same. (convert_gimple_call): Same. * c-common.h (c_split_parallel_clauses): New argument. * c-parser.c (c_parser_statement_after_labels): Pass location to c_finish_goto_label. (c_parser_switch_statement): Pass location to c_start_case. (c_parser_for_statement): Pass location to c_finish_expr_stmt, and c_process_expr_stmt. (c_parser_omp_variable_list): Add location argument. (c_parser_omp_clause_collapse): Pass location to build_omp_clause. (c_parser_omp_clause_default): Same. (c_parser_omp_clause_if): Same. (c_parser_omp_clause_num_threads): Same. (-c_parser_omp_clause_ordered): Same. (c_parser_omp_clause_reduction): Pass location to c_parser_omp_variable_list. (c_parser_omp_clause_schedule): Pass location to build_omp_clause. (c_parser_omp_clause_untied): Same. (c_parser_omp_for_loop): Pass location to c_process_expr_stmt. (c_parser_omp_parallel): Pass location to c_split_parallel_clauses. * c-tree.h (check_for_loop_decls, undeclared_variable, build_component_ref, build_array_ref, build_external_ref, c_expr_sizeof_expr, c_expr_sizeof_type, parser_build_unary_op, build_conditional_expr, build_compound_expr, c_cast_expr, build_c_cast, build_asm_expr, c_end_compound_stmt, c_finish_stmt_expr, c_finish_return, c_finish_omp_parallel, c_finish_omp_task): New argument. * c-semantics.c (build_stmt): Same. (build_case_label): Same. * c-decl.c (c_finish_incomplete_decl): Pass location on down. (undeclared_variable): New argument. (make_label): Same. (lookup_label): Pass location on down. (define_label): Same. (finish_decl): Same. (build_compound_literal): Same. (finish_struct): Same. (finish_function): Do not set location here. (check_for_loop_decls): New argument. * tree.c (save_expr): Set location. (build_empty_stmt): New argument. * tree.h (build_empty_stmt): New argument to build_empty_stmt. (CAN_HAVE_LOCATION_P): Make sure we have a non empty node. * builtins.c (gimplify_va_arg_expr): Use locations. (expand_builtin_sync_operation): Same. * c-typeck.c (build_component_ref): New argument. (build_array_ref): Same. (build_external_ref): Same. (c_expr_sizeof_expr): Same. (c_expr_sizeof_type): Same. (parser_build_unary_op): Same. (build_conditional_expr): Same. (build_compound_expr): Pass location on down. (build_compound_expr): New argument. (build_c_cast): Same. (c_cast_expr): Same. (build_asm_expr): Same. (c_finish_return): Same. (c_process_expr_stmt): Pass location on down. (c_finish_stmt_expr): New argument. (push_clenaup): Same. (c_finish_omp_parallel): Same. (c_finish_omp_task): Same. * gimplify.c (gimplify_call_expr): Pass location on down. * c-omp.c (c_finish_omp_master): New argument. (c_finish_omp_critical): Same. (c_finish_omp_ordered): Same. (c_finish_omp_barrier): Same. (-c_finish_omp_taskwait): Same. (c_finish_omp_atomic): Same. (c_finish_omp_flush): Same. * tree-inline.c (copy_tree_body_r): Pass location on down. (inline_forbidden_p): Remove use of input_location. * c-gimplify.c (c_build_bind_expr): New argument. * c-common.c (c_common_truthvalue_conversion): Pass location on down. (c_sizeof_or_alignof_type): New argument. (c_alignof_expr): Same. (build_va_arg): Same. (c_add_case_label): Same. * c-common.h (c_sizeof_or_alignof_type, c_alignof_expr, c_sizeof, c_alignof, build_va_arg, build_stmt, build_case_label, c_build_bind_expr, objc_build_selector_expr, objc_build_throw_stmt, c_finish_omp_master, c_finish_omp_critical, c_finish_omp_ordered, c_finish_omp_barrier, c_finish_omp_atomic, c_finish_omp_flush, c_finish_omp_taskwait, c_finish_omp_for, c_split_parallel_clauses): New argument. * stub-objc.c (objc_build_selector_expr): Same. (objc_build_throw_stmt): Same. * c-parser.c (c_parser_declaration_or_fndef): Pass location on down. (c_parser_initelt): Same. (c_parser_compound_statement): Same. (c_parser_compound_statement_nostart): Same. (c_parser_label): Same. (c_parser_statement_after_labels): Same. (c_parser_if_body): Same. (c_parser_else_body): Same. (c_parser_if_statement): Same. (c_parser_switch_statement): Same. (c_parser_while_statement): Same. (c_parser_do_statement): Same. (c_parser_for_statement): Same. (c_parser_asm_statement): Same. (c_parser_conditional_expression): Same. (c_parser_binary_expression): Same. (c_parser_cast_expression): Same. (c_parser_unary_expression): Same. (c_parser_sizeof_expression): Same. (c_parser_alignof_expression): Same. (c_parser_postfix_expression): Same. (c_parser_expression): Same. (c_parser_objc_receiver): Same. (c_parser_omp_variable_list): Same. (c_parser_omp_structured_block): Same. (c_parser_omp_atomic): New argument. (c_parser_omp_barrier): Same. (c_parser_omp_critical): Same. (c_parser_omp_flush): Pass location on down. (c_parser_omp_for_loop): New argument. (c_parser_omp_for): Same. (c_parser_omp_master): Same. (c_parser_omp_ordered): Same. (c_parser_omp_sections_scope): Same. (c_parser_omp_sections): Same. (c_parser_omp_parallel): Same. (c_parser_omp_single): Same. (c_parser_omp_task): Same. (c_parser_omp_taskwait): Pass location on down. (c_parser_omp_construct): Same. (c_parser_omp_threadprivate): Same. * dwarf2asm.c, targhooks.c, optabs.c, tree.c, tree.h, target.h, builtins.c, omp-low.c, cgraphunit.c, tree-call-cdce.c, tree-ssa-alias.c, gimple-low.c, c-tree.h, expr.c, tree-parloops.c, c-decl.c, tree-eh.c, langhooks.c, function.c, stor-layout.c, c-typeck.c, gimplify.c, c-pragma.c, expmed.c, except.c, coverage.c, emit-rtl.c, cfgexpand.c, tree-mudflap.c, varasm.c, tree-nested.c, rtl.h, tree-inline.c, tree-profile.c, c-common.c, c-common.h, tree-switch-conversion.c, tree-cfg.c, ipa-struct-reorg.c, c-parser.c, config/i386/i386.c, stmt.c: Add location argument to the following function definitions and/or function calls: build_decl, objcp_start_struct, objcp_finish_struct, start_struct, finish_struct, PUSH_FIELD, create_artificial_label, cp_make_fname_decl, pushtag, implicitly_declare, c_make_fname_decl, build_compound_literal, parser_xref_tag, resolve_overloaded_builtin, do_case, c_finish_bc_stmt, build_compound_literal, build_function_call. * c-decl.c (build_compound_literal): Add location argument. Make all diagnostic calls use location. (start_struct): Same. (finish_struct): Same. (start_enum): Same. (build_enumerator): Same. (start_function): Same. (grokdeclarator): Make all diagnostic calls use location. (store_parm_decls_oldstyle): Same. * c-typeck.c (build_function_call): Add location argument. Make all diagnostic calls use location. (do_case): Same. (c_finish_bc_stmt): Same. * tree-nested.c (get_trampoline_type): Add argument. Pass location to build_decl. (lookup_tramp_for_decl): Pass location to get_trampoline_type. * rtl.h (RTL_LOCATION): New. * c-common.c (c_add_case_label): Add location argument. Make all diagnostic calls use location. * c-common.h: Add location argument to make_fname_decl, do_case, c_add_case_label, build_function_call, resolve_overloaded_builtin. * c-parser.c (c_parser_enum_specifier): Rename ident_loc to enum_loc. Set it appropriately for every case. Pass enum_loc to start_enum call. Pass value_loc first to build_enumerator. Pass enum_loc to parser_xref_tag. (c_parser_struct_or_union_specifier): Save location. Use it for start_struct, finish_struct, and parser_xref_tag. gcc/testsuite/ * gcc.dg/old-style-prom-3.c: Add column info. * gcc.dg/overflow-warn-1.c * gcc.dg/gomp/pr27415.c * gcc.dg/gomp/for-1.c: Same. * gcc.dg/enum-compat-1.c: Same. * gcc.dg/c99-tag-3.c: Same. * gcc.dg/Wredundant-decls-2.c: Same. * gcc.dg/func-ptr-conv-1.c: Same. * gcc.dg/asm-wide-1.c: Same. * gcc.dg/nofixed-point-2.c: Same. * gcc.dg/cpp/line3.c: Same. * gcc.dg/array-10.c: Same. * gcc.dg/c99-vla-jump-1.c: Same. * gcc.dg/pr20368-1.c: Same. * gcc.dg/Wshadow-3.c: Same. * gcc.dg/c90-const-expr-8.c: Same. * gcc.dg/label-decl-2.c: Same. * gcc.dg/dremf-type-compat-2.c: Same. * gcc.dg/c90-const-expr-5.c: Same. * gcc.dg/builtins-30.c: Same. * gcc.dg/Warray-bounds.c: Same. * gcc.dg/Wcxx-compat-2.c: Same. * gcc.dg/tree-ssa/col-1.c: Same. * gcc.dg/old-style-prom-2.c: Same. * gcc.dg/cast-function-1.c: Same. * gcc.dg/pr15698-1.c: Same. * gcc.dg/dremf-type-compat-3.c: Same. * gcc.dg/vla-8.c: Same. * gcc.dg/gomp/pr27415.c: Move firstprivate diagnostics to correct line. * gcc.dg/label-decl-2.c: Move label diagnostic to correct line. * gcc.dg/old-style-prom-3.c: Check for error on the correct line. * gcc.dg/enum-compat-1.c: Same. * gcc.dg/dremf-type-compat-2.c: Same. * gcc.dg/old-style-prom-2.c: Same. * gcc.dg/pr15698-1.c: Same. * gcc.dg/pr20368-1.c: Same. * gcc.dg/dremf-type-compat-3.c: Same. * gcc.dg/builtins-30.c: Same. Test for columns. gcc/objcp/ * objcp-decl.h (c_end_compound_stmt): New argument. * objcp-decl.c (objcp_start_struct): Add argument. (objcp_finish_struct): Same. gcc/cp/ * typeck.c (cp_build_binary_op): Pass location to overflow_warning. (build_modify_expr): New arg. * semantics.c (finish_unary_op_expr): Pass location to overflow_warning. (handle_omp_for_class_iterator): Pass location to build_modify_expr. * typeck.c (cxx_sizeof_or_alignof_type): Pass location to c_sizeof_or_alignof_type. (build_array_ref): New argument. (build_compound_expr): Same. (build_const_cast): Same. (build_ptrmemfunc): Pass location to build_c_cast. * init.c (avoid_placement_new_aliasing): Pass location to build_stmt. (build_vec_delete_1): Pass location to cp_build_modify_expr, build_compound_expr. * class.c (build_vtbl_ref_1): Pass location to build_array_ref. * decl.c (poplevel): Pass location to c_build_bind_expr. (finish_case_label): Pass location to build_case_label. (finish_constructor_body): Same. (finish_destructor_body): Pass location to build_stmt. (cxx_maybe_build_cleanup): Same, but to build_compound_expr. * call.c (build_new_op): Pass location to build_array_ref. (build_x_va_arg): Pass location to build_va_arg. * except.c (expand_end_catch_block): Pass location to build_stmt. * cp-tree.h (build_array_ref): New argument. (build_compound_expr): Same. (build_c_cast): Same. * cp-gimplify.c (gimplify_if_stmt): Pass location on down. (gimplify_switch_stmt): Same. * typeck2.c (split_nonconstant_init_1): Same. * pt.c (tsubst_copy): Same. * semantics.c (add_decl_expr): Same. (do_poplevel): Same. (push_cleanup): Same. (finish_goto_stmt): Same. (finish_expr_stmt): Same. (begin_if_stmt): Same. (begin_while_stmt): Same. (begin_do_stmt): Same. (finish_return_stmt): Same. (begin_for_stmt): Same. (finish_break_stmt): Same. (finish_continue_stmt): Same. (begin_switch_stmt): Same. (begin_try_block): Same. (begin_handler): Same. (finish_asm_stmt): Same. (finish_label_stmt): Same. (finish_stmt_expr_expr): Same. (finalize_nrv_r): Same. (finish_omp_atomic): Same. * name-lookup.c (do_using_directive): Same. * decl2.c (grok_array_decl): Same. * parser.c (cp_parser_cast_expression): Same. (cp_parser_selection_statement): Same. (cp_parser_implicitly_scoped_statement): Same. (cp_parser_objc_selector_expression): Same. (cp_parser_objc_synchronized_statement): Same. (cp_parser_objc_throw_statement): Same. (cp_parser_omp_critical): Same. (cp_parser_omp_master): Same. * typeck.c (build_function_call): Add location argument. * init.c: Add location argument to all build_decl calls. * class.c: Same. * method.c: Same. * rtti.c: Same. * tree.c: Same. * pt.c: Same. * semantics.c: Same. * lex.c: Same. * decl2.c: Same. * cp-gimplify.c: Same. * decl.c: Same. (cp_make_fname_decl): Add location argument. Pass location ot build_decl. (finish_case_label): Same. * cp-tree.h (finish_case_label): Add location argument. * parser.c (cp_parser_label_for_labeled_statement): Pass location to finish_case_label. gcc/fortran/ * trans-array.c (gfc_trans_allocate_array_storage): Pass location on down. (gfc_trans_array_constructor_value): Same. (gfc_trans_scalarized_loop_end): Same. (gfc_conv_ss_startstride): Same. (gfc_trans_g77_array): Same. (gfc_trans_dummy_array_bias): Same. (gfc_conv_array_parameter): Same. (structure_alloc_comps): Same. * trans-expr.c (gfc_conv_function_call): Same. (fill_with_spaces): Same. (gfc_trans_string_copy): Same. (gfc_trans_scalar_assign): Same. * trans-stmt.c (gfc_trans_goto): Same. (gfc_trans_if_1): Same. (gfc_trans_simple_do): Same. (gfc_trans_do): Same. (gfc_trans_do_while): Same. (gfc_trans_logical_select): Same. (gfc_trans_select): Same. (gfc_trans_forall_loop): Same. (gfc_trans_nested_forall_loop): Same. (generate_loop_for_temp_to_lhs): Same. (generate_loop_for_rhs_to_temp): Same. (gfc_trans_forall_1): Same. (gfc_trans_where_assign): Same. (gfc_trans_where_3): Same. (gfc_trans_allocate): Same. * trans.c (gfc_finish_block): Same. (gfc_trans_runtime_check): Same. (gfc_call_malloc): Same. (gfc_allocate_with_status): Same. (gfc_call_free): Same. (gfc_deallocate_with_status): Same. (gfc_call_realloc): Same. (gfc_trans_code): Same. * trans-decl.c (gfc_init_default_dt): Same. (gfc_generate_constructors): Same. * trans-io.c (gfc_trans_io_runtime_check): Same. * trans-intrinsic.c (gfc_conv_intrinsic_ctime): Same. (gfc_conv_intrinsic_fdate): Same. (gfc_conv_intrinsic_ttynam): Same. (gfc_conv_intrinsic_minmax): Same. (gfc_conv_intrinsic_minmax_char): Same. (gfc_conv_intrinsic_anyall): Same. (gfc_conv_intrinsic_count): Same. (gfc_conv_intrinsic_arith): Same. (gfc_conv_intrinsic_minmaxloc): Same. (gfc_conv_intrinsic_minmaxval): Same. (gfc_conv_intrinsic_rrspacing): Same. (gfc_conv_intrinsic_array_transfer): Same. (gfc_conv_intrinsic_trim): Same. (gfc_conv_intrinsic_repeat): Same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148442 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 08 Jun, 2009 1 commit
-
-
pault authored
* trans-array.h : Replace prototypes for gfc_conv_descriptor_offset, gfc_conv_descriptor_stride, gfc_conv_descriptor_lbound, gfc_conv_descriptor_ubound with new prototypes of the same names with _get or _set appended. * trans-array.c : Make the originals of the above static and new functions for the _get and _set functions. Update all the references to these descriptor access functions. * trans-expr.c : Update references to the above descriptor access functions. * trans-intrinsic.c : The same. * trans-openmp.c : The same. * trans-stmt.c : The same. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148290 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 25 May, 2009 1 commit
-
-
janus authored
PR fortran/40176 * primary.c (gfc_match_varspec): Handle procedure pointer components with array return value. * resolve.c (resolve_expr_ppc): Ditto. (resolve_symbol): Make sure the interface of a procedure pointer has been resolved. * trans-array.c (gfc_walk_function_expr): Handle procedure pointer components with array return value. * trans-expr.c (gfc_conv_component_ref,gfc_conv_procedure_call, gfc_trans_arrayfunc_assign): Ditto. (gfc_trans_pointer_assignment): Handle procedure pointer assignments, where the rhs is a dummy argument. * trans-types.c (gfc_get_ppc_type,gfc_get_derived_type): Handle procedure pointer components with array return value. 2009-05-25 Janus Weil <janus@gcc.gnu.org> PR fortran/40176 * gfortran.dg/proc_ptr_18.f90: New. * gfortran.dg/proc_ptr_19.f90: New. * gfortran.dg/proc_ptr_comp_9.f90: New. * gfortran.dg/proc_ptr_comp_10.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147850 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 18 May, 2009 1 commit
-
-
rguenth authored
PR fortran/40168 * trans-expr.c (gfc_trans_zero_assign): For local array destinations use an assignment from an empty constructor. * gfortran.dg/array_memset_2.f90: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147659 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 14 May, 2009 1 commit
-
-
jakub authored
* io.c (resolve_tag_format): CHARACTER array in FMT= argument isn't an extension. Reject non-CHARACTER array element of assumed shape or pointer or assumed size array. * trans-array.c (array_parameter_size): New function. (gfc_conv_array_parameter): Add size argument. Call array_parameter_size if it is non-NULL. * trans-array.h (gfc_conv_array_parameter): Adjust prototype. * trans-expr.c (gfc_conv_function_call, gfc_trans_arrayfunc_assign): Adjust callers. * trans-intrinsic.c (gfc_conv_intrinsic_loc): Likewise. * trans-io.c (gfc_convert_array_to_string): Rewritten. * gfortran.dg/pr39865.f90: New test. * gfortran.dg/hollerith.f90: Don't expect errors for CHARACTER arrays in FMT=. * gfortran.dg/hollerith_f95.f90: Likewise. * gfortran.dg/hollerith6.f90: New test. * gfortran.dg/hollerith7.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147507 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 13 May, 2009 1 commit
-
-
kargl authored
* gfortran.h (gfc_code): Rename struct member expr to expr1. * openmp.c (resolve_omp_atomic): Update expr to expr1. * interface.c (gfc_extend_assign): Ditto. * trans-expr.c (gfc_conv_expr_reference, gfc_trans_assignment, gfc_trans_init_assign): Ditto. * dump-parse-tree.c (show_code_node): Ditto. * trans-openmp.c (gfc_trans_omp_atomic): Ditto. * trans-stmt.c ( gfc_trans_label_assign, gfc_trans_goto, gfc_trans_call, gfc_trans_return, gfc_trans_pause, gfc_trans_stop, gfc_trans_if_1, gfc_trans_arithmetic_if, gfc_trans_do_while, gfc_trans_integer_select, gfc_trans_logical_select, gfc_trans_character_select forall_make_variable_temp, check_forall_dependencies gfc_trans_forall_1, gfc_trans_where_2, gfc_trans_where_3 gfc_trans_where, gfc_trans_allocate, gfc_trans_deallocate): Ditto. * io.c (match_io_element, gfc_match_inquire): Ditto. * resolve.c (resolve_typebound_call, resolve_ppc_call, resolve_allocate_expr, resolve_allocate_deallocate, resolve_select, resolve_transfer, resolve_where, gfc_resolve_assign_in_forall, gfc_resolve_blocks, resolve_code, build_init_assign): Ditto. * st.c (gfc_free_statement): Ditto. * match.c (gfc_match_assignment, gfc_match_pointer_assignment, match_arithmetic_if, gfc_match_if, gfc_match_elseif gfc_match_stopcode, gfc_match_assign, gfc_match_goto, gfc_match_nullify, match_typebound_call, gfc_match_call gfc_match_select, match_simple_where, gfc_match_where gfc_match_elsewhere, match_simple_forall, gfc_match_forall): Ditto. * trans-io.c (gfc_trans_transfer): Ditto. * parse.c (parse_where_block, parse_if_block): Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147497 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 10 May, 2009 1 commit
-
-
pault authored
PR fortran/38863 * trans-expr.c (gfc_conv_operator_assign): Remove function. * trans.h : Remove prototype for gfc_conv_operator_assign. * trans-stmt.c (gfc_conv_elemental_dependencies): Initialize derivde types with intent(out). (gfc_trans_call): Add mask, count1 and invert arguments. Add code to use mask for WHERE assignments. (gfc_trans_forall_1): Use new arguments for gfc_trans_call. (gfc_trans_where_assign): The gfc_symbol argument is replaced by the corresponding code. If this has a resolved_sym, then gfc_trans_call is called. The call to gfc_conv_operator_assign is removed. (gfc_trans_where_2): Change the last argument in the call to gfc_trans_where_assign. * trans-stmt.h : Modify prototype for gfc_trans_call. * trans.c (gfc_trans_code): Use new args for gfc_trans_call. 2009-05-10 Paul Thomas <pault@gcc.gnu.org> PR fortran/38863 * gfortran.dg/dependency_24.f90: New test. * gfortran.dg/dependency_23.f90: Clean up module files. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147329 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 06 May, 2009 1 commit
-
-
janus authored
Paul Thomas <pault@gcc.gnu.org> PR fortran/39630 * decl.c (match_procedure_interface): New function to match the interface for a PROCEDURE statement. (match_procedure_decl): Call match_procedure_interface. (match_ppc_decl): New function to match the declaration of a procedure pointer component. (gfc_match_procedure): Call match_ppc_decl. (match_binding_attributes): Add new argument 'ppc' and handle the POINTER attribute for procedure pointer components. (match_procedure_in_type,gfc_match_generic): Added new argument to match_binding_attributes. * dump-parse-tree.c (show_expr,show_components,show_code_node): Handle procedure pointer components. * expr.c (free_expr0,gfc_copy_expr,gfc_simplify_expr): Handle EXPR_PPC. (gfc_check_pointer_assign): Handle procedure pointer components, but no full checking yet. (is_proc_ptr_comp): New function to determine if an expression is a procedure pointer component. * gfortran.h (expr_t): Add EXPR_PPC. (symbol_attribute): Add new member 'proc_pointer_comp'. (gfc_component): Add new member 'formal'. (gfc_exec_op): Add EXEC_CALL_PPC. (gfc_get_default_type): Changed first argument. (is_proc_ptr_comp): Add prototype. (gfc_match_varspec): Add new argument. * interface.c (compare_actual_formal): Handle procedure pointer components. * match.c (gfc_match_pointer_assignment,match_typebound_call): Handle procedure pointer components. * module.c (mio_expr): Handle EXPR_PPC. * parse.c (parse_derived): Handle procedure pointer components. * primary.c (gfc_match_varspec): Add new argument 'ppc_arg' and handle procedure pointer components. (gfc_variable_attr): Handle procedure pointer components. (gfc_match_rvalue): Added new argument to gfc_match_varspec and changed first argument of gfc_get_default_type. (match_variable): Added new argument to gfc_match_varspec. * resolve.c (resolve_entries,set_type,resolve_fl_parameter): Changed first argument of gfc_get_default_type. (resolve_structure_cons,resolve_actual_arglist): Handle procedure pointer components. (resolve_ppc_call): New function to resolve a call to a procedure pointer component (subroutine). (resolve_expr_ppc): New function to resolve a call to a procedure pointer component (function). (gfc_resolve_expr): Handle EXPR_PPC. (resolve_code): Handle EXEC_CALL_PPC. (resolve_fl_derived): Copy the interface for a procedure pointer component. (resolve_symbol): Fix overlong line. * st.c (gfc_free_statement): Handle EXEC_CALL_PPC. * symbol.c (gfc_get_default_type): Changed first argument. (gfc_set_default_type): Changed first argument of gfc_get_default_type. (gfc_add_component): Initialize ts.type to BT_UNKNOWN. * trans.h (gfc_conv_function_call): Renamed. * trans.c (gfc_trans_code): Handle EXEC_CALL_PPC. * trans-expr.c (gfc_conv_component_ref): Ditto. (gfc_conv_function_val): Rename to 'conv_function_val', add new argument 'expr' and handle procedure pointer components. (gfc_conv_operator_assign): Renamed gfc_conv_function_val. (gfc_apply_interface_mapping_to_expr): Handle EXPR_PPC. (gfc_conv_function_call): Rename to 'gfc_conv_procedure_call', add new argument 'expr' and handle procedure pointer components. (gfc_get_proc_ptr_comp): New function to get the backend decl for a procedure pointer component. (gfc_conv_function_expr): Renamed gfc_conv_function_call. (gfc_conv_structure): Handle procedure pointer components. * trans-intrinsic.c (gfc_conv_intrinsic_funcall, conv_generic_with_optional_char_arg): Renamed gfc_conv_function_call. * trans-stmt.h (gfc_get_proc_ptr_comp): Add prototype. * trans-stmt.c (gfc_trans_call): Renamed gfc_conv_function_call. * trans-types.h (gfc_get_ppc_type): Add prototype. * trans-types.c (gfc_get_ppc_type): New function to build a tree node for a procedure pointer component. (gfc_get_derived_type): Handle procedure pointer components. 2009-05-06 Janus Weil <janus@gcc.gnu.org> PR fortran/39630 * gfortran.dg/proc_decl_1.f90: Modified. * gfortran.dg/proc_ptr_comp_1.f90: New. * gfortran.dg/proc_ptr_comp_2.f90: New. * gfortran.dg/proc_ptr_comp_3.f90: New. * gfortran.dg/proc_ptr_comp_4.f90: New. * gfortran.dg/proc_ptr_comp_5.f90: New. * gfortran.dg/proc_ptr_comp_6.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147206 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 28 Apr, 2009 2 commits
-
-
pault authored
PR fortran/39879 * trans_expr.c (gfc_conv_procedure_call): Deep copy a derived type parentheses argument if it is a variable with allocatable components. 2009-04-28 Paul Thomas <pault@gcc.gnu.org> PR fortran/39879 * gfortran.dg/alloc_comp_assign_10.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146872 138bc75d-0d04-0410-961f-82ee72b054a4
-
pault authored
PR fortran/39879 * trans_expr.c (gfc_conv_procedure_call): Deep copy a derived type parentheses argument if it is a variable with allocatable components. 2009-04-28 Paul Thomas <pault@gcc.gnu.org> PR fortran/39879 * gfortran.dg/alloc_comp_assign_10.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146871 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 20 Apr, 2009 1 commit
-
-
jakub authored
* trans.h (OMPWS_WORKSHARE_FLAG, OMPWS_CURR_SINGLEUNIT, OMPWS_SCALARIZER_WS, OMPWS_NOWAIT): Define. (ompws_flags): New extern decl. * trans-array.c (gfc_trans_scalarized_loop_end): Build OMP_FOR for the outer dimension if ompws_flags allow it. * trans.c (gfc_generate_code): Clear ompws_flags. * trans-expr.c (gfc_trans_assignment_1): Allow worksharing array assignments inside of !$omp workshare. * trans-stmt.c (gfc_trans_where_3): Similarly for where statements and constructs. * trans-openmp.c (ompws_flags): New variable. (gfc_trans_omp_workshare): Rewritten. * testsuite/libgomp.fortran/workshare2.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146397 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 31 Mar, 2009 1 commit
-
-
pault authored
PR fortran/38915 * trans-expr.c (gfc_trans_assignment_1): Ensure temporaries have a string_length. 2009-03-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38915 * gfortran.dg/char_length_15.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145370 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 28 Mar, 2009 1 commit
-
-
burnus authored
Paul Thomas <pault@gcc.gnu.org> Tobias Burnus <burnus@net-b.de> * gfortran.h (gfc_option_t): Add rtcheck. * lang.opt: New option -fruntime-check. * libgfortran.h: Add GFC_RTCHECK_* constants. * invoke.texi: Document -fruntime-check. * options.c (gfc_handle_runtime_check_option): New function. (gfc_init_options,gfc_post_options,gfc_handle_option): Add -fruntime-check option. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145183 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 27 Mar, 2009 1 commit
-
-
rguenth authored
* gimplify.c (mark_addressable): Export. * tree-flow.h (mark_addressable): Declare. * tree-ssa-loop-manip.c (create_iv): Mark the base addressable. * tree-ssa.c (verify_phi_args): Verify that address taken variables have TREE_ADDRESSABLE set. 2009-03-27 Richard Guenther <rguenther@suse.de> * fold-const.c (build_fold_addr_expr_with_type_1): Rename back to ... (build_fold_addr_expr_with_type): ... this. Remove in_fold handling. Do not mark decls TREE_ADDRESSABLE. (build_fold_addr_expr): Adjust. (fold_addr_expr): Remove. (fold_unary): Use build_fold_addr_expr. (fold_comparison): Likewise. (split_address_to_core_and_offset): Likewise. * coverage.c (tree_coverage_counter_addr): Mark the array decl TREE_ADDRESSABLE. * gimplify.c (mark_addressable): Do not exclude RESULT_DECLs. (gimplify_modify_expr_to_memcpy): Mark source and destination addressable. * omp-low.c (create_omp_child_function): Mark the object decl TREE_ADDRESSABLE. (lower_rec_input_clauses): Mark the var we take the address of TREE_ADDRESSABLE. (lower_omp_taskreg): Mark the sender decl TREE_ADDRESSABLE. fortran/ * trans-array.c (gfc_conv_descriptor_data_addr): Use gfc_build_addr_expr instead of build_fold_addr_expr. (gfc_trans_allocate_array_storage, gfc_trans_array_constructor_value, gfc_trans_constant_array_constructor, gfc_conv_array_data, gfc_conv_expr_descriptor, gfc_conv_array_parameter): Likewise. * trans-expr.c (gfc_conv_missing_dummy, gfc_conv_variable, gfc_conv_function_val, gfc_conv_operator_assign, gfc_conv_subref_array_arg, gfc_conv_function_call, gfc_conv_expr_reference, gfc_trans_scalar_assign): Likewise. * trans-intrinsic.c (gfc_conv_intrinsic_exponent, gfc_conv_intrinsic_ctime, gfc_conv_intrinsic_fdate, gfc_conv_intrinsic_ttynam, gfc_conv_intrinsic_minmax_char, gfc_conv_intrinsic_fraction, gfc_conv_intrinsic_spacing, gfc_conv_intrinsic_rrspacing, gfc_conv_intrinsic_set_exponent, gfc_conv_intrinsic_array_transfer, gfc_conv_intrinsic_transfer, gfc_conv_intrinsic_si_kind, gfc_conv_intrinsic_trim): Likewise. * trans-io.c (gfc_trans_io_runtime_check, set_parameter_ref, gfc_convert_array_to_string, gfc_trans_open, gfc_trans_close, build_filepos, gfc_trans_inquire, gfc_trans_wait, nml_get_addr_expr, transfer_namelist_element, build_dt, gfc_trans_dt_end, transfer_array_component, transfer_expr, transfer_array_desc, gfc_trans_transfer): Likewise. * trans-stmt.c (gfc_trans_allocate, gfc_trans_deallocate): Likewise. * trans.c (gfc_build_addr_expr): Mark the base of the address TREE_ADDRESSABLE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145142 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 20 Feb, 2009 1 commit
-
-
jakub authored
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144324 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 13 Feb, 2009 1 commit
-
-
pault authored
PR fortran/36703 PR fortran/36528 * trans-expr.c (gfc_conv_function_val): Stabilize Cray-pointer function references to ensure that a valid expression is used. (gfc_conv_function_call): Pass Cray pointers to procedures. 2009-02-13 Paul Thomas <pault@gcc.gnu.org> PR fortran/36528 * gfortran.dg/cray_pointers_8.f90: New test. PR fortran/36703 * gfortran.dg/cray_pointers_9.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144164 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 18 Dec, 2008 1 commit
-
-
domob authored
PR fortran/31822 * gfortran.h (gfc_check_same_strlen): Made public. * trans.h (gfc_trans_same_strlen_check): Made public. * check.c (gfc_check_same_strlen): Made public and adapted error message output to be useful not only for intrinsics. (gfc_check_merge): Adapt to gfc_check_same_strlen change. * expr.c (gfc_check_pointer_assign): Use gfc_check_same_strlen for string length compile-time check. * trans-expr.c (gfc_trans_pointer_assignment): Add runtime-check for equal string lengths using gfc_trans_same_strlen_check. * trans-intrinsic.c (gfc_trans_same_strlen_check): Renamed and made public from conv_same_strlen_check. (gfc_conv_intrinsic_merge): Adapted accordingly. 2008-12-18 Daniel Kraft <d@domob.eu> PR fortran/31822 * gfortran.dg/char_pointer_assign_2.f90: Updated expected error message to be more detailed. * gfortran.dg/char_pointer_assign_4.f90: New test. * gfortran.dg/char_pointer_assign_5.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142808 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 14 Dec, 2008 1 commit
-
-
pault authored
PR fortran/35937 * trans-expr.c (gfc_finish_interface_mapping): Fold convert the character length to gfc_charlen_type_node. 2008-12-14 Paul Thomas <pault@gcc.gnu.org> PR fortran/35937 * gfortran.dg/char_length_14.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142750 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 09 Dec, 2008 1 commit
-
-
mikael authored
PR fortran/35983 * trans-expr.c (gfc_trans_subcomponent_assign): Add se's pre and post blocks to current block. (gfc_trans_structure_assign): Remove specific handling of C_NULL_PTR and C_NULL_FUNPTR. 2008-12-09 Mikael Morin <mikael.morin@tele2.fr> PR fortran/35983 * gfortran.dg/pr35983.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142605 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 24 Nov, 2008 1 commit
-
-
pault authored
PR fortran/34820 * trans-expr.c (gfc_conv_function_call): Remove all code to deallocate intent out derived types with allocatable components. (gfc_trans_assignment_1): An assignment from a scalar to an array of derived types with allocatable components, requires a deep copy to each array element and deallocation of the converted rhs expression afterwards. * trans-array.c : Minor whitespace. * trans-decl.c (init_intent_out_dt): Add code to deallocate allocatable components of derived types with intent out. (generate_local_decl): If these types are unused, set them referenced anyway but allow the uninitialized warning. PR fortran/34143 * trans-expr.c (gfc_trans_subcomponent_assign): If a conversion expression has a null data pointer argument, nullify the allocatable component. PR fortran/32795 * trans-expr.c (gfc_trans_subcomponent_assign): Only nullify the data pointer if the source is not a variable. 2008-11-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/34820 * gfortran.dg/alloc_comp_constructor_6.f90 : New test. * gfortran.dg/alloc_comp_basics_1.f90 : Reduce expected refs to 'builtin_free' from 24 to 18. PR fortran/34143 * gfortran.dg/alloc_comp_constructor_5.f90 : New test. PR fortran/32795 * gfortran.dg/alloc_comp_constructor_4.f90 : New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@142148 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 16 Nov, 2008 3 commits
-
-
mikael authored
PR fortran/35681 * dependency.c (gfc_check_argument_var_dependency): Add elemental check flag. Issue a warning if we find a dependency but don't generate a temporary. Add the case of an elemental function call as actual argument to an elemental procedure. Add the case of an operator expression as actual argument to an elemental procedure. (gfc_check_argument_dependency): Add elemental check flag. Update calls to gfc_check_argument_var_dependency. (gfc_check_fncall_dependency): Add elemental check flag. Update call to gfc_check_argument_dependency. * trans-stmt.c (gfc_trans_call): Make call to gfc_conv_elemental_dependency unconditional, but with a flag whether we should check dependencies between variables. (gfc_conv_elemental_dependency): Add elemental check flag. Update call to gfc_check_fncall_dependency. * trans-expr.c (gfc_trans_arrayfunc_assign): Update call to gfc_check_fncall_dependency. * resolve.c (find_noncopying_intrinsics): Update call to gfc_check_fncall_dependency. * dependency.h (enum gfc_dep_check): New enum. (gfc_check_fncall_dependency): Update prototype. 2008-11-16 Mikael Morin <mikael.morin@tele2.fr> PR fortran/35681 * gfortran.dg/elemental_dependency_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141931 138bc75d-0d04-0410-961f-82ee72b054a4
-
burnus authored
PR fortran/38095 * trans-expr.c (gfc_map_intrinsic_function): Fix pointer access. 2008-11-16 Tobias Burnus <burnus@net-b.de> PR fortran/38095 * gfortran.dg/char_length_13.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141917 138bc75d-0d04-0410-961f-82ee72b054a4
-
pault authored
PR fortran/37926 * trans-expr.c (gfc_free_interface_mapping): Null sym->formal (gfc_add_interface_mapping): Copy the pointer to the formal arglist, rather than using copy_formal_args. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141914 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 15 Nov, 2008 1 commit
-
-
pault authored
PR fortran/37926 * trans-expr.c (gfc_add_interface_mapping): Transfer the formal arglist and the always_explicit attribute if the dummy arg is a procedure. 2008-11-15 Paul Thomas <pault@gcc.gnu.org> PR fortran/37926 * gfortran.dg/dummy_procedure_3.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141890 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 01 Nov, 2008 2 commits
-
-
domob authored
PR fortran/35681 * gfortran.h (struct gfc_code): New field `resolved_isym'. * trans.h (gfc_build_memcpy_call): Made public. * trans-array.h (gfc_trans_create_temp_array): New argument `initial'. * intrinsic.c (gfc_intrinsic_sub_interface): Set resolved_isym. * iresolve.c (create_formal_for_intents): New helper method. (gfc_resolve_mvbits): Put dummy formal arglist on resolved_sym. * resolve.c (resolve_call): Initialize resolved_isym to NULL. * trans-array.c (gfc_trans_allocate_array_storage): New argument `initial' to allow initializing the allocated storage to some initial value copied from another array. (gfc_trans_create_temp_array): Allow initialization of the temporary with a copy of some other array by using the new extension. (gfc_trans_array_constructor): Pass NULL_TREE for initial argument. (gfc_conv_loop_setup): Ditto. * trans-intrinsic.c (gfc_conv_intrinsic_array_transfer): Ditto. * trans-expr.c (gfc_conv_function_call): Ditto. (gfc_build_memcpy_call): Made public. * trans-stmt.c (gfc_conv_elemental_dependencies): Initialize created temporary for INTENT(INOUT) arguments to the value of the mirrored array and clean up the temporary as very last intructions in the created block. * trans.c (gfc_trans_code): For EXEC_CALL, see if we have a MVBITS call and enable elemental dependency checking if we have. 2008-11-01 Daniel Kraft <d@domob.eu> PR fortran/35681 * gfortran.dg/mvbits_4.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141516 138bc75d-0d04-0410-961f-82ee72b054a4
-
janus authored
PR fortran/36322 PR fortran/36463 * gfortran.h: New function gfc_expr_replace_symbols. * decl.c (match_procedure_decl): Increase reference count for interface. * expr.c: New functions replace_symbol and gfc_expr_replace_symbols. * resolve.c (resolve_symbol): Correctly copy array spec and char len of PROCEDURE declarations from their interface. * symbol.c (gfc_get_default_type): Enhanced error message. (copy_formal_args): Call copy_formal_args recursively for arguments. * trans-expr.c (gfc_conv_function_call): Bugfix. 2008-11-01 Janus Weil <janus@gcc.gnu.org> PR fortran/36322 PR fortran/36463 * gfortran.dg/proc_decl_17.f90: New. * gfortran.dg/proc_decl_18.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141515 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 21 Sep, 2008 1 commit
-
-
domob authored
PR fortran/35846 * trans.h (gfc_conv_string_length): New argument `expr'. * trans-expr.c (flatten_array_ctors_without_strlen): New method. (gfc_conv_string_length): New argument `expr' that is used in a new special case handling if cl->length is NULL. (gfc_conv_subref_array_arg): Pass expr to gfc_conv_string_length. * trans-array.c (gfc_conv_expr_descriptor): Ditto. (gfc_trans_auto_array_allocation): Pass NULL as new expr. (gfc_trans_g77_array), (gfc_trans_dummy_array_bias): Ditto. (gfc_trans_deferred_array): Ditto. (gfc_trans_array_constructor): Save and restore old values of globals used for bounds checking. * trans-decl.c (gfc_trans_dummy_character): Ditto. (gfc_trans_auto_character_variable): Ditto. 2008-09-21 Daniel Kraft <d@domob.eu> PR fortran/35846 * gfortran.dg/nested_array_constructor_1.f90: New test. * gfortran.dg/nested_array_constructor_2.f90: New test. * gfortran.dg/nested_array_constructor_3.f90: New test. * gfortran.dg/nested_array_constructor_4.f90: New test. * gfortran.dg/nested_array_constructor_5.f90: New test. * gfortran.dg/nested_array_constructor_6.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140529 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 08 Sep, 2008 1 commit
-
-
domob authored
PR fortran/37199 * trans-expr.c (gfc_add_interface_mapping): Set new_sym->as. (gfc_map_intrinsic_function): Added checks against NULL bounds in array specs. 2008-09-08 Daniel Kraft <d@domob.eu> PR fortran/37199 * gfortran.dg/array_function_2.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140102 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 04 Sep, 2008 1 commit
-
-
rguenth authored
* trans-array.c (gfc_conv_array_parameter): Use correct types in building COND_EXPRs. * trans-expr.c (gfc_conv_missing_dummy): Likewise. * trans-intrinsics.c (gfc_conv_intrinsic_merge): Likewise. * gfortran.dg/internal_pack_4.f90: Adjust pattern. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@140001 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 31 Aug, 2008 1 commit
-
-
rguenth authored
* trans-expr.c (gfc_trans_string_copy): Use the correct types to compute slen and dlen. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139832 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 28 Aug, 2008 1 commit
-
-
domob authored
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139724 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 24 Aug, 2008 1 commit
-
-
burnus authored
PR fortran/37201 * trans-expr.c (gfc_conv_function_call): Add string_length for character-returning bind(C) functions. 2008-08-24 Tobias Burnus <burnus@net-b.de> PR fortran/37201 * gfortran.dg/bind_c_usage_17.f90: New. * gfortran.dg/bind_c_usage_17_c.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139537 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 23 Aug, 2008 1 commit
-
-
janus authored
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139524 138bc75d-0d04-0410-961f-82ee72b054a4
-
- 29 Jul, 2008 1 commit
-
-
pault authored
=================================================================== *** gcc/fortran/trans-expr.c (revision 138273) --- gcc/fortran/trans-expr.c (working copy) *************** *** 1,6 **** /* Expression translation ! Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software ! Foundation, Inc. Contributed by Paul Brook <paul@nowt.org> and Steven Bosscher <s.bosscher@student.tudelft.nl> --- 1,6 ---- /* Expression translation ! Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 ! Free Software Foundation, Inc. Contributed by Paul Brook <paul@nowt.org> and Steven Bosscher <s.bosscher@student.tudelft.nl> *************** gfc_conv_component_ref (gfc_se * se, gfc *** 395,400 **** --- 395,434 ---- } + /* This function deals with component references to components of the + parent type for derived type extensons. */ + static void + conv_parent_component_references (gfc_se * se, gfc_ref * ref) + { + gfc_component *c; + gfc_component *cmp; + gfc_symbol *dt; + gfc_ref parent; + + dt = ref->u.c.sym; + c = ref->u.c.component; + + /* Build a gfc_ref to recursively call gfc_conv_component_ref. */ + parent.type = REF_COMPONENT; + parent.next = NULL; + parent.u.c.sym = dt; + parent.u.c.component = dt->components; + + if (dt->attr.extension && dt->components) + { + /* Return if the component is not in the parent type. */ + for (cmp = dt->components->next; cmp; cmp = cmp->next) + if (strcmp (c->name, cmp->name) == 0) + return; + + /* Otherwise build the reference and call self. */ + gfc_conv_component_ref (se, &parent); + parent.u.c.sym = dt->components->ts.derived; + parent.u.c.component = c; + conv_parent_component_references (se, &parent); + } + } + /* Return the contents of a variable. Also handles reference/pointer variables (all Fortran pointer references are implicit). */ *************** gfc_conv_variable (gfc_se * se, gfc_expr *** 561,566 **** --- 595,603 ---- break; case REF_COMPONENT: + if (ref->u.c.sym->attr.extension) + conv_parent_component_references (se, ref); + gfc_conv_component_ref (se, ref); break; Index: gcc/fortran/trans-array.c =================================================================== *** gcc/fortran/trans-array.c (revision 138273) --- gcc/fortran/trans-array.c (working copy) *************** gfc_conv_resolve_dependencies (gfc_loopi *** 3257,3270 **** if (ss->type != GFC_SS_SECTION) continue; ! if (gfc_could_be_alias (dest, ss) ! || gfc_are_equivalenced_arrays (dest->expr, ss->expr)) { ! nDepend = 1; ! break; } ! ! if (dest->expr->symtree->n.sym == ss->expr->symtree->n.sym) { lref = dest->expr->ref; rref = ss->expr->ref; --- 3257,3272 ---- if (ss->type != GFC_SS_SECTION) continue; ! if (dest->expr->symtree->n.sym != ss->expr->symtree->n.sym) { ! if (gfc_could_be_alias (dest, ss) ! || gfc_are_equivalenced_arrays (dest->expr, ss->expr)) ! { ! nDepend = 1; ! break; ! } } ! else { lref = dest->expr->ref; rref = ss->expr->ref; Index: gcc/fortran/symbol.c =================================================================== *** gcc/fortran/symbol.c (revision 138273) --- gcc/fortran/symbol.c (working copy) *************** gfc_add_component (gfc_symbol *sym, cons *** 1701,1706 **** --- 1701,1714 ---- tail = p; } + if (sym->attr.extension + && gfc_find_component (sym->components->ts.derived, name)) + { + gfc_error ("Component '%s' at %C already in the parent type " + "at %L", name, &sym->components->ts.derived->declared_at); + return FAILURE; + } + /* Allocate a new component. */ p = gfc_get_component (); *************** gfc_find_component (gfc_symbol *sym, con *** 1830,1846 **** if (strcmp (p->name, name) == 0) break; if (p == NULL) gfc_error ("'%s' at %C is not a member of the '%s' structure", name, sym->name); ! else { ! if (sym->attr.use_assoc && (sym->component_access == ACCESS_PRIVATE ! || p->access == ACCESS_PRIVATE)) { gfc_error ("Component '%s' at %C is a PRIVATE component of '%s'", name, sym->name); ! p = NULL; } } --- 1838,1873 ---- if (strcmp (p->name, name) == 0) break; + if (p == NULL + && sym->attr.extension + && sym->components->ts.type == BT_DERIVED) + { + p = gfc_find_component (sym->components->ts.derived, name); + /* Do not overwrite the error. */ + if (p == NULL) + return p; + } + if (p == NULL) gfc_error ("'%s' at %C is not a member of the '%s' structure", name, sym->name); ! ! else if (sym->attr.use_assoc) { ! if (p->access == ACCESS_PRIVATE) { gfc_error ("Component '%s' at %C is a PRIVATE component of '%s'", name, sym->name); ! return NULL; ! } ! ! /* If there were components given and all components are private, error ! out at this place. */ ! if (p->access != ACCESS_PUBLIC && sym->component_access == ACCESS_PRIVATE) ! { ! gfc_error ("All components of '%s' are PRIVATE in structure" ! " constructor at %C", sym->name); ! return NULL; } } Index: gcc/fortran/decl.c =================================================================== *** gcc/fortran/decl.c (revision 138273) --- gcc/fortran/decl.c (working copy) *************** match_data_constant (gfc_expr **result) *** 367,373 **** return MATCH_ERROR; } else if (sym->attr.flavor == FL_DERIVED) ! return gfc_match_structure_constructor (sym, result); /* Check to see if the value is an initialization array expression. */ if (sym->value->expr_type == EXPR_ARRAY) --- 367,373 ---- return MATCH_ERROR; } else if (sym->attr.flavor == FL_DERIVED) ! return gfc_match_structure_constructor (sym, result, false); /* Check to see if the value is an initialization array expression. */ if (sym->value->expr_type == EXPR_ARRAY) *************** syntax: *** 6250,6255 **** --- 6250,6298 ---- } + /* Check a derived type that is being extended. */ + static gfc_symbol* + check_extended_derived_type (char *name) + { + gfc_symbol *extended; + + if (gfc_find_symbol (name, gfc_current_ns, 1, &extended)) + { + gfc_error ("Ambiguous symbol in TYPE definition at %C"); + return NULL; + } + + if (!extended) + { + gfc_error ("No such symbol in TYPE definition at %C"); + return NULL; + } + + if (extended->attr.flavor != FL_DERIVED) + { + gfc_error ("'%s' in EXTENDS expression at %C is not a " + "derived type", name); + return NULL; + } + + if (extended->attr.is_bind_c) + { + gfc_error ("'%s' cannot be extended at %C because it " + "is BIND(C)", extended->name); + return NULL; + } + + if (extended->attr.sequence) + { + gfc_error ("'%s' cannot be extended at %C because it " + "is a SEQUENCE type", extended->name); + return NULL; + } + + return extended; + } + + /* Match the optional attribute specifiers for a type declaration. Return MATCH_ERROR if an error is encountered in one of the handled attributes (public, private, bind(c)), MATCH_NO if what's found is *************** syntax: *** 6257,6263 **** checking on attribute conflicts needs to be done. */ match ! gfc_get_type_attr_spec (symbol_attribute *attr) { /* See if the derived type is marked as private. */ if (gfc_match (" , private") == MATCH_YES) --- 6300,6306 ---- checking on attribute conflicts needs to be done. */ match ! gfc_get_type_attr_spec (symbol_attribute *attr, char *name) { /* See if the derived type is marked as private. */ if (gfc_match (" , private") == MATCH_YES) *************** gfc_get_type_attr_spec (symbol_attribute *** 6295,6300 **** --- 6338,6349 ---- /* TODO: attr conflicts need to be checked, probably in symbol.c. */ } + else if (name && gfc_match(" , extends ( %n )", name) == MATCH_YES) + { + if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: derived type " + "extended at %C") == FAILURE) + return MATCH_ERROR; + } else return MATCH_NO; *************** match *** 6311,6318 **** --- 6360,6369 ---- gfc_match_derived_decl (void) { char name[GFC_MAX_SYMBOL_LEN + 1]; + char parent[GFC_MAX_SYMBOL_LEN + 1]; symbol_attribute attr; gfc_symbol *sym; + gfc_symbol *extended; match m; match is_type_attr_spec = MATCH_NO; bool seen_attr = false; *************** gfc_match_derived_decl (void) *** 6320,6336 **** if (gfc_current_state () == COMP_DERIVED) return MATCH_NO; gfc_clear_attr (&attr); do { ! is_type_attr_spec = gfc_get_type_attr_spec (&attr); if (is_type_attr_spec == MATCH_ERROR) return MATCH_ERROR; if (is_type_attr_spec == MATCH_YES) seen_attr = true; } while (is_type_attr_spec == MATCH_YES); if (gfc_match (" ::") != MATCH_YES && seen_attr) { gfc_error ("Expected :: in TYPE definition at %C"); --- 6371,6397 ---- if (gfc_current_state () == COMP_DERIVED) return MATCH_NO; + name[0] = '\0'; + parent[0] = '\0'; gfc_clear_attr (&attr); + extended = NULL; do { ! is_type_attr_spec = gfc_get_type_attr_spec (&attr, parent); if (is_type_attr_spec == MATCH_ERROR) return MATCH_ERROR; if (is_type_attr_spec == MATCH_YES) seen_attr = true; } while (is_type_attr_spec == MATCH_YES); + /* Deal with derived type extensions. */ + if (parent[0]) + extended = check_extended_derived_type (parent); + + if (parent[0] && !extended) + return MATCH_ERROR; + if (gfc_match (" ::") != MATCH_YES && seen_attr) { gfc_error ("Expected :: in TYPE definition at %C"); *************** gfc_match_derived_decl (void) *** 6383,6392 **** --- 6444,6477 ---- if (attr.is_bind_c != 0) sym->attr.is_bind_c = attr.is_bind_c; + /* Construct the f2k_derived namespace if it is not yet there. */ if (!sym->f2k_derived) sym->f2k_derived = gfc_get_namespace (NULL, 0); + + if (extended && !sym->components) + { + gfc_component *p; + gfc_symtree *st; + + /* Add the extended derived type as the first component. */ + gfc_add_component (sym, parent, &p); + sym->attr.extension = 1; + extended->refs++; + gfc_set_sym_referenced (extended); + + p->ts.type = BT_DERIVED; + p->ts.derived = extended; + p->initializer = gfc_default_initializer (&p->ts); + + /* Provide the links between the extended type and its extension. */ + if (!extended->f2k_derived) + extended->f2k_derived = gfc_get_namespace (NULL, 0); + st = gfc_new_symtree (&extended->f2k_derived->sym_root, sym->name); + st->n.sym = sym; + } + gfc_new_block = sym; return MATCH_YES; Index: gcc/fortran/gfortran.h =================================================================== *** gcc/fortran/gfortran.h (revision 138273) --- gcc/fortran/gfortran.h (working copy) *************** typedef struct *** 638,643 **** --- 638,644 ---- unsigned untyped:1; /* No implicit type could be found. */ unsigned is_bind_c:1; /* say if is bound to C */ + unsigned extension:1; /* extends a derived type */ /* These flags are both in the typespec and attribute. The attribute list is what gets read from/written to a module file. The typespec *************** typedef struct gfc_symbol *** 1016,1024 **** gfc_formal_arglist *formal; struct gfc_namespace *formal_ns; - - /* The namespace containing type-associated procedure symbols. */ - /* TODO: Make this union with formal? */ struct gfc_namespace *f2k_derived; struct gfc_expr *value; /* Parameter/Initializer value */ --- 1017,1022 ---- Index: gcc/fortran/ChangeLog =================================================================== *** gcc/fortran/ChangeLog (revision 138273) --- gcc/fortran/ChangeLog (working copy) *************** *** 1,3 **** --- 1,42 ---- + 2008-07-29 Paul Thomas <pault@gcc.gnu.org> + + * trans-expr.c (conv_parent_component_references): New function + to build missing parent references. + (gfc_conv_variable): Call it + * symbol.c (gfc_add_component): Check that component name in a + derived type extension does not appear in parent. + (gfc_find_component): For a derived type extension, check if + the component appears in the parent derived type by calling + self. Separate errors for private components and private types. + * decl.c (match_data_constant): Add extra arg to call to + gfc_match_structure_constructor. + (check_extended_derived_type): New function to check that a + parent derived type exists and that it is OK for exension. + (gfc_get_type_attr_spec): Add extra argument 'name' and return + it if extends is specified. + (gfc_match_derived_decl): Match derived type extension and + build a first component of the parent derived type if OK. Add + the f2k namespace if not present. + * gfortran.h : Add the extension attribute. + * module.c : Handle attribute 'extension'. + * match.h : Modify prototypes for gfc_get_type_attr_spec and + gfc_match_structure_constructor. + * primary.c (build_actual_constructor): New function extracted + from gfc_match_structure_constructor and modified to call self + iteratively to build derived type extensions, when f2k named + components are used. + (gfc_match_structure_constructor): Do not throw error for too + many components if a parent type is being handled. Use + gfc_find_component to generate errors for non-existent or + private components. Iteratively call self for derived type + extensions so that parent constructor is built. If extension + and components left over, throw error. + (gfc_match_rvalue): Add extra arg to call to + gfc_match_structure_constructor. + + * trans-array.c (gfc_conv_resolve_dependencies): If lhs and rhs + are the same symbol, aliassing does not matter. + 2008-07-29 Jan Hubicka <jh@suse.cz> * options.c (gfc_post_options): Do not set flag_no_inline. Index: gcc/fortran/module.c =================================================================== *** gcc/fortran/module.c (revision 138273) --- gcc/fortran/module.c (working copy) *************** typedef enum *** 1648,1654 **** AB_ELEMENTAL, AB_PURE, AB_RECURSIVE, AB_GENERIC, AB_ALWAYS_EXPLICIT, AB_CRAY_POINTER, AB_CRAY_POINTEE, AB_THREADPRIVATE, AB_ALLOC_COMP, AB_POINTER_COMP, AB_PRIVATE_COMP, AB_VALUE, AB_VOLATILE, AB_PROTECTED, ! AB_IS_BIND_C, AB_IS_C_INTEROP, AB_IS_ISO_C, AB_ABSTRACT, AB_ZERO_COMP } ab_attribute; --- 1648,1655 ---- AB_ELEMENTAL, AB_PURE, AB_RECURSIVE, AB_GENERIC, AB_ALWAYS_EXPLICIT, AB_CRAY_POINTER, AB_CRAY_POINTEE, AB_THREADPRIVATE, AB_ALLOC_COMP, AB_POINTER_COMP, AB_PRIVATE_COMP, AB_VALUE, AB_VOLATILE, AB_PROTECTED, ! AB_IS_BIND_C, AB_IS_C_INTEROP, AB_IS_ISO_C, AB_ABSTRACT, AB_ZERO_COMP, ! AB_EXTENSION } ab_attribute; *************** static const mstring attr_bits[] = *** 1688,1693 **** --- 1689,1695 ---- minit ("ZERO_COMP", AB_ZERO_COMP), minit ("PROTECTED", AB_PROTECTED), minit ("ABSTRACT", AB_ABSTRACT), + minit ("EXTENSION", AB_EXTENSION), minit (NULL, -1) }; *************** mio_symbol_attribute (symbol_attribute * *** 1801,1806 **** --- 1803,1810 ---- MIO_NAME (ab_attribute) (AB_PRIVATE_COMP, attr_bits); if (attr->zero_comp) MIO_NAME (ab_attribute) (AB_ZERO_COMP, attr_bits); + if (attr->extension) + MIO_NAME (ab_attribute) (AB_EXTENSION, attr_bits); mio_rparen (); *************** mio_symbol_attribute (symbol_attribute * *** 1919,1924 **** --- 1923,1931 ---- case AB_ZERO_COMP: attr->zero_comp = 1; break; + case AB_EXTENSION: + attr->extension = 1; + break; } } } Index: gcc/fortran/trans-io.c =================================================================== *** gcc/fortran/trans-io.c (revision 138273) --- gcc/fortran/trans-io.c (working copy) *************** *** 1,6 **** /* IO Code translation/library interface ! Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software ! Foundation, Inc. Contributed by Paul Brook This file is part of GCC. --- 1,6 ---- /* IO Code translation/library interface ! Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 ! Free Software Foundation, Inc. Contributed by Paul Brook This file is part of GCC. Index: gcc/fortran/match.h =================================================================== *** gcc/fortran/match.h (revision 138273) --- gcc/fortran/match.h (working copy) *************** gfc_try get_bind_c_idents (void); *** 182,191 **** match gfc_match_bind_c_stmt (void); match gfc_match_suffix (gfc_symbol *, gfc_symbol **); match gfc_match_bind_c (gfc_symbol *, bool); ! match gfc_get_type_attr_spec (symbol_attribute *); /* primary.c. */ ! match gfc_match_structure_constructor (gfc_symbol *, gfc_expr **); match gfc_match_variable (gfc_expr **, int); match gfc_match_equiv_variable (gfc_expr **); match gfc_match_actual_arglist (int, gfc_actual_arglist **); --- 182,191 ---- match gfc_match_bind_c_stmt (void); match gfc_match_suffix (gfc_symbol *, gfc_symbol **); match gfc_match_bind_c (gfc_symbol *, bool); ! match gfc_get_type_attr_spec (symbol_attribute *, char*); /* primary.c. */ ! match gfc_match_structure_constructor (gfc_symbol *, gfc_expr **, bool); match gfc_match_variable (gfc_expr **, int); match gfc_match_equiv_variable (gfc_expr **); match gfc_match_actual_arglist (int, gfc_actual_arglist **); Index: gcc/fortran/primary.c =================================================================== *** gcc/fortran/primary.c (revision 138273) --- gcc/fortran/primary.c (working copy) *************** gfc_free_structure_ctor_component (gfc_s *** 1984,1994 **** gfc_free_expr (comp->val); } ! match ! gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result) { - gfc_structure_ctor_component *comp_head, *comp_tail; gfc_structure_ctor_component *comp_iter; gfc_constructor *ctor_head, *ctor_tail; gfc_component *comp; /* Is set NULL when named component is first seen */ gfc_expr *e; --- 1984,2086 ---- gfc_free_expr (comp->val); } ! ! /* Translate the component list into the actual constructor by sorting it in ! the order required; this also checks along the way that each and every ! component actually has an initializer and handles default initializers ! for components without explicit value given. */ ! static gfc_try ! build_actual_constructor (gfc_structure_ctor_component **comp_head, ! gfc_constructor **ctor_head, gfc_symbol *sym) { gfc_structure_ctor_component *comp_iter; + gfc_constructor *ctor_tail = NULL; + gfc_component *comp; + + for (comp = sym->components; comp; comp = comp->next) + { + gfc_structure_ctor_component **next_ptr; + gfc_expr *value = NULL; + + /* Try to find the initializer for the current component by name. */ + next_ptr = comp_head; + for (comp_iter = *comp_head; comp_iter; comp_iter = comp_iter->next) + { + if (!strcmp (comp_iter->name, comp->name)) + break; + next_ptr = &comp_iter->next; + } + + /* If an extension, try building the parent derived type by building + a value expression for the parent derived type and calling self. */ + if (!comp_iter && comp == sym->components && sym->attr.extension) + { + value = gfc_get_expr (); + value->expr_type = EXPR_STRUCTURE; + value->value.constructor = NULL; + value->ts = comp->ts; + value->where = gfc_current_locus; + + if (build_actual_constructor (comp_head, &value->value.constructor, + comp->ts.derived) == FAILURE) + { + gfc_free_expr (value); + return FAILURE; + } + *ctor_head = ctor_tail = gfc_get_constructor (); + ctor_tail->expr = value; + continue; + } + + /* If it was not found, try the default initializer if there's any; + otherwise, it's an error. */ + if (!comp_iter) + { + if (comp->initializer) + { + if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: Structure" + " constructor with missing optional arguments" + " at %C") == FAILURE) + return FAILURE; + value = gfc_copy_expr (comp->initializer); + } + else + { + gfc_error ("No initializer for component '%s' given in the" + " structure constructor at %C!", comp->name); + return FAILURE; + } + } + else + value = comp_iter->val; + + /* Add the value to the constructor chain built. */ + if (ctor_tail) + { + ctor_tail->next = gfc_get_constructor (); + ctor_tail = ctor_tail->next; + } + else + *ctor_head = ctor_tail = gfc_get_constructor (); + gcc_assert (value); + ctor_tail->expr = value; + + /* Remove the entry from the component list. We don't want the expression + value to be free'd, so set it to NULL. */ + if (comp_iter) + { + *next_ptr = comp_iter->next; + comp_iter->val = NULL; + gfc_free_structure_ctor_component (comp_iter); + } + } + return SUCCESS; + } + + match + gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result, bool parent) + { + gfc_structure_ctor_component *comp_tail, *comp_head, *comp_iter; gfc_constructor *ctor_head, *ctor_tail; gfc_component *comp; /* Is set NULL when named component is first seen */ gfc_expr *e; *************** gfc_match_structure_constructor (gfc_sym *** 1996,2005 **** match m; const char* last_name = NULL; ! comp_head = comp_tail = NULL; ctor_head = ctor_tail = NULL; ! if (gfc_match_char ('(') != MATCH_YES) goto syntax; where = gfc_current_locus; --- 2088,2097 ---- match m; const char* last_name = NULL; ! comp_tail = comp_head = NULL; ctor_head = ctor_tail = NULL; ! if (!parent && gfc_match_char ('(') != MATCH_YES) goto syntax; where = gfc_current_locus; *************** gfc_match_structure_constructor (gfc_sym *** 2047,2053 **** if (last_name) gfc_error ("Component initializer without name after" " component named %s at %C!", last_name); ! else gfc_error ("Too many components in structure constructor at" " %C!"); goto cleanup; --- 2139,2145 ---- if (last_name) gfc_error ("Component initializer without name after" " component named %s at %C!", last_name); ! else if (!parent) gfc_error ("Too many components in structure constructor at" " %C!"); goto cleanup; *************** gfc_match_structure_constructor (gfc_sym *** 2057,2095 **** strncpy (comp_tail->name, comp->name, GFC_MAX_SYMBOL_LEN + 1); } ! /* Find the current component in the structure definition; this is ! needed to get its access attribute in the private check below. */ if (comp) ! this_comp = comp; else { ! for (comp = sym->components; comp; comp = comp->next) ! if (!strcmp (comp->name, comp_tail->name)) ! { ! this_comp = comp; ! break; ! } comp = NULL; /* Reset needed! */ - - /* Here we can check if a component name is given which does not - correspond to any component of the defined structure. */ - if (!this_comp) - { - gfc_error ("Component '%s' in structure constructor at %C" - " does not correspond to any component in the" - " constructed structure!", comp_tail->name); - goto cleanup; - } } - gcc_assert (this_comp); ! /* Check the current component's access status. */ ! if (sym->attr.use_assoc && this_comp->access == ACCESS_PRIVATE) ! { ! gfc_error ("Component '%s' is PRIVATE in structure constructor" ! " at %C!", comp_tail->name); ! goto cleanup; ! } /* Check if this component is already given a value. */ for (comp_iter = comp_head; comp_iter != comp_tail; --- 2149,2168 ---- strncpy (comp_tail->name, comp->name, GFC_MAX_SYMBOL_LEN + 1); } ! /* Find the current component in the structure definition and check its ! access is not private. */ if (comp) ! this_comp = gfc_find_component (sym, comp->name); else { ! this_comp = gfc_find_component (sym, (const char *)comp_tail->name); comp = NULL; /* Reset needed! */ } ! /* Here we can check if a component name is given which does not ! correspond to any component of the defined structure. */ ! if (!this_comp) ! goto cleanup; /* Check if this component is already given a value. */ for (comp_iter = comp_head; comp_iter != comp_tail; *************** gfc_match_structure_constructor (gfc_sym *** 2111,2199 **** if (m == MATCH_ERROR) goto cleanup; ! if (comp) comp = comp->next; } while (gfc_match_char (',') == MATCH_YES); ! if (gfc_match_char (')') != MATCH_YES) goto syntax; - - /* If there were components given and all components are private, error - out at this place. */ - if (sym->attr.use_assoc && sym->component_access == ACCESS_PRIVATE) - { - gfc_error ("All components of '%s' are PRIVATE in structure" - " constructor at %C", sym->name); - goto cleanup; - } } ! /* Translate the component list into the actual constructor by sorting it in ! the order required; this also checks along the way that each and every ! component actually has an initializer and handles default initializers ! for components without explicit value given. */ ! for (comp = sym->components; comp; comp = comp->next) ! { ! gfc_structure_ctor_component **next_ptr; ! gfc_expr *value = NULL; ! /* Try to find the initializer for the current component by name. */ ! next_ptr = &comp_head; for (comp_iter = comp_head; comp_iter; comp_iter = comp_iter->next) { ! if (!strcmp (comp_iter->name, comp->name)) ! break; ! next_ptr = &comp_iter->next; ! } ! ! /* If it was not found, try the default initializer if there's any; ! otherwise, it's an error. */ ! if (!comp_iter) ! { ! if (comp->initializer) ! { ! if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: Structure" ! " constructor with missing optional arguments" ! " at %C") == FAILURE) ! goto cleanup; ! value = gfc_copy_expr (comp->initializer); ! } ! else ! { ! gfc_error ("No initializer for component '%s' given in the" ! " structure constructor at %C!", comp->name); ! goto cleanup; ! } ! } ! else ! value = comp_iter->val; ! ! /* Add the value to the constructor chain built. */ ! if (ctor_tail) ! { ! ctor_tail->next = gfc_get_constructor (); ! ctor_tail = ctor_tail->next; ! } ! else ! ctor_head = ctor_tail = gfc_get_constructor (); ! gcc_assert (value); ! ctor_tail->expr = value; ! ! /* Remove the entry from the component list. We don't want the expression ! value to be free'd, so set it to NULL. */ ! if (comp_iter) ! { ! *next_ptr = comp_iter->next; ! comp_iter->val = NULL; ! gfc_free_structure_ctor_component (comp_iter); } } ! ! /* No component should be left, as this should have caused an error in the ! loop constructing the component-list (name that does not correspond to any ! component in the structure definition). */ ! gcc_assert (!comp_head); e = gfc_get_expr (); --- 2184,2239 ---- if (m == MATCH_ERROR) goto cleanup; ! /* If not explicitly a parent constructor, gather up the components ! and build one. */ ! if (comp && comp == sym->components ! && sym->attr.extension ! && (comp_tail->val->ts.type != BT_DERIVED ! || ! comp_tail->val->ts.derived != this_comp->ts.derived)) ! { ! gfc_current_locus = where; ! gfc_free_expr (comp_tail->val); ! ! m = gfc_match_structure_constructor (comp->ts.derived, ! &comp_tail->val, true); ! if (m == MATCH_NO) ! goto syntax; ! if (m == MATCH_ERROR) ! goto cleanup; ! } ! ! if (comp) comp = comp->next; + + if (parent && !comp) + break; } + while (gfc_match_char (',') == MATCH_YES); ! if (!parent && gfc_match_char (')') != MATCH_YES) goto syntax; } ! if (build_actual_constructor (&comp_head, &ctor_head, sym) == FAILURE) ! goto cleanup; ! /* No component should be left, as this should have caused an error in the ! loop constructing the component-list (name that does not correspond to any ! component in the structure definition). */ ! if (comp_head && sym->attr.extension) ! { for (comp_iter = comp_head; comp_iter; comp_iter = comp_iter->next) { ! gfc_error ("component '%s' at %L has already been set by a " ! "parent derived type constructor", comp_iter->name, ! &comp_iter->where); } + goto cleanup; } ! else ! gcc_assert (!comp_head); e = gfc_get_expr (); *************** gfc_match_rvalue (gfc_expr **result) *** 2396,2402 **** if (sym == NULL) m = MATCH_ERROR; else ! m = gfc_match_structure_constructor (sym, &e); break; /* If we're here, then the name is known to be the name of a --- 2436,2442 ---- if (sym == NULL) m = MATCH_ERROR; else ! m = gfc_match_structure_constructor (sym, &e, false); break; /* If we're here, then the name is known to be the name of a Index: gcc/testsuite/ChangeLog =================================================================== *** gcc/testsuite/ChangeLog (revision 138273) --- gcc/testsuite/ChangeLog (working copy) *************** *** 1,3 **** --- 1,15 ---- + 2008-07-29 Paul Thomas <pault@gcc.gnu.org> + + * gfortran.dg/extends_1.f03: New test. + * gfortran.dg/extends_2.f03: New test. + * gfortran.dg/extends_3.f03: New test. + * gfortran.dg/extends_4.f03: New test. + * gfortran.dg/extends_5.f03: New test. + * gfortran.dg/extends_6.f03: New test. + * gfortran.dg/private_type_6.f90: Modify error message. + * gfortran.dg/structure_constructor_7.f03: Modify error message. + * gfortran.dg/structure_constructor_8.f03: Modify error message. + 2008-07-29 Richard Guenther <rguenther@suse.de> PR tree-optimization/36945 Index: gcc/testsuite/gfortran.dg/extends_1.f03 =================================================================== *** gcc/testsuite/gfortran.dg/extends_1.f03 (revision 0) --- gcc/testsuite/gfortran.dg/extends_1.f03 (revision 0) *************** *** 0 **** --- 1,73 ---- + ! { dg-do run } + ! A basic functional test of derived type extension. + ! + ! Contributed by Paul Thomas <pault@gcc.gnu.org> + ! + module persons + type :: person + character(24) :: name = "" + integer :: ss = 1 + end type person + end module persons + + module person_education + use persons + type, extends(person) :: education + integer :: attainment = 0 + character(24) :: institution = "" + end type education + end module person_education + + use person_education + type, extends(education) :: service + integer :: personnel_number = 0 + character(24) :: department = "" + end type service + + type, extends(service) :: person_record + type (person_record), pointer :: supervisor => NULL () + end type person_record + + type(person_record), pointer :: recruit, supervisor + + ! Check that references by ultimate component work + + allocate (supervisor) + supervisor%name = "Joe Honcho" + supervisor%ss = 123455 + supervisor%attainment = 100 + supervisor%institution = "Celestial University" + supervisor%personnel_number = 1 + supervisor%department = "Directorate" + + recruit => entry ("John Smith", 123456, 1, "Bog Hill High School", & + 99, "Records", supervisor) + + if (trim (recruit%name) /= "John Smith") call abort + if (recruit%name /= recruit%service%name) call abort + if (recruit%supervisor%ss /= 123455) call abort + if (recruit%supervisor%ss /= supervisor%person%ss) call abort + + deallocate (supervisor) + deallocate (recruit) + contains + function entry (name, ss, attainment, institution, & + personnel_number, department, supervisor) result (new_person) + integer :: ss, attainment, personnel_number + character (*) :: name, institution, department + type (person_record), pointer :: supervisor, new_person + + allocate (new_person) + + ! Check mixtures of references + new_person%person%name = name + new_person%service%education%person%ss = ss + new_person%service%attainment = attainment + new_person%education%institution = institution + new_person%personnel_number = personnel_number + new_person%service%department = department + new_person%supervisor => supervisor + end function + end + + ! { dg-final { cleanup-modules "persons person_education" } } Index: gcc/testsuite/gfortran.dg/extends_2.f03 =================================================================== *** gcc/testsuite/gfortran.dg/extends_2.f03 (revision 0) --- gcc/testsuite/gfortran.dg/extends_2.f03 (revision 0) *************** *** 0 **** --- 1,66 ---- + ! { dg-do run } + ! A test of f95 style constructors with derived type extension. + ! + ! Contributed by Paul Thomas <pault@gcc.gnu.org> + ! + module persons + type :: person + character(24) :: name = "" + integer :: ss = 1 + end type person + end module persons + + module person_education + use persons + type, extends(person) :: education + integer :: attainment = 0 + character(24) :: institution = "" + end type education + end module person_education + + use person_education + type, extends(education) :: service + integer :: personnel_number = 0 + character(24) :: department = "" + end type service + + type, extends(service) :: person_record + type (person_record), pointer :: supervisor => NULL () + end type person_record + + type(person_record), pointer :: recruit, supervisor + + ! Check that simple constructor works + allocate (supervisor) + supervisor%service = service ("Joe Honcho", 123455, 100, & + "Celestial University", 1, & + "Directorate") + + recruit => entry ("John Smith", 123456, 1, "Bog Hill High School", & + 99, "Records", supervisor) + + if (trim (recruit%name) /= "John Smith") call abort + if (recruit%name /= recruit%service%name) call abort + if (recruit%supervisor%ss /= 123455) call abort + if (recruit%supervisor%ss /= supervisor%person%ss) call abort + + deallocate (supervisor) + deallocate (recruit) + contains + function entry (name, ss, attainment, institution, & + personnel_number, department, supervisor) result (new_person) + integer :: ss, attainment, personnel_number + character (*) :: name, institution, department + type (person_record), pointer :: supervisor, new_person + + allocate (new_person) + + ! Check nested constructors + new_person = person_record (education (person (name, ss), & + attainment, institution), & + personnel_number, department, & + supervisor) + end function + end + + ! { dg-final { cleanup-modules "persons person_education" } } Index: gcc/testsuite/gfortran.dg/extends_3.f03 =================================================================== *** gcc/testsuite/gfortran.dg/extends_3.f03 (revision 0) --- gcc/testsuite/gfortran.dg/extends_3.f03 (revision 0) *************** *** 0 **** --- 1,71 ---- + ! { dg-do run } + ! A test of f2k style constructors with derived type extension. + ! + ! Contributed by Paul Thomas <pault@gcc.gnu.org> + ! + module persons + type :: person + character(24) :: name = "" + integer :: ss = 1 + end type person + end module persons + + module person_education + use persons + type, extends(person) :: education + integer :: attainment = 0 + character(24) :: institution = "" + end type education + end module person_education + + use person_education + type, extends(education) :: service + integer :: personnel_number = 0 + character(24) :: department = "" + end type service + + type, extends(service) :: person_record + type (person_record), pointer :: supervisor => NULL () + end type person_record + + type(person_record), pointer :: recruit, supervisor + + ! Check that F2K constructor with missing entries works + allocate (supervisor) + supervisor%service = service (NAME = "Joe Honcho", SS= 123455) + + recruit => entry ("John Smith", 123456, 1, "Bog Hill High School", & + 99, "Records", supervisor) + + if (supervisor%ss /= 123455) call abort + if (trim (supervisor%name) /= "Joe Honcho") call abort + if (trim (supervisor%institution) /= "") call abort + if (supervisor%attainment /= 0) call abort + + if (trim (recruit%name) /= "John Smith") call abort + if (recruit%name /= recruit%service%name) call abort + if (recruit%supervisor%ss /= 123455) call abort + if (recruit%supervisor%ss /= supervisor%person%ss) call abort + + deallocate (supervisor) + deallocate (recruit) + contains + function entry (name, ss, attainment, institution, & + personnel_number, department, supervisor) result (new_person) + integer :: ss, attainment, personnel_number + character (*) :: name, institution, department + type (person_record), pointer :: supervisor, new_person + + allocate (new_person) + + ! Check F2K constructor with order shuffled a bit + new_person = person_record (NAME = name, SS =ss, & + DEPARTMENT = department, & + INSTITUTION = institution, & + PERSONNEL_NUMBER = personnel_number, & + ATTAINMENT = attainment, & + SUPERVISOR = supervisor) + end function + end + + ! { dg-final { cleanup-modules "persons person_education" } } Index: gcc/testsuite/gfortran.dg/extends_4.f03 =================================================================== *** gcc/testsuite/gfortran.dg/extends_4.f03 (revision 0) --- gcc/testsuite/gfortran.dg/extends_4.f03 (revision 0) *************** *** 0 **** --- 1,52 ---- + ! { dg-do run } + ! Check that derived type extension is compatible with renaming + ! the parent type and that allocatable components are OK. At + ! the same time, private type and components are checked. + ! + ! Contributed by Paul Thomas <pault@gcc.gnu.org> + ! + module mymod + type :: a + real, allocatable :: x(:) + integer, private :: ia = 0 + end type a + type :: b + private + real, allocatable :: x(:) + integer :: i + end type b + contains + function set_b () result (res) + type(b) :: res + allocate (res%x(2)) + res%x = [10.0, 20.0] + res%i = 1 + end function + subroutine check_b (arg) + type(b) :: arg + if (any (arg%x /= [10.0, 20.0])) call abort + if (arg%i /= 1) call abort + end subroutine + end module mymod + + use mymod, e => a + type, extends(e) :: f + integer :: if + end type f + type, extends(b) :: d + integer :: id + end type d + + type(f) :: p + type(d) :: q + + p = f (x = [1.0, 2.0], if = 3) + if (any (p%e%x /= [1.0, 2.0])) call abort + + q%b = set_b () + call check_b (q%b) + q = d (b = set_b (), id = 99) + call check_b (q%b) + end + + ! { dg-final { cleanup-modules "persons person_education" } } Index: gcc/testsuite/gfortran.dg/extends_5.f03 =================================================================== *** gcc/testsuite/gfortran.dg/extends_5.f03 (revision 0) --- gcc/testsuite/gfortran.dg/extends_5.f03 (revision 0) *************** *** 0 **** --- 1,27 ---- + ! { dg-do compile } + ! Some errors for derived type extension. + ! + ! Contributed by Paul Thomas <pault@gcc.gnu.org> + ! + module m + use iso_c_binding + type :: date + sequence + integer :: yr, mon + integer,public :: day + end type + type, bind(c) :: dt + integer(c_int) :: yr, mon + integer(c_int) :: day + end type + end module m + + use m + type, extends(date) :: datetime ! { dg-error "because it is a SEQUENCE type" } + end type ! { dg-error "Expecting END PROGRAM" } + + type, extends(dt) :: dt_type ! { dg-error "because it is BIND" } + end type ! { dg-error "Expecting END PROGRAM" } + end + + ! { dg-final { cleanup-modules "m" } } Index: gcc/testsuite/gfortran.dg/extends_6.f03 =================================================================== *** gcc/testsuite/gfortran.dg/extends_6.f03 (revision 0) --- gcc/testsuite/gfortran.dg/extends_6.f03 (revision 0) *************** *** 0 **** --- 1,49 ---- + ! { dg-do compile } + ! Some errors pointed out in the development of the patch. + ! + ! Contributed by Tobias Burnus <burnus@net-b.de> + ! + module m + type :: date + private + integer :: yr, mon + integer,public :: day + end type + type :: dt + integer :: yr, mon + integer :: day + end type + end module m + + use m + type, extends(date) :: datetime + integer :: hr, min, sec + end type + type(datetime) :: o_dt + + type :: one + integer :: i + end type one + + type, extends(one) :: two + real :: r + end type two + + o_dt%day = 5 ! VALID but failed in first version of EXTENDS patch + o_dt%yr = 5 ! { dg-error "All components of 'date' are PRIVATE" } + + t = two(one = one(4), i = 5, r=4.4) ! { dg-error "has already been set" } + + call foo + contains + subroutine foo + use m, date_type => dt + type, extends(date_type) :: dt_type + end type + type (dt_type) :: foo_dt + foo_dt%date_type%day = 1 + foo_dt%dt%day = 1 ! { dg-error "not a member" } + end subroutine + end + + ! { dg-final { cleanup-modules "m" } } Index: gcc/testsuite/gfortran.dg/private_type_6.f90 =================================================================== *** gcc/testsuite/gfortran.dg/private_type_6.f90 (revision 138273) --- gcc/testsuite/gfortran.dg/private_type_6.f90 (working copy) *************** program foo_test *** 19,25 **** TYPE(footype) :: foo TYPE(bartype) :: foo2 foo = footype(1) ! { dg-error "All components of 'footype' are PRIVATE" } ! foo2 = bartype(1,2) ! { dg-error "'dummy2' is PRIVATE" } foo2%dummy2 = 5 ! { dg-error "is a PRIVATE component" } end program foo_test ! { dg-final { cleanup-modules "foomod" } } --- 19,25 ---- TYPE(footype) :: foo TYPE(bartype) :: foo2 foo = footype(1) ! { dg-error "All components of 'footype' are PRIVATE" } ! foo2 = bartype(1,2) ! { dg-error "is a PRIVATE component" } foo2%dummy2 = 5 ! { dg-error "is a PRIVATE component" } end program foo_test ! { dg-final { cleanup-modules "foomod" } } Index: gcc/testsuite/gfortran.dg/structure_constructor_7.f03 =================================================================== *** gcc/testsuite/gfortran.dg/structure_constructor_7.f03 (revision 138273) --- gcc/testsuite/gfortran.dg/structure_constructor_7.f03 (working copy) *************** PROGRAM test *** 13,18 **** TYPE(basics_t) :: basics basics = basics_t (42, 1.5, 1000) ! { dg-error "Too many components" } ! basics = basics_t (42, xxx = 1000) ! { dg-error "Component 'xxx'" } END PROGRAM test --- 13,18 ---- TYPE(basics_t) :: basics basics = basics_t (42, 1.5, 1000) ! { dg-error "Too many components" } ! basics = basics_t (42, xxx = 1000) ! { dg-error "is not a member" } END PROGRAM test Index: gcc/testsuite/gfortran.dg/structure_constructor_8.f03 =================================================================== *** gcc/testsuite/gfortran.dg/structure_constructor_8.f03 (revision 138273) --- gcc/testsuite/gfortran.dg/structure_constructor_8.f03 (working copy) *************** PROGRAM test *** 47,54 **** struct2 = allpriv_t () ! These should fail ! struct1 = haspriv_t (1, 2) ! { dg-error "'b' is PRIVATE" } ! struct1 = haspriv_t (b = 2, a = 1) ! { dg-error "'b' is PRIVATE" } ! This should fail as all components are private struct2 = allpriv_t (5) ! { dg-error "of 'allpriv_t' are PRIVATE" } --- 47,54 ---- struct2 = allpriv_t () ! These should fail ! struct1 = haspriv_t (1, 2) ! { dg-error "is a PRIVATE component" } ! struct1 = haspriv_t (b = 2, a = 1) ! { dg-error "is a PRIVATE component" } ! This should fail as all components are private struct2 = allpriv_t (5) ! { dg-error "of 'allpriv_t' are PRIVATE" } git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138275 138bc75d-0d04-0410-961f-82ee72b054a4
-