Skip to content

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

Closed
@remexre

Description

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...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions