Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C - Fix padding numbering when structs are omitted #56

Merged

Conversation

stefanlippuner
Copy link
Contributor

@stefanlippuner stefanlippuner commented Aug 14, 2024

With the change from #55, I've introduced/triggered a new issue :| If padding is inserted at the top-level and within a block omitted prefix, the same name is given to the padding variable resulting in compilation errors, e.g.

#ifndef __ASSEMBLER__
struct blkprefix3 {
  /* [0x0]: BLOCK (comment missing) */
  /* [0x0]: REG (rw) (comment missing) */
  uint32_t r1;

  /* padding to: 8 Bytes */
  uint32_t __padding_0[1];

  /* [0x8]: REG (rw) (comment missing) */
  uint64_t r2;

  /* [0x10]: BLOCK (comment missing) */
  /* [0x0]: REG (rw) (comment missing) */
  uint32_t r3;

  /* padding to: 8 Bytes */
  uint32_t __padding_0[1];

  /* [0x8]: REG (rw) (comment missing) */
  uint64_t r4;

  /* [0x20]: BLOCK (comment missing) */
  struct b2 {
    /* [0x0]: REG (rw) (comment missing) */
    uint32_t r1;

    /* padding to: 8 Bytes */
    uint32_t __padding_0[1];

    /* [0x8]: REG (rw) (comment missing) */
    uint64_t r2;
  } b2;
};
#endif /* !__ASSEMBLER__*/

Note the duplicate __padding_0

This MR fixes the issue by tracking the padding numbering using a stack within CPrinter. The numbering is still reset when a new struct (without omitted prefix) starts.

@stefanlippuner stefanlippuner marked this pull request as ready for review August 14, 2024 15:43
@tgingold-cern tgingold-cern merged commit d4766b0 into tgingold-cern:master Oct 1, 2024
2 checks passed
@tgingold-cern
Copy link
Owner

Thanks!

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