re PR fortran/51953 ([F2008] Allow multiple allocate-objects in ALLOCATE with SOURCE=)
authorTobias Burnus <burnus@net-b.de>
Fri, 27 Jan 2012 13:06:13 +0000 (14:06 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 27 Jan 2012 13:06:13 +0000 (14:06 +0100)
2012-01-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51953
        * match.c (gfc_match_allocate): Allow more than allocate
        object with SOURCE=.

2012-01-27  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51953
        * gfortran.dg/allocate_alloc_opt_13.f90: New.
        * gfortran.dg/allocate_alloc_opt_4.f90: Add -std=f2003
        and change dg-error string.

From-SVN: r183621

gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/allocate_alloc_opt_13.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/allocate_alloc_opt_4.f90

index 675c6eed6bb51ba3dfca36d8e207fffadc30e16e..1c709f0531205ca4be522bef6289875adf0a3a6d 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-27  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/51953
+       * match.c (gfc_match_allocate): Allow more than allocate
+       object with SOURCE=.
+
 2012-01-27  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/52016
index fd91921c9793004a2a0a17b228ea970a4355b49c..05853081173440bdc0578f4b5342512773b482ed 100644 (file)
@@ -3660,12 +3660,11 @@ alloc_opt_list:
              goto cleanup;
            }
 
-         if (head->next)
-           {
-             gfc_error ("SOURCE tag at %L requires only a single entity in "
-                        "the allocation-list", &tmp->where);
-             goto cleanup;
-            }
+         if (head->next
+             && gfc_notify_std (GFC_STD_F2008, "Fortran 2008: SOURCE tag at %L"
+                                " with more than a single allocate objects",
+                                &tmp->where) == FAILURE)
+           goto cleanup;
 
          source = tmp;
          tmp = NULL;
index b3440a03a845487165e87b377165c9252742a432..dae81122636ae5ba40cbe4177026abc2580d17ef 100644 (file)
@@ -1,3 +1,10 @@
+2012-01-27  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/51953
+       * gfortran.dg/allocate_alloc_opt_13.f90: New.
+       * gfortran.dg/allocate_alloc_opt_4.f90: Add -std=f2003
+       and change dg-error string.
+
 2012-01-27  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/52016
diff --git a/gcc/testsuite/gfortran.dg/allocate_alloc_opt_13.f90 b/gcc/testsuite/gfortran.dg/allocate_alloc_opt_13.f90
new file mode 100644 (file)
index 0000000..462b121
--- /dev/null
@@ -0,0 +1,25 @@
+! { dg-do compile }
+!
+! PR fortran/51953
+!
+!
+type t
+end type t
+
+class(t), allocatable :: a, c(:), e(:)
+class(t), pointer :: b, d(:)
+
+allocate (a, b, source=c(1))
+allocate (c(4), d(6), source=e)
+
+allocate (a, b, source=f())
+allocate (c(1), d(6), source=g())
+
+contains
+function f()
+  class(t), allocatable :: f
+end function
+function g()
+  class(t), allocatable :: g(:)
+end function
+end
index 89052ef16b9aa7a64863a7dc5907c4d0f207d43b..ed035b570922f299e17967c66d577ff1a6d936c3 100644 (file)
@@ -1,4 +1,5 @@
 ! { dg-do compile }
+! { dg-options "-std=f2003" }
 program a
 
   implicit none
@@ -16,7 +17,7 @@ program a
 
   allocate(integer(4) :: i(4), source=n) ! { dg-error "conflicts with the typespec" }
 
-  allocate(i(4), j(n), source=n) ! { dg-error "requires only a single entity" }
+  allocate(i(4), j(n), source=n) ! { dg-error "Fortran 2008: SOURCE tag at .1. with more than a single allocate objects" }
 
   allocate(x(4), source=n) ! { dg-error "type incompatible with" }