[Bug fortran/88155] ICE in gfc_format_decoder, at fortran/error.c:947

2018-12-11 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88155

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |kargl at gcc dot gnu.org
   Target Milestone|--- |7.5

--- Comment #6 from kargl at gcc dot gnu.org ---
Fixed on trunk, branch-8, and branch-7.

[Bug fortran/88155] ICE in gfc_format_decoder, at fortran/error.c:947

2018-12-11 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88155

--- Comment #5 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Wed Dec 12 01:26:12 2018
New Revision: 267043

URL: https://gcc.gnu.org/viewcvs?rev=267043=gcc=rev
Log:
2018-12-11  Steven G. Kargl  

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  

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

[Bug fortran/88155] ICE in gfc_format_decoder, at fortran/error.c:947

2018-12-11 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88155

--- Comment #4 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Wed Dec 12 01:14:58 2018
New Revision: 267042

URL: https://gcc.gnu.org/viewcvs?rev=267042=gcc=rev
Log:
2018-12-11  Steven G. Kargl  

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  

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

[Bug fortran/88155] ICE in gfc_format_decoder, at fortran/error.c:947

2018-12-11 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88155

--- Comment #3 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Wed Dec 12 00:53:08 2018
New Revision: 267041

URL: https://gcc.gnu.org/viewcvs?rev=267041=gcc=rev
Log:
2018-12-11  Steven G. Kargl  

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  

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

[Bug fortran/88155] ICE in gfc_format_decoder, at fortran/error.c:947

2018-11-23 Thread kargl at gcc dot gnu.org
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);

[Bug fortran/88155] ICE in gfc_format_decoder, at fortran/error.c:947

2018-11-22 Thread kargl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88155

kargl at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P4
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-11-22
 Ever confirmed|0   |1

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