Debian Codegraph @

gcc/testsuite/gcc.dg/analyzer/write-to-const-2.c

raw
1 typedef __SIZE_TYPE__ size_t;
2
3 void read_only (void *)
4 __attribute__ ((access (read_only, 1)));
5 void write_only (void *) /* { dg-message "parameter 1 of 'write_only' marked with attribute 'access \\(write_only, 1\\)'" } */
6 __attribute__ ((access (write_only, 1)));
7 void read_write (void *) /* { dg-message "parameter 1 of 'read_write' marked with attribute 'access \\(read_write, 1\\)'" } */
8 __attribute__ ((access (read_write, 1)));
9 void none (void *)
10 __attribute__ ((access (none, 1)));
11 void read_only_with_size (void *, size_t)
12 __attribute__ ((access (read_only, 1, 2)));
13 void write_only_with_size (void *, size_t) /* { dg-message "parameter 1 of 'write_only_with_size' marked with attribute 'access \\(write_only, 1, 2\\)'" } */
14 __attribute__ ((access (write_only, 1, 2)));
15 void read_write_with_size (void *, size_t) /* { dg-message "parameter 1 of 'read_write_with_size' marked with attribute 'access \\(read_write, 1, 2\\)'" } */
16 __attribute__ ((access (read_write, 1, 2)));
17 void none_with_size (void *, size_t)
18 __attribute__ ((access (none, 1, 2)));
19
20 const char buf[5] = { 0 }; /* { dg-message "declared here" } */
21
22 void test_read_only (void)
23 {
24 read_only ((char *)buf);
25 }
26
27 void test_write_only (void)
28 {
29 write_only ((char *)buf); /* { dg-warning "write to 'const' object 'buf'" } */
30 }
31
32 void test_read_write (void)
33 {
34 read_write ((char *)buf); /* { dg-warning "write to 'const' object 'buf'" } */
35 }
36
37 void test_none (void)
38 {
39 none ((char *)buf);
40 }
41
42 void test_read_only_with_size (void)
43 {
44 read_only_with_size ((char *)buf, sizeof (buf));
45 }
46
47 void test_write_only_with_size (void)
48 {
49 write_only_with_size ((char *)buf, sizeof (buf)); /* { dg-warning "write to 'const' object 'buf'" } */
50 }
51
52 void test_read_write_with_size (void)
53 {
54 read_write_with_size ((char *)buf, sizeof (buf)); /* { dg-warning "write to 'const' object 'buf'" } */
55 }
56
57 void test_none_with_size (void)
58 {
59 none_with_size ((char *)buf, sizeof (buf));
60 }