[Bug fortran/50410] [8/9/10/11 Regression] ICE in record_reference, pointer variable in data statement
anlauf at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jun 21 17:20:09 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50410
--- Comment #42 from anlauf at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #41)
> In my working tree I had the following patch
This still ICEs on comment#23 z1.
Slightly rewriting that case, one gets a reasonable error message:
program p
type ta
integer :: a
end type ta
type t
type(ta), pointer :: b
end type t
type(t) :: u = t(ta(1))
end
pr50410_23x.f90:8:19:
8 | type(t) :: u = t(ta(1))
| 1
Error: The element in the structure constructor at (1), for pointer component
'b' should be a POINTER or a TARGET
Digging further, one sees that the error is generated for z1 but not emitted.
The following patch does the magic (not regtested):
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 8daa7bb8d06..0a995ec3ae7 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3087,6 +3087,9 @@ gfc_reduce_init_expr (gfc_expr *expr)
t = gfc_check_init_expr (expr);
gfc_init_expr_flag = false;
+ if (gfc_error_check())
+ return false;
+
if (!t || !expr)
return false;
More information about the Gcc-bugs
mailing list