Ted Kremenek | 033a07e | 2011-08-03 23:14:55 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -verify %s |
Ted Kremenek | c530291 | 2009-03-05 20:22:13 +0000 | [diff] [blame] | 2 | |
| 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 Kremenek | 5c42f9b | 2009-03-05 22:47:06 +0000 | [diff] [blame] | 6 | typedef void* (*MyFuncTest1)(void); |
Ted Kremenek | c530291 | 2009-03-05 20:22:13 +0000 | [diff] [blame] | 7 | |
| 8 | MyFuncTest1 test1_aux(void); |
| 9 | void test1(void) { |
| 10 | void *x; |
| 11 | void* (*p)(void); |
| 12 | p = ((void*) test1_aux()); |
| 13 | if (p != ((void*) 0)) x = (*p)(); |
| 14 | } |
Ted Kremenek | 5c42f9b | 2009-03-05 22:47:06 +0000 | [diff] [blame] | 15 | |
| 16 | // Test casts from void* to function pointers. Same issue as above: |
| 17 | // should we eventually model function pointers using regions? |
| 18 | void* test2(void *p) { |
| 19 | MyFuncTest1 fp = (MyFuncTest1) p; |
| 20 | return (*fp)(); |
| 21 | } |