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

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* PR c/12085 */
kono
parents:
diff changeset
2 /* Origin: David Hollenberg <dhollen@mosis.org> */
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 /* Verify that the compiler doesn't inline a function at
kono
parents:
diff changeset
5 a calling point where it is viewed with a different
kono
parents:
diff changeset
6 prototype than the actual one. */
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 /* { dg-do compile } */
kono
parents:
diff changeset
9 /* { dg-options "-O3" } */
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 int foo1(int);
kono
parents:
diff changeset
12 int foo2();
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 typedef struct {
kono
parents:
diff changeset
15 double d;
kono
parents:
diff changeset
16 int a;
kono
parents:
diff changeset
17 } str_t;
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 void bar(double d, int i, str_t s)
kono
parents:
diff changeset
20 {
kono
parents:
diff changeset
21 d = ((double (*) (int)) foo1) (i); /* { dg-warning "8:non-compatible|abort" } */
kono
parents:
diff changeset
22 i = ((int (*) (double)) foo1) (d); /* { dg-warning "8:non-compatible|abort" } */
kono
parents:
diff changeset
23 s = ((str_t (*) (int)) foo1) (i); /* { dg-warning "8:non-compatible|abort" } */
kono
parents:
diff changeset
24 ((void (*) (int)) foo1) (d); /* { dg-warning "non-compatible|abort" } */
kono
parents:
diff changeset
25 i = ((int (*) (int)) foo1) (i); /* { dg-bogus "non-compatible|abort" } */
kono
parents:
diff changeset
26 (void) foo1 (i); /* { dg-bogus "non-compatible|abort" } */
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 d = ((double (*) (int)) foo2) (i); /* { dg-warning "8:non-compatible|abort" } */
kono
parents:
diff changeset
29 i = ((int (*) (double)) foo2) (d); /* { dg-bogus "non-compatible|abort" } */
kono
parents:
diff changeset
30 s = ((str_t (*) (int)) foo2) (i); /* { dg-warning "non-compatible|abort" } */
kono
parents:
diff changeset
31 ((void (*) (int)) foo2) (d); /* { dg-warning "non-compatible|abort" } */
kono
parents:
diff changeset
32 i = ((int (*) (int)) foo2) (i); /* { dg-bogus "non-compatible|abort" } */
kono
parents:
diff changeset
33 (void) foo2 (i); /* { dg-bogus "non-compatible|abort" } */
kono
parents:
diff changeset
34 }
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 int foo1(int arg)
kono
parents:
diff changeset
37 {
kono
parents:
diff changeset
38 /* Prevent the function from becoming const and thus DCEd. */
kono
parents:
diff changeset
39 __asm volatile ("" : "+r" (arg));
kono
parents:
diff changeset
40 return arg;
kono
parents:
diff changeset
41 }
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 int foo2(arg)
kono
parents:
diff changeset
44 int arg;
kono
parents:
diff changeset
45 {
kono
parents:
diff changeset
46 /* Prevent the function from becoming const and thus DCEd. */
kono
parents:
diff changeset
47 __asm volatile ("" : "+r" (arg));
kono
parents:
diff changeset
48 return arg;
kono
parents:
diff changeset
49 }