Bug 21932 – importC: enum 'ENUM' conflicts with enum 'ENUM'
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-05-19T17:59:55Z
Last change time
2021-07-15T15:16:08Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
Iain Buclaw
Comments
Comment #0 by ibuclaw — 2021-05-19T17:59:55Z
The parser allows implicit typedefs, which is not valid C.
---
struct STRUCT { void *opaque; };
STRUCT mystruct; // Should error.
---
Instead, it errors on the correct way to declare variables of type 'struct'.
---
struct STRUCT { void *opaque; };
struct STRUCT mystruct; // Error
---
Same goes for enums
---
enum ENUM { ENUM_a };
enum ENUM myenum; // Error
---
Comment #1 by ibuclaw — 2021-05-19T18:02:29Z
(In reply to Iain Buclaw from comment #0)
> The parser allows implicit typedefs, which is not valid C.
> ---
> struct STRUCT { void *opaque; };
> STRUCT mystruct; // Should error.
> ---
This is probably not so easily solvable though, as the error should happen in the semantic (but the semantic follows D rules!)
The immediate issue should focus on getting `struct S s;` working.
Comment #2 by bugzilla — 2021-05-27T08:17:20Z
This is actually how C++ works, and it compiles C fine.
It is not rigorous C, to be sure, but I think we're all right with it.
Comment #3 by ibuclaw — 2021-05-27T08:40:54Z
(In reply to Walter Bright from comment #2)
> This is actually how C++ works, and it compiles C fine.
>
> It is not rigorous C, to be sure, but I think we're all right with it.
Yeah, I'll removed the accepts-invalid tag. In principle there's nothing wrong will accepting more than what a typical C compiler would so long as it can be justified.
Comment #4 by ibuclaw — 2021-06-21T16:21:58Z
The struct test case has been fixed with the introduction of TypeTag.
The enum test case still fails, however.
---
enum ENUM { ENUM_a };
enum ENUM myenum; // Error
Comment #5 by dlang-bot — 2021-06-21T17:30:55Z
@ibuclaw created dlang/dmd pull request #12723 "fix Issue 21932, 22060 - importC: Multiple forward declarations result in error struct conflicts with struct" fixing this issue:
- fix Issue 21932 - importC: enum 'ENUM' conflicts with enum 'ENUM'
https://github.com/dlang/dmd/pull/12723
Comment #6 by dlang-bot — 2021-06-30T09:40:31Z
@WalterBright created dlang/dmd pull request #12787 "fix Issue 21932 ImportC: enum ENUM conflicst with enum ENUM" fixing this issue:
- fix Issue 21932 ImportC: enum ENUM conflicst with enum ENUM
https://github.com/dlang/dmd/pull/12787
Comment #7 by ibuclaw — 2021-07-15T15:16:08Z
Fix was committed but issue did not get auto-closed.