CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
127 lines
2.9 KiB
Objective-C
127 lines
2.9 KiB
Objective-C
// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify -Wno-objc-root-class %s
|
|
// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
|
|
|
|
@interface StopAccessingIvarsDirectlyExample
|
|
@property(strong) id name, rank, serialNumber;
|
|
@end
|
|
|
|
@implementation StopAccessingIvarsDirectlyExample
|
|
|
|
- (void)identifyYourSelf {
|
|
if (self.name && self.rank && self.serialNumber)
|
|
self.name = 0;
|
|
}
|
|
|
|
// @synthesize name, rank, serialNumber;
|
|
// default synthesis allows direct access to property ivars.
|
|
- (id)init {
|
|
_name = _rank = _serialNumber = 0;
|
|
return self;
|
|
}
|
|
|
|
- (void)dealloc {
|
|
}
|
|
@end
|
|
|
|
|
|
// Test2
|
|
@interface Test2
|
|
@property(strong, nonatomic) id object;
|
|
@end
|
|
|
|
// object has user declared setter/getter so it won't be
|
|
// default synthesized; thus causing user error.
|
|
@implementation Test2
|
|
- (id) bar { return object; } // expected-error {{use of undeclared identifier 'object'}}
|
|
- (void)setObject:(id)newObject {}
|
|
- (id)object { return 0; }
|
|
@end
|
|
|
|
// Test3
|
|
@interface Test3
|
|
{
|
|
id uid; // expected-note {{instance variable is declared here}}
|
|
}
|
|
@property (readwrite, assign) id uid; // expected-note {{property declared here}}
|
|
@end
|
|
|
|
@implementation Test3 // expected-warning {{autosynthesized property 'uid' will use synthesized instance variable '_uid', not existing instance variable 'uid'}}
|
|
// Oops, forgot to write @synthesize! will be default synthesized
|
|
- (void) myMethod {
|
|
self.uid = 0; // Use of the “setter”
|
|
uid = 0; // Use of the wrong instance variable
|
|
_uid = 0; // Use of the property instance variable
|
|
}
|
|
@end
|
|
|
|
@interface Test4 {
|
|
id _var;
|
|
}
|
|
@property (readwrite, assign) id var;
|
|
@end
|
|
|
|
|
|
// default synthesize property named 'var'
|
|
@implementation Test4
|
|
- (id) myMethod {
|
|
return self->_var; // compiles because 'var' is synthesized by default
|
|
}
|
|
@end
|
|
|
|
@interface Test5
|
|
{
|
|
id _var;
|
|
}
|
|
@property (readwrite, assign) id var;
|
|
@end
|
|
|
|
// default synthesis of property 'var'
|
|
@implementation Test5
|
|
- (id) myMethod {
|
|
Test5 *foo = 0;
|
|
return foo->_var; // OK
|
|
}
|
|
@end
|
|
|
|
@interface Test6
|
|
{
|
|
id _var; // expected-note {{'_var' declared here}}
|
|
}
|
|
@property (readwrite, assign) id var;
|
|
@end
|
|
|
|
// no default synthesis. So error is expected.
|
|
@implementation Test6
|
|
- (id) myMethod
|
|
{
|
|
return var; // expected-error {{use of undeclared identifier 'var'}}
|
|
}
|
|
@synthesize var = _var;
|
|
@end
|
|
|
|
int* _object;
|
|
|
|
@interface Test7
|
|
@property (readwrite, assign) id object;
|
|
@end
|
|
|
|
// With default synthesis, '_object' is be the synthesized ivar not the global
|
|
// 'int*' object. So no error.
|
|
@implementation Test7
|
|
- (id) myMethod {
|
|
return _object;
|
|
}
|
|
@end
|
|
|
|
@interface Test8
|
|
{
|
|
id _y;
|
|
id y; // expected-note {{instance variable is declared here}}
|
|
}
|
|
@property(copy) id y; // expected-note {{property declared here}}
|
|
@end
|
|
|
|
|
|
@implementation Test8 @end // expected-warning {{autosynthesized property 'y' will use instance variable '_y', not existing instance variable 'y'}}
|
|
|