This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran] Fix PR40728 - bogus error, ice-on-invalid
- From: Daniel Franke <franke at embl-hamburg dot de>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 6 May 2010 23:03:58 +0200
- Subject: [patch, fortran] Fix PR40728 - bogus error, ice-on-invalid
Hi all.
Attached patch fixes a bogus error and an ICE when a particular standard is
selected.
The problem was, that resolve.c (specific_sym) assumes that the symbol of the
deselected intrinsic is a specific symbol because sym->attr.external was
already set by intrinsic.c (gfc_is_intrinsic). The patch removes the side
effect of setting attr.external in the latter function and - voila.
gcc/fortran/:
2010-05-06 Daniel Franke <franke.daniel@gmail.com>
PR fortran/40728
* intrinc.c (gfc_is_intrinsic): Do not prematurely mark symbol
as external.
gcc/testsuite/:
2010-05-06 Daniel Franke <franke.daniel@gmail.com>
PR fortran/40728
* gfortran.dg/coarray_1.f90: Fixed error message.
* gfortran.dg/selected_char_kind_3.f90: Fixed error message.
* gfortran.dg/intrinsic_std_1.f90: Fixed bogus message.
* gfortran.dg/intrinsic_std_5.f90: New.
Regression tested on i686-pc-linux-gnu.
Ok for trunk? 4.5?
Daniel
Index: fortran/intrinsic.c
===================================================================
--- fortran/intrinsic.c (revision 159089)
+++ fortran/intrinsic.c (working copy)
@@ -956,17 +956,14 @@ gfc_is_intrinsic (gfc_symbol* sym, int s
/* See if this intrinsic is allowed in the current standard. */
if (gfc_check_intrinsic_standard (isym, &symstd, false, loc) == FAILURE)
{
- if (sym->attr.proc == PROC_UNKNOWN)
- {
- if (gfc_option.warn_intrinsics_std)
- gfc_warning_now ("The intrinsic '%s' at %L is not included in the"
- " selected standard but %s and '%s' will be"
- " treated as if declared EXTERNAL. Use an"
- " appropriate -std=* option or define"
- " -fall-intrinsics to allow this intrinsic.",
- sym->name, &loc, symstd, sym->name);
- gfc_add_external (&sym->attr, &loc);
- }
+ if (sym->attr.proc == PROC_UNKNOWN
+ && gfc_option.warn_intrinsics_std)
+ gfc_warning_now ("The intrinsic '%s' at %L is not included in the"
+ " selected standard but %s and '%s' will be"
+ " treated as if declared EXTERNAL. Use an"
+ " appropriate -std=* option or define"
+ " -fall-intrinsics to allow this intrinsic.",
+ sym->name, &loc, symstd, sym->name);
return false;
}
Index: testsuite/gfortran.dg/coarray_1.f90
===================================================================
--- testsuite/gfortran.dg/coarray_1.f90 (revision 159089)
+++ testsuite/gfortran.dg/coarray_1.f90 (working copy)
@@ -13,6 +13,6 @@ sync memory ! { dg-error "Fortran 2008:
sync images(*) ! { dg-error "Fortran 2008:" }
! num_images is implicitly defined:
-n = num_images() ! { dg-error "convert UNKNOWN to INTEGER" }
+n = num_images() ! { dg-error "has no IMPLICIT type" }
error stop 'stop' ! { dg-error "Fortran 2008:" }
end
Index: testsuite/gfortran.dg/selected_char_kind_3.f90
===================================================================
--- testsuite/gfortran.dg/selected_char_kind_3.f90 (revision 159089)
+++ testsuite/gfortran.dg/selected_char_kind_3.f90 (working copy)
@@ -4,7 +4,7 @@
! Check that SELECTED_CHAR_KIND is rejected with -std=f95
!
implicit none
- character(kind=selected_char_kind("ascii")) :: s ! { dg-error "must be an intrinsic function" }
+ character(kind=selected_char_kind("ascii")) :: s ! { dg-error "has no IMPLICIT type" }
s = "" ! { dg-error "has no IMPLICIT type" }
print *, s
end
Index: testsuite/gfortran.dg/intrinsic_std_1.f90
===================================================================
--- testsuite/gfortran.dg/intrinsic_std_1.f90 (revision 159089)
+++ testsuite/gfortran.dg/intrinsic_std_1.f90 (working copy)
@@ -20,7 +20,7 @@ SUBROUTINE no_implicit
! ASINH is an intrinsic of F2008
! The warning should be issued in the declaration above where it is declared
! EXTERNAL.
- WRITE (*,*) ASINH (1.) ! { dg-bogus "Fortran 2008" }
+ WRITE (*,*) ASINH (1.) ! { dg-warning "Fortran 2008" }
END SUBROUTINE no_implicit
SUBROUTINE implicit_type
Index: testsuite/gfortran.dg/intrinsic_std_5.f03
===================================================================
--- testsuite/gfortran.dg/intrinsic_std_5.f03 (revision 0)
+++ testsuite/gfortran.dg/intrinsic_std_5.f03 (revision 0)
@@ -0,0 +1,24 @@
+! { dg-do compile }
+! { dg-options "-std=f2003" }
+!
+! PR fortran/40728
+!
+
+! bogus error
+SUBROUTINE s1
+ IMPLICIT NONE
+ real(4), volatile :: r4
+
+ r4 = 0.0_4
+ r4 = asinh(r4) ! { dg-error "has no IMPLICIT type" }
+END SUBROUTINE
+
+
+
+! ICE on invalid (ATANH is defined by F2008 only)
+SUBROUTINE s2
+ IMPLICIT NONE
+ real :: r
+ r = 0.4
+ print *, atanh(r) ! { dg-error "has no IMPLICIT type" }
+END SUBROUTINE