]> git.pld-linux.org Git - packages/gcc.git/blob - gcc32-c++-tail-pad.patch
- updated patches, some cleanup :)
[packages/gcc.git] / gcc32-c++-tail-pad.patch
1 2002-08-22  Jason Merrill  <jason@redhat.com>
2
3         * langhooks-def.h (LANG_HOOKS_EXPR_SIZE): New macro.
4         * langhooks.c (lhd_expr_size): Define default.
5         * langhooks.h (struct lang_hooks): Add expr_size.
6         * explow.c (expr_size): Call it.
7         (int_expr_size): New fn.
8         * expr.h: Declare it.
9         * expr.c (expand_expr) [CONSTRUCTOR]: Use it to calculate how
10         much to store.
11 cp/
12         PR c++/5607
13         * search.c (check_final_overrider): No longer static.
14         * class.c (update_vtable_entry_for_fn): Call it.
15         * cp-tree.h: Adjust.
16
17         * cp-lang.c (LANG_HOOKS_EXPR_SIZE): Define.
18         (cp_expr_size): New fn.
19         * call.c (convert_arg_to_ellipsis): Promote non-POD warning to error.
20         * typeck.c (build_modify_expr): Don't use save_expr on an lvalue.
21
22 --- gcc/cp/call.c.jj    2002-04-15 14:48:51.000000000 +0200
23 +++ gcc/cp/call.c       2002-08-23 13:51:08.000000000 +0200
24 @@ -4022,9 +4022,12 @@ convert_arg_to_ellipsis (arg)
25    
26    if (arg != error_mark_node && ! pod_type_p (TREE_TYPE (arg)))
27      {
28 -      /* Undefined behaviour [expr.call] 5.2.2/7.  */
29 -      warning ("cannot pass objects of non-POD type `%#T' through `...'",
30 -                 TREE_TYPE (arg));
31 +      /* Undefined behaviour [expr.call] 5.2.2/7.  We used to just warn
32 +        here and do a bitwise copy, but now cp_expr_size will abort if we
33 +        try to do that.  */
34 +      error ("cannot pass objects of non-POD type `%#T' through `...'",
35 +            TREE_TYPE (arg));
36 +      arg = error_mark_node;
37      }
38  
39    return arg;
40 --- gcc/cp/class.c.jj   2002-08-05 18:30:31.000000000 +0200
41 +++ gcc/cp/class.c      2002-08-23 13:51:08.000000000 +0200
42 @@ -2454,6 +2454,10 @@ update_vtable_entry_for_fn (t, binfo, fn
43    if (overrider == error_mark_node)
44      return;
45  
46 +  /* Check for unsupported covariant returns again now that we've
47 +     calculated the base offsets.  */
48 +  check_final_overrider (TREE_PURPOSE (overrider), fn);
49 +
50    /* Assume that we will produce a thunk that convert all the way to
51       the final overrider, and not to an intermediate virtual base.  */
52    virtual_base = NULL_TREE;
53 --- gcc/cp/cp-lang.c.jj 2002-05-25 00:02:21.000000000 +0200
54 +++ gcc/cp/cp-lang.c    2002-08-23 13:51:08.000000000 +0200
55 @@ -28,7 +28,8 @@ Boston, MA 02111-1307, USA.  */
56  #include "langhooks.h"
57  #include "langhooks-def.h"
58  
59 -static HOST_WIDE_INT cxx_get_alias_set PARAMS ((tree));
60 +static HOST_WIDE_INT cxx_get_alias_set         PARAMS ((tree));
61 +static tree cp_expr_size                       PARAMS ((tree));
62  
63  #undef LANG_HOOKS_NAME
64  #define LANG_HOOKS_NAME "GNU C++"
65 @@ -91,6 +92,8 @@ static HOST_WIDE_INT cxx_get_alias_set P
66  #define LANG_HOOKS_TREE_DUMP_DUMP_TREE_FN cp_dump_tree
67  #undef LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN
68  #define LANG_HOOKS_TREE_DUMP_TYPE_QUALS_FN cp_type_quals
69 +#undef LANG_HOOKS_EXPR_SIZE
70 +#define LANG_HOOKS_EXPR_SIZE cp_expr_size
71  
72  /* Each front end provides its own hooks, for toplev.c.  */
73  const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
74 @@ -108,3 +111,28 @@ cxx_get_alias_set (t)
75  
76    return c_common_get_alias_set (t);
77  }
78 +
79 +/* Langhook for expr_size: Tell the backend that the value of an expression
80 +   of non-POD class type does not include any tail padding; a derived class
81 +   might have allocated something there.  */
82 +
83 +static tree
84 +cp_expr_size (exp)
85 +     tree exp;
86 +{
87 +  if (CLASS_TYPE_P (TREE_TYPE (exp)))
88 +    {
89 +      /* The backend should not be interested in the size of an expression
90 +        of a type with both of these set; all copies of such types must go
91 +        through a constructor or assignment op.  */
92 +      if (TYPE_HAS_COMPLEX_INIT_REF (TREE_TYPE (exp))
93 +         && TYPE_HAS_COMPLEX_ASSIGN_REF (TREE_TYPE (exp)))
94 +       abort ();
95 +      /* This would be wrong for a type with virtual bases, but they are
96 +        caught by the abort above.  */
97 +      return CLASSTYPE_SIZE_UNIT (TREE_TYPE (exp));
98 +    }
99 +  else
100 +    /* Use the default code.  */
101 +    return lhd_expr_size (exp);
102 +}
103 --- gcc/cp/cp-tree.h.jj 2002-07-27 01:31:05.000000000 +0200
104 +++ gcc/cp/cp-tree.h    2002-08-23 13:51:08.000000000 +0200
105 @@ -4084,6 +4084,7 @@ extern tree lookup_conversions                    PARAMS 
106  extern tree binfo_for_vtable                   PARAMS ((tree));
107  extern tree binfo_from_vbase                   PARAMS ((tree));
108  extern tree look_for_overrides_here            PARAMS ((tree, tree));
109 +extern int check_final_overrider               PARAMS ((tree, tree));
110  extern tree dfs_walk                            PARAMS ((tree,
111                                                        tree (*) (tree, void *),
112                                                        tree (*) (tree, void *),
113 --- gcc/cp/search.c.jj  2002-04-23 20:29:00.000000000 +0200
114 +++ gcc/cp/search.c     2002-08-23 13:51:08.000000000 +0200
115 @@ -100,7 +100,6 @@ static tree dfs_push_decls PARAMS ((tree
116  static tree dfs_unuse_fields PARAMS ((tree, void *));
117  static tree add_conversions PARAMS ((tree, void *));
118  static int covariant_return_p PARAMS ((tree, tree));
119 -static int check_final_overrider PARAMS ((tree, tree));
120  static int look_for_overrides_r PARAMS ((tree, tree));
121  static struct search_level *push_search_level
122         PARAMS ((struct stack_level *, struct obstack *));
123 @@ -1800,7 +1799,7 @@ covariant_return_p (brettype, drettype)
124  /* Check that virtual overrider OVERRIDER is acceptable for base function
125     BASEFN. Issue diagnostic, and return zero, if unacceptable.  */
126  
127 -static int
128 +int
129  check_final_overrider (overrider, basefn)
130       tree overrider, basefn;
131  {
132 --- gcc/cp/typeck.c.jj  2002-07-10 11:37:43.000000000 +0200
133 +++ gcc/cp/typeck.c     2002-08-23 13:51:08.000000000 +0200
134 @@ -5450,7 +5450,10 @@ build_modify_expr (lhs, modifycode, rhs)
135            so the code to compute it is only emitted once.  */
136         tree cond;
137  
138 -       rhs = save_expr (rhs);
139 +       if (lvalue_p (rhs))
140 +         rhs = stabilize_reference (rhs);
141 +       else
142 +         rhs = save_expr (rhs);
143         
144         /* Check this here to avoid odd errors when trying to convert
145            a throw to the type of the COND_EXPR.  */
146 --- gcc/expr.c.jj       2002-05-07 12:45:49.000000000 +0200
147 +++ gcc/expr.c  2002-08-23 13:51:09.000000000 +0200
148 @@ -6661,8 +6661,7 @@ expand_expr (exp, target, tmode, modifie
149                                                        * TYPE_QUAL_CONST))),
150                              0, TREE_ADDRESSABLE (exp), 1);
151  
152 -         store_constructor (exp, target, 0,
153 -                            int_size_in_bytes (TREE_TYPE (exp)));
154 +         store_constructor (exp, target, 0, int_expr_size (exp));
155           return target;
156         }
157  
158 --- gcc/explow.c.jj     2002-02-22 11:32:03.000000000 +0100
159 +++ gcc/explow.c        2002-08-23 13:51:08.000000000 +0200
160 @@ -34,6 +34,7 @@ Software Foundation, 59 Temple Place - S
161  #include "insn-config.h"
162  #include "ggc.h"
163  #include "recog.h"
164 +#include "langhooks.h"
165  
166  static rtx break_out_memory_refs       PARAMS ((rtx));
167  static void emit_stack_probe           PARAMS ((rtx));
168 @@ -285,20 +286,33 @@ rtx
169  expr_size (exp)
170       tree exp;
171  {
172 -  tree size;
173 -
174 -  if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd'
175 -      && DECL_SIZE_UNIT (exp) != 0)
176 -    size = DECL_SIZE_UNIT (exp);
177 -  else
178 -    size = size_in_bytes (TREE_TYPE (exp));
179 +  tree size = (*lang_hooks.expr_size) (exp);
180  
181    if (TREE_CODE (size) != INTEGER_CST
182        && contains_placeholder_p (size))
183      size = build (WITH_RECORD_EXPR, sizetype, size, exp);
184  
185    return expand_expr (size, NULL_RTX, TYPE_MODE (sizetype), 0);
186 +}
187 +
188 +/* Return a wide integer for the size in bytes of the value of EXP, or -1
189 +   if the size can vary or is larger than an integer.  */
190 +
191 +HOST_WIDE_INT
192 +int_expr_size (exp)
193 +     tree exp;
194 +{
195 +  tree t = (*lang_hooks.expr_size) (exp);
196 +
197 +  if (t == 0
198 +      || TREE_CODE (t) != INTEGER_CST
199 +      || TREE_OVERFLOW (t)
200 +      || TREE_INT_CST_HIGH (t) != 0
201 +      /* If the result would appear negative, it's too big to represent.  */
202 +      || (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0)
203 +    return -1;
204  
205 +  return TREE_INT_CST_LOW (t);
206  }
207  \f
208  /* Return a copy of X in which all memory references
209 --- gcc/expr.h.jj       2002-04-02 23:17:24.000000000 +0200
210 +++ gcc/expr.h  2002-08-23 13:51:09.000000000 +0200
211 @@ -548,6 +548,10 @@ extern unsigned int case_values_threshol
212  /* Return an rtx for the size in bytes of the value of an expr.  */
213  extern rtx expr_size PARAMS ((tree));
214  
215 +/* Return a wide integer for the size in bytes of the value of EXP, or -1
216 +   if the size can vary or is larger than an integer.  */
217 +extern HOST_WIDE_INT int_expr_size PARAMS ((tree));
218 +
219  extern rtx lookup_static_chain PARAMS ((tree));
220  
221  /* Convert a stack slot address ADDR valid in function FNDECL
222 --- gcc/langhooks-def.h.jj      2002-05-24 23:55:54.000000000 +0200
223 +++ gcc/langhooks-def.h 2002-08-23 13:51:09.000000000 +0200
224 @@ -48,6 +48,7 @@ extern int lhd_staticp PARAMS ((tree));
225  extern void lhd_clear_binding_stack PARAMS ((void));
226  extern void lhd_print_tree_nothing PARAMS ((FILE *, tree, int));
227  extern void lhd_set_yydebug PARAMS ((int));
228 +extern tree lhd_expr_size PARAMS ((tree));
229  
230  /* Declarations of default tree inlining hooks.  */
231  tree lhd_tree_inlining_walk_subtrees           PARAMS ((tree *, int *,
232 @@ -85,6 +86,7 @@ tree lhd_tree_inlining_convert_parm_for_
233  #define LANG_HOOKS_PRINT_TYPE          lhd_print_tree_nothing
234  #define LANG_HOOKS_PRINT_IDENTIFIER    lhd_print_tree_nothing
235  #define LANG_HOOKS_SET_YYDEBUG         lhd_set_yydebug
236 +#define LANG_HOOKS_EXPR_SIZE           lhd_expr_size
237  
238  /* Tree inlining hooks.  */
239  #define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES lhd_tree_inlining_walk_subtrees
240 @@ -156,6 +158,7 @@ int lhd_tree_dump_type_quals                        PARAMS ((
241    LANG_HOOKS_PRINT_TYPE, \
242    LANG_HOOKS_PRINT_IDENTIFIER, \
243    LANG_HOOKS_SET_YYDEBUG, \
244 +  LANG_HOOKS_EXPR_SIZE, \
245    LANG_HOOKS_TREE_INLINING_INITIALIZER, \
246    LANG_HOOKS_TREE_DUMP_INITIALIZER \
247  }
248 --- gcc/langhooks.c.jj  2002-03-23 12:02:51.000000000 +0100
249 +++ gcc/langhooks.c     2002-08-23 13:51:09.000000000 +0200
250 @@ -303,3 +303,16 @@ lhd_tree_dump_type_quals (t)
251    return TYPE_QUALS (t);
252  }
253  
254 +/* lang_hooks.expr_size: Determine the size of the value of an expression T
255 +   in a language-specific way.  Returns a tree for the size in bytes.  */
256 +
257 +tree
258 +lhd_expr_size (exp)
259 +     tree exp;
260 +{
261 +  if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'd'
262 +      && DECL_SIZE_UNIT (exp) != 0)
263 +    return DECL_SIZE_UNIT (exp);
264 +  else
265 +    return size_in_bytes (TREE_TYPE (exp));
266 +}
267 --- gcc/langhooks.h.jj  2002-05-24 23:55:54.000000000 +0200
268 +++ gcc/langhooks.h     2002-08-23 13:51:09.000000000 +0200
269 @@ -156,6 +156,12 @@ struct lang_hooks
270       warning that the front end does not use such a parser.  */
271    void (*set_yydebug) PARAMS ((int));
272  
273 +  /* Called from expr_size to calculate the size of the value of an
274 +     expression in a language-dependent way.  Returns a tree for the size
275 +     in bytes.  A frontend can call lhd_expr_size to get the default
276 +     semantics in cases that it doesn't want to handle specially.  */
277 +  tree (*expr_size) PARAMS ((tree));
278 +
279    struct lang_hooks_for_tree_inlining tree_inlining;
280    
281    struct lang_hooks_for_tree_dump tree_dump;
This page took 0.074602 seconds and 3 git commands to generate.