Skip to content

Commit c9f8dde

Browse files
cmaloneyclaude
andcommitted
gh-162182: Fix c-analyzer on static_assert containing a comma
With -std=c99, glibc expands `static_assert(cond, msg)` to a declaration that has cond in a struct bitfield size. For example static_assert(offsetof(T, m) >= 1, "msg"); is preprocessed to extern int (*__Static_assert_function (void)) [!!sizeof (struct { int __error_if_negative: (__builtin_offsetof (T, m) >= 1) ? 2 : -1; })]; The parser ended the size at the first comma, the one in "(T, m)", which left it out of sync and `make check-c-globals` failed with "too many lines". Let a bitfield size containing parentheses run to the ";". Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent 715d34f commit c9f8dde

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎Tools/c-analyzer/c_parser/parser/_regexes.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ def _ind(text, level=1, edges='both'):
340340
# This is actually a "constant expression".
341341
\d+
342342
|
343-
[^'",}}]+
343+
[^'",(}}]+
344+
|
345+
# Parens may hold commas (e.g. from offsetof()).
346+
[^'";}}]+ (?= ; )
344347
)
345348
)?
346349
\s*

0 commit comments

Comments
 (0)