Clang warning: receiver A is a forward class and corresponding @interface may not exist [-Wreceiver-forward-class] (warn_receiver_forward_class)
Jump to navigation
Jump to search
Text | error: receiver A is a forward class and corresponding @interface may not exist |
---|---|
Type | Warning |
Category | Semantic Issue |
Internal Id | warn_receiver_forward_class |
Active by Default | Yes |
Flags | -Wno-receiver-forward-class (2 elements) |
Internal Message | receiver %0 is a forward class and corresponding @interface may not exist
|
Regular Expression | (?:warning|error|fatal error)\: receiver (.*?) is a forward class and corresponding @interface may not exist \[(?:\-Werror,)?\-Wreceiver\-forward\-class[^\]]*\]
|
First Commit | 2009-05-09 1bd844da8057 Warn if forward class is used as a receiver. |
Description
Example
Flags | -xobjective-c -Wreceiver-forward-class
|
|
---|---|---|
Source |
@class C;
int main() {
[C someMethod]; // 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 '+someMethod' not found (return type defaults to 'id') [-Wobjc-method-access] |
Clang Internals (17.0.6)
Git Commit Message
Warn if forward class is used as a receiver. llvm-svn: 71278
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/SemaExprObjC.cpp (line 2663)
/// \param ReceiverType The type of the object receiving the
/// message. When \p ReceiverTypeInfo is non-NULL, this is the same
/// type as that refers to. For a superclass send, this is the type of
/// the superclass.
///
/// \param SuperLoc The location of the "super" keyword in a
/// superclass message.
///
/// \param Sel The selector to which the message is being sent.
///
/// \param Method The method that this class message is invoking, if
/// already known.
///
/// \param LBracLoc The location of the opening square bracket ']'.
///
/// \param RBracLoc The location of the closing square bracket ']'.
///
/// \param ArgsIn The message arguments.
ExprResult Sema::BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef<SourceLocation> SelectorLocs, SourceLocation RBracLoc, MultiExprArg ArgsIn, bool isImplicit) {
// ...
// Find the method we are messaging.
if (!Method) {
// ...
if (RequireCompleteType(Loc, Context.getObjCInterfaceType(Class), (getLangOpts().ObjCAutoRefCount ? diag::err_arc_receiver_forward_class : diag::warn_receiver_forward_class), TypeRange)) {
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaObjC/forward-class-receiver.m
- clang/test/SemaObjC/forward-class-receiver.m:12:4: warning: receiver 'NotKnown' is a forward class and corresponding @interface may not exist [-Wreceiver-forward-class]