diff options
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0357-PR-c-48657.patch')
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0357-PR-c-48657.patch | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0357-PR-c-48657.patch b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0357-PR-c-48657.patch new file mode 100644 index 0000000000..49a0763dbc --- /dev/null +++ b/meta/recipes-devtools/gcc/gcc-4.6.0/gcc-4_6-branch-backports/0357-PR-c-48657.patch | |||
@@ -0,0 +1,149 @@ | |||
1 | From 04ed2c7147286ab11c8ba25e486e3f726c4970d4 Mon Sep 17 00:00:00 2001 | ||
2 | From: jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | ||
3 | Date: Fri, 27 May 2011 18:10:48 +0000 | ||
4 | Subject: [PATCH] PR c++/48657 | ||
5 | PR c++/49176 | ||
6 | * decl.c (cp_finish_decl): Simplify template handling. | ||
7 | |||
8 | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@174346 138bc75d-0d04-0410-961f-82ee72b054a4 | ||
9 | |||
10 | index dac87dd..8395b2b 100644 | ||
11 | --- a/gcc/cp/decl.c | ||
12 | +++ b/gcc/cp/decl.c | ||
13 | @@ -5760,7 +5760,6 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, | ||
14 | const char *asmspec = NULL; | ||
15 | int was_readonly = 0; | ||
16 | bool var_definition_p = false; | ||
17 | - int saved_processing_template_decl; | ||
18 | tree auto_node; | ||
19 | |||
20 | if (decl == error_mark_node) | ||
21 | @@ -5782,7 +5781,6 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, | ||
22 | |||
23 | /* Assume no cleanup is required. */ | ||
24 | cleanup = NULL_TREE; | ||
25 | - saved_processing_template_decl = processing_template_decl; | ||
26 | |||
27 | /* If a name was specified, get the string. */ | ||
28 | if (global_scope_p (current_binding_level)) | ||
29 | @@ -5882,45 +5880,24 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, | ||
30 | template is instantiated. But, if DECL is a variable constant | ||
31 | then it can be used in future constant expressions, so its value | ||
32 | must be available. */ | ||
33 | - if (!(init | ||
34 | - && init_const_expr_p | ||
35 | - && !type_dependent_p | ||
36 | - && decl_maybe_constant_var_p (decl) | ||
37 | - && !value_dependent_init_p (init))) | ||
38 | - { | ||
39 | - if (init) | ||
40 | - DECL_INITIAL (decl) = init; | ||
41 | - if (TREE_CODE (decl) == VAR_DECL | ||
42 | - && !DECL_PRETTY_FUNCTION_P (decl) | ||
43 | - && !type_dependent_p) | ||
44 | - maybe_deduce_size_from_array_init (decl, init); | ||
45 | - goto finish_end; | ||
46 | - } | ||
47 | - | ||
48 | - if (!DECL_CLASS_SCOPE_P (decl)) | ||
49 | + if (init | ||
50 | + && init_const_expr_p | ||
51 | + && !type_dependent_p | ||
52 | + && decl_maybe_constant_var_p (decl) | ||
53 | + && !value_dependent_init_p (init)) | ||
54 | { | ||
55 | tree init_code = check_initializer (decl, init, flags, &cleanup); | ||
56 | - if (init_code) | ||
57 | - DECL_INITIAL (decl) = init; | ||
58 | - goto finish_end; | ||
59 | + if (init_code == NULL_TREE) | ||
60 | + init = NULL_TREE; | ||
61 | } | ||
62 | + else if (TREE_CODE (decl) == VAR_DECL | ||
63 | + && !DECL_PRETTY_FUNCTION_P (decl) | ||
64 | + && !type_dependent_p) | ||
65 | + maybe_deduce_size_from_array_init (decl, init); | ||
66 | |||
67 | - if (TREE_CODE (init) == TREE_LIST) | ||
68 | - { | ||
69 | - /* If the parenthesized-initializer form was used (e.g., | ||
70 | - "int A<N>::i(X)"), then INIT will be a TREE_LIST of initializer | ||
71 | - arguments. (There is generally only one.) We convert them | ||
72 | - individually. */ | ||
73 | - tree list = init; | ||
74 | - for (; list; list = TREE_CHAIN (list)) | ||
75 | - { | ||
76 | - tree elt = TREE_VALUE (list); | ||
77 | - TREE_VALUE (list) = fold_non_dependent_expr (elt); | ||
78 | - } | ||
79 | - } | ||
80 | - else | ||
81 | - init = fold_non_dependent_expr (init); | ||
82 | - processing_template_decl = 0; | ||
83 | + if (init) | ||
84 | + DECL_INITIAL (decl) = init; | ||
85 | + return; | ||
86 | } | ||
87 | |||
88 | /* Take care of TYPE_DECLs up front. */ | ||
89 | @@ -5943,7 +5920,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, | ||
90 | |||
91 | rest_of_decl_compilation (decl, DECL_FILE_SCOPE_P (decl), | ||
92 | at_eof); | ||
93 | - goto finish_end; | ||
94 | + return; | ||
95 | } | ||
96 | |||
97 | /* A reference will be modified here, as it is initialized. */ | ||
98 | @@ -6067,8 +6044,7 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, | ||
99 | else if (TREE_CODE (type) == ARRAY_TYPE) | ||
100 | layout_type (type); | ||
101 | |||
102 | - if (!processing_template_decl | ||
103 | - && TREE_STATIC (decl) | ||
104 | + if (TREE_STATIC (decl) | ||
105 | && !at_function_scope_p () | ||
106 | && current_function_decl == NULL) | ||
107 | /* So decl is a global variable or a static member of a | ||
108 | @@ -6088,9 +6064,8 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, | ||
109 | |||
110 | /* Let the middle end know about variables and functions -- but not | ||
111 | static data members in uninstantiated class templates. */ | ||
112 | - if (!saved_processing_template_decl | ||
113 | - && (TREE_CODE (decl) == VAR_DECL | ||
114 | - || TREE_CODE (decl) == FUNCTION_DECL)) | ||
115 | + if (TREE_CODE (decl) == VAR_DECL | ||
116 | + || TREE_CODE (decl) == FUNCTION_DECL) | ||
117 | { | ||
118 | if (TREE_CODE (decl) == VAR_DECL) | ||
119 | { | ||
120 | @@ -6177,9 +6152,6 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p, | ||
121 | if (cleanup) | ||
122 | push_cleanup (decl, cleanup, false); | ||
123 | |||
124 | - finish_end: | ||
125 | - processing_template_decl = saved_processing_template_decl; | ||
126 | - | ||
127 | if (was_readonly) | ||
128 | TREE_READONLY (decl) = 1; | ||
129 | } | ||
130 | new file mode 100644 | ||
131 | index 0000000..5d3ec5b | ||
132 | --- /dev/null | ||
133 | +++ b/gcc/testsuite/g++.dg/template/const5.C | ||
134 | @@ -0,0 +1,12 @@ | ||
135 | +// PR c++/49176 | ||
136 | +// { dg-options -std=c++0x } | ||
137 | + | ||
138 | +struct A { static int a(); }; | ||
139 | + | ||
140 | +template<int> | ||
141 | +struct B { static int const b; }; | ||
142 | + | ||
143 | +int f() { return B<0>::b; } | ||
144 | + | ||
145 | +template<int I> | ||
146 | +int const B<I>::b=A::a(); | ||
147 | -- | ||
148 | 1.7.0.4 | ||
149 | |||