Bug 23662 – ImportC bad handling of enum arguments for a function

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-01-30T23:10:32Z
Last change time
2023-06-28T14:09:24Z
Keywords
ImportC
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=23415, https://issues.dlang.org/show_bug.cgi?id=24022

Comments

Comment #0 by bugzilla — 2023-01-30T23:10:32Z
From Dmytro Katyukha <[email protected]>: It seems that ImportC does not allow to pass enums declared with typedef but without tag to function that receives enum as one of argument ## The code snippets: ```c // testlib.c typedef enum /*enum_test_1_t*/ { E_TEST_1_ITEM_1 = 1, E_TEST_1_ITEM_2, } enum_test_1_t; int some_func(enum_test_1_t val) { return val; } ``` ```d //test.d import testlib; void main(string[] args) { enum_test_1_t val1 = E_TEST_1_ITEM_1; some_func(E_TEST_1_ITEM_1); } ``` ## Attempt to compile produce following output ``` dmd test.d testlib.c test.d(6): Error: function `testlib.some_func(__tag2 val)` is not callable using argument types `(__anonymous)` test.d(6): cannot pass argument `E_TEST_1_ITEM_1` of type `__anonymous` to parameter `__tag2 val` ```
Comment #1 by dlang-bot — 2023-02-02T21:21:48Z
@katyukha created dlang/dmd pull request #14859 "Fix Issue 23662: ImportC bad handling of enum arguments for a function" mentioning this issue: - Added testcase for Issue 23662 See: https://issues.dlang.org/show_bug.cgi?id=23662 - [FIX] Issue 23662 https://github.com/dlang/dmd/pull/14859
Comment #2 by dlang-bot — 2023-02-09T10:50:23Z
dlang/dmd pull request #14859 "Fix Issue 23662: ImportC bad handling of enum arguments for a function" was merged into stable: - 26358e7106349f319f94f28bd152ee4b9614e63f by Dmytro Katyukha: Added testcase for Issue 23662 See: https://issues.dlang.org/show_bug.cgi?id=23662 - 5e72b01d56594288a6c43683a06eccb61d74df7b by Dmytro Katyukha: Fix Issue 23662 https://github.com/dlang/dmd/pull/14859
Comment #3 by dlang-bot — 2023-02-13T03:29:12Z
dlang/dmd pull request #14875 "merge stable" was merged into master: - 582dd6c1a1c8f2fc07498c3787dd5b878dac79b3 by Dmytro Katyukha: Fix Issue 23662: ImportC bad handling of enum arguments for a function (#14859) * Added testcase for Issue 23662 See: https://issues.dlang.org/show_bug.cgi?id=23662 * Fix Issue 23662 https://github.com/dlang/dmd/pull/14875