1 # Copyright 2012-2024 Free Software Foundation, Inc.
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.
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.
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/>.
18 require allow_cplus_tests
20 load_lib "cp-support.exp"
24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
32 if {[test_compiler_info {clang-*-*} c++]} {
38 gdb_test_no_output "set language c++" ""
39 gdb_test_no_output "set width 0" ""
41 proc do_check_holder {name {flags ""} {show_typedefs 1} {show_methods 1}
46 { base "public Base<T>" }
47 { field public "Simple<T> t;" }
48 { field public "Simple<T*> tstar;" }
52 lappend contents { field public "Holder<int>::Z z;" }
54 lappend contents { field public "Z z;" }
58 # Clang does not add accessibility information for typedefs:
59 # https://github.com/llvm/llvm-project/issues/57608
61 setup_xfail "clang 57608" *-*-*
63 lappend contents { typedef public "typedef Simple<Simple<T> > Z;" }
67 lappend contents { method public "double method();" }
71 regsub -all -- "T" $contents "int" contents
74 cp_test_ptype_class value $name "class" "Holder<int>" $contents \
78 proc do_check_typedef_holder {name {flags ""} {show_typedefs 1} {show_methods 1}
83 { field public "double a;" }
84 { field public "ns::scoped_double b;" }
85 { field public "global_double c;" }
89 { field public "class_double a;" }
90 { field public "class_double b;" }
91 { field public "class_double c;" }
96 lappend contents { typedef private "typedef double class_double;" }
101 lappend contents { method private "double method1(ns::scoped_double);" }
102 lappend contents { method private "double method2(global_double);" }
104 lappend contents { method private "class_double method1(class_double);" }
105 lappend contents { method private "class_double method2(class_double);" }
110 lappend contents { field private "TypedefHolder::class_double d;" }
112 lappend contents { field private "class_double d;" }
115 cp_test_ptype_class value2 $name "class" "TypedefHolder" $contents \
119 do_check_holder "basic test"
120 do_check_holder "no methods" "/m" 1 0
121 do_check_holder "no typedefs" "/t" 0 1
122 do_check_holder "no methods or typedefs" "/mt" 0 0
123 do_check_typedef_holder "typdefs class: basic test"
124 do_check_typedef_holder "typdefs class: no methods" "/m" 1 0
125 do_check_typedef_holder "typdefs class: no typedefs" "/t" 0 1 0
126 do_check_typedef_holder "typdefs class:no methods or typedefs" "/mt" 0 0
128 do_check_holder "raw" "/r" 1 1 1
129 do_check_holder "raw no methods" "/rm" 1 0 1
130 do_check_holder "raw no typedefs" "/rt" 0 1 1
131 do_check_holder "raw no methods or typedefs" "/rmt" 0 0 1
132 do_check_typedef_holder "typedef class: raw" "/r" 1 1 1
133 do_check_typedef_holder "typedef class: raw no methods" "/rm" 1 0 1
134 do_check_typedef_holder "typedef class: raw no typedefs" "/rt" 0 1 1
135 do_check_typedef_holder "typedef class: raw no methods or typedefs" "/rmt" 0 0 1
137 gdb_test_no_output "set print type methods off"
138 do_check_holder "basic test, default methods off" "" 1 0
139 do_check_holder "methods, default methods off" "/M" 1 1
140 do_check_holder "no typedefs, default methods off" "/t" 0 0
141 do_check_holder "methods, no typedefs, default methods off" "/Mt" 0 1
142 do_check_typedef_holder \
143 "typedef class: basic test, default methods off" "" 1 0
144 do_check_typedef_holder \
145 "typedef class: methods, default methods off" "/M" 1 1
146 do_check_typedef_holder \
147 "typedef class: no typedefs, default methods off" "/t" 0 0
148 do_check_typedef_holder \
149 "typedef class: methods, no typedefs, default methods off" "/Mt" 0 1
151 gdb_test_no_output "set print type typedefs off"
152 do_check_holder "basic test, default methods+typedefs off" "" 0 0
153 do_check_holder "methods, default methods+typedefs off" "/M" 0 1
154 do_check_holder "typedefs, default methods+typedefs off" "/T" 1 0
155 do_check_holder "methods typedefs, default methods+typedefs off" "/MT" 1 1
156 do_check_typedef_holder \
157 "typedef class: basic test, default methods+typedefs off" "" 0 0
158 do_check_typedef_holder \
159 "typedef class: methods, default methods+typedefs off" "/M" 0 1
160 do_check_typedef_holder \
161 "typedef class: typedefs, default methods+typedefs off" "/T" 1 0
162 do_check_typedef_holder \
163 "typedef class: methods typedefs, default methods+typedefs off" "/MT" 1 1