From e65b086e07a6345d8eb85bf84f3899368c233348 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 6 Mar 2012 20:05:56 +0000 Subject: 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 --- .../test/SemaObjC/objc-container-subscripting-2.m | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 clang/test/SemaObjC/objc-container-subscripting-2.m (limited to 'clang/test/SemaObjC/objc-container-subscripting-2.m') 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}} +} + -- cgit v1.2.3