Parse / AST: Allow let / var as argument labels with a warning.

The diagnostic is now a warning and the new message alerts the user that
though it is valid to have let and var as argument label names,
they are interpreted as argument labels, not keywords.
This commit is contained in:
Sam Lazarus
2019-04-16 19:58:05 -04:00
parent 07b6bf4489
commit 2a38b48eea
11 changed files with 70 additions and 52 deletions

View File

@@ -854,8 +854,8 @@ ERROR(parameter_specifier_as_attr_disallowed,none,
ERROR(parameter_specifier_repeated,none,
"parameter must not have multiple '__owned', 'inout', '__shared',"
" 'var', or 'let' specifiers", ())
ERROR(parameter_let_var_as_attr,none,
"'%0' as a parameter attribute is not allowed",
WARNING(parameter_let_var_as_attr,none,
"'%0' in this position is interpreted as an argument label",
(StringRef))

View File

@@ -587,6 +587,8 @@ public:
void skipUntilDeclRBrace(tok T1, tok T2);
void skipListUntilDeclRBrace(tok T1, tok T2);
/// Skip a single token, but match parentheses, braces, and square brackets.
///
/// Note: this does \em not match angle brackets ("<" and ">")! These are

View File

@@ -173,8 +173,8 @@ public:
return true;
}
// 'let', 'var', and 'inout' cannot be argument labels.
if (isAny(tok::kw_let, tok::kw_var, tok::kw_inout))
// inout cannot be used as an argument label.
if (is(tok::kw_inout))
return false;
// All other keywords can be argument labels.