Clang Project

clang_source_code/test/Sema/incompatible-function-pointer-types.c
1// RUN: %clang_cc1 -fsyntax-only %s -Wincompatible-pointer-types -verify
2// RUN: %clang_cc1 -fsyntax-only %s -Wincompatible-function-pointer-types -verify
3
4// This test ensures that the subgroup of -Wincompatible-pointer-types warnings
5// that concern function pointers can be promoted (or not promoted) to an error
6// *separately* from the other -Wincompatible-pointer-type warnings.
7typedef int (*MyFnTyA)(int *, char *);
8
9int bar(char *a, int *b) { return 0; }
10int foo(MyFnTyA x) { return 0; } // expected-note {{passing argument to parameter 'x' here}}
11
12void baz() {
13  foo(&bar); // expected-warning {{incompatible function pointer types passing 'int (*)(char *, int *)' to parameter of type 'MyFnTyA' (aka 'int (*)(int *, char *)')}}
14}
15