blob: 4d2ff9adb886824c7d1f2ee615bb96afdf004066 [file] [log] [blame]
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00001// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic --verify %s
Daniel Dunbard7d5f022009-03-24 02:24:46 +00002// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region --verify %s
Ted Kremenekc5302912009-03-05 20:22:13 +00003
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?
Ted Kremenek5c42f9b2009-03-05 22:47:06 +00007typedef void* (*MyFuncTest1)(void);
Ted Kremenekc5302912009-03-05 20:22:13 +00008
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}
Ted Kremenek5c42f9b2009-03-05 22:47:06 +000016
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}