From patchwork Mon Mar 21 20:59:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artemiy Volkov X-Patchwork-Id: 11462 Received: (qmail 77065 invoked by alias); 21 Mar 2016 21:02:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 77003 invoked by uid 89); 21 Mar 2016 21:02:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=1276 X-HELO: mail-lb0-f196.google.com Received: from mail-lb0-f196.google.com (HELO mail-lb0-f196.google.com) (209.85.217.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 21 Mar 2016 21:02:18 +0000 Received: by mail-lb0-f196.google.com with SMTP id bc4so12053033lbc.0 for ; Mon, 21 Mar 2016 14:02:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=llOBlD59ipfDjqlUWI+ID4XGlOB1tP5VS2TJmBR2hoY=; b=hvvNVrJ3ZGPOAmGmF1gAKmJUOI3L0mzeU18S0EClE+T+B0/9/rl8clEJalkPC8Y3U2 F6NaKRk1XgYQACRAtuUscU9DhshANEALagoBixAtL3bRp41EuR1o4IlAzPUKnYMg64Mv fFxo3cATs0mgS7Sx3QqegEILpvNr+m7lQ4wCVmSn0abRJ68wIsPmHb8FAnkOwVCcnLRT CsGTy2CukB8BqiaW934OgOjnMNc0qfd0LOV7Pe+vCAi1ViwSq/5I1UJqBTNMpfbBtlqp IJJfTPQC+yfxKsGkQYIoVOYzSi4xNCWmkLb78HvjLjAPCev1eYnyvoFqOKqZ5RidEbSV YlMw== X-Gm-Message-State: AD7BkJL4ObkRO77yGn3VjS5jS2GtfPVtwjud3TjB8Zf61MF4za965pO1ItrVvPpfPRBfrQ== X-Received: by 10.112.72.135 with SMTP id d7mr12257672lbv.126.1458594135388; Mon, 21 Mar 2016 14:02:15 -0700 (PDT) Received: from arch.smware.local (broadband-90-154-70-182.nationalcablenetworks.ru. [90.154.70.182]) by smtp.gmail.com with ESMTPSA id 40sm4730939lfp.41.2016.03.21.14.02.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Mar 2016 14:02:14 -0700 (PDT) From: Artemiy Volkov To: gdb-patches@sourceware.org Cc: keiths@redhat.com, palves@redhat.com, Artemiy Volkov Subject: [PATCH v4 04/11] [PR gdb/14441] gdb: parse: support rvalue reference type Date: Mon, 21 Mar 2016 13:59:11 -0700 Message-Id: <1458593958-25656-5-git-send-email-artemiyv@acm.org> In-Reply-To: <1458593958-25656-1-git-send-email-artemiyv@acm.org> References: <1457147955-21871-1-git-send-email-artemiyv@acm.org> <1458593958-25656-1-git-send-email-artemiyv@acm.org> X-IsSubscribed: yes This patch implements correct parsing of C++0x 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: 2016-03-21 Artemiy Volkov * 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) : New constant. --- gdb/c-exp.y | 6 +++++- gdb/parse.c | 39 ++++++++++++++++++++++----------------- gdb/parser-defs.h | 1 + 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 9f2a229..f83047b 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -799,7 +799,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)); @@ -1140,6 +1140,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 06f7bcd..eb8e475 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -1470,10 +1470,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) @@ -1482,7 +1482,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 @@ -1695,18 +1696,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 1b1d3c3..c474150 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,