diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ir/var.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/ir/var.rs b/src/ir/var.rs index 0e7df618..1c7b2028 100644 --- a/src/ir/var.rs +++ b/src/ir/var.rs @@ -87,17 +87,19 @@ impl ClangSubItemParser for Var { assert!(!id.is_empty(), "Empty macro name?"); - if ctx.parsed_macro(&id) { - let name = String::from_utf8(id).unwrap(); - warn!("Duplicated macro definition: {}", name); - return Err(ParseError::Continue); - } + let previously_defined = ctx.parsed_macro(&id); // NB: It's important to "note" the macro even if the result is // not an integer, otherwise we might loose other kind of // derived macros. ctx.note_parsed_macro(id.clone(), value.clone()); + if previously_defined { + let name = String::from_utf8(id).unwrap(); + warn!("Duplicated macro definition: {}", name); + return Err(ParseError::Continue); + } + // NOTE: Unwrapping, here and above, is safe, because the // identifier of a token comes straight from clang, and we // enforce utf8 there, so we should have already panicked at |