summaryrefslogtreecommitdiff
path: root/clang/test/Sema/incompatible-function-pointer-types-strict.c
blob: 647251de420307cf76ca89c8aa45d03bd1dbcbe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// RUN: %clang_cc1 -fsyntax-only %s -Wincompatible-function-pointer-types-strict -verify=soft,strict
// RUN: %clang_cc1 -fsyntax-only %s -Werror=incompatible-function-pointer-types-strict -verify=hard,strict
// RUN: %clang_cc1 -fsyntax-only %s -Wincompatible-function-pointer-types -verify=nonstrict
// nonstrict-no-diagnostics

enum E { A = -1, B };
typedef enum E (*fn_a_t)(void);
typedef void (*fn_b_t)(void);

int a(void) { return 0; }
void __attribute__((noreturn)) b(void) { while (1); }

void fa(fn_a_t x) {} // strict-note {{passing argument to parameter 'x' here}}
void fb(fn_b_t x) {}

void baz(void) {
  fa(&a); // soft-warning {{incompatible function pointer types passing 'int (*)(void)' to parameter of type 'fn_a_t' (aka 'enum E (*)(void)')}} \
             hard-error {{incompatible function pointer types passing 'int (*)(void)' to parameter of type 'fn_a_t' (aka 'enum E (*)(void)')}}
  fb(&b); // no-warning
}