]> 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:48:56 +0000 (11:48 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 2 Jul 2014 09:48:56 +0000 (11:48 +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: r212229

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

index 8033c7a5cc294cb2a2ab9095500d9cc945754e1d..65cfa6ffe9361ee6247b0c3b65fc9e48b2f0c8fa 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-15  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        Backport from trunk.
index 7dec803a36d5f89b894131aeb5a583e496ae2928..9292418adcaa4c120a8dc8451347f9256d9b84d4 100644 (file)
@@ -1996,6 +1996,13 @@ variable_decl (int elem)
       if (gfc_notify_std (GFC_STD_GNU, "Old-style "
                          "initialization at %C") == FAILURE)
        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 8ccfcfedb8f7162917067cc8da9af5303628900e..facd6dd0c2d692d77638f6ac4f392a097cc43d92 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-06-30  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        Backport from mainline
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