Bug 22703 – importC: C++11 unscoped enums with underlying type rejects some C types.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-01-25T06:59:02Z
Last change time
2022-01-29T09:26:45Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
dave287091

Comments

Comment #0 by dave287091 — 2022-01-25T06:59:02Z
As a followup to #22631, the following enums are rejected: // test.c enum L: long long { // L_A = 1, }; enum U: unsigned long long { // U_A = 1, }; enum U2: unsigned { // U2_A = 1, }; enum U3: unsigned long { // U2_A = 1, }; Enums deriving from unsigned long are needed for at least the CoreFoundation framework on macOS. I believe this line https://github.com/dlang/dmd/blob/153f706dc1ca871ad68839745b42db5dfcfaf4f2/src/dmd/cparse.d#L3109 should be cparseTypeName(), not parseType().
Comment #1 by dave287091 — 2022-01-25T07:18:37Z
On macOs, CoreFoundation imports <dispatch/dispatch.h>, which has an enum defined: typedef enum : unsigned long { DISPATCH_AUTORELEASE_FREQUENCY_INHERIT __attribute__((availability(macos,introduced=10.12))) __attribute__((availability(ios,introduced=10.0))) __attribute__((availability(tvos,introduced=10.0))) __attribute__((availability(watchos,introduced=3.0))) = 0, DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM __attribute__((availability(macos,introduced=10.12))) __attribute__((availability(ios,introduced=10.0))) __attribute__((availability(tvos,introduced=10.0))) __attribute__((availability(watchos,introduced=3.0))) = 1, DISPATCH_AUTORELEASE_FREQUENCY_NEVER __attribute__((availability(macos,introduced=10.12))) __attribute__((availability(ios,introduced=10.0))) __attribute__((availability(tvos,introduced=10.0))) __attribute__((availability(watchos,introduced=3.0))) = 2, } __attribute__((__enum_extensibility__(open))) dispatch_autorelease_frequency_t; Removing all those attributes, gives: typedef enum : unsigned long { DISPATCH_AUTORELEASE_FREQUENCY_INHERIT = 0, DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM= 1, DISPATCH_AUTORELEASE_FREQUENCY_NEVER = 2, } dispatch_autorelease_frequency_t;
Comment #2 by dlang-bot — 2022-01-29T06:49:33Z
@WalterBright created dlang/dmd pull request #13579 "fix Issue 22703 - importC: C++11 unscoped enums with underlying type …" fixing this issue: - fix Issue 22703 - importC: C++11 unscoped enums with underlying type rejects some C types https://github.com/dlang/dmd/pull/13579
Comment #3 by dlang-bot — 2022-01-29T09:26:45Z
dlang/dmd pull request #13579 "fix Issue 22703 - importC: C++11 unscoped enums with underlying type …" was merged into master: - 7794a0916736f93b1e6732b96230947a4d8fae92 by Walter Bright: fix Issue 22703 - importC: C++11 unscoped enums with underlying type rejects some C types https://github.com/dlang/dmd/pull/13579