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
42 lines
2.8 KiB
Objective-C
42 lines
2.8 KiB
Objective-C
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx11.0.0 -fobjc-runtime=macosx-11.0.0 -fobjc-constant-literals -fconstant-nsnumber-literals -fconstant-nsarray-literals -fconstant-nsdictionary-literals -verify %s
|
|
|
|
#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
|
|
typedef unsigned long NSUInteger;
|
|
#else
|
|
typedef unsigned int NSUInteger;
|
|
#endif
|
|
|
|
@class NSString;
|
|
|
|
@interface NSNumber
|
|
+ (NSNumber *)numberWithInt:(int)value;
|
|
@end
|
|
|
|
@interface NSArray
|
|
+ (id)arrayWithObjects:(const id[])objects count:(NSUInteger)cnt;
|
|
@end
|
|
|
|
@interface NSDictionary
|
|
+ (id)dictionaryWithObjects:(const id[])objects forKeys:(const id[])keys count:(NSUInteger)cnt;
|
|
@end
|
|
|
|
static NSArray *const array = @[ @"Hello", @"There", @"How Are You", [NSNumber numberWithInt:42] ]; // expected-error {{an array literal can only be used at file scope if its contents are all also constant literals}}
|
|
static NSArray *const array1 = @[ @"Hello", @"There", @"How Are You", @42 ];
|
|
static NSDictionary *const dictionary = @{@"Hello" : @"There", @"How Are You" : [NSNumber numberWithInt:42]}; // expected-error {{a dictionary literal can only be used at file scope if its contents are all also constant literals and its keys are string literals}}
|
|
static NSDictionary *const dictionary1 = @{@"Hello" : @"There", @"How Are You" : @42};
|
|
static NSDictionary *const dictionary2 = @{@2 : @"Foo"}; // expected-error {{a dictionary literal can only be used at file scope if its contents are all also constant literals and its keys are string literals}}
|
|
|
|
/// For now we only support raw literals in collections not references to other varibles that *could* be modified
|
|
/// so ensure this get's downgraded to a normal runtime literal and warns even at the global scope
|
|
static NSString *const someStringConstantVar = @"foo";
|
|
static NSNumber *const someNumberConstantVar = @2;
|
|
static NSArray *const containsConstantVarReferencesArray = @[ someStringConstantVar, someNumberConstantVar ]; // expected-error {{an array literal can only be used at file scope if its contents are all also constant literals}}
|
|
static NSDictionary *const containsConstantVarReferencesDictionary = @{someStringConstantVar : someNumberConstantVar}; // expected-error {{a dictionary literal can only be used at file scope if its contents are all also constant literals and its keys are string literals}}
|
|
static NSDictionary *const containsConstantVarReferencesDictionary2 = @{@"Foo" : someNumberConstantVar}; // expected-error {{a dictionary literal can only be used at file scope if its contents are all also constant literals and its keys are string literals}}
|
|
|
|
int fooNum() {
|
|
return 2;
|
|
}
|
|
|
|
NSNumber *foo = @(2 + fooNum()); // expected-error{{a boxed expression literal can only be used at file scope if constant}}
|