Give a better error when doing pointer arithmetic on maybe pointers
[delight/core.git] / patches / patch-gcc-4.1.x
blob55ca0987f84124c93af908f7c0eb59cceefc8ae8
1 diff -cr gcc-orig/cgraph.c gcc/cgraph.c
2 *** gcc-orig/cgraph.c   Mon Oct 31 16:07:29 2005
3 --- gcc/cgraph.c        Tue Jan 23 19:39:14 2007
4 ***************
5 *** 182,187 ****
6 --- 182,188 ----
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 *** 203,214 ****
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 !       node->master_clone = node;
25       }
26     return node;
27   }
28 --- 204,219 ----
29     node = cgraph_create_node ();
30     node->decl = decl;
31     *slot = node;
32 !   if (!DECL_NO_STATIC_CHAIN (decl))
33       {
34 !       context = decl_function_context (decl);
35 !       if (context)
36 !         {
37 !         node->origin = cgraph_node (context);
38 !         node->next_nested = node->origin->nested;
39 !         node->origin->nested = node;
40 !         node->master_clone = node;
41 !         }
42       }
43     return node;
44   }
45 diff -cr gcc-orig/config/arm.c gcc/config/arm.c
46 *** gcc-orig/config/arm/arm.c   Mon Oct 16 21:04:38 2006
47 --- gcc/config/arm/arm.c        Sun Sep 30 21:58:58 2007
48 ***************
49 *** 15371,15376 ****
50 --- 15371,15385 ----
51           /* Move from sp to reg.  */
52           asm_fprintf (asm_out_file, "\t.movsp %r\n", REGNO (e0));
53         }
54 +       else if (GET_CODE (e1) == PLUS
55 +             && GET_CODE (XEXP (e1, 0)) == REG
56 +             && REGNO (XEXP (e1, 0)) == SP_REGNUM
57 +             && GET_CODE (XEXP (e1, 1)) == CONST_INT)
58 +       {
59 +         /* Set reg to offset from sp.  */
60 +         asm_fprintf (asm_out_file, "\t.movsp %r, #%d\n",
61 +                      REGNO (e0), (int)INTVAL(XEXP (e1, 1)));
62 +       }
63         else
64         abort ();
65         break;
66 diff -cr gcc-orig/config/darwin.h gcc/config/darwin.h
67 *** gcc-orig/config/darwin.h    Mon Nov 14 23:55:12 2005
68 --- gcc/config/darwin.h Tue Jan 23 19:39:14 2007
69 ***************
70 *** 926,933 ****
71   
72   #define MACHO_DYNAMIC_NO_PIC_P        (TARGET_DYNAMIC_NO_PIC)
73   #define MACHOPIC_INDIRECT     (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
74 ! #define MACHOPIC_JUST_INDIRECT        (flag_pic == 1 || MACHO_DYNAMIC_NO_PIC_P)
75 ! #define MACHOPIC_PURE         (flag_pic == 2 && ! MACHO_DYNAMIC_NO_PIC_P)
76   
77   #undef TARGET_ENCODE_SECTION_INFO
78   #define TARGET_ENCODE_SECTION_INFO  darwin_encode_section_info
79 --- 926,933 ----
80   
81   #define MACHO_DYNAMIC_NO_PIC_P        (TARGET_DYNAMIC_NO_PIC)
82   #define MACHOPIC_INDIRECT     (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
83 ! #define MACHOPIC_JUST_INDIRECT        (MACHO_DYNAMIC_NO_PIC_P)
84 ! #define MACHOPIC_PURE         (flag_pic && ! MACHO_DYNAMIC_NO_PIC_P)
85   
86   #undef TARGET_ENCODE_SECTION_INFO
87   #define TARGET_ENCODE_SECTION_INFO  darwin_encode_section_info
88 Only in gcc/config: darwin.h.orig
89 diff -cr gcc-orig/config/i386/i386.c gcc/config/i386/i386.c
90 *** gcc-orig/config/i386/i386.c Tue May 16 21:11:59 2006
91 --- gcc/config/i386/i386.c      Tue Jan 23 19:39:14 2007
92 ***************
93 *** 4727,4732 ****
94 --- 4727,4737 ----
95       frame->red_zone_size = 0;
96     frame->to_allocate -= frame->red_zone_size;
97     frame->stack_pointer_offset -= frame->red_zone_size;
98
99 +   if (cfun->naked)
100 +       /* As above, skip return address */
101 +       frame->stack_pointer_offset = UNITS_PER_WORD;
103   #if 0
104     fprintf (stderr, "nregs: %i\n", frame->nregs);
105     fprintf (stderr, "size: %i\n", size);
106 ***************
107 *** 16950,16956 ****
108           output_set_got (tmp);
109   
110           xops[1] = tmp;
111 !         output_asm_insn ("mov{l}\t{%0@GOT(%1), %1|%1, %0@GOT[%1]}", xops);
112           output_asm_insn ("jmp\t{*}%1", xops);
113         }
114       }
115 --- 16950,16956 ----
116           output_set_got (tmp);
117   
118           xops[1] = tmp;
119 !         output_asm_insn ("mov{l}\t{%a0@GOT(%1), %1|%1, %a0@GOT[%1]}", xops);
120           output_asm_insn ("jmp\t{*}%1", xops);
121         }
122       }
123 diff -cr gcc-orig/config/rs6000/rs6000.c gcc/config/rs6000/rs6000.c
124 *** gcc-orig/config/rs6000/rs6000.c     Thu Apr 13 01:46:01 2006
125 --- gcc/config/rs6000/rs6000.c  Tue Jan 23 19:39:14 2007
126 ***************
127 *** 15236,15242 ****
128          use language_string.
129          C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
130          Java is 13.  Objective-C is 14.  */
131 !       if (! strcmp (language_string, "GNU C"))
132         i = 0;
133         else if (! strcmp (language_string, "GNU F77")
134                || ! strcmp (language_string, "GNU F95"))
135 --- 15236,15243 ----
136          use language_string.
137          C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
138          Java is 13.  Objective-C is 14.  */
139 !       if (! strcmp (language_string, "GNU C") ||
140 !         ! strcmp (language_string, "GNU D"))
141         i = 0;
142         else if (! strcmp (language_string, "GNU F77")
143                || ! strcmp (language_string, "GNU F95"))
144 Only in gcc: d
145 diff -cr gcc-orig/dwarf2.h gcc/dwarf2.h
146 *** gcc-orig/dwarf2.h   Fri Jun 24 22:02:01 2005
147 --- gcc/dwarf2.h        Tue Jan 23 19:39:14 2007
148 ***************
149 *** 731,736 ****
150 --- 731,737 ----
151       DW_LANG_C99 = 0x000c,
152       DW_LANG_Ada95 = 0x000d,
153       DW_LANG_Fortran95 = 0x000e,
154 +     DW_LANG_D = 0x0013,
155       /* MIPS.  */
156       DW_LANG_Mips_Assembler = 0x8001,
157       /* UPC.  */
158 diff -cr gcc-orig/dwarf2out.c gcc/dwarf2out.c
159 *** gcc-orig/dwarf2out.c        Mon Apr 10 09:21:13 2006
160 --- gcc/dwarf2out.c     Tue Jan 23 19:39:14 2007
161 ***************
162 *** 5311,5317 ****
163     unsigned int lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
164   
165     return (lang == DW_LANG_C || lang == DW_LANG_C89
166 !         || lang == DW_LANG_C_plus_plus);
167   }
168   
169   /* Return TRUE if the language is C++.  */
170 --- 5311,5318 ----
171     unsigned int lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
172   
173     return (lang == DW_LANG_C || lang == DW_LANG_C89
174 !         || lang == DW_LANG_C_plus_plus
175 !         || lang == DW_LANG_D);
176   }
177   
178   /* Return TRUE if the language is C++.  */
179 ***************
180 *** 12187,12192 ****
181 --- 12188,12195 ----
182       language = DW_LANG_Pascal83;
183     else if (strcmp (language_string, "GNU Java") == 0)
184       language = DW_LANG_Java;
185 +   else if (strcmp (language_string, "GNU D") == 0)
186 +     language = DW_LANG_D;
187     else
188       language = DW_LANG_C89;
189   
190 ***************
191 *** 13318,13324 ****
192   
193         /* For local statics lookup proper context die.  */
194         if (TREE_STATIC (decl) && decl_function_context (decl))
195 !       context_die = lookup_decl_die (DECL_CONTEXT (decl));
196   
197         /* If we are in terse mode, don't generate any DIEs to represent any
198          variable declarations or definitions.  */
199 --- 13321,13327 ----
200   
201         /* For local statics lookup proper context die.  */
202         if (TREE_STATIC (decl) && decl_function_context (decl))
203 !       context_die = lookup_decl_die (decl_function_context (decl));
204   
205         /* If we are in terse mode, don't generate any DIEs to represent any
206          variable declarations or definitions.  */
207 diff -cr gcc-orig/expr.c gcc/expr.c
208 *** gcc-orig/expr.c     Wed May 17 12:03:25 2006
209 --- gcc/expr.c  Tue Jan 23 19:39:14 2007
210 ***************
211 *** 8476,8481 ****
212 --- 8476,8486 ----
213         /* Lowered by gimplify.c.  */
214         gcc_unreachable ();
215   
216 +     case STATIC_CHAIN_EXPR:
217 +     case STATIC_CHAIN_DECL:
218 +       /* Lowered by tree-nested.c */
219 +       gcc_unreachable ();
221       case EXC_PTR_EXPR:
222         return get_exception_pointer (cfun);
223   
224 diff -cr gcc-orig/function.c gcc/function.c
225 *** gcc-orig/function.c Wed Jan  4 04:13:56 2006
226 --- gcc/function.c      Tue Jan 23 19:39:14 2007
227 ***************
228 *** 2990,2996 ****
229         FUNCTION_ARG_ADVANCE (all.args_so_far, data.promoted_mode,
230                             data.passed_type, data.named_arg);
231   
232 !       assign_parm_adjust_stack_rtl (&data);
233   
234         if (assign_parm_setup_block_p (&data))
235         assign_parm_setup_block (&all, parm, &data);
236 --- 2990,2997 ----
237         FUNCTION_ARG_ADVANCE (all.args_so_far, data.promoted_mode,
238                             data.passed_type, data.named_arg);
239   
240 !       if (!cfun->naked)
241 !       assign_parm_adjust_stack_rtl (&data);
242   
243         if (assign_parm_setup_block_p (&data))
244         assign_parm_setup_block (&all, parm, &data);
245 ***************
246 *** 3005,3011 ****
247   
248     /* Output all parameter conversion instructions (possibly including calls)
249        now that all parameters have been copied out of hard registers.  */
250 !   emit_insn (all.conversion_insns);
251   
252     /* If we are receiving a struct value address as the first argument, set up
253        the RTL for the function result. As this might require code to convert
254 --- 3006,3013 ----
255   
256     /* Output all parameter conversion instructions (possibly including calls)
257        now that all parameters have been copied out of hard registers.  */
258 !   if (!cfun->naked)
259 !     emit_insn (all.conversion_insns);
260   
261     /* If we are receiving a struct value address as the first argument, set up
262        the RTL for the function result. As this might require code to convert
263 ***************
264 *** 3135,3140 ****
265 --- 3137,3145 ----
266     struct assign_parm_data_all all;
267     tree fnargs, parm, stmts = NULL;
268   
269 +   if (cfun->naked)
270 +     return NULL;
272     assign_parms_initialize_all (&all);
273     fnargs = assign_parms_augmented_arg_list (&all);
274   
275 ***************
276 *** 4169,4179 ****
277         tree parm = cfun->static_chain_decl;
278         rtx local = gen_reg_rtx (Pmode);
279   
280 -       set_decl_incoming_rtl (parm, static_chain_incoming_rtx);
281         SET_DECL_RTL (parm, local);
282         mark_reg_pointer (local, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm))));
283   
284 !       emit_move_insn (local, static_chain_incoming_rtx);
285       }
286   
287     /* If the function receives a non-local goto, then store the
288 --- 4174,4188 ----
289         tree parm = cfun->static_chain_decl;
290         rtx local = gen_reg_rtx (Pmode);
291   
292         SET_DECL_RTL (parm, local);
293         mark_reg_pointer (local, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm))));
294   
295 !       if (! cfun->custom_static_chain)
296 !         {
297 !           set_decl_incoming_rtl (parm, static_chain_incoming_rtx);
298 !           emit_move_insn (local, static_chain_incoming_rtx);
299 !       }
300 !       /* else, the static chain will be set in the main body */
301       }
302   
303     /* If the function receives a non-local goto, then store the
304 ***************
305 *** 5086,5091 ****
306 --- 5095,5103 ----
307   #endif
308     edge_iterator ei;
309   
310 +   if (cfun->naked)
311 +       return;
313   #ifdef HAVE_prologue
314     if (HAVE_prologue)
315       {
316 diff -cr gcc-orig/function.h gcc/function.h
317 *** gcc-orig/function.h Fri Aug 19 17:16:20 2005
318 --- gcc/function.h      Tue Jan 23 19:39:14 2007
319 ***************
320 *** 461,466 ****
321 --- 461,474 ----
322     /* Number of units of floating point registers that need saving in stdarg
323        function.  */
324     unsigned int va_list_fpr_size : 8;
326 +   /* Nonzero if static chain is initialized by something other than
327 +      static_chain_incoming_rtx. */
328 +   unsigned int custom_static_chain : 1;
330 +   /* Nonzero if no code should be generated for prologues, copying
331 +      parameters, etc. */
332 +   unsigned int naked : 1;
333   };
334   
335   /* If va_list_[gf]pr_size is set to this, it means we don't know how
336 diff -cr gcc-orig/gcc.c gcc/gcc.c
337 *** gcc-orig/gcc.c      Wed May 17 14:38:58 2006
338 --- gcc/gcc.c   Thu Mar  1 10:42:36 2007
339 ***************
340 *** 126,131 ****
341 --- 126,134 ----
342   /* Flag set by cppspec.c to 1.  */
343   int is_cpp_driver;
344   
345 + /* Flag set by drivers needing Pthreads. */
346 + int need_pthreads;
348   /* Flag saying to pass the greatest exit code returned by a sub-process
349      to the calling program.  */
350   static int pass_exit_codes;
351 ***************
352 *** 458,463 ****
353 --- 461,467 ----
354         assembler has done its job.
355    %D   Dump out a -L option for each directory in startfile_prefixes.
356         If multilib_dir is set, extra entries are generated with it affixed.
357 +  %N     Output the currently selected multilib directory name.
358    %l     process LINK_SPEC as a spec.
359    %L     process LIB_SPEC as a spec.
360    %G     process LIBGCC_SPEC as a spec.
361 ***************
362 *** 876,881 ****
363 --- 880,887 ----
364   #endif
365   #endif
366   
367 + #define GCC_SPEC_FORMAT_4 1
369   /* Record the mapping from file suffixes for compilation specs.  */
370   
371   struct compiler
372 ***************
373 *** 3797,3802 ****
374 --- 3803,3811 ----
375         }
376       }
377   
378 +   if (need_pthreads)
379 +       n_switches++;
381     if (save_temps_flag && use_pipes)
382       {
383         /* -save-temps overrides -pipe, so that temp files are produced */
384 ***************
385 *** 4135,4140 ****
386 --- 4144,4161 ----
387         }
388       }
389   
390 +   if (need_pthreads)
391 +     {
392 +       switches[n_switches].part1 = "pthread";
393 +       switches[n_switches].args = 0;
394 +       switches[n_switches].live_cond = SWITCH_OK;
395 +       /* Do not print an error if there is not expansion for -pthread. */
396 +       switches[n_switches].validated = 1;
397 +       switches[n_switches].ordering = 0;
399 +       n_switches++;
400 +     }
402     switches[n_switches].part1 = 0;
403     infiles[n_infiles].name = 0;
404   }
405 ***************
406 *** 5106,5111 ****
407 --- 5127,5143 ----
408               return value;
409             break;
410   
411 +         case 'N':
412 +           if (multilib_dir)
413 +             {
414 +               arg_going = 1;
415 +               obstack_grow (&obstack, "-fmultilib-dir=",
416 +                             strlen ("-fmultilib-dir="));
417 +               obstack_grow (&obstack, multilib_dir,
418 +                             strlen (multilib_dir));
419 +             }
420 +           break;
422             /* Here we define characters other than letters and digits.  */
423   
424           case '{':
425 diff -cr gcc-orig/gcc.c gcc/gcc.h
426 *** gcc-orig/gcc.h Fri Jun 24 22:02:01 2005
427 --- gcc/gcc.h       Sun Mar  4 13:44:05 2007
428 ***************
429 *** 38,44 ****
430      || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \
431      || (CHAR) == 'I' || (CHAR) == 'm' || (CHAR) == 'x' \
432      || (CHAR) == 'L' || (CHAR) == 'A' || (CHAR) == 'V' \
433 !    || (CHAR) == 'B' || (CHAR) == 'b')
434   
435   /* This defines which multi-letter switches take arguments.  */
436   
437 --- 38,44 ----
438      || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \
439      || (CHAR) == 'I' || (CHAR) == 'm' || (CHAR) == 'x' \
440      || (CHAR) == 'L' || (CHAR) == 'A' || (CHAR) == 'V' \
441 !    || (CHAR) == 'B' || (CHAR) == 'b' || (CHAR) == 'J')
442   
443   /* This defines which multi-letter switches take arguments.  */
444   
445 diff -cr gcc-orig/gimplify.c gcc/gimplify.c
446 *** gcc-orig/gimplify.c Wed Apr  5 09:41:27 2006
447 --- gcc/gimplify.c      Tue Jan 23 19:39:14 2007
448 ***************
449 *** 4181,4186 ****
450 --- 4181,4192 ----
451             }
452           break;
453   
454 +       case STATIC_CHAIN_EXPR:
455 +         /* The argument is used as information only.  No need to gimplify */
456 +       case STATIC_CHAIN_DECL:  
457 +         ret = GS_ALL_DONE;
458 +         break;
459 +         
460         case TREE_LIST:
461           gcc_unreachable ();
462   
463 diff -cr gcc-orig/predict.c gcc/predict.c
464 *** gcc-orig/predict.c  Thu Jul 19 20:05:21 2007
465 --- gcc/predict.c       Thu Jul 19 20:06:06 2007
466 ***************
467 *** 1339,1344 ****
468 --- 1339,1345 ----
469              care for error returns and other cases are often used for
470              fast paths trought function.  */
471           if (e->dest == EXIT_BLOCK_PTR
472 +             && last_stmt (bb) == NULL_TREE
473               && TREE_CODE (last_stmt (bb)) == RETURN_EXPR
474               && !single_pred_p (bb))
475             {
476 diff -cr gcc-orig/real.c gcc/real.c
477 *** gcc-orig/real.c     Mon Sep 19 13:01:40 2005
478 --- gcc/real.c  Tue Jan 23 19:39:14 2007
479 ***************
480 *** 2212,2217 ****
481 --- 2212,2219 ----
482     np2 = SIGNIFICAND_BITS - fmt->p * fmt->log2_b;
483     memset (r->sig, -1, SIGSZ * sizeof (unsigned long));
484     clear_significand_below (r, np2);
485 +   if (REAL_MODE_FORMAT_COMPOSITE_P (mode))
486 +       clear_significand_bit (r, SIGNIFICAND_BITS - fmt->pnan - 1);
487   }
488   
489   /* Fills R with 2**N.  */
490 diff -cr gcc-orig/tree-dump.c gcc/tree-dump.c
491 *** gcc-orig/tree-dump.c        Sat Aug 20 12:03:58 2005
492 --- gcc/tree-dump.c     Tue Jan 23 19:39:14 2007
493 ***************
494 *** 582,587 ****
495 --- 582,591 ----
496         dump_child ("args", TREE_OPERAND (t, 1));
497         break;
498   
499 +     case STATIC_CHAIN_EXPR:
500 +       dump_child ("func", TREE_OPERAND (t, 0));
501 +       break;
503       case CONSTRUCTOR:
504         {
505         unsigned HOST_WIDE_INT cnt;
506 diff -cr gcc-orig/tree-gimple.c gcc/tree-gimple.c
507 *** gcc-orig/tree-gimple.c      Sun Nov 20 14:05:43 2005
508 --- gcc/tree-gimple.c   Tue Jan 23 19:39:14 2007
509 ***************
510 *** 72,77 ****
511 --- 72,79 ----
512       case VECTOR_CST:
513       case OBJ_TYPE_REF:
514       case ASSERT_EXPR:
515 +     case STATIC_CHAIN_EXPR: /* not sure if this is right...*/
516 +     case STATIC_CHAIN_DECL:
517         return true;
518   
519       default:
520 ***************
521 *** 143,149 ****
522           || TREE_CODE (t) == WITH_SIZE_EXPR
523           /* These are complex lvalues, but don't have addresses, so they
524              go here.  */
525 !         || TREE_CODE (t) == BIT_FIELD_REF);
526   }
527   
528   /*  Return true if T is a GIMPLE condition.  */
529 --- 145,154 ----
530           || TREE_CODE (t) == WITH_SIZE_EXPR
531           /* These are complex lvalues, but don't have addresses, so they
532              go here.  */
533 !         || TREE_CODE (t) == BIT_FIELD_REF
534 !           /* This is an lvalue because it will be replaced with the real
535 !            static chain decl. */
536 !         || TREE_CODE (t) == STATIC_CHAIN_DECL);
537   }
538   
539   /*  Return true if T is a GIMPLE condition.  */
540 diff -cr gcc-orig/tree-inline.c gcc/tree-inline.c
541 *** gcc-orig/tree-inline.c      Fri Apr 28 07:43:43 2006
542 --- gcc/tree-inline.c   Tue Jan 23 19:39:14 2007
543 ***************
544 *** 602,611 ****
545        knows not to copy VAR_DECLs, etc., so this is safe.  */
546     else
547       {
548         /* Here we handle trees that are not completely rewritten.
549          First we detect some inlining-induced bogosities for
550          discarding.  */
551 !       if (TREE_CODE (*tp) == MODIFY_EXPR
552           && TREE_OPERAND (*tp, 0) == TREE_OPERAND (*tp, 1)
553           && (lang_hooks.tree_inlining.auto_var_in_fn_p
554               (TREE_OPERAND (*tp, 0), fn)))
555 --- 602,622 ----
556        knows not to copy VAR_DECLs, etc., so this is safe.  */
557     else
558       {
559 +       if (! id->cloning_p && ! id->saving_p &&
560 +         TREE_CODE (*tp) == MODIFY_EXPR &&
561 +         TREE_OPERAND (*tp, 0) ==
562 +         DECL_STRUCT_FUNCTION (fn)->static_chain_decl)
563 +       {
564 +         /* Don't use special methods to initialize the static chain
565 +            if expanding inline.  If this code could somehow be
566 +            expanded in expand_start_function, it would not be
567 +            necessary to deal with it here. */
568 +         *tp = build_empty_stmt ();
569 +       }
570         /* Here we handle trees that are not completely rewritten.
571          First we detect some inlining-induced bogosities for
572          discarding.  */
573 !       else if (TREE_CODE (*tp) == MODIFY_EXPR
574           && TREE_OPERAND (*tp, 0) == TREE_OPERAND (*tp, 1)
575           && (lang_hooks.tree_inlining.auto_var_in_fn_p
576               (TREE_OPERAND (*tp, 0), fn)))
577 diff -cr gcc-orig/tree-nested.c gcc/tree-nested.c
578 *** gcc-orig/tree-nested.c      Mon Oct  3 16:57:45 2005
579 --- gcc/tree-nested.c   Tue Jan 23 19:39:14 2007
580 ***************
581 *** 320,325 ****
582 --- 320,326 ----
583     if (!decl)
584       {
585         tree type;
586 +       enum tree_code code;
587   
588         type = get_frame_type (info->outer);
589         type = build_pointer_type (type);
590 ***************
591 *** 330,341 ****
592          Note also that it's represented as a parameter.  This is more
593          close to the truth, since the initial value does come from 
594          the caller.  */
595 !       decl = build_decl (PARM_DECL, create_tmp_var_name ("CHAIN"), type);
596         DECL_ARTIFICIAL (decl) = 1;
597         DECL_IGNORED_P (decl) = 1;
598         TREE_USED (decl) = 1;
599         DECL_CONTEXT (decl) = info->context;
600 !       DECL_ARG_TYPE (decl) = type;
601   
602         /* Tell tree-inline.c that we never write to this variable, so
603          it can copy-prop the replacement value immediately.  */
604 --- 331,347 ----
605          Note also that it's represented as a parameter.  This is more
606          close to the truth, since the initial value does come from 
607          the caller.  */
608 !       /* If the function has a custom static chain, a VAR_DECL is more
609 !        appropriate. */
610 !       code = DECL_STRUCT_FUNCTION (info->context)->custom_static_chain ?
611 !         VAR_DECL : PARM_DECL;
612 !       decl = build_decl (code, create_tmp_var_name ("CHAIN"), type);
613         DECL_ARTIFICIAL (decl) = 1;
614         DECL_IGNORED_P (decl) = 1;
615         TREE_USED (decl) = 1;
616         DECL_CONTEXT (decl) = info->context;
617 !       if (TREE_CODE (decl) == PARM_DECL)
618 !         DECL_ARG_TYPE (decl) = type;
619   
620         /* Tell tree-inline.c that we never write to this variable, so
621          it can copy-prop the replacement value immediately.  */
622 ***************
623 *** 738,743 ****
624 --- 744,751 ----
625   
626     if (info->context == target_context)
627       {
628 +       /* might be doing something wrong to need the following line.. */
629 +       get_frame_type (info);
630         x = build_addr (info->frame_decl, target_context);
631       }
632     else
633 ***************
634 *** 1221,1226 ****
635 --- 1229,1238 ----
636         if (DECL_NO_STATIC_CHAIN (decl))
637         break;
638   
639 +       /* Don't use a trampoline for a static reference. */
640 +       if (TREE_STATIC (t))
641 +       break;
643         /* Lookup the immediate parent of the callee, as that's where
644          we need to insert the trampoline.  */
645         for (i = info; i->context != target_context; i = i->outer)
646 ***************
647 *** 1285,1290 ****
648 --- 1297,1310 ----
649           = get_static_chain (info, target_context, &wi->tsi);
650         break;
651   
652 +     case STATIC_CHAIN_EXPR:
653 +       *tp = get_static_chain (info, TREE_OPERAND (t, 0), &wi->tsi);
654 +       break;
656 +     case STATIC_CHAIN_DECL:
657 +       *tp = get_chain_decl (info);
658 +       break;
659 +  
660       case RETURN_EXPR:
661       case MODIFY_EXPR:
662       case WITH_SIZE_EXPR:
663 ***************
664 *** 1384,1390 ****
665         tree x = build (COMPONENT_REF, TREE_TYPE (root->chain_field),
666                       root->frame_decl, root->chain_field, NULL_TREE);
667         x = build (MODIFY_EXPR, TREE_TYPE (x), x, get_chain_decl (root));
668 !       append_to_statement_list (x, &stmt_list);
669       }
670   
671     /* If trampolines were created, then we need to initialize them.  */
672 --- 1404,1432 ----
673         tree x = build (COMPONENT_REF, TREE_TYPE (root->chain_field),
674                       root->frame_decl, root->chain_field, NULL_TREE);
675         x = build (MODIFY_EXPR, TREE_TYPE (x), x, get_chain_decl (root));
676 !       /* If the function has a custom static chain, chain_field must
677 !        be set after the static chain. */
678 !       if (DECL_STRUCT_FUNCTION (root->context)->custom_static_chain)
679 !       {
680 !         /* Should use walk_function instead. */
681 !         tree_stmt_iterator i =
682 !             tsi_start ( BIND_EXPR_BODY (DECL_SAVED_TREE (context)));
683 !         while (!tsi_end_p (i))
684 !           {
685 !             tree t = tsi_stmt (i);
686 !             if (TREE_CODE (t) == MODIFY_EXPR &&
687 !                 TREE_OPERAND (t, 0) == root->chain_decl)
688 !               {
689 !                 tsi_link_after(& i, x, TSI_SAME_STMT);
690 !                 x = NULL_TREE;
691 !                 break;
692 !               }
693 !             tsi_next (& i);
694 !           }
695 !         gcc_assert(x == NULL_TREE);
696 !       }
697 !       else
698 !       append_to_statement_list (x, &stmt_list);
699       }
700   
701     /* If trampolines were created, then we need to initialize them.  */
702 diff -cr gcc-orig/tree-pretty-print.c gcc/tree-pretty-print.c
703 *** gcc-orig/tree-pretty-print.c        Sun Jul 31 16:55:41 2005
704 --- gcc/tree-pretty-print.c     Tue Jan 23 19:39:14 2007
705 ***************
706 *** 1004,1009 ****
707 --- 1004,1019 ----
708         pp_string (buffer, " [tail call]");
709         break;
710   
711 +     case STATIC_CHAIN_EXPR:
712 +       pp_string (buffer, "<<static chain of ");
713 +       dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
714 +       pp_string (buffer, ">>");
715 +       break;
717 +     case STATIC_CHAIN_DECL:
718 +        pp_string (buffer, "<<static chain decl>>");
719 +        break;
720 +       
721       case WITH_CLEANUP_EXPR:
722         NIY;
723         break;
724 diff -cr gcc-orig/tree-sra.c gcc/tree-sra.c
725 *** gcc-orig/tree-sra.c Sun Nov 20 19:55:57 2005
726 --- gcc/tree-sra.c      Sun Jul 22 11:32:36 2007
727 ***************
728 *** 198,203 ****
729 --- 198,205 ----
730       case RECORD_TYPE:
731         {
732         bool saw_one_field = false;
733 +       tree last_offset = size_zero_node;
734 +       tree cmp;
735   
736         for (t = TYPE_FIELDS (type); t ; t = TREE_CHAIN (t))
737           if (TREE_CODE (t) == FIELD_DECL)
738 ***************
739 *** 207,212 ****
740 --- 209,219 ----
741                   && (tree_low_cst (DECL_SIZE (t), 1)
742                       != TYPE_PRECISION (TREE_TYPE (t))))
743                 goto fail;
744 +             /* Reject aliased fields created by GDC for anonymous unions. */
745 +             cmp = fold_binary_to_constant (LE_EXPR, boolean_type_node,
746 +               DECL_FIELD_OFFSET (t), last_offset);
747 +             if (cmp == NULL_TREE || tree_expr_nonzero_p (cmp))
748 +               goto fail;
749   
750               saw_one_field = true;
751             }
752 diff -cr gcc-orig/tree.def gcc/tree.def
753 *** gcc-orig/tree.def   Fri Feb 10 12:32:10 2006
754 --- gcc/tree.def        Tue Jan 23 19:39:14 2007
755 ***************
756 *** 526,531 ****
757 --- 526,538 ----
758      Operand 2 is the static chain argument, or NULL.  */
759   DEFTREECODE (CALL_EXPR, "call_expr", tcc_expression, 3)
760   
761 + /* Operand 0 is the FUNC_DECL of the outer function for
762 +    which the static chain is to be computed. */
763 + DEFTREECODE (STATIC_CHAIN_EXPR, "static_chain_expr", tcc_expression, 1)
764 +     
765 + /* Represents a function's static chain.  It can be used as an lvalue. */
766 + DEFTREECODE (STATIC_CHAIN_DECL, "static_chain_decl", tcc_expression, 0)
768   /* Specify a value to compute along with its corresponding cleanup.
769      Operand 0 is the cleanup expression.
770      The cleanup is executed by the first enclosing CLEANUP_POINT_EXPR,
771 diff -cr gcc-orig/varray.h gcc/varray.h
772 *** gcc-orig/varray.h   Fri Jun 24 22:02:01 2005
773 --- gcc/varray.h        Tue Jan 23 19:39:14 2007
774 ***************
775 *** 62,67 ****
776 --- 62,78 ----
777     NUM_VARRAY_DATA
778   };
779   
780 + #ifndef __cplusplus 
781 + # define VARRAY_STRANGE_1 rtx
782 + # define VARRAY_STRANGE_2 rtvec
783 + # define VARRAY_STRANGE_3 tree
784 + #else
785 + # define VARRAY_STRANGE_1 rtx_
786 + # define VARRAY_STRANGE_2 rtvec_
787 + # define VARRAY_STRANGE_3 tree_
788 + #endif
791   /* Union of various array types that are used.  */
792   typedef union varray_data_tag GTY (()) {
793     char                          GTY ((length ("%0.num_elements"),
794 ***************
795 *** 91,101 ****
796     char                         *GTY ((length ("%0.num_elements"),
797                                 tag ("VARRAY_DATA_CPTR")))      cptr[1];
798     rtx                   GTY ((length ("%0.num_elements"),
799 !                               tag ("VARRAY_DATA_RTX")))       rtx[1];
800     rtvec                         GTY ((length ("%0.num_elements"),
801 !                               tag ("VARRAY_DATA_RTVEC")))     rtvec[1];
802     tree                          GTY ((length ("%0.num_elements"),
803 !                               tag ("VARRAY_DATA_TREE")))      tree[1];
804     struct bitmap_head_def *GTY ((length ("%0.num_elements"),
805                                 tag ("VARRAY_DATA_BITMAP")))    bitmap[1];
806     struct reg_info_def  *GTY ((length ("%0.num_elements"), skip,
807 --- 102,112 ----
808     char                         *GTY ((length ("%0.num_elements"),
809                                 tag ("VARRAY_DATA_CPTR")))      cptr[1];
810     rtx                   GTY ((length ("%0.num_elements"),
811 !                               tag ("VARRAY_DATA_RTX")))       VARRAY_STRANGE_1[1];
812     rtvec                         GTY ((length ("%0.num_elements"),
813 !                               tag ("VARRAY_DATA_RTVEC")))     VARRAY_STRANGE_2[1];
814     tree                          GTY ((length ("%0.num_elements"),
815 !                               tag ("VARRAY_DATA_TREE")))      VARRAY_STRANGE_3[1];
816     struct bitmap_head_def *GTY ((length ("%0.num_elements"),
817                                 tag ("VARRAY_DATA_BITMAP")))    bitmap[1];
818     struct reg_info_def  *GTY ((length ("%0.num_elements"), skip,