File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,24 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
259
259
if (Tok.is (tok::colon)) {
260
260
param.ColonLoc = consumeToken ();
261
261
262
+ // Check if token is @ sign ergo an attribute
263
+ if (Tok.is (tok::at_sign)) {
264
+ Token nextToken = peekToken ();
265
+ // Check if attribute is invalid type attribute
266
+ // and actually a declaration attribute
267
+ TypeAttrKind TK = TypeAttributes::getAttrKindFromString (nextToken.getText ());
268
+ DeclAttrKind DK = DeclAttribute::getAttrKindFromString (nextToken.getText ());
269
+ if ((TK == TAK_Count || (TK == TAK_noescape && !isInSILMode ()))
270
+ && DK != DAK_Count
271
+ && DeclAttribute::getOptions (declKind) & OnParam) {
272
+ SourceLoc AtLoc = consumeToken (tok::at_sign);
273
+ SourceLoc AttrLoc = consumeToken (tok::identifier);
274
+ diagnose (AtLoc, diag::decl_attribute_applied_to_type)
275
+ .fixItRemove (SourceRange (AtLoc, AttrLoc))
276
+ .fixItInsert (StartLoc, " @" + nextToken.getText ().str ()+" " );
277
+ }
278
+ }
279
+
262
280
auto type = parseType (diag::expected_parameter_type);
263
281
status |= type;
264
282
param.Type = type.getPtrOrNull ();
You can’t perform that action at this time.
0 commit comments