This file is indexed.

/usr/src/gcc-4.4/debian/patches/gdc-4.4-linaro.diff is in gcc-4.4-source 4.4.7-1ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
# DP: Patches the GCC Directory for D.

--- a/src/gcc/cgraph.c	2008-11-16 22:31:58.000000000 +0000
+++ b/src/gcc/cgraph.c	2010-08-26 17:13:05.507131097 +0100
@@ -451,6 +451,7 @@
 cgraph_node (tree decl)
 {
   struct cgraph_node key, *node, **slot;
+  tree context;
 
   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
 
@@ -472,14 +473,18 @@
   node = cgraph_create_node ();
   node->decl = decl;
   *slot = node;
-  if (DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)
+  if (!DECL_NO_STATIC_CHAIN (decl))
     {
-      node->origin = cgraph_node (DECL_CONTEXT (decl));
-      node->origin->ever_was_nested = 1;
-      node->next_nested = node->origin->nested;
-      node->origin->nested = node;
-      node->master_clone = node;
-      node->ever_was_nested = 1;
+      context = decl_function_context (decl);
+      if (context)
+	{
+	  node->origin = cgraph_node (context);
+	  node->origin->ever_was_nested = 1;
+	  node->next_nested = node->origin->nested;
+	  node->origin->nested = node;
+	  node->master_clone = node;
+	  node->ever_was_nested = 1;
+	}
     }
   if (assembler_name_hash)
     {
--- a/src/gcc/cgraphunit.c	2010-03-31 14:23:17.000000000 +0100
+++ b/src/gcc/cgraphunit.c	2010-08-26 17:13:05.511130348 +0100
@@ -1032,6 +1032,10 @@
 static void
 cgraph_expand_function (struct cgraph_node *node)
 {
+  int save_flag_omit_frame_pointer = flag_omit_frame_pointer;
+  static int inited = 0;
+  static int orig_omit_frame_pointer;
+
   tree decl = node->decl;
 
   /* We ought to not compile any inline clones.  */
@@ -1041,11 +1045,21 @@
 
   gcc_assert (node->lowered);
 
+  if (!inited)
+    {
+      inited = 1;
+      orig_omit_frame_pointer = flag_omit_frame_pointer;
+    }
+  flag_omit_frame_pointer = orig_omit_frame_pointer ||
+      DECL_STRUCT_FUNCTION (decl)->naked;
+
   /* Generate RTL for the body of DECL.  */
   if (lang_hooks.callgraph.emit_associated_thunks)
     lang_hooks.callgraph.emit_associated_thunks (decl);
   tree_rest_of_compilation (decl);
 
+  flag_omit_frame_pointer = save_flag_omit_frame_pointer;
+
   /* Make sure that BE didn't give up on compiling.  */
   gcc_assert (TREE_ASM_WRITTEN (decl));
   current_function_decl = NULL;
--- a/src/gcc/config/i386/i386.c	2010-04-08 16:09:17.000000000 +0100
+++ b/src/gcc/config/i386/i386.c	2010-08-26 17:13:05.590134523 +0100
@@ -7876,6 +7876,11 @@
     frame->red_zone_size = 0;
   frame->to_allocate -= frame->red_zone_size;
   frame->stack_pointer_offset -= frame->red_zone_size;
+
+  if (cfun->naked)
+    /* As above, skip return address */
+    frame->stack_pointer_offset = UNITS_PER_WORD;
+
 #if 0
   fprintf (stderr, "\n");
   fprintf (stderr, "size: %ld\n", (long)size);
@@ -26792,7 +26797,7 @@
 	  output_set_got (tmp, NULL_RTX);
 
 	  xops[1] = tmp;
-	  output_asm_insn ("mov{l}\t{%0@GOT(%1), %1|%1, %0@GOT[%1]}", xops);
+	  output_asm_insn ("mov{l}\t{%a0@GOT(%1), %1|%1, %a0@GOT[%1]}", xops);
 	  output_asm_insn ("jmp\t{*}%1", xops);
 	}
     }
--- a/src/gcc/config/rs6000/rs6000.c	2010-03-27 18:56:08.000000000 +0000
+++ b/src/gcc/config/rs6000/rs6000.c	2010-08-26 17:13:05.622134818 +0100
@@ -17630,7 +17630,8 @@
 	 C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
 	 Java is 13.  Objective-C is 14.  Objective-C++ isn't assigned
 	 a number, so for now use 9.  */
-      if (! strcmp (language_string, "GNU C"))
+      if (! strcmp (language_string, "GNU C")
+	  || ! strcmp (language_string, "GNU D"))
 	i = 0;
       else if (! strcmp (language_string, "GNU F77")
 	       || ! strcmp (language_string, "GNU Fortran"))
--- a/src/gcc/dwarf2out.c	2010-02-10 15:09:06.000000000 +0000
+++ b/src/gcc/dwarf2out.c	2010-08-26 17:13:05.654133370 +0100
@@ -6398,7 +6398,8 @@
 
   return (lang == DW_LANG_C || lang == DW_LANG_C89 || lang == DW_LANG_ObjC
 	  || lang == DW_LANG_C99
-	  || lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus);
+	  || lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus
+	  || lang == DW_LANG_D);
 }
 
 /* Return TRUE if the language is C++.  */
@@ -14506,6 +14507,8 @@
     language = DW_LANG_ObjC;
   else if (strcmp (language_string, "GNU Objective-C++") == 0)
     language = DW_LANG_ObjC_plus_plus;
+  else if (strcmp (language_string, "GNU D") == 0)
+    language = DW_LANG_D;
   else
     language = DW_LANG_C89;
 
@@ -15688,7 +15691,7 @@
 
       /* For local statics lookup proper context die.  */
       if (TREE_STATIC (decl) && decl_function_context (decl))
-	context_die = lookup_decl_die (DECL_CONTEXT (decl));
+	context_die = lookup_decl_die (decl_function_context (decl));
 
       /* If we are in terse mode, don't generate any DIEs to represent any
 	 variable declarations or definitions.  */
--- a/src/gcc/except.c	2010-03-08 11:46:28.000000000 +0000
+++ b/src/gcc/except.c	2010-08-26 17:13:05.662141930 +0100
@@ -200,7 +200,7 @@
 
 typedef struct eh_region *eh_region;
 
-struct call_site_record GTY(())
+struct call_site_record_d GTY(())
 {
   rtx landing_pad;
   int action;
@@ -3198,7 +3198,7 @@
 {
   call_site_record record;
   
-  record = GGC_NEW (struct call_site_record);
+  record = GGC_NEW (struct call_site_record_d);
   record->landing_pad = landing_pad;
   record->action = action;
 
@@ -3399,7 +3399,7 @@
 
   for (i = 0; i < n; ++i)
     {
-      struct call_site_record *cs = VEC_index (call_site_record, crtl->eh.call_site_record, i);
+      struct call_site_record_d *cs = VEC_index (call_site_record, crtl->eh.call_site_record, i);
       size += size_of_uleb128 (cs->action);
     }
 
@@ -3415,7 +3415,7 @@
 
   for (i = 0; i < n; ++i)
     {
-      struct call_site_record *cs = VEC_index (call_site_record, crtl->eh.call_site_record, i);
+      struct call_site_record_d *cs = VEC_index (call_site_record, crtl->eh.call_site_record, i);
       size += size_of_uleb128 (INTVAL (cs->landing_pad));
       size += size_of_uleb128 (cs->action);
     }
@@ -3432,7 +3432,7 @@
 
   for (i = 0; i < n; ++i)
     {
-      struct call_site_record *cs = VEC_index (call_site_record, crtl->eh.call_site_record, i);
+      struct call_site_record_d *cs = VEC_index (call_site_record, crtl->eh.call_site_record, i);
       char reg_start_lab[32];
       char reg_end_lab[32];
       char landing_pad_lab[32];
@@ -3486,7 +3486,7 @@
 
   for (i = 0; i < n; ++i)
     {
-      struct call_site_record *cs = VEC_index (call_site_record, crtl->eh.call_site_record, i);
+      struct call_site_record_d *cs = VEC_index (call_site_record, crtl->eh.call_site_record, i);
 
       dw2_asm_output_data_uleb128 (INTVAL (cs->landing_pad),
 				   "region %d landing pad", i);
--- a/src/gcc/expr.c	2010-03-08 11:46:28.000000000 +0000
+++ b/src/gcc/expr.c	2010-08-26 17:13:05.678130275 +0100
@@ -9321,6 +9321,11 @@
 	 represent.  */
       return const0_rtx;
 
+    case STATIC_CHAIN_EXPR:
+    case STATIC_CHAIN_DECL:
+      /* Lowered by tree-nested.c */
+      gcc_unreachable ();
+
     case EXC_PTR_EXPR:
       return get_exception_pointer ();
 
--- a/src/gcc/function.c	2009-11-13 19:57:51.000000000 +0000
+++ b/src/gcc/function.c	2010-08-26 17:13:05.690132989 +0100
@@ -3184,7 +3184,8 @@
       FUNCTION_ARG_ADVANCE (all.args_so_far, data.promoted_mode,
 			    data.passed_type, data.named_arg);
 
-      assign_parm_adjust_stack_rtl (&data);
+      if (!cfun->naked)
+	assign_parm_adjust_stack_rtl (&data);
 
       if (assign_parm_setup_block_p (&data))
 	assign_parm_setup_block (&all, parm, &data);
@@ -3199,7 +3200,8 @@
 
   /* Output all parameter conversion instructions (possibly including calls)
      now that all parameters have been copied out of hard registers.  */
-  emit_insn (all.first_conversion_insn);
+  if (!cfun->naked)
+    emit_insn (all.first_conversion_insn);
 
   /* Estimate reload stack alignment from scalar return mode.  */
   if (SUPPORTS_STACK_ALIGNMENT)
@@ -3351,6 +3353,9 @@
   tree fnargs, parm;
   gimple_seq stmts = NULL;
 
+  if (cfun->naked)
+    return NULL;
+
   assign_parms_initialize_all (&all);
   fnargs = assign_parms_augmented_arg_list (&all);
 
@@ -4456,11 +4461,15 @@
       tree parm = cfun->static_chain_decl;
       rtx local = gen_reg_rtx (Pmode);
 
-      set_decl_incoming_rtl (parm, static_chain_incoming_rtx, false);
       SET_DECL_RTL (parm, local);
       mark_reg_pointer (local, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (parm))));
 
-      emit_move_insn (local, static_chain_incoming_rtx);
+      if (!cfun->custom_static_chain)
+	{
+	  set_decl_incoming_rtl (parm, static_chain_incoming_rtx, false);
+	  emit_move_insn (local, static_chain_incoming_rtx);
+	}
+      /* else, the static chain will be set in the main body */
     }
 
   /* If the function receives a non-local goto, then store the
@@ -4981,6 +4990,9 @@
 #endif
   edge_iterator ei;
 
+  if (cfun->naked)
+    return;
+
   rtl_profile_for_bb (ENTRY_BLOCK_PTR);
 #ifdef HAVE_prologue
   if (HAVE_prologue)
--- a/src/gcc/function.h	2009-09-23 15:58:58.000000000 +0100
+++ b/src/gcc/function.h	2010-08-26 17:13:05.694133708 +0100
@@ -137,7 +137,7 @@
   rtx x_forced_labels;
 };
 
-typedef struct call_site_record *call_site_record;
+typedef struct call_site_record_d *call_site_record;
 DEF_VEC_P(call_site_record);
 DEF_VEC_ALLOC_P(call_site_record, gc);
 
@@ -175,12 +175,12 @@
 struct gimple_df;
 struct temp_slot;
 typedef struct temp_slot *temp_slot_p;
-struct call_site_record;
+struct call_site_record_d;
 
 DEF_VEC_P(temp_slot_p);
 DEF_VEC_ALLOC_P(temp_slot_p,gc);
-struct ipa_opt_pass;
-typedef struct ipa_opt_pass *ipa_opt_pass;
+struct ipa_opt_pass_d;
+typedef struct ipa_opt_pass_d *ipa_opt_pass;
 
 DEF_VEC_P(ipa_opt_pass);
 DEF_VEC_ALLOC_P(ipa_opt_pass,heap);
@@ -600,6 +600,14 @@
      adjusts one of its arguments and forwards to another
      function.  */
   unsigned int is_thunk : 1;
+
+  /* Nonzero if static chain is initialized by something other than
+     static_chain_incoming_rtx. */
+  unsigned int custom_static_chain : 1;
+
+  /* Nonzero if no code should be generated for prologues, copying
+     parameters, etc. */
+  unsigned int naked : 1;
 };
 
 /* If va_list_[gf]pr_size is set to this, it means we don't know how
--- a/src/gcc/gcc.c	2010-01-09 00:05:06.000000000 +0000
+++ b/src/gcc/gcc.c	2010-08-26 17:13:39.034133274 +0100
@@ -126,6 +126,9 @@
 /* Flag set to nonzero if an @file argument has been supplied to gcc.  */
 static bool at_file_supplied;
 
+/* Flag set by drivers needing Pthreads. */
+int need_pthreads;
+
 /* Flag saying to pass the greatest exit code returned by a sub-process
    to the calling program.  */
 static int pass_exit_codes;
@@ -373,6 +376,9 @@
 static const char *version_compare_spec_function (int, const char **);
 static const char *include_spec_function (int, const char **);
 static const char *print_asm_header_spec_function (int, const char **);
+
+extern const char *d_all_sources_spec_function (int, const char **);
+extern const char *d_output_prefix_spec_function (int, const char **);
 
 /* The Specs Language
 
@@ -480,6 +486,7 @@
 	assembler has done its job.
  %D	Dump out a -L option for each directory in startfile_prefixes.
 	If multilib_dir is set, extra entries are generated with it affixed.
+ %N     Output the currently selected multilib directory name
  %l     process LINK_SPEC as a spec.
  %L     process LIB_SPEC as a spec.
  %G     process LIBGCC_SPEC as a spec.
@@ -925,6 +932,8 @@
 #endif
 #endif
 
+#define GCC_SPEC_FORMAT_4 1
+
 /* Record the mapping from file suffixes for compilation specs.  */
 
 struct compiler
@@ -1647,6 +1656,10 @@
   { "version-compare",		version_compare_spec_function },
   { "include",			include_spec_function },
   { "print-asm-header",		print_asm_header_spec_function },
+#ifdef D_USE_EXTRA_SPEC_FUNCTIONS
+  { "d-all-sources",		d_all_sources_spec_function },
+  { "d-output-prefix",		d_output_prefix_spec_function },
+#endif
 #ifdef EXTRA_SPEC_FUNCTIONS
   EXTRA_SPEC_FUNCTIONS
 #endif
@@ -4022,6 +4035,9 @@
 	}
     }
 
+  if (need_pthreads)
+      n_switches++;
+
   if (save_temps_flag && use_pipes)
     {
       /* -save-temps overrides -pipe, so that temp files are produced */
@@ -4332,6 +4348,18 @@
       infiles[0].name   = "help-dummy";
     }
 
+  if (need_pthreads)
+    {
+      switches[n_switches].part1 = "pthread";
+      switches[n_switches].args = 0;
+      switches[n_switches].live_cond = 0;
+      /* Do not print an error if there is not expansion for -pthread. */
+      switches[n_switches].validated = 1;
+      switches[n_switches].ordering = 0;
+
+      n_switches++;
+    }
+
   switches[n_switches].part1 = 0;
   infiles[n_infiles].name = 0;
 }
@@ -5337,6 +5365,17 @@
 	      return value;
 	    break;
 
+	  case 'N':
+	    if (multilib_dir)
+	      {
+		arg_going = 1;
+		obstack_grow (&obstack, "-fmultilib-dir=",
+			      strlen ("-fmultilib-dir="));
+		obstack_grow (&obstack, multilib_dir,
+			      strlen (multilib_dir));
+	      }
+	    break;
+
 	    /* Here we define characters other than letters and digits.  */
 
 	  case '{':
--- a/src/gcc/gimple.c	2008-12-07 23:27:14.000000000 +0000
+++ b/src/gcc/gimple.c	2010-08-26 17:13:05.714129477 +0100
@@ -2535,6 +2535,9 @@
       || (SYM) == POLYNOMIAL_CHREC					    \
       || (SYM) == DOT_PROD_EXPR						    \
       || (SYM) == VEC_COND_EXPR						    \
+      || (SYM) == STATIC_CHAIN_DECL					    \
+      || (SYM) == STATIC_CHAIN_EXPR /* not sure if this is right...*/	    \
+      || (SYM) == VEC_COND_EXPR						    \
       || (SYM) == REALIGN_LOAD_EXPR) ? GIMPLE_SINGLE_RHS		    \
    : GIMPLE_INVALID_RHS),
 #define END_OF_BASE_TREE_CODES (unsigned char) GIMPLE_INVALID_RHS,
@@ -2615,7 +2618,10 @@
 	  || TREE_CODE (t) == WITH_SIZE_EXPR
 	  /* These are complex lvalues, but don't have addresses, so they
 	     go here.  */
-	  || TREE_CODE (t) == BIT_FIELD_REF);
+	  || TREE_CODE (t) == BIT_FIELD_REF
+	  /* This is an lvalue because it will be replaced with the real
+	     static chain decl. */
+	  || TREE_CODE (t) == STATIC_CHAIN_DECL);
 }
 
 /*  Return true if T is a GIMPLE condition.  */
@@ -2851,6 +2857,7 @@
   return (TREE_CODE (t) == VAR_DECL
 	  || TREE_CODE (t) == PARM_DECL
 	  || TREE_CODE (t) == RESULT_DECL
+	  || TREE_CODE (t) == STATIC_CHAIN_DECL
 	  || TREE_CODE (t) == SSA_NAME);
 }
 
--- a/src/gcc/gimple.h	2009-05-18 11:13:43.000000000 +0100
+++ b/src/gcc/gimple.h	2010-08-26 17:13:05.722133148 +0100
@@ -65,7 +65,7 @@
     const_gimple __gs = (GS);						\
     if (gimple_code (__gs) != (CODE))					\
       gimple_check_failed (__gs, __FILE__, __LINE__, __FUNCTION__,	\
-	  		   (CODE), 0);					\
+	  		   (CODE), ERROR_MARK);				\
   } while (0)
 #else  /* not ENABLE_GIMPLE_CHECKING  */
 #define GIMPLE_CHECK(GS, CODE)			(void)0
@@ -2216,7 +2216,7 @@
 gimple_cond_code (const_gimple gs)
 {
   GIMPLE_CHECK (gs, GIMPLE_COND);
-  return gs->gsbase.subcode;
+  return (enum tree_code) gs->gsbase.subcode;
 }
 
 
--- a/src/gcc/gimplify.c	2010-04-08 12:47:13.000000000 +0100
+++ b/src/gcc/gimplify.c	2010-08-26 17:13:05.734134534 +0100
@@ -6447,6 +6447,12 @@
 	    }
 	  break;
 
+	case STATIC_CHAIN_EXPR:
+	  /* The argument is used as information only.  No need to gimplify */
+	case STATIC_CHAIN_DECL:
+	  ret = GS_ALL_DONE;
+	  break;
+
 	case TREE_LIST:
 	  gcc_unreachable ();
 
--- a/src/gcc/ipa-cp.c	2009-12-27 22:39:58.000000000 +0000
+++ b/src/gcc/ipa-cp.c	2010-08-26 17:13:05.738152434 +0100
@@ -1393,7 +1393,7 @@
   return flag_ipa_cp;
 }
 
-struct ipa_opt_pass pass_ipa_cp = 
+struct ipa_opt_pass_d pass_ipa_cp = 
 {
  {
   IPA_PASS,
--- a/src/gcc/ipa-inline.c	2010-02-08 14:10:15.000000000 +0000
+++ b/src/gcc/ipa-inline.c	2010-08-26 17:13:05.742147425 +0100
@@ -1753,7 +1753,7 @@
   return todo | execute_fixup_cfg ();
 }
 
-struct ipa_opt_pass pass_ipa_inline = 
+struct ipa_opt_pass_d pass_ipa_inline = 
 {
  {
   IPA_PASS,
--- a/src/gcc/ipa-pure-const.c	2008-09-18 18:28:40.000000000 +0100
+++ b/src/gcc/ipa-pure-const.c	2010-08-26 17:13:05.746146816 +0100
@@ -910,7 +910,7 @@
 	  && !(errorcount || sorrycount));
 }
 
-struct ipa_opt_pass pass_ipa_pure_const =
+struct ipa_opt_pass_d pass_ipa_pure_const =
 {
  {
   IPA_PASS,
--- a/src/gcc/ipa-reference.c	2008-09-18 18:28:40.000000000 +0100
+++ b/src/gcc/ipa-reference.c	2010-08-26 17:13:05.746146816 +0100
@@ -1257,7 +1257,7 @@
 	  && !(errorcount || sorrycount));
 }
 
-struct ipa_opt_pass pass_ipa_reference =
+struct ipa_opt_pass_d pass_ipa_reference =
 {
  {
   IPA_PASS,
--- a/src/gcc/passes.c	2009-02-20 15:20:38.000000000 +0000
+++ b/src/gcc/passes.c	2010-08-26 17:13:05.750140201 +0100
@@ -1146,14 +1146,14 @@
 static void
 add_ipa_transform_pass (void *data)
 {
-  struct ipa_opt_pass *ipa_pass = (struct ipa_opt_pass *) data;
+  struct ipa_opt_pass_d *ipa_pass = (struct ipa_opt_pass_d *) data;
   VEC_safe_push (ipa_opt_pass, heap, cfun->ipa_transforms_to_apply, ipa_pass);
 }
 
 /* Execute summary generation for all of the passes in IPA_PASS.  */
 
 static void
-execute_ipa_summary_passes (struct ipa_opt_pass *ipa_pass)
+execute_ipa_summary_passes (struct ipa_opt_pass_d *ipa_pass)
 {
   while (ipa_pass)
     {
@@ -1167,7 +1167,7 @@
 	  ipa_pass->generate_summary ();
 	  pass_fini_dump_file (pass);
 	}
-      ipa_pass = (struct ipa_opt_pass *)ipa_pass->pass.next;
+      ipa_pass = (struct ipa_opt_pass_d *)ipa_pass->pass.next;
     }
 }
 
@@ -1175,7 +1175,7 @@
 
 static void
 execute_one_ipa_transform_pass (struct cgraph_node *node,
-				struct ipa_opt_pass *ipa_pass)
+				struct ipa_opt_pass_d *ipa_pass)
 {
   struct opt_pass *pass = &ipa_pass->pass;
   unsigned int todo_after = 0;
@@ -1347,7 +1347,7 @@
 	    {
 	      if (!quiet_flag && !cfun)
 		fprintf (stderr, " <summary generate>");
-	      execute_ipa_summary_passes ((struct ipa_opt_pass *) pass);
+	      execute_ipa_summary_passes ((struct ipa_opt_pass_d *) pass);
 	    }
 	  summaries_generated = true;
 	}
--- a/src/gcc/system.h	2008-07-28 15:33:56.000000000 +0100
+++ b/src/gcc/system.h	2010-08-26 17:13:05.754132398 +0100
@@ -786,6 +786,9 @@
    change after the fact).  Beyond these uses, most other cases of
    using this macro should be viewed with extreme caution.  */
 
+#ifdef __cplusplus
+#define CONST_CAST2(TOTYPE,FROMTYPE,X) (const_cast<TOTYPE> (X))
+#else
 #if defined(__GNUC__) && GCC_VERSION > 4000
 /* GCC 4.0.x has a bug where it may ICE on this expression,
    so does GCC 3.4.x (PR17436).  */
@@ -793,6 +796,7 @@
 #else
 #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)(FROMTYPE)(X))
 #endif
+#endif
 #define CONST_CAST(TYPE,X) CONST_CAST2(TYPE, const TYPE, (X))
 #define CONST_CAST_TREE(X) CONST_CAST(union tree_node *, (X))
 #define CONST_CAST_RTX(X) CONST_CAST(struct rtx_def *, (X))
--- a/src/gcc/tree.def	2009-02-20 15:20:38.000000000 +0000
+++ b/src/gcc/tree.def	2010-08-26 17:13:05.758136609 +0100
@@ -554,6 +554,13 @@
    arguments to the call.  */
 DEFTREECODE (CALL_EXPR, "call_expr", tcc_vl_exp, 3)
 
+/* Operand 0 is the FUNC_DECL of the outer function for
+   which the static chain is to be computed. */
+DEFTREECODE (STATIC_CHAIN_EXPR, "static_chain_expr", tcc_expression, 1)
+    
+/* Represents a function's static chain.  It can be used as an lvalue. */
+DEFTREECODE (STATIC_CHAIN_DECL, "static_chain_decl", tcc_expression, 0)
+
 /* Specify a value to compute along with its corresponding cleanup.
    Operand 0 is the cleanup expression.
    The cleanup is executed by the first enclosing CLEANUP_POINT_EXPR,
--- a/src/gcc/tree-dump.c	2008-08-06 16:57:09.000000000 +0100
+++ b/src/gcc/tree-dump.c	2010-08-26 17:13:05.770134642 +0100
@@ -639,6 +639,10 @@
       }
       break;
 
+    case STATIC_CHAIN_EXPR:
+      dump_child ("func", TREE_OPERAND (t, 0));
+      break;
+
     case CONSTRUCTOR:
       {
 	unsigned HOST_WIDE_INT cnt;
--- a/src/gcc/tree-nested.c	2010-04-20 09:37:12.000000000 +0100
+++ b/src/gcc/tree-nested.c	2010-08-26 17:13:05.774146186 +0100
@@ -714,6 +714,8 @@
 
   if (info->context == target_context)
     {
+      /* might be doing something wrong to need the following line.. */
+      get_frame_type (info);
       x = build_addr (info->frame_decl, target_context);
     }
   else
@@ -1761,6 +1763,10 @@
       if (DECL_NO_STATIC_CHAIN (decl))
 	break;
 
+      /* Don't use a trampoline for a static reference. */
+      if (TREE_STATIC (t))
+	break;
+
       /* If we don't want a trampoline, then don't build one.  */
       if (TREE_NO_TRAMPOLINE (t))
 	break;
@@ -1908,6 +1914,25 @@
       walk_body (convert_gimple_call, NULL, info, gimple_omp_body (stmt));
       break;
 
+    case GIMPLE_ASSIGN:
+      /* Deal with static_chain_decl */
+      decl = gimple_op(stmt, 0);
+      if (TREE_CODE (decl) == STATIC_CHAIN_DECL)
+	{
+	  tree chain = get_chain_decl (info);
+	  gimple_assign_set_lhs (stmt, chain);
+	  break;
+	}
+      /* Deal with static_chain_expr */
+      decl = gimple_op(stmt, 1);
+      if (TREE_CODE (decl) == STATIC_CHAIN_EXPR)
+	{
+	  tree chain = get_static_chain (info, TREE_OPERAND (decl, 0), &wi->gsi);
+	  gimple_assign_set_rhs1 (stmt, chain);
+	  break;
+	}
+      /* FALLTHRU */
+
     default:
       /* Keep looking for other operands.  */
       *handled_ops_p = false;
@@ -2054,8 +2079,38 @@
       gimple bind;
       annotate_all_with_location (stmt_list, DECL_SOURCE_LOCATION (context));
       bind = gimple_seq_first_stmt (gimple_body (context));
-      gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind));
-      gimple_bind_set_body (bind, stmt_list);
+
+      if (DECL_STRUCT_FUNCTION (root->context)->custom_static_chain)
+	{
+	  /* This chicanery is needed to make sure the GIMPLE initialization
+	     statements are in the right order
+
+	     CHAIN.3 = D.1614;
+	     FRAME.0.__chain = CHAIN.3;
+	     FRAME.0.m = m;
+	   */
+	  gimple_stmt_iterator gsi =
+	      gsi_start (gimple_bind_body (bind));
+	  int found = 0;
+	  while (!gsi_end_p (gsi))
+	    {
+	      gimple g = gsi_stmt (gsi);
+	      if (gimple_code (g) == GIMPLE_ASSIGN &&
+		  gimple_op (g, 0) == root->chain_decl)
+		{
+		  gsi_insert_seq_after (& gsi, stmt_list, GSI_SAME_STMT);
+		  found = 1;
+		  break;
+		}
+	      gsi_next (& gsi);
+	    }
+	  gcc_assert (found);
+	}
+      else
+	{
+	  gimple_seq_add_seq (&stmt_list, gimple_bind_body (bind));
+	  gimple_bind_set_body (bind, stmt_list);
+	}
     }
 
   /* If a chain_decl was created, then it needs to be registered with
--- a/src/gcc/tree-pass.h	2009-02-20 15:20:38.000000000 +0000
+++ b/src/gcc/tree-pass.h	2010-08-26 17:13:05.774146186 +0100
@@ -157,7 +157,7 @@
 
 /* Description of IPA pass with generate summary, write, execute, read and
    transform stages.  */
-struct ipa_opt_pass
+struct ipa_opt_pass_d
 {
   struct opt_pass pass;
 
@@ -390,10 +390,10 @@
 extern struct gimple_opt_pass pass_reset_cc_flags;
 
 /* IPA Passes */
-extern struct ipa_opt_pass pass_ipa_inline;
-extern struct ipa_opt_pass pass_ipa_cp;
-extern struct ipa_opt_pass pass_ipa_reference;
-extern struct ipa_opt_pass pass_ipa_pure_const;
+extern struct ipa_opt_pass_d pass_ipa_inline;
+extern struct ipa_opt_pass_d pass_ipa_cp;
+extern struct ipa_opt_pass_d pass_ipa_reference;
+extern struct ipa_opt_pass_d pass_ipa_pure_const;
 
 extern struct simple_ipa_opt_pass pass_ipa_matrix_reorg;
 extern struct simple_ipa_opt_pass pass_ipa_early_inline;
--- a/src/gcc/tree-pretty-print.c	2009-02-18 21:03:05.000000000 +0000
+++ b/src/gcc/tree-pretty-print.c	2010-08-26 17:13:05.778131469 +0100
@@ -1216,6 +1216,16 @@
 	pp_string (buffer, " [tail call]");
       break;
 
+    case STATIC_CHAIN_EXPR:
+      pp_string (buffer, "<<static chain of ");
+      dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
+      pp_string (buffer, ">>");
+      break;
+
+    case STATIC_CHAIN_DECL:
+      pp_string (buffer, "<<static chain decl>>");
+      break;
+
     case WITH_CLEANUP_EXPR:
       NIY;
       break;
--- a/src/gcc/tree-sra.c	2010-04-18 16:56:32.000000000 +0100
+++ b/src/gcc/tree-sra.c	2010-08-26 17:13:05.786133185 +0100
@@ -263,6 +263,8 @@
     case RECORD_TYPE:
       {
 	bool saw_one_field = false;
+	tree last_offset = size_zero_node;
+	tree cmp;
 
 	for (t = TYPE_FIELDS (type); t ; t = TREE_CHAIN (t))
 	  if (TREE_CODE (t) == FIELD_DECL)
@@ -274,6 +276,12 @@
 		      != TYPE_PRECISION (TREE_TYPE (t))))
 		goto fail;
 
+	      /* Reject aliased fields created by GDC for anonymous unions. */
+	      cmp = fold_binary_to_constant (LE_EXPR, boolean_type_node,
+					     DECL_FIELD_OFFSET (t), last_offset);
+	      if (cmp == NULL_TREE || tree_expr_nonzero_p (cmp))
+		goto fail;
+
 	      saw_one_field = true;
 	    }
 
--- a/src/gcc/tree-ssa.c	2009-08-03 20:27:32.000000000 +0100
+++ b/src/gcc/tree-ssa.c	2010-08-26 17:13:05.790130062 +0100
@@ -1094,8 +1094,10 @@
       && TYPE_CANONICAL (inner_type) == TYPE_CANONICAL (outer_type))
     return true;
 
-  /* Changes in machine mode are never useless conversions.  */
-  if (TYPE_MODE (inner_type) != TYPE_MODE (outer_type))
+  /* Changes in machine mode are never useless conversions unless we
+     deal with aggregate types in which case we defer to later checks.  */
+  if (TYPE_MODE (inner_type) != TYPE_MODE (outer_type)
+      && !AGGREGATE_TYPE_P (inner_type))
     return false;
 
   /* If both the inner and outer types are integral types, then the