Commit Graph

348 Commits

Author SHA1 Message Date
Harald Anlauf 8f87c1ab9b backport: re PR fortran/83864 (ICE in gfc_apply_init, at fortran/expr.c:4271)
2018-01-18  Harald Anlauf  <anlauf@gmx.de>

	Backport from mainline
	PR fortran/83864
	* expr.c (gfc_apply_init): Do not dereference NULL pointer.

2018-01-18  Harald Anlauf  <anlauf@gmx.de>

	Backport from mainline
	PR fortran/83864
	* gfortran.dg/pr83864.f90: New test.

From-SVN: r256857
2018-01-18 18:27:22 +00:00
Thomas Koenig 0efe5ea92c backport: re PR fortran/80118 (ICE with zero size parameter array)
2017-10-03  Thomas Koenig  <tkoenig@gcc.gnu.org>
	    Steven G. Kargl  <kargl@gcc.gnu.org>

	Backport from trunk
	PR fortran/80118
	* expr.c (gfc_get_full_arrayspec_from_expr): If there is
	no symtree, set array spec to NULL.

2017-10-03  Thomas Koenig  <tkoenig@gcc.gnu.org>
	    Steven G. Kargl  <kargl@gcc.gnu.org>

	Backport from trunk
	PR fortran/80118
	* gfortran.dg/zero_sized_7.f90: New test.



Co-Authored-By: Steven G. Kargl <kargl@gcc.gnu.org>

From-SVN: r253383
2017-10-03 15:50:45 +00:00
Janus Weil ef28b00460 backport: re PR fortran/81770 (Bogus warning: Pointer in pointer assignment might outlive the pointer target)
2017-09-02  Janus Weil  <janus@gcc.gnu.org>

	Backport from trunk
	PR fortran/81770
	* expr.c (gfc_check_pointer_assign): Improve the check whether pointer
	may outlive pointer target.


2017-09-02  Janus Weil  <janus@gcc.gnu.org>

	Backport from trunk
	PR fortran/81770
	* gfortran.dg/warn_target_lifetime_3.f90: Fix a typo.
	* gfortran.dg/warn_target_lifetime_4.f90: New testcase.

From-SVN: r251618
2017-09-02 21:04:08 +02:00
Steven G. Kargl 4fc88affeb re PR fortran/80752 (ICE with wrong type initialization)
2017-05-15  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/80752
	* expr.c (gfc_generate_initializer):  If type conversion fails,
	check for error and return NULL.

2017-05-15  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/80752
	gfortran.dg/pr80752.f90: New test.

From-SVN: r248076
2017-05-15 20:43:25 +00:00
Janus Weil 99827b5ca0 re PR fortran/80046 ([F03] Explicit interface required: pointer argument)
2017-04-10  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/80046
	* expr.c (gfc_check_pointer_assign): Check if procedure pointer
	components in a pointer assignment need an explicit interface.

2017-04-10  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/80046
	* gfortran.dg/proc_ptr_comp_48.f90: New test case.

From-SVN: r246823
2017-04-10 22:28:23 +02:00
Dominique d'Humieres 2f029c0898 re PR fortran/79602 (translation: globally replace '%s' with %qs)
2017-03-22  Dominique d'Humieres  <dominiq@lps.ens.fr>

	PR fortran/79602
	* decl.c: Replace '%s' with %qs.
	* expr.c: Likewise.
	* interface.c: Likewise.
	* match.c: Likewise.
	* primary.c: Likewise.
	* resolve.c: Likewise.

	PR fortran/79844
	PR fortran/80011
	* io.c: Remove trailing spaces.
	* match.c: Likewise.
	* openmp.c: Likewise.
	* resolve.c: Likewise.
	* trans-intrinsic.c: Likewise.

	PR fortran/79853
	* expr.c: Remove a double spaces.

	PR fortran/79859
	* primary.c: Remove spurious quotes around %qs.

From-SVN: r246391
2017-03-22 17:29:30 +01:00
Jakub Jelinek 51f03c6b11 gfortran.h (gfc_extract_int): Change return type to bool.
* gfortran.h (gfc_extract_int): Change return type to bool.  Add
	int argument with = 0.
	* decl.c (gfc_match_kind_spec): Adjust gfc_extract_int caller, pass
	1 as new last argument to it, don't emit gfc_error.
	(match_char_kind): Likewise.
	(gfc_match_decl_type_spec): Use gfc_get_string ("%s", x) instead of
	gfc_get_string (x).
	(gfc_match_derived_decl, match_binding_attributes): Likewise.
	(gfc_match_structure_decl): Don't sprintf back to name, call
	get_struct_decl directly with gfc_dt_upper_string (name) result.
	* trans-stmt.c (gfc_trans_allocate): Use gfc_get_string ("%s", x)
	instead of gfc_get_string (x).
	* module.c (gfc_dt_lower_string, gfc_dt_upper_string,
	gfc_match_use, gfc_match_submodule, find_true_name, mio_pool_string,
	mio_symtree_ref, mio_expr, mio_omp_udr_expr, load_generic_interfaces,
	load_omp_udrs, load_needed, read_module, dump_module,
	create_intrinsic_function, import_iso_c_binding_module,
	create_int_parameter, create_int_parameter_array, create_derived_type,
	use_iso_fortran_env_module): Likewise.
	* error.c (gfc_diagnostic_starter, gfc_diagnostic_start_span): Use
	pp_verbatim (context->printer, "%s", x) instead of
	pp_verbatim (context->printer, x).
	* match.c (gfc_match_small_int): Adjust gfc_extract_int caller, pass
	1 as new last argument to it, don't emit gfc_error.
	(gfc_match_small_int_expr): Likewise.
	* iresolve.c (gfc_get_string): Optimize format "%s" case.
	(resolve_bound): Use gfc_get_string ("%s", x) instead of
	gfc_get_string (x).
	(resolve_transformational): Formatting fix.
	(gfc_resolve_char_achar): Change name argument to bool is_achar,
	use a single format string and if is_achar add "a" before "char".
	(gfc_resolve_achar, gfc_resolve_char): Adjust callers.
	* expr.c (gfc_extract_int): Change return type to bool, return true
	if some error occurred.  Add REPORT_ERROR argument, if non-zero
	call either gfc_error or gfc_error_now depending on its sign.
	* arith.c (arith_power): Adjust gfc_extract_int caller.
	* symbol.c (gfc_add_component): Use gfc_get_string ("%s", x) instead
	of gfc_get_string (x).
	(gfc_new_symtree, gfc_delete_symtree, gfc_get_uop, gfc_new_symbol,
	gfc_get_gsymbol, generate_isocbinding_symbol): Likewise.
	* openmp.c (gfc_match_omp_clauses): Adjust gfc_extract_int caller, pass
	-1 as new last argument to it, don't emit gfc_error_now.
	(gfc_match_omp_declare_reduction): Use gfc_get_string ("%s", x)
	instead of gfc_get_string (x).
	* check.c (kind_check): Adjust gfc_extract_int caller.
	* intrinsic.c (add_sym, find_sym, make_alias): Use
	gfc_get_string ("%s", x) instead of gfc_get_string (x).
	* simplify.c (get_kind, gfc_simplify_btest, gfc_simplify_maskr,
	gfc_simplify_maskl, gfc_simplify_poppar, gfc_simplify_repeat,
	gfc_simplify_selected_int_kind, gfc_simplify_selected_real_kind):
	Adjust gfc_extract_int callers.
	* trans-decl.c (gfc_find_module): Use gfc_get_string ("%s", x)
	instead of gfc_get_string (x).
	* matchexp.c (expression_syntax): Add const.
	* primary.c (match_kind_param, match_hollerith_constant,
	match_string_constant): Adjust gfc_extract_int callers.
	(match_keyword_arg): Use gfc_get_string ("%s", x) instead of
	gfc_get_string (x).
	* frontend-passes.c (optimize_minmaxloc): Likewise.

From-SVN: r244744
2017-01-21 11:30:54 +01:00
Janne Blomqvist c1e9bbcc49 Revert r244448
From-SVN: r244454
2017-01-13 21:53:16 +02:00
Janne Blomqvist a6ab4e077b PR 78534 Change character length from int to size_t
In order to handle large character lengths on (L)LP64 targets, switch
the GFortran character length from an int to a size_t.

This is an ABI change, as procedures with character arguments take
hidden arguments with the character length.

I also changed the _size member in vtables from int to size_t, as
there were some cases where character lengths and sizes were
apparently mixed up and caused regressions otherwise. Although I
haven't tested, this might enable very large derived types as well.

Also, as there are some places in the frontend were negative character
lengths are used as special flag values, in the frontend the character
length is handled as a signed variable of the same size as a size_t,
although in the runtime library it really is size_t.

I haven't changed the character length variables for the co-array
intrinsics, as this is something that may need to be synchronized with
OpenCoarrays.

This is v4 of the patch. v3 was applied but had to reverted due to
breaking bootstrap. The fix is in resolve.c:resolve_charlen, where
it's necessary to check that an expression is constant before using
mpz_sgn.

Overview of v3 of the patch: All the issues pointed out by FX's review
of v2 have been fixed. In particular, there are now new functions
gfc_mpz_get_hwi and gfc_mpz_set_hwi, similar to the GMP functions
mpz_get_si and mpz_set_si, except that they get/set a HOST_WIDE_INT
instead of a long value. Similarly, gfc_get_int_expr now takes a
HOST_WIDE_INT instead of a long, gfc_extract_long is replaced by
gfc_extract_hwi. Also, the preliminary work to handle
gfc_charlen_type_node being unsigned has been removed.

Regtested on x86_64-pc-linux-gnu and i686-pc-linux-gnu.

frontend:

2017-01-13  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	PR fortran/66310
	* class.c (gfc_find_derived_vtab): Use gfc_size_kind instead of
	hardcoded kind.
	(find_intrinsic_vtab): Likewise.
	* expr.c (gfc_get_character_expr): Length parameter of type
	gfc_charlen_t.
	(gfc_get_int_expr): Value argument of type HOST_WIDE_INT.
	(gfc_extract_hwi): New function.
	(simplify_const_ref): Make string_len of type gfc_charlen_t.
	(gfc_simplify_expr): Use HOST_WIDE_INT for substring refs.
	* gfortran.h (gfc_mpz_get_hwi): New prototype.
	(gfc_mpz_set_hwi): Likewise.
	(gfc_charlen_t): New typedef.
	(gfc_expr): Use gfc_charlen_t for character lengths.
	(gfc_size_kind): New extern variable.
	(gfc_extract_hwi): New prototype.
	(gfc_get_character_expr): Use gfc_charlen_t for character length.
	(gfc_get_int_expr): Use HOST_WIDE_INT type for value argument.
	* iresolve.c (gfc_resolve_repeat): Pass string length directly without
	temporary, use gfc_charlen_int_kind.
	* match.c (select_intrinsic_set_tmp): Use HOST_WIDE_INT for charlen.
	* misc.c (gfc_mpz_get_hwi): New function.
	(gfc_mpz_set_hwi): New function.
	* module.c (atom_int): Change type from int to HOST_WIDE_INT.
	(parse_integer): Don't complain about large integers.
	(write_atom): Use HOST_WIDE_INT for integers.
	(mio_integer): Handle integer type mismatch.
	(mio_hwi): New function.
	(mio_intrinsic_op): Use HOST_WIDE_INT.
	(mio_array_ref): Likewise.
	(mio_expr): Likewise.
	* resolve.c (resolve_select_type): Use HOST_WIDE_INT for charlen,
	use snprintf.
	(resolve_substring_charlen): Use gfc_charlen_int_kind.
	(resolve_charlen): Use mpz_sgn to determine sign.
	* simplify.c (gfc_simplify_repeat): Use HOST_WIDE_INT/gfc_charlen_t
	instead of long.
	* target-memory.c (size_character): Length argument of type
	gfc_charlen_t.
	(gfc_encode_character): Likewise.
	(gfc_interpret_character): Use gfc_charlen_t.
	* target-memory.h (gfc_encode_character): Modify prototype.
	* trans-array.c (get_array_ctor_var_strlen): Use
	gfc_conv_mpz_to_tree_type.
	* trans-const.c (gfc_conv_mpz_to_tree_type): New function.
	* trans-const.h (gfc_conv_mpz_to_tree_type): New prototype.
	* trans-expr.c (gfc_class_len_or_zero_get): Build const of type
	gfc_charlen_type_node.
	(gfc_conv_intrinsic_to_class): Use gfc_charlen_int_kind instead of
	4, fold_convert to correct type.
	(gfc_conv_class_to_class): Build const of type size_type_node for
	size.
	(gfc_copy_class_to_class): Likewise.
	(gfc_conv_string_length): Use same type in expression.
	(gfc_conv_substring): Likewise, use HOST_WIDE_INT for charlen.
	(gfc_conv_string_tmp): Make sure len is of the right type.
	(gfc_conv_concat_op): Use same type in expression.
	(gfc_conv_procedure_call): Likewise.
	(alloc_scalar_allocatable_for_subcomponent_assignment):
	fold_convert to right type.
	(gfc_trans_subcomponent_assign): Likewise.
	(trans_class_vptr_len_assignment): Build const of correct type.
	(gfc_trans_pointer_assignment): Likewise.
	(alloc_scalar_allocatable_for_assignment): fold_convert to right
	type in expr.
	(trans_class_assignment): Build const of correct type.
	* trans-intrinsic.c (gfc_conv_associated): Likewise.
	(gfc_conv_intrinsic_repeat): Do calculation in sizetype.
	* trans-io.c (gfc_build_io_library_fndecls): Use
	gfc_charlen_type_node for character lengths.
	* trans-stmt.c (gfc_trans_label_assign): Build const of
	gfc_charlen_type_node.
	(gfc_trans_character_select): Likewise.
	(gfc_trans_allocate): Likewise, don't typecast strlen result.
	(gfc_trans_deallocate): Don't typecast strlen result.
	* trans-types.c (gfc_size_kind): New variable.
	(gfc_init_types): Determine gfc_charlen_int_kind and gfc_size_kind
	from size_type_node.

testsuite:

2017-01-13  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	PR fortran/66310
	* gfortran.dg/repeat_4.f90: Use integers of kind C_SIZE_T.
	* gfortran.dg/repeat_7.f90: New test for PR 66310.
	* gfortran.dg/scan_2.f90: Handle potential cast in assignment.
	* gfortran.dg/string_1.f90: Limit to ilp32 targets.
	* gfortran.dg/string_1_lp64.f90: New test.
	* gfortran.dg/string_3.f90: Limit to ilp32 targets.
	* gfortran.dg/string_3_lp64.f90: New test.

libgfortran:

2017-01-13  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	* intrinsics/args.c (getarg_i4): Use gfc_charlen_type.
	(get_command_argument_i4): Likewise.
	(get_command_i4): Likewise.
	* intrinsics/chmod.c (chmod_internal): Likewise.
	* intrinsics/env.c (get_environment_variable_i4): Likewise.
	* intrinsics/extends_type_of.c (struct vtype): Use size_t for size
	member.
	* intrinsics/gerror.c (gerror): Use gfc_charlen_type.
	* intrinsics/getlog.c (getlog): Likewise.
	* intrinsics/hostnm.c (hostnm_0): Likewise.
	* intrinsics/string_intrinsics_inc.c (string_len_trim): Rework to
	work if gfc_charlen_type is unsigned.
	(string_scan): Likewise.
	* io/transfer.c (transfer_character): Modify prototype.
	(transfer_character_write): Likewise.
	(transfer_character_wide): Likewise.
	(transfer_character_wide_write): Likewise.
	(transfer_array): Typecast to avoid signed-unsigned comparison.
	* io/unit.c (is_trim_ok): Use gfc_charlen_type.
	* io/write.c (namelist_write): Likewise.
	* libgfortran.h (gfc_charlen_type): Change typedef to size_t.

From-SVN: r244448
2017-01-13 19:05:48 +02:00
Andre Vehreschild de91486c74 re PR fortran/78781 ([Coarray] ICE in gfc_deallocate_scalar_with_status, at fortran/trans.c:1588)
gcc/fortran/ChangeLog:

2017-01-07  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/78781
	PR fortran/78935
	* expr.c (gfc_check_pointer_assign): Return the same error message for
	rewritten coarray pointer assignments like for plain ones.
	* gfortran.h: Change prototype.
	* primary.c (caf_variable_attr): Set attributes used ones only only
	ones.  Add setting of pointer_comp attribute.
	(gfc_caf_attr): Add setting of pointer_comp attribute.
	* trans-array.c (gfc_array_allocate): Add flag that the component to
	allocate is not an ultimate coarray component.  Add allocation of
	pointer arrays.
	(structure_alloc_comps): Extend nullify to treat pointer components in
	coarrays correctly.  Restructure nullify to remove redundant code.
	(gfc_nullify_alloc_comp): Allow setting caf_mode flags.
	* trans-array.h: Change prototype of gfc_nullify_alloc_comp ().
	* trans-decl.c (generate_coarray_sym_init): Call nullify_alloc_comp for
	derived type coarrays with pointer components.
	* trans-expr.c (gfc_trans_structure_assign): Also treat pointer
	components.
	(trans_caf_token_assign): Handle assignment of token of scalar pointer
	components.
	(gfc_trans_pointer_assignment): Call above routine.
	* trans-intrinsic.c (conv_expr_ref_to_caf_ref): Add treating pointer
	components.
	(gfc_conv_intrinsic_caf_get): Likewise.
	(conv_caf_send): Likewise.
	* trans-stmt.c (gfc_trans_allocate): After allocating a derived type in
	a coarray pre-register the tokens.
	(gfc_trans_deallocate): Simply determining the coarray type (scalar or
	array) and deregistering it correctly.
	* trans-types.c (gfc_typenode_for_spec): Replace in_coarray flag by the
	actual codim to allow lookup of array types in the cache.
	(gfc_build_array_type): Likewise.
	(gfc_get_array_descriptor_base): Likewise.
	(gfc_get_array_type_bounds): Likewise.
	(gfc_get_derived_type): Likewise.
	* trans-types.h: Likewise.
	* trans.c (gfc_deallocate_with_status): Enable deregistering of all kind
	of coarray components.
	(gfc_deallocate_scalar_with_status): Use free() in fcoarray_single mode
	instead of caf_deregister.

libgfortran/ChangeLog:

2017-01-07  Andre Vehreschild  <vehre@gcc.gnu.org>

	PR fortran/78781
	PR fortran/78935
	* caf/single.c (send_by_ref): Fix addressing of non-allocatable scalar
	destination components.

gcc/testsuite/ChangeLog:

2017-01-07  Andre Vehreschild  <vehre@gcc.gnu.org>

	* gfortran.dg/coarray/ptr_comp_1.f08: New test.
	* gfortran.dg/coarray/ptr_comp_2.f08: New test.
	* gfortran.dg/coarray/ptr_comp_3.f08: New test.
	* gfortran.dg/coarray/ptr_comp_4.f08: New test.
	* gfortran.dg/coarray_ptr_comp_1.f08: New test.
	* gfortran.dg/coarray_ptr_comp_2.f08: New test.
	* gfortran.dg/coarray_ptr_comp_3.f08: New test.

From-SVN: r244196
2017-01-07 18:26:58 +01:00
Janne Blomqvist 84aff3c2d4 PR 78534 Revert r244011
r244011 caused regressions on 32-bit hosts.

From-SVN: r244027
2017-01-03 20:01:30 +02:00
Janne Blomqvist 994e4aca2c PR 78534 Change character length from int to size_t
In order to handle large character lengths on (L)LP64 targets, switch
the GFortran character length from an int to a size_t.

This is an ABI change, as procedures with character arguments take
hidden arguments with the character length.

I also changed the _size member in vtables from int to size_t, as
there were some cases where character lengths and sizes were
apparently mixed up and caused regressions otherwise. Although I
haven't tested, this might enable very large derived types as well.

Also, as there are some places in the frontend were negative character
lengths are used as special flag values, in the frontend the character
length is handled as a signed variable of the same size as a size_t,
although in the runtime library it really is size_t.

I haven't changed the character length variables for the co-array
intrinsics, as this is something that may need to be synchronized with
OpenCoarrays.

This is v3 of the patch. All the issues pointed out by FX's review of
v2 have been fixed. In particular, there are now new functions
gfc_mpz_get_hwi and gfc_mpz_set_hwi, similar to the GMP functions
mpz_get_si and mpz_set_si, except that they get/set a HOST_WIDE_INT
instead of a long value. Similarly, gfc_get_int_expr now takes a
HOST_WIDE_INT instead of a long, gfc_extract_long is replaced by
gfc_extract_hwi. Also, the preliminary work to handle
gfc_charlen_type_node being unsigned has been removed.

Regtested on x86_64-pc-linux-gnu.

frontend:

2017-01-03  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	PR fortran/66310
	* class.c (gfc_find_derived_vtab): Use gfc_size_kind instead of
	hardcoded kind.
	(find_intrinsic_vtab): Likewise.
	* expr.c (gfc_get_character_expr): Length parameter of type
	gfc_charlen_t.
	(gfc_get_int_expr): Value argument of type HOST_WIDE_INT.
	(gfc_extract_hwi): New function.
	(simplify_const_ref): Make string_len of type gfc_charlen_t.
	(gfc_simplify_expr): Use HOST_WIDE_INT for substring refs.
	* gfortran.h (gfc_mpz_get_hwi): New prototype.
	(gfc_mpz_set_hwi): Likewise.
	(gfc_charlen_t): New typedef.
	(gfc_expr): Use gfc_charlen_t for character lengths.
	(gfc_size_kind): New extern variable.
	(gfc_extract_hwi): New prototype.
	(gfc_get_character_expr): Use gfc_charlen_t for character length.
	(gfc_get_int_expr): Use HOST_WIDE_INT type for value argument.
	* iresolve.c (gfc_resolve_repeat): Pass string length directly without
	temporary, use gfc_charlen_int_kind.
	* match.c (select_intrinsic_set_tmp): Use HOST_WIDE_INT for charlen.
	* misc.c (gfc_mpz_get_hwi): New function.
	(gfc_mpz_set_hwi): New function.
	* module.c (atom_int): Change type from int to HOST_WIDE_INT.
	(parse_integer): Don't complain about large integers.
	(write_atom): Use HOST_WIDE_INT for integers.
	(mio_integer): Handle integer type mismatch.
	(mio_hwi): New function.
	(mio_intrinsic_op): Use HOST_WIDE_INT.
	(mio_array_ref): Likewise.
	(mio_expr): Likewise.
	* resolve.c (resolve_select_type): Use HOST_WIDE_INT for charlen,
	use snprintf.
	(resolve_charlen): Use mpz_sgn to determine sign.
	* simplify.c (gfc_simplify_repeat): Use HOST_WIDE_INT/gfc_charlen_t
	instead of long.
	* target-memory.c (size_character): Length argument of type
	gfc_charlen_t.
	(gfc_encode_character): Likewise.
	(gfc_interpret_character): Use gfc_charlen_t.
	* target-memory.h (gfc_encode_character): Modify prototype.
	* trans-array.c (get_array_ctor_var_strlen): Use
	gfc_conv_mpz_to_tree_type.
	* trans-const.c (gfc_conv_mpz_to_tree_type): New function.
	* trans-const.h (gfc_conv_mpz_to_tree_type): New prototype.
	* trans-expr.c (gfc_class_len_or_zero_get): Build const of type
	gfc_charlen_type_node.
	(gfc_conv_intrinsic_to_class): Use gfc_charlen_int_kind instead of
	4, fold_convert to correct type.
	(gfc_conv_class_to_class): Build const of type size_type_node for
	size.
	(gfc_copy_class_to_class): Likewise.
	(gfc_conv_string_length): Use same type in expression.
	(gfc_conv_substring): Likewise, use HOST_WIDE_INT for charlen.
	(gfc_conv_string_tmp): Make sure len is of the right type.
	(gfc_conv_concat_op): Use same type in expression.
	(gfc_conv_procedure_call): Likewise.
	(alloc_scalar_allocatable_for_subcomponent_assignment):
	fold_convert to right type.
	(gfc_trans_subcomponent_assign): Likewise.
	(trans_class_vptr_len_assignment): Build const of correct type.
	(gfc_trans_pointer_assignment): Likewise.
	(alloc_scalar_allocatable_for_assignment): fold_convert to right
	type in expr.
	(trans_class_assignment): Build const of correct type.
	* trans-intrinsic.c (gfc_conv_associated): Likewise.
	(gfc_conv_intrinsic_repeat): Do calculation in sizetype.
	* trans-io.c (gfc_build_io_library_fndecls): Use
	gfc_charlen_type_node for character lengths.
	* trans-stmt.c (gfc_trans_label_assign): Build const of
	gfc_charlen_type_node.
	(gfc_trans_character_select): Likewise.
	(gfc_trans_allocate): Likewise, don't typecast strlen result.
	(gfc_trans_deallocate): Don't typecast strlen result.
	* trans-types.c (gfc_size_kind): New variable.
	(gfc_init_types): Determine gfc_charlen_int_kind and gfc_size_kind
	from size_type_node.

testsuite:

2017-01-03  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	PR fortran/66310
	* gfortran.dg/dependency_49.f90: Change scan-tree-dump-times
          due to gfc_trans_string_copy change to avoid
          -Wstringop-overflow.
	* gfortran.dg/repeat_4.f90: Use integers of kind C_SIZE_T.
	* gfortran.dg/repeat_7.f90: New test for PR 66310.
	* gfortran.dg/scan_2.f90: Handle potential cast in assignment.
	* gfortran.dg/string_1.f90: Limit to ilp32 targets.
	* gfortran.dg/string_1_lp64.f90: New test.
	* gfortran.dg/string_3.f90: Limit to ilp32 targets.
	* gfortran.dg/string_3_lp64.f90: New test.
	* gfortran.dg/transfer_intrinsic_1.f90: Change
          scan-tree-dump-times due to gfc_trans_string_copy change to
          avoid -Wstringop-overflow.

libgfortran:

2017-01-03  Janne Blomqvist  <jb@gcc.gnu.org>

	PR fortran/78534
	* intrinsics/args.c (getarg_i4): Use gfc_charlen_type.
	(get_command_argument_i4): Likewise.
	(get_command_i4): Likewise.
	* intrinsics/chmod.c (chmod_internal): Likewise.
	* intrinsics/env.c (get_environment_variable_i4): Likewise.
	* intrinsics/extends_type_of.c (struct vtype): Use size_t for size
	member.
	* intrinsics/gerror.c (gerror): Use gfc_charlen_type.
	* intrinsics/getlog.c (getlog): Likewise.
	* intrinsics/hostnm.c (hostnm_0): Likewise.
	* intrinsics/string_intrinsics_inc.c (string_len_trim): Rework to
	work if gfc_charlen_type is unsigned.
	(string_scan): Likewise.
	* io/transfer.c (transfer_character): Modify prototype.
	(transfer_character_write): Likewise.
	(transfer_character_wide): Likewise.
	(transfer_character_wide_write): Likewise.
	(transfer_array): Typecast to avoid signed-unsigned comparison.
	* io/unit.c (is_trim_ok): Use gfc_charlen_type.
	* io/write.c (namelist_write): Likewise.
	* libgfortran.h (gfc_charlen_type): Change typedef to size_t.

From-SVN: r244011
2017-01-03 09:04:01 +02:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Janus Weil 7a28353e36 re PR fortran/78798 ([cleanup] some int-valued functions should be bool)
2016-12-13  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/78798
	* gfortran.h (gfc_is_constant_expr, gfc_is_formal_arg,
	gfc_is_compile_time_shape): Return bool instead of int.
	* array.c (gfc_is_compile_time_shape): Ditto.
	* expr.c (gfc_is_constant_expr): Ditto.
	* resolve.c (gfc_is_formal_arg): Ditto. Make formal_arg_flag bool.

From-SVN: r243621
2016-12-13 19:55:20 +01:00
Janus Weil 068b961b6a re PR fortran/78392 (ICE in gfc_trans_auto_array_allocation, at fortran/trans-array.c:5979)
2016-12-12  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/78392
	* expr.c (gfc_is_constant_expr): Specification functions are not
	compile-time constants. Update documentation (add reference to F08
	standard), add a FIXME.
	(external_spec_function): Add reference to F08 standard.
	* resolve.c (resolve_fl_variable): Ditto.

2016-12-12  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/78392
	* gfortran.dg/constant_shape.f90: New test case.

From-SVN: r243580
2016-12-12 19:54:54 +01:00
Steven G. Kargl 98ff2d6b12 expr.c (gfc_build_conversion): Remove unneeded initialization.
2016-12-02   Steven G. Kargl  <kargl@gcc.gnu.org>

	* expr.c (gfc_build_conversion): Remove unneeded initialization.

From-SVN: r243217
2016-12-03 07:23:13 +00:00
Janus Weil 6ed022af2a [multiple changes]
2016-12-02  Janus Weil  <janus@gcc.gnu.org>
	    Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/78618
	* check.c (gfc_check_rank): Remove ATTRIBUTE_UNUSED.
	* expr.c (gfc_check_assign): Fix error propagation.

2016-12-02  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/78618
	* gfortran.dg/char_conversion.f90: New test.

From-SVN: r243201
2016-12-02 19:38:24 +01:00
Steven G. Kargl fba5a793b3 re PR fortran/78500 (ICE in gfc_check_vardef_context, at fortran/expr.c:5289)
2016-11-24  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/78500
	* expr.c (gfc_check_vardef_contextm): Fix NULL pointer dereference.
	* interface.c (matching_typebound_op): Ditto.

2016-11-24  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/78500
	* gfortran.dg/class_result_4.f90: New test.

From-SVN: r242846
2016-11-24 18:27:58 +00:00
Steven G. Kargl 7e98cccbd8 re PR fortran/78479 (ICE in gfc_apply_init, at fortran/expr.c:4135)
2016-11-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/78479
	* expr.c (gfc_apply_init):  Allocate a charlen if needed.

2016-11-22  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/78479
	* gfortran.dg/char_component_initializer_3.f90: New test.

From-SVN: r242725
2016-11-22 21:52:15 +00:00
Janus Weil b349a81aa0 [multiple changes]
2016-11-09  Steve Kargl <kargl@gcc.gnu.org>
	    Janus Weil  <janus@gcc.gnu.org>

	PR fortran/60777
	* expr.c (external_spec_function): Allow recursive specification
	functions in F03.

2016-11-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/60777
	* gfortran.dg/spec_expr_7.f90: New test.

From-SVN: r242009
2016-11-09 18:22:02 +01:00
Janus Weil 103c4f759a re PR fortran/68440 ([OOP] ICE on declaring class variable with wrong attribute)
2016-11-08  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/68440
	* expr.c (check_alloc_comp_init): Loosen an assert.
	* resolve.c (resolve_fl_parameter): Reject class parameters.

2016-11-08  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/68440
	* gfortran.dg/class_58.f90: New test.

From-SVN: r241979
2016-11-08 23:07:21 +01:00
Janus Weil eba5aec8e3 re PR fortran/77596 ([F03] procedure pointer component with implicit interface can point to a function)
2016-11-08  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/77596
	* expr.c (gfc_check_pointer_assign): Add special check for procedure-
	pointer component with absent interface.

2016-11-08  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/77596
	* gfortran.dg/proc_ptr_comp_46.f90: New test.

From-SVN: r241972
2016-11-08 17:10:56 +01:00
Thomas Koenig 39b4b34de0 re PR fortran/78226 (Fill out location information everywhere)
2016-11-07  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/78226
	* expr.c (gfc_generate_initializer):  Add where to EXPR_NULL
	statement.
	* iresolve.c (gfc_resolve_extends_type_of):  Add where to
	both arguments of the function.
	* resolve.c (resolve_select_type):  Add where to the
	second argument of the new statement.

From-SVN: r241927
2016-11-07 19:33:27 +00:00
Andre Vehreschild cc03bf7a7b allocate_with_source_14.f03: Fixed number mallocs occuring.
gcc/testsuite/ChangeLog:

2016-11-06  Andre Vehreschild  <vehre@gcc.gnu.org>

	* gfortran.dg/allocate_with_source_14.f03: Fixed number mallocs
	occuring.

gcc/fortran/ChangeLog:

2016-11-06  Andre Vehreschild  <vehre@gcc.gnu.org>

	* expr.c (is_non_empty_structure_constructor): New function to detect
	non-empty structure constructor.
	(gfc_has_default_initializer): Analyse initializers.
	* resolve.c (cond_init): Removed.
	(resolve_allocate_expr): Removed dead code.  Moved invariant code out
	of the loop over all objects to allocate.
	(resolve_allocate_deallocate): Added the invariant code remove from
	resolve_allocate_expr.
	* trans-array.c (gfc_array_allocate): Removed nullify of structure
	components in favour of doing this in gfc_trans_allocate for both
	scalars and arrays in the same place.
	* trans-expr.c (gfc_trans_init_assign): Always using _vptr->copy for
	class objects.
	* trans-stmt.c (allocate_get_initializer): Get the initializer
	expression for object allocated.
	(gfc_trans_allocate): Nullify a derived type only, when no SOURCE=
	or MOLD= is present preventing duplicate work.  Moved the creation
	of the init-expression here to prevent code for conditions that
	can not occur on freshly allocated object, like checking for the need
	to free allocatable components.

From-SVN: r241885
2016-11-06 17:10:22 +01:00
Fritz Reese f8da53e093 Fix initialization of UNIONs with -finit-derived.
gcc/fortran/
	* expr.c (generate_union_initializer, get_union_initializer): New.
	* expr.c (component_initializer): Consider BT_UNION specially.
	* resolve.c (resolve_structure_cons): Hack for BT_UNION.
	* trans-expr.c (gfc_trans_subcomponent_assign): Ditto.
	* trans-expr.c (gfc_conv_union_initializer): New.
	* trans-expr.c (gfc_conv_structure): Replace UNION handling code with
	new function gfc_conv_union_initializer.

	gcc/testsuite/gfortran.dg/
	* dec_init_1.f90, dec_init_2.f90: Remove -fdump-tree-original.
	* dec_init_3.f90, dec_init_4.f90: New tests.

From-SVN: r241626
2016-10-27 17:21:46 +00:00
Paul Thomas bf9f15ee55 re PR fortran/45516 ([F08] allocatable compontents of recursive type)
2016-10-25  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/45516
	* class.c (gfc_find_derived_vtab): Detect recursive allocatable
	derived type components. If present, add '_deallocate' field to
	the vtable and build the '__deallocate' function.
	* decl.c (build_struct): Allow recursive allocatable derived
	type components for -std=f2008 or more.
	(gfc_match_data_decl): Accept these derived types.
	* expr.c (gfc_has_default_initializer): Ditto.
	* resolve.c (resolve_component): Make sure that the vtable is
	built for these derived types.
	* trans-array.c(structure_alloc_comps) : Use the '__deallocate'
	function for the automatic deallocation of these types.
	* trans-expr.c : Generate the deallocate accessor.
	* trans.h : Add its prototype.
	* trans-types.c (gfc_get_derived_type): Treat the recursive
	allocatable components in the same way as the corresponding
	pointer components.

2016-10-25  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/45516
	* gfortran.dg/class_2.f03: Set -std=f2003.
	* gfortran.dg/finalize_21.f90: Modify tree-dump.
	* gfortran.dg/recursive_alloc_comp_1.f08: New test.
	* gfortran.dg/recursive_alloc_comp_2.f08: New test.
	* gfortran.dg/recursive_alloc_comp_3.f08: New test.
	* gfortran.dg/recursive_alloc_comp_4.f08: New test.

From-SVN: r241539
2016-10-25 20:37:05 +00:00
Andre Vehreschild 3c9f5092c6 libcaf.h: Add caf_reference_type.
libgfortran/ChangeLog:

2016-09-19  Andre Vehreschild  <vehre@gcc.gnu.org>

	* caf/libcaf.h: Add caf_reference_type.
	* caf/mpi.c: Adapted signature of caf_register().
	* caf/single.c (struct caf_single_token): Added to keep the pointer
	to the memory registered and array descriptor.
	(caf_internal_error): Added convenience interface.
	(_gfortran_caf_register): Adapted to work with caf_single_token and
	return memory in the array descriptor.
	(_gfortran_caf_deregister): Same.
	(assign_char1_from_char4): Fixed style.
	(convert_type): Fixed incorrect conversion.
	(_gfortran_caf_get): Adapted to work with caf_single_token.
	(_gfortran_caf_send): Same.
	(_gfortran_caf_sendget): Same.
	(copy_data): Added to stop repeating it in all _by_ref functions.
	(get_for_ref): Recursive getting of coarray data using a chain of
	references.
	(_gfortran_caf_get_by_ref): Driver for computing the memory needed for
	the get and checking properties of the operation.
	(send_by_ref): Same as get_for_ref but for sending data.
	(_gfortran_caf_send_by_ref): Same like caf_get_by_ref but for sending.
	(_gfortran_caf_sendget_by_ref): Uses get_by_ref and send_by_ref to
	implement sendget for reference chains.
	(_gfortran_caf_atomic_define): Adapted to work with caf_single_token.
	(_gfortran_caf_atomic_ref): Likewise.
	(_gfortran_caf_atomic_cas): Likewise.
	(_gfortran_caf_atomic_op): Likewise.
	(_gfortran_caf_event_post): Likewise.
	(_gfortran_caf_event_wait): Likewise.
	(_gfortran_caf_event_query): Likewise.
	(_gfortran_caf_lock): Likewise.
	(_gfortran_caf_unlock): Likewise.


gcc/testsuite/ChangeLog:

2016-09-19  Andre Vehreschild  <vehre@gcc.gnu.org>

	* gfortran.dg/coarray/alloc_comp_4.f90: New test.
	* gfortran.dg/coarray_38.f90:
	* gfortran.dg/coarray_alloc_comp_1.f08: New test.
	* gfortran.dg/coarray_alloc_comp_2.f08: New test.
	* gfortran.dg/coarray_allocate_7.f08: New test.
	* gfortran.dg/coarray_allocate_8.f08: New test.
	* gfortran.dg/coarray_allocate_9.f08: New test.
	* gfortran.dg/coarray_lib_alloc_1.f90: Adapted scan-tree-dumps to expect
	new caf_register.
	* gfortran.dg/coarray_lib_alloc_2.f90: Same.
	* gfortran.dg/coarray_lib_alloc_3.f90: Same.
	* gfortran.dg/coarray_lib_comm_1.f90: Adapted scan-tree-dumps to expect
	get_by_refs.
	* gfortran.dg/coarray_lib_token_3.f90: Same as for coarray_lib_alloc2.
	* gfortran.dg/coarray_lock_7.f90: Same.
	* gfortran.dg/coarray_poly_5.f90: Same.
	* gfortran.dg/coarray_poly_6.f90: Same.
	* gfortran.dg/coarray_poly_7.f90: Same.
	* gfortran.dg/coarray_poly_8.f90: Same.
	* gfortran.dg/coindexed_1.f90: Changed errors expected.

gcc/fortran/ChangeLog:

2016-09-19  Andre Vehreschild  <vehre@gcc.gnu.org>

	* expr.c (gfc_check_assign): Added flag to control whether datatype
	conversion is allowed.
	* gfortran.h: Added caf-token-tree to gfc_component.  Changed
	prototypes mostly to add whether datatype conversion is allowed.
	* gfortran.texi: Added documentation for the caf_reference_t and the
	caf_*_by_ref function.
	* primary.c (caf_variable_attr): Similar to gfc_variable_attr but
	focused on the needs of coarrays.
	(gfc_caf_attr): Same.
	* resolve.c (resolve_ordinary_assign): Set the conversion allowed
	flag when not in a coarray.
	* trans-array.c (gfc_array_init_size): Moved setting of array
	descriptor's datatype before the alloc, because caf_register needs it.
	(gfc_array_allocate): Changed notion of whether an array is a coarray.
	(gfc_array_deallocate): Same.
	(gfc_alloc_allocatable_for_assignment): Added setting of coarray's
	array descriptor datatype before the register.  And using deregister/
	register to mimmick a realloc for coarrays.
	* trans-decl.c (gfc_build_builtin_function_decls): Corrected signatures
	of old caf-functions and added signature definitions of the _by_ref
	ones.
	(generate_coarray_sym_init): Adapted to new caf_register signature.
	* trans-expr.c (gfc_conv_scalar_to_descriptor): Make sure a constant
	is translated to an lvalue expression before use in an array
	descriptor.
	(gfc_get_ultimate_alloc_ptr_comps_caf_token): New function.  Get the
	last allocatable component's coarray token.
	(gfc_get_tree_for_caf_expr): For top-level object get the coarray
	token and check for unsupported features.
	(gfc_get_caf_token_offset): Getting the offset might procude new
	statements, which now are stored in the pre and post of the current se.
	(gfc_caf_get_image_index): For this image return a call to
	caf_this_image.
	(expr_may_alias_variables): Check that the result is set for testing
	its properties.
	(alloc_scalar_allocatable_for_assignment): Added auto allocation of
	coarray components.
	(gfc_trans_assignment_1): Rewrite an assign to a coarray object to
	be a sendget.
	* trans-intrinsic.c (conv_caf_vector_subscript_elem): Corrected
	wrong comment.
	(compute_component_offset): Compute the correct offset a structure
	member.
	(conv_expr_ref_to_caf_ref): Convert to a chain of refs into
	caf_references.
	(gfc_conv_intrinsic_caf_get): Call caf_get_by_ref instead of caf_get.
	(conv_caf_send): Call caf_*_by_ref for coarrays that need
	reallocation.
	(gfc_conv_intrinsic_function): Adapted to new signuature of the caf
	drivers.
	(conv_intrinsic_atomic_op): Add pre and post statements correctly.
	(conv_intrinsic_atomic_ref): Same.
	(conv_intrinsic_atomic_cas): Same.
	(conv_intrinsic_event_query): Same.
	* trans-stmt.c (gfc_trans_lock_unlock): Same.
	(gfc_trans_event_post_wait): Same.
	(gfc_trans_allocate): Support allocation of allocatable coarrays.
	(gfc_trans_deallocate): And there deallocation.
	* trans-types.c (gfc_typenode_for_spec): Added flag to control whether
	a component is part of coarray.  When so, then add space to store a
	coarray token.
	(gfc_build_array_type): Same.
	(gfc_get_array_descriptor_base): Same.
	(gfc_get_array_type_bounds): Same.
	(gfc_sym_type): Same.
	(gfc_get_derived_type): Same.
	(gfc_get_caf_reference_type): Declare the caf_reference_type.
	* trans-types.h: Prototype changes only.
	* trans.c (gfc_allocate_using_lib): Use the updated caf_register
	signature.
	(gfc_allocate_allocatable): Same.
	(gfc_deallocate_with_status): Same.
	* trans.h: Defined the runtime types for caf_reference_t and the enums.

From-SVN: r240231
2016-09-19 15:45:40 +02:00
Fritz Reese 7fc6162617 lang.opt, [...]: New flag -finit-derived.
2016-08-15  Fritz Reese  <fritzoreese@gmail.com>

	gcc/fortran/
	* lang.opt, invoke.texi: New flag -finit-derived.
	* gfortran.h (gfc_build_default_init_expr, gfc_apply_init,
	gfc_generate_initializer): New prototypes.
	* expr.c (gfc_build_default_init_expr, gfc_apply_init,
	component_initializer, gfc_generate_initializer): New functions.
	* expr.c (gfc_default_initializer): Wrap gfc_generate_initializer.
	* decl.c (build_struct): Move common code to gfc_apply_init.
	* resolve.c (can_generate_init): New function.
	* resolve.c (build_default_init_expr): Wrap gfc_build_default_init_expr.
	* resolve.c (apply_default_init, resolve_fl_variable_derived): Use
	gfc_generate_initializer.
	* trans-decl.c (gfc_generate_function_code): Use
	gfc_generate_initializer.

	gcc/testsuite/gfortran.dg/
	* init_flag_13.f90: New testcase.
	* init_flag_14.f90: Ditto.
	* init_flag_15.f03: Ditto.
	* dec_init_1.f90: Ditto.
	* dec_init_2.f90: Ditto.

From-SVN: r239489
2016-08-15 21:19:09 +00:00
Andre Vehreschild 4971dd802d expr.c (gfc_find_stat_co): Fixed whitespaces.
gcc/fortran/ChangeLog:

2016-07-22  Andre Vehreschild  <vehre@gcc.gnu.org>

	* expr.c (gfc_find_stat_co): Fixed whitespaces.
	* gfortran.texi: Fixed typos and reversed meaning of caf_get()'s
	src and dst description.
	* trans-decl.c (gfc_build_builtin_function_decls): Fixed style
	and corrected fnspec for caf functions.
	* trans-intrinsic.c (gfc_conv_intrinsic_caf_get): Fixed style.
	(conv_caf_send): Dito.

From-SVN: r238635
2016-07-22 11:46:54 +02:00
Alessandro Fanfarillo 20d0bfcefd Second review of STAT= patch + tests
From-SVN: r238007
2016-07-05 09:33:06 -06:00
Fritz Reese e75eb64fdf re PR fortran/71047 (Allocatable component of INTENT(OUT) dummy not set correctly)
2016-05-14  Fritz Reese <fritzoreese@gmail.com>

	PR fortran/71047
	* expr.c (gfc_default_initializer): Avoid extra component refs in
	constructors for derived types and classes.

2016-05-14  Fritz Reese <fritzoreese@gmail.com>
	PR fortran/71047
	* gfortran.dg/pr71047.f08: New test.

From-SVN: r236241
2016-05-14 15:29:13 +00:00
Fritz Reese f6288c2431 re PR fortran/56226 (Add support for DEC UNION and MAP extensions)
2016-05-07  Fritz Reese  <fritzoreese@gmail.com>

	PR fortran/56226
	* module.c (dt_upper_string): Rename to gfc_dt_upper_string
	(dt_lower_string): Likewise.
	* gfortran.h: Make new gfc_dt_upper/lower_string global.
	* class.c: Use gfc_dt_upper_string.
	* decl.c: Likewise.
	* symbol.c: Likewise.
	* resolve.c (resolve_component): New function.
	(resolve_fl_derived0): Move component loop code to resolve_component.
	* parse.c (check_component): New function.
	(parse_derived): Move loop code to check_component.
	* lang.opt, invoke.texi, options.c : New option -fdec-structure.
	* libgfortran.h (bt): New basic type BT_UNION.
	* gfortran.h (gfc_option): New option -fdec-structure.
	(gfc_get_union_type, gfc_compare_union_types): New prototypes.
	(gfc_bt_struct, gfc_fl_struct, case_bt_struct, case_fl_struct): New
	macros.
	(gfc_find_component): Change prototype.
	* match.h (gfc_match_member_sep, gfc_match_map, gfc_match_union,
	gfc_match_structure_decl): New prototypes.
	* parse.h (gfc_comp_struct): New macro.
	* symbol.c (gfc_find_component): Search for components in nested unions
	* class.c (insert_component_ref, gfc_add_component_ref, add_proc_comp,
	copy_vtab_proc_comps): Update calls to gfc_find_component.
	* primary.c (gfc_convert_to_structure_constructor): Likewise.
	* symbol.c (gfc_add_component): Likewise.
	* resolve.c (resolve_typebound_function, resolve_typebound_subroutine,
	resolve_typebound_procedure, resolve_component, resolve_fl_derived):
	Likewise.
	* expr.c (get_union_init, component_init): New functions.
	* decl.c (match_clist_expr, match_record_decl, get_struct_decl,
	gfc_match_map, gfc_match_union, gfc_match_structure_decl): Likewise.
	* interface.c (compare_components, gfc_compare_union_types): Likewise.
	* match.c (gfc_match_member_sep): Likewise.
	* parse.c (check_component, parse_union, parse_struct_map): Likewise.
	* resolve.c (resolve_fl_struct): Likewise.
	* symbol.c (find_union_component): Likewise.
	* trans-types.c (gfc_get_union_type): Likewise.
	* parse.c (parse_derived): Use new functions.
	* interface.c (gfc_compare_derived_types, gfc_compare_types): Likewise.
	* expr.c (gfc_default_initializer): Likewise.
	* gfortran.texi: Support for DEC structures, unions, and maps.
	* gfortran.h (gfc_statement, sym_flavor): Likewise.
	* check.c (gfc_check_kill_sub): Likewise.
	* expr.c (gfc_copy_expr, simplify_const_ref,
	gfc_has_default_initializer): Likewise.
	* decl.c (build_sym, match_data_constant, add_init_expr_to_sym,
	match_pointer_init, build_struct, variable_decl,
	gfc_match_decl_type_spec, gfc_mach_data-decl, gfc_match_entry,
	gfc_match_end, gfc_match_derived_decl): Likewise.
	* interface.c (check_interface0, check_interface1,
	gfc_search_interface): Likewise.
	* misc.c (gfc_basic_typename, gfc_typename): Likewise.
	* module.c (add_true_name, build_tnt, bt_types, mio_typespec,
	fix_mio_expr, load_needed, mio_symbol, read_module, write_symbol,
	gfc_get_module_backend_decl): Likewise.
	* parse.h (gfc_compile_state): Likewise.
	* parse.c (decode_specification_statement, decode_statement,
	gfc_ascii_statement, verify_st_order, parse_spec): Likewise.
	* primary.c (gfc_match_varspec, gfc_match_structure_constructor,
	gfc_match_rvalue, match_variable): Likewise.
	* resolve.c (find_arglists, resolve_structure_cons,
	is_illegal_recursion, resolve_generic_f, get_declared_from_expr,
	resolve_typebound_subroutine, resolve_allocate_expr,
	nonscalar_typebound_assign, generate_component_assignments,
	resolve_fl_variable_derived, check_defined_assignments,
	resolve_component, resolve_symbol, resolve_equivalence_derived):
	Likewise.
	* symbol.c (flavors, check_conflict, gfc_add_flavor, gfc_use_derived,
	gfc_restore_last_undo_checkpoint, gfc_type_compatible,
	gfc_find_dt_in_generic): Likewise.
	* trans-decl.c (gfc_get_module_backend_decl, create_function_arglist,
	gfc_create_module_variable, check_constant_initializer): Likewise.
	* trans-expr.c (gfc_conv_component_ref, gfc_conv_initializer,
	gfc_trans_alloc_subarray_assign, gfc_trans_subcomponent_assign,
	gfc_conv_structure, gfc_trans_scalar_assign, copyable_array_p):
	Likewise.
	* trans-io.c (transfer_namelist_element, transfer_expr,
	gfc_trans_transfer): Likewise.
	* trans-stmt.c (gfc_trans_deallocate): Likewise.
	* trans-types.c (gfc_typenode_for_spec, gfc_copy_dt_decls_ifequal,
	gfc_get_derived_type): Likewise.

2016-05-07  Fritz Reese  <fritzoreese@gmail.com>

	PR fortran/56226
	* gfortran.dg/dec_structure_1.f90: New testcase.
	* gfortran.dg/dec_structure_2.f90: Ditto.
	* gfortran.dg/dec_structure_3.f90: Ditto.
	* gfortran.dg/dec_structure_4.f90: Ditto.
	* gfortran.dg/dec_structure_5.f90: Ditto.
	* gfortran.dg/dec_structure_6.f90: Ditto.
	* gfortran.dg/dec_structure_7.f90: Ditto.
	* gfortran.dg/dec_structure_8.f90: Ditto.
	* gfortran.dg/dec_structure_9.f90: Ditto.
	* gfortran.dg/dec_structure_10.f90: Ditto.
	* gfortran.dg/dec_structure_11.f90: Ditto.
	* gfortran.dg/dec_union_1.f90: Ditto.
	* gfortran.dg/dec_union_2.f90: Ditto.
	* gfortran.dg/dec_union_3.f90: Ditto.
	* gfortran.dg/dec_union_4.f90: Ditto.
	* gfortran.dg/dec_union_5.f90: Ditto.
	* gfortran.dg/dec_union_6.f90: Ditto.
	* gfortran.dg/dec_union_7.f90: Ditto.

From-SVN: r235999
2016-05-07 23:16:23 +00:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Paul Thomas 3324776285 re PR fortran/68196 (ICE on function result with procedure pointer component)
2015-12-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/68196
	*expr.c (gfc_has_default_initializer): Prevent infinite recursion
	through this function for procedure pointer components.
	* trans-array.c (structure_alloc_comps): Ditto twice.


2015-12-18  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/68196
	* gfortran.dg/proc_ptr_48.f90: New test.

From-SVN: r231807
2015-12-18 09:34:13 +00:00
Tobias Burnus 460263d0ef re PR fortran/45859 ([Coarray, F2008, IR] Rejects valid actuals to coarray dummies)
2014-12-12  Tobias Burnus  <burnus@net-b.de>

gcc/fortran
        PR fortran/45859
        * expr.c (gfc_is_simply_contiguous): Optionally permit array
        * elements.
        (gfc_check_pointer_assign): Update call.
        * interface.c (compare_parameter): Ditto.
        * trans-array.c (gfc_conv_array_parameter): Ditto.
        * trans-intrinsic.c (gfc_conv_intrinsic_transfer,
        conv_isocbinding_function): Ditto.
        * gfortran.h (gfc_is_simply_contiguous): Update prototype.

gcc/testsuite/
        PR fortran/45859
        * gcc/testsuite/gfortran.dg/coarray_args_2.f90: Remove dg-error.

From-SVN: r231585
2015-12-12 20:00:32 +01:00
Tobias Burnus 5df445a2a5 check.c (gfc_check_event_query): New function.
2015-12-02  Tobias Burnus  <burnus@net-b.de>
	    Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>

	* check.c (gfc_check_event_query): New function.
	* dump-parse-tree.c (show_code_node): Handle EXEC_EVENT_POST,
	EXEC_EVENT_WAIT.
	* expr.c (gfc_check_vardef_context): New check for event variables
	definition.
	* gfortran.h (gfc_statement): Add ST_EVENT_POST, ST_EVENT_WAIT.
	(gfc_isym_id): GFC_ISYM_EVENT_QUERY.
	(struct symbol_attribute): New field.
	(gfc_exec_op): Add EXEC_EVENT_POST and EXEC_EVENT_WAIT.
	* gfortran.texi: Document about new events functions and minor
	changes.
	* interface.c (compare_parameter): New check.
	(gfc_procedure_use): New check for explicit procedure interface.
	(add_subroutines): Add event_query.
	* intrinsic.h (gfc_check_event_query,gfc_resolve_event_query):
	New prototypes.
	* iresolve.c (gfc_resolve_event_query): New function.
	* iso-fortran-env.def (event_type): New type.
	* match.c (event_statement,gfc_match_event_post,gfc_match_event_wait):
	New functions.
	(gfc_match_name): New event post and event wait.
	* match.h (gfc_match_event_post,gfc_match_event_wait):
	New prototypes.
	* module.c (ab_attribute): Add AB_EVENT_COMP.
	(attr_bits): Likewise.
	(mio_symbol_attribute): Handle event_comp attribute.
	* parse.c (decode_statement): Add ST_EVENT_POST, ST_EVENT_WAIT.
	(next_statement): Add ST_EVENT_POST, ST_EVENT_WAIT.
	(gfc_ascii_statement): Add ST_EVENT_POST, ST_EVENT_WAIT.
	(parse_derived): Check for event_type components.
	* resolve.c (resolve_allocate_expr): Check for event variable def.
	(resolve_lock_unlock): Renamed to resolve_lock_unlock_event. It
	includes logic for locks and events.
	(gfc_resolve_code): Call it.
	(gfc_resolve_symbol): New check for event variable to be a corray.
	* st.c (gfc_free_statement): Handle new EXEC_EVENT_POST and
	EXEC_EVENT_WAIT.
	* trans-decl.c (gfor_fndecl_caf_event_post,gfor_fndecl_caf_event_wait,
	gfor_fndecl_caf_event_query): New global variables.
	(generate_coarray_sym_init): Checking for event_type.
	(gfc_conv_procedure_call): Check for C bind attribute.
	* trans-intrinsic.c (conv_intrinsic_event_query): New function.
	(conv_intrinsic_move_alloc): Call it.
	* trans-stmt.c (gfc_trans_lock_unlock): Passing address
	of actual argument.
	(gfc_trans_sync): Likewise.
	(gfc_trans_event_post_wait): New function.
	* trans-stmt.h (gfc_trans_event_post_wait): New prototype.
	* trans-types.c (gfc_get_derived_type): Integer_kind as event_type.
	* trans.c (gfc_allocate_using_lib): New argument and logic for events.
	(gfc_allocate_allocatable): Passing new argument.
	(trans_code): Handle EXEC_EVENT_POST, EXEC_EVENT_WAIT.
	* trans.h (gfc_coarray_type): New elements.
	(gfor_fndecl_caf_event_post,gfor_fndecl_caf_event_wait,
	gfor_fndecl_caf_event_query): Declare them.

2015-12-02  Tobias Burnus  <burnus@net-b.de>
	    Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>

	* gfortran.dg/coarray/event_1.f90: New.
	* gfortran.dg/coarray/event_2.f90: New.

Co-Authored-By: Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>

From-SVN: r231208
2015-12-02 21:59:05 +00:00
Dominique d'Humieres 83be3fe57d re PR fortran/65751 (Bogus &L in error message)
2015-11-17  Dominique d'Humieres <dominiq@lps.ens.fr>

	PR fortran/65751
	* expr.c (gfc_check_pointer_assign): Fix error message.

	* gfortran.dg/unlimited_polymorphic_2.f03: Update test.

From-SVN: r230465
2015-11-17 17:29:45 +01:00
Steven G. Kargl 3e6ab82844 re PR fortran/58027 ("Arithmetic overflow converting ..." in PARAMETER triggers an ICE)
2015-11-16  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/58027
	PR fortran/60993
	* expr.c (gfc_check_init_expr): Prevent a redundant check when a
	__convert_* function was inserted into an array constructor.
	(gfc_check_assign_symbol): Check for an initialization expression
	when a __convert_* was inserted.

2015-11-16  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/58027
	PR fortran/60993
	* gfortran.dg/pr58027.f90: New test.

From-SVN: r230433
2015-11-16 19:15:25 +00:00
Paul Thomas 79124116d6 [multiple changes]
2015-09-28  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/40054
	PR fortran/63921
	* decl.c (get_proc_name): Return if statement function is
	found.
	* expr.c (gfc_check_vardef_context): Add error return for
	derived type expression lacking the derived type itself.
	* match.c (gfc_match_ptr_fcn_assign): New function.
	* match.h : Add prototype for gfc_match_ptr_fcn_assign.
	* parse.c : Add static flag 'in_specification_block'.
	(decode_statement): If in specification block match a statement
	function, then, if no error arising from statement function
	matching, try to match pointer function assignment.
	(parse_interface): Set 'in_specification_block' on exiting from
	parse_spec.
	(parse_spec): Set and then reset 'in_specification_block'.
	(gfc_parse_file): Set 'in_specification_block'.
	* resolve.c (get_temp_from_expr): Extend to include functions
	and array constructors as rvalues..
	(resolve_ptr_fcn_assign): New function.
	(gfc_resolve_code): Call it on finding a pointer function as an
	lvalue. If valid or on error, go back to start of resolve_code.
	* symbol.c (gfc_add_procedure): Add a sentence to the error to
	flag up the ambiguity between a statement function and pointer
	function assignment at the end of the specification block.

2015-09-28  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/40054
	PR fortran/63921
	* gfortran.dg/fmt_tab_1.f90: Change from run to compile and set
	standard as legacy.
	* gfortran.dg/fmt_tab_2.f90: Add extra tab error.
	* gfortran.dg/function_types_3.f90: Change error message to
	"Type inaccessible...."
	* gfortran.dg/ptr_func_assign_1.f08: New test.
	* gfortran.dg/ptr_func_assign_2.f08: New test.

2015-09-25  Mikael Morin  <mikael.morin@sfr.fr>

	PR fortran/40054
	PR fortran/63921
	* gfortran.dg/ptr_func_assign_3.f08: New test.
	* gfortran.dg/ptr_func_assign_4.f08: New test.

From-SVN: r228222
2015-09-28 21:18:38 +00:00
Steven G. Kargl 3108836938 re PR fortran/67526 (ICE on missing end parenthesis in substring construct)
2015-09-09  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/67526
	* gfortran.dg/pr67526.f90: New test.

2015-09-09  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/67526
	* expr.c (gfc_check_init_expr): Do not dereference a NULL pointer.

From-SVN: r227651
2015-09-10 17:13:11 +00:00
Francois-Xavier Coudert 0e360db970 re PR fortran/64104 ([F2003][IEEE] Allow IEEE functions in specification expressions)
PR fortran/64104

	* expr.c (gfc_check_init_expr): Allow some IEEE functions in
	constant expressions.
	(external_spec_function): Allow some IEEE functions in specification
	expressions.
	* simplify.c (gfc_simplify_ieee_selected_real_kind): Remove.
	(simplify_ieee_selected_real_kind, simplify_ieee_support,
	matches_ieee_function_name, gfc_simplify_ieee_functions): New
	functions.
	* gfortran.h (gfc_simplify_ieee_selected_real_kind): Remove
	prototype.
	(gfc_simplify_ieee_functions): Add prototype.

	* gfortran.dg/ieee/ieee_8.f90: New test.

From-SVN: r226723
2015-08-07 15:02:15 +00:00
Andrew MacLeod 1916bcb556 flags.h: Don't include flag-types.h or options.h.
2015-07-09  Andrew MacLeod  <amacleod@redhat.com>

	* flags.h: Don't include flag-types.h or options.h.
	* opts-common.c: Adjust includes.
	* opts-global.c: Likewise.
	* common/config/epiphany/epiphany-common.c: Likewise.

c

	* c-array-notation.c: Adjust includes for flags.h changes.
	* c-objc-common.c: Likewise.

c-family

	* c-common.h: Adjust includes for flags.h changes.
	* stub-objc.c: Likewise.
	
fortran

	* arith.c: Adjust includes for flags.h changes.
	* array.c: Likewise.
	* check.c: Likewise.
	* decl.c: Likewise.
	* error.c: Likewise.
	* expr.c: Likewise.
	* frontend-passes.c: Likewise.
	* interface.c: Likewise.
	* intrinsic.c: Likewise.
	* io.c: Likewise.
	* match.c: Likewise.
	* openmp.c: Likewise.
	* parse.c: Likewise.
	* primary.c: Likewise.
	* resolve.c: Likewise.
	* scanner.c: Likewise.
	* simplify.c: Likewise.
	* symbol.c: Likewise.
	* target-memory.c: Likewise.

jit
	* dummy-frontend.c: Adjust includes for flags.h changes.
	* jit-common.h: Likewise.
	* jit-playback.c: Likewise.

lto
	* lto-lang.c: Adjust includes for flags.h changes.

From-SVN: r225608
2015-07-09 11:27:35 +00:00
Thomas Koenig cbf560d708 re PR fortran/47359 (Recursive functions of intrinsic names generates invalid assembler)
2015-06-06  Thomas Koenig  <tkoenig@netcologne.de>

	PR fortran/47359
	* arith.c (eval_intrinsic_op): Set warn flag for
	gfc_type_convert_binary if -Wconversion or -Wconversion-extra
	are set.
	(wprecision_real_real): New function.
	(wprecision_int_real): New function.
	(gfc_int2int): If -fno-range-check and -Wconversion are specified
	and it is a narrowing conversion, warn.
	(gfc_int2real): If there is a change in value for the conversion,
	warn.
	(gfc_int2complex):  Likewise.
	(gfc_real2int): If there is a fractional part to the real number,
	warn with -Wconversion, otherwise warn with -Wconversion-extra.
	(gfc_real2real): Emit warning if the constant was changed by
	conversion with either -Wconversion or -Wconversion-extra.  With
	-Wconversion-extra, warn if no warning was issued earlier.
	(gfc_real2complex):  Likewise.
	(gfc_complex2int): For -Wconversion or -Wconversion-extra, if
	there was an imaginary part, warn; otherwise, warn for change in
	value.  Warn with -Wconversion-extra if no other warning was
	issued.
	(gfc_complex2real): For -Wconversion or -Wconversion-extra, if
	there was an imaginary part, warn; otherwise, warn for change in
	value. Warn with -Wconversion-extra if no other warning was
	issued.
	(gfc_complex2complex):  For -Wconversion, warn if the value of
	either the real or the imaginary part was changed.  Warn for
	-Wconversion-extra if no prior warning was issued.
	* expr.c (gfc_check_assign):  Remove check for change in value.
	* primary.c (match_real_constant): For -Wconversion-extra, check
	against a number in which the last non-zero digit has been
	replaced with a zero.  If the number compares equal, warn.
	* intrinsic.c (gfc_convert_type_warn):  Do not warn about constant
	conversions.

2015-06-06  Thomas Koenig  <tkoenig@netcologne.de>

	PR fortran/47359
	* gfortran.dg/array_constructor_type_17.f03: Adjust error message.
	* gfortran.dg/warn_conversion.f90: Add warning for change in value
	for assignment.
	* gfortran.dg/warn_conversion_3.f90: Add warnings.
	* gfortran.dg/warn_conversion_5.f90: New test.
	* gfortran.dg/warn_conversion_6.f90: New test.
	* gfortran.dg/warn_conversion_7.f90: New test.

From-SVN: r224190
2015-06-06 16:12:39 +00:00
Manuel López-Ibáñez fea70c9963 re PR fortran/44054 (Handle -Werror, -Werror=, -fdiagnostics-show-option, !GCC$ diagnostic (pragmas) and color)
gcc/fortran/ChangeLog:

2015-05-24  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	PR fortran/44054
	* gfortran.h (struct gfc_error_buf): Rename as
	gfc_error_buffer. Move closer to push, pop and free
	methods. Reimplement using an output_buffer.
	* error.c (errors, warnings, warning_buffer, cur_error_buffer):
	Delete everywhere in this file.
	(error_char): Delete all contents.
	(gfc_increment_error_count): Delete.
	(gfc_error_now): Update comment. Set error_buffer.flag.
	(gfc_warning_check): Do not handle warning_buffer.
	(gfc_error_1): Delete.
	(gfc_error_now_1): Delete.
	(gfc_error_check): Simplify.
	(gfc_move_error_buffer_from_to): Renamed from
	gfc_move_output_buffer_from_to.
	(gfc_push_error): Handle only gfc_error_buffer.
	(gfc_pop_error): Likewise.
	(gfc_free_error): Likewise.
	(gfc_get_errors): Remove warnings and errors.
	(gfc_diagnostics_init): Use static error_buffer.
	(gfc_error_1,gfc_error_now_1): Delete declarations.
	* symbol.c, decl.c, trans-common.c, data.c, expr.c, expr.c,
	frontend-passes.c, resolve.c, match.c, parse.c: Replace
	gfc_error_1 with gfc_error and gfc_error_now_1 with gfc_error_1
	everywhere.
	* f95-lang.c (gfc_be_parse_file): Do not update errorcount and
	warningcount here.
	* primary.c (match_complex_constant): Replace gfc_error_buf and
	output_buffer with gfc_error_buffer.

From-SVN: r223614
2015-05-23 23:02:52 +00:00
Steven G. Kargl bfeeb14516 re PR fortran/66045 (ICE on incorrect code with null)
2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/66045
	* expr.c (gfc_check_assign):  Check for assignment of NULL() instead
	of the (intended) pointer assignment.

2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/66045
	* gfortran.dg/null1.f90: New test.

From-SVN: r223322
2015-05-18 22:21:08 +00:00
Thomas Koenig 1aae3f0547 re PR fortran/66113 (Variable n cannot appear in the expression with nested blocks)
2015-05-16  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/66113
	* expr.c (is_parent_of_current_ns):  New function.
	(check_restricted):  Use it.

2015-05-16  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/66113
	* gfortran.dg/block_14.f90:  New test.

From-SVN: r223238
2015-05-16 12:33:01 +00:00
David Malcolm 21c0a521e4 Fix indentation issues seen by -Wmisleading-indentation
gcc/ChangeLog:
	* auto-profile.c (afdo_find_equiv_class): Fix indentation so
	that it reflects the block structure.
	(afdo_propagate_edge): Likewise.
	(afdo_calculate_branch_prob): Likewise.
	(afdo_annotate_cfg): Likewise.
	* cfgcleanup.c (equal_different_set_p): Likewise.
	(try_crossjump_to_edge): Likewise.
	* cgraph.c (cgraph_node::verify_node): Likewise.
	* cgraphunit.c (expand_all_functions): Likewise.
	* config/i386/i386.c (ix86_expand_copysign): Likewise.
	(exact_dependency_1): Likewise.
	* dwarf2asm.c (dw2_output_indirect_constants): Likewise.
	* dwarf2out.c (tree_add_const_value_attribute_for_decl): Likewise.
	* gensupport.c (process_define_subst): Likewise.
	* lto-wrapper.c (merge_and_complain): Likewise.
	* tree-if-conv.c (if_convertible_bb_p): Likewise.
	* tree-ssa-loop-prefetch.c (find_or_create_group): Likewise.
	* tree-ssa-tail-merge.c (gsi_advance_fw_nondebug_nonlocal): Likewise.
	* tree-vect-data-refs.c (vect_grouped_load_supported): Likewise.
	* tree-vect-loop.c (vectorizable_reduction): Likewise.
	* tree-vect-slp.c (vect_transform_slp_perm_load): Likewise.
	* tree-vect-stmts.c (vectorizable_shift): Likewise.
	* tree-vrp.c (vrp_finalize): Likewise.
	* tree.c (variably_modified_type_p): Likewise.

gcc/cp/ChangeLog:
	* parser.c (cp_parser_asm_definition): Only test for
        error_mark_node if "outputs" was just set.
	(cp_parser_asm_definition): Likewise for "inputs".

gcc/fortran/ChangeLog:
	* expr.c (check_inquiry): Fix indentation so that it reflects the
	block structure.
	* interface.c (compare_parameter): Likewise.
	* parse.c (parse_oacc_structured_block): Likewise.
	* target-memory.c (expr_to_char): Likewise.
	* trans-types.c (gfc_init_kinds): Likewise.

libcpp/ChangeLog:
	* pch.c (cpp_valid_state): Fix indentation so that it reflects the
	block structure.

From-SVN: r222823
2015-05-05 19:41:11 +00:00
Andre Vehreschild f3b0bb7a56 PF fortran/60322
gcc/testsuite/ChangeLog:

2015-04-23  Andre Vehreschild  <vehre@gmx.de>

	PF fortran/60322
	* gfortran.dg/class_allocate_19.f03: New test.
	* gfortran.dg/class_array_20.f03: New test.
	* gfortran.dg/class_array_21.f03: New test.
	* gfortran.dg/finalize_10.f90: Corrected scan-trees.
	* gfortran.dg/finalize_15.f90: Fixing comparision to model
	initialization correctly.
	* gfortran.dg/finalize_29.f08: New test.


gcc/fortran/ChangeLog:

2015-04-23  Andre Vehreschild  <vehre@gmx.de>

	PR fortran/60322
	* expr.c (gfc_lval_expr_from_sym): Code to select the regular
	or class array added.
	* gfortran.h: Add IS_CLASS_ARRAY macro.
	* trans-array.c (gfc_add_loop_ss_code): Treat class objects
	to be referenced always.
	(build_class_array_ref): Adapt retrieval of array descriptor.
	(build_array_ref): Likewise.
	(gfc_conv_array_ref): Hand the vptr or the descriptor to 
	build_array_ref depending whether the sym is class or not.
	(gfc_trans_array_cobounds):  Select correct gfc_array_spec for
	regular and class arrays.
	(gfc_trans_array_bounds): Likewise.
	(gfc_trans_dummy_array_bias): Likewise. 
	(gfc_get_dataptr_offset): Correcting call of build_array_ref.
	(gfc_conv_expr_descriptor): Set the array's offset to -1 when
	lbound in inner most dim is 1 and symbol non-pointer/assoc.
	* trans-decl.c (gfc_build_qualified_array): Select correct
	gfc_array_spec for regular and class arrays.
	(gfc_build_dummy_array_decl): Likewise.
	(gfc_get_symbol_decl): Get a dummy array for class arrays.
	(gfc_trans_deferred_vars): Tell conv_expr that the descriptor
	is desired.
	* trans-expr.c (gfc_class_vptr_get): Get the class descriptor
	from the correct location for class arrays.
	(gfc_class_len_get): Likewise.
	(gfc_conv_intrinsic_to_class): Add handling of _len component.
	(gfc_conv_class_to_class):  Prevent access to unset array data
	when the array is an optional argument. Add handling of _len
	component.
	(gfc_copy_class_to_class): Check that _def_init is non-NULL
	when used in _vptr->copy()
	(gfc_trans_class_init_assign): Ensure that the rank of
	_def_init is zero.
	(gfc_conv_component_ref): Get the _vptr along with _data refs.
	(gfc_conv_variable): Make sure the temp array descriptor is
	returned for class arrays, too, and that class arrays are
	dereferenced correctly.
	(gfc_conv_procedure_call): For polymorphic type initialization
	the initializer has to be a pointer to _def_init stored in a
	dummy variable, which then needs to be used by value.
	* trans-intrinsic.c (gfc_conv_intrinsic_sizeof): Use the
	temporary array descriptor for class arrays, too.
	(gfc_conv_intrinsic_storage_size): Likewise.
	(gfc_conv_intrinsic_loc): Add ref to _data for BT_CLASS
	expressions.
	* trans-stmt.c (trans_associate_var): Use a temporary array for
	the associate variable of class arrays, too, making the array
	one-based (lbound == 1).
	* trans-types.c (gfc_is_nodesc_array): Use the correct
	array data.
	* trans.c (gfc_build_array_ref): Use the dummy array descriptor
	when present.
	* trans.h: Add class_vptr to gfc_se for storing a class ref's
	vptr.

From-SVN: r222361
2015-04-23 13:32:00 +02:00
Paul Thomas 43a68a9df5 re PR fortran/63205 ([OOP] Wrongly rejects type = class (for identical declared type))
2015-02-06  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/63205
	* gfortran.h: Add 'must finalize' field to gfc_expr and
	prototypes for gfc_is_alloc_class_scalar_function and for
	gfc_is_alloc_class_array_function.
	* expr.c (gfc_is_alloc_class_scalar_function,
	gfc_is_alloc_class_array_function): New functions.
	* trans-array.c (gfc_add_loop_ss_code): Do not move the
	expression for allocatable class scalar functions outside the
	loop.
	(conv_array_index_offset): Cope with deltas being NULL_TREE.
	(build_class_array_ref): Do not return with allocatable class
	array functions. Add code to pick out the returned class array.
	Dereference if necessary and return if not a class object.
	(gfc_conv_scalarized_array_ref): Cope with offsets being NULL.
	(gfc_walk_function_expr): Return an array ss for the result of
	an allocatable class array function.
	* trans-expr.c (gfc_conv_subref_array_arg): Remove the assert
	that the argument should be a variable. If an allocatable class
	array function, set the offset to zero and skip the write-out
	loop in this case.
	(gfc_conv_procedure_call): Add allocatable class array function
	to the assert. Call gfc_conv_subref_array_arg for allocatable
	class array function arguments with derived type formal arg..
	Add the code for handling allocatable class functions, including
	finalization calls to prevent memory leaks.
	(arrayfunc_assign_needs_temporary): Return if an allocatable
	class array function.
	(gfc_trans_assignment_1): Set must_finalize to rhs expression
	for allocatable class functions. Set scalar_to_array as needed
	for scalar class allocatable functions assigned to an array.
	Nullify the allocatable components corresponding the the lhs
	derived type so that the finalization does not free them.

2015-02-06  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/63205
	* gfortran.dg/class_to_type_4.f90: New test

From-SVN: r220482
2015-02-06 18:15:01 +00:00
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00