OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [Wbad-function-cast-1.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Test operation of -Wbad-function-cast.  Bug 6980 complained of the
2
   wording of the diagnostic.  */
3
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
4
/* { dg-do compile } */
5
/* { dg-options "-Wbad-function-cast" } */
6
 
7
void vf(void);
8
int if1(void);
9
char if2(void);
10
long if3(void);
11
float rf1(void);
12
double rf2(void);
13
_Complex double cf(void);
14
enum e { E1 } ef(void);
15
_Bool bf(void);
16
char *pf1(void);
17
int *pf2(void);
18
 
19
void
20
foo(void)
21
{
22
  /* Casts to void types are always OK.  */
23
  (void)vf();
24
  (void)if1();
25
  (void)cf();
26
  (const void)bf();
27
  /* Casts to the same type or similar types are OK.  */
28
  (int)if1();
29
  (long)if2();
30
  (char)if3();
31
  (float)rf1();
32
  (long double)rf2();
33
  (_Complex float)cf();
34
  (enum f { F1 })ef();
35
  (_Bool)bf();
36
  (void *)pf1();
37
  (char *)pf2();
38
  /* Casts to types with different TREE_CODE (which is how this
39
     warning has been defined) are not OK, except for casts to void
40
     types.  */
41
  (float)if1(); /* { dg-warning "cast from function call of type 'int' to non-matching type 'float'" } */
42
  (double)if2(); /* { dg-warning "cast from function call of type 'char' to non-matching type 'double'" } */
43
  (_Bool)if3(); /* { dg-warning "cast from function call of type 'long int' to non-matching type '_Bool'" } */
44
  (int)rf1(); /* { dg-warning "cast from function call of type 'float' to non-matching type 'int'" } */
45
  (long)rf2(); /* { dg-warning "cast from function call of type 'double' to non-matching type 'long int'" } */
46
  (double)cf(); /* { dg-warning "cast from function call of type 'complex double' to non-matching type 'double'" } */
47
  (int)ef(); /* { dg-warning "cast from function call of type 'enum e' to non-matching type 'int'" } */
48
  (int)bf(); /* { dg-warning "cast from function call of type '_Bool' to non-matching type 'int'" } */
49
  (__SIZE_TYPE__)pf1(); /* { dg-warning "cast from function call of type 'char \\*' to non-matching type '\[^\\n\]*'" } */
50
  (__PTRDIFF_TYPE__)pf2(); /* { dg-warning "cast from function call of type 'int \\*' to non-matching type '\[^\\n\]*'" } */
51
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.