"setter/getter expects '=' followed by name")
DIAG(err_objc_expected_property_attr, ERROR,
"unknown property attribute detected")
+DIAG(err_objc_unexpected_attr, ERROR,
+ "prefix attribute must be followed by an interface or protocol")
DIAG(err_objc_property_attr_mutually_exclusive, ERROR,
"property attributes '%0' and '%1' are mutually exclusive")
DIAG(warn_objc_property_no_assignment_attribute, WARNING,
SourceLocation ProtocolLoc,
DeclTy * const *ProtoRefs,
unsigned NumProtoRefs,
- SourceLocation EndProtoLoc) {
+ SourceLocation EndProtoLoc,
+ AttributeList *AttrList) {
return 0;
}
// ActOnStartCategoryInterface - this action is called immdiately after
SourceLocation &EndProtoLoc);
void ParseObjCInterfaceDeclList(DeclTy *interfaceDecl,
tok::ObjCKeywordKind contextKey);
- DeclTy *ParseObjCAtProtocolDeclaration(SourceLocation atLoc);
+ DeclTy *ParseObjCAtProtocolDeclaration(SourceLocation atLoc,
+ AttributeList *prefixAttrs = 0);
DeclTy *ObjCImpDecl;
/// "@protocol identifier ;" should be resolved as "@protocol
/// identifier-list ;": objc-interface-decl-list may not start with a
/// semicolon in the first alternative if objc-protocol-refs are omitted.
-Parser::DeclTy *Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc) {
+Parser::DeclTy *Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
+ AttributeList *attrList) {
assert(Tok.isObjCAtKeyword(tok::objc_protocol) &&
"ParseObjCAtProtocolDeclaration(): Expected @protocol");
ConsumeToken(); // the "protocol" identifier
DeclTy *ProtoType =
Actions.ActOnStartProtocolInterface(AtLoc, protocolName, nameLoc,
&ProtocolRefs[0], ProtocolRefs.size(),
- EndProtoLoc);
+ EndProtoLoc, attrList);
ParseObjCInterfaceDeclList(ProtoType, tok::objc_protocol);
// The @ sign was already consumed by ParseObjCInterfaceDeclList().
return Actions.ParsedFreeStandingDeclSpec(CurScope, DS);
}
- // ObjC2 allows prefix attributes on class interfaces.
+ // ObjC2 allows prefix attributes on class interfaces and protocols.
+ // FIXME: This still needs better diagnostics. We should only accept
+ // attributes here, no types, etc.
if (getLang().ObjC2 && Tok.is(tok::at)) {
SourceLocation AtLoc = ConsumeToken(); // the "@"
- if (!Tok.isObjCAtKeyword(tok::objc_interface)) {
- Diag(Tok, diag::err_objc_expected_property_attr);//FIXME:better diagnostic
+ if (!Tok.isObjCAtKeyword(tok::objc_interface) &&
+ !Tok.isObjCAtKeyword(tok::objc_protocol)) {
+ Diag(Tok, diag::err_objc_unexpected_attr);
SkipUntil(tok::semi); // FIXME: better skip?
return 0;
}
const char *PrevSpec = 0;
if (DS.SetTypeSpecType(DeclSpec::TST_unspecified, AtLoc, PrevSpec))
Diag(AtLoc, diag::err_invalid_decl_spec_combination, PrevSpec);
+ if (Tok.isObjCAtKeyword(tok::objc_protocol))
+ return ParseObjCAtProtocolDeclaration(AtLoc, DS.getAttributes());
return ParseObjCAtInterfaceDeclaration(AtLoc, DS.getAttributes());
}
SourceLocation AtProtoInterfaceLoc,
IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
DeclTy * const *ProtoRefNames, unsigned NumProtoRefs,
- SourceLocation EndProtoLoc);
+ SourceLocation EndProtoLoc,
+ AttributeList *AttrList);
virtual DeclTy *ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
IdentifierInfo *ClassName,
SourceLocation ProtocolLoc,
DeclTy * const *ProtoRefs,
unsigned NumProtoRefs,
- SourceLocation EndProtoLoc) {
+ SourceLocation EndProtoLoc,
+ AttributeList *AttrList) {
+ // FIXME: Deal with AttrList.
assert(ProtocolName && "Missing protocol identifier");
ObjCProtocolDecl *PDecl = ObjCProtocols[ProtocolName];
if (PDecl) {
// RUN: clang -fsyntax-only -verify %s
-int @"s" = 5; // expected-error {{unknown}}
+// FIXME: This is a horrible error message here. Fix.
+int @"s" = 5; // expected-error {{prefix attribute must be}}
--- /dev/null
+// RUN: clang -verify -fsyntax-only %s
+
+__attribute__((deprecated)) @class B; // expected-error {{prefix attribute must be followed by an interface or protocol}}
+
+__attribute__((deprecated)) @interface A @end
+__attribute__((deprecated)) @protocol P0;
+__attribute__((deprecated)) @protocol P1
+@end