summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2013-04-03 17:36:11 +0000
committerNico Weber <nicolasweber@gmx.de>2013-04-03 17:36:11 +0000
commit04e213b6b6fb14b8b20b83bf7fd4a4cddbbcb91c (patch)
treee33e4617af229861051636ecea3bdd5a9d04b8ed /clang/lib
parent0707b125e3e81b456dde6f7591d5f9a4e3e8976e (diff)
downloadbcm5719-llvm-04e213b6b6fb14b8b20b83bf7fd4a4cddbbcb91c.tar.gz
bcm5719-llvm-04e213b6b6fb14b8b20b83bf7fd4a4cddbbcb91c.zip
Emit a nicer diagnostic for misplaced attributes on ObjC directives.
llvm-svn: 178670
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Parse/ParseObjc.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index fb0237ac05e..844a3d12e93 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -22,6 +22,14 @@
#include "llvm/ADT/StringExtras.h"
using namespace clang;
+/// Skips attributes after an Objective-C @ directive. Emits a diagnostic.
+void Parser::MaybeSkipAttributes() {
+ ParsedAttributes attrs(AttrFactory);
+ if (Tok.is(tok::kw___attribute)) {
+ Diag(Tok, diag::err_objc_postfix_attribute);
+ ParseGNUAttributes(attrs);
+ }
+}
/// ParseObjCAtDirectives - Handle parts of the external-declaration production:
/// external-declaration: [C99 6.9]
@@ -93,6 +101,7 @@ Parser::ParseObjCAtClassDeclaration(SourceLocation atLoc) {
while (1) {
+ MaybeSkipAttributes();
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident);
SkipUntil(tok::semi);
@@ -179,6 +188,8 @@ Decl *Parser::ParseObjCAtInterfaceDeclaration(SourceLocation AtLoc,
return 0;
}
+ MaybeSkipAttributes();
+
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident); // missing class or category name.
return 0;
@@ -1397,6 +1408,8 @@ Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
return DeclGroupPtrTy();
}
+ MaybeSkipAttributes();
+
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident); // missing protocol name.
return DeclGroupPtrTy();
@@ -1488,6 +1501,8 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
return DeclGroupPtrTy();
}
+ MaybeSkipAttributes();
+
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected_ident); // missing class or category name.
return DeclGroupPtrTy();
OpenPOWER on IntegriCloud