annotate gcc/testsuite/gcc.dg/deprecated.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 /* Test __attribute__ ((deprecated)) */
kono
parents:
diff changeset
2 /* { dg-do compile } */
kono
parents:
diff changeset
3 /* { dg-options "-Wdeprecated-declarations" } */
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 #if 1
kono
parents:
diff changeset
6 typedef int INT1 __attribute__((deprecated));
kono
parents:
diff changeset
7 typedef INT1 INT2 __attribute__ ((__deprecated__));
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 typedef INT1 INT1a; /* { dg-warning "'INT1' is deprecated" } */
kono
parents:
diff changeset
10 typedef INT1 INT1b __attribute__ ((deprecated));
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 INT1 should_be_unavailable; /* { dg-warning "'INT1' is deprecated" } */
kono
parents:
diff changeset
13 INT1a should_not_be_deprecated;
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 INT1 f1(void) __attribute__ ((deprecated));
kono
parents:
diff changeset
16 INT1 f2(void) { return 0; } /* { dg-warning "'INT1' is deprecated" } */
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 INT2 f3(void) __attribute__ ((__deprecated__));
kono
parents:
diff changeset
19 INT2 f4(void) { return 0; } /* { dg-warning "'INT2' is deprecated" } */
kono
parents:
diff changeset
20 int f5(INT2 x); /* { dg-warning "'INT2' is deprecated" } */
kono
parents:
diff changeset
21 int f6(INT2 x) __attribute__ ((__deprecated__)); /* { dg-warning "'INT2' is deprecated" } */
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 typedef enum {red, green, blue} Color __attribute__((deprecated));
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 int g1;
kono
parents:
diff changeset
26 int g2 __attribute__ ((deprecated));
kono
parents:
diff changeset
27 int g3 __attribute__ ((__deprecated__));
kono
parents:
diff changeset
28 Color k; /* { dg-warning "'Color' is deprecated" } */
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30 typedef struct {
kono
parents:
diff changeset
31 int field1;
kono
parents:
diff changeset
32 int field2 __attribute__ ((deprecated));
kono
parents:
diff changeset
33 int field3;
kono
parents:
diff changeset
34 int field4 __attribute__ ((__deprecated__));
kono
parents:
diff changeset
35 union {
kono
parents:
diff changeset
36 int field5;
kono
parents:
diff changeset
37 int field6 __attribute__ ((deprecated));
kono
parents:
diff changeset
38 } u1;
kono
parents:
diff changeset
39 int field7:1;
kono
parents:
diff changeset
40 int field8:1 __attribute__ ((deprecated));
kono
parents:
diff changeset
41 union {
kono
parents:
diff changeset
42 int field9;
kono
parents:
diff changeset
43 int field10;
kono
parents:
diff changeset
44 } u2 __attribute__ ((deprecated));
kono
parents:
diff changeset
45 } S1;
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 int func1()
kono
parents:
diff changeset
48 {
kono
parents:
diff changeset
49 INT1 w; /* { dg-warning "'INT1' is deprecated" } */
kono
parents:
diff changeset
50 int x __attribute__ ((deprecated));
kono
parents:
diff changeset
51 int y __attribute__ ((__deprecated__));
kono
parents:
diff changeset
52 int z;
kono
parents:
diff changeset
53 int (*pf)() = f1; /* { dg-warning "'f1' is deprecated" } */
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 z = w + x + y + g1 + g2 + g3; /* { dg-warning "'x' is deprecated" } */
kono
parents:
diff changeset
56 /* { dg-warning "'y' is deprecated" "y" { target *-*-* } .-1 } */
kono
parents:
diff changeset
57 /* { dg-warning "'g2' is deprecated" "g2" { target *-*-* } .-2 } */
kono
parents:
diff changeset
58 /* { dg-warning "'g3' is deprecated" "g3" { target *-*-* } .-3 } */
kono
parents:
diff changeset
59 return f1(); /* { dg-warning "'f1' is deprecated" "f1" } */
kono
parents:
diff changeset
60 }
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 int func2(S1 *p)
kono
parents:
diff changeset
63 {
kono
parents:
diff changeset
64 S1 lp;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 if (p->field1)
kono
parents:
diff changeset
67 return p->field2; /* { dg-warning "'field2' is deprecated" } */
kono
parents:
diff changeset
68 else if (lp.field4) /* { dg-warning "'field4' is deprecated" } */
kono
parents:
diff changeset
69 return p->field3;
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 p->u1.field5 = g1 + p->field7;
kono
parents:
diff changeset
72 p->u2.field9; /* { dg-warning "'u2' is deprecated" } */
kono
parents:
diff changeset
73 return p->u1.field6 + p->field8; /* { dg-warning "'field6' is deprecated" } */
kono
parents:
diff changeset
74 /* { dg-warning "'field8' is deprecated" "field8" { target *-*-* } .-1 } */
kono
parents:
diff changeset
75 }
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 struct SS1 {
kono
parents:
diff changeset
78 int x;
kono
parents:
diff changeset
79 INT1 y; /* { dg-warning "'INT1' is deprecated" } */
kono
parents:
diff changeset
80 } __attribute__ ((deprecated));
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 struct SS1 *p1; /* { dg-warning "'SS1' is deprecated" } */
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 struct __attribute__ ((__deprecated__)) SS2 {
kono
parents:
diff changeset
85 int x;
kono
parents:
diff changeset
86 INT1 y; /* { dg-warning "'INT1' is deprecated" } */
kono
parents:
diff changeset
87 };
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 struct SS2 *p2; /* { dg-warning "'SS2' is deprecated" } */
kono
parents:
diff changeset
90 #endif
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 #ifdef __cplusplus
kono
parents:
diff changeset
93 class T {
kono
parents:
diff changeset
94 public:
kono
parents:
diff changeset
95 void member1(int) __attribute__ ((deprecated));
kono
parents:
diff changeset
96 void member2(INT1) __attribute__ ((__deprecated__));
kono
parents:
diff changeset
97 int member3(T *);
kono
parents:
diff changeset
98 int x;
kono
parents:
diff changeset
99 } __attribute__ ((deprecated));
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 T *p2;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 inline void T::member1(int) {}
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 int T::member2(T *p)
kono
parents:
diff changeset
106 {
kono
parents:
diff changeset
107 p->member1(1); /* { xxdg-warning "'member1' is deprecated" } */
kono
parents:
diff changeset
108 (*p).member1(2); /* { xxdg-warning "'member1' is deprecated" } */
kono
parents:
diff changeset
109 p->member2(1); /* { xxdg-warning "'member2' is deprecated" } */
kono
parents:
diff changeset
110 (*p).member2(2); /* { xxdg-warning "'member2' is deprecated" } */
kono
parents:
diff changeset
111 p->member3(p);
kono
parents:
diff changeset
112 (*p).member3(p);
kono
parents:
diff changeset
113 return f1(); /* { xxdg-warning "'f1' is deprecated" } */
kono
parents:
diff changeset
114 }
kono
parents:
diff changeset
115 #endif
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117