summaryrefslogtreecommitdiffstats
path: root/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99308.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99308.patch')
-rw-r--r--recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99308.patch112
1 files changed, 112 insertions, 0 deletions
diff --git a/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99308.patch b/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99308.patch
new file mode 100644
index 0000000000..bf35a2ed4e
--- /dev/null
+++ b/recipes-devtools/gcc/gcc-4.5/linaro/gcc-4.5-linaro-r99308.patch
@@ -0,0 +1,112 @@
12010-07-15 Jie Zhang <jie@codesourcery.com>
2
3 Backport from mainline (originally from Sourcery G++ 4.4):
4
5 gcc/cp/
6 2010-04-07 Jie Zhang <jie@codesourcery.com>
7
8 PR c++/42556
9 * typeck2.c (split_nonconstant_init_1): Drop empty CONSTRUCTOR
10 when all of its elements are non-constant and have been split out.
11
12 gcc/testsuite/
13 2010-04-07 Jie Zhang <jie@codesourcery.com>
14
15 PR c++/42556
16 * g++.dg/init/pr42556.C: New test.
17
18 2010-07-12 Yao Qi <yao@codesourcery.com>
19
20 Merge from Sourcery G++ 4.4:
21
22=== modified file 'gcc/cp/typeck2.c'
23--- old/gcc/cp/typeck2.c 2010-02-23 18:32:20 +0000
24+++ new/gcc/cp/typeck2.c 2010-07-30 14:05:57 +0000
25@@ -549,13 +549,15 @@
26 expression to which INIT should be assigned. INIT is a CONSTRUCTOR. */
27
28 static void
29-split_nonconstant_init_1 (tree dest, tree init)
30+split_nonconstant_init_1 (tree dest, tree *initp)
31 {
32 unsigned HOST_WIDE_INT idx;
33+ tree init = *initp;
34 tree field_index, value;
35 tree type = TREE_TYPE (dest);
36 tree inner_type = NULL;
37 bool array_type_p = false;
38+ HOST_WIDE_INT num_type_elements, num_initialized_elements;
39
40 switch (TREE_CODE (type))
41 {
42@@ -567,6 +569,7 @@
43 case RECORD_TYPE:
44 case UNION_TYPE:
45 case QUAL_UNION_TYPE:
46+ num_initialized_elements = 0;
47 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (init), idx,
48 field_index, value)
49 {
50@@ -589,12 +592,13 @@
51 sub = build3 (COMPONENT_REF, inner_type, dest, field_index,
52 NULL_TREE);
53
54- split_nonconstant_init_1 (sub, value);
55+ split_nonconstant_init_1 (sub, &value);
56 }
57 else if (!initializer_constant_valid_p (value, inner_type))
58 {
59 tree code;
60 tree sub;
61+ HOST_WIDE_INT inner_elements;
62
63 /* FIXME: Ordered removal is O(1) so the whole function is
64 worst-case quadratic. This could be fixed using an aside
65@@ -617,9 +621,22 @@
66 code = build2 (INIT_EXPR, inner_type, sub, value);
67 code = build_stmt (input_location, EXPR_STMT, code);
68 add_stmt (code);
69+
70+ inner_elements = count_type_elements (inner_type, true);
71+ if (inner_elements < 0)
72+ num_initialized_elements = -1;
73+ else if (num_initialized_elements >= 0)
74+ num_initialized_elements += inner_elements;
75 continue;
76 }
77 }
78+
79+ num_type_elements = count_type_elements (type, true);
80+ /* If all elements of the initializer are non-constant and
81+ have been split out, we don't need the empty CONSTRUCTOR. */
82+ if (num_type_elements > 0
83+ && num_type_elements == num_initialized_elements)
84+ *initp = NULL;
85 break;
86
87 case VECTOR_TYPE:
88@@ -655,7 +672,7 @@
89 if (TREE_CODE (init) == CONSTRUCTOR)
90 {
91 code = push_stmt_list ();
92- split_nonconstant_init_1 (dest, init);
93+ split_nonconstant_init_1 (dest, &init);
94 code = pop_stmt_list (code);
95 DECL_INITIAL (dest) = init;
96 TREE_READONLY (dest) = 0;
97
98=== added file 'gcc/testsuite/g++.dg/init/pr42556.C'
99--- old/gcc/testsuite/g++.dg/init/pr42556.C 1970-01-01 00:00:00 +0000
100+++ new/gcc/testsuite/g++.dg/init/pr42556.C 2010-07-30 14:05:57 +0000
101@@ -0,0 +1,10 @@
102+// { dg-do compile }
103+// { dg-options "-fdump-tree-gimple" }
104+
105+void foo (int a, int b, int c, int d)
106+{
107+ int v[4] = {a, b, c, d};
108+}
109+
110+// { dg-final { scan-tree-dump-not "v = {}" "gimple" } }
111+// { dg-final { cleanup-tree-dump "gimple" } }
112