]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/90744 (Bogus length for character temporaries passed to exter...
authorThomas Koenig <tkoenig@gcc.gnu.org>
Wed, 12 Jun 2019 20:08:38 +0000 (20:08 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Wed, 12 Jun 2019 20:08:38 +0000 (20:08 +0000)
2019-06-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
    Tomáš Trnka  <trnka@scm.com>

    Backport from trunk
    PR fortran/90744
    * trans-types.c (get_formal_from_actual_arglist): Unset typespec
    flags which make no sense for procedures without explicit
    interface.

2019-06-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
    Tomáš Trnka  <trnka@scm.com>

    Backport from trunk
    PR fortran/90744
    * gfortran.dg/deferred_character_33.f90: New test.
    * gfortran.dg/deferred_character_33a.f90: New test.

Co-Authored-By: Tomáš Trnka <trnka@scm.com>
From-SVN: r272214

gcc/fortran/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/deferred_character_33.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/deferred_character_33a.f90 [new file with mode: 0644]

index c4b87ed513adbdea9effcfbabc07d14699dd6bbf..a6b01fc9cfd21920ff203a66d6b18196c941f0e7 100644 (file)
@@ -1,3 +1,12 @@
+2019-06-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
+       Tomáš Trnka  <trnka@scm.com>
+
+       Backport from trunk
+       PR fortran/90744
+       * trans-types.c (get_formal_from_actual_arglist): Unset typespec
+       flags which make no sense for procedures without explicit
+       interface.
+
 2019-05-05  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/90344
index 587c1a469818fb9b8ff1f5706319468888ff3fca..b003836585c4da47fc52b810bb27a86acdf0837d 100644 (file)
@@ -1,3 +1,11 @@
+2019-06-12  Thomas Koenig  <tkoenig@gcc.gnu.org>
+       Tomáš Trnka  <trnka@scm.com>
+
+       Backport from trunk
+       PR fortran/90744
+       * gfortran.dg/deferred_character_33.f90: New test.
+       * gfortran.dg/deferred_character_33a.f90: New test.
+
 2019-06-04  Iain Sandoe  <iain@sandoe.co.uk>
 
        Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/deferred_character_33.f90 b/gcc/testsuite/gfortran.dg/deferred_character_33.f90
new file mode 100644 (file)
index 0000000..ec864d8
--- /dev/null
@@ -0,0 +1,35 @@
+! { dg-do run }
+! { dg-additional-sources deferred_character_33a.f90 }
+! PR fortran/90744 - this used to pass a wrong length
+! to an external function without a prototype.
+! Original test case by Tomáš Trnka.
+module StringModule
+   implicit none
+
+contains
+   function getstr()
+      character(:), allocatable :: getstr
+
+      getstr = 'OK'
+   end function
+end module
+module TestModule
+   use StringModule
+   implicit none
+
+contains
+   subroutine DoTest()
+      if (.false.) then
+         call convrs('A',getstr())
+      else
+         call convrs('B',getstr())
+      end if
+   end subroutine
+end module
+program external_char_length
+   use TestModule
+
+   implicit none
+
+   call DoTest()
+end program
diff --git a/gcc/testsuite/gfortran.dg/deferred_character_33a.f90 b/gcc/testsuite/gfortran.dg/deferred_character_33a.f90
new file mode 100644 (file)
index 0000000..db117cc
--- /dev/null
@@ -0,0 +1,9 @@
+! { dg-do compile }
+subroutine convrs(quanty,fromto)
+   implicit none
+
+   character(*), intent(in) :: quanty,fromto
+
+   if (len(fromto) /= 2) stop 1
+   if (fromto /= 'OK') stop 2
+end subroutine