| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -verify %s |
| 2 |
// expected-no-diagnostics |
| 3 |
|
| 4 |
// Test function pointer casts. |
| 5 |
typedef void* (*MyFuncTest1)(void); |
| 6 |
|
| 7 |
MyFuncTest1 test1_aux(void); |
| 8 |
void test1(void) { |
| 9 |
void *x; |
| 10 |
void* (*p)(void); |
| 11 |
p = ((void*) test1_aux()); |
| 12 |
if (p != ((void*) 0)) x = (*p)(); |
| 13 |
} |
| 14 |
|
| 15 |
// Test casts from void* to function pointers. |
| 16 |
void* test2(void *p) { |
| 17 |
MyFuncTest1 fp = (MyFuncTest1) p; |
| 18 |
return (*fp)(); |
| 19 |
} |
| 20 |
|
| 21 |
// A cast from int onjective C property reference to int. |
| 22 |
typedef signed char BOOL; |
| 23 |
@protocol NSObject - (BOOL)isEqual:(id)object; @end |
| 24 |
@interface NSObject <NSObject> {} - (id)init; @end |
| 25 |
typedef enum { |
| 26 |
EEOne, |
| 27 |
EETwo |
| 28 |
} RDR10087620Enum; |
| 29 |
@interface RDR10087620 : NSObject { |
| 30 |
RDR10087620Enum elem; |
| 31 |
} |
| 32 |
@property (readwrite, nonatomic) RDR10087620Enum elem; |
| 33 |
@end |
| 34 |
|
| 35 |
static void |
| 36 |
adium_media_ready_cb(RDR10087620 *InObj) |
| 37 |
{ |
| 38 |
InObj.elem |= EEOne; |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
// PR16690 |
| 43 |
_Bool testLocAsIntegerToBool(void) { |
| 44 |
return (long long)&testLocAsIntegerToBool; |
| 45 |
} |