Bug 20876 - Subroutine call in FORALL block not PURE
Summary: Subroutine call in FORALL block not PURE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2005-04-08 15:59 UTC by Joost VandeVondele
Modified: 2006-06-23 15:42 UTC (History)
1 user (show)

See Also:
Host:
Target: i686-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-27 20:34:23


Attachments
Patch to fix PR (210 bytes, patch)
2006-06-19 08:11 UTC, Paul Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2005-04-08 15:59:39 UTC
The following is non-standard and the compiler should probably generate a
warning/error with '-pedantic -std=f95'


MODULE TT
 TYPE data_type
   INTEGER :: I
 END TYPE data_type
 INTERFACE ASSIGNMENT (=)
   MODULE PROCEDURE set
 END INTERFACE
CONTAINS
  SUBROUTINE set(x1,x2)
    TYPE(data_type), INTENT(IN) :: x2
    TYPE(data_type), INTENT(OUT) :: x1
  END SUBROUTINE set
END MODULE
USE TT
TYPE(data_type) D(10)
FORALL (I=1:10) D(I)=data_type(0)
END
Comment 1 Francois-Xavier Coudert 2005-05-12 08:27:56 UTC
This one currently segfaults.
Comment 2 Andrew Pinski 2005-09-30 20:38:25 UTC
We seg fault while trying to print an error message:
#0  show_locus (offset=0, loc=0x927130c)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/fortran/error.c:137
#1  0x0805cbdc in show_loci (l1=0x927130c, l2=0x0)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/fortran/error.c:270
#2  0x0805c56c in error_print (type=0x851cb61 "Error:", 
    format0=0x8524a04 "Subroutine call to '%s' in FORALL block at %L is not PURE", argp=Variable 
"argp" is not available.
)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/fortran/error.c:381
#3  0x0805c757 in gfc_error (
    nocmsgid=0x8524a04 "Subroutine call to '%s' in FORALL block at %L is not PURE")
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/fortran/error.c:595
#4  0x08081009 in pure_subroutine (c=0x9271300, sym=0x9265178)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/fortran/resolve.c:1134
#5  0x0808230a in resolve_specific_s0 (c=0x9271300, sym=0x9265178)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/fortran/resolve.c:1255
#6  0x080861ed in resolve_code (code=Variable "code" is not available.
)
    at /home/peshtigo/pinskia/src/gnu/gcc/src/gcc/fortran/resolve.c:1269
Comment 3 Paul Thomas 2006-06-19 08:11:49 UTC
Created attachment 11694 [details]
Patch to fix PR

The reason for the segfault is that the locus for the assign statement was never set.

Will commit tonight under the obvious rule.

Paul
Comment 4 Paul Thomas 2006-06-20 04:31:12 UTC
Subject: Bug 20876

Author: pault
Date: Tue Jun 20 04:30:48 2006
New Revision: 114802

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114802
Log:
2006-06-20  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25049
	PR fortran/25050
	* check.c (non_init_transformational): New function.
	(find_substring_ref): New function to signal use of disallowed
	transformational intrinsic in an initialization expression.
	(gfc_check_all_any): Call previous if initialization expr.
	(gfc_check_count): The same.
	(gfc_check_cshift): The same.
	(gfc_check_dot_product): The same.
	(gfc_check_eoshift): The same.
	(gfc_check_minloc_maxloc): The same.
	(gfc_check_minval_maxval): The same.
	(gfc_check_gfc_check_product_sum): The same.
	(gfc_check_pack): The same.
	(gfc_check_spread): The same.
	(gfc_check_transpose): The same.
	(gfc_check_unpack): The same.

	PR fortran/18769
	*intrinsic.c (add_functions): Add gfc_simplify_transfer.
	*intrinsic.h : Add prototype for gfc_simplify_transfer.
	*simplify.c (gfc_simplify_transfer) : New function to act as
	placeholder for eventual implementation.  Emit error for now.

	PR fortran/16206
	* expr.c (find_array_element): Eliminate condition on length of
	offset. Add bounds checking. Rearrange exit. Return try and
	put gfc_constructor result as an argument.
	(find_array_section): New function.
	(find_substring_ref): New function.
	(simplify_const_ref): Add calls to previous.
	(simplify_parameter_variable): Return on NULL expr.
	(gfc_simplify_expr): Only call gfc_expand_constructor for full
	arrays.

	PR fortran/20876
	* match.c (gfc_match_forall): Add missing locus to gfc_code.

2006-06-20  Paul Thomas  <pault@gcc.gnu.org>

	PR libfortran/28005
	* m4/matmul.m4: aystride = 1 does not uniquely detect the
	presence of a temporary transpose; an array element in the
	first dimension produces the same signature.  Detect this
	using the rank of a and add specific code.
	* generated/matmul_r4.c: Regenerate.
	* generated/matmul_r8.c: Regenerate.
	* generated/matmul_r10.c: Regenerate.
	* generated/matmul_r16.c: Regenerate.
	* generated/matmul_c4.c: Regenerate.
	* generated/matmul_c8.c: Regenerate.
	* generated/matmul_c10.c: Regenerate.
	* generated/matmul_c16.c: Regenerate.
	* generated/matmul_i4.c: Regenerate.
	* generated/matmul_i8.c: Regenerate.
	* generated/matmul_i16.c: Regenerate.

2006-06-20  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/16206
	* gfortran.dg/array_initializer_1.f90: New test.

	PR fortran/28005
	* gfortran.dg/matmul_3.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/array_initializer_1.f90
    trunk/gcc/testsuite/gfortran.dg/matmul_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/match.c
    trunk/gcc/fortran/simplify.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/generated/matmul_c10.c
    trunk/libgfortran/generated/matmul_c16.c
    trunk/libgfortran/generated/matmul_c4.c
    trunk/libgfortran/generated/matmul_c8.c
    trunk/libgfortran/generated/matmul_i16.c
    trunk/libgfortran/generated/matmul_i4.c
    trunk/libgfortran/generated/matmul_i8.c
    trunk/libgfortran/generated/matmul_r10.c
    trunk/libgfortran/generated/matmul_r16.c
    trunk/libgfortran/generated/matmul_r4.c
    trunk/libgfortran/generated/matmul_r8.c
    trunk/libgfortran/m4/matmul.m4

Comment 5 Paul Thomas 2006-06-23 04:47:11 UTC
Subject: Bug 20876

Author: pault
Date: Fri Jun 23 04:46:50 2006
New Revision: 114925

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114925
Log:
2006-06-23  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/25049
	PR fortran/25050
	* check.c (non_init_transformational): New function.
	(find_substring_ref): New function to signal use of disallowed
	transformational intrinsic in an initialization expression.
	(gfc_check_all_any): Call previous if initialization expr.
	(gfc_check_count): The same.
	(gfc_check_cshift): The same.
	(gfc_check_dot_product): The same.
	(gfc_check_eoshift): The same.
	(gfc_check_minloc_maxloc): The same.
	(gfc_check_minval_maxval): The same.
	(gfc_check_gfc_check_product_sum): The same.
	(gfc_check_pack): The same.
	(gfc_check_spread): The same.
	(gfc_check_transpose): The same.
	(gfc_check_unpack): The same.

	PR fortran/18769
	*intrinsic.c (add_functions): Add gfc_simplify_transfer.
	*intrinsic.h : Add prototype for gfc_simplify_transfer.
	*simplify.c (gfc_simplify_transfer) : New function to act as
	placeholder for eventual implementation.  Emit error for now.

	PR fortran/16206
	* expr.c (find_array_element): Eliminate condition on length of
	offset. Add bounds checking. Rearrange exit. Return try and
	put gfc_constructor result as an argument.
	(find_array_section): New function.
	(find_substring_ref): New function.
	(simplify_const_ref): Add calls to previous.
	(simplify_parameter_variable): Return on NULL expr.
	(gfc_simplify_expr): Only call gfc_expand_constructor for full
	arrays.

	PR fortran/20876
	* match.c (gfc_match_forall): Add missing locus to gfc_code.

2006-06-23  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/16206
	* gfortran.dg/array_initializer_1.f90: New test.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/array_initializer_1.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/check.c
    branches/gcc-4_1-branch/gcc/fortran/expr.c
    branches/gcc-4_1-branch/gcc/fortran/intrinsic.c
    branches/gcc-4_1-branch/gcc/fortran/intrinsic.h
    branches/gcc-4_1-branch/gcc/fortran/match.c
    branches/gcc-4_1-branch/gcc/fortran/simplify.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 6 Paul Thomas 2006-06-23 15:42:42 UTC
Fixed on trunk and 4.1

Paul