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

__attribute__((noreturn)) in function pointer argument applies to function's type #2715

Closed
remexre opened this issue Jan 11, 2024 · 0 comments · Fixed by #2716
Closed

__attribute__((noreturn)) in function pointer argument applies to function's type #2715

remexre opened this issue Jan 11, 2024 · 0 comments · Fixed by #2716

Comments

@remexre
Copy link

remexre commented Jan 11, 2024

Input C/C++ Header

void foo(__attribute__((noreturn)) void (*arg)(void));

Bindgen Invocation

$ bindgen /tmp/foo.h

Actual Results

/* automatically generated by rust-bindgen 0.66.1 */

extern "C" {
    pub fn foo(arg: ::std::option::Option<unsafe extern "C" fn() -> !>) -> !;
}

Expected Results

/* automatically generated by rust-bindgen 0.66.1 */

extern "C" {
    pub fn foo(arg: ::std::option::Option<unsafe extern "C" fn() -> !>);
}

Note the lack of the second -> !.

Notes

I'm fairly sure the problem is here:

// This looks easy to break but the clang parser keeps the type spelling clean even if
// other attributes are added.
is_divergent =
is_divergent || ty.spelling().contains("__attribute__((noreturn))");

Since the type of argument of the function contains __attribute__((noreturn)), this assumes that the function does as well...

remexre pushed a commit to remexre/rust-bindgen that referenced this issue Jan 12, 2024
remexre pushed a commit to remexre/rust-bindgen that referenced this issue Jan 12, 2024
remexre pushed a commit to remexre/rust-bindgen that referenced this issue Jan 12, 2024
remexre pushed a commit to remexre/rust-bindgen that referenced this issue Jan 12, 2024
emilio pushed a commit that referenced this issue Jan 12, 2024
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 a pull request may close this issue.

1 participant