Make the ObjC attributes diagnostics a bit more informative.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178720 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 844a3d1..ad95dd5 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -23,10 +23,14 @@
using namespace clang;
/// Skips attributes after an Objective-C @ directive. Emits a diagnostic.
-void Parser::MaybeSkipAttributes() {
+void Parser::MaybeSkipAttributes(tok::ObjCKeywordKind Kind) {
ParsedAttributes attrs(AttrFactory);
if (Tok.is(tok::kw___attribute)) {
- Diag(Tok, diag::err_objc_postfix_attribute);
+ if (Kind == tok::objc_interface || Kind == tok::objc_protocol)
+ Diag(Tok, diag::err_objc_postfix_attribute_hint)
+ << (Kind == tok::objc_protocol);
+ else
+ Diag(Tok, diag::err_objc_postfix_attribute);
ParseGNUAttributes(attrs);
}
}
@@ -101,7 +105,7 @@
while (1) {
- MaybeSkipAttributes();
+ MaybeSkipAttributes(tok::objc_class);
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::semi);
@@ -188,7 +192,7 @@
return 0;
}
- MaybeSkipAttributes();
+ MaybeSkipAttributes(tok::objc_interface);
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident); // missing class or category name.
@@ -1408,7 +1412,7 @@
return DeclGroupPtrTy();
}
- MaybeSkipAttributes();
+ MaybeSkipAttributes(tok::objc_protocol);
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident); // missing protocol name.
@@ -1501,7 +1505,7 @@
return DeclGroupPtrTy();
}
- MaybeSkipAttributes();
+ MaybeSkipAttributes(tok::objc_implementation);
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident); // missing class or category name.