3 // RUN: %clang -framework Foundation -fsanitize=objc-cast %s -O1 -o %t
4 // RUN: %run %t 2>&1 | FileCheck %s
6 // RUN: %clang -framework Foundation -fsanitize=objc-cast -fno-sanitize-recover=objc-cast %s -O1 -o %t.trap
7 // RUN: not %run %t.trap 2>&1 | FileCheck %s
9 #include <Foundation/Foundation.h>
12 NSArray *arrayOfInt = [NSArray arrayWithObjects:@1, @2, @3, (void *)0];
13 // CHECK: objc-cast.m:[[@LINE+1]]:{{.*}}: runtime error: invalid ObjC cast, object is a '{{__NSCFNumber|NSConstantIntegerNumber}}', but expected a 'NSString'
14 for (NSString *str in arrayOfInt) {
18 NSArray *arrayOfStr = [NSArray arrayWithObjects:@"a", @"b", @"c", (void *)0];
19 for (NSString *str in arrayOfStr) {
23 // The diagnostic should only be printed once.
24 // CHECK-NOT: runtime error