Skip to content

Commit ec9b169

Browse files
Copilotinducer
andcommitted
Fix coord issues in _parse_attributes_opt and _parse_designator
Agent-Logs-Url: https://github.com/inducer/pycparserext/sessions/d2fb57b1-f272-4ad0-9c3f-c81d8816e4a3 Co-authored-by: inducer <[email protected]>
1 parent b367304 commit ec9b169

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

pycparserext/ext_c_parser.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def _parse_attribute_decl(self):
349349

350350
def _parse_attributes_opt(self):
351351
tok = self._peek()
352-
coord = self._tok_coord(tok) if tok else self.clex.filename
352+
coord = self._tok_coord(tok) if tok else None
353353
result = c_ast.ExprList([], coord)
354354
while self._peek_type() in {"__ATTRIBUTE__", "__ATTRIBUTE"}:
355355
attr_list = self._parse_attribute_decl()
@@ -1085,12 +1085,13 @@ def _parse_labeled_statement(self):
10851085
return super()._parse_labeled_statement()
10861086

10871087
def _parse_designator(self):
1088-
if self._accept("LBRACKET"):
1088+
lbrack_tok = self._accept("LBRACKET")
1089+
if lbrack_tok is not None:
10891090
expr = self._parse_constant_expression()
10901091
if self._accept("ELLIPSIS"):
10911092
last = self._parse_constant_expression()
10921093
self._expect("RBRACKET")
1093-
return RangeExpression(expr, last)
1094+
return RangeExpression(expr, last, coord=self._tok_coord(lbrack_tok))
10941095
self._expect("RBRACKET")
10951096
return expr
10961097
if self._accept("PERIOD"):

0 commit comments

Comments
 (0)