Committed as obvious. The attached patch set an expression locus to gfc_current_locus to avoid a NULL pointer reference when emitting an error message. On beneficial fallout to this patch required a fix up to the testcase gfortran.dg/pr70870_1.f90.
2018-12-11 Steven G. Kargl <ka...@gcc.gnu.org> PR fortran/88155 * primary.c (gfc_match_structure_constructor): Set the locus of an expression to avoid a NULL pointer dereference. 2018-12-11 Steven G. Kargl <ka...@gcc.gnu.org> PR fortran/88155 * gfortran.dg/pr70870_1.f90: Update testcase to use -std=gnu. * gfortran.dg/pr88155.f90: New test. -- Steve
Index: gcc/fortran/primary.c =================================================================== --- gcc/fortran/primary.c (revision 267034) +++ gcc/fortran/primary.c (working copy) @@ -3212,6 +3212,7 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_ e = gfc_get_expr (); e->symtree = symtree; e->expr_type = EXPR_FUNCTION; + e->where = gfc_current_locus; gcc_assert (gfc_fl_struct (sym->attr.flavor) && symtree->n.sym->attr.flavor == FL_PROCEDURE); Index: gcc/testsuite/gfortran.dg/pr70870_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr70870_1.f90 (revision 267034) +++ gcc/testsuite/gfortran.dg/pr70870_1.f90 (working copy) @@ -1,4 +1,5 @@ ! { dg-do compile } +! { dg-options "-std=gnu" } ! PR fortran/70870 ! Contributed by Vittorio Zecca <zeccav at gmail dot com > type t Index: gcc/testsuite/gfortran.dg/pr88155.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr88155.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr88155.f90 (working copy) @@ -0,0 +1,9 @@ +! { dg-do compile } +program p + type t + integer :: a + end type + type(t) :: x + data x /t()1/ ! { dg-error "No initializer for component" } + print *, x +end