From dadf0e9c7a2409d46fc5ff8e1b1a1c7b086dedbf Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Tue, 9 Feb 2010 13:16:33 +0000 Subject: [PATCH] * gdb.ada/ptype_tagged_param: New testcase. --- gdb/testsuite/ChangeLog | 4 ++ gdb/testsuite/gdb.ada/ptype_tagged_param.exp | 47 +++++++++++++++++++ .../gdb.ada/ptype_tagged_param/foo.adb | 23 +++++++++ .../gdb.ada/ptype_tagged_param/pck.adb | 30 ++++++++++++ .../gdb.ada/ptype_tagged_param/pck.ads | 29 ++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 gdb/testsuite/gdb.ada/ptype_tagged_param.exp create mode 100644 gdb/testsuite/gdb.ada/ptype_tagged_param/foo.adb create mode 100644 gdb/testsuite/gdb.ada/ptype_tagged_param/pck.adb create mode 100644 gdb/testsuite/gdb.ada/ptype_tagged_param/pck.ads diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4bbbd9377e3..ae7df70a6fe 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-02-09 Joel Brobecker + + * gdb.ada/ptype_tagged_param: New testcase. + 2010-02-08 Tom Tromey PR c++/8017: diff --git a/gdb/testsuite/gdb.ada/ptype_tagged_param.exp b/gdb/testsuite/gdb.ada/ptype_tagged_param.exp new file mode 100644 index 00000000000..39b64d5432e --- /dev/null +++ b/gdb/testsuite/gdb.ada/ptype_tagged_param.exp @@ -0,0 +1,47 @@ +# Copyright 2010 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 . + +if $tracelevel then { + strace $tracelevel +} + +load_lib "ada.exp" + +set testdir "ptype_tagged_param" +set testfile "${testdir}/foo" +set srcfile ${srcdir}/${subdir}/${testfile}.adb +set binfile ${objdir}/${subdir}/${testfile} + +file mkdir ${objdir}/${subdir}/${testdir} +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } { + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto "position_x" ] then { + return -1 +} + +set eol "\[\r\n\]+" +set sp "\[ \t\]*" + +gdb_test "ptype s" \ + "type = new pck.shape with record${eol}${sp}r: integer;${eol}end record" \ + "ptype s" + diff --git a/gdb/testsuite/gdb.ada/ptype_tagged_param/foo.adb b/gdb/testsuite/gdb.ada/ptype_tagged_param/foo.adb new file mode 100644 index 00000000000..3a124534e9e --- /dev/null +++ b/gdb/testsuite/gdb.ada/ptype_tagged_param/foo.adb @@ -0,0 +1,23 @@ +-- Copyright 2010 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 . + +with Pck; use Pck; + +procedure Foo is + My_Shape : Circle := (X => 1, Y => 2, R => 3); + X : Integer; +begin + X := Position_X (My_Shape); +end Foo; diff --git a/gdb/testsuite/gdb.ada/ptype_tagged_param/pck.adb b/gdb/testsuite/gdb.ada/ptype_tagged_param/pck.adb new file mode 100644 index 00000000000..e54bcb1725a --- /dev/null +++ b/gdb/testsuite/gdb.ada/ptype_tagged_param/pck.adb @@ -0,0 +1,30 @@ +-- Copyright 2010 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 . + +package body Pck is + + function Position_X (S : in Shape) return Integer is + begin + return S.X; + end Position_X; + + function Area (C : in Circle) return Integer is + begin + -- Very crude calculation... + return 6 * C.R * C.R; + end Area; + +end Pck; + diff --git a/gdb/testsuite/gdb.ada/ptype_tagged_param/pck.ads b/gdb/testsuite/gdb.ada/ptype_tagged_param/pck.ads new file mode 100644 index 00000000000..8d8f1d01ad2 --- /dev/null +++ b/gdb/testsuite/gdb.ada/ptype_tagged_param/pck.ads @@ -0,0 +1,29 @@ +-- Copyright 2010 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 . + +package Pck is + + type Shape is abstract tagged record + X, Y: Integer; + end record; + function Position_X (S : in Shape) return Integer; + + type Circle is new Shape with record + R : Integer; + end record; + function Area (C : in Circle) return Integer; + +end Pck; + -- 2.30.2