Skip to content

Commit 87b2bc0

Browse files
jbangeloemilio
authored andcommitted
Fixed const-ness of multidimensional arrays
1 parent 7f7809f commit 87b2bc0

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/ir/ty.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,10 @@ impl Type {
12091209

12101210
let name = if name.is_empty() { None } else { Some(name) };
12111211

1212-
let is_const = ty.is_const();
1212+
let is_const = ty.is_const() ||
1213+
(ty.kind() == CXType_ConstantArray &&
1214+
ty.elem_type()
1215+
.map_or(false, |element| element.is_const()));
12131216

12141217
let ty = Type::new(name, layout, kind, is_const);
12151218
// TODO: maybe declaration.canonical()?
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![allow(
2+
dead_code,
3+
non_snake_case,
4+
non_camel_case_types,
5+
non_upper_case_globals
6+
)]
7+
8+
extern "C" {
9+
pub fn f(a: *const [::std::os::raw::c_int; 1usize]);
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void f(const int a[1][1]);

0 commit comments

Comments
 (0)