| 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 |
|
| 10 |
int a(void) { return 0; } |
| 11 |
void __attribute__((noreturn)) b(void) { while (1); } |
| 12 |
|
| 13 |
void fa(fn_a_t x) {} // strict-note {{passing argument to parameter 'x' here}} |
| 14 |
void fb(fn_b_t x) {} |
| 15 |
|
| 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 |
} |