blob: 092500e066fd7ddb66bb70b9bf28704216c3a7c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#include <string.h>
/* PR analyzer/95007. */
void test_1 (void)
{
char *s = "foo";
s[0] = 'g'; /* { dg-warning "write to string literal" } */
}
/* PR c/83347. */
void test_2 (void)
{
memcpy ("abc", "def", 3); /* { dg-warning "write to string literal" } */
}
static char * __attribute__((noinline))
called_by_test_3 (void)
{
return (char *)"foo";
}
void test_3 (void)
{
char *s = called_by_test_3 ();
s[1] = 'a'; /* { dg-warning "write to string literal" } */
}
static char * __attribute__((noinline))
called_by_test_4 (int flag)
{
if (flag)
return (char *)"foo";
else
return (char *)"bar";
}
void test_4 (void)
{
char *s = called_by_test_4 (0);
s[1] = 'z'; /* { dg-warning "write to string literal" } */
}
static char * __attribute__((noinline))
called_by_test_5 (int flag)
{
if (flag)
return (char *)"foo";
else
return (char *)"bar";
}
void test_5 (int flag)
{
char *s = called_by_test_5 (flag);
s[1] = 'z'; /* We miss this one, unless we disable state merging. */
}
|