Skip to content

ast-exporter: handle foreign/extern enums properly#1743

Merged
kkysen merged 1 commit into
immunant:masterfrom
Rua:foreign-enum
Apr 24, 2026
Merged

ast-exporter: handle foreign/extern enums properly#1743
kkysen merged 1 commit into
immunant:masterfrom
Rua:foreign-enum

Conversation

@Rua
Copy link
Copy Markdown
Contributor

@Rua Rua commented Apr 15, 2026

getDefinition returns NULL if there is no definition, only a forward declaration. That would then be exported as node number 0, which would not have any valid decl associated with it. This PR adds a check for the NULL case and uses the canonical decl instead.

@Rua Rua force-pushed the foreign-enum branch 2 times, most recently from b25c44b to 5b1dd70 Compare April 16, 2026 09:44
@Rua Rua marked this pull request as ready for review April 16, 2026 09:44
Comment thread c2rust-ast-exporter/src/AstExporter.cpp
Comment thread tests/unit/enums/src/enum_fwd_decl.c
Comment thread tests/unit/enums/src/enum_fwd_decl.c
@ahomescu
Copy link
Copy Markdown
Contributor

Since forward declarations of enums aren't allowed in C (per https://en.cppreference.com/c/language/enum and also the issue you opened), I'm starting to think we should fix our test instead.

Comment thread c2rust-ast-exporter/src/AstExporter.cpp Outdated
@Rua
Copy link
Copy Markdown
Contributor Author

Rua commented Apr 22, 2026

I'm starting to think we should fix our test instead.

What kind of fix?

@kkysen kkysen merged commit 69cd376 into immunant:master Apr 24, 2026
11 checks passed
kkysen added a commit that referenced this pull request Apr 24, 2026
@Rua Rua deleted the foreign-enum branch April 24, 2026 09:03
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.

transpile: Panic on forward declared enum

3 participants