From d60b593c8b1d19a4adfdadaeeaa93aa10b9dba53 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 24 Jan 2017 10:29:30 +0100 Subject: New version to support designators. The c standard allows member designators for offsetof. The current implementation works by recursively combining the offset of each of the member designators. For array access the size of the subtypes is multiplied by the index and for members the offset of the member is calculated. Bug 20765 --- cparser/Parser.vy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cparser/Parser.vy') diff --git a/cparser/Parser.vy b/cparser/Parser.vy index fb0b7444..f6bd6a7e 100644 --- a/cparser/Parser.vy +++ b/cparser/Parser.vy @@ -145,8 +145,8 @@ postfix_expression: { (CAST typ (COMPOUND_INIT (rev' init)), loc) } | loc = LPAREN typ = type_name RPAREN LBRACE init = initializer_list COMMA RBRACE { (CAST typ (COMPOUND_INIT (rev' init)), loc) } -| loc = BUILTIN_OFFSETOF LPAREN typ = type_name COMMA mem = OTHER_NAME RPAREN - { (BUILTIN_OFFSETOF typ (fst mem), loc) } +| loc = BUILTIN_OFFSETOF LPAREN typ = type_name COMMA mem = designator_list RPAREN + { (BUILTIN_OFFSETOF typ (rev mem), loc) } (* Semantic value is in reverse order. *) argument_expression_list: -- cgit