gcc/fortran/ChangeLog:
PR fortran/69636
PR fortran/103779
* intrinsic.cc (gfc_convert_chartype): Recover on invalid character
kind in conversion instead of generating an internal error.
gcc/testsuite/ChangeLog:
PR fortran/69636
PR fortran/103779
* gfortran.dg/pr103779.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
gcc_assert (expr->ts.type == BT_CHARACTER && ts->type == BT_CHARACTER);
sym = find_char_conv (&expr->ts, ts);
- gcc_assert (sym);
+ if (sym == NULL)
+ return false;
/* Insert a pre-resolved function call to the right function. */
old_where = expr->where;
--- /dev/null
+! { dg-do compile }
+! PR fortran/69636
+! PR fortran/103779
+! Contributed by G.Steinmetz
+
+character(1,) function f() ! { dg-error "Expected initialization expression" }
+ f = 'a'
+end
+
+character(1,kind=) function g() ! { dg-error "Expected initialization expression" }
+ g = 'a'
+end
+
+character(1,n) function h() ! { dg-error "has not been declared" }
+ h = 'a'
+end
+
+! { dg-prune-output "Bad kind expression" }