casts.m revision c037eac3bda3c636c961aab6377beea3242e81e4
1// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic --verify %s && 2// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic-old-cast --verify %s && 3// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region --verify %s 4 5// Test function pointer casts. Currently we track function addresses using 6// loc::FunctionVal. Because casts can be arbitrary, do we need to model 7// functions with regions? 8typedef void* (*MyFuncTest1)(void); 9 10MyFuncTest1 test1_aux(void); 11void test1(void) { 12 void *x; 13 void* (*p)(void); 14 p = ((void*) test1_aux()); 15 if (p != ((void*) 0)) x = (*p)(); 16} 17 18// Test casts from void* to function pointers. Same issue as above: 19// should we eventually model function pointers using regions? 20void* test2(void *p) { 21 MyFuncTest1 fp = (MyFuncTest1) p; 22 return (*fp)(); 23} 24