summaryrefslogtreecommitdiff
path: root/gdb/parse.c
diff options
context:
space:
mode:
authorArtemiy Volkov <artemiyv@acm.org>2017-03-20 13:47:43 -0700
committerKeith Seitz <keiths@redhat.com>2017-03-20 13:47:43 -0700
commit53cc15f5fe1f5e2358994d4f60f1c2aa9115004d (patch)
tree311f5e38f845699047db919a1addd12411f4b014 /gdb/parse.c
parenta65cfae5f8b268158c23a862e7a996d15bbcef0e (diff)
downloadbinutils-gdb-53cc15f5fe1f5e2358994d4f60f1c2aa9115004d.tar.gz
Support rvalue reference type in parser
This patch implements correct parsing of C++11 rvalue reference typenames. This is done in full similarity to the handling of regular references by adding a '&&' token handling in c-exp.y, defining an rvalue reference type piece, and implementing a follow type derivation in follow_types(). gdb/ChangeLog PR gdb/14441 * c-exp.y (ptr_operator): Handle the '&&' token in the typename. * parse.c (insert_type): Change assert statement. (follow_types): Handle rvalue reference types. * parser-defs.h (enum type_pieces) <tp_rvalue_reference>: New constant.
Diffstat (limited to 'gdb/parse.c')
-rw-r--r--gdb/parse.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/gdb/parse.c b/gdb/parse.c
index 23c636f6c7e..3dd7075e553 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -1461,10 +1461,10 @@ insert_into_type_stack (int slot, union type_stack_elt element)
}
/* Insert a new type, TP, at the bottom of the type stack. If TP is
- tp_pointer or tp_reference, it is inserted at the bottom. If TP is
- a qualifier, it is inserted at slot 1 (just above a previous
- tp_pointer) if there is anything on the stack, or simply pushed if
- the stack is empty. Other values for TP are invalid. */
+ tp_pointer, tp_reference or tp_rvalue_reference, it is inserted at the
+ bottom. If TP is a qualifier, it is inserted at slot 1 (just above a
+ previous tp_pointer) if there is anything on the stack, or simply pushed
+ if the stack is empty. Other values for TP are invalid. */
void
insert_type (enum type_pieces tp)
@@ -1473,7 +1473,8 @@ insert_type (enum type_pieces tp)
int slot;
gdb_assert (tp == tp_pointer || tp == tp_reference
- || tp == tp_const || tp == tp_volatile);
+ || tp == tp_rvalue_reference || tp == tp_const
+ || tp == tp_volatile);
/* If there is anything on the stack (we know it will be a
tp_pointer), insert the qualifier above it. Otherwise, simply
@@ -1686,18 +1687,22 @@ follow_types (struct type *follow_type)
make_addr_space = 0;
break;
case tp_reference:
- follow_type = lookup_lvalue_reference_type (follow_type);
- if (make_const)
- follow_type = make_cv_type (make_const,
- TYPE_VOLATILE (follow_type),
- follow_type, 0);
- if (make_volatile)
- follow_type = make_cv_type (TYPE_CONST (follow_type),
- make_volatile,
- follow_type, 0);
- if (make_addr_space)
- follow_type = make_type_with_address_space (follow_type,
- make_addr_space);
+ follow_type = lookup_lvalue_reference_type (follow_type);
+ goto process_reference;
+ case tp_rvalue_reference:
+ follow_type = lookup_rvalue_reference_type (follow_type);
+ process_reference:
+ if (make_const)
+ follow_type = make_cv_type (make_const,
+ TYPE_VOLATILE (follow_type),
+ follow_type, 0);
+ if (make_volatile)
+ follow_type = make_cv_type (TYPE_CONST (follow_type),
+ make_volatile,
+ follow_type, 0);
+ if (make_addr_space)
+ follow_type = make_type_with_address_space (follow_type,
+ make_addr_space);
make_const = make_volatile = 0;
make_addr_space = 0;
break;