[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-07 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #16 from Dominique d'Humieres dominiq at lps dot ens.fr 
2011-03-07 10:07:00 UTC ---
I think the -std=f95 issue mentioned in comment #5 is pr41165.


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-06 Thread jvdelisle at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #11 from Jerry DeLisle jvdelisle at gcc dot gnu.org 2011-03-06 
14:59:05 UTC ---
Info: Does not fix it but why this behavior with the test case?

Index: expr.c
===
--- expr.c(revision 170543)
+++ expr.c(working copy)
@@ -946,6 +946,7 @@ gfc_is_constant_expr (gfc_expr *e)
   return 1;

 case EXPR_ARRAY:
+  /* return 1 here and it works. */
   return gfc_constant_ac (e);

 default:


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-06 Thread jvdelisle at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #12 from Jerry DeLisle jvdelisle at gcc dot gnu.org 2011-03-06 
15:16:46 UTC ---
Passes:
case EXPR_ARRAY:
  /* return 1 here and it works. */
  /* gfc_constant_ac (e); */
  return 1;
Fails:
case EXPR_ARRAY:
  /* return 1 here and it works. */
  gfc_constant_ac (e);
  return 1;


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-06 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #13 from Paul Thomas pault at gcc dot gnu.org 2011-03-06 16:19:02 
UTC ---
(In reply to comment #12)
Jerry,

Based in this and comment #11, I noted that the place where this was failing
was iterator-free EXPR_ARRAYs.  I then leapt to the following patch, which is
just now regtesting (it's up to typebound_generic_4.f03):

Index: /svn/trunk/gcc/fortran/expr.c
===
*** /svn/trunk/gcc/fortran/expr.c(revision 170337)
--- /svn/trunk/gcc/fortran/expr.c(working copy)
*** gfc_is_constant_expr (gfc_expr *e)
*** 937,952 
return e-ref == NULL || (gfc_is_constant_expr (e-ref-u.ss.start)
   gfc_is_constant_expr (e-ref-u.ss.end));

  case EXPR_STRUCTURE:
!   for (c = gfc_constructor_first (e-value.constructor);
!c; c = gfc_constructor_next (c))
  if (!gfc_is_constant_expr (c-expr))
return 0;

return 1;

- case EXPR_ARRAY:
-   return gfc_constant_ac (e);

  default:
gfc_internal_error (gfc_is_constant_expr(): Unknown expression type);
--- 937,954 
return e-ref == NULL || (gfc_is_constant_expr (e-ref-u.ss.start)
   gfc_is_constant_expr (e-ref-u.ss.end));

+ case EXPR_ARRAY:
  case EXPR_STRUCTURE:
!   c = gfc_constructor_first (e-value.constructor);
!   if ((e-expr_type == EXPR_ARRAY)  c  c-iterator)
! return gfc_constant_ac (e);
! 
!   for (; c; c = gfc_constructor_next (c))
  if (!gfc_is_constant_expr (c-expr))
return 0;

return 1;


  default:
gfc_internal_error (gfc_is_constant_expr(): Unknown expression type);


Cheers

Paul


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-06 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #14 from Paul Thomas pault at gcc dot gnu.org 2011-03-06 20:15:42 
UTC ---
Author: pault
Date: Sun Mar  6 20:15:38 2011
New Revision: 170720

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=170720
Log:
2011-03-06  Paul Thomas  pa...@gcc.gnu.org
Jerry DeLisle  jvdeli...@gcc.gnu.org

PR fortran/47850
* expr.c (gfc_is_constant_expr): Only use gfc_constant_ac if
the expression has an iterator.  Otherwise, iterate through the
array, checking for constant expressions for each element.

2011-03-06  Paul Thomas  pa...@gcc.gnu.org
Jerry DeLisle  jvdeli...@gcc.gnu.org

PR fortran/47850
* gfortran.dg/array_constructor_37.f90 : New test.


Added:
trunk/gcc/testsuite/gfortran.dg/array_constructor_37.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/expr.c
trunk/gcc/testsuite/ChangeLog


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-06 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

Paul Thomas pault at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||FIXED

--- Comment #15 from Paul Thomas pault at gcc dot gnu.org 2011-03-06 20:20:31 
UTC ---
Fixed on trunk.

Thanks for the report.

Paul


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-05 Thread jvdelisle at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

Jerry DeLisle jvdelisle at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jvdelisle at gcc dot
   ||gnu.org

--- Comment #9 from Jerry DeLisle jvdelisle at gcc dot gnu.org 2011-03-05 
19:13:36 UTC ---
This is suspicious.  I don't see it in the ChangeLog and is probably a merge
artifact.

http://gcc.gnu.org/viewcvs/trunk/gcc/fortran/arith.c?r1=155179r2=158253pathrev=158253


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-05 Thread jvdelisle at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #10 from Jerry DeLisle jvdelisle at gcc dot gnu.org 2011-03-05 
19:17:58 UTC ---
(In reply to comment #9)
 This is suspicious.  I don't see it in the ChangeLog and is probably a merge
 artifact.
 
 http://gcc.gnu.org/viewcvs/trunk/gcc/fortran/arith.c?r1=155179r2=158253pathrev=158253

Sorry, I now see it further down in the Log, however it does touch on OP stuff
so it still may be related.


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-02 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #8 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-03-02 
13:22:14 UTC ---
(In reply to comment #6)
 (In reply to comment #4)
  The regression appeared between revisions 158105 and 159105.

 In the above revision range r158253 looks by far the most likely candidate for
 this regression. 

Revision 158253 is indeed the cause of this pr: the tests compile and run with
r158252, but yields ICEs with 158253.


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-01 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #4 from Dominique d'Humieres dominiq at lps dot ens.fr 2011-03-01 
10:00:01 UTC ---
The regression appeared between revisions 158105 and 159105.


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-01 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #5 from Tobias Burnus burnus at gcc dot gnu.org 2011-03-01 
10:39:21 UTC ---
(In reply to comment #3)
 -std=f95 no longer generates the error that it should:
logical, parameter :: buf(3) = [(any(sc(i) ==nc), i = 1, 3)]
 1
 Error: transformational intrinsic 'any' at (1) is not permitted in an
 initialization expression

Ignoring the issue of [ ] vs. (/ /) which kicks in first: gfortran 4.4
diagnoses this, 4.5/4.6 do not.

I think one reason that the error no longer is shown is the change with regards
to constant vs. initialization expression. Fortran 2003 merged the two concepts
to the name initialization expressions (which were renamed to constant
expressions in F2008) - but in Fortran 95 not every constant expression was an
initialization expression and some places mandated an initialization
expression. F95 had:

7.1.6.1 Constant expression
A constant expression is an expression in which each operation is intrinsic
and each primary is [...] (5) A transformational intrinsic function reference
where each argument is a constant
expression,

In the same section, initialization expressions are defined, which do not
allows the transformational function NULL - and no other one.

Thus, it might be that the missing diagnosis is a side effect of the
F2003/F2008 support. (I think one needs to revamp that area as there are
several bugs; unfortunately, it is a tedious task.)

 * * *

Regarding the simplification, I tried the following patch, but that fails due
to the above mentioned bug/mess with gfortran's implementation of init-expr vs.
const-expr.

In particular: The gfc_is_constant_expr(e) returns false as e-value.op.op1 is
EXPR_VARIABLE (of attr.flavor FL_PARAMETER) and that function simply returns
0 if it encounters EXPR_VARIABLE.

I sincerely believe the we do not want to touch the const/init-expr mess when
the 4.6 release is imminent.

--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -231,9 +231,17 @@ is_constant_array_expr (gfc_expr *e)
   if (e == NULL)
 return true;

-  if (e-expr_type != EXPR_ARRAY || !gfc_is_constant_expr (e))
+  if (!gfc_is_constant_expr (e))
 return false;

+  if (e-expr_type != EXPR_ARRAY)
+{
+  if (gfc_simplify_expr (e,1) != SUCCESS)
+   return false;
+  if (e-expr_type != EXPR_ARRAY)
+   return false;
+}
+
   for (c = gfc_constructor_first (e-value.constructor);
c; c = gfc_constructor_next (c))
 if (c-expr-expr_type != EXPR_CONSTANT


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-01 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

Paul Thomas pault at gcc dot gnu.org changed:

   What|Removed |Added

 CC||franke.daniel at gmail dot
   ||com

--- Comment #6 from Paul Thomas pault at gcc dot gnu.org 2011-03-01 10:48:46 
UTC ---
(In reply to comment #4)
 The regression appeared between revisions 158105 and 159105.

(In reply to comment #4)
 The regression appeared between revisions 158105 and 159105.

In the above revision range r158253 looks by far the most likely candidate for
this regression.  It carrys the handles jvdeli...@gcc.gnu.org and
franke.dan...@gmail.com.

I have CC'd Daniel as the principal author.

Paul


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-01 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #7 from Paul Thomas pault at gcc dot gnu.org 2011-03-01 12:45:34 
UTC ---
(In reply to comment #5)
 (In reply to comment #3)
  -std=f95 no longer generates the error that it should:
 logical, parameter :: buf(3) = [(any(sc(i) ==nc), i = 1, 3)]
  1
  Error: transformational intrinsic 'any' at (1) is not permitted in an
  initialization expression
 
 Ignoring the issue of [ ] vs. (/ /) which kicks in first: gfortran 4.4
 diagnoses this, 4.5/4.6 do not.
 
 I think one reason that the error no longer is shown is the change with 
 regards
 to constant vs. initialization expression. Fortran 2003 merged the two 
 concepts
 to the name initialization expressions (which were renamed to constant
 expressions in F2008) - but in Fortran 95 not every constant expression was 
 an
 initialization expression and some places mandated an initialization
 expression. F95 had:

Well regardless of the evolution of the standard, I expect that -std=f95 would
know the difference between the two.

Cheers

Paul


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-02-26 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #3 from Paul Thomas pault at gcc dot gnu.org 2011-02-26 11:09:41 
UTC ---
(In reply to comment #2)
 (In reply to comment #1)

It appears to be ANY that is not simplified.

program Cindex
   integer,parameter :: sc(3) =  [10,12,17], nc(2) = [10,17]
   logical, parameter :: buf(3) = [(any(sc(i) ==nc), i = 1, 3)]
   print *, buf
end program Cindex

produces:

pr47850.f90:5:0: internal compiler error: in record_reference, at
cgraphbuild.c:60

and the -fdump-tree-original shows that any has not been simplified.

-std=f95 no longer generates the error that it should:

   logical, parameter :: buf(3) = [(any(sc(i) ==nc), i = 1, 3)]
1
Error: transformational intrinsic 'any' at (1) is not permitted in an
initialization expression

Paul


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-02-23 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

--- Comment #1 from Tobias Burnus burnus at gcc dot gnu.org 2011-02-23 
09:04:03 UTC ---
The problem is that for 

   integer,parameter :: C_INDEX(8) = unpack( 
  vector = [(i,i=1,size(SENSOR_CHANNEL))], 
  mask = [(any(SENSOR_CHANNEL(i) == NLTE_CHANNEL), 
 i=lbound(SENSOR_CHANNEL,1),ubound(SENSOR_CHANNEL,1))], 

the mask is not regarded as gfc_is_constant_expr - gfc_constant_ac.


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-02-23 Thread pault at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

Paul Thomas pault at gcc dot gnu.org changed:

   What|Removed |Added

 CC||pault at gcc dot gnu.org

--- Comment #2 from Paul Thomas pault at gcc dot gnu.org 2011-02-23 15:00:20 
UTC ---
(In reply to comment #1)
 The problem is that for 
 
integer,parameter :: C_INDEX(8) = unpack( 
   vector = [(i,i=1,size(SENSOR_CHANNEL))], 
   mask = [(any(SENSOR_CHANNEL(i) == NLTE_CHANNEL), 
  i=lbound(SENSOR_CHANNEL,1),ubound(SENSOR_CHANNEL,1))], 
 
 the mask is not regarded as gfc_is_constant_expr - gfc_constant_ac.

I just found the same thing! That's what comes of not refreshing the page :-)

Paul


[Bug fortran/47850] [4.6 Regression] ICE in gfc_conv_array_initializer

2011-02-22 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47850

Tobias Burnus burnus at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P4
   Target Milestone|--- |4.6.0