@@ -172,22 +172,14 @@ LayoutConstraint Parser::parseLayoutConstraint(Identifier LayoutConstraintID) {
172
172
ParserResult<TypeRepr> Parser::parseTypeSimple (Diag<> MessageID,
173
173
bool HandleCodeCompletion) {
174
174
ParserResult<TypeRepr> ty;
175
- // If this is an "inout" marker for an identifier type, consume the inout.
176
- SourceLoc SpecifierLoc;
177
- VarDecl::Specifier TypeSpecifier;
178
- if (Tok.is (tok::kw_inout)) {
179
- SpecifierLoc = consumeToken ();
180
- TypeSpecifier = VarDecl::Specifier::InOut;
181
- } else if (Tok.is (tok::identifier)) {
182
- if (Tok.getRawText ().equals (" __shared" )) {
183
- assert (false );
184
- SpecifierLoc = consumeToken ();
185
- TypeSpecifier = VarDecl::Specifier::Shared;
186
- } else if (Tok.getRawText ().equals (" __owned" )) {
187
- assert (false );
188
- SpecifierLoc = consumeToken ();
189
- TypeSpecifier = VarDecl::Specifier::Owned;
190
- }
175
+
176
+ if (Tok.is (tok::kw_inout) ||
177
+ (Tok.is (tok::identifier) && (Tok.getRawText ().equals (" __shared" ) ||
178
+ Tok.getRawText ().equals (" __owned" )))) {
179
+ // Type specifier should already be parsed before here. This only happens
180
+ // for construct like 'P1 & inout P2'.
181
+ diagnose (Tok.getLoc (), diag::attr_only_on_parameters_parse, Tok.getText ());
182
+ consumeToken ();
191
183
}
192
184
193
185
switch (Tok.getKind ()) {
@@ -297,24 +289,6 @@ ParserResult<TypeRepr> Parser::parseTypeSimple(Diag<> MessageID,
297
289
break ;
298
290
}
299
291
300
- // If we parsed any specifier, prepend it.
301
- if (SpecifierLoc.isValid () && ty.isNonNull ()) {
302
- TypeRepr *repr = ty.get ();
303
- switch (TypeSpecifier) {
304
- case VarDecl::Specifier::InOut:
305
- repr = new (Context) InOutTypeRepr (repr, SpecifierLoc);
306
- break ;
307
- case VarDecl::Specifier::Shared:
308
- repr = new (Context) SharedTypeRepr (repr, SpecifierLoc);
309
- break ;
310
- case VarDecl::Specifier::Owned:
311
- break ;
312
- case VarDecl::Specifier::Var:
313
- llvm_unreachable (" tried to create var type specifier?" );
314
- }
315
- ty = makeParserResult (repr);
316
- }
317
-
318
292
return ty;
319
293
}
320
294
0 commit comments