Handle void * conversions in FreeBSD/x86 native code to fix C++ build.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / cpexprs.exp
index e112c5ed9976f1b4caae7753571bcef0f2663ace..baf0801ba563d592e2b5593ba9c5e6e01935e9a0 100644 (file)
@@ -1,6 +1,6 @@
 # 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.
 #
 proc test_breakpoint {func} {
     global DEC
 
-    # Restart every time
-    if {![runto_main]} {
-       perror "could not run to main when attempting to break at $func"
+    # Return to the top of the test function every time.
+    delete_breakpoints
+    if { ! [gdb_breakpoint test_function] } {
+       fail "set test_function breakpoint for $func"
+    } elseif { [gdb_test "continue" \
+                   "Continuing.\r\n\r\nBreakpoint $DEC+,.*test_function.*" \
+                   ""] != 0 } {
+       fail "continue to test_function for $func"
     } else {
        gdb_breakpoint "$func"
        set i [expr {[string last : $func] + 1}]
@@ -49,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
@@ -62,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)
@@ -113,7 +122,7 @@ set ADDR "0x$HEX+"; # address
 array set all_functions {}
 
 # "Normal" functions/methods
-add {main} \
+add {test_function} \
     {int (int, char **)} \
     - \
     -
@@ -134,32 +143,40 @@ add {base2::a_function} \
 
 # 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)} \
@@ -191,12 +208,7 @@ add {base::~base} \
     - \
     -
 
-# 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)} \
     - \
@@ -663,35 +675,27 @@ add {policyd5::function} \
     {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.
+if { [istarget "spu*-*-*"] } {
+        return 0
+}
+
 #
 # 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
@@ -712,11 +716,35 @@ foreach name [get_functions list] {
 
 # Running to breakpoint -- use any function we can "list"
 foreach name [get_functions list] {
-    # Skip "main", since test_breakpoint uses it
-    if {[string compare $name "main"] != 0} {
+    # Skip "test_function", since test_breakpoint uses it
+    if {[string compare $name "test_function"] != 0} {
        test_breakpoint $name
     }
 }
 
+# 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
This page took 0.028226 seconds and 4 git commands to generate.