# cpexprs.exp - C++ expressions tests
#
-# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
+# Copyright 2008-2016 Free Software Foundation, Inc.
#
# Contributed by Red Hat, originally written by Keith Seitz.
#
# Usage:
# add NAME TYPE PRINT LST
# add NAME TYPE PRINT -
-proc add {func type print lst} {
+proc add_type_regexp {func type print lst} {
global all_functions CONVAR ADDR
set all_functions($func,type) $type
regsub {\(void\)} $print {()} print
set all_functions($func,print) \
- "$CONVAR = {[string_to_regexp $type]} $ADDR <[string_to_regexp $print].*>"
+ "$CONVAR = {$type} $ADDR <[string_to_regexp $print].*>"
if {$lst == "-"} {
set lst "$func"
}
set all_functions($func,list) ".*// [string_to_regexp $lst]"
}
+proc add {func type print lst} {
+ add_type_regexp $func [string_to_regexp $type] $print $lst
+}
+
proc get {func cmd} {
global all_functions
return $all_functions($func,$cmd)
# On targets using the ARM EABI, the constructor is expected to return
# "this".
-proc ctor { type arglist } {
+proc ctor_ret { type } {
if { [istarget arm*-*eabi*] } {
- set ret "$type *"
+ return "$type *"
} else {
- set ret "void "
+ return "void "
}
+}
+
+proc ctor_prefix { type } {
+ set ret [ctor_ret $type]
+ return "${ret}($type * const"
+}
+
+proc ctor { type arglist } {
if { $arglist != "" } {
set arglist ", $arglist"
}
- return "${ret}($type * const$arglist)"
+ return "[ctor_prefix $type]$arglist)"
}
add {derived::derived} \
[ctor derived ""] \
- \
-
-add {base1::base1(void)} \
- [ctor base1 "const void ** const"] \
+add_type_regexp {base1::base1(void)} \
+ "[string_to_regexp [ctor_prefix base1]], (const )?void \\*\\*( const)?\\)" \
- \
-
add {base1::base1(int)} \
[ctor base1 "int"] \
- \
-
-add {base2::base2} \
- [ctor base2 "const void ** const"] \
+add_type_regexp {base2::base2} \
+ "[string_to_regexp [ctor_prefix base2]], (const )?void \\*\\*( const)?\\)" \
- \
-
add {base::base(void)} \
- \
-
-# Overloaded methods (all are const -- we try to use the void
-# method with and without specifying "const")
-add {base::overload(void)} \
- {int (const base * const)} \
- - \
- {base::overload(void) const}
+# Overloaded methods (all are const)
add {base::overload(void) const} \
{int (const base * const)} \
- \
{operation_1<T>::function}
# Start the test
-if {$tracelevel} {
- strace $tracelevel
-}
-
if {[skip_cplus_tests]} { continue }
# On SPU this test fails because the executable exceeds local storage size.
# test running programs
#
-set testfile "cpexprs"
-set srcfile "${testfile}.cc"
-set binfile [file join $objdir $subdir $testfile]
+standard_testfile .cc
-if {[gdb_compile [file join $srcdir $subdir $srcfile] $binfile \
- executable {debug c++}] != "" } {
- untested "$testfile.exp"
+if {[get_compiler_info "c++"]} {
return -1
}
-if {[get_compiler_info $binfile "c++"]} {
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
return -1
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir [file join $srcdir $subdir]
-gdb_load $binfile
-
if {![runto_main]} {
perror "couldn't run to breakpoint"
continue
}
}
+# Test c/v gets recognized even without quoting.
+foreach cv {{} { const} { volatile} { const volatile}} {
+ set test "p 'CV::m(int)$cv'"
+ gdb_test_multiple $test $test {
+ -re "( = {.*} 0x\[0-9a-f\]+ <CV::m.*>)\r\n$gdb_prompt $" {
+ # = {void (CV * const, CV::t)} 0x400944 <CV::m(int)>
+ set correct $expect_out(1,string)
+ pass $test
+ }
+ }
+ if {"$cv" != ""} {
+ setup_kfail c++/14186 *-*-*
+ }
+ gdb_test "p CV::m(int)$cv" [string_to_regexp $correct]
+}
+
+# Test TYPENAME:: gets recognized even in parentheses.
+gdb_test "p CV_f(int)" { = {int \(int\)} 0x[0-9a-f]+ <CV_f\(int\)>}
+gdb_test "p CV_f(CV::t)" { = {int \(int\)} 0x[0-9a-f]+ <CV_f\(int\)>}
+gdb_test "p CV_f(CV::i)" " = 43"
+
+gdb_test "p CV_f('cpexprs.cc'::CV::t)" \
+ { = {int \(int\)} 0x[0-9a-f]+ <CV_f\(int\)>}
+
gdb_exit
return 0