Bug 18737 - ICE on invalid use of external keyword
Summary: ICE on invalid use of external keyword
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.3
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2004-11-30 13:05 UTC by Francois-Xavier Coudert
Modified: 2005-11-01 12:58 UTC (History)
3 users (show)

See Also:
Host: i686-unkown-linux
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-06-13 00:45:50


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Francois-Xavier Coudert 2004-11-30 13:05:54 UTC
$ cat a.f90 
program test
  implicit none
  real(8) :: x
  external bug

  x = 2
  print *, bug(x)
  
end program test


$ gfortran -c a.f90
a.f90: In function ‘MAIN__’:
a.f90:7: internal compiler error: in gfc_typenode_for_spec, at
fortran/trans-types.c:613
Comment 1 Andrew Pinski 2004-11-30 14:03:39 UTC
Confirmed.
Comment 2 Tobias Schlüter 2005-03-14 20:34:30 UTC
Actually, this slightly modified valid testcase fails with the same error:
program test
!  implicit none
  real(8) :: x
  external bug

  x = 2
  print *, bug(x)
  
end program test


Comment 3 Tobias Schlüter 2005-03-14 20:37:30 UTC
Excuse, the testcase with "implicit none" commented out passes.
Comment 4 Tobias Schlüter 2005-03-14 20:52:28 UTC
The bug is caused by the call to gfc_set_default_type in resolve.c:3961 passing
0 as second argument, thereby suppressing the error that should be issued there.
 Unfortunately, passing 1 for the argument breaks code which calls intrinsic
functions.
Comment 5 Paul Thomas 2005-08-03 11:42:03 UTC
(In reply to comment #4)
> The bug is caused by the call to gfc_set_default_type in resolve.c:3961 
passing
> 0 as second argument, thereby suppressing the error that should be issued 
there.
>  Unfortunately, passing 1 for the argument breaks code which calls intrinsic
> functions.

This sounds familiar!  I can add this to the pr16940 fix; ie. before calling 
gfc_set_default_type, we look for an external declaration, as well as a generic 
interface.  I'll put it on the TODO list.

Paul T
Comment 6 Paul Thomas 2005-11-01 05:53:34 UTC
Subject: Bug 18737

Author: pault
Date: Tue Nov  1 05:53:29 2005
New Revision: 106317

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106317
Log:
2005-11-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/21565
	* symbol.c (check_conflict): An object cannot be in a namelist and in
	block data.

	PR fortran/18737
	* resolve.c (resolve_symbol): Set the error flag to
	gfc_set_default_type, in the case of an external symbol, so that
	an error message is emitted if IMPLICIT NONE is set.

	PR fortran/14994
	* gfortran.h (gfc_generic_isym_id): Add GFC_ISYM_SECNDS to enum.
	* check.c (gfc_check_secnds): New function.
	* intrinsic.c (add_functions): Add call to secnds.
	* iresolve.c (gfc_resolve_secnds): New function.
	* trans-intrinsic (gfc_conv_intrinsic_function): Add call to
	secnds via case GFC_ISYM_SECNDS.
	* intrinsic.texi: Add documentation for secnds.

2005-11-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/14994
	* libgfortran/intrinsics/date_and_time.c: Add interface to
	the functions date_and_time for the intrinsic function secnds.

2005-11-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/21565
	gfortran.dg/namelist_blockdata.f90: New test.

	PR fortran/18737
	gfortran.dg/external_implicit_none.f90: New test.

	PR fortran/14994
	* gfortran.dg/secnds.f: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/external_implicit_none.f90
    trunk/gcc/testsuite/gfortran.dg/namelist_blockdata.f
    trunk/gcc/testsuite/gfortran.dg/secnds.f
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/check.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/intrinsic.h
    trunk/gcc/fortran/intrinsic.texi
    trunk/gcc/fortran/iresolve.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/intrinsics/date_and_time.c

Comment 7 Paul Thomas 2005-11-01 12:15:31 UTC
Subject: Bug 18737

Author: pault
Date: Tue Nov  1 12:15:07 2005
New Revision: 106326

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106326
Log:
2005-11-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/21565
	* symbol.c (check_conflict): An object cannot be in a namelist and in
	block data.

	PR fortran/18737
	* resolve.c (resolve_symbol): Set the error flag to
	gfc_set_default_type, in the case of an external symbol, so that
	an error message is emitted if IMPLICIT NONE is set.

	PR fortran/14994
	* gfortran.h (gfc_generic_isym_id): Add GFC_ISYM_SECNDS to enum.
	* check.c (gfc_check_secnds): New function.
	* intrinsic.c (add_functions): Add call to secnds.
	* iresolve.c (gfc_resolve_secnds): New function.
	* trans-intrinsic (gfc_conv_intrinsic_function): Add call to
	secnds via case GFC_ISYM_SECNDS.
	* intrinsic.texi: Add documentation for secnds.

2005-11-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/14994
	* libgfortran/intrinsics/date_and_time.c: Add interface to
	the functions date_and_time for the intrinsic function secnds.

2005-11-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/21565
	gfortran.dg/namelist_blockdata.f90: New test.

	PR fortran/18737
	gfortran.dg/external_implicit_none.f90: New test.

	PR fortran/14994
	* gfortran.dg/secnds.f: New test.

Added:
    branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/external_implicit_none.f90
    branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/namelist_blockdata.f
    branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/secnds.f
Modified:
    branches/gcc-4_0-branch/gcc/fortran/ChangeLog
    branches/gcc-4_0-branch/gcc/fortran/check.c
    branches/gcc-4_0-branch/gcc/fortran/gfortran.h
    branches/gcc-4_0-branch/gcc/fortran/intrinsic.c
    branches/gcc-4_0-branch/gcc/fortran/intrinsic.h
    branches/gcc-4_0-branch/gcc/fortran/intrinsic.texi
    branches/gcc-4_0-branch/gcc/fortran/iresolve.c
    branches/gcc-4_0-branch/gcc/fortran/resolve.c
    branches/gcc-4_0-branch/gcc/fortran/symbol.c
    branches/gcc-4_0-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_0-branch/libgfortran/ChangeLog
    branches/gcc-4_0-branch/libgfortran/intrinsics/date_and_time.c

Comment 8 Tobias Schlüter 2005-11-01 12:58:27 UTC
Fixed by Paul's patch.