Skip to content

fix: preserve GCC __attribute__ between enum keyword and name in AST#5

Closed
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-attribute-dropped-in-ast
Closed

fix: preserve GCC __attribute__ between enum keyword and name in AST#5
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-attribute-dropped-in-ast

Conversation

Copy link
Copy Markdown

Copilot AI commented May 8, 2026

__attribute__ placed between enum and the tag name (e.g. enum __attribute__((packed)) color { ... }) was silently dropped from the AST. The parser consumed the tokens correctly but discarded the returned attribute list instead of attaching it to the IASTEnumerationSpecifier.

Changes

  • AbstractGNUSourceCodeParser.enumSpecifier() — capture the return value of __attribute_decl_seq() and call addAttributeSpecifiers(attributes, result) on the resulting enum specifier node, matching the pattern already used in classSpecifier() for struct/class/union
  • AST2Tests.testEnumAttribute() — regression test verifying that enum __attribute__((packed)) color { ... } produces exactly one attribute specifier on the enum's decl specifier in the AST
// Previously: attribute was consumed but not added to the AST node
enum __attribute__ ((packed)) color {
    RED = 1,
    GREEN = 2
};

Checklist:

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Test Results

4 719 tests  +1   4 710 ✅ +1   2m 30s ⏱️ -2s
  182 suites ±0       9 💤 ±0 
  182 files   ±0       0 ❌ ±0 

Results for commit 3869cdc. ± Comparison against base commit acd4556.

♻️ This comment has been updated with latest results.

@strimo378 strimo378 closed this May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants