From patchwork Mon Sep 14 13:38:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 8673 Received: (qmail 33986 invoked by alias); 14 Sep 2015 13:38:33 -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 33974 invoked by uid 89); 14 Sep 2015 13:38:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_40, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f173.google.com Received: from mail-wi0-f173.google.com (HELO mail-wi0-f173.google.com) (209.85.212.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 14 Sep 2015 13:38:32 +0000 Received: by wicge5 with SMTP id ge5so143284373wic.0 for ; Mon, 14 Sep 2015 06:38:29 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.194.81.137 with SMTP id a9mr30123182wjy.155.1442237908706; Mon, 14 Sep 2015 06:38:28 -0700 (PDT) Received: by 10.27.83.201 with HTTP; Mon, 14 Sep 2015 06:38:28 -0700 (PDT) Date: Mon, 14 Sep 2015 15:38:28 +0200 Message-ID: Subject: [PATCH] [D] Add grammar support for sizeof and typeof From: Iain Buclaw To: GDB Patches X-IsSubscribed: yes Hi, This adds support for D-style (T).sizeof, (E).sizeof, and typeof(E) syntax to the gdb grammar for the D language. All of which are trivial additions that need no special support. Regards Iain. gdb/ChangeLog: * d-exp.y: (UnaryExpression): Add grammar support for 'type.sizeof'. (PostfixExpression): Add grammar support for 'expr.sizeof'. (PrimaryExpression): Add grammar support for 'typeof(expr)'. --- diff --git a/gdb/d-exp.y b/gdb/d-exp.y index e9d21ac..1378e82 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -366,6 +366,8 @@ UnaryExpression: { write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); } | '~' UnaryExpression { write_exp_elt_opcode (pstate, UNOP_COMPLEMENT); } +| TypeExp '.' SIZEOF_KEYWORD + { write_exp_elt_opcode (pstate, UNOP_SIZEOF); } | CastExpression | PowExpression ; @@ -408,6 +410,8 @@ PostfixExpression: write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); write_exp_string (pstate, $3); write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); } +| PostfixExpression '.' SIZEOF_KEYWORD + { write_exp_elt_opcode (pstate, UNOP_SIZEOF); } | PostfixExpression INCREMENT { write_exp_elt_opcode (pstate, UNOP_POSTINCREMENT); } | PostfixExpression DECREMENT @@ -616,6 +620,8 @@ PrimaryExpression: write_exp_elt_longcst (pstate, (LONGEST) 0); write_exp_elt_longcst (pstate, (LONGEST) $1 - 1); write_exp_elt_opcode (pstate, OP_ARRAY); } +| TYPEOF_KEYWORD '(' Expression ')' + { write_exp_elt_opcode (pstate, OP_TYPEOF); } ; ArrayLiteral: