57 lines · plain
1// RUN: %clang_cc1 -Wuninitialized -fsyntax-only -fblocks %s -verify2 3#include <stdarg.h>4 5@interface NSObject {} @end6@class NSString;7 8@interface NSException9+ (void)raise:(NSString *)name format:(NSString *)format, ...;10+ (void)raise:(NSString *)name format:(NSString *)format arguments:(va_list)argList;11- (void)raise;12@end13 14// Duplicated from uninit-variables.c.15// Test just to ensure the analysis is working.16int test1(void) {17 int x; // expected-note{{initialize the variable 'x' to silence this warning}}18 return x; // expected-warning{{variable 'x' is uninitialized when used here}}19}20 21// Test ObjC fast enumeration.22void test2(void) {23 id collection = 0;24 for (id obj in collection) {25 if (0 == obj) // no-warning26 break;27 }28}29 30void test3(void) {31 id collection = 0;32 id obj;33 for (obj in collection) { // no-warning34 if (0 == obj) // no-warning35 break;36 }37}38 39int test_abort_on_exceptions(int y, NSException *e, NSString *s, int *z, ...) {40 int x; // expected-note {{initialize the variable 'x' to silence this warning}}41 if (y == 1) {42 va_list alist;43 va_start(alist, z);44 [NSException raise:@"Blah" format:@"Blah %@" arguments:alist];45 return x;46 }47 else if (y == 2) {48 [NSException raise:@"Blah" format:s];49 return x; 50 }51 else if (y == 3) {52 [e raise];53 return x;54 }55 return x; // expected-warning {{variable 'x' is uninitialized when used here}}56}57