summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/ty.rs11
-rw-r--r--tests/expectations/tests/pointer-attr.rs10
-rw-r--r--tests/headers/pointer-attr.h1
3 files changed, 21 insertions, 1 deletions
diff --git a/src/ir/ty.rs b/src/ir/ty.rs
index d573408c..38ab4564 100644
--- a/src/ir/ty.rs
+++ b/src/ir/ty.rs
@@ -1031,7 +1031,16 @@ impl Type {
CXType_ObjCObjectPointer |
CXType_MemberPointer |
CXType_Pointer => {
- let pointee = ty.pointee_type().unwrap();
+ let mut pointee = ty.pointee_type().unwrap();
+ if *ty != canonical_ty {
+ let canonical_pointee =
+ canonical_ty.pointee_type().unwrap();
+ // clang sometimes loses pointee constness here, see
+ // #2244.
+ if canonical_pointee.is_const() != pointee.is_const() {
+ pointee = canonical_pointee;
+ }
+ }
let inner =
Item::from_ty_or_ref(pointee, location, None, ctx);
TypeKind::Pointer(inner)
diff --git a/tests/expectations/tests/pointer-attr.rs b/tests/expectations/tests/pointer-attr.rs
new file mode 100644
index 00000000..95fe9c5f
--- /dev/null
+++ b/tests/expectations/tests/pointer-attr.rs
@@ -0,0 +1,10 @@
+#![allow(
+ dead_code,
+ non_snake_case,
+ non_camel_case_types,
+ non_upper_case_globals
+)]
+
+extern "C" {
+ pub fn a(arg1: *const ::std::os::raw::c_char);
+}
diff --git a/tests/headers/pointer-attr.h b/tests/headers/pointer-attr.h
new file mode 100644
index 00000000..fe0004b8
--- /dev/null
+++ b/tests/headers/pointer-attr.h
@@ -0,0 +1 @@
+void a(const char __attribute__((btf_type_tag("a"))) *);