[PATCH] Fix ICE on old style init of derived components
Jakub Jelinek
jakub@redhat.com
Wed Jul 2 07:48:00 GMT 2014
Hi!
As the testcase shows, we ICE on old style initialization of derived type
components. ifort also rejects these, I think it doesn't make sense to
support such initializations of derived type components.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.9?
2014-07-02 Jakub Jelinek <jakub@redhat.com>
Fritz Reese <Reese-Fritz@zai.com>
* decl.c (variable_decl): Reject old style initialization
for derived type components.
* gfortran.dg/oldstyle_5.f: New test.
--- gcc/fortran/decl.c.jj 2014-06-30 09:28:50.000000000 +0200
+++ gcc/fortran/decl.c 2014-07-01 16:47:19.466050044 +0200
@@ -1997,6 +1997,13 @@ variable_decl (int elem)
if (!gfc_notify_std (GFC_STD_GNU, "Old-style "
"initialization at %C"))
return MATCH_ERROR;
+ else if (gfc_current_state () == COMP_DERIVED)
+ {
+ gfc_error ("Invalid old style initialization for derived type "
+ "component at %C");
+ m = MATCH_ERROR;
+ goto cleanup;
+ }
return match_old_style_init (name);
}
--- gcc/testsuite/gfortran.dg/oldstyle_5.f.jj 2014-07-01 16:50:40.449001427 +0200
+++ gcc/testsuite/gfortran.dg/oldstyle_5.f 2014-07-01 16:48:33.000000000 +0200
@@ -0,0 +1,8 @@
+C { dg-do compile }
+ TYPE T
+ INTEGER A(2)/1,2/ ! { dg-error "Invalid old style initialization for derived type component" }
+ END TYPE
+ TYPE S
+ INTEGER B/1/ ! { dg-error "Invalid old style initialization for derived type component" }
+ END TYPE
+ END
Jakub
More information about the Gcc-patches
mailing list