Debian Codegraph @

gcc/testsuite/g++.dg/ext/attr-access-2.C

raw
1 /* PR c++/94098 - checking ICE on attribute access redeclaration
2 { dg-do compile }
3 { dg-options "-Wall" } */
4
5 #define RO(...) __attribute__ ((access (read_only, __VA_ARGS__)))
6 #define RW(...) __attribute__ ((access (read_write, __VA_ARGS__)))
7 #define WO(...) __attribute__ ((access (write_only, __VA_ARGS__)))
8
9 typedef __INT32_TYPE__ int32_t;
10
11 int rdwr1_2_3_4 (void*, void*, void*, void*);
12 int RW (1) rdwr1_2_3_4 (void*, void*, void*, void*);
13 int RW (2) rdwr1_2_3_4 (void*, void*, void*, void*);
14 int RW (3) rdwr1_2_3_4 (void*, void*, void*, void*);
15 int RW (4) rdwr1_2_3_4 (void*, void*, void*, void*);
16
17 extern int32_t x[1];
18
19 void call_rdwrp1_2_3_4 (void)
20 {
21 rdwr1_2_3_4 (x, x, x, x);
22 rdwr1_2_3_4 (x, x, x, x + 1); // { dg-warning "\\\[-Wstringop-overflow" }
23 rdwr1_2_3_4 (x, x, x + 1, x); // { dg-warning "\\\[-Wstringop-overflow" }
24 rdwr1_2_3_4 (x, x + 1, x, x); // { dg-warning "\\\[-Wstringop-overflow" }
25 rdwr1_2_3_4 (x + 1, x, x, x); // { dg-warning "\\\[-Wstringop-overflow" }
26 }
27
28
29 int rdwr4_3_2_1 (void*, void*, void*, void*);
30 int RW (4) rdwr4_3_2_1 (void*, void*, void*, void*);
31 int RW (3) rdwr4_3_2_1 (void*, void*, void*, void*);
32 int RW (2) rdwr4_3_2_1 (void*, void*, void*, void*);
33 int RW (1) rdwr4_3_2_1 (void*, void*, void*, void*);
34
35 void call_rdwr4_3_2_1 (void)
36 {
37 rdwr4_3_2_1 (x, x, x, x);
38 rdwr4_3_2_1 (x, x, x, x + 1); // { dg-warning "\\\[-Wstringop-overflow" }
39 rdwr4_3_2_1 (x, x, x + 1, x); // { dg-warning "\\\[-Wstringop-overflow" }
40 rdwr4_3_2_1 (x, x + 1, x, x); // { dg-warning "\\\[-Wstringop-overflow" }
41 rdwr4_3_2_1 (x + 1, x, x, x); // { dg-warning "\\\[-Wstringop-overflow" }
42 }
43
44
45 int rdwrall (void*, void*, void*, void*);
46 int RW (1) rdwrall (void*, void*, void*, void*);
47 int RW (1) RW (2) rdwrall (void*, void*, void*, void*);
48 int RW (1) RW (2) RW (3) rdwrall (void*, void*, void*, void*);
49 int RW (1) RW (2) RW (3) RW (4) rdwrall (void*, void*, void*, void*);
50
51 void call_rdwrall (void)
52 {
53 rdwrall (x, x, x, x);
54 rdwrall (x, x, x, x + 1); // { dg-warning "\\\[-Wstringop-overflow" }
55 rdwrall (x, x, x + 1, x); // { dg-warning "\\\[-Wstringop-overflow" }
56 rdwrall (x, x + 1, x, x); // { dg-warning "\\\[-Wstringop-overflow" }
57 rdwrall (x + 1, x, x, x); // { dg-warning "\\\[-Wstringop-overflow" }
58 }
59
60
61 // Verify the attribute is a part of the function's type.
62 typedef __typeof__ (rdwrall) F;
63
64 void call_fnptr_typeof (F *f)
65 {
66 f (x, x, x, x);
67 f (x, x, x, x + 1); // { dg-warning "\\\[-Wstringop-overflow" }
68 f (x, x, x + 1, x); // { dg-warning "\\\[-Wstringop-overflow" }
69 f (x, x + 1, x, x); // { dg-warning "\\\[-Wstringop-overflow" }
70 f (x + 1, x, x, x); // { dg-warning "\\\[-Wstringop-overflow" }
71 }
72
73
74 // Verify the attribute is effective on a typedef.
75 typedef void FWRall (void*, void*, void*, void*);
76 typedef RW (1) void FWRall (void*, void*, void*, void*);
77 typedef RW (2) void FWRall (void*, void*, void*, void*);
78 typedef RW (3) void FWRall (void*, void*, void*, void*);
79 typedef RW (4) void FWRall (void*, void*, void*, void*);
80
81 void call_fnptr (FWRall *f)
82 {
83 f (x, x, x, x);
84 f (x, x, x, x + 1); // { dg-warning "\\\[-Wstringop-overflow" "pr94171" { xfail *-*-* } }
85 f (x, x, x + 1, x); // { dg-warning "\\\[-Wstringop-overflow" "pr94171" { xfail *-*-* } }
86 f (x, x + 1, x, x); // { dg-warning "\\\[-Wstringop-overflow" "pr94171" { xfail *-*-* } }
87 f (x + 1, x, x, x); // { dg-warning "\\\[-Wstringop-overflow" "pr94171" { xfail *-*-* } }
88 }