xref: /llvm-project/clang/test/Sema/incompatible-function-pointer-types-strict.c (revision 41ce74e6e983f523d44d3a80be5ae778c35df85a)
1 // RUN: %clang_cc1 -fsyntax-only %s -Wincompatible-function-pointer-types-strict -verify=soft,strict
2 // RUN: %clang_cc1 -fsyntax-only %s -Werror=incompatible-function-pointer-types-strict -verify=hard,strict
3 // RUN: %clang_cc1 -fsyntax-only %s -Wincompatible-function-pointer-types -verify=nonstrict
4 // nonstrict-no-diagnostics
5 
6 enum E { A = -1, B };
7 typedef enum E (*fn_a_t)(void);
8 typedef void (*fn_b_t)(void);
9 
a(void)10 int a(void) { return 0; }
b(void)11 void __attribute__((noreturn)) b(void) { while (1); }
12 
fa(fn_a_t x)13 void fa(fn_a_t x) {} // strict-note {{passing argument to parameter 'x' here}}
fb(fn_b_t x)14 void fb(fn_b_t x) {}
15 
baz(void)16 void baz(void) {
17   fa(&a); // soft-warning {{incompatible function pointer types passing 'int (*)(void)' to parameter of type 'fn_a_t' (aka 'enum E (*)(void)')}} \
18              hard-error {{incompatible function pointer types passing 'int (*)(void)' to parameter of type 'fn_a_t' (aka 'enum E (*)(void)')}}
19   fb(&b); // no-warning
20 }
21