annotate gcc/testsuite/gcc.dg/cast-3.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test diagnostics for bad or doubtful casts. Test with
kono
parents:
diff changeset
2 -pedantic-errors. */
kono
parents:
diff changeset
3 /* Origin: Joseph Myers <joseph@codesourcery.com> */
kono
parents:
diff changeset
4 /* { dg-do compile } */
kono
parents:
diff changeset
5 /* { dg-options "-std=gnu99 -pedantic-errors" } */
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 struct s { int a; } sv;
kono
parents:
diff changeset
8 union u { int a; } uv;
kono
parents:
diff changeset
9 int i;
kono
parents:
diff changeset
10 long l;
kono
parents:
diff changeset
11 char c;
kono
parents:
diff changeset
12 void *p;
kono
parents:
diff changeset
13 float fv;
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 void
kono
parents:
diff changeset
16 f (void)
kono
parents:
diff changeset
17 {
kono
parents:
diff changeset
18 (int []) p; /* { dg-error "cast specifies array type" } */
kono
parents:
diff changeset
19 (int ()) p; /* { dg-error "cast specifies function type" } */
kono
parents:
diff changeset
20 (struct s) sv; /* { dg-error "ISO C forbids casting nonscalar to the same type" } */
kono
parents:
diff changeset
21 (union u) uv; /* { dg-error "ISO C forbids casting nonscalar to the same type" } */
kono
parents:
diff changeset
22 (struct s) i; /* { dg-error "conversion to non-scalar type requested" } */
kono
parents:
diff changeset
23 (union u) i; /* { dg-error "ISO C forbids casts to union type" } */
kono
parents:
diff changeset
24 (union u) l; /* { dg-error "cast to union type from type not present in union" } */
kono
parents:
diff changeset
25 (int) sv; /* { dg-error "aggregate value used where an integer was expected" } */
kono
parents:
diff changeset
26 (int) uv; /* { dg-error "aggregate value used where an integer was expected" } */
kono
parents:
diff changeset
27 (float) sv; /* { dg-error "aggregate value used where a float was expected" } */
kono
parents:
diff changeset
28 (float) uv; /* { dg-error "aggregate value used where a float was expected" } */
kono
parents:
diff changeset
29 (_Complex double) sv; /* { dg-error "aggregate value used where a complex was expected" } */
kono
parents:
diff changeset
30 (_Complex double) uv; /* { dg-error "aggregate value used where a complex was expected" } */
kono
parents:
diff changeset
31 (void *) sv; /* { dg-error "cannot convert to a pointer type" } */
kono
parents:
diff changeset
32 (void *) uv; /* { dg-error "cannot convert to a pointer type" } */
kono
parents:
diff changeset
33 (_Bool) sv; /* { dg-error "used struct type value where scalar is required" } */
kono
parents:
diff changeset
34 (_Bool) uv; /* { dg-error "used union type value where scalar is required" } */
kono
parents:
diff changeset
35 (void) sv;
kono
parents:
diff changeset
36 (const void) uv;
kono
parents:
diff changeset
37 (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */
kono
parents:
diff changeset
38 (void *) (char) 1;
kono
parents:
diff changeset
39 (char) p; /* { dg-warning "cast from pointer to integer of different size" } */
kono
parents:
diff changeset
40 (char) (void *) 1; /* { dg-warning "cast from pointer to integer of different size" } */
kono
parents:
diff changeset
41 }