Fortran: checking of passed character length [PR125393]

Commit r16-3462 enhanced checking of character length passed to a character
dummy.  However, when the actual argument was an array element, its storage
size was estimated from all elements up to the end of the array.  This
could give a bogus warning when the dummy argument was of a scalar
character type.  Fix check for this case to actually compare the character
lengths of actual and dummy.

	PR fortran/125393

gcc/fortran/ChangeLog:

	* interface.cc (get_expr_storage_size): Additionally return
	character length.
	(gfc_compare_actual_formal): When the formal is a scalar character
	variable, use character lengths, not array storage size for check.

gcc/testsuite/ChangeLog:

	* gfortran.dg/argument_checking_28.f90: New test.

(cherry picked from commit 47bb24546297ef6812d69bc800ec005fc7e567e9)
2 files changed