diff options
author | Tom Tromey <tom@tromey.com> | 2016-07-11 15:02:10 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2016-07-21 15:16:04 -0600 |
commit | 12df5c002dcbfc5ac54983e1e7040a182f71a753 (patch) | |
tree | 6008ef91eacbb303c3b821642fa012b3cd3b1dd1 /gdb/rust-exp.y | |
parent | 305450edd3f96bfeebff78300e1e93487563d90a (diff) | |
download | gdb-12df5c002dcbfc5ac54983e1e7040a182f71a753.zip gdb-12df5c002dcbfc5ac54983e1e7040a182f71a753.tar.gz gdb-12df5c002dcbfc5ac54983e1e7040a182f71a753.tar.bz2 |
Allow empty struct expressions in Rust
I learned recently that empty struct expressions, like "X{}", have been
promoted from experimental to stable in Rust. This patch changes the
Rust expression parser to allow this case.
New test case included.
Built and regtested on x86-64 Fedora 23, using Rust 1.11 beta.
2016-07-21 Tom Tromey <tom@tromey.com>
* rust-lang.c (rust_tuple_struct_type_p): Return false for empty
structs.
* rust-exp.y (struct_expr_list): Allow empty elements.
2016-07-21 Tom Tromey <tom@tromey.com>
* gdb.rust/simple.rs (main): Use empty struct expression.
* gdb.rust/simple.exp: Add tests for empty struct expression.
Diffstat (limited to 'gdb/rust-exp.y')
-rw-r--r-- | gdb/rust-exp.y | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y index 456ffe5..6dc4704 100644 --- a/gdb/rust-exp.y +++ b/gdb/rust-exp.y @@ -428,10 +428,14 @@ struct_expr_tail: } ; -/* S{} is documented as valid but seems to be an unstable feature, so - it is left out here. */ struct_expr_list: - struct_expr_tail + /* %empty */ + { + VEC (set_field) **result + = OBSTACK_ZALLOC (&work_obstack, VEC (set_field) *); + $$ = result; + } +| struct_expr_tail { VEC (set_field) **result = OBSTACK_ZALLOC (&work_obstack, VEC (set_field) *); |