aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/function-ptr-4.c
blob: 016351a83f6bf4800a8440c8e25dc5dc319e7ff9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Test to see if the analyzer detect and analyze calls via 
   function pointers or not.  */

#include <stdlib.h>

void fun(int *int_ptr)
{
	free(int_ptr); /* { dg-warning "double-'free' of 'int_ptr'" } */
}

void single_call()
{
	int *int_ptr = (int*)malloc(sizeof(int));
	void (*fun_ptr)(int *) = &fun;
	(*fun_ptr)(int_ptr);
}

void double_call()
{
	int *int_ptr = (int*)malloc(sizeof(int));
	void (*fun_ptr)(int *) = &fun;
	(*fun_ptr)(int_ptr); /* { dg-message "calling 'fun' from 'double_call'" } */
	(*fun_ptr)(int_ptr);
}