diff mbox

[D] Add grammar support for sizeof and typeof

Message ID CABOHX+e_F3BdgWZ1a6DM+vobwZiJmCy9jPgOJTTuBJ2ap3USrQ@mail.gmail.com
State New
Headers show

Commit Message

Iain Buclaw Sept. 14, 2015, 1:38 p.m. UTC
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.
diff mbox

Patch

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: