c++/24367: Infinite recursion of typedef substitution
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / class2.exp
index 9d5534566d2876bb9fef3538d20711d12e0dae1d..14dad14bd0d5facacec621ee82ac4c77ac6a32eb 100644 (file)
@@ -1,50 +1,37 @@
-# Copyright 2003 Free Software Foundation, Inc.
+# Copyright 2003-2019 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
-
-if $tracelevel then {
-    strace $tracelevel
-    }
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 if { [skip_cplus_tests] } { continue }
 
-set prms_id 0
-set bug_id 0
 
-set testfile "class2"
-set srcfile ${testfile}.cc
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .cc
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
-if [get_compiler_info ${binfile} "c++"] {
+if [get_compiler_info "c++"] {
     return -1
 }
 
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-    gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+    return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
-# Start with "set print object off".
+# Start with "set print object off" and "set print symbol off".
 
-gdb_test "set print object off" ""
+gdb_test_no_output "set print object off"
+gdb_test_no_output "set print symbol off"
 
 if ![runto_main] then {
     perror "couldn't run to main"
@@ -113,3 +100,32 @@ gdb_test_multiple "print * abp" "print * abp at marker return 0, s-p-o off" {
 gdb_test "print * (B *) abp" \
     "= {.*a1 = 200.*b1 = 201.*b2 = 202}" \
     "print * (B *) abp at marker return 0"
+
+# Print the "D" object.
+
+gdb_test "print delta" \
+    "= {.*d1 = 400}" \
+    "print delta with \"print object\" off"
+
+# Printing the value of an object containing no data fields:
+
+gdb_test "p e" "= \{<No data fields>\}" "print object with no data fields"
+
+# Printing NULL pointers with "set print object on".
+
+gdb_test_no_output "set print object on"
+gdb_test "p acp" "= \\(C \\*\\) ${hex}"
+gdb_test "p acp->c1" "\\(A \\*\\) 0x0"
+gdb_test "p acp->c2" "\\(A \\*\\) ${hex}f"
+
+# Print the "D" object with "set print object on".
+# There's no difference in output, but this exercises vtable lookup
+# with a typedef'd baseclass.
+
+gdb_test "print delta" \
+    "= {.*d1 = 400}" \
+    "print delta with \"print object\" on"
+
+# Regression test for PR c++/15401.
+# Check that the type printed is a reference.
+gdb_test "p aref" " = \\(A \\&\\) .*"
This page took 0.024974 seconds and 4 git commands to generate.