aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp/local-static.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.cp/local-static.exp')
-rw-r--r--gdb/testsuite/gdb.cp/local-static.exp125
1 files changed, 109 insertions, 16 deletions
diff --git a/gdb/testsuite/gdb.cp/local-static.exp b/gdb/testsuite/gdb.cp/local-static.exp
index 581efa3..5e8eaaa 100644
--- a/gdb/testsuite/gdb.cp/local-static.exp
+++ b/gdb/testsuite/gdb.cp/local-static.exp
@@ -19,28 +19,98 @@
standard_testfile .c
+# A few expected errors.
+set syntax_re "A syntax error in expression, near.*"
+set cannot_resolve_re "Cannot resolve method S::method to any overloaded instance"
+
+# Build an "Cannot resolve method ..." expected error string for
+# method METH.
+#
+proc cannot_resolve {meth} {
+ return "Cannot resolve method $meth to any overloaded instance"
+}
+
# A list of scopes that have the static variables that we want to
# print. Each entry has, in order, the scope/function name, and the
-# prefix used by the static variables. (The prefix exists to make it
-# easier to debug the test if something goes wrong.)
-
- #SCOPE #PREFIX
+# prefix used by the static variables. The prefix exists both to make
+# it easier to debug the test if something goes wrong, and, to make
+# sure that printing the static local of one method overload doesn't
+# find the variables of the wrong overload.
+#
+# While at it, we also try printing each scope without the static
+# local, to check that the parse copes with cv overloads without
+# quoting. That's what the third and forth columns are for. Note
+# that printing "func()" is different from "func(void)". The former
+# is an inferior function call, while the latter is a reference to the
+# function.
+
+ #SCOPE #PREFIX #PRINT-SCOPE-QUOTED
+ #PRINT-SCOPE-UNQUOTED (opt)
set cxx_scopes_list {
- {"S::method()" "S_M"}
- {"S::static_method()" "S_SM"}
- {"S::inline_method()" "S_IM"}
- {"S::static_inline_method()" "S_SIM"}
- {"S2<int>::method()" "S2_M"}
- {"S2<int>::static_method()" "S2_SM"}
- {"S2<int>::inline_method()" "S2_IM"}
- {"S2<int>::static_inline_method()" "S2_SIM"}
- {"free_func()" "FF"}
- {"free_inline_func()" "FIF"}
+ {"S::method()" "S_M" {= \\{void \\(S \\* const\\)\\} $hex <S::method\\(\\)>}
+ {[cannot_resolve "S::method"]}}
+
+ {"S::method() const" "S_M_C" {= \\{void \\(const S \\* const\\)\\} $hex <S::method\\(\\) const>}
+ $syntax_re}
+
+ {"S::method() volatile" "S_M_V" {= \\{void \\(volatile S \\* const\\)\\} $hex <S::method\\(\\) volatile>}
+ $syntax_re}
+
+ {"S::method() const volatile" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}
+ $syntax_re}
+
+ {"S::method() volatile const" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}
+ $syntax_re}
+
+ {"S::method(void)" "S_M" {= \\{void \\(S \\* const\\)\\} $hex <S::method\\(\\)>}}
+ {"S::method(void) const" "S_M_C" {= \\{void \\(const S \\* const\\)\\} $hex <S::method\\(\\) const>}}
+ {"S::method(void) volatile" "S_M_V" {= \\{void \\(volatile S \\* const\\)\\} $hex <S::method\\(\\) volatile>}}
+ {"S::method(void) const volatile" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}}
+ {"S::method(void) volatile const" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}}
+
+ {"S::static_method()" "S_SM" {= \\{void \\(void\\)\\} $hex <S::static_method\\(\\)>}
+ "void"}
+
+ {"S::static_method(void)" "S_SM" {= \\{void \\(void\\)\\} $hex <S::static_method\\(\\)>}}
+
+ {"S::inline_method()" "S_IM" {= \\{void \\(S \\* const\\)\\} $hex <S::inline_method\\(\\)>}
+ {[cannot_resolve "S::inline_method"]}}
+
+ {"S::inline_method(void)" "S_IM" {= \\{void \\(S \\* const\\)\\} $hex <S::inline_method\\(\\)>}}
+
+ {"S::static_inline_method()" "S_SIM" {= \\{void \\(void\\)\\} $hex <S::static_inline_method\\(\\)>}
+ "void"}
+
+ {"S::static_inline_method(void)" "S_SIM" {= \\{void \\(void\\)\\} $hex <S::static_inline_method\\(\\)>}}
+
+ {"S2<int>::method()" "S2_M" {= \\{void \\(S2<int> \\* const\\)\\} $hex <S2<int>::method\\(\\)>}
+ {[cannot_resolve "S2<int>::method"]}}
+
+ {"S2<int>::static_method()" "S2_SM" {= \\{void \\(void\\)\\} $hex <S2<int>::static_method\\(\\)>}
+ "void"}
+
+ {"S2<int>::inline_method()" "S2_IM" {= \\{void \\(S2<int> \\* const\\)\\} $hex <S2<int>::inline_method\\(\\)>}
+ {[cannot_resolve "S2<int>::inline_method"]}}
+
+ {"S2<int>::static_inline_method()" "S2_SIM" {= \\{void \\(void\\)\\} $hex <S2<int>::static_inline_method\\(\\)>}
+ "void"}
+
+ {"free_func" "FF" {= \\{void \\(void\\)\\} $hex <free_func\\(\\)>}}
+
+ {"free_func()" "FF" {= \\{void \\(void\\)\\} $hex <free_func\\(\\)>}
+ "void"}
+
+ {"free_func(void)" "FF" {= \\{void \\(void\\)\\} $hex <free_func\\(\\)>}}
+
+ {"free_inline_func()" "FIF" {= \\{void \\(void\\)\\} $hex <free_inline_func\\(\\)>}
+ "void"}
+
+ {"free_inline_func(void)" "FIF" {= \\{void \\(void\\)\\} $hex <free_inline_func\\(\\)>}}
}
set c_scopes_list {
- {"free_func" "FF"}
- {"free_inline_func" "FIF"}
+ {"free_func" "FF" {= \\{void \\(void\\)\\} $hex <free_func>}}
+ {"free_inline_func" "FIF" {= \\{void \\(void\\)\\} $hex <free_inline_func>}}
}
# A list of all the static varibles defined in each scope. The first
@@ -91,6 +161,29 @@ proc do_test {lang} {
set scopes_list $cxx_scopes_list
}
+ # Print each scope/function using these syntaxes:
+ #
+ # "(gdb) p 'S::method() const'" # quoted
+ # "(gdb) p S::method() const" # unquoted
+ #
+ foreach scope_line $scopes_list {
+ set scope [lindex $scope_line 0]
+
+ set print_quoted_re [lindex $scope_line 2]
+ set print_quoted_re [uplevel 1 "subst -nobackslashes -nocommands \"$print_quoted_re\""]
+
+ set print_unquoted_re [lindex $scope_line 3]
+ set print_unquoted_re [uplevel 1 "subst -nobackslashes -nocommands \"$print_unquoted_re\""]
+
+ gdb_test "print '${scope}'" $print_quoted_re
+
+ if {$print_unquoted_re != ""} {
+ gdb_test "print ${scope}" $print_unquoted_re
+ } else {
+ gdb_test "print ${scope}" $print_quoted_re
+ }
+ }
+
# Print each variable using these syntaxes:
#
# 'func()'::var