nncarlson / gfortran.dg

The GFortran testsuite rigged for testing other Fortran compilers
7 stars 2 forks source link

Wrong syntax for PDT constructor in several test files #11

Open nncarlson opened 6 years ago

nncarlson commented 6 years ago

Several test problems use an invalid constructor syntax for parametrized data types. The current PDT implementation conflates type parameters with type components when the two are completely separate things. This error has been reported; see PR84120 for details of what is wrong and why.

Note that gfortran currently rejects the correct constructor syntax

For pdt_23.f03 here is the patch that corrects the constructor error (this file has additional errors):

diff --git a/pdt_23.f03 b/pdt_23.f03
index e38cf67..2748390 100644
--- a/pdt_23.f03
+++ b/pdt_23.f03
@@ -15,12 +15,12 @@ program p
    type(t(:)), allocatable :: x
    allocate (t(2) :: x)

-   x = t(2,'ab')
+   x = t(2)('ab')
    write (buffer, *) x%c ! Tests the fix for PR82720
    read (buffer, *) chr
    if (trim (chr) .ne. 'ab') stop 1

-   x = t(3,'xyz')
+   x = t(3)('xyz')
    if (len (x%c) .ne. 3) stop 1
    write (buffer, *) x   ! Tests the fix for PR82719
    read (buffer, *) i, chr

For pdt_3.f03 this patch corrects the constructor error:

diff --git a/pdt_3.f03 b/pdt_3.f03diff --git a/pdt_3.f03 b/pdt_3.f03
index 8b3b84a..744acb0 100644
--- a/pdt_3.f03
+++ b/pdt_3.f03
@@ -57,7 +57,7 @@ end module
   matrix = w%d

 ! TODO - for some reason, using w%d directly in the source causes a seg fault.
-  allocate (cz, source = mytype(ftype, d_dim, 0, matrix))
+  allocate (cz, source = mytype(ftype, d_dim)(0, matrix))
   select type (cz)
     type is (mytype(ftype, *))
       if (int (sum (cz%d)) .ne. 136) stop 1

index 8b3b84a..744acb0 100644
--- a/pdt_3.f03
+++ b/pdt_3.f03
@@ -57,7 +57,7 @@ end module
   matrix = w%d

 ! TODO - for some reason, using w%d directly in the source causes a seg fault.
-  allocate (cz, source = mytype(ftype, d_dim, 0, matrix))
+  allocate (cz, source = mytype(ftype, d_dim)(0, matrix))
   select type (cz)
     type is (mytype(ftype, *))
       if (int (sum (cz%d)) .ne. 136) stop 1