Clang error: cannot find protocol declaration for A (err_undeclared_protocol)
Jump to navigation
Jump to search
Text | error: cannot find protocol declaration for A |
---|---|
Type | Error |
Category | Semantic Issue |
Internal Id | err_undeclared_protocol |
Internal Message | cannot find protocol declaration for %0
|
Regular Expression | (?:error|fatal error)\: cannot find protocol declaration for (.*?)
|
First Commit | 2009-03-04 b1c4d5507fad The basic representation of diagnostics information in tablegen format, plus (uncommented and incomp... |
Description
Example
Flags | -xobjective-c
|
|
---|---|---|
Source |
@interface C (Category) <P> @end
| |
Compiler Output |
<source>:1:26: error: cannot find protocol declaration for 'P' <source>:1:12: error: cannot find interface declaration for 'C' |
Clang Internals (17.0.6)
Git Commit Message
The basic representation of diagnostics information in tablegen format, plus (uncommented and incomplete) test conversions of the existing def files to this format. llvm-svn: 66064
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaDeclObjC.cpp (line 1330)
/// FindProtocolDeclaration - This routine looks up protocols and
/// issues an error if they are not declared. It returns list of
/// protocol declarations in its 'Protocols' argument.
void Sema::FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, ArrayRef<IdentifierLocPair> ProtocolId, SmallVectorImpl<Decl *> &Protocols) {
for (const IdentifierLocPair &Pair : ProtocolId) {
// ...
if (!PDecl) {
Diag(Pair.second, diag::err_undeclared_protocol) << Pair.first;
clang/lib/Sema/SemaDeclObjC.cpp (line 1744)
void Sema::actOnObjCTypeArgsOrProtocolQualifiers(Scope *S, ParsedType baseType, SourceLocation lAngleLoc, ArrayRef<IdentifierInfo *> identifiers, ArrayRef<SourceLocation> identifierLocs, SourceLocation rAngleLoc, SourceLocation &typeArgsLAngleLoc, SmallVectorImpl<ParsedType> &typeArgs, SourceLocation &typeArgsRAngleLoc, SourceLocation &protocolLAngleLoc, SmallVectorImpl<Decl *> &protocols, SourceLocation &protocolRAngleLoc, bool warnOnIncompleteProtocols) {
// ...
for (unsigned i = 0, n = identifiers.size(); i != n; ++i) {
// ...
Diag(identifierLocs[i], (lookupKind == LookupAnyName ? diag::err_objc_type_arg_missing : lookupKind == LookupObjCProtocolName ? diag::err_undeclared_protocol : diag::err_unknown_typename)) << identifiers[i];
clang/lib/Sema/SemaExprObjC.cpp (line 1392)
ExprResult Sema::ParseObjCProtocolExpression(IdentifierInfo *ProtocolId, SourceLocation AtLoc, SourceLocation ProtoLoc, SourceLocation LParenLoc, SourceLocation ProtoIdLoc, SourceLocation RParenLoc) {
// ...
if (!PDecl) {
Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaObjC/undefined-protocol-type-1.m
- clang/test/SemaObjC/undefined-protocol-type-1.m:7:10: error: cannot find protocol declaration for 'p3'
- clang/test/SemaObjC/undefined-protocol-type-1.m:8:10: error: cannot find protocol declaration for 'p3'