Bug 35786 - OpenMP Fortran PRIVATE on parameter gives error in gfc_finish_var_decl
Summary: OpenMP Fortran PRIVATE on parameter gives error in gfc_finish_var_decl
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: diagnostic, ice-on-invalid-code, openmp
Depends on:
Blocks:
 
Reported: 2008-04-01 08:09 UTC by Jonathan Hogg
Modified: 2008-04-03 21:25 UTC (History)
1 user (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2008-04-03 14:57:20


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Hogg 2008-04-01 08:09:44 UTC
Using the parameter ONE in the PRIVATE stanza of the parallel do in the below code produces the shown error. This error only occurs if the subroutine is in a module file.

user@host $ gfortran-4.3 -fopenmp -c test.f90
test.f90: In function ‘test’:
test.f90:8: internal compiler error: in gfc_finish_var_decl, at fortran/trans-decl.c:510
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
user@host $ cat test.f90
module testmod
  implicit none

  real, parameter :: one = 1.0

contains

subroutine test
    integer i

    real, dimension(4) :: a = (/ 1, 2, 3, 4 /)
    real, dimension(4) :: b

    !$OMP PARALLEL DO PRIVATE(I, ONE)
    do i = 1,size(a)
      b(i) = one*a(i)
    end do
    !$OMP END PARALLEL DO

    print *, "b = ", b
end subroutine test
end module
user@host $ gfortran-4.3 -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --program-suffix=-4.3
Thread model: posix
gcc version 4.3.0 (GCC)
Comment 1 Tobias Burnus 2008-04-01 13:22:13 UTC
Thanks for the report; the internal compiler error is definitely a compiler bug. However, I believe the program is invalid.

If I read "2.8.3.3 private clause" in the OpenMP 2.5 specification correctly, the items in the private(list) need to variables which are definable or allocatable. However, "ONE" is not even a variable. Thus the program is invalid. However, an error message such as the one of sunf95 should be given instead of an ICE.


sunf95 writes:
    !$OMP PARALLEL DO PRIVATE(I, ONE)
                                 ^
"dfff.f90", Line = 14, Column = 34: ERROR: Object ONE must be a variable to be in the PRIVATE clause of the PARALLEL DO directive.

ifort writes:
    !$OMP PARALLEL DO PRIVATE(I, ONE)
---------------------------------^
fortcom: Error: dfff.f90, line 14: Subobjects are not allowed in this OpenMP clause; a named variable must be specified.
Comment 2 Jonathan Hogg 2008-04-01 14:13:52 UTC
(In reply to comment #1)
> Thanks for the report; the internal compiler error is definitely a compiler
> bug. However, I believe the program is invalid.

I know the program is invalid (thought that went without saying, I should probably be more verbose in the future), it was more of a feature request for a nice error message.

Thanks for your help,
Jonathan.
Comment 3 Jakub Jelinek 2008-04-03 21:02:09 UTC
Subject: Bug 35786

Author: jakub
Date: Thu Apr  3 21:01:26 2008
New Revision: 133874

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133874
Log:
	PR fortran/35786
	* openmp.c (resolve_omp_clauses): Diagnose if a clause symbol
	isn't a variable.

	* gfortran.dg/gomp/pr35786-1.f90: New test.
	* gfortran.dg/gomp/pr35786-2.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/gomp/pr35786-1.f90
    trunk/gcc/testsuite/gfortran.dg/gomp/pr35786-2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/openmp.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Jakub Jelinek 2008-04-03 21:21:36 UTC
Subject: Bug 35786

Author: jakub
Date: Thu Apr  3 21:20:53 2008
New Revision: 133877

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133877
Log:
	PR fortran/35786
	* openmp.c (resolve_omp_clauses): Diagnose if a clause symbol
	isn't a variable.

	* gfortran.dg/gomp/pr35786-1.f90: New test.
	* gfortran.dg/gomp/pr35786-2.f90: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/gomp/pr35786-1.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/gomp/pr35786-2.f90
Modified:
    branches/gcc-4_3-branch/gcc/fortran/ChangeLog
    branches/gcc-4_3-branch/gcc/fortran/openmp.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 5 Jakub Jelinek 2008-04-03 21:25:48 UTC
Fixed.