Input C/C++ Header
void (__attribute__((noreturn)) *take(int t))(int);
Bindgen Invocation
$ bindgen input.h -- -x c -std=gnu11
Actual Results
bindgen exits 0 and emits:
unsafe extern "C" {
pub fn take(t: ::std::os::raw::c_int) -> !;
}
The attribute is on the returned function pointer, not on take. take returns a pointer.
libclang's type spelling is void (*(int))(int) __attribute__((noreturn)). FunctionSig::from_ty looks for __attribute__((noreturn)) at paren-depth 0 and sets is_divergent.
Without the attribute, bindgen emits Option<unsafe extern "C" fn(t: c_int)>. void take(int t) __attribute__((noreturn)); correctly becomes -> !.
#2715 / #2716 fixed the argument shape void foo(__attribute__((noreturn)) void (*arg)(void)); (foo(arg: Option<fn() -> !>), no outer -> !). That check skips attributes inside argument parentheses. On a returned pointer clang puts the attribute at the end of the spelling (depth 0), so the same check still fires.
Expected Results
take should return a function pointer (the pointee can be fn(c_int) -> !). It should not be -> !.
Environment
bindgen: 0.73.1 (rust-lang/rust-bindgen 77cbc723)
clang/libclang: Homebrew clang 21.1.8
rustc: 1.97.1
target: aarch64-apple-darwin
OS: macOS
Input C/C++ Header
Bindgen Invocation
$ bindgen input.h -- -x c -std=gnu11Actual Results
bindgen exits 0 and emits:
The attribute is on the returned function pointer, not on
take.takereturns a pointer.libclang's type spelling is
void (*(int))(int) __attribute__((noreturn)).FunctionSig::from_tylooks for__attribute__((noreturn))at paren-depth 0 and setsis_divergent.Without the attribute, bindgen emits
Option<unsafe extern "C" fn(t: c_int)>.void take(int t) __attribute__((noreturn));correctly becomes-> !.#2715 / #2716 fixed the argument shape
void foo(__attribute__((noreturn)) void (*arg)(void));(foo(arg: Option<fn() -> !>), no outer-> !). That check skips attributes inside argument parentheses. On a returned pointer clang puts the attribute at the end of the spelling (depth 0), so the same check still fires.Expected Results
takeshould return a function pointer (the pointee can befn(c_int) -> !). It should not be-> !.Environment