From: Keith Seitz <keiths@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v6 04/11] Support rvalue reference type in parser
Date: Fri, 10 Mar 2017 20:10:00 -0000 [thread overview]
Message-ID: <1489176286-27973-5-git-send-email-keiths@redhat.com> (raw)
In-Reply-To: <1489176286-27973-1-git-send-email-keiths@redhat.com>
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().
There are no changes to this patch from v5.
gdb/ChangeLog
PR gdb/14441
From Artemiy Volkov <artemiyv@acm.org>
* 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.
---
gdb/ChangeLog | 10 ++++++++++
gdb/c-exp.y | 6 +++++-
gdb/parse.c | 39 ++++++++++++++++++++++-----------------
gdb/parser-defs.h | 1 +
4 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4768848..f7685ad 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -2,6 +2,16 @@
PR gdb/14441
From Artemiy Volkov <artemiyv@acm.org>
+ * 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.
+
+2017-MM-DD Keith Seitz <keiths@redhat.com>
+
+ PR gdb/14441
+ From Artemiy Volkov <artemiyv@acm.org>
* ada-lang.c (ada_evaluate_subexp): Adhere to the new
value_ref() interface.
* c-valprint.c (c_value_print): Likewise.
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 2753c6e..7c25641 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -744,7 +744,7 @@ exp : SIZEOF '(' type ')' %prec UNARY
says of sizeof: "When applied to a reference
or a reference type, the result is the size of
the referenced type." */
- if (TYPE_CODE (type) == TYPE_CODE_REF)
+ if (TYPE_IS_REFERENCE (type))
type = check_typedef (TYPE_TARGET_TYPE (type));
write_exp_elt_longcst (pstate,
(LONGEST) TYPE_LENGTH (type));
@@ -1085,6 +1085,10 @@ ptr_operator:
{ insert_type (tp_reference); }
| '&' ptr_operator
{ insert_type (tp_reference); }
+ | ANDAND
+ { insert_type (tp_rvalue_reference); }
+ | ANDAND ptr_operator
+ { insert_type (tp_rvalue_reference); }
;
ptr_operator_ts: ptr_operator
diff --git a/gdb/parse.c b/gdb/parse.c
index d864970..bf27598 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;
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 85da6a4..a291aed 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -127,6 +127,7 @@ enum type_pieces
tp_end = -1,
tp_pointer,
tp_reference,
+ tp_rvalue_reference,
tp_array,
tp_function,
tp_function_with_arguments,
--
2.1.0
next prev parent reply other threads:[~2017-03-10 20:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 20:04 [PATCH v6 00/11] c++/14441: Rvalue reference support Keith Seitz
2017-03-10 20:04 ` [PATCH v6 01/11] Add definitions for rvalue reference types Keith Seitz
2017-03-10 20:05 ` [PATCH v6 02/11] Change {lookup,make}_reference_type API Keith Seitz
2017-03-10 20:05 ` [PATCH v6 11/11] Add rvalue reference tests and NEWS entry Keith Seitz
2017-03-10 22:02 ` Eli Zaretskii
2017-03-14 18:14 ` Keith Seitz
2017-03-17 17:06 ` Keith Seitz
2017-03-17 18:51 ` Eli Zaretskii
2017-03-13 18:52 ` Pedro Alves
2017-03-14 18:15 ` Keith Seitz
2017-03-14 18:39 ` Pedro Alves
2017-04-04 11:10 ` Yao Qi
2017-03-10 20:05 ` [PATCH v6 03/11] Add ability to return rvalue reference values from value_ref Keith Seitz
2017-03-10 20:10 ` [PATCH v6 07/11] Support DW_TAG_rvalue_reference type Keith Seitz
2017-03-10 20:10 ` [PATCH v6 06/11] Implement printing of rvalue reference types and values Keith Seitz
2017-03-10 20:10 ` [PATCH v6 05/11] Implement demangling for rvalue reference type names Keith Seitz
2017-03-10 20:10 ` [PATCH v6 08/11] Support rvalue references in the gdb python module (includes doc/) Keith Seitz
2017-03-10 22:04 ` Eli Zaretskii
2017-03-14 18:14 ` Keith Seitz
2017-03-17 17:06 ` Keith Seitz
2017-03-17 18:51 ` Eli Zaretskii
2017-03-10 20:10 ` Keith Seitz [this message]
2017-03-10 20:12 ` [PATCH v6 09/11] Convert lvalue reference type check to general reference type check Keith Seitz
2017-03-10 20:14 ` [PATCH v6 10/11] Add rvalue references to overloading resolution Keith Seitz
2017-03-13 18:51 ` [PATCH v6 00/11] c++/14441: Rvalue reference support Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1489176286-27973-5-git-send-email-keiths@redhat.com \
--to=keiths@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox