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