https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88155

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org ---
(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);

Reply via email to