Add ... parsing for fn pointer type

This commit is contained in:
Edwin Cheng 2019-04-23 11:10:41 +08:00
parent 1705e5887d
commit 6c913d8fa7
4 changed files with 47 additions and 3 deletions

View file

@ -43,7 +43,7 @@ fn list_(p: &mut Parser, flavor: Flavor) {
if flavor.type_required() {
opt_self_param(p);
}
while !p.at(EOF) && !p.at(ket) && !(flavor == Flavor::Normal && p.at(DOTDOTDOT)) {
while !p.at(EOF) && !p.at(ket) && !(flavor.type_required() && p.at(DOTDOTDOT)) {
if !p.at_ts(VALUE_PARAMETER_FIRST) {
p.error("expected value parameter");
break;
@ -55,7 +55,7 @@ fn list_(p: &mut Parser, flavor: Flavor) {
}
// test param_list_vararg
// extern "C" { fn printf(format: *const i8, ...) -> i32; }
if flavor == Flavor::Normal {
if flavor.type_required() {
p.eat(DOTDOTDOT);
}
p.expect(ket);

View file

@ -166,6 +166,7 @@ fn placeholder_type(p: &mut Parser) {
// type A = fn();
// type B = unsafe fn();
// type C = unsafe extern "C" fn();
// type D = extern "C" fn ( u8 , ... ) -> u8;
fn fn_pointer_type(p: &mut Parser) {
let m = p.start();
p.eat(UNSAFE_KW);