From patchwork Fri Jul 11 09:21:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keven Boell X-Patchwork-Id: 2029 Received: (qmail 793 invoked by alias); 11 Jul 2014 09:22:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 739 invoked by uid 89); 11 Jul 2014 09:22:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: mga14.intel.com Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Jul 2014 09:22:08 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 11 Jul 2014 02:15:59 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 11 Jul 2014 02:21:48 -0700 Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [172.28.50.14]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s6B9LlLA020760; Fri, 11 Jul 2014 10:21:47 +0100 Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [127.0.0.1]) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8) with ESMTP id s6B9LmvB007066; Fri, 11 Jul 2014 11:21:48 +0200 Received: (from kboell@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id s6B9LmLd007065; Fri, 11 Jul 2014 11:21:48 +0200 From: Keven Boell To: gdb-patches@sourceware.org Cc: keven.boell@intel.com, sanimir.agovic@intel.com Subject: [V2 18/23] test: dynamic arrays passed to functions. Date: Fri, 11 Jul 2014 11:21:30 +0200 Message-Id: <1405070495-6948-19-git-send-email-keven.boell@intel.com> In-Reply-To: <1405070495-6948-1-git-send-email-keven.boell@intel.com> References: <1405070495-6948-1-git-send-email-keven.boell@intel.com> Tests for dynamic arrays passed to functions and returned from functions. 2014-05-28 Keven Boell Sanimir Agovic testsuite/gdb.fortran/: * vla-func.f90: New file. * vla-func.exp: New file. Change-Id: Ic3eb212f35f599e4c10a284c23125491653b17df Signed-off-by: Keven Boell --- gdb/testsuite/gdb.fortran/vla-func.exp | 61 +++++++++++++++++++++++++++ gdb/testsuite/gdb.fortran/vla-func.f90 | 71 ++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 gdb/testsuite/gdb.fortran/vla-func.exp create mode 100644 gdb/testsuite/gdb.fortran/vla-func.f90 diff --git a/gdb/testsuite/gdb.fortran/vla-func.exp b/gdb/testsuite/gdb.fortran/vla-func.exp new file mode 100644 index 0000000..f0f236b --- /dev/null +++ b/gdb/testsuite/gdb.fortran/vla-func.exp @@ -0,0 +1,61 @@ +# Copyright 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +standard_testfile ".f90" + +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ + {debug f90 quiet}] } { + return -1 +} + +if ![runto MAIN__] then { + perror "couldn't run to breakpoint MAIN__" + continue +} + +# Check VLA passed to first Fortran function. +gdb_breakpoint [gdb_get_line_number "func1-vla-passed"] +gdb_continue_to_breakpoint "func1-vla-passed" +gdb_test "print vla" " = \\( *\\( *22, *22, *22,\[()22, .\]*\\)" \ + "print vla (func1)" +gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10,10\\\)" \ + "ptype vla (func1)" + +gdb_breakpoint [gdb_get_line_number "func1-vla-modified"] +gdb_continue_to_breakpoint "func1-vla-modified" +gdb_test "print vla(5,5)" " = 55" "print vla(5,5) (func1)" +gdb_test "print vla(7,7)" " = 77" "print vla(5,5) (func1)" + +# Check if the values are correct after returning from func1 +gdb_breakpoint [gdb_get_line_number "func1-returned"] +gdb_continue_to_breakpoint "func1-returned" +gdb_test "print ret" " = .TRUE." "print ret after func1 returned" + +# Check VLA passed to second Fortran function +gdb_breakpoint [gdb_get_line_number "func2-vla-passed"] +gdb_continue_to_breakpoint "func2-vla-passed" +gdb_test "print vla" \ + " = \\\(44, 44, 44, 44, 44, 44, 44, 44, 44, 44\\\)" \ + "print vla (func2)" +gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10\\\)" \ + "ptype vla (func2)" + +# Check if the returned VLA has the correct values and ptype. +gdb_breakpoint [gdb_get_line_number "func2-returned"] +gdb_continue_to_breakpoint "func2-returned" +gdb_test "print vla3" " = \\\(1, 2, 44, 4, 44, 44, 44, 8, 44, 44\\\)" \ + "print vla3 (after func2)" +gdb_test "ptype vla3" "type = integer\\\(kind=4\\\) \\\(10\\\)" \ + "ptype vla3 (after func2)" diff --git a/gdb/testsuite/gdb.fortran/vla-func.f90 b/gdb/testsuite/gdb.fortran/vla-func.f90 new file mode 100644 index 0000000..4f45da1 --- /dev/null +++ b/gdb/testsuite/gdb.fortran/vla-func.f90 @@ -0,0 +1,71 @@ +! Copyright 2014 Free Software Foundation, Inc. +! +! This program is free software; you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation; either version 2 of the License, or +! (at your option) any later version. +! +! This program is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with this program; if not, write to the Free Software +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +logical function func1 (vla) + implicit none + integer, allocatable :: vla (:, :) + func1 = allocated(vla) + vla(5,5) = 55 ! func1-vla-passed + vla(7,7) = 77 + return ! func1-vla-modified +end function func1 + +function func2(vla) + implicit none + integer :: vla (:) + integer :: func2(size(vla)) + integer :: k + + vla(1) = 1 ! func2-vla-passed + vla(2) = 2 + vla(4) = 4 + vla(8) = 8 + + func2 = vla +end function func2 + +program vla_func + implicit none + interface + logical function func1 (vla) + integer :: vla (:, :) + end function + end interface + interface + function func2 (vla) + integer :: vla (:) + integer func2(size(vla)) + end function + end interface + + logical :: ret + integer, allocatable :: vla1 (:, :) + integer, allocatable :: vla2 (:) + integer, allocatable :: vla3 (:) + + ret = .FALSE. + + allocate (vla1 (10,10)) + vla1(:,:) = 22 + + allocate (vla2 (10)) + vla2(:) = 44 + + ret = func1(vla1) + vla3 = func2(vla2) ! func1-returned + + ret = .TRUE. ! func2-returned +end program vla_func