casts.m revision 8e8fb3be5bd78f0564444eca02b404566a5f3b5d
1// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s
2// expected-no-diagnostics
3
4// Test function pointer casts.  Currently we track function addresses using
5// loc::FunctionVal.  Because casts can be arbitrary, do we need to model
6// functions with regions?
7typedef void* (*MyFuncTest1)(void);
8
9MyFuncTest1 test1_aux(void);
10void test1(void) {
11  void *x;
12  void* (*p)(void);
13  p = ((void*) test1_aux());
14  if (p != ((void*) 0)) x = (*p)();
15}
16
17// Test casts from void* to function pointers.  Same issue as above:
18// should we eventually model function pointers using regions?
19void* test2(void *p) {
20  MyFuncTest1 fp = (MyFuncTest1) p;
21  return (*fp)();
22}
23
24// <radar://10087620>
25// A cast from int onjective C property reference to int.
26typedef signed char BOOL;
27@protocol NSObject  - (BOOL)isEqual:(id)object; @end
28@interface NSObject <NSObject> {} - (id)init; @end
29typedef enum {
30  EEOne,
31  EETwo
32} RDR10087620Enum;
33@interface RDR10087620 : NSObject {
34  RDR10087620Enum   elem;
35}
36@property (readwrite, nonatomic) RDR10087620Enum elem;
37@end
38
39static void
40adium_media_ready_cb(RDR10087620 *InObj)
41{
42  InObj.elem |= EEOne;
43}
44