1# Copyright 2008-2023 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 16standard_testfile .cc 17 18if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ 19 {debug c++ additional_flags=-Wno-unused-comparison}] } { 20 return -1 21} 22 23############################################ 24 25if {![runto_main]} { 26 return 27} 28 29# Test global operator 30gdb_test "p a == 1" "= 11" "global operator" 31gdb_test "p a == 'a'" "= 12" "global operator overload" 32 33# Test ADL operator 34gdb_test "p bc == 1" "= 22" "ADL operator" 35gdb_test "p bc == 'a'" "= 23" "ADL operator overload" 36gdb_test "p B::BD::operator== (bc,'a')" "= 24" "fully qualified explicit operator call" 37 38# Test operator imported from anonymous namespace 39gdb_test "p d == 1" "= 33" "anonymous namespace operator" 40gdb_test "p d == 'a'" "= 34" "anonymous namespace operator overload" 41gdb_test "p d == 1.0f" "= 35" "anonymous namespace operator overload float" 42 43# Test operator imported by using directive 44gdb_test "p e == 1" "= 44" "imported operator" 45gdb_test "p e == 'a'" "= 45" "imported operator overload" 46gdb_test "p e == 1.0f" "= 46" "imported operator overload float" 47 48# Test member operator 49gdb_test "p g == 1" "= 55" "member operator" 50gdb_test "p g == 'a'" "= 56" "member operator overload" 51 52# Test that operators are not wrongly imported 53# by import declarations and namespace aliases 54gdb_test "p h == 1" "Cannot resolve function operator== to any overloaded instance" "namespace alias" 55gdb_test "p j == 1" "Cannot resolve function operator== to any overloaded instance" "imported declaration" 56 57# Test that indirectly imported operators work 58gdb_test "p l == 1" "= 88" 59 60# Test that we don't fall into an import loop 61gdb_test {p x[0]} {No symbol "operator\[\]" in current context.} 62