[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2023-01-28 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

Jerry DeLisle  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #12 from Jerry DeLisle  ---
Fixed and closing.

[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2023-01-21 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

--- Comment #11 from CVS Commits  ---
The master branch has been updated by Jerry DeLisle :

https://gcc.gnu.org/g:48f544ad5c98b668d8d345eaafcf09cc0bd44635

commit r13-5276-g48f544ad5c98b668d8d345eaafcf09cc0bd44635
Author: Jerry DeLisle 
Date:   Sat Jan 21 15:19:57 2023 -0800

fortran: [PR102595]

PR fortran/102595

gcc/fortran/ChangeLog:

* data.cc (gfc_assign_data_value): Remove check for PARAMETER in
DATA.
* primary.cc (match_variable): Add check for PARAMETER in DATA.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr88048.f90: Adjust for changed error message.
* gfortran.dg/parameter_data0.f90: New test.

[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2023-01-17 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

Jerry DeLisle  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |jvdelisle at gcc dot 
gnu.org

--- Comment #10 from Jerry DeLisle  ---
The following appears to catch it correctly.  The previous spot I removed after
spotting while checking the addition to primary.cc.  I keep the error message
similar so that existing tests in gfortrn.dg pass without changing.

diff --git a/gcc/fortran/data.cc b/gcc/fortran/data.cc
index 443d35da9cf..d29eb12c1b1 100644
--- a/gcc/fortran/data.cc
+++ b/gcc/fortran/data.cc
@@ -244,13 +244,6 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue,
mpz_t index,
"array-element nor a scalar-structure-component";

   symbol = lvalue->symtree->n.sym;
-  if (symbol->attr.flavor == FL_PARAMETER)
-{
-  gfc_error ("PARAMETER %qs shall not appear in a DATA statement at %L",
-symbol->name, >where);
-  return false;
-}
-
   init = symbol->value;
   last_ts = >ts;
   last_con = NULL;
diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc
index 543d9cc0de4..158f039f225 100644
--- a/gcc/fortran/primary.cc
+++ b/gcc/fortran/primary.cc
@@ -4076,6 +4076,11 @@ match_variable (gfc_expr **result, int equiv_flag, int
host_flag)
  gfc_error ("Named constant at %C in an EQUIVALENCE");
  return MATCH_ERROR;
}
+  if (gfc_in_match_data())
+   {
+ gfc_error ("PARAMETER %qs shall not appear in a DATA statement at
%C",
+ sym->name);
+   }
   /* Otherwise this is checked for and an error given in the
 variable definition context checks.  */
   break;

[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2023-01-15 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

--- Comment #9 from Steve Kargl  ---
On Sun, Jan 15, 2023 at 08:07:16PM +, jvdelisle at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595
> 
> --- Comment #8 from Jerry DeLisle  ---
> I started to do some variations on the z1.f90 case:
> 
> program p
>complex, parameter :: x(0) = 2

x is a zero-sized array.

program p
   complex, parameter :: x(0) = 2
   print *, size(x)
end program p

[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2023-01-15 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

--- Comment #8 from Jerry DeLisle  ---
I started to do some variations on the z1.f90 case:

program p
   complex, parameter :: x(0) = 2
   !data x%im /3.0/
   print *, x
end

Running this prints a blank line;

Looking at the -fdump-tree-original shows:

  parm.1.span = 8;
  parm.1.dtype = {.elem_len=8, .rank=1, .type=4};
  parm.1.dim[0].lbound = 1;
  parm.1.dim[0].ubound = 0;
  parm.1.dim[0].stride = 1;
  parm.1.data = (void *) [0];
  parm.1.offset = -1;

Is it valid to have an ubound less than the lbound?

program p
   complex, parameter :: x(1) = 2
   !data x%im /3.0/
   print *, x
end

The z2 case prints what is expected.  It looks like we need to catch something
in the parameter declaration before the data statement so that it is not
garbage later.

.. to be continued ..

[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2023-01-13 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

Jerry DeLisle  changed:

   What|Removed |Added

 CC||jvdelisle at gcc dot gnu.org

--- Comment #7 from Jerry DeLisle  ---
(In reply to CVS Commits from comment #6)

The above commit should have been for PR102331.

[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2022-12-29 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

--- Comment #6 from CVS Commits  ---
The master branch has been updated by Jerry DeLisle :

https://gcc.gnu.org/g:cdc6bf44eec295805ae29a8aaddafd111de01c8e

commit r13-4934-gcdc6bf44eec295805ae29a8aaddafd111de01c8e
Author: Steve Kargl 
Date:   Mon Dec 26 14:07:04 2022 -0800

Modify checks to avoid referencing NULL pointer.

Update test cases with error messages that changed as a result.

gcc/fortran/ChangeLog:

PR fortran/102595
* decl.cc (attr_decl1): Guard against NULL pointer.
* parse.cc (match_deferred_characteristics): Include BT_CLASS in
check for
derived being undefined.

gcc/testsuite/ChangeLog:

PR fortran/102595
* gfortran.dg/class_result_4.f90: Update error message check.
* gfortran.dg/pr85779_3.f90: Update error message check.

[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2021-12-23 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

kargl at gcc dot gnu.org changed:

   What|Removed |Added

  Attachment #52053|0   |1
is obsolete||

--- Comment #5 from kargl at gcc dot gnu.org ---
Created attachment 52054
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52054=edit
new patch

This is a better patch and now deals with the legal code

program foo
   complex a
   data a%re, a%im /1., 2./
   print *, a%re, a%im
end program foo

and the invalid code

program foo
   complex a
   data a%re, a%re /1., 2./
   print *, a%re, a%im
end program foo

[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2021-12-23 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

--- Comment #4 from kargl at gcc dot gnu.org ---
Comment on attachment 52053
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52053
patch

This patch fixes the problem in the PR and addresses a few
niggles I found as I poked gfortran.  Some of those errors
don't occur without this patch.

program p
   complex, parameter :: x(0) = 2
!   complex :: x(0) = 2! { dg-error "more values than variables" }
!   complex :: x(1) = 2! { dg-error "already is initialized" }
!   complex :: x = 2   ! { dg-error "already is initialized" }
!   complex :: x(1)! Works (as expected?)
!   complex :: x(0)! { dg-error "more values than variables" }
   data x%re /3.0/
   print *, x%re
end

[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2021-12-23 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kargl at gcc dot gnu.org

--- Comment #3 from kargl at gcc dot gnu.org ---
Created attachment 52053
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52053=edit
patch

[Bug fortran/102595] ICE in var_element, at fortran/decl.c:298 since r10-5607-gde89b5748d68b76b

2021-10-11 Thread marxin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102595

Martin Liška  changed:

   What|Removed |Added

 CC||burnus at gcc dot gnu.org,
   ||marxin at gcc dot gnu.org
Summary|ICE in var_element, at  |ICE in var_element, at
   |fortran/decl.c:298  |fortran/decl.c:298 since
   ||r10-5607-gde89b5748d68b76b

--- Comment #2 from Martin Liška  ---
Started with r10-5607-gde89b5748d68b76b.