Skip to content

Commit abed16d

Browse files
committed
ir: Ignore non-finite macro constants from macros.
1 parent 16bd8b7 commit abed16d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/ir/var.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ impl ClangSubItemParser for Var {
146146
let (type_kind, val) = match value {
147147
EvalResult::Invalid => return Err(ParseError::Continue),
148148
EvalResult::Float(f) => {
149+
// Bail out if this number is not finite. We could
150+
// generate those, I guess, but its utility is unclear.
151+
if !f.is_finite() {
152+
return Err(ParseError::Continue);
153+
}
149154
(TypeKind::Float(FloatKind::Float), VarType::Float(f))
150155
}
151156
EvalResult::Char(c) => {
@@ -178,9 +183,7 @@ impl ClangSubItemParser for Var {
178183
} else {
179184
IntKind::Int
180185
}
181-
} else if value >
182-
u32::max_value() as
183-
i64 {
186+
} else if value > u32::max_value() as i64 {
184187
IntKind::ULongLong
185188
} else {
186189
IntKind::UInt
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+

tests/headers/infinite-macro.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define INFINITY (1.0f/0.0f)
2+
#define NAN (0.0f/0.0f)

0 commit comments

Comments
 (0)