Clang error: '__kindof' specifier cannot be applied to non-object type A (err_objc_kindof_nonobject)
Jump to navigation
Jump to search
Text | error: '__kindof' specifier cannot be applied to non-object type A |
---|---|
Type | Error |
Category | Semantic Issue |
Internal Id | err_objc_kindof_nonobject |
Internal Message | '__kindof' specifier cannot be applied to non-object type %0
|
Regular Expression | (?:error|fatal error)\: '__kindof' specifier cannot be applied to non\-object type (.*?)
|
First Commit | 2015-07-07 ab209d83be5d Implement the Objective-C __kindof type qualifier. |
Description
Example
Flags | -xobjective-c
|
|
---|---|---|
Source |
int main() {
__kindof int x; // __kindof applied to non-object type 'int'
return 0;
}
| |
Compiler Output |
<source>:2:3: error: '__kindof' specifier cannot be applied to non-object type 'int' |
Clang Internals (17.0.6)
Git Commit Message
Implement the Objective-C __kindof type qualifier. The __kindof type qualifier can be applied to Objective-C object (pointer) types to indicate id-like behavior, which includes implicit "downcasting" of __kindof types to subclasses and id-like message-send behavior. __kindof types provide better type bounds for substitutions into unspecified generic types, which preserves more type information. llvm-svn: 241548
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/SemaType.cpp (line 7596)
/// Check the application of the Objective-C '__kindof' qualifier to
/// the given type.
static bool checkObjCKindOfType(TypeProcessingState &state, QualType &type, ParsedAttr &attr) {
// ...
// If not, we can't apply __kindof.
if (!objType) {
// ...
S.Diag(attr.getLoc(), diag::err_objc_kindof_nonobject) << type;
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaObjC/kindof.m
- clang/test/SemaObjC/kindof.m:64:9: error: '__kindof' specifier cannot be applied to non-object type 'int'
- clang/test/SemaObjC/kindof.m:66:9: error: '__kindof' specifier cannot be applied to non-object type 'NSObject_ptr_ptr' (aka 'NSObject **')