Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.cp / ptype-flags.exp
blob476c075f2872128e3978547d5a2ee231ec22e7de
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/>.
16 set nl          "\[\r\n\]+"
18 require allow_cplus_tests
20 load_lib "cp-support.exp"
22 standard_testfile .cc
24 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
25     return -1
28 if {![runto_main]} {
29     return
32 if {[test_compiler_info {clang-*-*} c++]} {
33     set using_clang true
34 } else {
35     set using_clang false
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}
42                       {raw 0}} {
43     global using_clang
45     set contents {
46         { base "public Base<T>" }
47         { field public "Simple<T> t;" }
48         { field public "Simple<T*> tstar;" }
49     }
51     if {$raw} {
52         lappend contents { field public "Holder<int>::Z z;" }
53     } else {
54         lappend contents { field public "Z z;" }
55     }
57     if {$show_typedefs} {
58         # Clang does not add accessibility information for typedefs:
59         # https://github.com/llvm/llvm-project/issues/57608
60         if {$using_clang} {
61             setup_xfail "clang 57608" *-*-*
62         }
63         lappend contents { typedef public "typedef Simple<Simple<T> > Z;" }
64     }
66     if {$show_methods} {
67         lappend contents { method public "double method();" }
68     }
70     if {$raw} {
71         regsub -all -- "T" $contents "int" contents
72     }
74     cp_test_ptype_class value $name "class" "Holder<int>" $contents \
75         "" {} $flags
78 proc do_check_typedef_holder {name {flags ""} {show_typedefs 1} {show_methods 1}
79                               {raw 0}} {
81     if {$raw} {
82         set contents {
83             { field public "double a;" }
84             { field public "ns::scoped_double b;" }
85             { field public "global_double c;" }
86         }
87     } else {
88         set contents {
89             { field public "class_double a;" }
90             { field public "class_double b;" }
91             { field public "class_double c;" }
92         }
93     }
95     if {$show_typedefs} {
96         lappend contents { typedef private "typedef double class_double;" }
97     }
99     if {$show_methods} {
100         if {$raw} {
101             lappend contents { method private "double method1(ns::scoped_double);" }
102             lappend contents { method private "double method2(global_double);" }
103         } else {
104             lappend contents { method private "class_double method1(class_double);" }
105             lappend contents { method private "class_double method2(class_double);" }
106         }
107     }
109     if {$raw} {
110         lappend contents { field private "TypedefHolder::class_double d;" }
111     } else {
112         lappend contents { field private "class_double d;" }
113     }
115     cp_test_ptype_class value2 $name "class" "TypedefHolder" $contents \
116         "" {} $flags
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