brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · c43e0f2 Raw
54 lines · c
1// RUN: %clang_cc1 %s -fsyntax-only -Wcast-function-type -verify=expected,strict2// RUN: %clang_cc1 %s -fsyntax-only -Wcast-function-type-strict -verify=expected,strict3// RUN: %clang_cc1 %s -fsyntax-only -Wextra -Wno-ignored-qualifiers -verify4 5int t(int array[static 12]);6int u(int i);7const int v(int i);8int x(long);9 10typedef int (f1)(long);11typedef int (f2)(void*);12typedef int (f3)();13typedef void (f4)();14typedef void (f5)(void);15typedef int (f6)(long, int);16typedef int (f7)(long,...);17typedef int (f8)(int *);18typedef int (f9)(const int);19typedef int (f10)(int);20 21f1 *a;22f2 *b;23f3 *c;24f4 *d;25f5 *e;26f6 *f;27f7 *g;28f8 *h;29f9 *i;30f10 *j;31 32enum E : long;33int efunc(enum E);34 35// Produce the underlying `long` type implicitly.36enum E2 { big = __LONG_MAX__ };37int e2func(enum E2);38 39void foo(void) {40  a = (f1 *)x;41  a = (f1 *)efunc; // strict-warning {{cast from 'int (*)(enum E)' to 'f1 *' (aka 'int (*)(long)') converts to incompatible function type}}42  a = (f1 *)e2func; // strict-warning {{cast from 'int (*)(enum E2)' to 'f1 *' (aka 'int (*)(long)') converts to incompatible function type}}43  b = (f2 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f2 *' (aka 'int (*)(void *)') converts to incompatible function type}} */44  c = (f3 *)x; /* strict-warning {{cast from 'int (*)(long)' to 'f3 *' (aka 'int (*)()') converts to incompatible function type}} */45  d = (f4 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f4 *' (aka 'void (*)()') converts to incompatible function type}} */46  e = (f5 *)x; /* strict-warning {{cast from 'int (*)(long)' to 'f5 *' (aka 'void (*)(void)') converts to incompatible function type}} */47  f = (f6 *)x; /* expected-warning {{cast from 'int (*)(long)' to 'f6 *' (aka 'int (*)(long, int)') converts to incompatible function type}} */48  g = (f7 *)x; /* strict-warning {{cast from 'int (*)(long)' to 'f7 *' (aka 'int (*)(long, ...)') converts to incompatible function type}} */49  h = (f8 *)t;50  i = (f9 *)u;51  // FIXME: return type qualifier should not be included in the function type . Warning should be absent after this issue is fixed. https://github.com/llvm/llvm-project/issues/39494 .52  j = (f10 *)v; /* strict-warning {{cast from 'const int (*)(int)' to 'f10 *' (aka 'int (*)(int)') converts to incompatible function type}} */53}54