Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / attr-unavailable-4.c
blob9e39c50fec6ea497cb2bd96679aede02f712ca08
1 /* Test __attribute__ ((unavailable("message"))) */
2 /* { dg-do compile } */
3 /* { dg-options "" } */
5 typedef int INT1 __attribute__((unavailable("You can't use INT1")));
6 typedef INT1 INT2 __attribute__ ((__unavailable__("You can't use INT2")));
8 typedef INT1 INT1a; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
9 typedef INT1 INT1b __attribute__ ((unavailable("You can't use INT1b")));
11 INT1 should_be_unavailable; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
12 INT1a should_not_be_unavailable;
14 INT1 f1(void) __attribute__ ((unavailable("You can't use f1")));
15 INT1 f2(void) { return 0; } /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
17 INT2 f3(void) __attribute__ ((__unavailable__("You can't use f3")));
18 INT2 f4(void) { return 0; } /* { dg-error "'INT2' is unavailable: You can't use INT2" "" } */
19 int f5(INT2 x); /* { dg-error "'INT2' is unavailable: You can't use INT2" "" } */
20 int f6(INT2 x) __attribute__ ((__unavailable__("You can't use f6"))); /* { dg-error "'INT2' is unavailable: You can't use INT2" "" } */
22 typedef enum {red, green, blue} Color __attribute__((unavailable("You can't use Color")));
24 int g1;
25 int g2 __attribute__ ((unavailable("You can't use g2")));
26 int g3 __attribute__ ((__unavailable__("You can't use g3")));
27 Color k; /* { dg-error "'Color' is unavailable: You can't use Color" "" } */
29 typedef struct {
30 int field1;
31 int field2 __attribute__ ((unavailable("You can't use field2")));
32 int field3;
33 int field4 __attribute__ ((__unavailable__("You can't use field4")));
34 union {
35 int field5;
36 int field6 __attribute__ ((unavailable("You can't use field6")));
37 } u1;
38 int field7:1;
39 int field8:1 __attribute__ ((unavailable("You can't use field8")));
40 union {
41 int field9;
42 int field10;
43 } u2 __attribute__ ((unavailable("You can't use u2")));
44 } S1;
46 int func1()
48 INT1 w; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
49 int x __attribute__ ((unavailable("Avoid x")));
50 int y __attribute__ ((__unavailable__("Bad y")));
51 int z;
52 int (*pf)() = f1; /* { dg-error "'f1' is unavailable: You can't use f1" "" } */
54 z = w + x + y + g1 + g2 + g3; /* { dg-error "'x' is unavailable: Avoid x" "" } */
55 /* { dg-error "'y' is unavailable: Bad y" "y" { target *-*-* } .-1 } */
56 /* { dg-error "'g2' is unavailable: You can't use g2" "g2" { target *-*-* } .-2 } */
57 /* { dg-error "'g3' is unavailable: You can't use g3" "g3" { target *-*-* } .-3 } */
58 return f1(); /* { dg-error "'f1' is unavailable: You can't use f1" "" } */
61 int func2(S1 *p)
63 S1 lp;
65 if (p->field1)
66 return p->field2; /* { dg-error "'field2' is unavailable: You can't use field2" "" } */
67 else if (lp.field4) /* { dg-error "'field4' is unavailable: You can't use field4" "" } */
68 return p->field3;
70 p->u1.field5 = g1 + p->field7;
71 p->u2.field9; /* { dg-error "'u2' is unavailable: You can't use u2" "" } */
72 return p->u1.field6 + p->field8; /* { dg-error "'field6' is unavailable: You can't use field6" "" } */
73 /* { dg-error "'field8' is unavailable: You can't use field8" "field8" { target *-*-* } .-1 } */
76 struct SS1 {
77 int x;
78 INT1 y; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
79 } __attribute__ ((unavailable("You can't use SS1")));
81 struct SS1 *p1; /* { dg-error "'SS1' is unavailable: You can't use SS1" "" } */
83 struct __attribute__ ((__unavailable__("You can't use SS2"))) SS2 {
84 int x;
85 INT1 y; /* { dg-error "'INT1' is unavailable: You can't use INT1" "" } */
88 struct SS2 *p2; /* { dg-error "'SS2' is unavailable: You can't use SS2" "" } */