Clang note: forward declaration of class here (note_forward_class)
Jump to navigation
Jump to search
Text | error: forward declaration of class here |
---|---|
Type | Note |
Category | Semantic Issue |
Internal Id | note_forward_class |
Internal Message | forward declaration of class here
|
Regular Expression | note\: forward declaration of class here
|
First Commit | 2010-12-16 7cabbe04ebdd Improve diagnostics when property being looked up |
Description
Example
Flags | -xobjective-c
|
|
---|---|---|
Source |
@class C;
int main() {
[C performSelector:@selector(unknownMethod)]; // Forward declaration of C
return 0;
}
| |
Compiler Output |
<source>:4:4: warning: receiver 'C' is a forward class and corresponding @interface may not exist [-Wreceiver-forward-class] <source>:1:8: note: forward declaration of class here <source>:4:6: warning: class method '+performSelector:' not found (return type defaults to 'id') [-Wobjc-method-access] |
Clang Internals (17.0.6)
Git Commit Message
Improve diagnostics when property being looked up in a forward @class object. // rdar://8774513 llvm-svn: 121933
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/SemaAvailability.cpp (line 551)
/// Actually emit an availability diagnostic for a reference to an unavailable
/// decl.
///
/// \param Ctx The context that the reference occurred in
/// \param ReferringDecl The exact declaration that was referenced.
/// \param OffendingDecl A related decl to \c ReferringDecl that has an
/// availability attribute corresponding to \c K attached to it. Note that this
/// may not be the same as ReferringDecl, i.e. if an EnumDecl is annotated and
/// we refer to a member EnumConstantDecl, ReferringDecl is the EnumConstantDecl
/// and OffendingDecl is the EnumDecl.
static void DoEmitAvailabilityWarning(Sema &S, AvailabilityResult K, Decl *Ctx, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, StringRef Message, ArrayRef<SourceLocation> Locs, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess) {
// ...
if (!Message.empty()) {
// ...
} else if (!UnknownObjCClass) {
// ...
} else {
// ...
S.Diag(UnknownObjCClass->getLocation(), diag::note_forward_class);
clang/lib/Sema/SemaExprObjC.cpp (line 209)
/// Validates ObjCInterfaceDecl availability.
/// ObjCInterfaceDecl, used to create ObjC literals, should be defined
/// if clang not in a debugger mode.
static bool ValidateObjCLiteralInterfaceDecl(Sema &S, ObjCInterfaceDecl *Decl, SourceLocation Loc, Sema::ObjCLiteralKind LiteralKind) {
if (!Decl) {
// ...
} else if (!Decl->hasDefinition() && !S.getLangOpts().DebuggerObjCLiteral) {
// ...
S.Diag(Decl->getLocation(), diag::note_forward_class);
clang/lib/Sema/SemaType.cpp (line 9252)
/// The implementation of RequireCompleteType
bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser *Diagnoser) {
// ...
// If the Objective-C class was a forward declaration, produce a note.
if (IFace && !IFace->isInvalidDecl() && !IFace->getLocation().isInvalid())
Diag(IFace->getLocation(), diag::note_forward_class);
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaObjC/exprs.m
- clang/test/SemaObjC/exprs.m:36:8: note: forward declaration of class here