Allow enabling/disabling breakpoint location ranges
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / cpexprs.exp
index 52a293bc6d442df512d51e0ab6f483bb92c8f09b..463e89c12cdb6f1c01cf216bd3fa6da6c595c064 100644 (file)
@@ -1,6 +1,6 @@
 # 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.
 #
@@ -54,7 +54,7 @@ proc test_breakpoint {func} {
 # 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
@@ -67,13 +67,17 @@ proc add {func type print lst} {
     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)
@@ -139,32 +143,40 @@ add {base2::a_function} \
 
 # 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)} \
@@ -183,7 +195,7 @@ add {base::base(int)} \
 # 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 "
@@ -395,6 +407,10 @@ add {base::operator int} \
     {int (const base * const)} \
     - \
     -
+add {base::operator fluff const* const*} \
+    {const fluff * const *(const base * const)} \
+    - \
+    -
 
 # Templates
 add {tclass<char>::do_something} \
@@ -680,7 +696,7 @@ if {[get_compiler_info "c++"]} {
     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
 }
 
@@ -734,5 +750,17 @@ 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\)>}
 
+# 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
This page took 0.04434 seconds and 4 git commands to generate.