diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index b84293c6794b..85e418b02f31 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2433,8 +2433,8 @@ def err_ns_bridged_not_interface : Error< "parameter of 'ns_bridged' attribute does not name an Objective-C class">; // objc_bridge attribute diagnostics. -def err_objc_bridge_not_id : Error< - "parameter of 'objc_bridge' attribute must be a single name of an Objective-C class">; +def err_objc_attr_not_id : Error< + "parameter of %0 attribute must be a single name of an Objective-C %select{class|protocol}1">; def err_objc_cf_bridged_not_interface : Error< "CF object of type %0 is bridged to '%1', which is not an Objective-C class">; def err_objc_ns_bridged_invalid_cfobject : Error< diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ed97457101b9..38bffa2f99e4 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -4347,19 +4347,18 @@ static void handleObjCBridgeAttr(Sema &S, Scope *Sc, Decl *D, : ExpectedStructOrUnion); return; } - - if (Attr.getNumArgs() != 1) { - S.Diag(D->getLocStart(), diag::err_objc_bridge_not_id); - return; - } - IdentifierLoc *Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0; + + IdentifierLoc *Parm = 0; + if (Attr.getNumArgs() == 1) + Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : 0; + if (!Parm) { - S.Diag(D->getLocStart(), diag::err_objc_bridge_not_id); + S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0; return; } D->addAttr(::new (S.Context) - ObjCBridgeAttr(Attr.getRange(), S.Context, Parm ? Parm->Ident : 0, + ObjCBridgeAttr(Attr.getRange(), S.Context, Parm->Ident, Attr.getAttributeSpellingListIndex())); }