Allow returning something of type void in a function that returns void
[delight/core.git] / patches / patch-apple-gcc-5465
blob8eb67844b80a0ecc7170199d5f460de6a51561fc
1 diff -cr gcc-orig/cgraph.c gcc/cgraph.c
2 *** gcc-orig/cgraph.c   Sat Apr  9 02:13:35 2005
3 --- gcc/cgraph.c        Sat Dec 15 09:54:04 2007
4 ***************
5 *** 172,177 ****
6 --- 172,178 ----
7   cgraph_node (tree decl)
8   {
9     struct cgraph_node key, *node, **slot;
10 +   tree context;
11   
12     gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
13   
14 ***************
15 *** 188,198 ****
16     node = cgraph_create_node ();
17     node->decl = decl;
18     *slot = node;
19 !   if (DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
20       {
21 !       node->origin = cgraph_node (DECL_CONTEXT (decl));
22 !       node->next_nested = node->origin->nested;
23 !       node->origin->nested = node;
24       }
25     return node;
26   }
27 --- 189,203 ----
28     node = cgraph_create_node ();
29     node->decl = decl;
30     *slot = node;
31 !   if (!DECL_NO_STATIC_CHAIN (decl))
32       {
33 !       context = decl_function_context (decl);
34 !       if (context)
35 !         {
36 !           node->origin = cgraph_node (context);
37 !           node->next_nested = node->origin->nested;
38 !           node->origin->nested = node;
39 !         }
40       }
41     return node;
42   }
43 diff -cr gcc-orig/config/i386/i386.c gcc/config/i386/i386.c
44 *** gcc-orig/config/i386/i386.c Wed May 16 19:52:55 2007
45 --- gcc/config/i386/i386.c      Sat Dec 15 09:54:04 2007
46 ***************
47 *** 5202,5207 ****
48 --- 5202,5212 ----
49       frame->red_zone_size = 0;
50     frame->to_allocate -= frame->red_zone_size;
51     frame->stack_pointer_offset -= frame->red_zone_size;
52
53 +   if (cfun->naked)
54 +       /* As above, skip return address */
55 +       frame->stack_pointer_offset = UNITS_PER_WORD;
56
57   #if 0
58     fprintf (stderr, "nregs: %i\n", frame->nregs);
59     fprintf (stderr, "size: %i\n", size);
60 ***************
61 *** 18329,18335 ****
62           output_set_got (tmp, NULL_RTX);
63   
64           xops[1] = tmp;
65 !         output_asm_insn ("mov{l}\t{%0@GOT(%1), %1|%1, %0@GOT[%1]}", xops);
66           output_asm_insn ("jmp\t{*}%1", xops);
67         }
68       }
69 --- 18334,18340 ----
70           output_set_got (tmp, NULL_RTX);
71   
72           xops[1] = tmp;
73 !         output_asm_insn ("mov{l}\t{%a0@GOT(%1), %1|%1, %a0@GOT[%1]}", xops);
74           output_asm_insn ("jmp\t{*}%1", xops);
75         }
76       }
77 diff -cr gcc-orig/config/rs6000/rs6000.c gcc/config/rs6000/rs6000.c
78 *** gcc-orig/config/rs6000/rs6000.c     Thu Jul  5 18:26:15 2007
79 --- gcc/config/rs6000/rs6000.c  Sat Dec 15 09:54:04 2007
80 ***************
81 *** 17596,17602 ****
82          use language_string.
83          C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
84          Java is 13.  Objective-C is 14.  */
85 !       if (! strcmp (language_string, "GNU C"))
86         i = 0;
87         else if (! strcmp (language_string, "GNU F77")
88                || ! strcmp (language_string, "GNU F95"))
89 --- 17596,17603 ----
90          use language_string.
91          C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
92          Java is 13.  Objective-C is 14.  */
93 !       if (! strcmp (language_string, "GNU C") ||
94 !         ! strcmp (language_string, "GNU D"))
95         i = 0;
96         else if (! strcmp (language_string, "GNU F77")
97                || ! strcmp (language_string, "GNU F95"))
98 diff -cr gcc-orig/convert.c gcc/convert.c
99 *** gcc-orig/convert.c  Thu Nov  2 12:43:32 2006
100 --- gcc/convert.c       Sat Dec 15 09:54:04 2007
101 ***************
102 *** 30,39 ****
103 --- 30,41 ----
104   #include "tree.h"
105   #include "flags.h"
106   #include "convert.h"
107 + #if 0
108   /* APPLE LOCAL begin AltiVec */
109   #include "c-tree.h"
110   #include "c-common.h"
111   /* APPLE LOCAL end AltiVec */
112 + #endif
113   #include "toplev.h"
114   #include "langhooks.h"
115   #include "real.h"
116 ***************
117 *** 703,708 ****
118 --- 705,711 ----
119       }
120   }
121   
122 + #if 0
123   /* APPLE LOCAL begin AltiVec */
124   /* Build a COMPOUND_LITERAL_EXPR.  TYPE is the type given in the compound
125      literal.  INIT is a CONSTRUCTOR that initializes the compound literal.  */
126 ***************
127 *** 727,732 ****
128 --- 730,736 ----
129     return complit;
130   }
131   /* APPLE LOCAL end AltiVec */
132 + #endif
133   
134   /* Convert EXPR to the vector type TYPE in the usual ways.  */
135   
136 ***************
137 *** 742,747 ****
138 --- 746,752 ----
139           error ("can't convert between vector values of different size");
140           return error_mark_node;
141         }
142 + #if 0
143         /* APPLE LOCAL begin AltiVec */
144         if (TREE_CODE (type) == VECTOR_TYPE  
145           && TREE_CODE (TREE_TYPE (expr)) == VECTOR_TYPE
146 ***************
147 *** 749,754 ****
148 --- 754,760 ----
149           /* converting a constant vector to new vector type with Motorola Syntax. */
150           return convert (type, build_compound_literal_vector (TREE_TYPE (expr), expr));
151         /* APPLE LOCAL end AltiVec */
152 + #endif
153   
154         /* APPLE LOCAL mainline 4253848 */
155         return build1 (VIEW_CONVERT_EXPR, type, expr);
156 diff -cr gcc-orig/dwarf2out.c gcc/dwarf2out.c
157 *** gcc-orig/dwarf2out.c        Tue Mar 27 02:05:04 2007
158 --- gcc/dwarf2out.c     Sat Dec 15 09:54:04 2007
159 ***************
160 *** 5481,5487 ****
161   /* APPLE LOCAL begin mainline 2006-03-24 4485597 */
162     return (lang == DW_LANG_C || lang == DW_LANG_C89 || lang == DW_LANG_ObjC
163           || lang == DW_LANG_C99
164 !         || lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus);
165   /* APPLE LOCAL end mainline 2006-03-24 4485597 */
166   }
167   
168 --- 5481,5488 ----
169   /* APPLE LOCAL begin mainline 2006-03-24 4485597 */
170     return (lang == DW_LANG_C || lang == DW_LANG_C89 || lang == DW_LANG_ObjC
171           || lang == DW_LANG_C99
172 !         || lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus
173 !         || lang == DW_LANG_D);
174   /* APPLE LOCAL end mainline 2006-03-24 4485597 */
175   }
176   
177 ***************
178 *** 12531,12536 ****
179 --- 12532,12539 ----
180     else if (strcmp (language_string, "GNU Objective-C++") == 0)
181       language = DW_LANG_ObjC_plus_plus;
182   /* APPLE LOCAL end mainline 2006-03-24 4485597 */
183 +   else if (strcmp (language_string, "GNU D") == 0)
184 +     language = DW_LANG_D;
185     else
186       language = DW_LANG_C89;
187   
188 diff -cr gcc-orig/expr.c gcc/expr.c
189 *** gcc-orig/expr.c     Tue Jul  3 15:11:00 2007
190 --- gcc/expr.c  Sat Dec 15 09:54:04 2007
191 ***************
192 *** 8338,8343 ****
193 --- 8338,8348 ----
194         /* Lowered by gimplify.c.  */
195         gcc_unreachable ();
196   
197 +     case STATIC_CHAIN_EXPR:
198 +     case STATIC_CHAIN_DECL:
199 +       /* Lowered by tree-nested.c */
200 +       gcc_unreachable ();
202       case EXC_PTR_EXPR:
203         return get_exception_pointer (cfun);
204   
205 diff -cr gcc-orig/function.c gcc/function.c
206 *** gcc-orig/function.c Tue Jun 19 12:30:52 2007
207 --- gcc/function.c      Sat Dec 15 09:54:04 2007
208 ***************
209 *** 3149,3155 ****
210             FUNCTION_ARG_ADVANCE (all.args_so_far, data.promoted_mode,
211                                 data.passed_type, data.named_arg);
212   
213 !           assign_parm_adjust_stack_rtl (&data);
214   
215             if (assign_parm_setup_block_p (&data))
216             assign_parm_setup_block (&all, parm, &data);
217 --- 3149,3156 ----
218             FUNCTION_ARG_ADVANCE (all.args_so_far, data.promoted_mode,
219                                 data.passed_type, data.named_arg);
220   
221 !         if (!cfun->naked)
222 !           assign_parm_adjust_stack_rtl (&data);
223   
224             if (assign_parm_setup_block_p (&data))
225             assign_parm_setup_block (&all, parm, &data);
226 ***************
227 *** 3166,3172 ****
228   
229     /* Output all parameter conversion instructions (possibly including calls)
230        now that all parameters have been copied out of hard registers.  */
231 !   emit_insn (all.conversion_insns);
232   
233     /* If we are receiving a struct value address as the first argument, set up
234        the RTL for the function result. As this might require code to convert
235 --- 3167,3174 ----
236   
237     /* Output all parameter conversion instructions (possibly including calls)
238        now that all parameters have been copied out of hard registers.  */
239 !   if (!cfun->naked)
240 !     emit_insn (all.conversion_insns);
241   
242     /* If we are receiving a struct value address as the first argument, set up
243        the RTL for the function result. As this might require code to convert
244 ***************
245 *** 3306,3311 ****
246 --- 3308,3316 ----
247     struct assign_parm_data_all all;
248     tree fnargs, parm, stmts = NULL;
249   
250 +   if (cfun->naked)
251 +     return NULL;
253     assign_parms_initialize_all (&all);
254     fnargs = assign_parms_augmented_arg_list (&all);
255   
256 ***************
257 *** 4331,4341 ****
258         tree parm = cfun->static_chain_decl;
259         rtx local = gen_reg_rtx (Pmode);
260   
261 -       set_decl_incoming_rtl (parm, static_chain_incoming_rtx);
262         SET_DECL_RTL (parm, local);
263         mark_reg_pointer (local, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm))));
264   
265 !       emit_move_insn (local, static_chain_incoming_rtx);
266       }
267   
268     /* If the function receives a non-local goto, then store the
269 --- 4336,4350 ----
270         tree parm = cfun->static_chain_decl;
271         rtx local = gen_reg_rtx (Pmode);
272   
273         SET_DECL_RTL (parm, local);
274         mark_reg_pointer (local, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm))));
275   
276 !       if (! cfun->custom_static_chain)
277 !         {
278 !           set_decl_incoming_rtl (parm, static_chain_incoming_rtx);
279 !           emit_move_insn (local, static_chain_incoming_rtx);
280 !       }
281 !       /* else, the static chain will be set in the main body */
282       }
283   
284     /* If the function receives a non-local goto, then store the
285 ***************
286 *** 5250,5255 ****
287 --- 5259,5267 ----
288   #endif
289     edge_iterator ei;
290   
291 +   if (cfun->naked)
292 +       return;
294   #ifdef HAVE_prologue
295     if (HAVE_prologue)
296       {
297 diff -cr gcc-orig/function.h gcc/function.h
298 *** gcc-orig/function.h Wed Jun 27 17:23:44 2007
299 --- gcc/function.h      Sat Dec 15 10:19:28 2007
300 ***************
301 *** 464,469 ****
302 --- 464,477 ----
303     unsigned int calls_builtin_ret_addr : 1;
304     unsigned int calls_builtin_frame_addr : 1;
305     /* APPLE LOCAL end ARM reliable backtraces */
307 +   /* Nonzero if static chain is initialized by something other than
308 +      static_chain_incoming_rtx. */
309 +   unsigned int custom_static_chain : 1;
311 +   /* Nonzero if no code should be generated for prologues, copying
312 +      parameters, etc. */
313 +   unsigned int naked : 1;
314   };
315   
316   /* The function currently being compiled.  */
317 diff -cr gcc-orig/gcc.c gcc/gcc.c
318 *** gcc-orig/gcc.c      Thu Jun 28 13:01:41 2007
319 --- gcc/gcc.c   Sat Dec 15 09:54:05 2007
320 ***************
321 *** 134,139 ****
322 --- 134,142 ----
323   /* Flag set by cppspec.c to 1.  */
324   int is_cpp_driver;
325   
326 + /* Flag set by drivers needing Pthreads. */
327 + int need_pthreads;
329   /* Flag saying to pass the greatest exit code returned by a sub-process
330      to the calling program.  */
331   static int pass_exit_codes;
332 ***************
333 *** 487,492 ****
334 --- 490,496 ----
335         assembler has done its job.
336    %D   Dump out a -L option for each directory in startfile_prefixes.
337         If multilib_dir is set, extra entries are generated with it affixed.
338 +  %N     Output the currently selected multilib directory name.
339    %l     process LINK_SPEC as a spec.
340    %L     process LIB_SPEC as a spec.
341    %G     process LIBGCC_SPEC as a spec.
342 ***************
343 *** 917,922 ****
344 --- 921,928 ----
345   #endif
346   #endif
347   
348 + #define GCC_SPEC_FORMAT_4 1
350   /* Record the mapping from file suffixes for compilation specs.  */
351   
352   struct compiler
353 ***************
354 *** 3975,3980 ****
355 --- 3981,3989 ----
356         }
357       }
358   
359 +   if (need_pthreads)
360 +       n_switches++;
362     if ((save_temps_flag || report_times) && use_pipes)
363       {
364         /* -save-temps overrides -pipe, so that temp files are produced */
365 ***************
366 *** 4359,4364 ****
367 --- 4368,4385 ----
368         }
369       }
370   
371 +   if (need_pthreads)
372 +     {
373 +       switches[n_switches].part1 = "pthread";
374 +       switches[n_switches].args = 0;
375 +       switches[n_switches].live_cond = SWITCH_OK;
376 +       /* Do not print an error if there is not expansion for -pthread. */
377 +       switches[n_switches].validated = 1;
378 +       switches[n_switches].ordering = 0;
380 +       n_switches++;
381 +     }
383     switches[n_switches].part1 = 0;
384     infiles[n_infiles].name = 0;
385   }
386 ***************
387 *** 5448,5453 ****
388 --- 5469,5485 ----
389               return value;
390             break;
391   
392 +         case 'N':
393 +           if (multilib_dir)
394 +             {
395 +               arg_going = 1;
396 +               obstack_grow (&obstack, "-fmultilib-dir=",
397 +                             strlen ("-fmultilib-dir="));
398 +               obstack_grow (&obstack, multilib_dir,
399 +                             strlen (multilib_dir));
400 +             }
401 +           break;
403             /* Here we define characters other than letters and digits.  */
404   
405           case '{':
406 diff -cr gcc-orig/gcc.h gcc/gcc.h
407 *** gcc-orig/gcc.h      Fri Mar  4 15:17:11 2005
408 --- gcc/gcc.h   Sat Dec 15 09:54:05 2007
409 ***************
410 *** 40,46 ****
411      || (CHAR) == 'L' || (CHAR) == 'A' || (CHAR) == 'V' \
412      /* APPLE LOCAL frameworks */ \
413      || (CHAR) == 'F' \
414 !    || (CHAR) == 'B' || (CHAR) == 'b')
415   
416   /* This defines which multi-letter switches take arguments.  */
417   
418 --- 40,46 ----
419      || (CHAR) == 'L' || (CHAR) == 'A' || (CHAR) == 'V' \
420      /* APPLE LOCAL frameworks */ \
421      || (CHAR) == 'F' \
422 !    || (CHAR) == 'B' || (CHAR) == 'b' || (CHAR) == 'J')
423   
424   /* This defines which multi-letter switches take arguments.  */
425   
426 diff -cr gcc-orig/gimplify.c gcc/gimplify.c
427 *** gcc-orig/gimplify.c Mon Jun 18 18:03:55 2007
428 --- gcc/gimplify.c      Sat Dec 15 09:54:05 2007
429 ***************
430 *** 3923,3928 ****
431 --- 3923,3934 ----
432             }
433           break;
434   
435 +       case STATIC_CHAIN_EXPR:
436 +         /* The argument is used as information only.  No need to gimplify */
437 +       case STATIC_CHAIN_DECL:  
438 +         ret = GS_ALL_DONE;
439 +         break;
440 +         
441         case TREE_LIST:
442           gcc_unreachable ();
443   
444 diff -cr gcc-orig/tree-dump.c gcc/tree-dump.c
445 *** gcc-orig/tree-dump.c        Tue Feb 15 10:53:52 2005
446 --- gcc/tree-dump.c     Sat Dec 15 09:54:05 2007
447 ***************
448 *** 577,582 ****
449 --- 577,586 ----
450         dump_child ("args", TREE_OPERAND (t, 1));
451         break;
452   
453 +     case STATIC_CHAIN_EXPR:
454 +       dump_child ("func", TREE_OPERAND (t, 0));
455 +       break;
457       case CONSTRUCTOR:
458         dump_child ("elts", CONSTRUCTOR_ELTS (t));
459         break;
460 diff -cr gcc-orig/tree-gimple.c gcc/tree-gimple.c
461 *** gcc-orig/tree-gimple.c      Sat Jul  9 18:14:08 2005
462 --- gcc/tree-gimple.c   Sat Dec 15 09:54:05 2007
463 ***************
464 *** 73,78 ****
465 --- 73,80 ----
466       case COMPLEX_CST:
467       case VECTOR_CST:
468       case OBJ_TYPE_REF:
469 +     case STATIC_CHAIN_EXPR: /* not sure if this is right...*/
470 +     case STATIC_CHAIN_DECL:
471         return true;
472   
473       default:
474 ***************
475 *** 144,150 ****
476           || TREE_CODE (t) == WITH_SIZE_EXPR
477           /* These are complex lvalues, but don't have addresses, so they
478              go here.  */
479 !         || TREE_CODE (t) == BIT_FIELD_REF);
480   }
481   
482   /*  Return true if T is a GIMPLE condition.  */
483 --- 146,155 ----
484           || TREE_CODE (t) == WITH_SIZE_EXPR
485           /* These are complex lvalues, but don't have addresses, so they
486              go here.  */
487 !         || TREE_CODE (t) == BIT_FIELD_REF
488 !           /* This is an lvalue because it will be replaced with the real
489 !            static chain decl. */
490 !         || TREE_CODE (t) == STATIC_CHAIN_DECL);
491   }
492   
493   /*  Return true if T is a GIMPLE condition.  */
494 diff -cr gcc-orig/tree-inline.c gcc/tree-inline.c
495 *** gcc-orig/tree-inline.c      Thu Jun 28 19:17:08 2007
496 --- gcc/tree-inline.c   Sat Dec 15 09:54:05 2007
497 ***************
498 *** 559,565 ****
499       {
500         tree old_node = *tp;
501   
502 !       if (TREE_CODE (*tp) == MODIFY_EXPR
503           && TREE_OPERAND (*tp, 0) == TREE_OPERAND (*tp, 1)
504           && (lang_hooks.tree_inlining.auto_var_in_fn_p
505               (TREE_OPERAND (*tp, 0), fn)))
506 --- 559,576 ----
507       {
508         tree old_node = *tp;
509   
510 !       if (! id->cloning_p && ! id->saving_p &&
511 !         TREE_CODE (*tp) == MODIFY_EXPR &&
512 !         TREE_OPERAND (*tp, 0) ==
513 !         DECL_STRUCT_FUNCTION (fn)->static_chain_decl)
514 !       {
515 !         /* Don't use special methods to initialize the static chain
516 !            if expanding inline.  If this code could somehow be
517 !            expanded in expand_start_function, it would not be
518 !            necessary to deal with it here. */
519 !         *tp = build_empty_stmt ();
520 !       }
521 !       else if (TREE_CODE (*tp) == MODIFY_EXPR
522           && TREE_OPERAND (*tp, 0) == TREE_OPERAND (*tp, 1)
523           && (lang_hooks.tree_inlining.auto_var_in_fn_p
524               (TREE_OPERAND (*tp, 0), fn)))
525 diff -cr gcc-orig/tree-nested.c gcc/tree-nested.c
526 *** gcc-orig/tree-nested.c      Mon Aug  8 15:02:59 2005
527 --- gcc/tree-nested.c   Sat Dec 15 09:54:05 2007
528 ***************
529 *** 298,303 ****
530 --- 298,304 ----
531     if (!decl)
532       {
533         tree type;
534 +       enum tree_code code;
535   
536         type = get_frame_type (info->outer);
537         type = build_pointer_type (type);
538 ***************
539 *** 308,319 ****
540          Note also that it's represented as a parameter.  This is more
541          close to the truth, since the initial value does come from 
542          the caller.  */
543 !       decl = build_decl (PARM_DECL, create_tmp_var_name ("CHAIN"), type);
544         DECL_ARTIFICIAL (decl) = 1;
545         DECL_IGNORED_P (decl) = 1;
546         TREE_USED (decl) = 1;
547         DECL_CONTEXT (decl) = info->context;
548 !       DECL_ARG_TYPE (decl) = type;
549   
550         /* Tell tree-inline.c that we never write to this variable, so
551          it can copy-prop the replacement value immediately.  */
552 --- 309,325 ----
553          Note also that it's represented as a parameter.  This is more
554          close to the truth, since the initial value does come from 
555          the caller.  */
556 !       /* If the function has a custom static chain, a VAR_DECL is more
557 !        appropriate. */
558 !       code = DECL_STRUCT_FUNCTION (info->context)->custom_static_chain ?
559 !         VAR_DECL : PARM_DECL;
560 !       decl = build_decl (code, create_tmp_var_name ("CHAIN"), type);
561         DECL_ARTIFICIAL (decl) = 1;
562         DECL_IGNORED_P (decl) = 1;
563         TREE_USED (decl) = 1;
564         DECL_CONTEXT (decl) = info->context;
565 !       if (TREE_CODE (decl) == PARM_DECL)
566 !         DECL_ARG_TYPE (decl) = type;
567   
568         /* Tell tree-inline.c that we never write to this variable, so
569          it can copy-prop the replacement value immediately.  */
570 ***************
571 *** 717,722 ****
572 --- 723,730 ----
573   
574     if (info->context == target_context)
575       {
576 +       /* might be doing something wrong to need the following line.. */
577 +       get_frame_type (info);
578         x = build_addr (info->frame_decl);
579       }
580     else
581 ***************
582 *** 1195,1200 ****
583 --- 1203,1212 ----
584         if (DECL_NO_STATIC_CHAIN (decl))
585         break;
586   
587 +       /* Don't use a trampoline for a static reference. */
588 +       if (TREE_STATIC (t))
589 +       break;
591         /* Lookup the immediate parent of the callee, as that's where
592          we need to insert the trampoline.  */
593         for (i = info; i->context != target_context; i = i->outer)
594 ***************
595 *** 1259,1264 ****
596 --- 1271,1284 ----
597           = get_static_chain (info, target_context, &wi->tsi);
598         break;
599   
600 +     case STATIC_CHAIN_EXPR:
601 +       *tp = get_static_chain (info, TREE_OPERAND (t, 0), &wi->tsi);
602 +       break;
604 +     case STATIC_CHAIN_DECL:
605 +       *tp = get_chain_decl (info);
606 +       break;
607 +  
608       case RETURN_EXPR:
609       case MODIFY_EXPR:
610       case WITH_SIZE_EXPR:
611 ***************
612 *** 1360,1366 ****
613         tree x = build (COMPONENT_REF, TREE_TYPE (root->chain_field),
614                       root->frame_decl, root->chain_field, NULL_TREE);
615         x = build (MODIFY_EXPR, TREE_TYPE (x), x, get_chain_decl (root));
616 !       append_to_statement_list (x, &stmt_list);
617       }
618   
619     /* If trampolines were created, then we need to initialize them.  */
620 --- 1380,1407 ----
621         tree x = build (COMPONENT_REF, TREE_TYPE (root->chain_field),
622                       root->frame_decl, root->chain_field, NULL_TREE);
623         x = build (MODIFY_EXPR, TREE_TYPE (x), x, get_chain_decl (root));
624 !       /* If the function has a custom static chain, chain_field must
625 !        be set after the static chain. */
626 !       if (DECL_STRUCT_FUNCTION (root->context)->custom_static_chain)
627 !       {
628 !         /* Should use walk_function instead. */
629 !         tree_stmt_iterator i =
630 !             tsi_start ( BIND_EXPR_BODY (DECL_SAVED_TREE (context)));
631 !         while (!tsi_end_p (i))
632 !           {
633 !             tree t = tsi_stmt (i);
634 !             if (TREE_CODE (t) == MODIFY_EXPR &&
635 !                 TREE_OPERAND (t, 0) == root->chain_decl)
636 !               {
637 !                 tsi_link_after(& i, x, TSI_SAME_STMT);
638 !                 x = NULL_TREE;
639 !                 break;
640 !               }
641 !           }
642 !         gcc_assert(x == NULL_TREE);
643 !       }
644 !       else
645 !       append_to_statement_list (x, &stmt_list);
646       }
647   
648     /* If trampolines were created, then we need to initialize them.  */
649 diff -cr gcc-orig/tree-pretty-print.c gcc/tree-pretty-print.c
650 *** gcc-orig/tree-pretty-print.c        Thu Dec  9 05:54:50 2004
651 --- gcc/tree-pretty-print.c     Sat Dec 15 09:54:05 2007
652 ***************
653 *** 953,958 ****
654 --- 953,968 ----
655         pp_string (buffer, " [tail call]");
656         break;
657   
658 +     case STATIC_CHAIN_EXPR:
659 +       pp_string (buffer, "<<static chain of ");
660 +       dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
661 +       pp_string (buffer, ">>");
662 +       break;
664 +     case STATIC_CHAIN_DECL:
665 +        pp_string (buffer, "<<static chain decl>>");
666 +        break;
667 +       
668       case WITH_CLEANUP_EXPR:
669         NIY;
670         break;
671 diff -cr gcc-orig/tree-sra.c gcc/tree-sra.c
672 *** gcc-orig/tree-sra.c Sat May 19 00:56:18 2007
673 --- gcc-orig/tree-sra.c Fri Mar  7 13:43:03 2008
674 ***************
675 *** 206,211 ****
676 --- 206,213 ----
677       case RECORD_TYPE:
678         {
679         bool saw_one_field = false;
680 +       tree last_offset = size_zero_node;
681 +       tree cmp;
682   
683         for (t = TYPE_FIELDS (type); t ; t = TREE_CHAIN (t))
684           if (TREE_CODE (t) == FIELD_DECL)
685 ***************
686 *** 215,220 ****
687 --- 217,227 ----
688                   && (tree_low_cst (DECL_SIZE (t), 1)
689                       != TYPE_PRECISION (TREE_TYPE (t))))
690                 goto fail;
691 +             /* Reject aliased fields created by GDC for anonymous unions. */
692 +             cmp = fold_binary_to_constant (LE_EXPR, boolean_type_node,
693 +               DECL_FIELD_OFFSET (t), last_offset);
694 +             if (cmp == NULL_TREE || TREE_CODE (cmp) != INTEGER_CST || TREE_INT_CST_LOW (cmp))
695 +               goto fail;
696   
697               saw_one_field = true;
698             }
699 diff -cr gcc-orig/tree.def gcc/tree.def
700 *** gcc-orig/tree.def   Mon Oct  3 16:31:24 2005
701 --- gcc/tree.def        Sat Dec 15 09:54:05 2007
702 ***************
703 *** 528,533 ****
704 --- 528,540 ----
705      Operand 2 is the static chain argument, or NULL.  */
706   DEFTREECODE (CALL_EXPR, "call_expr", tcc_expression, 3)
707   
708 + /* Operand 0 is the FUNC_DECL of the outer function for
709 +    which the static chain is to be computed. */
710 + DEFTREECODE (STATIC_CHAIN_EXPR, "static_chain_expr", tcc_expression, 1)
711 +     
712 + /* Represents a function's static chain.  It can be used as an lvalue. */
713 + DEFTREECODE (STATIC_CHAIN_DECL, "static_chain_decl", tcc_expression, 0)
715   /* Specify a value to compute along with its corresponding cleanup.
716      Operand 0 is the cleanup expression.
717      The cleanup is executed by the first enclosing CLEANUP_POINT_EXPR,
718 ***************
719 *** 901,907 ****
720   
721   /* APPLE LOCAL begin AV vmul_uch --haifa  */
722   /* Used during vectorization to represent computation idioms.  */
723 ! DEFTREECODE (MULT_UCH_EXPR, "mult_uch", '2', 2)
724   /* APPLE LOCAL end AV vmul_uch --haifa  */
725   
726   /* Value handles.  Artificial nodes to represent expressions in
727 --- 908,914 ----
728   
729   /* APPLE LOCAL begin AV vmul_uch --haifa  */
730   /* Used during vectorization to represent computation idioms.  */
731 ! DEFTREECODE (MULT_UCH_EXPR, "mult_uch", tcc_binary, 2)
732   /* APPLE LOCAL end AV vmul_uch --haifa  */
733   
734   /* Value handles.  Artificial nodes to represent expressions in