diff --git a/Cargo.toml b/Cargo.toml index cec8a57902..d93c052ddc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ bitflags = "1.0.3" cexpr = "0.6" # This kinda sucks: https://github.com/rust-lang/cargo/issues/1982 clap = { version = "3", optional = true } -clang-sys = { version = "1", features = ["clang_6_0"] } +clang-sys = { version = "1", features = ["clang_11_0"] } lazycell = "1" lazy_static = "1" peeking_take_while = "0.1.2" diff --git a/src/clang.rs b/src/clang.rs index 528c8a9111..99849c0be2 100644 --- a/src/clang.rs +++ b/src/clang.rs @@ -1068,6 +1068,15 @@ impl Type { } } + /// If this is an atomic type, returns the underlying value type, otherwise + /// an invalid type. + #[inline] + pub fn atomic_value_type(&self) -> Self { + Self { + x: unsafe { clang_Type_getValueType(self.x) }, + } + } + /// What is the size of this type? Paper over invalid types by returning `0` /// for them. pub fn size(&self, ctx: &BindgenContext) -> usize { diff --git a/src/ir/context.rs b/src/ir/context.rs index 9afd16d6a6..7c61f42f0c 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -1970,6 +1970,10 @@ If you encounter an error missing from this list, please file an issue or a PR!" CXType_Double => TypeKind::Float(FloatKind::Double), CXType_LongDouble => TypeKind::Float(FloatKind::LongDouble), CXType_Float128 => TypeKind::Float(FloatKind::Float128), + CXType_Atomic => { + // TODO(#2151): Preserve atomicity in a useful way somehow. + return self.build_builtin_ty(&ty.atomic_value_type()); + } CXType_Complex => { let float_type = ty.elem_type().expect("Not able to resolve complex type?"); diff --git a/tests/expectations/tests/atomic-constant.rs b/tests/expectations/tests/atomic-constant.rs new file mode 100644 index 0000000000..7f9ffce301 --- /dev/null +++ b/tests/expectations/tests/atomic-constant.rs @@ -0,0 +1,10 @@ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +extern "C" { + pub static mut interrupted: ::std::os::raw::c_uint; +} diff --git a/tests/headers/atomic-constant.h b/tests/headers/atomic-constant.h new file mode 100644 index 0000000000..a43eaad37e --- /dev/null +++ b/tests/headers/atomic-constant.h @@ -0,0 +1 @@ +extern _Atomic unsigned interrupted;