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