From 18b63865ce35901d9beaf7ea94f4b1408defd7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Fri, 3 Jun 2011 14:34:19 -0400 Subject: [PATCH] Accept *foo as a pointer to foo. This is accepted everywhere, since just passing a pointer is safe. --- src/comp/front/ast.rs | 1 + src/comp/front/parser.rs | 5 +++++ src/test/run-pass/type-ptr.rs | 6 ++++++ 3 files changed, 12 insertions(+) create mode 100644 src/test/run-pass/type-ptr.rs diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index da94195ab93..85e525e8823 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -323,6 +323,7 @@ fn unop_to_str(unop op) -> str { ty_str; ty_box(mt); ty_vec(mt); + ty_ptr(mt); ty_task; ty_port(@ty); ty_chan(@ty); diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 688bfb01e19..d7fecee6ca4 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -511,6 +511,11 @@ fn parse_ty(&parser p) -> @ast::ty { auto mt = parse_mt(p); hi = mt.ty.span.hi; t = ast::ty_box(mt); + } else if (p.peek() == token::BINOP(token::STAR)) { + p.bump(); + auto mt = parse_mt(p); + hi = mt.ty.span.hi; + t = ast::ty_ptr(mt); } else if (eat_word(p, "vec")) { expect(p, token::LBRACKET); t = ast::ty_vec(parse_mt(p)); diff --git a/src/test/run-pass/type-ptr.rs b/src/test/run-pass/type-ptr.rs new file mode 100644 index 00000000000..8ccbba9218d --- /dev/null +++ b/src/test/run-pass/type-ptr.rs @@ -0,0 +1,6 @@ +fn f(*int a) { +} + +fn main(vec[str] args) { + ret; +}