Fortran: intrinsic MERGE shall use all its arguments [PR107874]

gcc/fortran/ChangeLog:

	PR fortran/107874
	* simplify.cc (gfc_simplify_merge): When simplifying MERGE with a
	constant scalar MASK, ensure that arguments TSOURCE and FSOURCE are
	either constant or will be evaluated.
	* trans-intrinsic.cc (gfc_conv_intrinsic_merge): Evaluate arguments
	before generating conditional expression.

gcc/testsuite/ChangeLog:

	PR fortran/107874
	* gfortran.dg/merge_init_expr_2.f90: Adjust code to the corrected
	simplification.
	* gfortran.dg/merge_1.f90: New test.

Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
4 files changed