view gcc/testsuite/c-c++-common/Wcast-function-type.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
line wrap: on
line source

/* { dg-do compile } */
/* { dg-options "-Wcast-function-type" } */

int f(long);

typedef int (f1)(long);
typedef int (f2)(void*);
#ifdef __cplusplus
typedef int (f3)(...);
typedef void (f4)(...);
#else
typedef int (f3)();
typedef void (f4)();
#endif
typedef void (f5)(void);

f1 *a;
f2 *b;
f3 *c;
f4 *d;
f5 *e;

void
foo (void)
{
  a = (f1 *) f; /* { dg-bogus   "incompatible function types" } */
  b = (f2 *) f; /* { dg-warning "7:cast between incompatible function types" } */
  c = (f3 *) f; /* { dg-bogus   "incompatible function types" } */
  d = (f4 *) f; /* { dg-warning "7:cast between incompatible function types" } */
  e = (f5 *) f; /* { dg-bogus   "incompatible function types" } */
}