| 1 |
/* { dg-skip-if "requires hosted libstdc++ for stdlib free" { ! hostedlib } } */ |
| 2 |
|
| 3 |
/* Test to see if the analyzer detect and analyze calls via |
| 4 |
function pointers or not. */ |
| 5 |
|
| 6 |
#include <stdlib.h> |
| 7 |
|
| 8 |
void fun(int *int_ptr) |
| 9 |
{ |
| 10 |
free(int_ptr); /* { dg-warning "double-'free' of 'int_ptr'" } */ |
| 11 |
} |
| 12 |
|
| 13 |
void single_call() |
| 14 |
{ |
| 15 |
int *int_ptr = (int*)malloc(sizeof(int)); |
| 16 |
void (*fun_ptr)(int *) = &fun; |
| 17 |
(*fun_ptr)(int_ptr); |
| 18 |
} |
| 19 |
|
| 20 |
void double_call() |
| 21 |
{ |
| 22 |
int *int_ptr = (int*)malloc(sizeof(int)); |
| 23 |
void (*fun_ptr)(int *) = &fun; |
| 24 |
(*fun_ptr)(int_ptr); /* { dg-message "calling 'fun' from 'double_call'" } */ |
| 25 |
(*fun_ptr)(int_ptr); |
| 26 |
} |