With a typo, down to at least gcc-5 : $ cat z1.f90 program p type t integer :: a end type type(t) :: x data x /t()1/ print *, x end $ gfortran-9-20181118 -c z1.f90 0x618fae gfc_format_decoder ../../gcc/fortran/error.c:947 0x131577e pp_format(pretty_printer*, text_info*) ../../gcc/pretty-print.c:1390 0x130b125 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) ../../gcc/diagnostic.c:1015 0x618e4c gfc_error_opt ../../gcc/fortran/error.c:1313 0x61a3f0 gfc_error(char const*, ...) ../../gcc/fortran/error.c:1342 0x675e10 build_actual_constructor ../../gcc/fortran/primary.c:2934 0x6793f6 gfc_convert_to_structure_constructor(gfc_expr*, gfc_symbol*, gfc_expr**, gfc_actual_arglist**, bool) ../../gcc/fortran/primary.c:3148 0x679801 gfc_match_structure_constructor(gfc_symbol*, gfc_expr**) ../../gcc/fortran/primary.c:3228 0x604f2f match_data_constant ../../gcc/fortran/decl.c:427 0x604fe3 top_val_list ../../gcc/fortran/decl.c:472 0x6051ff gfc_match_data() ../../gcc/fortran/decl.c:616 0x66a891 match_word ../../gcc/fortran/parse.c:65 0x66dfd6 decode_statement ../../gcc/fortran/parse.c:468 0x66ebfa next_free ../../gcc/fortran/parse.c:1234 0x66ebfa next_statement ../../gcc/fortran/parse.c:1466 0x67020b parse_spec ../../gcc/fortran/parse.c:3858 0x672cd7 parse_progunit ../../gcc/fortran/parse.c:5671 0x674359 gfc_parse_file() ../../gcc/fortran/parse.c:6211 0x6bc97f gfc_be_parse_file ../../gcc/fortran/f95-lang.c:204
(In reply to G. Steinmetz from comment #0) > With a typo, down to at least gcc-5 : > > > $ cat z1.f90 > program p > type t > integer :: a > end type > type(t) :: x > data x /t()1/ > print *, x > end > > > $ gfortran-9-20181118 -c z1.f90 > 0x618fae gfc_format_decoder > ../../gcc/fortran/error.c:947 > 0x131577e pp_format(pretty_printer*, text_info*) > ../../gcc/pretty-print.c:1390 > 0x130b125 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) > ../../gcc/diagnostic.c:1015 > 0x618e4c gfc_error_opt > ../../gcc/fortran/error.c:1313 > 0x61a3f0 gfc_error(char const*, ...) > ../../gcc/fortran/error.c:1342 > 0x675e10 build_actual_constructor > ../../gcc/fortran/primary.c:2934 Interesting bug. The pointer components of gfc_current_locus are NULL. Changing the use of %C to %L in gfc_error and using comp->loc yields troutmask:sgk[203] gfcx -c a.f90 a.f90:3:18: 3 | integer :: a | 1 Error: No initializer for component 'a' given in the structure constructor at (1) which is of course the bogus locus. Completely suppressing %C yields an error message but not a locus and source line output.
(In reply to kargl from comment #1) > (In reply to G. Steinmetz from comment #0) > > With a typo, down to at least gcc-5 : > > > > > > $ cat z1.f90 > > program p > > type t > > integer :: a > > end type > > type(t) :: x > > data x /t()1/ > > print *, x > > end > > > > > > $ gfortran-9-20181118 -c z1.f90 > > 0x618fae gfc_format_decoder > > ../../gcc/fortran/error.c:947 > > 0x131577e pp_format(pretty_printer*, text_info*) > > ../../gcc/pretty-print.c:1390 > > 0x130b125 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*) > > ../../gcc/diagnostic.c:1015 > > 0x618e4c gfc_error_opt > > ../../gcc/fortran/error.c:1313 > > 0x61a3f0 gfc_error(char const*, ...) > > ../../gcc/fortran/error.c:1342 > > 0x675e10 build_actual_constructor > > ../../gcc/fortran/primary.c:2934 > > Interesting bug. The pointer components of gfc_current_locus are NULL. > Changing the use of %C to %L in gfc_error and using comp->loc yields > > troutmask:sgk[203] gfcx -c a.f90 > a.f90:3:18: > > 3 | integer :: a > | 1 > Error: No initializer for component 'a' given in the structure constructor > at (1) > > which is of course the bogus locus. Completely suppressing %C > yields an error message but not a locus and source line output. This sets the locus correctly. Index: primary.c =================================================================== --- primary.c (revision 266386) +++ 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);
Author: kargl Date: Wed Dec 12 00:53:08 2018 New Revision: 267041 URL: https://gcc.gnu.org/viewcvs?rev=267041&root=gcc&view=rev Log: 2018-12-11 Steven G. Kargl <kargl@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 <kargl@gcc.gnu.org> PR fortran/88155 * gfortran.dg/pr70870_1.f90: Update testcase to use -std=gnu. * gfortran.dg/pr88155.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/pr88155.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/primary.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/pr70870_1.f90
Author: kargl Date: Wed Dec 12 01:14:58 2018 New Revision: 267042 URL: https://gcc.gnu.org/viewcvs?rev=267042&root=gcc&view=rev Log: 2018-12-11 Steven G. Kargl <kargl@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 <kargl@gcc.gnu.org> PR fortran/88155 * gfortran.dg/pr70870_1.f90: Update testcase to use -std=gnu. * gfortran.dg/pr88155.f90: New test. Added: branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pr88155.f90 Modified: branches/gcc-8-branch/gcc/fortran/ChangeLog branches/gcc-8-branch/gcc/fortran/primary.c branches/gcc-8-branch/gcc/testsuite/ChangeLog branches/gcc-8-branch/gcc/testsuite/gfortran.dg/pr70870_1.f90
Author: kargl Date: Wed Dec 12 01:26:12 2018 New Revision: 267043 URL: https://gcc.gnu.org/viewcvs?rev=267043&root=gcc&view=rev Log: 2018-12-11 Steven G. Kargl <kargl@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 <kargl@gcc.gnu.org> PR fortran/88155 * gfortran.dg/pr70870_1.f90: Update testcase to use -std=gnu. * gfortran.dg/pr88155.f90: New test. Added: branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr88155.f90 Modified: branches/gcc-7-branch/gcc/fortran/ChangeLog branches/gcc-7-branch/gcc/fortran/primary.c branches/gcc-7-branch/gcc/testsuite/ChangeLog branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr70870_1.f90
Fixed on trunk, branch-8, and branch-7.