Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle no return attributes #2259

Merged
merged 12 commits into from
Sep 23, 2022
Merged

Conversation

pvdrz
Copy link
Contributor

@pvdrz pvdrz commented Aug 31, 2022

Partially fixes #2094

@pvdrz pvdrz requested a review from emilio August 31, 2022 19:47
Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks generally good, though I have some minor comments.

tests/headers/noreturn.h Outdated Show resolved Hide resolved
src/clang.rs Outdated Show resolved Hide resolved
src/ir/function.rs Outdated Show resolved Hide resolved
@pvdrz pvdrz requested a review from emilio September 1, 2022 16:27
src/clang.rs Show resolved Hide resolved
@emilio
Copy link
Contributor

emilio commented Sep 1, 2022

So it looks reasonable, but it's fairly unfortunate that we can't handle neither [[noreturn]] nor __attribute__((noreturn)) which I think are more common ways to deal with this.

@pvdrz
Copy link
Contributor Author

pvdrz commented Sep 1, 2022

So it looks reasonable, but it's fairly unfortunate that we can't handle neither [[noreturn]] nor __attribute__((noreturn)) which I think are more common ways to deal with this.

I can try and handle __attribute_((noreturn)) at least in a future PR. I just need to dig more into clang to figure out how to detect them.

@pvdrz
Copy link
Contributor Author

pvdrz commented Sep 1, 2022

Weird, both test that failed pass on local (but I have a pretty recent clang version so that might be it). I'll try to bring back the UnexposedAttribute logic to check if that works.

@pvdrz
Copy link
Contributor Author

pvdrz commented Sep 1, 2022

Fixed 🎉

@pvdrz
Copy link
Contributor Author

pvdrz commented Sep 1, 2022

@emilio now this supports all 3 options :)

@emilio emilio merged commit 86f059f into rust-lang:master Sep 23, 2022
@pvdrz pvdrz deleted the no-return branch September 23, 2022 16:55
@oconnor663
Copy link

oconnor663 commented Oct 27, 2022

Any chance a new Bindgen release will pick this up anytime soon? I'm excited to use this :)

EDIT: Never mind! This is already out, and I just don't know how to fetch tags :p

@CGMossa
Copy link
Contributor

CGMossa commented Mar 19, 2024

I'm experiencing an issue that this PR should have dealt with. I'm thinking the reason could be that this was done for C++ and not for C. Is that restriction here?

@pvdrz
Copy link
Contributor Author

pvdrz commented Mar 19, 2024

Without more information I'm unable to say. However, this feature works on c:

// hello.h
__attribute__((noreturn)) void g(void);

Then you run bindgen hello.h and get

/* automatically generated by rust-bindgen 0.69.4 */

extern "C" {
    pub fn g() -> !;
}

@CGMossa
Copy link
Contributor

CGMossa commented Mar 20, 2024

I'm still seeing an issue on our end. Let me make a dedicated issue.

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.

Support _Noreturn, [[noreturn]], __attribute__((noreturn))
4 participants