Allow implicit conversion "foo*?" to "void*"
[delight/core.git] / patches / patch-apple-gcc-4.0.x
blob1becfb65bf151f0d963638045fe345b8d46508da
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        Thu Jun 22 19:49:34 2006
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 Fri Apr 28 16:42:39 2006
45 --- gcc/config/i386/i386.c      Thu Jun 22 19:49:34 2006
46 ***************
47 *** 5049,5054 ****
48 --- 5049,5059 ----
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 *** 17396,17402 ****
62           output_set_got (tmp);
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 --- 17396,17402 ----
70           output_set_got (tmp);
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 Apr 27 21:06:13 2006
79 --- gcc/config/rs6000/rs6000.c  Thu Jun 22 19:49:35 2006
80 ***************
81 *** 17445,17451 ****
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 --- 17445,17452 ----
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  Wed Sep 21 19:20:36 2005
100 --- gcc/convert.c       Thu Jun 22 20:08:13 2006
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         return build1 (NOP_EXPR, type, expr);
155   
156 diff -cr gcc-orig/dwarf2out.c gcc/dwarf2out.c
157 *** gcc-orig/dwarf2out.c        Wed Apr 26 15:06:48 2006
158 --- gcc/dwarf2out.c     Thu Jun 22 20:01:30 2006
159 ***************
160 *** 5350,5356 ****
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 --- 5350,5357 ----
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 *** 12020,12025 ****
179 --- 12021,12028 ----
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     Fri Oct 28 14:47:00 2005
190 --- gcc/expr.c  Thu Jun 22 19:49:35 2006
191 ***************
192 *** 8264,8269 ****
193 --- 8264,8274 ----
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 Wed Apr 26 14:07:46 2006
207 --- gcc/function.c      Thu Jun 22 19:49:35 2006
208 ***************
209 *** 3130,3136 ****
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 --- 3130,3137 ----
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 *** 3147,3153 ****
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 --- 3148,3155 ----
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 *** 3287,3292 ****
246 --- 3289,3297 ----
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 *** 4219,4229 ****
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 --- 4224,4238 ----
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 *** 5132,5137 ****
287 --- 5141,5149 ----
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 Apr 26 14:07:46 2006
299 --- gcc/function.h      Thu Jun 22 19:51:26 2006
300 ***************
301 *** 452,457 ****
302 --- 452,465 ----
303     /* APPLE LOCAL begin 3837835  */
304     unsigned int uses_vector : 1;
305     /* APPLE LOCAL end 3837835  */
306 +  
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      Sat Jan 21 13:38:48 2006
319 --- gcc/gcc.c   Thu Mar  1 10:27:25 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 *** 483,488 ****
334 --- 486,492 ----
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 *** 900,905 ****
344 --- 904,911 ----
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 *** 3965,3970 ****
355 --- 3971,3979 ----
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 *** 4349,4354 ****
367 --- 4358,4375 ----
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 *** 5438,5443 ****
388 --- 5459,5475 ----
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.c gcc/gcc.h
407 *** gcc-orig/gcc.h  Fri Mar  4 15:17:11 2005
408 --- gcc/gcc.h  Sun Mar  4 13:36:10 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 Thu Aug 11 19:55:22 2005
428 --- gcc/gimplify.c      Thu Jun 22 19:49:35 2006
429 ***************
430 *** 3876,3881 ****
431 --- 3876,3887 ----
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/real.c gcc/real.c
445 *** gcc-orig/real.c     Tue Jan 25 15:21:59 2005
446 --- gcc/real.c  Thu Jun 22 19:49:35 2006
447 ***************
448 *** 2205,2210 ****
449 --- 2205,2212 ----
450     np2 = SIGNIFICAND_BITS - fmt->p * fmt->log2_b;
451     memset (r->sig, -1, SIGSZ * sizeof (unsigned long));
452     clear_significand_below (r, np2);
453 +   if (REAL_MODE_FORMAT_COMPOSITE_P (mode))
454 +       clear_significand_bit (r, SIGNIFICAND_BITS - fmt->pnan - 1);
455   }
456   
457   /* Fills R with 2**N.  */
458 diff -cr gcc-orig/tree-dump.c gcc/tree-dump.c
459 *** gcc-orig/tree-dump.c        Tue Feb 15 10:53:52 2005
460 --- gcc/tree-dump.c     Thu Jun 22 19:49:35 2006
461 ***************
462 *** 577,582 ****
463 --- 577,586 ----
464         dump_child ("args", TREE_OPERAND (t, 1));
465         break;
466   
467 +     case STATIC_CHAIN_EXPR:
468 +       dump_child ("func", TREE_OPERAND (t, 0));
469 +       break;
471       case CONSTRUCTOR:
472         dump_child ("elts", CONSTRUCTOR_ELTS (t));
473         break;
474 diff -cr gcc-orig/tree-gimple.c gcc/tree-gimple.c
475 *** gcc-orig/tree-gimple.c      Sat Jul  9 18:14:08 2005
476 --- gcc/tree-gimple.c   Thu Jun 22 19:49:35 2006
477 ***************
478 *** 73,78 ****
479 --- 73,80 ----
480       case COMPLEX_CST:
481       case VECTOR_CST:
482       case OBJ_TYPE_REF:
483 +     case STATIC_CHAIN_EXPR: /* not sure if this is right...*/
484 +     case STATIC_CHAIN_DECL:
485         return true;
486   
487       default:
488 ***************
489 *** 144,150 ****
490           || TREE_CODE (t) == WITH_SIZE_EXPR
491           /* These are complex lvalues, but don't have addresses, so they
492              go here.  */
493 !         || TREE_CODE (t) == BIT_FIELD_REF);
494   }
495   
496   /*  Return true if T is a GIMPLE condition.  */
497 --- 146,155 ----
498           || TREE_CODE (t) == WITH_SIZE_EXPR
499           /* These are complex lvalues, but don't have addresses, so they
500              go here.  */
501 !         || TREE_CODE (t) == BIT_FIELD_REF
502 !           /* This is an lvalue because it will be replaced with the real
503 !            static chain decl. */
504 !         || TREE_CODE (t) == STATIC_CHAIN_DECL);
505   }
506   
507   /*  Return true if T is a GIMPLE condition.  */
508 diff -cr gcc-orig/tree-inline.c gcc/tree-inline.c
509 *** gcc-orig/tree-inline.c      Wed Apr 26 14:07:46 2006
510 --- gcc/tree-inline.c   Thu Jun 22 19:49:35 2006
511 ***************
512 *** 552,558 ****
513       {
514         tree old_node = *tp;
515   
516 !       if (TREE_CODE (*tp) == MODIFY_EXPR
517           && TREE_OPERAND (*tp, 0) == TREE_OPERAND (*tp, 1)
518           && (lang_hooks.tree_inlining.auto_var_in_fn_p
519               (TREE_OPERAND (*tp, 0), fn)))
520 --- 552,569 ----
521       {
522         tree old_node = *tp;
523   
524 !       if (! id->cloning_p && ! id->saving_p &&
525 !         TREE_CODE (*tp) == MODIFY_EXPR &&
526 !         TREE_OPERAND (*tp, 0) ==
527 !         DECL_STRUCT_FUNCTION (fn)->static_chain_decl)
528 !       {
529 !         /* Don't use special methods to initialize the static chain
530 !            if expanding inline.  If this code could somehow be
531 !            expanded in expand_start_function, it would not be
532 !            necessary to deal with it here. */
533 !         *tp = build_empty_stmt ();
534 !       }
535 !       else if (TREE_CODE (*tp) == MODIFY_EXPR
536           && TREE_OPERAND (*tp, 0) == TREE_OPERAND (*tp, 1)
537           && (lang_hooks.tree_inlining.auto_var_in_fn_p
538               (TREE_OPERAND (*tp, 0), fn)))
539 diff -cr gcc-orig/tree-nested.c gcc/tree-nested.c
540 *** gcc-orig/tree-nested.c      Mon Aug  8 15:02:59 2005
541 --- gcc/tree-nested.c   Thu Jun 22 19:49:35 2006
542 ***************
543 *** 298,303 ****
544 --- 298,304 ----
545     if (!decl)
546       {
547         tree type;
548 +       enum tree_code code;
549   
550         type = get_frame_type (info->outer);
551         type = build_pointer_type (type);
552 ***************
553 *** 308,319 ****
554          Note also that it's represented as a parameter.  This is more
555          close to the truth, since the initial value does come from 
556          the caller.  */
557 !       decl = build_decl (PARM_DECL, create_tmp_var_name ("CHAIN"), type);
558         DECL_ARTIFICIAL (decl) = 1;
559         DECL_IGNORED_P (decl) = 1;
560         TREE_USED (decl) = 1;
561         DECL_CONTEXT (decl) = info->context;
562 !       DECL_ARG_TYPE (decl) = type;
563   
564         /* Tell tree-inline.c that we never write to this variable, so
565          it can copy-prop the replacement value immediately.  */
566 --- 309,325 ----
567          Note also that it's represented as a parameter.  This is more
568          close to the truth, since the initial value does come from 
569          the caller.  */
570 !       /* If the function has a custom static chain, a VAR_DECL is more
571 !        appropriate. */
572 !       code = DECL_STRUCT_FUNCTION (info->context)->custom_static_chain ?
573 !         VAR_DECL : PARM_DECL;
574 !       decl = build_decl (code, create_tmp_var_name ("CHAIN"), type);
575         DECL_ARTIFICIAL (decl) = 1;
576         DECL_IGNORED_P (decl) = 1;
577         TREE_USED (decl) = 1;
578         DECL_CONTEXT (decl) = info->context;
579 !       if (TREE_CODE (decl) == PARM_DECL)
580 !         DECL_ARG_TYPE (decl) = type;
581   
582         /* Tell tree-inline.c that we never write to this variable, so
583          it can copy-prop the replacement value immediately.  */
584 ***************
585 *** 717,722 ****
586 --- 723,730 ----
587   
588     if (info->context == target_context)
589       {
590 +       /* might be doing something wrong to need the following line.. */
591 +       get_frame_type (info);
592         x = build_addr (info->frame_decl);
593       }
594     else
595 ***************
596 *** 1195,1200 ****
597 --- 1203,1212 ----
598         if (DECL_NO_STATIC_CHAIN (decl))
599         break;
600   
601 +       /* Don't use a trampoline for a static reference. */
602 +       if (TREE_STATIC (t))
603 +       break;
605         /* Lookup the immediate parent of the callee, as that's where
606          we need to insert the trampoline.  */
607         for (i = info; i->context != target_context; i = i->outer)
608 ***************
609 *** 1259,1264 ****
610 --- 1271,1284 ----
611           = get_static_chain (info, target_context, &wi->tsi);
612         break;
613   
614 +     case STATIC_CHAIN_EXPR:
615 +       *tp = get_static_chain (info, TREE_OPERAND (t, 0), &wi->tsi);
616 +       break;
618 +     case STATIC_CHAIN_DECL:
619 +       *tp = get_chain_decl (info);
620 +       break;
621 +  
622       case RETURN_EXPR:
623       case MODIFY_EXPR:
624       case WITH_SIZE_EXPR:
625 ***************
626 *** 1360,1366 ****
627         tree x = build (COMPONENT_REF, TREE_TYPE (root->chain_field),
628                       root->frame_decl, root->chain_field, NULL_TREE);
629         x = build (MODIFY_EXPR, TREE_TYPE (x), x, get_chain_decl (root));
630 !       append_to_statement_list (x, &stmt_list);
631       }
632   
633     /* If trampolines were created, then we need to initialize them.  */
634 --- 1380,1408 ----
635         tree x = build (COMPONENT_REF, TREE_TYPE (root->chain_field),
636                       root->frame_decl, root->chain_field, NULL_TREE);
637         x = build (MODIFY_EXPR, TREE_TYPE (x), x, get_chain_decl (root));
638 !       /* If the function has a custom static chain, chain_field must
639 !        be set after the static chain. */
640 !       if (DECL_STRUCT_FUNCTION (root->context)->custom_static_chain)
641 !       {
642 !         /* Should use walk_function instead. */
643 !         tree_stmt_iterator i =
644 !             tsi_start ( BIND_EXPR_BODY (DECL_SAVED_TREE (context)));
645 !         while (!tsi_end_p (i))
646 !           {
647 !             tree t = tsi_stmt (i);
648 !             if (TREE_CODE (t) == MODIFY_EXPR &&
649 !                 TREE_OPERAND (t, 0) == root->chain_decl)
650 !               {
651 !                 tsi_link_after(& i, x, TSI_SAME_STMT);
652 !                 x = NULL_TREE;
653 !                 break;
654 !               }
655 !             tsi_next (& i);
656 !           }
657 !         gcc_assert(x == NULL_TREE);
658 !       }
659 !       else
660 !       append_to_statement_list (x, &stmt_list);
661       }
662   
663     /* If trampolines were created, then we need to initialize them.  */
664 diff -cr gcc-orig/tree-pretty-print.c gcc/tree-pretty-print.c
665 *** gcc-orig/tree-pretty-print.c        Thu Dec  9 05:54:50 2004
666 --- gcc/tree-pretty-print.c     Thu Jun 22 19:49:35 2006
667 ***************
668 *** 953,958 ****
669 --- 953,968 ----
670         pp_string (buffer, " [tail call]");
671         break;
672   
673 +     case STATIC_CHAIN_EXPR:
674 +       pp_string (buffer, "<<static chain of ");
675 +       dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
676 +       pp_string (buffer, ">>");
677 +       break;
679 +     case STATIC_CHAIN_DECL:
680 +        pp_string (buffer, "<<static chain decl>>");
681 +        break;
682 +       
683       case WITH_CLEANUP_EXPR:
684         NIY;
685         break;
686 diff -cr gcc-orig/tree-sra.c gcc/tree-sra.c
687 *** gcc-orig/tree-sra.c Mon Aug 22 16:57:03 2005
688 --- gcc-orig/tree-sra.c Fri Mar  7 13:43:03 2008
689 ***************
690 *** 206,211 ****
691 --- 206,213 ----
692       case RECORD_TYPE:
693         {
694         bool saw_one_field = false;
695 +       tree last_offset = size_zero_node;
696 +       tree cmp;
697   
698         for (t = TYPE_FIELDS (type); t ; t = TREE_CHAIN (t))
699           if (TREE_CODE (t) == FIELD_DECL)
700 ***************
701 *** 215,220 ****
702 --- 217,227 ----
703                   && (tree_low_cst (DECL_SIZE (t), 1)
704                       != TYPE_PRECISION (TREE_TYPE (t))))
705                 goto fail;
706 +             /* Reject aliased fields created by GDC for anonymous unions. */
707 +             cmp = fold_binary_to_constant (LE_EXPR, boolean_type_node,
708 +               DECL_FIELD_OFFSET (t), last_offset);
709 +             if (cmp == NULL_TREE || TREE_CODE (cmp) != INTEGER_CST || TREE_INT_CST_LOW (cmp))
710 +               goto fail;
711   
712               saw_one_field = true;
713             }
714 diff -cr gcc-orig/tree.def gcc/tree.def
715 *** gcc-orig/tree.def   Mon Oct  3 16:31:24 2005
716 --- gcc/tree.def        Thu Jun 22 21:09:39 2006
717 ***************
718 *** 528,533 ****
719 --- 528,540 ----
720      Operand 2 is the static chain argument, or NULL.  */
721   DEFTREECODE (CALL_EXPR, "call_expr", tcc_expression, 3)
722   
723 + /* Operand 0 is the FUNC_DECL of the outer function for
724 +    which the static chain is to be computed. */
725 + DEFTREECODE (STATIC_CHAIN_EXPR, "static_chain_expr", tcc_expression, 1)
726 +     
727 + /* Represents a function's static chain.  It can be used as an lvalue. */
728 + DEFTREECODE (STATIC_CHAIN_DECL, "static_chain_decl", tcc_expression, 0)
730   /* Specify a value to compute along with its corresponding cleanup.
731      Operand 0 is the cleanup expression.
732      The cleanup is executed by the first enclosing CLEANUP_POINT_EXPR,
733 ***************
734 *** 901,907 ****
735   
736   /* APPLE LOCAL begin AV vmul_uch --haifa  */
737   /* Used during vectorization to represent computation idioms.  */
738 ! DEFTREECODE (MULT_UCH_EXPR, "mult_uch", '2', 2)
739   /* APPLE LOCAL end AV vmul_uch --haifa  */
740   
741   /* Value handles.  Artificial nodes to represent expressions in
742 --- 908,914 ----
743   
744   /* APPLE LOCAL begin AV vmul_uch --haifa  */
745   /* Used during vectorization to represent computation idioms.  */
746 ! DEFTREECODE (MULT_UCH_EXPR, "mult_uch", tcc_binary, 2)
747   /* APPLE LOCAL end AV vmul_uch --haifa  */
748   
749   /* Value handles.  Artificial nodes to represent expressions in
750 diff -cr gcc-orig/config/darwin.h gcc/config/darwin.h
751 *** gcc-orig/config/darwin.h    Thu Apr 27 21:06:13 2006
752 --- gcc/config/darwin.h Thu Dec  7 23:53:11 2006
753 ***************
754 *** 376,381 ****
755 --- 376,388 ----
756       %{!nostdlib:%{!nodefaultlibs:%G %L}} \
757       %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} %{F*} }}}}}}}}"
758   
759 + #ifdef TARGET_SYSTEM_ROOT
760 + #define LINK_SYSROOT_SPEC \
761 +   "%{isysroot*:-syslibroot %*;:-syslibroot " TARGET_SYSTEM_ROOT "}"
762 + #else
763 + #define LINK_SYSROOT_SPEC "%{isysroot*:-syslibroot %*}"
764 + #endif
766   /* Please keep the random linker options in alphabetical order (modulo
767      'Z' and 'no' prefixes).  Options that can only go to one of libtool
768      or ld must be listed twice, under both !Zdynamiclib and
769 ***************
770 *** 450,456 ****
771      %{Zfn_seg_addr_table_filename*:-seg_addr_table_filename %*} \
772      %{sub_library*} %{sub_umbrella*} \
773      "/* APPLE LOCAL mainline 4.1 2005-06-03 */" \
774 !    %{isysroot*:-syslibroot %*} \
775      %{twolevel_namespace} %{twolevel_namespace_hints} \
776      %{umbrella*} \
777      %{undefined*} \
778 --- 457,463 ----
779      %{Zfn_seg_addr_table_filename*:-seg_addr_table_filename %*} \
780      %{sub_library*} %{sub_umbrella*} \
781      "/* APPLE LOCAL mainline 4.1 2005-06-03 */" \
782 !    " LINK_SYSROOT_SPEC " \
783      %{twolevel_namespace} %{twolevel_namespace_hints} \
784      %{umbrella*} \
785      %{undefined*} \