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