-// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -verify -fobjc-gc -analyzer-constraints=basic %s
-// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -verify -fobjc-gc -analyzer-constraints=range %s
-// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -verify -fobjc-gc -disable-free %s
-// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify -fobjc-gc %s
-// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify -fobjc-gc %s
+// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -verify -fobjc-gc -analyzer-constraints=basic %s -Wno-implicit-function-declaration
+// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -verify -fobjc-gc -analyzer-constraints=range %s -Wno-implicit-function-declaration
+// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -verify -fobjc-gc -disable-free %s -Wno-implicit-function-declaration
+// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify -fobjc-gc %s -Wno-implicit-function-declaration
+// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify -fobjc-gc %s -Wno-implicit-function-declaration
//===----------------------------------------------------------------------===//
// The following code is reduced using delta-debugging from
// Test cases.
//===----------------------------------------------------------------------===//
+CFAbsoluteTime CFAbsoluteTimeGetCurrent();
+
CFAbsoluteTime f1_use_after_release() {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t);
static char *lorem = "fooBarBaz";
+void NSLog(NSString *, ...);
+
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *tmp1 = NSSTRINGWRAPPER(lorem, 6); // no-warning
struct sockaddr { sa_family_t sa_family; };
struct sockaddr_storage {};
+void getsockname();
+
void f(int sock) {
struct sockaddr_storage storage;
struct sockaddr* sockaddr = (struct sockaddr*)&storage;
// expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
}
+int f();
+
void f3() {
int r;
if ((r = f()) != 0) { // no-warning
// Check our handling of fields being invalidated by function calls.
struct test2_struct { int x; int y; char* s; };
-void test2_helper(struct test2_struct* p);
+void test2_help(struct test2_struct* p);
char test2() {
struct test2_struct s;
char value[1];
if ( *(value) != 1 ) {} // expected-warning{{The left operand of '!=' is a garbage value}}
}
-void rdar_rdar_7332673_test2_aux(char *x);
+int rdar_7332673_test2_aux(char *x);
void rdar_7332673_test2() {
char *value;
if ( rdar_7332673_test2_aux(value) != 1 ) {} // expected-warning{{Pass-by-value argument in function call is undefined}}
//===----------------------------------------------------------------------===//
int rdar7468209_aux();
-void rdar7468209_aux2();
+void rdar7468209_aux_2();
void rdar7468209() {
__block int x = 0;
(void (^)(void *))test_block_cast_aux(); // expected-warning{{expression result unused}}
}
+int OSAtomicCompareAndSwap32Barrier();
+
// Test comparison of 'id' instance variable to a null void* constant after
// performing an OSAtomicCompareAndSwap32Barrier.
// This previously was a crash in RegionStoreManager.
return;
}
+int ivar_getOffset();
+
// Reduced from a crash involving the cast of an Objective-C symbolic region to
// 'char *'
static NSNumber *test_ivar_offset(id self, SEL _cmd, Ivar inIvar) {
QuxSize size;
} __Request__SetPortalSize_t;
+double __Foo_READSWAP__double(double*);
+
static __inline__ bar_return_t
__Beeble_check__Request__SetPortalSize_t(__attribute__((__unused__)) __Request__SetPortalSize_t *In0P) {
if (In0P->Foo.int_rep != Foo_record.int_rep) {
NSDate* f;
};
+CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
+
CFAbsoluteTime f4() {
struct foo x;
// Test to see if we *issue* an error when we store the pointer
// to a struct. This differs from basic store.
+CFAbsoluteTime CFAbsoluteTimeGetCurrent(void);
+
struct foo {
NSDate* f;
};
// Test of handling objects whose references "escape" to containers.
//===----------------------------------------------------------------------===//
+void CFDictionaryAddValue();
+
// <rdar://problem/6539791>
void rdar_6539791(CFMutableDictionaryRef y, void* key, void* val_key) {
CFMutableDictionaryRef x = CFDictionaryCreateMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
// Test uninitialized value due to part of the structure being uninitialized.
struct TestUninit { int x; int y; };
struct TestUninit test_uninit_aux();
+void test_unit_aux2(int);
void test_uninit_pos() {
struct TestUninit v1 = { 0, 0 };
struct TestUninit v2 = test_uninit_aux();
-
+int ec(int, int);
void x() {
static void (*fp0)(void) __attribute__((noreturn));
+void fatal();
+
static void __attribute__((noreturn)) f0(void) {
fatal();
} // expected-warning {{function declared 'noreturn' should not return}}
// RUN: %clang_cc1 %s -verify -fblocks -fsyntax-only
+void xx();
+
int a() {
A:if (1) xx();
return ^{A:return 1;}();
}
+void bar(void*);
// rdar://6257721 - reference to static/global is byref by default.
static int test5g;
void test5() {
__block int (*ap)[size]; // expected-error {{__block attribute not allowed on declaration with a variably modified type}}
}
+void f();
+
void test17() {
void (^bp)(int);
void (*rp)(int);
else
return 0;
}
+void next();
void foo4() {
int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(char *)', expected 'int (^)(char const *)'}}
int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (char *)', expected 'int (*)(char const *)'}}
const char* test1 = 1 ? "i" : 1 == 1 ? "v" : "r";
void _efree(void *ptr);
+void free(void *ptr);
int _php_stream_free1() {
return (1 ? free(0) : _efree(0)); // expected-error {{incompatible type returning 'void', expected 'int'}}
int snprintf(char *restrict, size_t, const char *restrict, ...);
int sprintf(char *restrict, const char *restrict, ...);
int vasprintf(char **, const char *, va_list);
+int asprintf(char **, const char *, ...);
int vfprintf(FILE *, const char *restrict, va_list);
int vprintf(const char *restrict, va_list);
int vsnprintf(char *, size_t, const char *, va_list);
}
void f2() {
- fprintf(0, "foo"); // expected-error{{implicit declaration of 'fprintf' requires inclusion of the header <stdio.h>}}
+ fprintf(0, "foo"); // expected-error{{implicit declaration of 'fprintf' requires inclusion of the header <stdio.h>}} \
+ expected-warning {{implicit declaration of function 'fprintf' is invalid in C99}}
}
// PR2892
int32_t *vector[16];
const char compDesc[16 + 1];
int32_t compCount = 0;
- if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}}
+ if (_CFCalendarDecomposeAbsoluteTimeV(compDesc, vector, compCount)) { // expected-note {{previous implicit declaration is here}} \
+ expected-warning {{implicit declaration of function '_CFCalendarDecomposeAbsoluteTimeV' is invalid in C99}}
}
return ((void *)0); // expected-warning {{void function 'func' should not return a value}}
}
- (id) retain;
@end
+int objc_lookUpClass(const char*);
+
void __raiseExc1() {
[objc_lookUpClass("NSString") retain]; // expected-warning {{receiver type 'int' is not 'id'}} \
expected-warning {{method '-retain' not found}}
}
@end
+void NSLog(id, ...);
+
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
A *a = [[A new] autorelease];
extern void func4 (void (^block1)(), void (^block2)()) __attribute__((nonnull(1)))
__attribute__((nonnull(2)));
+void func6();
+void func7();
+
void
foo (int i1, int i2, int i3, void (^cp1)(), void (^cp2)(), void (^cp3)())
{
- (void) bar;
@end
+void bar();
void foo(id x) {
bar((short<SomeProtocol>)x); // expected-error {{expected ')'}} expected-note {{to match this '('}}
bar((<SomeProtocol>)x); // expected-warning {{protocol qualifiers without 'id' is archaic}}