Fortran: catch invalid kind in character conversion [PR69636,PR103779]
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>
This commit is contained in:
parent
b24e9c0830
commit
a618b45ac4
2 changed files with 20 additions and 1 deletions
|
@ -5419,7 +5419,8 @@ gfc_convert_chartype (gfc_expr *expr, gfc_typespec *ts)
|
|||
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;
|
||||
|
|
18
gcc/testsuite/gfortran.dg/pr103779.f90
Normal file
18
gcc/testsuite/gfortran.dg/pr103779.f90
Normal file
|
@ -0,0 +1,18 @@
|
|||
! { 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" }
|
Loading…
Add table
Reference in a new issue