From d7999cbc6eb5e83e712904c1739fba799caf1c6c Mon Sep 17 00:00:00 2001 From: Erik Pilkington Date: Wed, 26 Jun 2019 23:39:23 +0000 Subject: [PATCH] [ObjC] Improve error message for a malformed objc-type-name If the type didn't exist, we used to emit a really bad error: t.m:3:12: error: expected ')' -(nullable NoSuchType)foo3; ^ rdar://50925632 llvm-svn: 364489 --- clang/lib/Parse/ParseObjc.cpp | 2 +- clang/test/Parser/objc-interfaces.m | 3 +++ clang/test/SemaObjC/invalid-typename.m | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index c2e73d5e82c2..a8d6f7fd6027 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -1247,11 +1247,11 @@ ParsedType Parser::ParseObjCTypeName(ObjCDeclSpec &DS, BalancedDelimiterTracker T(*this, tok::l_paren); T.consumeOpen(); - SourceLocation TypeStartLoc = Tok.getLocation(); ObjCDeclContextSwitch ObjCDC(*this); // Parse type qualifiers, in, inout, etc. ParseObjCTypeQualifierList(DS, context); + SourceLocation TypeStartLoc = Tok.getLocation(); ParsedType Ty; if (isTypeSpecifierQualifier() || isObjCInstancetype()) { diff --git a/clang/test/Parser/objc-interfaces.m b/clang/test/Parser/objc-interfaces.m index 0ae17f15ee4d..911fa16a01e4 100644 --- a/clang/test/Parser/objc-interfaces.m +++ b/clang/test/Parser/objc-interfaces.m @@ -6,3 +6,6 @@ - (int*) foo2 __attribute__((deprecated)) : (int) x1 __attribute__((deprecated)); // expected-error {{expected ';' after method prototype}} expected-error {{method type specifier must start with '-' or '+'}} @end +@interface X +-(nullable NoSuchType)foo3; // expected-error {{expected a type}} +@end diff --git a/clang/test/SemaObjC/invalid-typename.m b/clang/test/SemaObjC/invalid-typename.m index 50dd18873822..4e2dba8e1494 100644 --- a/clang/test/SemaObjC/invalid-typename.m +++ b/clang/test/SemaObjC/invalid-typename.m @@ -7,6 +7,6 @@ canBeginSyncingPlanWithId:(bycopy NSString *)planId syncModes:(bycopy NSArray /* ISDSyncState */ *)syncModes entities:(bycopy NSArray /* ISDEntity */ *)entities - truthPullers:(bycopy NSDictionary /* NSString -> [NSString] */ *)truthPullers; // expected-error{{expected ')'}} expected-note {{to match this '('}} + truthPullers:(bycopy NSDictionary /* NSString -> [NSString] */ *)truthPullers; // expected-error {{expected a type}} @end