Build two gdb.cp testcases with -Wno-unused-comparison
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / operator.exp
CommitLineData
b811d2c2 1# Copyright 2008-2020 Free Software Foundation, Inc.
4c3376c8
SW
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
f5f3a911
TT
16standard_testfile .cc
17
735d5a07
GB
18if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
19 {debug c++ additional_flags=-Wno-unused-comparison}] } {
4c3376c8
SW
20 return -1
21}
22
23############################################
24
25if ![runto_main] then {
26 perror "couldn't run to breakpoint main"
27 continue
28}
29
30# Test global operator
31gdb_test "p a == 1" "= 11" "global operator"
32gdb_test "p a == 'a'" "= 12" "global operator overload"
33
34# Test ADL operator
35gdb_test "p bc == 1" "= 22" "ADL operator"
36gdb_test "p bc == 'a'" "= 23" "ADL operator overload"
cdc7edd7 37gdb_test "p B::BD::operator== (bc,'a')" "= 24" "fully qualified explicit operator call"
4c3376c8
SW
38
39# Test operator imported from anonymous namespace
40gdb_test "p d == 1" "= 33" "anonymous namespace operator"
41gdb_test "p d == 'a'" "= 34" "anonymous namespace operator overload"
42gdb_test "p d == 1.0f" "= 35" "anonymous namespace operator overload float"
43
44# Test operator imported by using directive
45gdb_test "p e == 1" "= 44" "imported operator"
46gdb_test "p e == 'a'" "= 45" "imported operator overload"
47gdb_test "p e == 1.0f" "= 46" "imported operator overload float"
48
49# Test member operator
50gdb_test "p g == 1" "= 55" "member operator"
51gdb_test "p g == 'a'" "= 56" "member operator overload"
52
53# Test that operators are not wrongly imported
54# by import declarations and namespace aliases
55gdb_test "p h == 1" "Cannot resolve function operator== to any overloaded instance" "namespace alias"
56gdb_test "p j == 1" "Cannot resolve function operator== to any overloaded instance" "imported declaration"
57
58# Test that indirectly imported operators work
59gdb_test "p l == 1" "= 88"
099ef718
SW
60
61# Test that we don't fall into an import loop
62gdb_test {p x[0]} {No symbol "operator\[\]" in current context.}
This page took 1.228879 seconds and 4 git commands to generate.