]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (variable_decl): Reject old style initialization for derived type components.
authorJakub Jelinek <jakub@redhat.com>
Wed, 2 Jul 2014 09:43:08 +0000 (11:43 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 2 Jul 2014 09:43:08 +0000 (11:43 +0200)
* decl.c (variable_decl): Reject old style initialization
for derived type components.

* gfortran.dg/oldstyle_5.f: New test.

Co-Authored-By: Fritz Reese <Reese-Fritz@zai.com>
From-SVN: r212227

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/oldstyle_5.f [new file with mode: 0644]

index 5ebf40b3b2e66873ff7ab6d9b0a0c2228d759b1a..46ddb8fcfeb5cfdf90ea1cee9995a75db998f26c 100644 (file)
@@ -1,3 +1,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.
+
 2014-06-29  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/36275
index 7f7428156e3ed246d00f212ece38f8b038189477..25d92a46d3e94478b569fba2ec7598e59aa4e9f3 100644 (file)
@@ -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);
     }
index b364f407b46cf568dafb16365b3873c06495c42a..ad46526bad68b5beacce2aab21976a3d97fdc9e2 100644 (file)
@@ -1,3 +1,8 @@
+2014-07-02  Jakub Jelinek  <jakub@redhat.com>
+           Fritz Reese  <Reese-Fritz@zai.com>
+
+       * gfortran.dg/oldstyle_5.f: New test.
+
 2014-07-02  Uros Bizjak  <ubizjak@gmail.com>
 
        * gfortran.dg/ieee/ieee_1.F90 (dg-additional-options): Remove -O0.
diff --git a/gcc/testsuite/gfortran.dg/oldstyle_5.f b/gcc/testsuite/gfortran.dg/oldstyle_5.f
new file mode 100644 (file)
index 0000000..8a0d311
--- /dev/null
@@ -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