Skip to content

Commit 6de944b

Browse files
committed
Add diagnostics for type alias to a wildcard, closes hsutter#357
In the current implementation of cppfront (f83ca9) the following code: ```cpp alias5: type == _; alias6: type == auto; ``` Generates succesfuly: ```cpp using alias5 = auto; using alias6 = auto; ``` Which is invalid cpp1 code. After this change the alias to wildcard will generate the following error: ``` error: a 'type ==' alias declaration must be followed by a type name (not a wildcard _ nor auto) ``` All regression tests pass. Closes hsutter#357
1 parent d7adb8f commit 6de944b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

source/parse.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5617,6 +5617,16 @@ class parser
56175617
);
56185618
return {};
56195619
}
5620+
if (
5621+
t->is_wildcard()
5622+
|| ( t->get_token() && t->get_token()->to_string(true) == "auto" )
5623+
) {
5624+
errors.emplace_back(
5625+
curr().position(),
5626+
"a 'type ==' alias declaration must be followed by a type name (not a wildcard _ nor auto)"
5627+
);
5628+
return {};
5629+
}
56205630
a->initializer = std::move(t);
56215631
}
56225632

0 commit comments

Comments
 (0)