summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-07-19 15:38:15 +0000
committerTom Tromey <tromey@redhat.com>2012-07-19 15:38:15 +0000
commita23fa27d5a315b7801bb925a2a99e871f8832bb3 (patch)
treec7e50145a6ae85d0550495f5395ef2bf6d6ae72c /gdb/testsuite/gdb.cp
parent2295b9bae645c263f07ad38ac327b515b24678ff (diff)
downloadgdb-a23fa27d5a315b7801bb925a2a99e871f8832bb3.tar.gz
PR exp/13206:
* ax-gdb.c (gen_expr) <OP_TYPEOF, OP_DECLTYPE>: New cases. * breakpoint.c (watchpoint_exp_is_const) <OP_TYPEOF, OP_DECLTYPE>: New cases. * c-exp.y (TYPEOF, DECLTYPE): New tokens. (type_exp): Add new productions. (ident_tokens): Add __typeof__, typeof, __typeof, __decltype, and decltype. * eval.c (evaluate_subexp_standard) <OP_TYPEOF, OP_DECLTYPE>: New case. * expprint.c (dump_subexp_body_standard) <OP_TYPEOF, OP_DECLTYPE>: New case. * parse.c (operator_length_standard) <OP_TYPEOF, OP_DECLTYPE>: New case. * std-operator.def (OP_TYPEOF, OP_DECLTYPE): New constants. * varobj.c (varobj_create): Handle OP_TYPEOF, OP_DECLTYPE. gdb/testsuite * gdb.cp/casts.exp: Add tests for typeof and decltype. * gdb.cp/casts.cc (decltype): New function. (main): Use it.
Diffstat (limited to 'gdb/testsuite/gdb.cp')
-rw-r--r--gdb/testsuite/gdb.cp/casts.cc10
-rw-r--r--gdb/testsuite/gdb.cp/casts.exp19
2 files changed, 29 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/casts.cc b/gdb/testsuite/gdb.cp/casts.cc
index 543db896d3d..43f112f32f1 100644
--- a/gdb/testsuite/gdb.cp/casts.cc
+++ b/gdb/testsuite/gdb.cp/casts.cc
@@ -34,6 +34,14 @@ struct DoublyDerived : public VirtuallyDerived,
{
};
+// Confuse a simpler approach.
+
+double
+decltype(int x)
+{
+ return x + 2.0;
+}
+
int
main (int argc, char **argv)
{
@@ -48,5 +56,7 @@ main (int argc, char **argv)
Alpha *ad = &derived;
Alpha *add = &doublyderived;
+ double y = decltype(2);
+
return 0; /* breakpoint spot: casts.exp: 1 */
}
diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp
index 2013ab841be..a3fe7435933 100644
--- a/gdb/testsuite/gdb.cp/casts.exp
+++ b/gdb/testsuite/gdb.cp/casts.exp
@@ -107,6 +107,25 @@ gdb_test "print reinterpret_cast<void> (b)" "Invalid reinterpret_cast" \
gdb_test "print reinterpret_cast<A &> (*b)" " = \\(A \\&\\) @$hex: {a = 42}" \
"reinterpret_cast to reference type"
+# Test that keyword shadowing works.
+
+gdb_test "whatis decltype(5)" " = double"
+
+# Basic tests using typeof.
+
+foreach opname {__typeof__ __typeof __decltype} {
+ gdb_test "print (${opname}(a)) (b)" " = \\(A \\*\\) $hex" \
+ "old-style cast using $opname"
+
+ gdb_test "print static_cast<${opname}(a)> (b)" " = \\(A \\*\\) $hex" \
+ "static_cast using $opname"
+
+ gdb_test "print reinterpret_cast<${opname}(a)> (b)" " = \\(A \\*\\) $hex" \
+ "reinterpret_cast using $opname"
+}
+
+gdb_test "whatis __decltype(*a)" "type = A \\&"
+
# Tests of dynamic_cast.
set nonzero_hex "0x\[0-9A-Fa-f\]\[0-9A-Fa-f\]+"