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  <ja...@redhat.com>
            Fritz Reese  <reese-fr...@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

Reply via email to