1# Copyright 2015-2020 Free Software Foundation, Inc.
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16load_lib "ada.exp"
17
18if { [skip_ada_tests] } { return -1 }
19
20standard_ada_testfile fun_renaming
21
22if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" } {
23  return -1
24}
25
26clean_restart ${testfile}
27
28set bp_location [gdb_get_line_number "BREAK" ${testdir}/fun_renaming.adb]
29runto "fun_renaming.adb:$bp_location"
30
31# Sanity check: make sure we can call a regular global function.
32gdb_test "print fun_rename_test_next(1)" " = 2"
33
34# Starting with GCC 6, renamed subprograms are materialized in the debugging
35# information: make sure we can call the regular global function using its
36# multiple names.
37
38set test "print fun_rename_test_n(1)"
39gdb_test_multiple $test $test {
40    -re " = 2\..*$gdb_prompt $"  {
41        pass $test
42    }
43    -re "No definition of \"fun_rename_test_n\" in current context\..*$gdb_prompt $" {
44        if {[test_compiler_info {gcc-6*}]} {
45            fail $test
46        } else {
47            xfail $test
48        }
49    }
50
51}
52set test "print renamed_fun_rename_test_next(1)"
53gdb_test_multiple $test $test {
54    -re " = 2\..*$gdb_prompt $" {
55        pass $test
56    }
57    -re "No definition of \"renamed_fun_rename_test_next\" in current context\..*$gdb_prompt $" {
58        if {[test_compiler_info {gcc-6*}]} {
59            fail $test
60        } else {
61            xfail $test
62        }
63    }
64}
65
66set test "print pack.renamed_fun_rename_test_next(1)"
67gdb_test_multiple $test $test {
68    -re " = 2\..*$gdb_prompt $" {
69        pass $test
70    }
71    -re "No definition of \"pack\.renamed_fun_rename_test_next\" in current context\..*$gdb_prompt $" {
72        if {[test_compiler_info {gcc-6*}]} {
73            fail $test
74        } else {
75            xfail $test
76        }
77    }
78    -re "Type <data variable, no debug info> is not a structure or union type\..*$gdb_prompt $" {
79        if {[test_compiler_info {gcc-6*}]} {
80            fail $test
81        } else {
82            xfail $test
83        }
84    }
85}
86