Fix previous compiler crash without breaking functions with auto return types
[delight/core.git] / patches / patch-gcc-3.4.x
blob06fb5139cd480fde41d0131df6ea31e72d82ec80
1 diff -c gcc-orig/gcc.c gcc/gcc.c
2 *** gcc-orig/gcc.c      Sat Jan 21 13:52:11 2006
3 --- gcc/gcc.c   Thu Mar  1 10:48:46 2007
4 ***************
5 *** 133,138 ****
6 --- 133,141 ----
7   /* Flag set by cppspec.c to 1.  */
8   int is_cpp_driver;
9   
10 + /* Flag set by drivers needing Pthreads. */
11 + int need_pthreads;
12
13   /* Flag saying to pass the greatest exit code returned by a sub-process
14      to the calling program.  */
15   static int pass_exit_codes;
16 ***************
17 *** 464,469 ****
18 --- 467,473 ----
19         assembler has done its job.
20    %D   Dump out a -L option for each directory in startfile_prefixes.
21         If multilib_dir is set, extra entries are generated with it affixed.
22 +  %N     Output the currently selected multilib directory name.
23    %l     process LINK_SPEC as a spec.
24    %L     process LIB_SPEC as a spec.
25    %G     process LIBGCC_SPEC as a spec.
26 ***************
27 *** 3738,3743 ****
28 --- 3742,3750 ----
29   
30     combine_inputs = (have_c && have_o && lang_n_infiles > 1);
31   
32 +   if (need_pthreads)
33 +       n_switches++;
34
35     if ((save_temps_flag || report_times) && use_pipes)
36       {
37         /* -save-temps overrides -pipe, so that temp files are produced */
38 ***************
39 *** 4080,4085 ****
40 --- 4087,4104 ----
41         }
42       }
43   
44 +   if (need_pthreads)
45 +     {
46 +       switches[n_switches].part1 = "pthread";
47 +       switches[n_switches].args = 0;
48 +       switches[n_switches].live_cond = SWITCH_OK;
49 +       /* Do not print an error if there is not expansion for -pthread. */
50 +       switches[n_switches].validated = 1;
51 +       switches[n_switches].ordering = 0;
52
53 +       n_switches++;
54 +     }
55
56     switches[n_switches].part1 = 0;
57     infiles[n_infiles].name = 0;
58   }
59 ***************
60 *** 5041,5046 ****
61 --- 5060,5076 ----
62               return value;
63             break;
64   
65 +         case 'N':
66 +           if (multilib_dir)
67 +             {
68 +               arg_going = 1;
69 +               obstack_grow (&obstack, "-fmultilib-dir=",
70 +                             strlen ("-fmultilib-dir="));
71 +               obstack_grow (&obstack, multilib_dir,
72 +                             strlen (multilib_dir));
73 +             }
74 +           break;
75
76             /* Here we define characters other than letters and digits.  */
77   
78           case '{':
79 diff -cr gcc-orig/gcc.c gcc/gcc.h
80 *** gcc-orig/gcc.h Fri Jun 24 22:02:01 2005
81 --- gcc/gcc.h       Sun Mar  4 13:44:05 2007
82 ***************
83 *** 38,44 ****
84      || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \
85      || (CHAR) == 'I' || (CHAR) == 'm' || (CHAR) == 'x' \
86      || (CHAR) == 'L' || (CHAR) == 'A' || (CHAR) == 'V' \
87 !    || (CHAR) == 'B' || (CHAR) == 'b')
88   
89   /* This defines which multi-letter switches take arguments.  */
90   
91 --- 38,44 ----
92      || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \
93      || (CHAR) == 'I' || (CHAR) == 'm' || (CHAR) == 'x' \
94      || (CHAR) == 'L' || (CHAR) == 'A' || (CHAR) == 'V' \
95 !    || (CHAR) == 'B' || (CHAR) == 'b' || (CHAR) == 'J')
96   
97   /* This defines which multi-letter switches take arguments.  */
98   
99 diff -c gcc-gcc-3.4.0-orig/real.h gcc-gcc-3.4.0/real.h
100 *** gcc-gcc-3.4.0-orig/real.h   Fri Oct 10 20:33:05 2003
101 --- gcc-gcc-3.4.0/real.h        Mon Sep 27 14:06:40 2004
102 ***************
103 *** 40,48 ****
104   #define SIGSZ                 (SIGNIFICAND_BITS / HOST_BITS_PER_LONG)
105   #define SIG_MSB                       ((unsigned long)1 << (HOST_BITS_PER_LONG - 1))
106   
107   struct real_value GTY(())
108   {
109 !   ENUM_BITFIELD (real_value_class) class : 2;
110     unsigned int sign : 1;
111     unsigned int signalling : 1;
112     unsigned int canonical : 1;
113 --- 40,56 ----
114   #define SIGSZ                 (SIGNIFICAND_BITS / HOST_BITS_PER_LONG)
115   #define SIG_MSB                       ((unsigned long)1 << (HOST_BITS_PER_LONG - 1))
116   
117 + /* Can't have "class" in C++, but gentype gets confused on #ifdefs
118 +    within the struct. */
119 + #ifndef __cplusplus
120 + # define REAL_CLASSY class
121 + #else
122 + # define REAL_CLASSY cl
123 + #endif
125   struct real_value GTY(())
126   {
127 !   ENUM_BITFIELD (real_value_class) REAL_CLASSY : 2;
128     unsigned int sign : 1;
129     unsigned int signalling : 1;
130     unsigned int canonical : 1;
131 ***************
132 *** 50,55 ****
133 --- 58,65 ----
134     unsigned long sig[SIGSZ];
135   };
136   
137 + #undef REAL_CLASSY
139   /* Various headers condition prototypes on #ifdef REAL_VALUE_TYPE, so it
140      needs to be a macro.  We do need to continue to have a structure tag
141      so that other headers can forward declare it.  */
142 diff -c gcc-gcc-3.4.0-orig/rtl.h gcc-gcc-3.4.0/rtl.h
143 *** gcc-gcc-3.4.0-orig/rtl.h    Thu Mar 25 16:44:43 2004
144 --- gcc-gcc-3.4.0/rtl.h Mon Sep 27 14:06:40 2004
145 ***************
146 *** 121,128 ****
147 --- 121,133 ----
148     int rtint;
149     unsigned int rtuint;
150     const char *rtstr;
151 + #ifndef __cplusplus
152     rtx rtx;
153     rtvec rtvec;
154 + #else
155 +   rtx rt_rtx;
156 +   rtvec rt_vec;
157 + #endif
158     enum machine_mode rttype;
159     addr_diff_vec_flags rt_addr_diff_vec_flags;
160     struct cselib_val_struct *rt_cselib;
161 *** gcc-orig/libgcc2.c  Sun Sep 26 16:47:14 2004
162 --- gcc/libgcc2.c       Sat May  7 11:47:55 2005
163 ***************
164 *** 29,34 ****
165 --- 29,45 ----
166   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
167   02111-1307, USA.  */
168   
169 + #ifdef L_eprintf
170 + #ifdef __APPLE__
171 + /* Hack for MacOS 10.4: gcc 3.4.x uses -mlong-double-128 to build
172 +    libgcc.  On 10.4, this causes *printf to be defined as
173 +    *printf$LDBLStub and requires linking with libSystemStubs.  Prevent
174 +    this from happening by making it seem as though double is the same
175 +    as long double. */
176 + #undef  __LDBL_MANT_DIG__
177 + #define __LDBL_MANT_DIG__ __DBL_MANT_DIG__
178 + #endif
179 + #endif
180   
181   /* We include auto-host.h here to get HAVE_GAS_HIDDEN.  This is
182      supposedly valid even though this is a "target" file.  */
183 *** gcc-orig/config/rs6000/rs6000.c     Fri Oct 22 15:19:35 2004
184 --- gcc/config/rs6000/rs6000.c  Sat May 21 16:08:37 2005
185 ***************
186 *** 12973,12979 ****
187          use language_string.
188          C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
189          Java is 13.  Objective-C is 14.  */
190 !       if (! strcmp (language_string, "GNU C"))
191         i = 0;
192         else if (! strcmp (language_string, "GNU F77"))
193         i = 1;
194 --- 12973,12980 ----
195          use language_string.
196          C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
197          Java is 13.  Objective-C is 14.  */
198 !       if (! strcmp (language_string, "GNU C") ||
199 !         ! strcmp (language_string, "GNU D"))
200         i = 0;
201         else if (! strcmp (language_string, "GNU F77"))
202         i = 1;
203 diff -c gcc-orig/function.c gcc/function.c
204 *** gcc-orig/function.c Wed May 11 17:19:49 2005
205 --- gcc/function.c      Thu Jun  9 19:53:27 2005
206 ***************
207 *** 6670,6680 ****
208       {
209         last_ptr = assign_stack_local (Pmode, GET_MODE_SIZE (Pmode), 0);
210   
211 !       /* Delay copying static chain if it is not a register to avoid
212 !        conflicts with regs used for parameters.  */
213 !       if (! SMALL_REGISTER_CLASSES
214 !         || GET_CODE (static_chain_incoming_rtx) == REG)
215 !       emit_move_insn (last_ptr, static_chain_incoming_rtx);
216       }
217   
218     /* If the parameters of this function need cleaning up, get a label
219 --- 6670,6683 ----
220       {
221         last_ptr = assign_stack_local (Pmode, GET_MODE_SIZE (Pmode), 0);
222   
223 !       if (cfun->static_chain_expr == NULL_TREE)
224 !         {
225 !         /* Delay copying static chain if it is not a register to avoid
226 !            conflicts with regs used for parameters.  */
227 !         if (! SMALL_REGISTER_CLASSES
228 !             || GET_CODE (static_chain_incoming_rtx) == REG)
229 !           emit_move_insn (last_ptr, static_chain_incoming_rtx);
230 !       }
231       }
232   
233     /* If the parameters of this function need cleaning up, get a label
234 ***************
235 *** 6762,6771 ****
236   
237     /* Copy the static chain now if it wasn't a register.  The delay is to
238        avoid conflicts with the parameter passing registers.  */
240 !   if (SMALL_REGISTER_CLASSES && current_function_needs_context)
241 !     if (GET_CODE (static_chain_incoming_rtx) != REG)
242 !       emit_move_insn (last_ptr, static_chain_incoming_rtx);
243   
244     /* The following was moved from init_function_start.
245        The move is supposed to make sdb output more accurate.  */
246 --- 6765,6776 ----
247   
248     /* Copy the static chain now if it wasn't a register.  The delay is to
249        avoid conflicts with the parameter passing registers.  */
250 !   if (cfun->static_chain_expr == NULL_TREE)
251 !     {
252 !       if (SMALL_REGISTER_CLASSES && current_function_needs_context)
253 !       if (GET_CODE (static_chain_incoming_rtx) != REG)
254 !         emit_move_insn (last_ptr, static_chain_incoming_rtx);
255 !     }
256   
257     /* The following was moved from init_function_start.
258        The move is supposed to make sdb output more accurate.  */
259 ***************
260 *** 6790,6799 ****
261           /* If the static chain originally came in a register, put it back
262              there, then move it out in the next insn.  The reason for
263              this peculiar code is to satisfy function integration.  */
264 !         if (SMALL_REGISTER_CLASSES
265 !             && GET_CODE (static_chain_incoming_rtx) == REG)
266 !           emit_move_insn (static_chain_incoming_rtx, last_ptr);
267 !         last_ptr = copy_to_reg (static_chain_incoming_rtx);
268         }
269   
270         while (tem)
271 --- 6795,6815 ----
272           /* If the static chain originally came in a register, put it back
273              there, then move it out in the next insn.  The reason for
274              this peculiar code is to satisfy function integration.  */
275 !         if (cfun->static_chain_expr == NULL_TREE)
276 !           {
277 !             if (SMALL_REGISTER_CLASSES
278 !                 && GET_CODE (static_chain_incoming_rtx) == REG)
279 !               emit_move_insn (static_chain_incoming_rtx, last_ptr);
280 !             last_ptr = copy_to_reg (static_chain_incoming_rtx);
281 !           }
282 !         else
283 !           {
284 !               rtx r = expand_expr_real (cfun->static_chain_expr, NULL_RTX,
285 !                   VOIDmode, EXPAND_NORMAL, NULL);
286 !               r = copy_to_reg (r);
287 !               emit_move_insn (last_ptr, r);
288 !               last_ptr = r;
289 !           }
290         }
291   
292         while (tem)
293 diff -c gcc-orig/function.h gcc/function.h
294 *** gcc-orig/function.h Wed May  5 19:24:30 2004
295 --- gcc/function.h      Wed Jun  8 18:46:24 2005
296 ***************
297 *** 517,522 ****
298 --- 517,526 ----
299   
300     /* Nonzero if the rtl inliner has saved the function for inlining.  */
301     unsigned int saved_for_inline : 1;
303 +   /* Expression to be evaluated to get the static chain.  If NULL,
304 +      static_chain_incoming_rtx is used. */
305 +   tree static_chain_expr;
306   };
307   
308   /* The function currently being compiled.  */
309 diff -cr gcc-orig/dwarf2.h gcc/dwarf2.h
310 *** gcc-orig/dwarf2.h   Thu Jan  8 07:50:36 2004
311 --- gcc/dwarf2.h        Thu Sep 22 13:21:47 2005
312 ***************
313 *** 591,596 ****
314 --- 591,597 ----
315       DW_LANG_C99 = 0x000c,
316       DW_LANG_Ada95 = 0x000d,
317       DW_LANG_Fortran95 = 0x000e,
318 +     DW_LANG_D = 0x0013,
319       /* MIPS.  */
320       DW_LANG_Mips_Assembler = 0x8001
321     };
322 diff -cr gcc-orig/dwarf2out.c gcc/dwarf2out.c
323 *** gcc-orig/dwarf2out.c        Mon Oct 25 21:46:45 2004
324 --- gcc/dwarf2out.c     Thu Sep 22 13:23:12 2005
325 ***************
326 *** 4979,4985 ****
327     unsigned int lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
328   
329     return (lang == DW_LANG_C || lang == DW_LANG_C89
330 !         || lang == DW_LANG_C_plus_plus);
331   }
332   
333   /* Return TRUE if the language is C++.  */
334 --- 4979,4986 ----
335     unsigned int lang = get_AT_unsigned (comp_unit_die, DW_AT_language);
336   
337     return (lang == DW_LANG_C || lang == DW_LANG_C89
338 !         || lang == DW_LANG_C_plus_plus
339 !         || lang == DW_LANG_D);
340   }
341   
342   /* Return TRUE if the language is C++.  */
343 ***************
344 *** 11403,11408 ****
345 --- 11404,11411 ----
346       language = DW_LANG_Pascal83;
347     else if (strcmp (language_string, "GNU Java") == 0)
348       language = DW_LANG_Java;
349 +   else if (strcmp (language_string, "GNU D") == 0)
350 +     language = DW_LANG_D;
351     else
352       language = DW_LANG_C89;
353   
354 ***************
355 *** 13061,13067 ****
356             add_child_die (comp_unit_die, die);
357           else if (node->created_for
358                    && ((DECL_P (node->created_for)
359 !                       && (context = DECL_CONTEXT (node->created_for)))
360                        || (TYPE_P (node->created_for)
361                            && (context = TYPE_CONTEXT (node->created_for))))
362                    && TREE_CODE (context) == FUNCTION_DECL)
363 --- 13064,13070 ----
364             add_child_die (comp_unit_die, die);
365           else if (node->created_for
366                    && ((DECL_P (node->created_for)
367 !                       && (context = decl_function_context (node->created_for)))
368                        || (TYPE_P (node->created_for)
369                            && (context = TYPE_CONTEXT (node->created_for))))
370                    && TREE_CODE (context) == FUNCTION_DECL)
371 diff -cr gcc-orig/config/i386/i386.c gcc/config/i386/i386.c
372 *** gcc-orig/config/i386/i386.c Wed Mar 16 10:23:40 2005
373 --- gcc/config/i386/i386.c      Sun Oct 30 10:10:39 2005
374 ***************
375 *** 15683,15689 ****
376           output_set_got (tmp);
377   
378           xops[1] = tmp;
379 !         output_asm_insn ("mov{l}\t{%0@GOT(%1), %1|%1, %0@GOT[%1]}", xops);
380           output_asm_insn ("jmp\t{*}%1", xops);
381         }
382       }
383 --- 15683,15689 ----
384           output_set_got (tmp);
385   
386           xops[1] = tmp;
387 !         output_asm_insn ("mov{l}\t{%a0@GOT(%1), %1|%1, %a0@GOT[%1]}", xops);
388           output_asm_insn ("jmp\t{*}%1", xops);
389         }
390       }