about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-11-24 16:17:26 -0800
committerBrian Anderson <banderson@mozilla.com>2011-11-24 16:18:26 -0800
commit7aee9f7b56f8d96f9444ebb1d06e32e024b81974 (patch)
tree66ce836ff65e1a3c8ecc3d7d8bd161ca14e24ac0 /src
parent3e303af86b5380c7d53a8879d883cd36ad2a69a6 (diff)
downloadrust-7aee9f7b56f8d96f9444ebb1d06e32e024b81974.tar.gz
rust-7aee9f7b56f8d96f9444ebb1d06e32e024b81974.zip
rustc: Fix a bug in cdir attribute parsing
The first attribute of the first mod was being applied to every mod.
Diffstat (limited to 'src')
-rw-r--r--src/comp/syntax/parse/parser.rs2
-rw-r--r--src/test/run-pass/dupe-first-attr.rc11
2 files changed, 13 insertions, 0 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index 82c477a7d96..a8f294820af 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -2515,9 +2515,11 @@ fn parse_crate_directives(p: parser, term: token::token,
     }
 
     let cdirs: [@ast::crate_directive] = [];
+    let first_outer_attr = first_outer_attr;
     while p.peek() != term {
         let cdir = @parse_crate_directive(p, first_outer_attr);
         cdirs += [cdir];
+        first_outer_attr = [];
     }
     ret cdirs;
 }
diff --git a/src/test/run-pass/dupe-first-attr.rc b/src/test/run-pass/dupe-first-attr.rc
new file mode 100644
index 00000000000..65798b048f9
--- /dev/null
+++ b/src/test/run-pass/dupe-first-attr.rc
@@ -0,0 +1,11 @@
+// Regression test for a problem with the first mod attribute
+// being applied to every mod
+
+#[cfg(target_os = "linux")]
+mod hello;
+
+#[cfg(target_os = "macos")]
+mod hello;
+
+#[cfg(target_os = "win32")]
+mod hello;
\ No newline at end of file