diff options
author | Tom Tromey <tromey@redhat.com> | 2014-03-27 12:24:27 -0600 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2014-04-14 11:42:18 -0600 |
commit | 3d567982aca11c85a7fa31f13046de3271d3afc8 (patch) | |
tree | 2531411a9a2aed81fb3a31d7be8960c34c9759e8 /gdb/testsuite/gdb.dwarf2 | |
parent | c848d64244912f9f411bec7b1c045bf14c72b61b (diff) | |
download | gdb-3d567982aca11c85a7fa31f13046de3271d3afc8.zip gdb-3d567982aca11c85a7fa31f13046de3271d3afc8.tar.gz gdb-3d567982aca11c85a7fa31f13046de3271d3afc8.tar.bz2 |
implement support for "enum class"
This adds support for the C++11 "enum class" feature. This is
PR c++/15246.
I chose to use the existing TYPE_DECLARED_CLASS rather than introduce
a new type code. This seemed both simple and clear to me.
I made overloading support for the new enum types strict. This is how
it works in C++; and it didn't seem like an undue burden to keep this,
particularly because enum constants are printed symbolically by gdb.
Built and regtested on x86-64 Fedora 20.
2014-04-14 Tom Tromey <tromey@redhat.com>
PR c++/15246:
* c-exp.y (type_aggregate_p): New function.
(qualified_name, classify_inner_name): Use it.
* c-typeprint.c (c_type_print_base): Handle TYPE_DECLARED_CLASS
and TYPE_TARGET_TYPE of an enum type.
* dwarf2read.c (read_enumeration_type): Set TYPE_DECLARED_CLASS on
an enum type.
(determine_prefix) <case DW_TAG_enumeration_type>: New case;
handle TYPE_DECLARED_CLASS.
* gdbtypes.c (rank_one_type): Handle TYPE_DECLARED_CLASS on enum
types.
* gdbtypes.h (TYPE_DECLARED_CLASS): Update comment.
* valops.c (enum_constant_from_type): New function.
(value_aggregate_elt): Use it.
* cp-namespace.c (cp_lookup_nested_symbol): Handle
TYPE_CODE_ENUM.
2014-04-14 Tom Tromey <tromey@redhat.com>
* gdb.cp/classes.exp (test_enums): Handle underlying type.
* gdb.dwarf2/enum-type.exp: Add test for enum with underlying
type.
* gdb.cp/enum-class.exp: New file.
* gdb.cp/enum-class.cc: New file.
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2')
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/enum-type.exp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/enum-type.exp b/gdb/testsuite/gdb.dwarf2/enum-type.exp index 60457a6..a4825ec 100644 --- a/gdb/testsuite/gdb.dwarf2/enum-type.exp +++ b/gdb/testsuite/gdb.dwarf2/enum-type.exp @@ -30,8 +30,7 @@ Dwarf::assemble $asm_file { {DW_AT_name enum-type-dw.c} {DW_AT_comp_dir /tmp} } { - declare_labels integer_label array_elt_label array_label \ - big_array_label + declare_labels integer_label uinteger_label integer_label: DW_TAG_base_type { {DW_AT_byte_size 4 DW_FORM_sdata} @@ -39,6 +38,12 @@ Dwarf::assemble $asm_file { {DW_AT_name integer} } + uinteger_label: DW_TAG_base_type { + {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_unsigned} + {DW_AT_name {unsigned integer}} + } + DW_TAG_enumeration_type { {DW_AT_name E} {DW_AT_type :$integer_label} @@ -48,6 +53,16 @@ Dwarf::assemble $asm_file { {DW_AT_const_value 1} } } + + DW_TAG_enumeration_type { + {DW_AT_name EU} + {DW_AT_type :$uinteger_label} + } { + DW_TAG_enumerator { + {DW_AT_name TWO} + {DW_AT_const_value 2 DW_FORM_sdata} + } + } } } } @@ -58,3 +73,9 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} \ } gdb_test "print sizeof(enum E)" " = 4" + +gdb_test "ptype enum EU" "type = enum EU {TWO = 2}" \ + "ptype EU in enum C" +gdb_test_no_output "set lang c++" +gdb_test "ptype enum EU" "type = enum EU : unsigned integer {TWO = 2}" \ + "ptype EU in C++" |