aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/expand/rust-macro-expand.cc8
-rw-r--r--gcc/rust/parse/rust-parse-impl.h6
-rw-r--r--gcc/testsuite/rust/compile/parse_range.rs9
3 files changed, 22 insertions, 1 deletions
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc
index a372e81..eef9194 100644
--- a/gcc/rust/expand/rust-macro-expand.cc
+++ b/gcc/rust/expand/rust-macro-expand.cc
@@ -731,6 +731,14 @@ parse_many (Parser<MacroInvocLexer> &parser, TokenId &delimiter,
break;
auto node = parse_fn ();
+ if (node.is_error ())
+ {
+ for (auto err : parser.get_errors ())
+ err.emit_error ();
+
+ return AST::ASTFragment::create_error ();
+ }
+
nodes.emplace_back (std::move (node));
}
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index d925aca..c4cfbe2 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -14102,9 +14102,13 @@ std::unique_ptr<AST::RangeExpr>
Parser<ManagedTokenSource>::parse_nud_range_exclusive_expr (
const_TokenPtr tok, AST::AttrVec outer_attrs ATTRIBUTE_UNUSED)
{
+ auto restrictions = ParseRestrictions ();
+ restrictions.expr_can_be_null = true;
+
// FIXME: this probably parses expressions accidently or whatever
// try parsing RHS (as tok has already been consumed in parse_expression)
- std::unique_ptr<AST::Expr> right = parse_expr (LBP_DOT_DOT, AST::AttrVec ());
+ std::unique_ptr<AST::Expr> right
+ = parse_expr (LBP_DOT_DOT, AST::AttrVec (), restrictions);
Location locus = tok->get_locus ();
diff --git a/gcc/testsuite/rust/compile/parse_range.rs b/gcc/testsuite/rust/compile/parse_range.rs
new file mode 100644
index 0000000..03469b1
--- /dev/null
+++ b/gcc/testsuite/rust/compile/parse_range.rs
@@ -0,0 +1,9 @@
+// { dg-additional-options "-fsyntax-only" }
+
+fn main() {
+ let a = [1, 2, 3, 4];
+ let _ = a[0..];
+ let _ = a[..3];
+ let _ = a[0..3];
+ let _ = a[..];
+}