# cpexprs.exp - C++ expressions tests
#
-# Copyright 2008-2013 Free Software Foundation, Inc.
+# Copyright 2008-2017 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 } {
- if { [istarget arm*-*eabi*] } {
- set ret "$type *"
+proc ctor_ret { type } {
+ if { [istarget arm*-*eabi*] || [is_aarch32_target] } {
+ 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)} \
# GCC returns void * instead of $type *; RealView appears to do
# the same.
proc dtor { type } {
- if { [istarget arm*-*eabi*] } {
+ if { [istarget arm*-*eabi*] || [is_aarch32_target] } {
set ret "void *"
} else {
set ret "void "
{int (const base * const)} \
- \
-
+add {base::operator fluff const* const*} \
+ {const fluff * const *(const base * const)} \
+ - \
+ -
# Templates
add {tclass<char>::do_something} \
return -1
}
-if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
return -1
}
gdb_test "p CV_f('cpexprs.cc'::CV::t)" \
{ = {int \(int\)} 0x[0-9a-f]+ <CV_f\(int\)>}
+# Make sure conversion operator names are canonicalized and properly
+# "spelled."
+gdb_test "p base::operator const fluff * const *" \
+ [get "base::operator fluff const* const*" print] \
+ "canonicalized conversion operator name 1"
+gdb_test "p base::operator const fluff* const*" \
+ [get "base::operator fluff const* const*" print] \
+ "canonicalized conversion operator name 2"
+gdb_test "p base::operator derived*" \
+ "There is no field named operator derived\\*" \
+ "undefined conversion operator"
+
gdb_exit
return 0