diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-03-06 20:05:56 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-03-06 20:05:56 +0000 |
commit | e65b086e07a6345d8eb85bf84f3899368c233348 (patch) | |
tree | 44a8c1e8e3da0b53a3167bcdb1fdb325f11f308c /clang/test/SemaObjC/objc-container-subscripting-2.m | |
parent | de850676e0206af165d62ad4c99e657c67a49e86 (diff) | |
download | bcm5719-llvm-e65b086e07a6345d8eb85bf84f3899368c233348.tar.gz bcm5719-llvm-e65b086e07a6345d8eb85bf84f3899368c233348.zip |
Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,
NSNumber, and boolean literals. This includes both Sema and Codegen support.
Included is also support for new Objective-C container subscripting.
My apologies for the large patch. It was very difficult to break apart.
The patch introduces changes to the driver as well to cause clang to link
in additional runtime support when needed to support the new language features.
Docs are forthcoming to document the implementation and behavior of these features.
llvm-svn: 152137
Diffstat (limited to 'clang/test/SemaObjC/objc-container-subscripting-2.m')
-rw-r--r-- | clang/test/SemaObjC/objc-container-subscripting-2.m | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/objc-container-subscripting-2.m b/clang/test/SemaObjC/objc-container-subscripting-2.m new file mode 100644 index 00000000000..2564975f4d4 --- /dev/null +++ b/clang/test/SemaObjC/objc-container-subscripting-2.m @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +typedef unsigned int size_t; +@protocol P @end + +@interface NSMutableArray +- (id)objectAtIndexedSubscript:(size_t)index; +- (void)setObject:(id)object atIndexedSubscript:(size_t)index; +@end + +@interface NSMutableDictionary +- (id)objectForKeyedSubscript:(id)key; +- (void)setObject:(id)object forKeyedSubscript:(size_t)key; +@end + +id func() { + NSMutableArray *array; + float f; + array[f] = array; // expected-error {{expected method to write dictionary element not found on object of type 'NSMutableArray *'}} + return array[3.14]; // expected-error {{expected method to read dictionary element not found on object of type 'NSMutableArray *'}} +} + +void test_unused() { + NSMutableArray *array; + array[10]; // expected-warning {{container access result unused - container access should not be used for side effects}} + + NSMutableDictionary *dict; + dict[array]; // expected-warning {{container access result unused - container access should not be used for side effects}} +} + |