blob: 6f19211976b792e7e0b4f7a2757c451ba22b6547 [file] [log] [blame]
Ted Kremenek033a07e2011-08-03 23:14:55 +00001// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s
Ted Kremenekc5302912009-03-05 20:22:13 +00002
3// Test function pointer casts. Currently we track function addresses using
4// loc::FunctionVal. Because casts can be arbitrary, do we need to model
5// functions with regions?
Ted Kremenek5c42f9b2009-03-05 22:47:06 +00006typedef void* (*MyFuncTest1)(void);
Ted Kremenekc5302912009-03-05 20:22:13 +00007
8MyFuncTest1 test1_aux(void);
9void test1(void) {
10 void *x;
11 void* (*p)(void);
12 p = ((void*) test1_aux());
13 if (p != ((void*) 0)) x = (*p)();
14}
Ted Kremenek5c42f9b2009-03-05 22:47:06 +000015
16// Test casts from void* to function pointers. Same issue as above:
17// should we eventually model function pointers using regions?
18void* test2(void *p) {
19 MyFuncTest1 fp = (MyFuncTest1) p;
20 return (*fp)();
21}
Anna Zaksf7afe4a2011-09-12 17:56:08 +000022
23// <radar://10087620>
24// A cast from int onjective C property reference to int.
25typedef signed char BOOL;
26@protocol NSObject - (BOOL)isEqual:(id)object; @end
27@interface NSObject <NSObject> {} - (id)init; @end
28typedef enum {
Anna Zaks773d8472011-09-12 18:28:35 +000029 EEOne,
30 EETwo
31} RDR10087620Enum;
32@interface RDR10087620 : NSObject {
33 RDR10087620Enum elem;
Anna Zaksf7afe4a2011-09-12 17:56:08 +000034}
Anna Zaks773d8472011-09-12 18:28:35 +000035@property (readwrite, nonatomic) RDR10087620Enum elem;
John McCall4b9c2d22011-11-06 09:01:30 +000036@end
37
Anna Zaksf7afe4a2011-09-12 17:56:08 +000038static void
Anna Zaks773d8472011-09-12 18:28:35 +000039adium_media_ready_cb(RDR10087620 *InObj)
Anna Zaksf7afe4a2011-09-12 17:56:08 +000040{
Anna Zaks773d8472011-09-12 18:28:35 +000041 InObj.elem |= EEOne;
Anna Zaksf7afe4a2011-09-12 17:56:08 +000042}