RFR: 7903777: jextract layout for enum with big constant values is wrong

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Jul 16 13:54:29 UTC 2024


This PR fixes the code that generates enum layouts. Currently, the layout of an enum type is determined by looking at the type of the first enum constant.
In some platforms, this strategy does not work, as an enum can have constants of **different** types.

The solution is to ask clang what the integral type of the enum declaration is, and store that as an attribute in the enum declaration. Then, we should simply retrieve that type when generating layouts that depend on the enum.

I've added a platform-dependent test, since this functionality is only really available on Linux/gcc (on Windows, enum constants are all truncated to 32 bits, it seems).

-------------

Commit messages:
 - Remove tabs
 - Add test
 - Initial push

Changes: https://git.openjdk.org/jextract/pull/252/files
  Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=252&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903777
  Stats: 94 lines in 6 files changed: 81 ins; 6 del; 7 mod
  Patch: https://git.openjdk.org/jextract/pull/252.diff
  Fetch: git fetch https://git.openjdk.org/jextract.git pull/252/head:pull/252

PR: https://git.openjdk.org/jextract/pull/252


More information about the jextract-dev mailing list