]> granicus.if.org Git - clang/commitdiff
[ObjC] Improve error message for a malformed objc-type-name
authorErik Pilkington <erik.pilkington@gmail.com>
Wed, 26 Jun 2019 23:39:23 +0000 (23:39 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Wed, 26 Jun 2019 23:39:23 +0000 (23:39 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364489 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseObjc.cpp
test/Parser/objc-interfaces.m
test/SemaObjC/invalid-typename.m

index c2e73d5e82c20fccf0ca60cf299af97b30805036..a8d6f7fd60270428bd6cf51d3e708d01fcb5e002 100644 (file)
@@ -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()) {
index 0ae17f15ee4d4d771fdedb8d87140ccd6b5ee03f..911fa16a01e40bb4ec6399433c95dd8939ae14f7 100644 (file)
@@ -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
index 50dd188738222df977f708d5ff17a938301293b3..4e2dba8e149429a43fd80a8a45879ca963755804 100644 (file)
@@ -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