[fortran] PR114739 [14 Regression] ice in gfc_find_derived_types, at fortran/symbol.cc:2458
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
This ICE was caused by my patch r14-9489-g3fd46d859cda10. However, the ICE
hid a wrong error going back to at least 6.4.1 20180703. The patch fixes
both and exposed incorrect error messages in existing tests in gfortran.dg.
The fix for these was to add 'IMPLICIT NONE' in call cases so that there
really is no implicit type.
Regtests OK - I will commit in 24 hours time, if there are no objections
and will backport in a couple of weeks.
Paul
Fortran: Fix ICE in gfc_match_varspec and error messages [PR114739]
2024-04-17 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/114739
* primary.cc (gfc_match_varspec): Check for default type before
checking for derived types with the right component name.
gcc/testsuite/
PR fortran/114739
* gfortran.dg/pr114739.f90: New test.
* gfortran.dg/derived_comp_array_ref_8.f90: Add 'implicit none'
for consistency with expected error message.
* gfortran.dg/nullify_4.f90: ditto
* gfortran.dg/pointer_init_6.f90: ditto
* gfortran.dg/pr107397.f90: ditto
* gfortran.dg/pr88138.f90: ditto
@@ -2236,6 +2236,15 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag,
match mm;
old_loc = gfc_current_locus;
mm = gfc_match_name (name);
+
+ /* Check to see if this is default complex. */
+ if (sym->ts.type == BT_UNKNOWN && tgt_expr == NULL
+ && gfc_get_default_type (sym->name, sym->ns)->type != BT_UNKNOWN)
+ {
+ gfc_set_default_type (sym, 0, sym->ns);
+ primary->ts = sym->ts;
+ }
+
/* This is a usable inquiry reference, if the symbol is already known
to have a type or no derived types with a component of this name
can be found. If this was an inquiry reference with the same name
@@ -2,6 +2,7 @@
!
! PR fortran/52325
!
+implicit none
real :: f
cc%a = 5 ! { dg-error "Symbol 'cc' at .1. has no IMPLICIT type" }
f%a = 5 ! { dg-error "Unexpected '%' for nonderived-type variable 'f' at" }
@@ -3,6 +3,7 @@
!
! Check error recovery; was crashing before.
!
+implicit none
real, pointer :: ptr
nullify(ptr, mesh%coarser) ! { dg-error "Symbol 'mesh' at .1. has no IMPLICIT type" }
end
@@ -21,7 +21,7 @@ end module m1
module m2
-
+ implicit none
type :: t
procedure(s), pointer, nopass :: ppc
end type
@@ -1,6 +1,7 @@
!{ dg-do compile }
!
program p
+ implicit none
type t
real :: a = 1.0
end type
new file mode 100644
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! The fix here was triggered by an ICE prior to r14-9489-g3fd46d859cda10
+! Before that gfortran gave an incorrect "no implicit type" error for all
+! three statements.
+program main
+ implicit complex(z)
+ implicit character(c)
+ z2%re = 1.
+ z2%im = 2.
+ print *, z2, c%kind
+end
@@ -1,5 +1,6 @@
! { dg-do compile }
program p
+ implicit none
type t
character :: c = 'c'
end type