]>
Commit | Line | Data |
---|---|---|
d09ee599 PS |
1 | This fixes the PR by making sure we fold "foo"[0] to 'f' |
2 | during fold_indirect_ref. | |
3 | ||
4 | PR tree-optimization/24172 | |
5 | * fold-const.c (fold_indirect_ref_1): Make sure we fold | |
6 | ARRAY_REFs of constant strings. | |
7 | ||
8 | * g++.dg/tree-ssa/pr24172.C: New testcase. | |
9 | ||
10 | ||
11 | *** gcc/gcc/fold-const.c 26 Sep 2005 01:28:38 -0000 1.626 | |
12 | --- gcc/gcc/fold-const.c 4 Oct 2005 10:59:06 -0000 | |
13 | *************** fold_indirect_ref_1 (tree type, tree op0 | |
14 | *** 11511,11519 **** | |
15 | { | |
16 | tree op = TREE_OPERAND (sub, 0); | |
17 | tree optype = TREE_TYPE (op); | |
18 | ! /* *&p => p */ | |
19 | if (type == optype) | |
20 | ! return op; | |
21 | /* *(foo *)&fooarray => fooarray[0] */ | |
22 | else if (TREE_CODE (optype) == ARRAY_TYPE | |
23 | && type == TREE_TYPE (optype)) | |
24 | --- 11511,11525 ---- | |
25 | { | |
26 | tree op = TREE_OPERAND (sub, 0); | |
27 | tree optype = TREE_TYPE (op); | |
28 | ! /* *&p => p; make sure to handle *&"str"[cst] here. */ | |
29 | if (type == optype) | |
30 | ! { | |
31 | ! tree fop = fold_read_from_constant_string (op); | |
32 | ! if (fop) | |
33 | ! return fop; | |
34 | ! else | |
35 | ! return op; | |
36 | ! } | |
37 | /* *(foo *)&fooarray => fooarray[0] */ | |
38 | else if (TREE_CODE (optype) == ARRAY_TYPE | |
39 | && type == TREE_TYPE (optype)) |