summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-11-14 12:01:04 -0600
committerGitHub <noreply@github.com>2016-11-14 12:01:04 -0600
commit004a19537f1f40e77aacdc13a2f56a8553e63dc9 (patch)
tree5ba2713d771291e8670b00a81d9cc2338bca9ad5 /src
parentb7259deb35aae61d7d21875e3b3da55e3f4391cc (diff)
parent1001e3bcc835e1b01deef6c84f2163d67ff6d509 (diff)
Auto merge of #247 - emilio:macro-redef, r=fitzgen
Handle macro redefinition a bit more graciously. r? @fitzgen
Diffstat (limited to 'src')
-rw-r--r--src/ir/var.rs12
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