diff options
Diffstat (limited to 'gcc')
91 files changed, 2247 insertions, 860 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 63eed378b15..2a7913557ef 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,156 @@ +2012-10-04 Basile Starynkevitch <basile@starynkevitch.net> + + * gengtype.c (walk_type): Emit mark_hook when inside a + struct of a union member. + +2012-10-04 Georg-Johann Lay <avr@gjlay.de> + + * config/avr/predicates.md (flash_operand): New predicate. + * config/avr/avr.md (reload_in<mode>): Use it in operand 1 instead + of memory_operand. + +2012-10-04 Tobias Burnus <burnus@net-b.de> + + * gcc.c (record_temp_file, add_sysrooted_prefix, process_command, + do_self_spec, compare_debug_dump_opt_spec_function): Plug memleaks. + (do_spec_1): Ditto, fix out-of-bound access. + * opts.c (common_handle_option): Plug memleak. + +2012-10-04 Jason Merrill <jason@redhat.com> + + * config/darwin.c (darwin_assemble_visibility): Treat + VISIBILITY_INTERNAL as hidden. + + * config/darwin-c.c (find_subframework_file): Add missing const. + (framework_construct_pathname): Likewise. + +2012-10-04 Florian Weimer <fweimer@redhat.com> + + * doc/cpp.texi (Pragmas): Document #pragma GCC warning, #pragma + GCC error. + +2012-10-04 Richard Guenther <rguenther@suse.de> + + PR middle-end/54735 + * tree-ssa-pre.c (do_pre): Make sure to update virtual SSA form before + cleaning up the CFG. + +2012-10-04 Richard Guenther <rguenther@suse.de> + + PR lto/47799 + * tree-streamer-out.c (write_ts_block_tree_pointers): For + inlined functions outer scopes write the ultimate origin + as BLOCK_ABSTRACT_ORIGIN and BLOCK_SOURCE_LOCATION. + Do not stream the fragment chains. + * tree-streamer-in.c (lto_input_ts_block_tree_pointers): Likewise. + * dwarf2out.c (gen_subprogram_die): Handle NULL DECL_INITIAL. + (dwarf2out_decl): Always output DECL_ABSTRACT function decls. + +2012-10-04 Arnaud Charlet <charlet@adacore.com> + + * dumpfile.h, dumpfile.c: Remove TDI_ada. + +2012-10-04 Yuri Rumyantsev <ysrumyan@gmail.com> + + * config/i386/i386.c (ix86_dep_by_shift_count_body) : Add + check on reload_completed since it can be invoked before + register allocation phase in pre-reload schedule. + (ia32_multipass_dfa_lookahead) : Do not use dfa_lookahead for pre-reload + schedule to save compile time. + (ix86_sched_reorder) : Do not perform ready list reordering for pre-reload + schedule to save compile time. + (insn_is_function_arg) : New function. Returns true if lhs of insn is + HW function argument register. + (add_parameter_dependencies) : New function. Add output dependencies + for chain of function adjacent arguments if only there is a move to + likely spilled HW registers. Return first argument if at least one + dependence was added or NULL otherwise. + (avoid_func_arg_motion) : New function. Add output or anti dependency + from insn to first_arg to restrict code motion. + (add_dependee_for_func_arg) : New function. Avoid cross block motion of + function argument through adding dependency from the first non-jump + insn in bb. + (ix86_dependencies_evaluation_hook) : New function. Hook for pre-reload schedule: + avoid motion of function arguments passed in passed in likely spilled + HW registers. + (ix86_adjust_priority) : New function. Hook for pre-reload schedule: set priority + of moves from likely spilled HW registers to maximum to schedule them + as soon as possible. + (ix86_sched_init_global): Do not perform multipass scheduling for pre-reload + schedule to save compile time. + +2012-10-04 Uros Bizjak <ubizjak@gmail.com> + + * configure.ac (noexception_flags): Add -fasynchronous-unwind-tables. + * configure: Regenerate. + +2012-10-04 Kaz Kojima <kkojima@gcc.gnu.org> + + * config/sh/sh.c (sh_can_use_simple_return_p): Return false for + SHmedia and SHcompact using call cookie. + * config/sh/sh.md (epilogue): Emit non-inlined return insns for + SHmedia and SHcompact using call cookie. + +2012-10-03 Oleg Endo <olegendo@gcc.gnu.org> + + PR target/51244 + * config/sh/sh.md (*mov_t_msb_neg): New insn and two accompanying + unnamed split patterns. + +2012-10-03 Oleg Endo <olegendo@gcc.gnu.org> + + PR target/50457 + * config/sh/sh.c (parse_validate_atomic_model_option): Handle name + strings in sh_atomic_model. + * config/sh/sh.h (TARGET_CPU_CPP_BUILTINS): Move macro implementation + to ... + * config/sh/sh-c.c (sh_cpu_cpp_builtins): ... this new function. + Add __SH1__ and __SH2__ defines. Add __SH_ATOMIC_MODEL_*__ define. + * config/sh/sh-protos.h (sh_atomic_model): Add name and cdef_name + variables. + (sh_cpu_cpp_builtins): Declare new function. + +2012-10-03 Dehao Chen <dehao@google.com> + + PR middle-end/54782 + * tree-cfg.c (move_block_to_fn): Update lexical block for phi_args. + +2012-10-03 Vladimir Makarov <vmakarov@redhat.com> + + * reginfo.c (max_regno_since_last_resize): New. + (reg_preferred_class, reg_alternate_class): Add assert. + (allocate_reg_info): Initialize allocated reg info. + (resize_reg_info): Make bigger reg_info and initialize new memory. + (reginfo_init): Initialize max_regno_since_last_resize. + (setup_reg_classes): Change assert. + +2012-10-03 Andrew W. Nosenko <andrew.w.nosenko@gmail.com> + + * config/i386/driver-i386.c (host_detect_local_cpu): Fix logic + in SSE and YMM state support check for -march=native. + +2012-10-03 Nick Clifton <nickc@redhat.com> + + * config/rx/rx.c (struct decl_chain): New local structure. + (warned_decls): New local variable. Contains a stack of decls for + which warnings have been issued. + (add_warned_decl): Adds a decl to the stack. + (already_warned): Returns true if a given decl is on the stack. + (rx_set_current_function): Issue a warning if multiple fast + interrupt handlers are defined. + * config/rx/rx.opt (mwarn-multiple-fast-interrupts): New option. + * doc/invoke.texi: Document the option. + +2012-09-03 Mark Kettenis <kettenis@openbsd.org> + + * config.gcc (*-*-openbsd4.[3-9]|*-*-openbsd[5-9]*): Set + default_use_cxa_atexit to yes. + +2012-10-03 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/54792 + * sched-deps.c (find_modifiable_mems): Scan also TAIL insn. + 2012-10-02 H.J. Lu <hongjiu.lu@intel.com> PR target/54785 @@ -57,7 +210,7 @@ 2012-10-02 H.J. Lu <hongjiu.lu@intel.com> PR target/54741 - * config/i386/driver-i386.c (XCR_XFEATURE_ENABLED_MASK): New. + * config/i386/driver-i386.c (XCR_XFEATURE_ENABLED_MASK): New. (XSTATE_FP): Likewise. (XSTATE_SSE): Likewise. (XSTATE_YMM): Likewise. @@ -121,9 +274,8 @@ * tree-ssa-sccvn.c (vn_reference_lookup_3): For VECTOR_TYPE CONSTRUCTORs, don't do anything if element type is VECTOR_TYPE, and don't check index. - * tree-vect-slp.c (vect_get_constant_vectors): VIEW_CONVERT_EXPR - ctor elements first if their type isn't compatible with vector - element type. + * tree-vect-slp.c (vect_get_constant_vectors): VIEW_CONVERT_EXPR ctor + elements first if their type isn't compatible with vector element type. 2012-10-02 Eric Botcazou <ebotcazou@adacore.com> diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index a63335804c8..392af5d642f 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20121003 +20121004 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d11055f81db..8196e94e8ad 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,132 @@ +2012-10-04 Robert Dewar <dewar@adacore.com> + + * sem_res.adb (Resolve_Set_Membership): Warn on duplicates. + +2012-10-04 Emmanuel Briot <briot@adacore.com> + + * g-comlin.adb (Getopt): Fix value of Full_Switch returned in case of + invalid switch. + +2012-10-04 Arnaud Charlet <charlet@adacore.com> + + * gcc-interface/Make-lang.in: Update dependencies. + +2012-10-04 Robert Dewar <dewar@adacore.com> + + * sem_eval.adb (Fold_Str, Fold_Uint, Fold_Ureal): Reset static + expression state after Resolve call. + +2012-10-04 Robert Dewar <dewar@adacore.com> + + * sem_prag.adb (Analyze_Pragma. case Warnngs): Don't make entry + in the table for Warnings Off pragmas if within an instance. + +2012-10-04 Ed Schonberg <schonberg@adacore.com> + + * sem_ch9.adb (Analyze_Entry_Body): Transfer + Has_Pragma_Unreferenced flag from entry formal to corresponding + entity in body, to prevent spurious warnings when pragma is + present. + +2012-10-04 Robert Dewar <dewar@adacore.com> + + * s-bignum.adb (Big_Exp): Raise Storage_Error for ludicrously + large results. + +2012-10-04 Ed Schonberg <schonberg@adacore.com> + + * sem_ch3.adb (Check_Duplicate_Aspects): Diagnose properly + aspects that appear in the partial and the full view of a type. + +2012-10-04 Robert Dewar <dewar@adacore.com> + + * sinfo.ads (N_Return_Statement): Removed. + +2012-10-04 Tristan Gingold <gingold@adacore.com> + + * init.c (__gl_zero_cost_exceptions): Comment it as not used + anymore. + * bindgen.adb (Gen_Adainit): Do not emit Zero_Cost_Exceptions + anymore. + +2012-10-04 Thomas Quinot <quinot@adacore.com> + + * prep.adb, prepcomp.adb, gprep.adb, opt.ads: New preprocessor switch + -a (all source text preserved). + +2012-10-04 Vincent Celier <celier@adacore.com> + + * prj-proc.adb (Recursive_Process): Use project directory + display path name as the value of 'Project_Dir. + +2012-10-04 Robert Dewar <dewar@adacore.com> + + * exp_ch4.adb (Expand_Compare_Minimize_Eliminate_Overflow): + Deal with case where we get a bignum operand and cannot do a + range analysis. + * sem_eval.adb (Why_Not_Static): Deal with bignum operands + +2012-10-04 Ed Schonberg <schonberg@adacore.com> + + * sem_ch4.adb (Find_Unary_Types): Within an instance, an + interpretation that involves a predefied arithmetic operator is + not a candidate if the corresponding generic formal type is not + a numeric type. + * sem_util.ads, sem_util.adb (Corresonding_Generic_Type): If a + type is a generic actual type within an instance, return the + corresponding formal in the generic unit, otherwise return + Any_Type. + +2012-10-04 Robert Dewar <dewar@adacore.com> + + * checks.adb (Minimize_Eliminate_Overflow_Checks): Dont reanalyze + if/case expression if nothing has changed (just reexpand). Stops + case expression from generating incorrect temporary. + * exp_ch4.adb (Expand_Compare_Minimize_Eliminate_Overflow): + Fix cut and paste typo for range analysis in NE (not equal) case. + * sem_eval.adb (Compile_Time_Compare): Small optimization to + catch some more cases. + * types.ads (Suppressed_Or_Checked): New subtype of + Overflow_Check_Type. + +2012-10-04 Javier Miranda <miranda@adacore.com> + + * exp_disp.adb (Set_CPP_Constructors_Old): Removed. + (Set_CPP_Constructors): Code cleanup. + +2012-10-04 Ed Schonberg <schonberg@adacore.com> + + * sem_ch10.adb (Is_Ancestor_Unit): Make global, for use elsewhere. + (Install_Private_with_Clauses): if clause is private and limited, + do not install the limited view if the library unit is an ancestor + of the unit being compiled. This unusual configuration occurs + when compiling a unit DDP, when an ancestor P of DDP has a + private limited with clause on a descendant of P that is itself + an ancestor of DDP. + +2012-10-04 Vincent Celier <celier@adacore.com> + + * prj-proc.adb (Process_Package_Declaration): Use project + directory display path name as the value of 'Project_Dir. + +2012-10-04 Gary Dismukes <dismukes@adacore.com> + + * exp_util.adb (Build_Allocate_Deallocate_Proc): The subpool can be + given by an arbitrary name, so copy the tree to make the call's actual. + +2012-10-04 Robert Dewar <dewar@adacore.com> + + * s-exnllf.adb, s-exnllf.ads: Minor reformatting. + +2012-10-04 Thomas Quinot <quinot@adacore.com> + + * exp_ch6.adb: Minor reformatting. + +2012-10-04 Pascal Obry <obry@adacore.com> + + * projects.texi: Use consistently @command{} when referencing + commands. Fix typos. + 2012-10-03 Ed Schonberg <schonberg@adacore.com> * sem_ch6.adb (New_Overloaded_Entity): call diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb index 094b25da42e..bb5a0aac906 100644 --- a/gcc/ada/bindgen.adb +++ b/gcc/ada/bindgen.adb @@ -137,7 +137,6 @@ package body Bindgen is -- Num_Interrupt_States : Integer; -- Unreserve_All_Interrupts : Integer; -- Exception_Tracebacks : Integer; - -- Zero_Cost_Exceptions : Integer; -- Detect_Blocking : Integer; -- Default_Stack_Size : Integer; -- Leap_Seconds_Support : Integer; @@ -216,9 +215,6 @@ package body Bindgen is -- tracebacks are provided by default, so a value of zero for this -- parameter does not necessarily mean no trace backs are available. - -- Zero_Cost_Exceptions is set to one if zero cost exceptions are used for - -- this partition, and to zero if longjmp/setjmp exceptions are used. - -- Detect_Blocking indicates whether pragma Detect_Blocking is active or -- not. A value of zero indicates that the pragma is not present, while a -- value of 1 signals its presence in the partition. @@ -607,9 +603,6 @@ package body Bindgen is """__gl_exception_tracebacks"");"); end if; - WBI (" Zero_Cost_Exceptions : Integer;"); - WBI (" pragma Import (C, Zero_Cost_Exceptions, " & - """__gl_zero_cost_exceptions"");"); WBI (" Detect_Blocking : Integer;"); WBI (" pragma Import (C, Detect_Blocking, " & """__gl_detect_blocking"");"); @@ -803,17 +796,6 @@ package body Bindgen is WBI (" Exception_Tracebacks := 1;"); end if; - Set_String (" Zero_Cost_Exceptions := "); - - if Zero_Cost_Exceptions_Specified then - Set_String ("1"); - else - Set_String ("0"); - end if; - - Set_String (";"); - Write_Statement_Buffer; - Set_String (" Detect_Blocking := "); if Detect_Blocking then diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index d74a05c11fe..075eb14caeb 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -34,6 +34,7 @@ with Exp_Pakd; use Exp_Pakd; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Elists; use Elists; +with Expander; use Expander; with Eval_Fat; use Eval_Fat; with Freeze; use Freeze; with Lib; use Lib; @@ -1272,8 +1273,7 @@ package body Checks is Apply_Range_Check (N, Typ); end if; - elsif (Is_Record_Type (Typ) - or else Is_Private_Type (Typ)) + elsif (Is_Record_Type (Typ) or else Is_Private_Type (Typ)) and then Has_Discriminants (Base_Type (Typ)) and then Is_Constrained (Typ) then @@ -6709,10 +6709,12 @@ package body Checks is -- to be done in bignum mode), and the determined ranges of the operands. -- After possible rewriting of a constituent subexpression node, a call is - -- made to reanalyze the node after setting Analyzed to False. To avoid a - -- recursive call into the whole overflow apparatus, and important rule for - -- this reanalysis call is that either Do_Overflow_Check must be False, or - -- if it is set, then the overflow checking mode must be temporarily set + -- made to either reexpand the node (if nothing has changed) or reanalyze + -- the node (if it has been modified by the overflow check processing). + -- The Analyzed_flag is set False before the reexpand/reanalyze. To avoid + -- a recursive call into the whole overflow apparatus, and important rule + -- for this call is that either Do_Overflow_Check must be False, or if + -- it is set, then the overflow checking mode must be temporarily set -- to Checked/Suppressed. Either step will avoid the unwanted recursion. procedure Minimize_Eliminate_Overflow_Checks @@ -6761,6 +6763,17 @@ package body Checks is -- range, then we must convert such operands back to the result type. -- This switch is properly set only when Bignum_Operands is False. + procedure Reexpand (C : Suppressed_Or_Checked); + -- This is called when we have not modifed the node, so we do not need + -- to reanalyze it. But we do want to reexpand it in either CHECKED + -- or SUPPRESSED mode (as indicated by the argument C) to get proper + -- expansion. It is important that we reset the mode to SUPPRESSED or + -- CHECKED, since if we leave it in MINIMIZED or ELIMINATED mode we + -- would reenter this routine recursively which would not be good! + -- Note that this is not just an optimization, testing has showed up + -- several complex cases in which renalyzing an already analyzed node + -- causes incorrect behavior. + function In_Result_Range return Boolean; -- Returns True iff Lo .. Hi are within range of the result type @@ -6813,6 +6826,24 @@ package body Checks is end if; end Min; + -------------- + -- Reexpand -- + -------------- + + procedure Reexpand (C : Suppressed_Or_Checked) is + Svg : constant Overflow_Check_Type := + Scope_Suppress.Overflow_Checks_General; + Sva : constant Overflow_Check_Type := + Scope_Suppress.Overflow_Checks_Assertions; + begin + Scope_Suppress.Overflow_Checks_General := C; + Scope_Suppress.Overflow_Checks_Assertions := C; + Set_Analyzed (N, False); + Expand (N); + Scope_Suppress.Overflow_Checks_General := Svg; + Scope_Suppress.Overflow_Checks_Assertions := Sva; + end Reexpand; + -- Start of processing for Minimize_Eliminate_Overflow_Checks begin @@ -6890,13 +6921,13 @@ package body Checks is -- If we have no Long_Long_Integer operands, then we are in result -- range, since it means that none of our operands felt the need -- to worry about overflow (otherwise it would have already been - -- converted to long long integer or bignum). We reanalyze to - -- complete the expansion of the if expression + -- converted to long long integer or bignum). We reexpand to + -- complete the expansion of the if expression (but we do not + -- need to reanalyze). elsif not Long_Long_Integer_Operands then Set_Do_Overflow_Check (N, False); - Set_Analyzed (N, False); - Analyze_And_Resolve (N, Suppress => Overflow_Check); + Reexpand (Suppressed); -- Otherwise convert us to long long integer mode. Note that we -- don't need any further overflow checking at this level. @@ -6953,14 +6984,13 @@ package body Checks is -- that none of our dependent expressions could raise overflow. -- In this case, we simply return with no changes except for -- resetting the overflow flag, since we are done with overflow - -- checks for this node. We will reset the Analyzed flag so that - -- we will properly reexpand and get the needed expansion for - -- the case expression. + -- checks for this node. We will reexpand to get the needed + -- expansion for the case expression, but we do not need to + -- renalyze, since nothing has changed. if not (Bignum_Operands or Long_Long_Integer_Operands) then Set_Do_Overflow_Check (N, False); - Set_Analyzed (N, False); - Analyze_And_Resolve (N, Suppress => Overflow_Check); + Reexpand (Suppressed); -- Otherwise we are going to rebuild the case expression using -- either bignum or long long integer operands throughout. @@ -7381,18 +7411,20 @@ package body Checks is end case; end if; - -- If we know we are in the result range, and we do not have Bignum - -- operands or Long_Long_Integer operands, we can just renalyze with - -- overflow checks turned off (since we know we cannot have overflow). - -- As always the reanalysis is required to complete expansion of the - -- operator, and we prevent recursion by suppressing the check. + -- Here for the case where we have not rewritten anything (no bignum + -- operands or long long integer operands), and we know the result If we + -- know we are in the result range, and we do not have Bignum operands + -- or Long_Long_Integer operands, we can just reexpand with overflow + -- checks turned off (since we know we cannot have overflow). As always + -- the reexpansion is required to complete expansion of the operator, + -- but we do not need to reanalyze, and we prevent recursion by + -- suppressing the check, if not (Bignum_Operands or Long_Long_Integer_Operands) and then In_Result_Range then Set_Do_Overflow_Check (N, False); - Set_Analyzed (N, False); - Analyze_And_Resolve (N, Suppress => Overflow_Check); + Reexpand (Suppressed); return; -- Here we know that we are not in the result range, and in the general @@ -7427,20 +7459,10 @@ package body Checks is -- eliminated overflow processing which is not what we want. Here -- we are at the top level, and we need a check against the result -- mode (i.e. we want to use Checked mode). So do exactly that! + -- Also, we have not modified the node, so this is a case where + -- we need to reexpand, but not reanalyze. - declare - Svg : constant Overflow_Check_Type := - Scope_Suppress.Overflow_Checks_General; - Sva : constant Overflow_Check_Type := - Scope_Suppress.Overflow_Checks_Assertions; - begin - Scope_Suppress.Overflow_Checks_General := Checked; - Scope_Suppress.Overflow_Checks_Assertions := Checked; - Analyze_And_Resolve (N); - Scope_Suppress.Overflow_Checks_General := Svg; - Scope_Suppress.Overflow_Checks_Assertions := Sva; - end; - + Reexpand (Checked); return; -- Cases where we do the operation in Bignum mode. This happens either diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 9357be68b57..f47bae4b918 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -2325,13 +2325,16 @@ package body Exp_Ch4 is Minimize_Eliminate_Overflow_Checks (Right_Opnd (N), Rlo, Rhi, Top_Level => False); - -- See if the range information decides the result of the comparison + -- See if the range information decides the result of the comparison. + -- We can only do this if we in fact have full range information (which + -- won't be the case if either operand is bignum at this stage). - case N_Op_Compare (Nkind (N)) is + if Llo /= No_Uint and then Rlo /= No_Uint then + case N_Op_Compare (Nkind (N)) is when N_Op_Eq => if Llo = Lhi and then Rlo = Rhi and then Llo = Rlo then Set_True; - elsif Llo > Rhi or else Rlo > Lhi then + elsif Llo > Rhi or else Lhi < Rlo then Set_False; end if; @@ -2365,16 +2368,17 @@ package body Exp_Ch4 is when N_Op_Ne => if Llo = Lhi and then Rlo = Rhi and then Llo = Rlo then - Set_True; - elsif Llo > Rhi or else Rlo > Lhi then Set_False; + elsif Llo > Rhi or else Lhi < Rlo then + Set_True; end if; - end case; + end case; - -- All done if we did the rewrite + -- All done if we did the rewrite - if Nkind (N) not in N_Op_Compare then - return; + if Nkind (N) not in N_Op_Compare then + return; + end if; end if; -- Otherwise, time to do the comparison diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 2fac2a3bffc..8d9ef9b38dd 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -1217,8 +1217,8 @@ package body Exp_Ch6 is and then Present (Effective_Extra_Accessibility (Entity (Lhs))) then - -- Copyback target is an Ada 2012 stand-alone object - -- of an anonymous access type + -- Copyback target is an Ada 2012 stand-alone object of an + -- anonymous access type. pragma Assert (Ada_Version >= Ada_2012); @@ -3046,7 +3046,7 @@ package body Exp_Ch6 is Set_Last_Assignment (Ent, Sav); Set_Is_Known_Valid (Ent, False); - -- For all other cases, just kill the current values + -- For all other cases, just kill the current values else Kill_Current_Values (Ent); @@ -3201,7 +3201,7 @@ package body Exp_Ch6 is end; end if; - -- If we are expanding a rhs of an assignment we need to check if tag + -- If we are expanding the RHS of an assignment we need to check if tag -- propagation is needed. You might expect this processing to be in -- Analyze_Assignment but has to be done earlier (bottom-up) because the -- assignment might be transformed to a declaration for an unconstrained @@ -4219,9 +4219,7 @@ package body Exp_Ch6 is Ret : Node_Id; begin - if Is_Entity_Name (N) - and then Present (Entity (N)) - then + if Is_Entity_Name (N) and then Present (Entity (N)) then E := Entity (N); if Is_Formal (E) diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb index 6db86e14ef0..9b5cb5716ea 100644 --- a/gcc/ada/exp_disp.adb +++ b/gcc/ada/exp_disp.adb @@ -8447,152 +8447,49 @@ package body Exp_Disp is procedure Set_CPP_Constructors (Typ : Entity_Id) is - procedure Set_CPP_Constructors_Old (Typ : Entity_Id); - -- For backward compatibility this routine handles CPP constructors - -- of non-tagged types. - - procedure Set_CPP_Constructors_Old (Typ : Entity_Id) is - Loc : Source_Ptr; - Init : Entity_Id; - E : Entity_Id; - Found : Boolean := False; - P : Node_Id; - Parms : List_Id; + function Gen_Parameters_Profile (E : Entity_Id) return List_Id; + -- Duplicate the parameters profile of the imported C++ constructor + -- adding an access to the object as an additional parameter. - Covers_Default_Constructor : Entity_Id := Empty; + function Gen_Parameters_Profile (E : Entity_Id) return List_Id is + Loc : constant Source_Ptr := Sloc (E); + Parms : List_Id; + P : Node_Id; begin - -- Look for the constructor entities - - E := Next_Entity (Typ); - while Present (E) loop - if Ekind (E) = E_Function - and then Is_Constructor (E) - then - -- Create the init procedure - - Found := True; - Loc := Sloc (E); - Init := Make_Defining_Identifier (Loc, - Make_Init_Proc_Name (Typ)); - Parms := - New_List ( - Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, Name_X), - Parameter_Type => - New_Reference_To (Typ, Loc))); - - if Present (Parameter_Specifications (Parent (E))) then - P := First (Parameter_Specifications (Parent (E))); - while Present (P) loop - Append_To (Parms, - Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, - Chars (Defining_Identifier (P))), - Parameter_Type => - New_Copy_Tree (Parameter_Type (P)), - Expression => New_Copy_Tree (Expression (P)))); - Next (P); - end loop; - end if; - - Discard_Node ( - Make_Subprogram_Declaration (Loc, - Make_Procedure_Specification (Loc, - Defining_Unit_Name => Init, - Parameter_Specifications => Parms))); - - Set_Init_Proc (Typ, Init); - Set_Is_Imported (Init); - Set_Is_Constructor (Init); - Set_Interface_Name (Init, Interface_Name (E)); - Set_Convention (Init, Convention_CPP); - Set_Is_Public (Init); - Set_Has_Completion (Init); - - -- If this constructor has parameters and all its parameters - -- have defaults then it covers the default constructor. The - -- semantic analyzer ensures that only one constructor with - -- defaults covers the default constructor. - - if Present (Parameter_Specifications (Parent (E))) - and then Needs_No_Actuals (E) - then - Covers_Default_Constructor := Init; - end if; - end if; - - Next_Entity (E); - end loop; - - -- If there are no constructors, mark the type as abstract since we - -- won't be able to declare objects of that type. - - if not Found then - Set_Is_Abstract_Type (Typ); + Parms := + New_List ( + Make_Parameter_Specification (Loc, + Defining_Identifier => + Make_Defining_Identifier (Loc, Name_uInit), + Parameter_Type => New_Reference_To (Typ, Loc))); + + if Present (Parameter_Specifications (Parent (E))) then + P := First (Parameter_Specifications (Parent (E))); + while Present (P) loop + Append_To (Parms, + Make_Parameter_Specification (Loc, + Defining_Identifier => + Make_Defining_Identifier (Loc, + Chars => Chars (Defining_Identifier (P))), + Parameter_Type => New_Copy_Tree (Parameter_Type (P)), + Expression => New_Copy_Tree (Expression (P)))); + Next (P); + end loop; end if; - -- Handle constructor that has all its parameters with defaults and - -- hence it covers the default constructor. We generate a wrapper IP - -- which calls the covering constructor. - - if Present (Covers_Default_Constructor) then - declare - Body_Stmts : List_Id; - Wrapper_Id : Entity_Id; - Wrapper_Body_Node : Node_Id; - begin - Loc := Sloc (Covers_Default_Constructor); - - Body_Stmts := New_List ( - Make_Procedure_Call_Statement (Loc, - Name => New_Reference_To (Covers_Default_Constructor, Loc), - Parameter_Associations => New_List ( - Make_Identifier (Loc, Name_uInit)))); - - Wrapper_Id := Make_Defining_Identifier (Loc, - Make_Init_Proc_Name (Typ)); - - Wrapper_Body_Node := - Make_Subprogram_Body (Loc, - Specification => - Make_Procedure_Specification (Loc, - Defining_Unit_Name => Wrapper_Id, - Parameter_Specifications => New_List ( - Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, Name_uInit), - Parameter_Type => - New_Reference_To (Typ, Loc)))), - Declarations => No_List, - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => Body_Stmts, - Exception_Handlers => No_List)); - - Discard_Node (Wrapper_Body_Node); - Set_Init_Proc (Typ, Wrapper_Id); - end; - end if; - end Set_CPP_Constructors_Old; + return Parms; + end Gen_Parameters_Profile; -- Local variables - Loc : Source_Ptr; - E : Entity_Id; - Found : Boolean := False; - P : Node_Id; - Parms : List_Id; - - Constructor_Decl_Node : Node_Id; - Constructor_Id : Entity_Id; - Wrapper_Id : Entity_Id; - Wrapper_Body_Node : Node_Id; - Actuals : List_Id; - Body_Stmts : List_Id; - Init_Tags_List : List_Id; + Loc : Source_Ptr; + E : Entity_Id; + Found : Boolean := False; + IP : Entity_Id; + IP_Body : Node_Id; + P : Node_Id; + Parms : List_Id; Covers_Default_Constructor : Entity_Id := Empty; @@ -8601,22 +8498,6 @@ package body Exp_Disp is begin pragma Assert (Is_CPP_Class (Typ)); - -- For backward compatibility the compiler accepts C++ classes - -- imported through non-tagged record types. In such case the - -- wrapper of the C++ constructor is useless because the _tag - -- component is not available. - - -- Example: - -- type Root is limited record ... - -- pragma Import (CPP, Root); - -- function New_Root return Root; - -- pragma CPP_Constructor (New_Root, ... ); - - if not Is_Tagged_Type (Typ) then - Set_CPP_Constructors_Old (Typ); - return; - end if; - -- Look for the constructor entities E := Next_Entity (Typ); @@ -8626,156 +8507,167 @@ package body Exp_Disp is then Found := True; Loc := Sloc (E); + Parms := Gen_Parameters_Profile (E); + IP := + Make_Defining_Identifier (Loc, + Chars => Make_Init_Proc_Name (Typ)); + + -- Case 1: Constructor of non-tagged type + + -- If the C++ class has no virtual methods then the matching Ada + -- type is a non-tagged record type. In such case there is no need + -- to generate a wrapper of the C++ constructor because the _tag + -- component is not available. + + if not Is_Tagged_Type (Typ) then + Discard_Node + (Make_Subprogram_Declaration (Loc, + Specification => + Make_Procedure_Specification (Loc, + Defining_Unit_Name => IP, + Parameter_Specifications => Parms))); + + Set_Init_Proc (Typ, IP); + Set_Is_Imported (IP); + Set_Is_Constructor (IP); + Set_Interface_Name (IP, Interface_Name (E)); + Set_Convention (IP, Convention_CPP); + Set_Is_Public (IP); + Set_Has_Completion (IP); + + -- Case 2: Constructor of a tagged type + + -- In this case we generate the IP as a wrapper of the the + -- C++ constructor because IP must also save copy of the _tag + -- generated in the C++ side. The copy of the _tag is used by + -- Build_CPP_Init_Procedure to elaborate derivations of C++ types. - -- Generate the declaration of the imported C++ constructor - - Parms := - New_List ( - Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, Name_uInit), - Parameter_Type => - New_Reference_To (Typ, Loc))); - - if Present (Parameter_Specifications (Parent (E))) then - P := First (Parameter_Specifications (Parent (E))); - while Present (P) loop - Append_To (Parms, - Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, - Chars (Defining_Identifier (P))), - Parameter_Type => New_Copy_Tree (Parameter_Type (P)))); - Next (P); - end loop; - end if; - - Constructor_Id := Make_Temporary (Loc, 'P'); + -- Generate: + -- procedure IP (_init : Typ; ...) is + -- procedure ConstructorP (_init : Typ; ...); + -- pragma Import (ConstructorP); + -- begin + -- ConstructorP (_init, ...); + -- if Typ._tag = null then + -- Typ._tag := _init._tag; + -- end if; + -- end IP; - Constructor_Decl_Node := - Make_Subprogram_Declaration (Loc, - Make_Procedure_Specification (Loc, - Defining_Unit_Name => Constructor_Id, - Parameter_Specifications => Parms)); + else + declare + Body_Stmts : constant List_Id := New_List; + Constructor_Id : Entity_Id; + Constructor_Decl_Node : Node_Id; + Init_Tags_List : List_Id; - Set_Is_Imported (Constructor_Id); - Set_Is_Constructor (Constructor_Id); - Set_Interface_Name (Constructor_Id, Interface_Name (E)); - Set_Convention (Constructor_Id, Convention_CPP); - Set_Is_Public (Constructor_Id); - Set_Has_Completion (Constructor_Id); + begin + Constructor_Id := Make_Temporary (Loc, 'P'); - -- Build the wrapper of this constructor + Constructor_Decl_Node := + Make_Subprogram_Declaration (Loc, + Make_Procedure_Specification (Loc, + Defining_Unit_Name => Constructor_Id, + Parameter_Specifications => Parms)); - Parms := - New_List ( - Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, Name_uInit), - Parameter_Type => - New_Reference_To (Typ, Loc))); - - if Present (Parameter_Specifications (Parent (E))) then - P := First (Parameter_Specifications (Parent (E))); - while Present (P) loop - Append_To (Parms, - Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, - Chars (Defining_Identifier (P))), - Parameter_Type => - New_Copy_Tree (Parameter_Type (P)), - Expression => New_Copy_Tree (Expression (P)))); - Next (P); - end loop; - end if; + Set_Is_Imported (Constructor_Id); + Set_Is_Constructor (Constructor_Id); + Set_Interface_Name (Constructor_Id, Interface_Name (E)); + Set_Convention (Constructor_Id, Convention_CPP); + Set_Is_Public (Constructor_Id); + Set_Has_Completion (Constructor_Id); - Body_Stmts := New_List; + -- Build the init procedure as a wrapper of this constructor - -- Invoke the C++ constructor + Parms := Gen_Parameters_Profile (E); - Actuals := New_List; + -- Invoke the C++ constructor - P := First (Parms); - while Present (P) loop - Append_To (Actuals, - New_Reference_To (Defining_Identifier (P), Loc)); - Next (P); - end loop; + declare + Actuals : constant List_Id := New_List; - Append_To (Body_Stmts, - Make_Procedure_Call_Statement (Loc, - Name => New_Reference_To (Constructor_Id, Loc), - Parameter_Associations => Actuals)); - - -- Initialize copies of C++ primary and secondary tags - - Init_Tags_List := New_List; - - declare - Tag_Elmt : Elmt_Id; - Tag_Comp : Node_Id; - - begin - Tag_Elmt := First_Elmt (Access_Disp_Table (Typ)); - Tag_Comp := First_Tag_Component (Typ); + begin + P := First (Parms); + while Present (P) loop + Append_To (Actuals, + New_Reference_To (Defining_Identifier (P), Loc)); + Next (P); + end loop; - while Present (Tag_Elmt) - and then Is_Tag (Node (Tag_Elmt)) - loop - -- Skip the following assertion with primary tags because - -- Related_Type is not set on primary tag components + Append_To (Body_Stmts, + Make_Procedure_Call_Statement (Loc, + Name => New_Reference_To (Constructor_Id, Loc), + Parameter_Associations => Actuals)); + end; - pragma Assert (Tag_Comp = First_Tag_Component (Typ) - or else Related_Type (Node (Tag_Elmt)) - = Related_Type (Tag_Comp)); + -- Initialize copies of C++ primary and secondary tags - Append_To (Init_Tags_List, - Make_Assignment_Statement (Loc, - Name => - New_Reference_To (Node (Tag_Elmt), Loc), - Expression => - Make_Selected_Component (Loc, - Prefix => - Make_Identifier (Loc, Name_uInit), - Selector_Name => - New_Reference_To (Tag_Comp, Loc)))); + Init_Tags_List := New_List; - Tag_Comp := Next_Tag_Component (Tag_Comp); - Next_Elmt (Tag_Elmt); - end loop; - end; + declare + Tag_Elmt : Elmt_Id; + Tag_Comp : Node_Id; - Append_To (Body_Stmts, - Make_If_Statement (Loc, - Condition => - Make_Op_Eq (Loc, - Left_Opnd => - New_Reference_To - (Node (First_Elmt (Access_Disp_Table (Typ))), - Loc), - Right_Opnd => - Unchecked_Convert_To (RTE (RE_Tag), - New_Reference_To (RTE (RE_Null_Address), Loc))), - Then_Statements => Init_Tags_List)); + begin + Tag_Elmt := First_Elmt (Access_Disp_Table (Typ)); + Tag_Comp := First_Tag_Component (Typ); - Wrapper_Id := Make_Defining_Identifier (Loc, - Make_Init_Proc_Name (Typ)); + while Present (Tag_Elmt) + and then Is_Tag (Node (Tag_Elmt)) + loop + -- Skip the following assertion with primary tags + -- because Related_Type is not set on primary tag + -- components + + pragma Assert + (Tag_Comp = First_Tag_Component (Typ) + or else Related_Type (Node (Tag_Elmt)) + = Related_Type (Tag_Comp)); + + Append_To (Init_Tags_List, + Make_Assignment_Statement (Loc, + Name => + New_Reference_To (Node (Tag_Elmt), Loc), + Expression => + Make_Selected_Component (Loc, + Prefix => + Make_Identifier (Loc, Name_uInit), + Selector_Name => + New_Reference_To (Tag_Comp, Loc)))); - Wrapper_Body_Node := - Make_Subprogram_Body (Loc, - Specification => - Make_Procedure_Specification (Loc, - Defining_Unit_Name => Wrapper_Id, - Parameter_Specifications => Parms), - Declarations => New_List (Constructor_Decl_Node), - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => Body_Stmts, - Exception_Handlers => No_List)); + Tag_Comp := Next_Tag_Component (Tag_Comp); + Next_Elmt (Tag_Elmt); + end loop; + end; - Discard_Node (Wrapper_Body_Node); - Set_Init_Proc (Typ, Wrapper_Id); + Append_To (Body_Stmts, + Make_If_Statement (Loc, + Condition => + Make_Op_Eq (Loc, + Left_Opnd => + New_Reference_To + (Node (First_Elmt (Access_Disp_Table (Typ))), + Loc), + Right_Opnd => + Unchecked_Convert_To (RTE (RE_Tag), + New_Reference_To (RTE (RE_Null_Address), Loc))), + Then_Statements => Init_Tags_List)); + + IP_Body := + Make_Subprogram_Body (Loc, + Specification => + Make_Procedure_Specification (Loc, + Defining_Unit_Name => IP, + Parameter_Specifications => Parms), + Declarations => New_List (Constructor_Decl_Node), + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => Body_Stmts, + Exception_Handlers => No_List)); + + Discard_Node (IP_Body); + Set_Init_Proc (Typ, IP); + end; + end if; -- If this constructor has parameters and all its parameters -- have defaults then it covers the default constructor. The @@ -8785,7 +8677,7 @@ package body Exp_Disp is if Present (Parameter_Specifications (Parent (E))) and then Needs_No_Actuals (E) then - Covers_Default_Constructor := Wrapper_Id; + Covers_Default_Constructor := IP; end if; end if; @@ -8804,39 +8696,42 @@ package body Exp_Disp is -- which calls the covering constructor. if Present (Covers_Default_Constructor) then - Loc := Sloc (Covers_Default_Constructor); + declare + Body_Stmts : List_Id; - Body_Stmts := New_List ( - Make_Procedure_Call_Statement (Loc, - Name => - New_Reference_To (Covers_Default_Constructor, Loc), - Parameter_Associations => New_List ( - Make_Identifier (Loc, Name_uInit)))); + begin + Loc := Sloc (Covers_Default_Constructor); - Wrapper_Id := - Make_Defining_Identifier (Loc, Make_Init_Proc_Name (Typ)); + Body_Stmts := New_List ( + Make_Procedure_Call_Statement (Loc, + Name => + New_Reference_To (Covers_Default_Constructor, Loc), + Parameter_Associations => New_List ( + Make_Identifier (Loc, Name_uInit)))); - Wrapper_Body_Node := - Make_Subprogram_Body (Loc, - Specification => - Make_Procedure_Specification (Loc, - Defining_Unit_Name => Wrapper_Id, - Parameter_Specifications => New_List ( - Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Loc, Name_uInit), - Parameter_Type => - New_Reference_To (Typ, Loc)))), - - Declarations => No_List, + IP := Make_Defining_Identifier (Loc, Make_Init_Proc_Name (Typ)); - Handled_Statement_Sequence => - Make_Handled_Sequence_Of_Statements (Loc, - Statements => Body_Stmts, - Exception_Handlers => No_List)); + IP_Body := + Make_Subprogram_Body (Loc, + Specification => + Make_Procedure_Specification (Loc, + Defining_Unit_Name => IP, + Parameter_Specifications => New_List ( + Make_Parameter_Specification (Loc, + Defining_Identifier => + Make_Defining_Identifier (Loc, Name_uInit), + Parameter_Type => New_Reference_To (Typ, Loc)))), - Discard_Node (Wrapper_Body_Node); - Set_Init_Proc (Typ, Wrapper_Id); + Declarations => No_List, + + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => Body_Stmts, + Exception_Handlers => No_List)); + + Discard_Node (IP_Body); + Set_Init_Proc (Typ, IP); + end; end if; -- If the CPP type has constructors then it must import also the default diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index cb397a24d71..82b054adfce 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -710,8 +710,11 @@ package body Exp_Util is Subpool := Subpool_Handle_Name (Expr); end if; + -- If a subpool is present it can be an arbitrary name, so make + -- the actual by copying the tree. + if Present (Subpool) then - Append_To (Actuals, New_Reference_To (Entity (Subpool), Loc)); + Append_To (Actuals, New_Copy_Tree (Subpool, New_Sloc => Loc)); else Append_To (Actuals, Make_Null (Loc)); end if; diff --git a/gcc/ada/g-comlin.adb b/gcc/ada/g-comlin.adb index 723ff120ff6..f11846fbb79 100644 --- a/gcc/ada/g-comlin.adb +++ b/gcc/ada/g-comlin.adb @@ -39,6 +39,10 @@ with GNAT.OS_Lib; use GNAT.OS_Lib; package body GNAT.Command_Line is + -- General note: this entire body could use much more commenting. There + -- are large sections of uncommented code throughout, and many formal + -- parameters of local subprograms are not documented at all ??? + package CL renames Ada.Command_Line; type Switch_Parameter_Type is @@ -56,6 +60,12 @@ package body GNAT.Command_Line is Extra : Character := ASCII.NUL); pragma Inline (Set_Parameter); -- Set the parameter that will be returned by Parameter below + -- + -- Extra is a character that needs to be added when reporting Full_Switch. + -- (it will in general be the switch character, for instance '-'). + -- Otherwise, Full_Switch will report 'f' instead of '-f'. In particular, + -- it needs to be set when reporting an invalid switch or handling '*'. + -- -- Parameters need to be defined ??? function Goto_Next_Argument_In_Section (Parser : Opt_Parser) return Boolean; @@ -95,9 +105,9 @@ package body GNAT.Command_Line is Index_In_Switches : out Integer; Switch_Length : out Integer; Param : out Switch_Parameter_Type); - -- Return the Longest switch from Switches that at least partially - -- partially Arg. Index_In_Switches is set to 0 if none matches. - -- What are other parameters??? in particular Param is not always set??? + -- Return the Longest switch from Switches that at least partially matches + -- Arg. Index_In_Switches is set to 0 if none matches. What are other + -- parameters??? in particular Param is not always set??? procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Argument_List, Argument_List_Access); @@ -663,17 +673,45 @@ package body GNAT.Command_Line is if Index_Switches = 0 then - -- Depending on the value of Concatenate, the full switch is - -- a single character or the rest of the argument. + -- Find the current switch that we did not recognize. This is in + -- fact difficult because Getopt does not know explicitly about + -- short and long switches. Ideally, we would want the following + -- behavior: + + -- * for short switches, with Concatenate: + -- if -a is not recognized, and the command line has -daf + -- we should report the invalid switch as "-a". + + -- * for short switches, wihtout Concatenate: + -- we should report the invalid switch as "-daf". + + -- * for long switches: + -- if the commadn line is "--long" we should report --long + -- as unrecongized. + + -- Unfortunately, the fact that long switches start with a + -- duplicate switch character is just a convention (so we could + -- have a long switch "-long" for instance). We'll still rely on + -- this convention here to try and get as helpful an error message + -- as possible. + + -- Long switch case (starting with double switch character) - End_Index := - (if Concatenate then Parser.Current_Index else Arg'Last); + if Arg (Arg'First + 1) = Parser.Switch_Character then + End_Index := Arg'Last; + + -- Short switch case + + else + End_Index := + (if Concatenate then Parser.Current_Index else Arg'Last); + end if; if Switches (Switches'First) = '*' then - -- Always prepend the switch character, so that users know that - -- this comes from a switch on the command line. This is - -- especially important when Concatenate is False, since + -- Always prepend the switch character, so that users know + -- that this comes from a switch on the command line. This + -- is especially important when Concatenate is False, since -- otherwise the current argument first character is lost. if Parser.Section (Parser.Current_Argument) = 0 then @@ -696,11 +734,21 @@ package body GNAT.Command_Line is end if; end if; - Set_Parameter - (Parser.The_Switch, - Arg_Num => Parser.Current_Argument, - First => Parser.Current_Index, - Last => End_Index); + if Parser.Current_Index = Arg'First then + Set_Parameter + (Parser.The_Switch, + Arg_Num => Parser.Current_Argument, + First => Parser.Current_Index, + Last => End_Index); + else + Set_Parameter + (Parser.The_Switch, + Arg_Num => Parser.Current_Argument, + First => Parser.Current_Index, + Last => End_Index, + Extra => Parser.Switch_Character); + end if; + Parser.Current_Index := End_Index + 1; raise Invalid_Switch; @@ -762,7 +810,7 @@ package body GNAT.Command_Line is raise Invalid_Parameter; end if; - -- If the switch is of the form <switch> xxx + -- Case of switch of the form <switch> xxx elsif Parser.Current_Argument < Parser.Arg_Count and then Parser.Section (Parser.Current_Argument + 1) /= 0 @@ -830,7 +878,8 @@ package body GNAT.Command_Line is (Parser.The_Switch, Arg_Num => Parser.Current_Argument, First => Parser.Current_Index, - Last => Arg'Last); + Last => Arg'Last, + Extra => Parser.Switch_Character); Parser.Current_Index := Arg'Last + 1; raise Invalid_Switch; end if; @@ -1170,9 +1219,7 @@ package body GNAT.Command_Line is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Opt_Parser_Data, Opt_Parser); begin - if Parser /= null - and then Parser /= Command_Line_Parser - then + if Parser /= null and then Parser /= Command_Line_Parser then Free (Parser.Arguments); Unchecked_Free (Parser); end if; @@ -1189,6 +1236,7 @@ package body GNAT.Command_Line is Section : String := "") is Def : Alias_Definition; + begin if Config = null then Config := new Command_Line_Configuration_Record; @@ -1255,8 +1303,9 @@ package body GNAT.Command_Line is -- Add -- --------- - procedure Add (Def : in out Alias_Definitions_List; - Alias : Alias_Definition) + procedure Add + (Def : in out Alias_Definitions_List; + Alias : Alias_Definition) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation @@ -1511,7 +1560,7 @@ package body GNAT.Command_Line is Foreach (Config, Section => Section); - -- Adding relevant aliases + -- Add relevant aliases if Config.Aliases /= null then for A in Config.Aliases'Range loop @@ -1585,8 +1634,8 @@ package body GNAT.Command_Line is function Real_Full_Switch (S : Character; Parser : Opt_Parser) return String; - -- Ensure that the returned switch value contains the - -- Switch_Char prefix if needed. + -- Ensure that the returned switch value contains the Switch_Char prefix + -- if needed. ---------------------- -- Real_Full_Switch -- @@ -2465,13 +2514,12 @@ package body GNAT.Command_Line is ((Cmd.Params (C) = null and then Param = "") or else (Cmd.Params (C) /= null - and then - -- Ignore the separator stored in Parameter + -- Ignore the separator stored in Parameter + and then Cmd.Params (C) (Cmd.Params (C)'First + 1 - .. Cmd.Params (C)'Last) = - Param)) + .. Cmd.Params (C)'Last) = Param)) then Remove (Cmd.Expanded, C); Remove (Cmd.Params, C); @@ -2550,9 +2598,7 @@ package body GNAT.Command_Line is -- Start of processing for Group_Switches begin - if Cmd.Config = null - or else Cmd.Config.Prefixes = null - then + if Cmd.Config = null or else Cmd.Config.Prefixes = null then return; end if; @@ -2638,10 +2684,9 @@ package body GNAT.Command_Line is First : Natural; procedure Check_Cb (Switch, Separator, Param : String; Index : Integer); - -- Checks whether the command line contains [Switch]. - -- Sets the global variable [Found] appropriately. - -- This will be called for each simple switch that make up an alias, to - -- know whether the alias should be applied. + -- Checks whether the command line contains [Switch]. Sets the global + -- variable [Found] appropriately. This is called for each simple switch + -- that make up an alias, to know whether the alias should be applied. procedure Remove_Cb (Switch, Separator, Param : String; Index : Integer); -- Remove the simple switch [Switch] from the command line, since it is @@ -2708,9 +2753,7 @@ package body GNAT.Command_Line is -- Start of processing for Alias_Switches begin - if Cmd.Config = null - or else Cmd.Config.Aliases = null - then + if Cmd.Config = null or else Cmd.Config.Aliases = null then return; end if; @@ -3079,7 +3122,7 @@ package body GNAT.Command_Line is procedure Display_Help (Config : Command_Line_Configuration) is function Switch_Name - (Def : Switch_Definition; + (Def : Switch_Definition; Section : String) return String; -- Return the "-short, --long=ARG" string for Def. -- Returns "" if the switch is not in the section. @@ -3194,7 +3237,7 @@ package body GNAT.Command_Line is ----------------- function Switch_Name - (Def : Switch_Definition; + (Def : Switch_Definition; Section : String) return String is use Ada.Strings.Unbounded; @@ -3488,7 +3531,7 @@ package body GNAT.Command_Line is Put_Line (Standard_Error, Base_Name (Ada.Command_Line.Command_Name) & ": unrecognized option '" - & Parser.Switch_Character & Full_Switch (Parser) + & Full_Switch (Parser) & "'"); Put_Line (Standard_Error, "Try `" diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index 5dcb935aabf..60637c9bb1d 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -1259,31 +1259,31 @@ ada/checks.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/eval_fat.ads ada/exp_aggr.ads ada/exp_ch11.ads ada/exp_ch2.ads \ ada/exp_ch4.ads ada/exp_ch6.ads ada/exp_ch7.ads ada/exp_disp.ads \ ada/exp_dist.ads ada/exp_pakd.ads ada/exp_tss.ads ada/exp_util.ads \ - ada/exp_util.adb ada/fname.ads ada/fname-uf.ads ada/freeze.ads \ - ada/get_targ.ads ada/gnat.ads ada/g-hesorg.ads ada/g-htable.ads \ - ada/gnatvsn.ads ada/hostparm.ads ada/inline.ads ada/itypes.ads \ - ada/lib.ads ada/lib.adb ada/lib-list.adb ada/lib-load.ads \ - ada/lib-sort.adb ada/lib-util.ads ada/lib-xref.ads ada/namet.ads \ - ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads \ - ada/opt.adb ada/output.ads ada/put_alfa.ads ada/restrict.ads \ - ada/restrict.adb ada/rident.ads ada/rtsfind.ads ada/rtsfind.adb \ - ada/scans.ads ada/sem.ads ada/sem_attr.ads ada/sem_aux.ads \ - ada/sem_cat.ads ada/sem_ch3.ads ada/sem_ch6.ads ada/sem_ch7.ads \ - ada/sem_ch8.ads ada/sem_disp.ads ada/sem_dist.ads ada/sem_eval.ads \ - ada/sem_eval.adb ada/sem_prag.ads ada/sem_res.ads ada/sem_type.ads \ - ada/sem_util.ads ada/sem_util.adb ada/sem_warn.ads ada/sinfo.ads \ - ada/sinfo.adb ada/sinput.ads ada/snames.ads ada/sprint.ads \ - ada/stand.ads ada/stringt.ads ada/style.ads ada/styleg.ads \ - ada/styleg.adb ada/stylesw.ads ada/system.ads ada/s-exctab.ads \ - ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads \ - ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads \ - ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb \ - ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads \ - ada/table.ads ada/table.adb ada/targparm.ads ada/tbuild.ads \ - ada/tbuild.adb ada/tree_io.ads ada/ttypes.ads ada/types.ads \ - ada/uintp.ads ada/uintp.adb ada/uname.ads ada/unchconv.ads \ - ada/unchdeal.ads ada/urealp.ads ada/urealp.adb ada/validsw.ads \ - ada/widechar.ads + ada/exp_util.adb ada/expander.ads ada/fname.ads ada/fname-uf.ads \ + ada/freeze.ads ada/get_targ.ads ada/gnat.ads ada/g-hesorg.ads \ + ada/g-htable.ads ada/gnatvsn.ads ada/hostparm.ads ada/inline.ads \ + ada/itypes.ads ada/lib.ads ada/lib.adb ada/lib-list.adb \ + ada/lib-load.ads ada/lib-sort.adb ada/lib-util.ads ada/lib-xref.ads \ + ada/namet.ads ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/nmake.adb \ + ada/opt.ads ada/opt.adb ada/output.ads ada/put_alfa.ads \ + ada/restrict.ads ada/restrict.adb ada/rident.ads ada/rtsfind.ads \ + ada/rtsfind.adb ada/scans.ads ada/sem.ads ada/sem_attr.ads \ + ada/sem_aux.ads ada/sem_cat.ads ada/sem_ch3.ads ada/sem_ch6.ads \ + ada/sem_ch7.ads ada/sem_ch8.ads ada/sem_disp.ads ada/sem_dist.ads \ + ada/sem_eval.ads ada/sem_eval.adb ada/sem_prag.ads ada/sem_res.ads \ + ada/sem_type.ads ada/sem_util.ads ada/sem_util.adb ada/sem_warn.ads \ + ada/sinfo.ads ada/sinfo.adb ada/sinput.ads ada/snames.ads \ + ada/sprint.ads ada/stand.ads ada/stringt.ads ada/style.ads \ + ada/styleg.ads ada/styleg.adb ada/stylesw.ads ada/system.ads \ + ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads \ + ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads \ + ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ + ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads \ + ada/s-wchcon.ads ada/table.ads ada/table.adb ada/targparm.ads \ + ada/tbuild.ads ada/tbuild.adb ada/tree_io.ads ada/ttypes.ads \ + ada/types.ads ada/uintp.ads ada/uintp.adb ada/uname.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/urealp.adb \ + ada/validsw.ads ada/widechar.ads ada/comperr.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/aspects.ads ada/atree.ads \ @@ -1642,28 +1642,28 @@ ada/exp_ch3.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/exp_ch4.ads ada/exp_ch6.ads ada/exp_ch7.ads ada/exp_ch9.ads \ ada/exp_dbug.ads ada/exp_disp.ads ada/exp_disp.adb ada/exp_dist.ads \ ada/exp_pakd.ads ada/exp_smem.ads ada/exp_strm.ads ada/exp_tss.ads \ - ada/exp_tss.adb ada/exp_util.ads ada/exp_util.adb ada/fname.ads \ - ada/fname-uf.ads ada/freeze.ads ada/get_targ.ads ada/gnat.ads \ - ada/g-htable.ads ada/hostparm.ads ada/inline.ads ada/itypes.ads \ - ada/layout.ads ada/lib.ads ada/lib-load.ads ada/namet.ads \ - ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads \ - ada/output.ads ada/restrict.ads ada/restrict.adb ada/rident.ads \ - ada/rtsfind.ads ada/rtsfind.adb ada/scil_ll.ads ada/sem.ads \ - ada/sem_attr.ads ada/sem_aux.ads ada/sem_aux.adb ada/sem_cat.ads \ - ada/sem_ch3.ads ada/sem_ch6.ads ada/sem_ch7.ads ada/sem_ch8.ads \ - ada/sem_disp.ads ada/sem_dist.ads ada/sem_eval.ads ada/sem_mech.ads \ - ada/sem_prag.ads ada/sem_res.ads ada/sem_scil.ads ada/sem_type.ads \ - ada/sem_util.ads ada/sem_warn.ads ada/sinfo.ads ada/sinfo.adb \ - ada/sinput.ads ada/snames.ads ada/sprint.ads ada/stand.ads \ - ada/stringt.ads ada/system.ads ada/s-exctab.ads ada/s-htable.ads \ - ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads \ - ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads \ - ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads \ - ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads ada/table.ads \ - ada/table.adb ada/targparm.ads ada/tbuild.ads ada/tbuild.adb \ - ada/tree_io.ads ada/ttypes.ads ada/types.ads ada/uintp.ads \ - ada/uintp.adb ada/uname.ads ada/unchconv.ads ada/unchdeal.ads \ - ada/urealp.ads ada/validsw.ads + ada/exp_tss.adb ada/exp_util.ads ada/exp_util.adb ada/expander.ads \ + ada/fname.ads ada/fname-uf.ads ada/freeze.ads ada/get_targ.ads \ + ada/gnat.ads ada/g-htable.ads ada/hostparm.ads ada/inline.ads \ + ada/itypes.ads ada/layout.ads ada/lib.ads ada/lib-load.ads \ + ada/namet.ads ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/nmake.adb \ + ada/opt.ads ada/output.ads ada/restrict.ads ada/restrict.adb \ + ada/rident.ads ada/rtsfind.ads ada/rtsfind.adb ada/scil_ll.ads \ + ada/sem.ads ada/sem_attr.ads ada/sem_aux.ads ada/sem_aux.adb \ + ada/sem_cat.ads ada/sem_ch3.ads ada/sem_ch6.ads ada/sem_ch7.ads \ + ada/sem_ch8.ads ada/sem_disp.ads ada/sem_dist.ads ada/sem_eval.ads \ + ada/sem_mech.ads ada/sem_prag.ads ada/sem_res.ads ada/sem_scil.ads \ + ada/sem_type.ads ada/sem_util.ads ada/sem_warn.ads ada/sinfo.ads \ + ada/sinfo.adb ada/sinput.ads ada/snames.ads ada/sprint.ads \ + ada/stand.ads ada/stringt.ads ada/system.ads ada/s-exctab.ads \ + ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads ada/s-os_lib.ads \ + ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb \ + ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/targparm.ads ada/tbuild.ads \ + ada/tbuild.adb ada/tree_io.ads ada/ttypes.ads ada/types.ads \ + ada/uintp.ads ada/uintp.adb ada/uname.ads ada/unchconv.ads \ + ada/unchdeal.ads ada/urealp.ads ada/validsw.ads ada/exp_ch4.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/aspects.ads ada/atree.ads \ @@ -1674,10 +1674,10 @@ ada/exp_ch4.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/exp_ch2.ads ada/exp_ch3.ads ada/exp_ch4.ads ada/exp_ch4.adb \ ada/exp_ch6.ads ada/exp_ch7.ads ada/exp_ch9.ads ada/exp_disp.ads \ ada/exp_fixd.ads ada/exp_intr.ads ada/exp_pakd.ads ada/exp_tss.ads \ - ada/exp_util.ads ada/exp_util.adb ada/exp_vfpt.ads ada/fname.ads \ - ada/fname-uf.ads ada/freeze.ads ada/get_targ.ads ada/gnat.ads \ - ada/g-hesorg.ads ada/g-htable.ads ada/hostparm.ads ada/inline.ads \ - ada/itypes.ads ada/lib.ads ada/lib.adb ada/lib-list.adb \ + ada/exp_util.ads ada/exp_util.adb ada/exp_vfpt.ads ada/expander.ads \ + ada/fname.ads ada/fname-uf.ads ada/freeze.ads ada/get_targ.ads \ + ada/gnat.ads ada/g-hesorg.ads ada/g-htable.ads ada/hostparm.ads \ + ada/inline.ads ada/itypes.ads ada/lib.ads ada/lib.adb ada/lib-list.adb \ ada/lib-sort.adb ada/lib-util.ads ada/lib-xref.ads ada/namet.ads \ ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads \ ada/output.ads ada/par_sco.ads ada/put_alfa.ads ada/restrict.ads \ @@ -1708,28 +1708,28 @@ ada/exp_ch5.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/exp_aggr.ads ada/exp_ch11.ads ada/exp_ch2.ads ada/exp_ch4.ads \ ada/exp_ch5.ads ada/exp_ch5.adb ada/exp_ch6.ads ada/exp_ch7.ads \ ada/exp_dbug.ads ada/exp_disp.ads ada/exp_pakd.ads ada/exp_tss.ads \ - ada/exp_util.ads ada/exp_util.adb ada/fname.ads ada/fname-uf.ads \ - ada/freeze.ads ada/get_targ.ads ada/gnat.ads ada/g-htable.ads \ - ada/hostparm.ads ada/inline.ads ada/itypes.ads ada/lib.ads \ - ada/lib-util.ads ada/lib-xref.ads ada/namet.ads ada/nlists.ads \ - ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads ada/output.ads \ - ada/put_alfa.ads ada/restrict.ads ada/restrict.adb ada/rident.ads \ - ada/rtsfind.ads ada/scans.ads ada/sem.ads ada/sem_attr.ads \ - ada/sem_aux.ads ada/sem_cat.ads ada/sem_ch13.ads ada/sem_ch3.ads \ - ada/sem_ch6.ads ada/sem_ch8.ads ada/sem_disp.ads ada/sem_eval.ads \ - ada/sem_eval.adb ada/sem_prag.ads ada/sem_res.ads ada/sem_type.ads \ - ada/sem_util.ads ada/sem_util.adb ada/sem_warn.ads ada/sinfo.ads \ - ada/sinfo.adb ada/sinput.ads ada/snames.ads ada/sprint.ads \ - ada/stand.ads ada/stringt.ads ada/stringt.adb ada/style.ads \ - ada/styleg.ads ada/styleg.adb ada/stylesw.ads ada/system.ads \ - ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads ada/s-memory.ads \ - ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads ada/s-secsta.ads \ - ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads \ - ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads \ - ada/s-wchcon.ads ada/table.ads ada/table.adb ada/targparm.ads \ - ada/tbuild.ads ada/tbuild.adb ada/tree_io.ads ada/ttypes.ads \ - ada/types.ads ada/uintp.ads ada/uname.ads ada/unchconv.ads \ - ada/unchdeal.ads ada/urealp.ads ada/validsw.ads + ada/exp_util.ads ada/exp_util.adb ada/expander.ads ada/fname.ads \ + ada/fname-uf.ads ada/freeze.ads ada/get_targ.ads ada/gnat.ads \ + ada/g-htable.ads ada/hostparm.ads ada/inline.ads ada/itypes.ads \ + ada/lib.ads ada/lib-util.ads ada/lib-xref.ads ada/namet.ads \ + ada/nlists.ads ada/nlists.adb ada/nmake.ads ada/nmake.adb ada/opt.ads \ + ada/output.ads ada/put_alfa.ads ada/restrict.ads ada/restrict.adb \ + ada/rident.ads ada/rtsfind.ads ada/scans.ads ada/sem.ads \ + ada/sem_attr.ads ada/sem_aux.ads ada/sem_cat.ads ada/sem_ch13.ads \ + ada/sem_ch3.ads ada/sem_ch6.ads ada/sem_ch8.ads ada/sem_disp.ads \ + ada/sem_eval.ads ada/sem_eval.adb ada/sem_prag.ads ada/sem_res.ads \ + ada/sem_type.ads ada/sem_util.ads ada/sem_util.adb ada/sem_warn.ads \ + ada/sinfo.ads ada/sinfo.adb ada/sinput.ads ada/snames.ads \ + ada/sprint.ads ada/stand.ads ada/stringt.ads ada/stringt.adb \ + ada/style.ads ada/styleg.ads ada/styleg.adb ada/stylesw.ads \ + ada/system.ads ada/s-exctab.ads ada/s-htable.ads ada/s-imenne.ads \ + ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads ada/s-rident.ads \ + ada/s-secsta.ads ada/s-soflin.ads ada/s-stache.ads ada/s-stalib.ads \ + ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads ada/s-traent.ads \ + ada/s-unstyp.ads ada/s-wchcon.ads ada/table.ads ada/table.adb \ + ada/targparm.ads ada/tbuild.ads ada/tbuild.adb ada/tree_io.ads \ + ada/ttypes.ads ada/types.ads ada/uintp.ads ada/uname.ads \ + ada/unchconv.ads ada/unchdeal.ads ada/urealp.ads ada/validsw.ads ada/exp_ch6.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/aspects.ads ada/atree.ads \ @@ -2044,10 +2044,10 @@ ada/exp_pakd.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/exp_aggr.ads ada/exp_ch11.ads ada/exp_ch2.ads ada/exp_ch4.ads \ ada/exp_ch6.ads ada/exp_ch7.ads ada/exp_dbug.ads ada/exp_pakd.ads \ ada/exp_pakd.adb ada/exp_tss.ads ada/exp_util.ads ada/exp_util.adb \ - ada/freeze.ads ada/get_targ.ads ada/gnat.ads ada/g-htable.ads \ - ada/hostparm.ads ada/inline.ads ada/itypes.ads ada/layout.ads \ - ada/lib.ads ada/namet.ads ada/nlists.ads ada/nlists.adb ada/nmake.ads \ - ada/nmake.adb ada/opt.ads ada/output.ads ada/restrict.ads \ + ada/expander.ads ada/freeze.ads ada/get_targ.ads ada/gnat.ads \ + ada/g-htable.ads ada/hostparm.ads ada/inline.ads ada/itypes.ads \ + ada/layout.ads ada/lib.ads ada/namet.ads ada/nlists.ads ada/nlists.adb \ + ada/nmake.ads ada/nmake.adb ada/opt.ads ada/output.ads ada/restrict.ads \ ada/rident.ads ada/rtsfind.ads ada/sem.ads ada/sem_aux.ads \ ada/sem_ch13.ads ada/sem_ch3.ads ada/sem_ch8.ads ada/sem_eval.ads \ ada/sem_prag.ads ada/sem_res.ads ada/sem_type.ads ada/sem_util.ads \ @@ -4179,15 +4179,16 @@ ada/switch-b.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/types.ads ada/unchconv.ads ada/unchdeal.ads ada/switch-c.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ - ada/a-uncdea.ads ada/alloc.ads ada/debug.ads ada/gnatvsn.ads \ - ada/hostparm.ads ada/lib.ads ada/namet.ads ada/opt.ads ada/osint.ads \ - ada/output.ads ada/stylesw.ads ada/switch.ads ada/switch-c.ads \ - ada/switch-c.adb ada/system.ads ada/s-exctab.ads ada/s-memory.ads \ - ada/s-os_lib.ads ada/s-parame.ads ada/s-soflin.ads ada/s-stache.ads \ - ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb ada/s-string.ads \ - ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads ada/table.ads \ - ada/table.adb ada/tree_io.ads ada/types.ads ada/unchconv.ads \ - ada/unchdeal.ads ada/validsw.ads ada/warnsw.ads + ada/a-uncdea.ads ada/alloc.ads ada/debug.ads ada/get_targ.ads \ + ada/gnatvsn.ads ada/hostparm.ads ada/lib.ads ada/namet.ads ada/opt.ads \ + ada/osint.ads ada/output.ads ada/stylesw.ads ada/switch.ads \ + ada/switch-c.ads ada/switch-c.adb ada/system.ads ada/s-exctab.ads \ + ada/s-memory.ads ada/s-os_lib.ads ada/s-parame.ads ada/s-soflin.ads \ + ada/s-stache.ads ada/s-stalib.ads ada/s-stoele.ads ada/s-stoele.adb \ + ada/s-string.ads ada/s-traent.ads ada/s-unstyp.ads ada/s-wchcon.ads \ + ada/table.ads ada/table.adb ada/tree_io.ads ada/ttypes.ads \ + ada/types.ads ada/unchconv.ads ada/unchdeal.ads ada/validsw.ads \ + ada/warnsw.ads ada/switch.o : ada/ada.ads ada/a-except.ads ada/a-unccon.ads \ ada/a-uncdea.ads ada/alloc.ads ada/debug.ads ada/gnatvsn.ads \ diff --git a/gcc/ada/gprep.adb b/gcc/ada/gprep.adb index f6ce3acf02e..0fad22bf7a7 100644 --- a/gcc/ada/gprep.adb +++ b/gcc/ada/gprep.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2002-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 2002-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -720,7 +720,7 @@ package body GPrep is loop begin - Switch := GNAT.Command_Line.Getopt ("D: b c C r s T u v"); + Switch := GNAT.Command_Line.Getopt ("D: a b c C r s T u v"); case Switch is @@ -731,6 +731,10 @@ package body GPrep is Process_Command_Line_Symbol_Definition (S => GNAT.Command_Line.Parameter); + when 'a' => + Opt.No_Deletion := True; + Opt.Undefined_Symbols_Are_False := True; + when 'b' => Opt.Blank_Deleted_Lines := True; diff --git a/gcc/ada/init.c b/gcc/ada/init.c index 8a27a601617..ad00e148fcc 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -103,12 +103,14 @@ char *__gl_interrupt_states = 0; int __gl_num_interrupt_states = 0; int __gl_unreserve_all_interrupts = 0; int __gl_exception_tracebacks = 0; -int __gl_zero_cost_exceptions = 0; int __gl_detect_blocking = 0; int __gl_default_stack_size = -1; int __gl_leap_seconds_support = 0; int __gl_canonical_streams = 0; +/* This value is not used anymore, but kept for bootstrapping purpose. */ +int __gl_zero_cost_exceptions = 0; + /* Indication of whether synchronous signal handler has already been installed by a previous call to adainit. */ int __gnat_handler_installed = 0; diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 184b09758a3..88194b3023b 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -968,6 +968,12 @@ package Opt is -- in this variable (e.g. 2 = select second unit in file). A value of -- zero indicates that we are in normal (one unit per file) mode. + No_Deletion : Boolean := False; + -- GNATPREP + -- Set by preprocessor switch -a. Do not eliminate any source text. Implies + -- Undefined_Symbols_Are_False. Useful to perform a syntax check on all + -- branches of #if constructs. + No_Main_Subprogram : Boolean := False; -- GNATMAKE, GNATBIND -- Set to True if compilation/binding of a program without main diff --git a/gcc/ada/prep.adb b/gcc/ada/prep.adb index 2b0e1378bce..3ec2087926a 100644 --- a/gcc/ada/prep.adb +++ b/gcc/ada/prep.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2002-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 2002-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -292,8 +292,8 @@ package body Prep is Result.Value := End_String; end if; - -- Now, check the syntax of the symbol (we don't allow accented and - -- wide characters) + -- Now, check the syntax of the symbol (we don't allow accented or + -- wide characters). if Name_Buffer (1) not in 'a' .. 'z' and then Name_Buffer (1) not in 'A' .. 'Z' @@ -356,7 +356,7 @@ package body Prep is begin -- Always return False when not inside an #if statement - if Pp_States.Last = Ground then + if Opt.No_Deletion or else Pp_States.Last = Ground then return False; else return Pp_States.Table (Pp_States.Last).Deleting; diff --git a/gcc/ada/prepcomp.adb b/gcc/ada/prepcomp.adb index 2da21df3c42..dd64bcb714b 100644 --- a/gcc/ada/prepcomp.adb +++ b/gcc/ada/prepcomp.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2003-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 2003-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -60,6 +60,7 @@ package body Prepcomp is Undef_False : Boolean := False; Always_Blank : Boolean := False; Comments : Boolean := False; + No_Deletion : Boolean := False; List_Symbols : Boolean := False; Processed : Boolean := False; end record; @@ -73,6 +74,7 @@ package body Prepcomp is Undef_False => False, Always_Blank => False, Comments => False, + No_Deletion => False, List_Symbols => False, Processed => False); @@ -330,6 +332,16 @@ package body Prepcomp is -- significant. case Sinput.Source (Token_Ptr) is + when 'a' => + + -- All source text preserved (also implies -u) + + if Name_Len = 1 then + Current_Data.No_Deletion := True; + Current_Data.Undef_False := True; + OK := True; + end if; + when 'u' => -- Undefined symbol are False @@ -581,15 +593,15 @@ package body Prepcomp is -- Set the preprocessing flags according to the preprocessing data - if Current_Data.Comments and then not Current_Data.Always_Blank then + if Current_Data.Comments and not Current_Data.Always_Blank then Comment_Deleted_Lines := True; Blank_Deleted_Lines := False; - else Comment_Deleted_Lines := False; Blank_Deleted_Lines := True; end if; + No_Deletion := Current_Data.No_Deletion; Undefined_Symbols_Are_False := Current_Data.Undef_False; List_Preprocessing_Symbols := Current_Data.List_Symbols; diff --git a/gcc/ada/prj-proc.adb b/gcc/ada/prj-proc.adb index 1d5c7738e52..cb9d533c765 100644 --- a/gcc/ada/prj-proc.adb +++ b/gcc/ada/prj-proc.adb @@ -1588,7 +1588,7 @@ package body Prj.Proc is Add_Attributes (Project, Project.Name, - Name_Id (Project.Directory.Name), + Name_Id (Project.Directory.Display_Name), Shared, Shared.Packages.Table (New_Pkg).Decl, First_Attribute_Of @@ -2850,7 +2850,7 @@ package body Prj.Proc is Add_Attributes (Project, Name, - Name_Id (Project.Directory.Name), + Name_Id (Project.Directory.Display_Name), In_Tree.Shared, Project.Decl, Prj.Attr.Attribute_First, diff --git a/gcc/ada/projects.texi b/gcc/ada/projects.texi index 2fff4eb1fab..fafb1d125de 100644 --- a/gcc/ada/projects.texi +++ b/gcc/ada/projects.texi @@ -1033,7 +1033,7 @@ names in lower case) After building an application or a library it is often required to install it into the development environment. This installation is required if the library is to be used by another application for -example. The @code{gprinstall} tool provide an easy way to install +example. The @command{gprinstall} tool provide an easy way to install libraries, executable or object code generated durting the build. The @b{Install} package can be used to change the default locations. @@ -1963,11 +1963,10 @@ included in the library. @c --------------------------------------------- @noindent -When using project files, library installation is part of the library build -process. Thus no further action is needed in order to make use of the -libraries that are built as part of the general application build. A usable -version of the library is installed in the directory specified by the -@code{Library_Dir} attribute of the library project file. +When using project files, a usable version of the library is created in the +directory specified by the @code{Library_Dir} attribute of the library +project file. Thus no further action is needed in order to make use of +the libraries that are built as part of the general application build. You may want to install a library in a context different from where the library is built. This situation arises with third party suppliers, who may want @@ -1976,6 +1975,12 @@ able to recompile the library. The simplest option in this case is to provide a project file slightly different from the one used to build the library, by using the @code{externally_built} attribute. @ref{Using Library Projects} +Another option is to use @command{gprinstall} to install the library in a +different context than the build location. A project to use this library is +generated automatically by @command{gprinstall} which also copy, in the install +location, the minimum set of sources needed to use the library. +@ref{Installation} + @c --------------------------------------------- @node Project Extension @section Project Extension @@ -2243,8 +2248,8 @@ Very often, modules will build their own executables (for testing purposes for instance), or libraries (for easier reuse in various contexts). -However, if you build your project through gnatmake or gprbuild, using -a syntax similar to +However, if you build your project through @command{gnatmake} or +@command{gprbuild}, using a syntax similar to @smallexample gprbuild -PA.gpr @@ -2252,9 +2257,9 @@ a syntax similar to this will only rebuild the main programs of project A, not those of the imported projects B and C. Therefore you have to spawn several -gnatmake commands, one per project, to build all executables. +@command{gnatmake} commands, one per project, to build all executables. This is a little inconvenient, but more importantly is inefficient -because gnatmake needs to do duplicate work to ensure that sources are +because @command{gnatmake} needs to do duplicate work to ensure that sources are up-to-date, and cannot easily compile things in parallel when using the -j switch. @@ -2295,14 +2300,14 @@ that are built independently from each other (but can be built in parallel). For instance, you have a project tree rooted at A, and another one (which might share some subprojects) rooted at B. -Using only gprbuild, you could do +Using only @command{gprbuild}, you could do @smallexample gprbuild -PA.gpr gprbuild -PB.gpr @end smallexample -to build both. But again, gprbuild has to do some duplicate work for +to build both. But again, @command{gprbuild} has to do some duplicate work for those files that are shared between the two, and cannot truly build things in parallel efficiently. @@ -2316,7 +2321,7 @@ sources. This scenario is particularly useful in environments like VxWorks 653 where the applications running in the multiple partitions can be built -in parallel through a single gprbuild command. This also works nicely +in parallel through a single @command{gprbuild} command. This also works nicely with Annex E. @c --------------------------------------------- @@ -2324,9 +2329,9 @@ with Annex E. @subsection Define a build environment @c --------------------------------------------- -The environment variables at the time you launch gprbuild or gprbuild -will influence the view these tools have of the project (PATH to find -the compiler, ADA_PROJECT_PATH or GPR_PROJECT_PATH to find the +The environment variables at the time you launch @command{gprbuild} or +@command{gnatmake} will influence the view these tools have of the project +(PATH to find the compiler, ADA_PROJECT_PATH or GPR_PROJECT_PATH to find the projects, environment variables that are referenced in project files through the "external" statement,...). Several command line switches can be used to override those (-X or -aP), but on some systems and @@ -2382,19 +2387,19 @@ end MyProject; @subsection Performance improvements in builder @c -------------------------------------------- -The loading of aggregate projects is optimized in gprbuild and -gnatmake, so that all files are searched for only once on the disk +The loading of aggregate projects is optimized in @command{gprbuild} and +@command{gnatmake}, so that all files are searched for only once on the disk (thus reducing the number of system calls and contributing to faster compilation times especially on systems with sources on remote -servers). As part of the loading, gprbuild and gnatmake compute how -and where a source file should be compiled, and even if it is found +servers). As part of the loading, @command{gprbuild} and @command{gnatmake} +compute how and where a source file should be compiled, and even if it is found several times in the aggregated projects it will be compiled only once. Since there is no ambiguity as to which switches should be used, files can be compiled in parallel (through the usual -j switch) and this can be done while maximizing the use of CPUs (compared to launching -multiple gprbuild and gnatmake commands in parallel). +multiple @command{gprbuild} and @command{gnatmake} commands in parallel). @c ------------------------------------- @node Syntax of aggregate projects @@ -2577,15 +2582,15 @@ These override the value given by the attribute, so that users can override the value set in the (presumably shared with others in his team) aggregate project. -@item The -X command line switch to gprbuild and gnatmake +@item The -X command line switch to @command{gprbuild} and @command{gnatmake} This always takes precedence. @end itemize This attribute is only taken into account in the main aggregate -project (i.e. the one specified on the command line to gprbuild or -natmake), and ignored in other aggregate projects. It is invalid +project (i.e. the one specified on the command line to @command{gprbuild} or +@command{gnatmake}), and ignored in other aggregate projects. It is invalid in standard projects. The goal is to have a consistent value in all projects that are built through the aggregate, which would not @@ -2610,8 +2615,8 @@ are valid: @item @b{Switches}: @cindex @code{Switches} This attribute gives the list of switches to use for the builder -(gprbuild or gnatmake), depending on the language of the main file. -For instance, +(@command{gprbuild} or @command{gnatmake}), depending on the language of the +main file. For instance, @smallexample @c projectfile for Switches ("Ada") use ("-d", "-p"); @@ -2995,7 +3000,7 @@ from other project or library project files. @item @b{library}: a library project must declare both attributes @code{Library_Name} and @code{Library_Dir}. @item @b{configuration}: a configuration project cannot be in a project tree. - It describes compilers and other tools to @code{gprbuild}. + It describes compilers and other tools to @command{gprbuild}. @end table @c --------------------------------------------- @@ -3263,7 +3268,7 @@ Here are some specific examples: @noindent An external value is an expression whose value is obtained from the command that invoked the processing of the current project file (typically a -gnatmake or gprbuild command). +@command{gnatmake} or @command{gprbuild} command). There are two kinds of external values, one that returns a single string, and one that returns a string list. @@ -3878,11 +3883,12 @@ Follow all symbolic links when processing project files. @item ^--subdirs^/SUBDIRS^=<subdir> @cindex @option{^--subdirs^/SUBDIRS^=} (gnatmake and gnatclean) -This switch is recognized by gnatmake and gnatclean. It indicate that the real -directories (except the source directories) are the subdirectories <subdir> -of the directories specified in the project files. This applies in particular -to object directories, library directories and exec directories. If the -subdirectories do not exist, they are created automatically. +This switch is recognized by @command{gnatmake} and @command{gnatclean}. It +indicate that the real directories (except the source directories) are the +subdirectories <subdir> of the directories specified in the project files. +This applies in particular to object directories, library directories and +exec directories. If the subdirectories do not exist, they are created +automatically. @end table @@ -4592,7 +4598,7 @@ e.g.@: @code{"wtx"} or @code{"vxworks"}. This is an associative array attribute, whose domain is a language name. Its value is string that denotes the command to be used to invoke the compiler. The value of @code{Compiler_Command ("Ada")} is expected to be compatible with -gnatmake, in particular in the handling of switches. +@command{gnatmake}, in particular in the handling of switches. @item Debugger_Command This is simple attribute, Its value is a string that specifies the name of diff --git a/gcc/ada/s-bignum.adb b/gcc/ada/s-bignum.adb index 69772772f55..b3af4796136 100644 --- a/gcc/ada/s-bignum.adb +++ b/gcc/ada/s-bignum.adb @@ -341,6 +341,17 @@ package body System.Bignums is begin Free_Bignum (XY2); + -- Raise storage error if intermediate value is getting too + -- large, which we arbitrarily define as 200 words for now! + + if XY2S.Len > 200 then + Free_Bignum (XY2S); + raise Storage_Error with + "exponentiation result is too large"; + end if; + + -- Otherwise take care of even/odd cases + if (Y and 1) = 0 then return XY2S; diff --git a/gcc/ada/s-exnllf.adb b/gcc/ada/s-exnllf.adb index a1e59c179e0..c6765e8fe9a 100644 --- a/gcc/ada/s-exnllf.adb +++ b/gcc/ada/s-exnllf.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009 Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -37,8 +37,7 @@ package body System.Exn_LLF is function Exn_Long_Long_Float (Left : Long_Long_Float; - Right : Integer) - return Long_Long_Float + Right : Integer) return Long_Long_Float is Result : Long_Long_Float := 1.0; Factor : Long_Long_Float := Left; diff --git a/gcc/ada/s-exnllf.ads b/gcc/ada/s-exnllf.ads index 59575b0e088..ba2828277b7 100644 --- a/gcc/ada/s-exnllf.ads +++ b/gcc/ada/s-exnllf.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2009 Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -36,7 +36,6 @@ package System.Exn_LLF is function Exn_Long_Long_Float (Left : Long_Long_Float; - Right : Integer) - return Long_Long_Float; + Right : Integer) return Long_Long_Float; end System.Exn_LLF; diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index ded081fc3e1..0a90eb2e80a 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -164,6 +164,11 @@ package body Sem_Ch10 is -- an enclosing scope. Iterate over context to find child units of U_Name -- or of some ancestor of it. + function Is_Ancestor_Unit (U1 : Node_Id; U2 : Node_Id) return Boolean; + -- When compiling a unit Q descended from some parent unit P, a limited + -- with_clause in the context of P that names some other ancestor of Q + -- must not be installed because the ancestor is immediately visible. + function Is_Child_Spec (Lib_Unit : Node_Id) return Boolean; -- Lib_Unit is a library unit which may be a spec or a body. Is_Child_Spec -- returns True if Lib_Unit is a library spec which is a child spec, i.e. @@ -3521,11 +3526,6 @@ package body Sem_Ch10 is -- units. The shadow entities are created when the inserted clause is -- analyzed. Implements Ada 2005 (AI-50217). - function Is_Ancestor_Unit (U1 : Node_Id; U2 : Node_Id) return Boolean; - -- When compiling a unit Q descended from some parent unit P, a limited - -- with_clause in the context of P that names some other ancestor of Q - -- must not be installed because the ancestor is immediately visible. - --------------------- -- Check_Renamings -- --------------------- @@ -3794,22 +3794,6 @@ package body Sem_Ch10 is end if; end Expand_Limited_With_Clause; - ---------------------- - -- Is_Ancestor_Unit -- - ---------------------- - - function Is_Ancestor_Unit (U1 : Node_Id; U2 : Node_Id) return Boolean is - E1 : constant Entity_Id := Defining_Entity (Unit (U1)); - E2 : Entity_Id; - begin - if Nkind_In (Unit (U2), N_Package_Body, N_Subprogram_Body) then - E2 := Defining_Entity (Unit (Library_Unit (U2))); - return Is_Ancestor_Package (E1, E2); - else - return False; - end if; - end Is_Ancestor_Unit; - -- Start of processing for Install_Limited_Context_Clauses begin @@ -4061,8 +4045,17 @@ package body Sem_Ch10 is if Nkind (Item) = N_With_Clause and then Private_Present (Item) then + -- If the unit is an ancestor of the current one, it is the + -- case of a private limited with clause on a child unit, and + -- the compilation of one of its descendants, In that case the + -- limited view is errelevant. + if Limited_Present (Item) then - if not Limited_View_Installed (Item) then + if not Limited_View_Installed (Item) + and then + not Is_Ancestor_Unit (Library_Unit (Item), + Cunit (Current_Sem_Unit)) + then Install_Limited_Withed_Unit (Item); end if; else @@ -5269,6 +5262,22 @@ package body Sem_Ch10 is (C_Unit, Cunit_Entity (Get_Source_Unit (Non_Limited_View (T)))); end Is_Legal_Shadow_Entity_In_Body; + ---------------------- + -- Is_Ancestor_Unit -- + ---------------------- + + function Is_Ancestor_Unit (U1 : Node_Id; U2 : Node_Id) return Boolean is + E1 : constant Entity_Id := Defining_Entity (Unit (U1)); + E2 : Entity_Id; + begin + if Nkind_In (Unit (U2), N_Package_Body, N_Subprogram_Body) then + E2 := Defining_Entity (Unit (Library_Unit (U2))); + return Is_Ancestor_Package (E1, E2); + else + return False; + end if; + end Is_Ancestor_Unit; + ----------------------- -- Load_Needed_Body -- ----------------------- diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index cb54be10215..7dd808c0d0d 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -23,6 +23,7 @@ -- -- ------------------------------------------------------------------------------ +with Aspects; use Aspects; with Atree; use Atree; with Checks; use Checks; with Debug; use Debug; @@ -14805,6 +14806,11 @@ package body Sem_Ch3 is New_Id : Entity_Id; Prev_Par : Node_Id; + procedure Check_Duplicate_Aspects; + -- Check that aspects specified in a completion have not been specified + -- already in the partial view. Type_Invariant and others can be + -- specified on either view but never on both. + procedure Tag_Mismatch; -- Diagnose a tagged partial view whose full view is untagged. -- We post the message on the full view, with a reference to @@ -14813,6 +14819,38 @@ package body Sem_Ch3 is -- so we determine the position of the error message from the -- respective slocs of both. + ----------------------------- + -- Check_Duplicate_Aspects -- + ----------------------------- + procedure Check_Duplicate_Aspects is + Prev_Aspects : constant List_Id := Aspect_Specifications (Prev_Par); + Full_Aspects : constant List_Id := Aspect_Specifications (N); + F_Spec, P_Spec : Node_Id; + + begin + if Present (Prev_Aspects) and then Present (Full_Aspects) then + F_Spec := First (Full_Aspects); + while Present (F_Spec) loop + P_Spec := First (Prev_Aspects); + while Present (P_Spec) loop + if + Chars (Identifier (P_Spec)) = Chars (Identifier (F_Spec)) + then + Error_Msg_N + ("aspect already specified in private declaration", + F_Spec); + Remove (F_Spec); + return; + end if; + + Next (P_Spec); + end loop; + + Next (F_Spec); + end loop; + end if; + end Check_Duplicate_Aspects; + ------------------ -- Tag_Mismatch -- ------------------ @@ -15022,6 +15060,10 @@ package body Sem_Ch3 is ("declaration of full view must appear in private part", N); end if; + if Ada_Version >= Ada_2012 then + Check_Duplicate_Aspects; + end if; + Copy_And_Swap (Prev, Id); Set_Has_Private_Declaration (Prev); Set_Has_Private_Declaration (Id); diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 64b40e6a397..9d63e886aaf 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -5888,14 +5888,36 @@ package body Sem_Ch4 is begin if not Is_Overloaded (R) then if Is_Numeric_Type (Etype (R)) then - Add_One_Interp (N, Op_Id, Base_Type (Etype (R))); + + -- In an instance a generic actual may be a numeric type even if + -- the formal in the generic unit was not. In that case, the + -- predefined operator was not a possible interpretation in the + -- generic, and cannot be one in the instance. + + if In_Instance + and then + not Is_Numeric_Type (Corresponding_Generic_Type (Etype (R))) + then + null; + else + Add_One_Interp (N, Op_Id, Base_Type (Etype (R))); + end if; end if; else Get_First_Interp (R, Index, It); while Present (It.Typ) loop if Is_Numeric_Type (It.Typ) then - Add_One_Interp (N, Op_Id, Base_Type (It.Typ)); + if In_Instance + and then + not Is_Numeric_Type + (Corresponding_Generic_Type (Etype (It.Typ))) + then + null; + + else + Add_One_Interp (N, Op_Id, Base_Type (It.Typ)); + end if; end if; Get_Next_Interp (Index, It); diff --git a/gcc/ada/sem_ch9.adb b/gcc/ada/sem_ch9.adb index d40647ed7ad..a81ea5c6148 100644 --- a/gcc/ada/sem_ch9.adb +++ b/gcc/ada/sem_ch9.adb @@ -1345,9 +1345,10 @@ package body Sem_Ch9 is -- Check for unreferenced variables etc. Before the Check_References -- call, we transfer Never_Set_In_Source and Referenced flags from -- parameters in the spec to the corresponding entities in the body, - -- since we want the warnings on the body entities. Note that we do - -- not have to transfer Referenced_As_LHS, since that flag can only - -- be set for simple variables. + -- since we want the warnings on the body entities. Note that we do not + -- have to transfer Referenced_As_LHS, since that flag can only be set + -- for simple variables, but we include Has_Pragma_Unreferenced, + -- which may have been specified for a formal in the body. -- At the same time, we set the flags on the spec entities to suppress -- any warnings on the spec formals, since we also scan the spec. @@ -1382,6 +1383,7 @@ package body Sem_Ch9 is Set_Referenced (E2, Referenced (E1)); Set_Referenced (E1); + Set_Has_Pragma_Unreferenced (E2, Has_Pragma_Unreferenced (E1)); Set_Entry_Component (E2, Entry_Component (E1)); <<Continue>> diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index 116864aa2a9..f7e774308fb 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -37,6 +37,7 @@ with Namet; use Namet; with Nmake; use Nmake; with Nlists; use Nlists; with Opt; use Opt; +with Rtsfind; use Rtsfind; with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Cat; use Sem_Cat; @@ -198,7 +199,7 @@ package body Sem_Eval is -- Tests to see if expression N whose single operand is Op1 is foldable, -- i.e. the operand value is known at compile time. If the operation is -- foldable, then Fold is True on return, and Stat indicates whether - -- the result is static (i.e. both operands were static). Note that it + -- the result is static (i.e. the operand was static). Note that it -- is quite possible for Fold to be True, and Stat to be False, since -- there are cases in which we know the value of an operand even though -- it is not technically static (e.g. the static lower bound of a range @@ -232,7 +233,7 @@ package body Sem_Eval is Stat : out Boolean; Fold : out Boolean); -- Same processing, except applies to an expression N with two operands - -- Op1 and Op2. + -- Op1 and Op2. The result is static only if both operands are static. function Test_In_Range (N : Node_Id; @@ -240,11 +241,11 @@ package body Sem_Eval is Assume_Valid : Boolean; Fixed_Int : Boolean; Int_Real : Boolean) return Range_Membership; - -- Common processing for Is_In_Range and Is_Out_Of_Range: - -- Returns In_Range or Out_Of_Range if it can be guaranteed at compile time - -- that expression N is known to be in or out of range of the subtype Typ. - -- If not compile time known, Unknown is returned. - -- See documentation of Is_In_Range for complete description of parameters. + -- Common processing for Is_In_Range and Is_Out_Of_Range: Returns In_Range + -- or Out_Of_Range if it can be guaranteed at compile time that expression + -- N is known to be in or out of range of the subtype Typ. If not compile + -- time known, Unknown is returned. See documentation of Is_In_Range for + -- complete description of parameters. procedure To_Bits (U : Uint; B : out Bits); -- Converts a Uint value to a bit string of length B'Length @@ -942,7 +943,49 @@ package body Sem_Eval is end if; end if; - -- Try range analysis on variables and see if ranges are disjoint + -- First attempt is to decompose the expressions to extract a + -- constant offset resulting from the use of any of the forms: + + -- expr + literal + -- expr - literal + -- typ'Succ (expr) + -- typ'Pred (expr) + + -- Then we see if the two expressions are the same value, and if so + -- the result is obtained by comparing the offsets. + + -- Note: the reason we do this test first is that it returns only + -- decisive results (with diff set), where other tests, like the + -- range test, may not be as so decisive. Consider for example + -- J .. J + 1. This code can conclude LT with a difference of 1, + -- even if the range of J is not known. + + declare + Lnode : Node_Id; + Loffs : Uint; + Rnode : Node_Id; + Roffs : Uint; + + begin + Compare_Decompose (L, Lnode, Loffs); + Compare_Decompose (R, Rnode, Roffs); + + if Is_Same_Value (Lnode, Rnode) then + if Loffs = Roffs then + return EQ; + + elsif Loffs < Roffs then + Diff.all := Roffs - Loffs; + return LT; + + else + Diff.all := Loffs - Roffs; + return GT; + end if; + end if; + end; + + -- Next, try range analysis and see if operand ranges are disjoint declare LOK, ROK : Boolean; @@ -1074,42 +1117,6 @@ package body Sem_Eval is end if; end if; - -- Next attempt is to decompose the expressions to extract - -- a constant offset resulting from the use of any of the forms: - - -- expr + literal - -- expr - literal - -- typ'Succ (expr) - -- typ'Pred (expr) - - -- Then we see if the two expressions are the same value, and if so - -- the result is obtained by comparing the offsets. - - declare - Lnode : Node_Id; - Loffs : Uint; - Rnode : Node_Id; - Roffs : Uint; - - begin - Compare_Decompose (L, Lnode, Loffs); - Compare_Decompose (R, Rnode, Roffs); - - if Is_Same_Value (Lnode, Rnode) then - if Loffs = Roffs then - return EQ; - - elsif Loffs < Roffs then - Diff.all := Roffs - Loffs; - return LT; - - else - Diff.all := Loffs - Roffs; - return GT; - end if; - end if; - end; - -- Next attempt is to see if we have an entity compared with a -- compile time known value, where there is a current value -- conditional for the entity which can tell us the result. @@ -4039,12 +4046,18 @@ package body Sem_Eval is -- We now have the literal with the right value, both the actual type -- and the expected type of this literal are taken from the expression - -- that was evaluated. + -- that was evaluated. So now we do the Analyze and Resolve. + + -- Note that we have to reset Is_Static_Expression both after the + -- analyze step (because Resolve will evaluate the literal, which + -- will cause semantic errors if it is marked as static), and after + -- the Resolve step (since Resolve in some cases sets this flag). Analyze (N); Set_Is_Static_Expression (N, Static); Set_Etype (N, Typ); Resolve (N); + Set_Is_Static_Expression (N, Static); end Fold_Str; --------------- @@ -4093,12 +4106,18 @@ package body Sem_Eval is -- We now have the literal with the right value, both the actual type -- and the expected type of this literal are taken from the expression - -- that was evaluated. + -- that was evaluated. So now we do the Analyze and Resolve. + + -- Note that we have to reset Is_Static_Expression both after the + -- analyze step (because Resolve will evaluate the literal, which + -- will cause semantic errors if it is marked as static), and after + -- the Resolve step (since Resolve in some cases sets this flag). Analyze (N); Set_Is_Static_Expression (N, Static); Set_Etype (N, Typ); Resolve (N); + Set_Is_Static_Expression (N, Static); end Fold_Uint; ---------------- @@ -4128,12 +4147,20 @@ package body Sem_Eval is Set_Original_Entity (N, Ent); - -- Both the actual and expected type comes from the original expression + -- We now have the literal with the right value, both the actual type + -- and the expected type of this literal are taken from the expression + -- that was evaluated. So now we do the Analyze and Resolve. + + -- Note that we have to reset Is_Static_Expression both after the + -- analyze step (because Resolve will evaluate the literal, which + -- will cause semantic errors if it is marked as static), and after + -- the Resolve step (since Resolve in some cases sets this flag). Analyze (N); Set_Is_Static_Expression (N, Static); Set_Etype (N, Typ); Resolve (N); + Set_Is_Static_Expression (N, Static); end Fold_Ureal; --------------- @@ -5413,10 +5440,12 @@ package body Sem_Eval is return; end if; - -- Type must be scalar or string type + -- Type must be scalar or string type (but allow Bignum, since this + -- is really a scalar type from our point of view in this diagnosis). if not Is_Scalar_Type (Typ) and then not Is_String_Type (Typ) + and then not Is_RTE (Typ, RE_Bignum) then Error_Msg_N ("static expression must have scalar or string type " & @@ -5533,7 +5562,14 @@ package body Sem_Eval is when N_Function_Call => Why_Not_Static_List (Parameter_Associations (N)); - Error_Msg_N ("non-static function call (RM 4.9(6,18))!", N); + + -- Complain about non-static function call unless we have Bignum + -- which means that the underlying expression is really some + -- scalar arithmetic operation. + + if not Is_RTE (Typ, RE_Bignum) then + Error_Msg_N ("non-static function call (RM 4.9(6,18))!", N); + end if; when N_Parameter_Association => Why_Not_Static (Explicit_Actual_Parameter (N)); diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 029b94b124d..258ec5b1685 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -14802,10 +14802,17 @@ package body Sem_Prag is loop Set_Warnings_Off (E, (Chars (Get_Pragma_Arg (Arg1)) = - Name_Off)); + Name_Off)); + + -- For OFF case, make entry in warnings off + -- pragma table for later processing. But we do + -- not do that within an instance, since these + -- warnings are about what is needed in the + -- template, not an instance of it. if Chars (Get_Pragma_Arg (Arg1)) = Name_Off and then Warn_On_Warnings_Off + and then not In_Instance then Warnings_Off_Pragmas.Append ((N, E)); end if; diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 81c4e142cab..4383754fa31 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -7685,10 +7685,11 @@ package body Sem_Res is ---------------------------- procedure Resolve_Set_Membership is - Alt : Node_Id; + Alt : Node_Id; + Ltyp : constant Entity_Id := Etype (L); begin - Resolve (L, Etype (L)); + Resolve (L, Ltyp); Alt := First (Alternatives (N)); while Present (Alt) loop @@ -7699,11 +7700,51 @@ package body Sem_Res is if not Is_Entity_Name (Alt) or else not Is_Type (Entity (Alt)) then - Resolve (Alt, Etype (L)); + Resolve (Alt, Ltyp); end if; Next (Alt); end loop; + + -- Check for duplicates for discrete case + + if Is_Discrete_Type (Ltyp) then + declare + type Ent is record + Alt : Node_Id; + Val : Uint; + end record; + + Alts : array (0 .. List_Length (Alternatives (N))) of Ent; + Nalts : Nat; + + begin + -- Loop checking duplicates. This is quadratic, but giant sets + -- are unlikely in this context so it's a reasonable choice. + + Nalts := 0; + Alt := First (Alternatives (N)); + while Present (Alt) loop + if Is_Static_Expression (Alt) + and then (Nkind_In (Alt, N_Integer_Literal, + N_Character_Literal) + or else Nkind (Alt) in N_Has_Entity) + then + Nalts := Nalts + 1; + Alts (Nalts) := (Alt, Expr_Value (Alt)); + + for J in 1 .. Nalts - 1 loop + if Alts (J).Val = Alts (Nalts).Val then + Error_Msg_Sloc := Sloc (Alts (J).Alt); + Error_Msg_N ("duplicate of value given#?", Alt); + end if; + end loop; + end if; + + Alt := Next (Alt); + end loop; + end; + end if; end Resolve_Set_Membership; -- Start of processing for Resolve_Membership_Op diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 2e68039262f..2202c886766 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -2489,6 +2489,45 @@ package body Sem_Util is return Plist; end Copy_Parameter_List; + -------------------------------- + -- Corresponding_Generic_Type -- + -------------------------------- + + function Corresponding_Generic_Type (T : Entity_Id) return Entity_Id is + Inst : Entity_Id; + Gen : Entity_Id; + Typ : Entity_Id; + + begin + if not Is_Generic_Actual_Type (T) then + return Any_Type; + + else + Inst := Scope (T); + + if Is_Wrapper_Package (Inst) then + Inst := Related_Instance (Inst); + end if; + + Gen := + Generic_Parent + (Specification (Unit_Declaration_Node (Inst))); + + -- Generic actual has the same name as the corresponding formal + + Typ := First_Entity (Gen); + while Present (Typ) loop + if Chars (Typ) = Chars (T) then + return Typ; + end if; + + Next_Entity (Typ); + end loop; + + return Any_Type; + end if; + end Corresponding_Generic_Type; + -------------------- -- Current_Entity -- -------------------- diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 57c4880b425..1b089b85ee7 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -299,6 +299,12 @@ package Sem_Util is -- create a new compatible record type. Loc is the source location assigned -- to the created nodes. + function Corresponding_Generic_Type (T : Entity_Id) return Entity_Id; + -- If a type is a generic actual type, return the corresponding formal in + -- the generic parent unit. There is no direct link in the tree for this + -- attribute, except in the case of formal private and derived types. + -- Possible optimization??? + function Current_Entity (N : Node_Id) return Entity_Id; pragma Inline (Current_Entity); -- Find the currently visible definition for a given identifier, that is to diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads index 41998908b75..39e9acba824 100644 --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -12419,15 +12419,4 @@ package Sinfo is pragma Inline (Set_Was_Originally_Stub); pragma Inline (Set_Withed_Body); - -------------- - -- Synonyms -- - -------------- - - -- These synonyms are to aid in transition, they should eventually be - -- removed when all remaining references to the obsolete name are gone. - - N_Return_Statement : constant Node_Kind := N_Simple_Return_Statement; - -- Rename N_Simple_Return_Statement to be N_Return_Statement. Clients - -- should refer to N_Simple_Return_Statement. - end Sinfo; diff --git a/gcc/ada/types.ads b/gcc/ada/types.ads index 73b11ac2d69..277bfd55146 100644 --- a/gcc/ada/types.ads +++ b/gcc/ada/types.ads @@ -737,7 +737,9 @@ package Types is subtype Minimized_Or_Eliminated is Overflow_Check_Type range Minimized .. Eliminated; - -- Definte subtypes so that clients don't need to know ordering. Note that + subtype Suppressed_Or_Checked is + Overflow_Check_Type range Suppressed .. Checked; + -- Define subtypes so that clients don't need to know ordering. Note that -- Overflow_Check_Type is not marked as an ordered enumeration type. -- The following structure captures the state of check suppression or diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index c26014ec469..0d112cfe7a7 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,7 +1,13 @@ +2012-10-04 Arnaud Charlet <charlet@adacore.com> + + * c-ada-spec.c (print_ada_declaration): Remove handling of TDF_RAW. + * c.opt (-fdump-ada-spec, -fdump-ada-spec-slim): Move switch definition + out of dumpfile.h. + 2012-09-25 Dehao Chen <dehao@google.com> PR middle-end/54645 - * c-family/c-pch.c (c_common_read_pch): Rebuild the location_adhoc_data + * c-pch.c (c_common_read_pch): Rebuild the location_adhoc_data map when read in the pch. 2012-09-18 Arnaud Charlet <charlet@adacore.com> diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 1e27e2c1e25..4f38a63ad89 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -2535,7 +2535,6 @@ print_ada_declaration (pretty_printer *buffer, tree t, tree type, int is_class = false; tree name = TYPE_NAME (TREE_TYPE (t)); tree decl_name = DECL_NAME (t); - bool dump_internal = get_dump_file_info (TDI_ada)->pflags & TDF_RAW; tree orig = NULL_TREE; if (cpp_check && cpp_check (t, IS_TEMPLATE)) @@ -2705,8 +2704,7 @@ print_ada_declaration (pretty_printer *buffer, tree t, tree type, } else { - if (!dump_internal - && TREE_CODE (t) == VAR_DECL + if (TREE_CODE (t) == VAR_DECL && decl_name && *IDENTIFIER_POINTER (decl_name) == '_') return 0; @@ -2796,8 +2794,7 @@ print_ada_declaration (pretty_printer *buffer, tree t, tree type, /* If this function has an entry in the dispatch table, we cannot omit it. */ - if (!dump_internal && !DECL_VINDEX (t) - && *IDENTIFIER_POINTER (decl_name) == '_') + if (!DECL_VINDEX (t) && *IDENTIFIER_POINTER (decl_name) == '_') { if (IDENTIFIER_POINTER (decl_name)[1] == '_') return 0; diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 6aa53a57744..b02c515327c 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -799,6 +799,14 @@ fdollars-in-identifiers C ObjC C++ ObjC++ Permit '$' as an identifier character +fdump-ada-spec +C ObjC C++ ObjC++ RejectNegative Var(flag_dump_ada_spec) +Write all declarations as Ada code transitively + +fdump-ada-spec-slim +C ObjC C++ ObjC++ RejectNegative Var(flag_dump_ada_spec_slim) +Write all declarations as Ada code for the given file only + felide-constructors C++ ObjC++ Var(flag_elide_constructors) Init(1) diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 770683c6ab5..257b752cca4 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2012-10-04 Arnaud Charlet <charlet@adacore.com> + + * c-decl.c (c_write_global_declarations): Fix handling of + -fdump-ada-spec*. + 2012-09-30 Sharad Singhai <singhai@google.com> * c-decl.c (c_write_global_declarations): Use a different method diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 1b4d764ca49..a4a8108d279 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -10079,10 +10079,10 @@ c_write_global_declarations (void) gcc_assert (!current_scope); /* Handle -fdump-ada-spec[-slim]. */ - if (dump_initialized_p (TDI_ada)) + if (flag_dump_ada_spec || flag_dump_ada_spec_slim) { /* Build a table of files to generate specs for */ - if (get_dump_file_info (TDI_ada)->pflags & TDF_SLIM) + if (flag_dump_ada_spec_slim) collect_source_ref (main_input_filename); else for_each_global_decl (collect_source_ref_cb); diff --git a/gcc/config.gcc b/gcc/config.gcc index 097d456f676..d3c7ed70cae 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -709,6 +709,11 @@ case ${target} in *-*-openbsd2.*|*-*-openbsd3.[012]) tm_defines="${tm_defines} HAS_LIBC_R=1" ;; esac + case ${target} in + *-*-openbsd4.[3-9]|*-*-openbsd[5-9]*) + default_use_cxa_atexit=yes + ;; + esac ;; *-*-rtems*) case ${enable_threads} in diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md index 284860e9ec5..d3ffd1aba41 100644 --- a/gcc/config/avr/avr.md +++ b/gcc/config/avr/avr.md @@ -395,7 +395,7 @@ ;; Secondary input reload from non-generic 16-bit address spaces (define_insn "reload_in<mode>" [(set (match_operand:MOVMODE 0 "register_operand" "=r") - (match_operand:MOVMODE 1 "memory_operand" "m")) + (match_operand:MOVMODE 1 "flash_operand" "m")) (clobber (match_operand:QI 2 "d_register_operand" "=d"))] ;; Fixme: The insn condition must not test the address space. ;; Because the gen tools refuse to generate insns for address spaces diff --git a/gcc/config/avr/predicates.md b/gcc/config/avr/predicates.md index 04587ae491f..fc4ca03de6b 100644 --- a/gcc/config/avr/predicates.md +++ b/gcc/config/avr/predicates.md @@ -72,6 +72,13 @@ (not (match_test "avr_load_libgcc_p (op)")) (not (match_test "avr_mem_memx_p (op)")))) +;; Return 1 if OP is a memory operand in one of the __flash* address spaces +(define_predicate "flash_operand" + (and (match_operand 0 "memory_operand") + (match_test "Pmode == mode") + (ior (match_test "!MEM_P (op)") + (match_test "avr_mem_flash_p (op)")))) + ;; Return 1 if OP is the zero constant for MODE. (define_predicate "const0_operand" (and (match_code "const_int,const_fixed,const_double") diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c index a642f66c40d..8e48c30575a 100644 --- a/gcc/config/darwin-c.c +++ b/gcc/config/darwin-c.c @@ -267,7 +267,7 @@ static struct framework_header framework_header_dirs[] = { static char * framework_construct_pathname (const char *fname, cpp_dir *dir) { - char *buf; + const char *buf; size_t fname_len, frname_len; cpp_dir *fast_dir; char *frname; @@ -344,7 +344,7 @@ find_subframework_file (const char *fname, const char *pname) { char *sfrname; const char *dot_framework = ".framework/"; - char *bufptr; + const char *bufptr; int sfrname_len, i, fname_len; struct cpp_dir *fast_dir; static struct cpp_dir subframe_dir; diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 54c92d16b75..5a9f50a9fdb 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -2623,7 +2623,7 @@ darwin_assemble_visibility (tree decl, int vis) { if (vis == VISIBILITY_DEFAULT) ; - else if (vis == VISIBILITY_HIDDEN) + else if (vis == VISIBILITY_HIDDEN || vis == VISIBILITY_INTERNAL) { fputs ("\t.private_extern ", asm_out_file); assemble_name (asm_out_file, @@ -2631,7 +2631,7 @@ darwin_assemble_visibility (tree decl, int vis) fputs ("\n", asm_out_file); } else - warning (OPT_Wattributes, "internal and protected visibility attributes " + warning (OPT_Wattributes, "protected visibility attribute " "not supported in this configuration; ignored"); } diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c index 4dffc51e4c9..36d80b1e621 100644 --- a/gcc/config/i386/driver-i386.c +++ b/gcc/config/i386/driver-i386.c @@ -473,7 +473,8 @@ const char *host_detect_local_cpu (int argc, const char **argv) : "c" (XCR_XFEATURE_ENABLED_MASK)); /* Check if SSE and YMM states are supported. */ - if ((eax & (XSTATE_SSE | XSTATE_YMM)) == (XSTATE_SSE | XSTATE_YMM)) + if (!has_osxsave + || (eax & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM)) { has_avx = 0; has_avx2 = 0; diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index de9c6871878..c10e49458f5 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -17520,9 +17520,16 @@ ix86_dep_by_shift_count_body (const_rtx set_body, const_rtx use_body) rtx shift_count = XEXP (shift_rtx, 1); /* Return true if shift count is dest of SET_BODY. */ - if (REG_P (shift_count) - && true_regnum (set_dest) == true_regnum (shift_count)) - return true; + if (REG_P (shift_count)) + { + /* Add check since it can be invoked before register + allocation in pre-reload schedule. */ + if (reload_completed + && true_regnum (set_dest) == true_regnum (shift_count)) + return true; + else if (REGNO(set_dest) == REGNO(shift_count)) + return true; + } } return false; @@ -24278,7 +24285,10 @@ ia32_multipass_dfa_lookahead (void) /* Generally, we want haifa-sched:max_issue() to look ahead as far as many instructions can be executed on a cycle, i.e., issue_rate. I wonder why tuning for many CPUs does not do this. */ - return ix86_issue_rate (); + if (reload_completed) + return ix86_issue_rate (); + /* Don't use lookahead for pre-reload schedule to save compile time. */ + return 0; default: return 0; @@ -24311,6 +24321,9 @@ ix86_sched_reorder(FILE *dump, int sched_verbose, rtx *ready, int *pn_ready, /* Do reodering for Atom only. */ if (ix86_tune != PROCESSOR_ATOM) return issue_rate; + /* Do not perform ready list reodering for pre-reload schedule pass. */ + if (!reload_completed) + return issue_rate; /* Nothing to do if ready list contains only 1 instruction. */ if (n_ready <= 1) return issue_rate; @@ -24393,7 +24406,198 @@ ix86_sched_reorder(FILE *dump, int sched_verbose, rtx *ready, int *pn_ready, return issue_rate; } - +static bool +ix86_class_likely_spilled_p (reg_class_t); + +/* Returns true if lhs of insn is HW function argument register and set up + is_spilled to true if it is likely spilled HW register. */ +static bool +insn_is_function_arg (rtx insn, bool* is_spilled) +{ + rtx dst; + + if (!NONDEBUG_INSN_P (insn)) + return false; + insn = PATTERN (insn); + if (GET_CODE (insn) == PARALLEL) + insn = XVECEXP (insn, 0, 0); + if (GET_CODE (insn) != SET) + return false; + dst = SET_DEST (insn); + if (REG_P (dst) && HARD_REGISTER_P (dst) + && ix86_function_arg_regno_p (REGNO (dst))) + { + /* Is it likely spilled HW register? */ + if (!TEST_HARD_REG_BIT (fixed_reg_set, REGNO (dst)) + && ix86_class_likely_spilled_p (REGNO_REG_CLASS (REGNO (dst)))) + *is_spilled = true; + return true; + } + return false; +} + +/* Add output dependencies for chain of function adjacent arguments if only + there is a move to likely spilled HW register. Return first argument + if at least one dependence was added or NULL otherwise. */ +static rtx +add_parameter_dependencies (rtx call, rtx head) +{ + rtx insn; + rtx last = call; + rtx first_arg = NULL; + bool is_spilled = false; + + /* Find nearest to call argument passing instruction. */ + while (true) + { + last = PREV_INSN (last); + if (last == head) + return NULL; + if (!NONDEBUG_INSN_P (last)) + continue; + if (insn_is_function_arg (last, &is_spilled)) + break; + return NULL; + } + + first_arg = last; + while (true) + { + insn = PREV_INSN (last); + if (!INSN_P (insn)) + break; + if (insn == head) + break; + if (!NONDEBUG_INSN_P (insn)) + { + last = insn; + continue; + } + if (insn_is_function_arg (insn, &is_spilled)) + { + /* Add output depdendence between two function arguments if chain + of output arguments contains likely spilled HW registers. */ + if (is_spilled) + add_dependence (last, insn, REG_DEP_OUTPUT); + first_arg = last = insn; + } + else + break; + } + if (!is_spilled) + return NULL; + return first_arg; +} + +/* Add output or anti dependency from insn to first_arg to restrict its code + motion. */ +static void +avoid_func_arg_motion (rtx first_arg, rtx insn) +{ + rtx set; + rtx tmp; + + set = single_set (insn); + if (!set) + return; + tmp = SET_DEST (set); + if (REG_P (tmp)) + { + /* Add output dependency to the first function argument. */ + add_dependence (first_arg, insn, REG_DEP_OUTPUT); + return; + } + /* Add anti dependency. */ + add_dependence (first_arg, insn, REG_DEP_ANTI); +} + +/* Avoid cross block motion of function argument through adding dependency + from the first non-jump instruction in bb. */ +static void +add_dependee_for_func_arg (rtx arg, basic_block bb) +{ + rtx insn = BB_END (bb); + + while (insn) + { + if (NONDEBUG_INSN_P (insn) && NONJUMP_INSN_P (insn)) + { + rtx set = single_set (insn); + if (set) + { + avoid_func_arg_motion (arg, insn); + return; + } + } + if (insn == BB_HEAD (bb)) + return; + insn = PREV_INSN (insn); + } +} + +/* Hook for pre-reload schedule - avoid motion of function arguments + passed in likely spilled HW registers. */ +static void +ix86_dependencies_evaluation_hook (rtx head, rtx tail) +{ + rtx insn; + rtx first_arg = NULL; + if (reload_completed) + return; + for (insn = tail; insn != head; insn = PREV_INSN (insn)) + if (INSN_P (insn) && CALL_P (insn)) + { + first_arg = add_parameter_dependencies (insn, head); + if (first_arg) + { + /* Check if first argument has dependee out of its home block. */ + sd_iterator_def sd_it1; + dep_t dep1; + FOR_EACH_DEP (first_arg, SD_LIST_BACK, sd_it1, dep1) + { + rtx dee; + dee = DEP_PRO (dep1); + if (!NONDEBUG_INSN_P (dee)) + continue; + if (BLOCK_FOR_INSN (dee) != BLOCK_FOR_INSN (first_arg)) + /* Must add dependee for first argument in dee's block. */ + add_dependee_for_func_arg (first_arg, BLOCK_FOR_INSN (dee)); + } + insn = first_arg; + } + } + else if (first_arg) + avoid_func_arg_motion (first_arg, insn); +} + +/* Hook for pre-reload schedule - set priority of moves from likely spilled + HW registers to maximum, to schedule them at soon as possible. These are + moves from function argument registers at the top of the function entry + and moves from function return value registers after call. */ +static int +ix86_adjust_priority (rtx insn, int priority) +{ + rtx set; + + if (reload_completed) + return priority; + + if (!NONDEBUG_INSN_P (insn)) + return priority; + + set = single_set (insn); + if (set) + { + rtx tmp = SET_SRC (set); + if (REG_P (tmp) + && HARD_REGISTER_P (tmp) + && !TEST_HARD_REG_BIT (fixed_reg_set, REGNO (tmp)) + && ix86_class_likely_spilled_p (REGNO_REG_CLASS (REGNO (tmp)))) + return current_sched_info->sched_max_insns_priority; + } + + return priority; +} /* Model decoder of Core 2/i7. Below hooks for multipass scheduling (see haifa-sched.c:max_issue) @@ -24606,27 +24810,32 @@ ix86_sched_init_global (FILE *dump ATTRIBUTE_UNUSED, case PROCESSOR_CORE2_64: case PROCESSOR_COREI7_32: case PROCESSOR_COREI7_64: - targetm.sched.dfa_post_advance_cycle - = core2i7_dfa_post_advance_cycle; - targetm.sched.first_cycle_multipass_init - = core2i7_first_cycle_multipass_init; - targetm.sched.first_cycle_multipass_begin - = core2i7_first_cycle_multipass_begin; - targetm.sched.first_cycle_multipass_issue - = core2i7_first_cycle_multipass_issue; - targetm.sched.first_cycle_multipass_backtrack - = core2i7_first_cycle_multipass_backtrack; - targetm.sched.first_cycle_multipass_end - = core2i7_first_cycle_multipass_end; - targetm.sched.first_cycle_multipass_fini - = core2i7_first_cycle_multipass_fini; - - /* Set decoder parameters. */ - core2i7_secondary_decoder_max_insn_size = 8; - core2i7_ifetch_block_size = 16; - core2i7_ifetch_block_max_insns = 6; - break; - + /* Do not perform multipass scheduling for pre-reload schedule + to save compile time. */ + if (reload_completed) + { + targetm.sched.dfa_post_advance_cycle + = core2i7_dfa_post_advance_cycle; + targetm.sched.first_cycle_multipass_init + = core2i7_first_cycle_multipass_init; + targetm.sched.first_cycle_multipass_begin + = core2i7_first_cycle_multipass_begin; + targetm.sched.first_cycle_multipass_issue + = core2i7_first_cycle_multipass_issue; + targetm.sched.first_cycle_multipass_backtrack + = core2i7_first_cycle_multipass_backtrack; + targetm.sched.first_cycle_multipass_end + = core2i7_first_cycle_multipass_end; + targetm.sched.first_cycle_multipass_fini + = core2i7_first_cycle_multipass_fini; + + /* Set decoder parameters. */ + core2i7_secondary_decoder_max_insn_size = 8; + core2i7_ifetch_block_size = 16; + core2i7_ifetch_block_max_insns = 6; + break; + } + /* ... Fall through ... */ default: targetm.sched.dfa_post_advance_cycle = NULL; targetm.sched.first_cycle_multipass_init = NULL; @@ -39687,6 +39896,10 @@ ix86_enum_va_list (int idx, const char **pname, tree *ptree) #define TARGET_SCHED_REASSOCIATION_WIDTH ix86_reassociation_width #undef TARGET_SCHED_REORDER #define TARGET_SCHED_REORDER ix86_sched_reorder +#undef TARGET_SCHED_ADJUST_PRIORITY +#define TARGET_SCHED_ADJUST_PRIORITY ix86_adjust_priority +#undef TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK +#define TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK ix86_dependencies_evaluation_hook /* The size of the dispatch window is the total number of bytes of object code allowed in a window. */ diff --git a/gcc/config/rx/rx.c b/gcc/config/rx/rx.c index 9dfcbffd0f7..8a863c94c7b 100644 --- a/gcc/config/rx/rx.c +++ b/gcc/config/rx/rx.c @@ -1256,6 +1256,41 @@ rx_conditional_register_usage (void) } } +struct decl_chain +{ + tree fndecl; + struct decl_chain * next; +}; + +/* Stack of decls for which we have issued warnings. */ +static struct decl_chain * warned_decls = NULL; + +static void +add_warned_decl (tree fndecl) +{ + struct decl_chain * warned = (struct decl_chain *) xmalloc (sizeof * warned); + + warned->fndecl = fndecl; + warned->next = warned_decls; + warned_decls = warned; +} + +/* Returns TRUE if FNDECL is on our list of warned about decls. */ + +static bool +already_warned (tree fndecl) +{ + struct decl_chain * warned; + + for (warned = warned_decls; + warned != NULL; + warned = warned->next) + if (warned->fndecl == fndecl) + return true; + + return false; +} + /* Perform any actions necessary before starting to compile FNDECL. For the RX we use this to make sure that we have the correct set of register masks selected. If FNDECL is NULL then we are @@ -1288,6 +1323,24 @@ rx_set_current_function (tree fndecl) target_reinit (); } + if (current_is_fast_interrupt && rx_warn_multiple_fast_interrupts) + { + /* We do not warn about the first fast interrupt routine that + we see. Instead we just push it onto the stack. */ + if (warned_decls == NULL) + add_warned_decl (fndecl); + + /* Otherwise if this fast interrupt is one for which we have + not already issued a warning, generate one and then push + it onto the stack as well. */ + else if (! already_warned (fndecl)) + { + warning (0, "multiple fast interrupt routines seen: %qE and %qE", + fndecl, warned_decls->fndecl); + add_warned_decl (fndecl); + } + } + rx_previous_fndecl = fndecl; } diff --git a/gcc/config/rx/rx.opt b/gcc/config/rx/rx.opt index 76c2f61c79b..f0a57b1fae1 100644 --- a/gcc/config/rx/rx.opt +++ b/gcc/config/rx/rx.opt @@ -118,3 +118,9 @@ Specifies whether interrupt functions should save and restore the accumulator re mpid Target Mask(PID) Enables Position-Independent-Data (PID) mode. + +;--------------------------------------------------- + +mwarn-multiple-fast-interrupts +Target Report Var(rx_warn_multiple_fast_interrupts) Init(1) Warning +Warn when multiple, different, fast interrupt handlers are in the compilation unit. diff --git a/gcc/config/sh/sh-c.c b/gcc/config/sh/sh-c.c index 2fdff542bb1..94c5f99d270 100644 --- a/gcc/config/sh/sh-c.c +++ b/gcc/config/sh/sh-c.c @@ -25,6 +25,9 @@ along with GCC; see the file COPYING3. If not see #include "tm.h" #include "tree.h" #include "tm_p.h" +#include "cpplib.h" +#include "c-family/c-common.h" +#include "target.h" /* Handle machine specific pragmas to be semi-compatible with Renesas compiler. */ @@ -66,3 +69,79 @@ sh_pr_nosave_low_regs (struct cpp_reader *pfile ATTRIBUTE_UNUSED) { sh_add_function_attribute ("nosave_low_regs"); } + +#define builtin_define(TXT) cpp_define (pfile, TXT) +#define builtin_assert(TXT) cpp_assert (pfile, TXT) + +/* Implement the TARGET_CPU_CPP_BUILTINS macro */ +void +sh_cpu_cpp_builtins (cpp_reader* pfile) +{ + builtin_define ("__sh__"); + builtin_assert ("cpu=sh"); + builtin_assert ("machine=sh"); + switch ((int) sh_cpu) + { + case PROCESSOR_SH1: + builtin_define ("__sh1__"); + builtin_define ("__SH1__"); + break; + case PROCESSOR_SH2: + builtin_define ("__sh2__"); + builtin_define ("__SH2__"); + break; + case PROCESSOR_SH2E: + builtin_define ("__SH2E__"); + break; + case PROCESSOR_SH2A: + builtin_define ("__SH2A__"); + if (TARGET_SH2A_DOUBLE) + builtin_define (TARGET_FPU_SINGLE + ? "__SH2A_SINGLE__" : "__SH2A_DOUBLE__"); + else + builtin_define (TARGET_FPU_ANY + ? "__SH2A_SINGLE_ONLY__" : "__SH2A_NOFPU__"); + break; + case PROCESSOR_SH3: + builtin_define ("__sh3__"); + builtin_define ("__SH3__"); + if (TARGET_HARD_SH4) + builtin_define ("__SH4_NOFPU__"); + break; + case PROCESSOR_SH3E: + builtin_define (TARGET_HARD_SH4 ? "__SH4_SINGLE_ONLY__" : "__SH3E__"); + break; + case PROCESSOR_SH4: + builtin_define (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__"); + break; + case PROCESSOR_SH4A: \ + builtin_define ("__SH4A__"); + builtin_define (TARGET_SH4 + ? (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__") + : TARGET_FPU_ANY ? "__SH4_SINGLE_ONLY__" + : "__SH4_NOFPU__"); + break; + case PROCESSOR_SH5: + { + builtin_define_with_value ("__SH5__", + TARGET_SHMEDIA64 ? "64" : "32", 0); + builtin_define_with_value ("__SHMEDIA__", + TARGET_SHMEDIA ? "1" : "0", 0); + if (! TARGET_FPU_DOUBLE) + builtin_define ("__SH4_NOFPU__"); + } + } + if (TARGET_FPU_ANY) + builtin_define ("__SH_FPU_ANY__"); + if (TARGET_FPU_DOUBLE) + builtin_define ("__SH_FPU_DOUBLE__"); + if (TARGET_HITACHI) + builtin_define ("__HITACHI__"); + if (TARGET_FMOVD) + builtin_define ("__FMOVD_ENABLED__"); + builtin_define (TARGET_LITTLE_ENDIAN + ? "__LITTLE_ENDIAN__" : "__BIG_ENDIAN__"); + + cpp_define_formatted (pfile, "__SH_ATOMIC_MODEL_%s__", + selected_atomic_model ().cdef_name); +} diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h index 135a5c43a9d..d908110dc1b 100644 --- a/gcc/config/sh/sh-protos.h +++ b/gcc/config/sh/sh-protos.h @@ -55,6 +55,14 @@ struct sh_atomic_model happen on SH4A. */ bool strict; enum_type type; + + /* Name string as it was specified on the command line. */ + const char* name; + + /* Name string as it is used in C/C++ defines. */ + const char* cdef_name; + + /* GBR offset variable for TCB model. */ int tcb_gbr_offset; }; @@ -156,6 +164,8 @@ extern void sh_canonicalize_comparison (enum rtx_code&, rtx&, rtx&, #endif /* RTX_CODE */ +extern void sh_cpu_cpp_builtins (cpp_reader* pfile); + extern const char *output_jump_label_table (void); extern rtx get_t_reg_rtx (void); extern rtx get_fpscr_rtx (void); diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index ebfacbbcfe0..33ae28e7a69 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -619,8 +619,17 @@ parse_validate_atomic_model_option (const char* str) model_names[sh_atomic_model::soft_tcb] = "soft-tcb"; model_names[sh_atomic_model::soft_imask] = "soft-imask"; + const char* model_cdef_names[sh_atomic_model::num_models]; + model_cdef_names[sh_atomic_model::none] = "NONE"; + model_cdef_names[sh_atomic_model::soft_gusa] = "SOFT_GUSA"; + model_cdef_names[sh_atomic_model::hard_llcs] = "HARD_LLCS"; + model_cdef_names[sh_atomic_model::soft_tcb] = "SOFT_TCB"; + model_cdef_names[sh_atomic_model::soft_imask] = "SOFT_IMASK"; + sh_atomic_model ret; ret.type = sh_atomic_model::none; + ret.name = model_names[sh_atomic_model::none]; + ret.cdef_name = model_cdef_names[sh_atomic_model::none]; ret.strict = false; ret.tcb_gbr_offset = -1; @@ -646,6 +655,8 @@ parse_validate_atomic_model_option (const char* str) if (tokens.front () == model_names[i]) { ret.type = (sh_atomic_model::enum_type)i; + ret.name = model_names[i]; + ret.cdef_name = model_cdef_names[i]; goto got_mode_name; } @@ -677,25 +688,23 @@ got_mode_name:; if (ret.type == sh_atomic_model::soft_gusa && !TARGET_SH3) err_ret ("atomic model %s is only available on SH3 and SH4 targets", - model_names[ret.type]); + ret.name); if (ret.type == sh_atomic_model::hard_llcs && !TARGET_SH4A) - err_ret ("atomic model %s is only available on SH4A targets", - model_names[ret.type]); + err_ret ("atomic model %s is only available on SH4A targets", ret.name); if (ret.type == sh_atomic_model::soft_tcb && ret.tcb_gbr_offset == -1) - err_ret ("atomic model %s requires gbr-offset parameter", - model_names[ret.type]); + err_ret ("atomic model %s requires gbr-offset parameter", ret.name); if (ret.type == sh_atomic_model::soft_tcb && (ret.tcb_gbr_offset < 0 || ret.tcb_gbr_offset > 1020 || (ret.tcb_gbr_offset & 3) != 0)) err_ret ("invalid gbr-offset value \"%d\" for atomic model %s; it must be " "a multiple of 4 in the range 0-1020", ret.tcb_gbr_offset, - model_names[ret.type]); + ret.name); if (ret.type == sh_atomic_model::soft_imask && TARGET_USERMODE) - err_ret ("cannot use atomic model %s in user mode", model_names[ret.type]); + err_ret ("cannot use atomic model %s in user mode", ret.name); return ret; @@ -13125,6 +13134,12 @@ sh_can_use_simple_return_p (void) HARD_REG_SET live_regs_mask; int d; + /* Some targets require special return insns. */ + if (TARGET_SHMEDIA + || (TARGET_SHCOMPACT + && (crtl->args.info.call_cookie & CALL_COOKIE_RET_TRAMP (1)))) + return false; + if (! reload_completed || frame_pointer_needed) return false; diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index 546cb6fd3cb..52875265ed6 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -31,69 +31,7 @@ along with GCC; see the file COPYING3. If not see /* ??? No longer true. */ extern int code_for_indirect_jump_scratch; -#define TARGET_CPU_CPP_BUILTINS() \ -do { \ - builtin_define ("__sh__"); \ - builtin_assert ("cpu=sh"); \ - builtin_assert ("machine=sh"); \ - switch ((int) sh_cpu) \ - { \ - case PROCESSOR_SH1: \ - builtin_define ("__sh1__"); \ - break; \ - case PROCESSOR_SH2: \ - builtin_define ("__sh2__"); \ - break; \ - case PROCESSOR_SH2E: \ - builtin_define ("__SH2E__"); \ - break; \ - case PROCESSOR_SH2A: \ - builtin_define ("__SH2A__"); \ - builtin_define (TARGET_SH2A_DOUBLE \ - ? (TARGET_FPU_SINGLE ? "__SH2A_SINGLE__" : "__SH2A_DOUBLE__") \ - : TARGET_FPU_ANY ? "__SH2A_SINGLE_ONLY__" \ - : "__SH2A_NOFPU__"); \ - break; \ - case PROCESSOR_SH3: \ - builtin_define ("__sh3__"); \ - builtin_define ("__SH3__"); \ - if (TARGET_HARD_SH4) \ - builtin_define ("__SH4_NOFPU__"); \ - break; \ - case PROCESSOR_SH3E: \ - builtin_define (TARGET_HARD_SH4 ? "__SH4_SINGLE_ONLY__" : "__SH3E__"); \ - break; \ - case PROCESSOR_SH4: \ - builtin_define (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__"); \ - break; \ - case PROCESSOR_SH4A: \ - builtin_define ("__SH4A__"); \ - builtin_define (TARGET_SH4 \ - ? (TARGET_FPU_SINGLE ? "__SH4_SINGLE__" : "__SH4__") \ - : TARGET_FPU_ANY ? "__SH4_SINGLE_ONLY__" \ - : "__SH4_NOFPU__"); \ - break; \ - case PROCESSOR_SH5: \ - { \ - builtin_define_with_value ("__SH5__", \ - TARGET_SHMEDIA64 ? "64" : "32", 0); \ - builtin_define_with_value ("__SHMEDIA__", \ - TARGET_SHMEDIA ? "1" : "0", 0); \ - if (! TARGET_FPU_DOUBLE) \ - builtin_define ("__SH4_NOFPU__"); \ - } \ - } \ - if (TARGET_FPU_ANY) \ - builtin_define ("__SH_FPU_ANY__"); \ - if (TARGET_FPU_DOUBLE) \ - builtin_define ("__SH_FPU_DOUBLE__"); \ - if (TARGET_HITACHI) \ - builtin_define ("__HITACHI__"); \ - if (TARGET_FMOVD) \ - builtin_define ("__FMOVD_ENABLED__"); \ - builtin_define (TARGET_LITTLE_ENDIAN \ - ? "__LITTLE_ENDIAN__" : "__BIG_ENDIAN__"); \ -} while (0) +#define TARGET_CPU_CPP_BUILTINS() sh_cpu_cpp_builtins (pfile) /* Value should be nonzero if functions must have frame pointers. Zero means the frame pointer need not be set up (and parms may be accessed diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index 8f0443ad6db..7a1c4d33a58 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -10460,6 +10460,13 @@ label: "" { sh_expand_epilogue (false); + if (TARGET_SHMEDIA + || (TARGET_SHCOMPACT + && (crtl->args.info.call_cookie & CALL_COOKIE_RET_TRAMP (1)))) + { + emit_jump_insn (gen_return ()); + DONE; + } }) (define_expand "eh_return" @@ -10769,6 +10776,51 @@ label: (set (reg:SI T_REG) (const_int 1)) (use (match_dup 2))])]) +;; Use negc to store the T bit in a MSB of a reg in the following way: +;; T = 1: 0x80000000 -> reg +;; T = 0: 0x7FFFFFFF -> reg +;; This works because 0 - 0x80000000 = 0x80000000. +(define_insn_and_split "*mov_t_msb_neg" + [(set (match_operand:SI 0 "arith_reg_dest") + (minus:SI (const_int -2147483648) ;; 0x80000000 + (match_operand 1 "t_reg_operand"))) + (clobber (reg:SI T_REG))] + "TARGET_SH1" + "#" + "&& can_create_pseudo_p ()" + [(set (match_dup 2) (const_int -2147483648)) + (parallel [(set (match_dup 0) (minus:SI (neg:SI (match_dup 2)) + (reg:SI T_REG))) + (clobber (reg:SI T_REG))])] +{ + operands[2] = gen_reg_rtx (SImode); +}) + +;; These are essentially the same as above, but with the inverted T bit. +;; Combine recognizes the split patterns, but does not take them sometimes +;; if the T_REG clobber is specified. Instead it tries to split out the +;; T bit negation. Since these splits are supposed to be taken only by +;; combine, it will see the T_REG clobber of the *mov_t_msb_neg insn, so this +;; should be fine. +(define_split + [(set (match_operand:SI 0 "arith_reg_dest") + (plus:SI (match_operand 1 "negt_reg_operand") + (const_int 2147483647)))] ;; 0x7fffffff + "TARGET_SH1 && can_create_pseudo_p ()" + [(parallel [(set (match_dup 0) + (minus:SI (const_int -2147483648) (reg:SI T_REG))) + (clobber (reg:SI T_REG))])]) + +(define_split + [(set (match_operand:SI 0 "arith_reg_dest") + (if_then_else:SI (match_operand 1 "t_reg_operand") + (const_int 2147483647) ;; 0x7fffffff + (const_int -2147483648)))] ;; 0x80000000 + "TARGET_SH1 && can_create_pseudo_p ()" + [(parallel [(set (match_dup 0) + (minus:SI (const_int -2147483648) (reg:SI T_REG))) + (clobber (reg:SI T_REG))])]) + ;; The *negnegt pattern helps the combine pass to figure out how to fold ;; an explicit double T bit negation. (define_insn_and_split "*negnegt" diff --git a/gcc/configure b/gcc/configure index ff98a2254eb..45bba8e785e 100755 --- a/gcc/configure +++ b/gcc/configure @@ -6636,7 +6636,7 @@ fi # Disable exceptions and RTTI if building with g++ noexception_flags= save_CFLAGS="$CFLAGS" -for real_option in -fno-exceptions -fno-rtti; do +for real_option in -fno-exceptions -fno-rtti -fasynchronous-unwind-tables; do # Do the check with the no- prefix removed since gcc silently # accepts any -Wno-* option on purpose case $real_option in diff --git a/gcc/configure.ac b/gcc/configure.ac index 453088e2fee..6ad6d19c9ed 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -365,7 +365,8 @@ AC_SUBST(warn_cxxflags) # Disable exceptions and RTTI if building with g++ ACX_PROG_CC_WARNING_OPTS( - m4_quote(m4_do([-fno-exceptions -fno-rtti])), [noexception_flags]) + m4_quote(m4_do([-fno-exceptions -fno-rtti -fasynchronous-unwind-tables])), + [noexception_flags]) # Enable expensive internal checks is_release= diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f868739be6e..fe72a9ca7e4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2012-10-04 Arnaud Charlet <charlet@adacore.com> + + * decl2.c (cp_write_global_declarations): Fix handling of + -fdump-ada-spec*. + +2012-10-03 Jakub Jelinek <jakub@redhat.com> + + PR c++/54777 + * semantics.c (cxx_eval_constant_expression) <case COMPOUND_EXPR>: If + not ignoring the second operand, pass the original second operand + and not one with stripped nops to cxx_eval_constant_expression. + 2012-10-01 Jason Merrill <jason@redhat.com> * decl.c (check_initializer): Set DECL_NONTRIVIALLY_INITIALIZED_P diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 9b1a5a1856d..87e38d3bf6f 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3698,9 +3698,9 @@ cp_write_global_declarations (void) cgraph_process_same_body_aliases (); /* Handle -fdump-ada-spec[-slim] */ - if (dump_initialized_p (TDI_ada)) + if (flag_dump_ada_spec || flag_dump_ada_spec_slim) { - if (get_dump_file_info (TDI_ada)->pflags & TDF_SLIM) + if (flag_dump_ada_spec_slim) collect_source_ref (main_input_filename); else collect_source_refs (global_namespace); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1aa5a8b8b56..68cbb4ba8c4 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7740,6 +7740,7 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t, /* Check that the LHS is constant and then discard it. */ cxx_eval_constant_expression (call, op0, allow_non_constant, false, non_constant_p); + op1 = TREE_OPERAND (t, 1); r = cxx_eval_constant_expression (call, op1, allow_non_constant, addr, non_constant_p); } diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index b363db014bf..fa5989e6bde 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -3634,6 +3634,15 @@ This pragma takes no arguments. It causes the rest of the code in the current file to be treated as if it came from a system header. @xref{System Headers}. +@item #pragma GCC warning +@itemx #pragma GCC error +@code{#pragma GCC warning "message"} causes the preprocessor to issue +a warning diagnostic with the text @samp{message}. The message +contained in the pragma must be a single string literal. Similarly, +@code{#pragma GCC error "message"} issues an error message. Unlike +the @samp{#warning} and @samp{#error} directives, these pragmas can be +embedded in preprocessor macros using @samp{_Pragma}. + @end ftable @node Other Directives diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index b37225874cd..63dd3eb67d9 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -859,6 +859,7 @@ See RS/6000 and PowerPC Options. -mmax-constant-size=@gol -mint-register=@gol -mpid@gol +-mno-warn-multiple-fast-interrupts@gol -msave-acc-in-interrupts} @emph{S/390 and zSeries Options} @@ -17880,6 +17881,15 @@ command line. By default this feature is not enabled. The default can be restored via the @option{-mno-pid} command-line option. +@item -mno-warn-multiple-fast-interrupts +@itemx -mwarn-multiple-fast-interrupts +@opindex mno-warn-multiple-fast-interrupts +@opindex mwarn-multiple-fast-interrupts +Prevents GCC from issuing a warning message if it finds more than one +fast interrupt handler when it is compiling a file. The default is to +issue a warning for each extra fast interrupt handler found, as the RX +only supports one such interrupt. + @end table @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}} diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c index 92d1409be08..2f610b6c259 100644 --- a/gcc/dumpfile.c +++ b/gcc/dumpfile.c @@ -57,8 +57,7 @@ static struct dump_file_info dump_files[TDI_end] = 0, 0, 0, 5}, {".vcg", "tree-vcg", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0, 6}, - {".ads", "ada-spec", NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 7}, -#define FIRST_AUTO_NUMBERED_DUMP 8 +#define FIRST_AUTO_NUMBERED_DUMP 7 {NULL, "tree-all", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0, 0}, diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h index cbaf47de422..87a2c728623 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -37,7 +37,6 @@ enum tree_dump_index TDI_nested, /* dump each function after unnesting it */ TDI_vcg, /* create a VCG graph file for each function's flowgraph. */ - TDI_ada, /* dump declarations in Ada syntax. */ TDI_tree_all, /* enable all the GENERIC/GIMPLE dumps. */ TDI_rtl_all, /* enable all the RTL dumps. */ TDI_ipa_all, /* enable all the IPA dumps. */ diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 25f57c06b9c..95fc130c3db 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -17329,7 +17329,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) a BLOCK node representing the function's outermost pair of curly braces, and any blocks used for the base and member initializers of a C++ constructor function. */ - if (! declaration && TREE_CODE (outer_scope) != ERROR_MARK) + if (! declaration && outer_scope && TREE_CODE (outer_scope) != ERROR_MARK) { int call_site_note_count = 0; int tail_call_site_note_count = 0; @@ -19622,8 +19622,14 @@ dwarf2out_decl (tree decl) inline" functions as DECL_EXTERNAL, but we need to generate DWARF for them anyway. Note that the C++ front-end also plays some similar games for inline function definitions appearing within include files which - also contain `#pragma interface' pragmas. */ - if (DECL_INITIAL (decl) == NULL_TREE) + also contain `#pragma interface' pragmas. + + If we are called from dwarf2out_abstract_function output a DIE + anyway. We can end up here this way with early inlining and LTO + where the inlined function is output in a different LTRANS unit + or not at all. */ + if (DECL_INITIAL (decl) == NULL_TREE + && ! DECL_ABSTRACT (decl)) return; /* If we're a nested function, initially use a parent of NULL; if we're diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b6d44cd0d20..a861601e0c2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,22 @@ +2012-10-04 Tobias Burnus <burnus@net-b.de> + + * expr.c (scalarize_intrinsic_call): Plug memory leak. + * frontend-passes.c (gcc_assert): Extend assert. + * interface.c (gfc_compare_derived_types): Fix comparison. + (gfc_check_operator_interface): Move up to make this error + message reachable. + (get_sym_storage_size): Remove always-true checks. + * io.c (format_lex): Add comment. + (gfc_free_wait): Free memory. + * match.c (gfc_match_select_type): Ditto. + * matchexpr.c (match_level_3): Ditto. + * primary.c (match_string_constant): Ditto. + (match_actual_arg): Check return value. + * resolve.c (gfc_resolve_substring_charlen, + resolve_typebound_generic_call, resolve_typebound_function, + resolve_typebound_subroutine): Free memory. + * trans-types.c (gfc_get_derived_type): Remove always-true check. + 2012-10-02 Janus Weil <janus@gcc.gnu.org> PR fortran/54778 diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 4bba438c25e..9ac0fc6858f 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2059,6 +2059,8 @@ scalarize_intrinsic_call (gfc_expr *e) free_expr0 (e); *e = *expr; + /* Free "expr" but not the pointers it contains. */ + free (expr); gfc_free_expr (old); return SUCCESS; diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 437ed7ec175..0cba9112a08 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -1177,7 +1177,7 @@ optimize_trim (gfc_expr *e) /* Set the end of the reference to the call to len_trim. */ ref->u.ss.end = fcn; - gcc_assert (*rr == NULL); + gcc_assert (rr != NULL && *rr == NULL); *rr = ref; return true; } diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 6bcd607adc3..fb3da1fb7ba 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -449,7 +449,7 @@ gfc_compare_derived_types (gfc_symbol *derived1, gfc_symbol *derived2) /* Make sure that link lists do not put this function into an endless recursive loop! */ if (!(dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.u.derived) - && !(dt1->ts.type == BT_DERIVED && derived1 == dt1->ts.u.derived) + && !(dt2->ts.type == BT_DERIVED && derived2 == dt2->ts.u.derived) && gfc_compare_types (&dt1->ts, &dt2->ts) == 0) return 0; @@ -641,8 +641,12 @@ gfc_check_operator_interface (gfc_symbol *sym, gfc_intrinsic_op op, && op != INTRINSIC_NOT) || (args == 2 && op == INTRINSIC_NOT)) { - gfc_error ("Operator interface at %L has the wrong number of arguments", - &sym->declared_at); + if (op == INTRINSIC_ASSIGN) + gfc_error ("Assignment operator interface at %L must have " + "two arguments", &sym->declared_at); + else + gfc_error ("Operator interface at %L has the wrong number of arguments", + &sym->declared_at); return false; } @@ -656,12 +660,6 @@ gfc_check_operator_interface (gfc_symbol *sym, gfc_intrinsic_op op, "a SUBROUTINE", &sym->declared_at); return false; } - if (args != 2) - { - gfc_error ("Assignment operator interface at %L must have " - "two arguments", &sym->declared_at); - return false; - } /* Allowed are (per F2003, 12.3.2.1.2 Defined assignments): - First argument an array with different rank than second, @@ -2149,7 +2147,7 @@ get_sym_storage_size (gfc_symbol *sym) return 0; for (i = 0; i < sym->as->rank; i++) { - if (!sym->as || sym->as->upper[i]->expr_type != EXPR_CONSTANT + if (sym->as->upper[i]->expr_type != EXPR_CONSTANT || sym->as->lower[i]->expr_type != EXPR_CONSTANT) return 0; @@ -2224,9 +2222,7 @@ get_expr_storage_size (gfc_expr *e) continue; } - if (ref->type == REF_ARRAY && ref->u.ar.type == AR_SECTION - && ref->u.ar.start && ref->u.ar.end && ref->u.ar.stride - && ref->u.ar.as->upper) + if (ref->type == REF_ARRAY && ref->u.ar.type == AR_SECTION) for (i = 0; i < ref->u.ar.dimen; i++) { long int start, end, stride; diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 428799c1262..447d03f0d50 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -243,6 +243,8 @@ format_lex (void) { case '-': negative_flag = 1; + /* Falls through. */ + case '+': c = next_char_not_space (&error); if (!ISDIGIT (c)) @@ -4117,6 +4119,7 @@ gfc_free_wait (gfc_wait *wait) gfc_free_expr (wait->iostat); gfc_free_expr (wait->iomsg); gfc_free_expr (wait->id); + free (wait); } diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index d46a495ae01..06585af94e9 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -5325,6 +5325,7 @@ gfc_match_select_type (void) char name[GFC_MAX_SYMBOL_LEN]; bool class_array; gfc_symbol *sym; + gfc_namespace *parent_ns; m = gfc_match_label (); if (m == MATCH_ERROR) @@ -5404,7 +5405,9 @@ gfc_match_select_type (void) return MATCH_YES; cleanup: - gfc_current_ns = gfc_current_ns->parent; + parent_ns = gfc_current_ns->parent; + gfc_free_namespace (gfc_current_ns); + gfc_current_ns = parent_ns; return m; } diff --git a/gcc/fortran/matchexp.c b/gcc/fortran/matchexp.c index 12d5b2dcbab..c1196a8802c 100644 --- a/gcc/fortran/matchexp.c +++ b/gcc/fortran/matchexp.c @@ -543,7 +543,7 @@ match_level_2 (gfc_expr **result) static match match_level_3 (gfc_expr **result) { - gfc_expr *all, *e, *total; + gfc_expr *all, *e, *total = NULL; locus where; match m; @@ -560,12 +560,12 @@ match_level_3 (gfc_expr **result) m = match_level_2 (&e); if (m == MATCH_NO) + gfc_error (expression_syntax); + if (m != MATCH_YES) { - gfc_error (expression_syntax); gfc_free_expr (all); + return MATCH_ERROR; } - if (m != MATCH_YES) - return MATCH_ERROR; total = gfc_concat (all, e); if (total == NULL) diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index f362f75426a..7b64a3c6854 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -1087,6 +1087,7 @@ got_delim: if (!gfc_check_character_range (c, kind)) { + gfc_free_expr (e); gfc_error ("Character '%s' in string at %C is not representable " "in character kind %d", gfc_print_wide_char (c), kind); return MATCH_ERROR; @@ -1507,8 +1508,9 @@ match_actual_arg (gfc_expr **result) if (sym->attr.in_common && !sym->attr.proc_pointer) { - gfc_add_flavor (&sym->attr, FL_VARIABLE, sym->name, - &sym->declared_at); + if (gfc_add_flavor (&sym->attr, FL_VARIABLE, sym->name, + &sym->declared_at) == FAILURE) + return MATCH_ERROR; break; } diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 3e23ca2e311..7c30cba9756 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -4964,7 +4964,11 @@ gfc_resolve_substring_charlen (gfc_expr *e) end = NULL; if (!start || !end) - return; + { + gfc_free_expr (start); + gfc_free_expr (end); + return; + } /* Length = (end - start +1). */ e->ts.u.cl->length = gfc_subtract (end, start); @@ -6004,7 +6008,10 @@ resolve_typebound_generic_call (gfc_expr* e, const char **name) gfc_expr* po; po = extract_compcall_passed_object (e); if (!po) - return FAILURE; + { + gfc_free_actual_arglist (args); + return FAILURE; + } gcc_assert (g->specific->pass_arg_num > 0); gcc_assert (!g->specific->error); @@ -6253,7 +6260,10 @@ resolve_typebound_function (gfc_expr* e) /* Treat the call as if it is a typebound procedure, in order to roll out the correct name for the specific function. */ if (resolve_compcall (e, &name) == FAILURE) - return FAILURE; + { + gfc_free_ref_list (new_ref); + return FAILURE; + } ts = e->ts; if (overridable) @@ -6374,7 +6384,10 @@ resolve_typebound_subroutine (gfc_code *code) } if (resolve_typebound_call (code, &name) == FAILURE) - return FAILURE; + { + gfc_free_ref_list (new_ref); + return FAILURE; + } ts = code->expr1->ts; if (overridable) diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 3286a5a6fd6..81b7fa5ca27 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -2445,7 +2445,7 @@ gfc_get_derived_type (gfc_symbol * derived) || c->ts.u.derived->backend_decl == NULL) c->ts.u.derived->backend_decl = gfc_get_derived_type (c->ts.u.derived); - if (c->ts.u.derived && c->ts.u.derived->attr.is_iso_c) + if (c->ts.u.derived->attr.is_iso_c) { /* Need to copy the modified ts from the derived type. The typespec was modified because C_PTR/C_FUNPTR are translated diff --git a/gcc/gcc.c b/gcc/gcc.c index af3c34acfeb..bbca6d84e33 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1988,7 +1988,10 @@ record_temp_file (const char *filename, int always_delete, int fail_delete) struct temp_file *temp; for (temp = failure_delete_queue; temp; temp = temp->next) if (! filename_cmp (name, temp->name)) - goto already2; + { + free (name); + goto already2; + } temp = XNEW (struct temp_file); temp->next = failure_delete_queue; @@ -2462,8 +2465,11 @@ add_sysrooted_prefix (struct path_prefix *pprefix, const char *prefix, sysroot_no_trailing_dir_separator[sysroot_len - 1] = '\0'; if (target_sysroot_suffix) - prefix = concat (target_sysroot_suffix, prefix, NULL); - prefix = concat (sysroot_no_trailing_dir_separator, prefix, NULL); + prefix = concat (sysroot_no_trailing_dir_separator, + target_sysroot_suffix, prefix, NULL); + else + prefix = concat (sysroot_no_trailing_dir_separator, prefix, NULL); + free (sysroot_no_trailing_dir_separator); /* We have to override this because GCC's notion of sysroot @@ -3571,7 +3577,7 @@ process_command (unsigned int decoded_options_count, { const char *temp; char *temp1; - const char *tooldir_prefix; + char *tooldir_prefix, *tooldir_prefix2; char *(*get_relative_prefix) (const char *, const char *, const char *) = NULL; struct cl_option_handlers handlers; @@ -3920,15 +3926,16 @@ process_command (unsigned int decoded_options_count, } gcc_assert (!IS_ABSOLUTE_PATH (tooldir_base_prefix)); - tooldir_prefix = concat (tooldir_base_prefix, spec_machine, - dir_separator_str, NULL); + tooldir_prefix2 = concat (tooldir_base_prefix, spec_machine, + dir_separator_str, NULL); /* Look for tools relative to the location from which the driver is running, or, if that is not available, the configured prefix. */ tooldir_prefix = concat (gcc_exec_prefix ? gcc_exec_prefix : standard_exec_prefix, spec_machine, dir_separator_str, - spec_version, dir_separator_str, tooldir_prefix, NULL); + spec_version, dir_separator_str, tooldir_prefix2, NULL); + free (tooldir_prefix2); add_prefix (&exec_prefixes, concat (tooldir_prefix, "bin", dir_separator_str, NULL), @@ -3936,6 +3943,7 @@ process_command (unsigned int decoded_options_count, add_prefix (&startfile_prefixes, concat (tooldir_prefix, "lib", dir_separator_str, NULL), "BINUTILS", PREFIX_PRIORITY_LAST, 0, 1); + free (tooldir_prefix); #if defined(TARGET_SYSTEM_ROOT_RELOCATABLE) && !defined(VMS) /* If the normal TARGET_SYSTEM_ROOT is inside of $exec_prefix, @@ -4319,6 +4327,7 @@ do_self_spec (const char *spec) argbuf_copy, CL_DRIVER, &decoded_options, &decoded_options_count); + free (argbuf_copy); set_option_handlers (&handlers); @@ -4740,8 +4749,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) memcpy (tmp, save_temps_prefix, save_temps_length); memcpy (tmp + save_temps_length, suffix, suffix_length); tmp[save_temps_length + suffix_length] = '\0'; - temp_filename = save_string (tmp, - temp_filename_length + 1); + temp_filename = save_string (tmp, save_temps_length + + suffix_length); obstack_grow (&obstack, temp_filename, temp_filename_length); arg_going = 1; @@ -5055,6 +5064,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) /* This option is new; add it. */ add_linker_option (string, strlen (string)); + free (string); } break; @@ -8186,7 +8196,7 @@ static const char * compare_debug_dump_opt_spec_function (int arg, const char **argv ATTRIBUTE_UNUSED) { - const char *ret; + char *ret; char *name; int which; static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3]; @@ -8240,8 +8250,12 @@ compare_debug_dump_opt_spec_function (int arg, } if (*random_seed) - ret = concat ("%{!frandom-seed=*:-frandom-seed=", random_seed, "} ", - ret, NULL); + { + char *tmp = ret; + ret = concat ("%{!frandom-seed=*:-frandom-seed=", random_seed, "} ", + ret, NULL); + free (tmp); + } if (which) *random_seed = 0; diff --git a/gcc/gengtype.c b/gcc/gengtype.c index d17f5bf44b4..4a36d567df1 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -2815,6 +2815,7 @@ walk_type (type_p t, struct walk_type_data *d) const char *oldval = d->val; const char *oldprevval1 = d->prev_val[1]; const char *oldprevval2 = d->prev_val[2]; + const char *struct_mark_hook = NULL; const int union_p = t->kind == TYPE_UNION; int seen_default_p = 0; options_p o; @@ -2838,6 +2839,13 @@ walk_type (type_p t, struct walk_type_data *d) if (!desc && strcmp (o->name, "desc") == 0 && o->kind == OPTION_STRING) desc = o->info.string; + else if (!struct_mark_hook && strcmp (o->name, "mark_hook") == 0 + && o->kind == OPTION_STRING) + struct_mark_hook = o->info.string; + + if (struct_mark_hook) + oprintf (d->of, "%*s%s (&%s);\n", + d->indent, "", struct_mark_hook, oldval); d->prev_val[2] = oldval; d->prev_val[1] = oldprevval2; diff --git a/gcc/opts.c b/gcc/opts.c index 8608a56dfe3..ccfe3c70a91 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1475,6 +1475,8 @@ common_handle_option (struct gcc_options *opts, strip_off_ending (tmp, strlen (tmp)); if (tmp[0]) opts->x_aux_base_name = tmp; + else + free (tmp); } break; diff --git a/gcc/reginfo.c b/gcc/reginfo.c index cdd85001b16..076036c5c57 100644 --- a/gcc/reginfo.c +++ b/gcc/reginfo.c @@ -839,6 +839,8 @@ static struct reg_pref *reg_pref; /* Current size of reg_info. */ static int reg_info_size; +/* Max_reg_num still last resize_reg_info call. */ +static int max_regno_since_last_resize; /* Return the reg_class in which pseudo reg number REGNO is best allocated. This function is sometimes called before the info has been computed. @@ -849,6 +851,7 @@ reg_preferred_class (int regno) if (reg_pref == 0) return GENERAL_REGS; + gcc_assert (regno < reg_info_size); return (enum reg_class) reg_pref[regno].prefclass; } @@ -858,6 +861,7 @@ reg_alternate_class (int regno) if (reg_pref == 0) return ALL_REGS; + gcc_assert (regno < reg_info_size); return (enum reg_class) reg_pref[regno].altclass; } @@ -868,45 +872,64 @@ reg_allocno_class (int regno) if (reg_pref == 0) return NO_REGS; + gcc_assert (regno < reg_info_size); return (enum reg_class) reg_pref[regno].allocnoclass; } -/* Allocate space for reg info. */ +/* Allocate space for reg info and initilize it. */ static void allocate_reg_info (void) { - reg_info_size = max_reg_num (); + int i; + + max_regno_since_last_resize = max_reg_num (); + reg_info_size = max_regno_since_last_resize * 3 / 2 + 1; gcc_assert (! reg_pref && ! reg_renumber); reg_renumber = XNEWVEC (short, reg_info_size); reg_pref = XCNEWVEC (struct reg_pref, reg_info_size); memset (reg_renumber, -1, reg_info_size * sizeof (short)); + for (i = 0; i < reg_info_size; i++) + { + reg_pref[i].prefclass = GENERAL_REGS; + reg_pref[i].altclass = ALL_REGS; + reg_pref[i].allocnoclass = GENERAL_REGS; + } } -/* Resize reg info. The new elements will be uninitialized. Return - TRUE if new elements (for new pseudos) were added. */ +/* Resize reg info. The new elements will be initialized. Return TRUE + if new pseudos were added since the last call. */ bool resize_reg_info (void) { - int old; + int old, i; + bool change_p; if (reg_pref == NULL) { allocate_reg_info (); return true; } - if (reg_info_size == max_reg_num ()) - return false; + change_p = max_regno_since_last_resize != max_reg_num (); + max_regno_since_last_resize = max_reg_num (); + if (reg_info_size >= max_reg_num ()) + return change_p; old = reg_info_size; - reg_info_size = max_reg_num (); + reg_info_size = max_reg_num () * 3 / 2 + 1; gcc_assert (reg_pref && reg_renumber); reg_renumber = XRESIZEVEC (short, reg_renumber, reg_info_size); reg_pref = XRESIZEVEC (struct reg_pref, reg_pref, reg_info_size); memset (reg_pref + old, -1, (reg_info_size - old) * sizeof (struct reg_pref)); memset (reg_renumber + old, -1, (reg_info_size - old) * sizeof (short)); + for (i = old; i < reg_info_size; i++) + { + reg_pref[i].prefclass = GENERAL_REGS; + reg_pref[i].altclass = ALL_REGS; + reg_pref[i].allocnoclass = GENERAL_REGS; + } return true; } @@ -938,6 +961,7 @@ reginfo_init (void) /* This prevents dump_reg_info from losing if called before reginfo is run. */ reg_pref = NULL; + reg_info_size = max_regno_since_last_resize = 0; /* No more global register variables may be declared. */ no_global_reg_vars = 1; return 1; @@ -964,7 +988,7 @@ struct rtl_opt_pass pass_reginfo_init = -/* Set up preferred, alternate, and cover classes for REGNO as +/* Set up preferred, alternate, and allocno classes for REGNO as PREFCLASS, ALTCLASS, and ALLOCNOCLASS. */ void setup_reg_classes (int regno, @@ -973,7 +997,7 @@ setup_reg_classes (int regno, { if (reg_pref == NULL) return; - gcc_assert (reg_info_size == max_reg_num ()); + gcc_assert (reg_info_size >= max_reg_num ()); reg_pref[regno].prefclass = prefclass; reg_pref[regno].altclass = altclass; reg_pref[regno].allocnoclass = allocnoclass; diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c index 6625a53a699..936a1317bb7 100644 --- a/gcc/sched-deps.c +++ b/gcc/sched-deps.c @@ -4816,10 +4816,10 @@ find_mem (struct mem_inc_info *mii, rtx *address_of_x) void find_modifiable_mems (rtx head, rtx tail) { - rtx insn; + rtx insn, next_tail = NEXT_INSN (tail); int success_in_block = 0; - for (insn = head; insn != tail; insn = NEXT_INSN (insn)) + for (insn = head; insn != next_tail; insn = NEXT_INSN (insn)) { struct mem_inc_info mii; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2120cb4d965..6d99e71c68d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,41 @@ +2012-10-04 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.dg/lto/20120723_0.c: Skip on SPARC 32-bit. + +2012-10-04 Florian Weimer <fweimer@redhat.com> + + * c-c++-common/cpp/diagnostic-pragma-1.c: New testcase. + +2012-10-04 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/54323 + * g++.dg/cpp0x/pr54323.C: New. + +2012-10-04 Richard Guenther <rguenther@suse.de> + + PR middle-end/54735 + * g++.dg/torture/pr54735.C: New testcase. + +2012-10-04 Eric Botcazou <ebotcazou@adacore.com> + + PR rtl-optimization/54739 + * gcc.dg/lower-subreg-1.c: Also skip on SPARC. + +2012-10-03 Oleg Endo <olegendo@gcc.gnu.org> + + PR target/51244 + * gcc.target/sh/pr51244-12.c: New. + +2012-10-03 Dehao Chen <dehao@google.com> + + PR middle-end/54782 + * gcc.dg/pr54782.c: New test. + +2012-10-03 Jakub Jelinek <jakub@redhat.com> + + PR c++/54777 + * g++.dg/cpp0x/constexpr-ref4.C: New test. + 2012-10-02 Janus Weil <janus@gcc.gnu.org> PR fortran/54778 diff --git a/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-1.c b/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-1.c new file mode 100644 index 00000000000..9867c94a8dd --- /dev/null +++ b/gcc/testsuite/c-c++-common/cpp/diagnostic-pragma-1.c @@ -0,0 +1,11 @@ +// { dg-do compile } + +#pragma GCC warning "warn-a" // { dg-warning warn-a } +#pragma GCC error "err-b" // { dg-error err-b } + +#define CONST1 _Pragma("GCC warning \"warn-c\"") 1 +#define CONST2 _Pragma("GCC error \"err-d\"") 2 + +char a[CONST1]; // { dg-warning warn-c } +char b[CONST2]; // { dg-error err-d } + diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C new file mode 100644 index 00000000000..6ae355a273f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref4.C @@ -0,0 +1,18 @@ +// PR c++/54777 +// { dg-options -std=c++0x } + +struct S +{ + int s[1]; + constexpr const int &foo (unsigned i) { return (i < 1 ? 0 : throw 1), s[i]; } + constexpr const int &bar (unsigned i) { return i < 1 ? s[i] : (throw 0, s[i]); } +}; + +int +main () +{ + constexpr S a {}; + constexpr int i = a.foo (0); + constexpr int j = a.bar (0); + static_assert (i == j, "Ouch"); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr54323.C b/gcc/testsuite/g++.dg/cpp0x/pr54323.C new file mode 100644 index 00000000000..71b6c7192df --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr54323.C @@ -0,0 +1,37 @@ +// PR c++/54323 +// { dg-do compile { target c++11 } } + +template<bool, typename T = void> +struct enable_if { }; + +template<typename T> +struct enable_if<true, T> +{ typedef T type; }; + +template<template<typename> class CRTP, typename T> +class Base +{ +public: + template<template<typename> class CRTP0, typename T0, class> + friend int func(const Base<CRTP0, T0>& rhs); + +protected: + int n; +}; + +template<template<typename> class CRTP0, typename T0, + class = typename enable_if<true>::type> +int func(const Base<CRTP0, T0>& rhs) +{ + return rhs.n; +} + +template<typename T> +class Derived : public Base<Derived, T> {}; + +int main() +{ + Derived<int> x; + func(x); + return 0; +} diff --git a/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C b/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C index 4300d1ab16a..b8133909a7f 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C +++ b/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C @@ -1,7 +1,7 @@ /* Test that #pragma GCC visibility does not override class member specific settings. */ /* { dg-do compile } */ /* { dg-require-visibility "internal" } */ -/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" { target { ! *-*-solaris2* } } } } */ +/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" { target { ! *-*-solaris2* } { ! *-*-darwin* } } } }*/ /* { dg-final { scan-assembler "\\.(internal|hidden).*Foo.methodEv" { target *-*-solaris2* } } } */ #pragma GCC visibility push(hidden) diff --git a/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C b/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C index f566cd2f419..3ceaf4a2523 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C +++ b/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C @@ -1,7 +1,7 @@ /* Test that #pragma GCC visibility does not override class member specific settings. */ /* { dg-do compile } */ /* { dg-require-visibility "internal" } */ -/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" { target { ! *-*-solaris2* } } } } */ +/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" { target { ! *-*-solaris2* } { ! *-*-darwin* } } } } */ /* { dg-final { scan-assembler "\\.(internal|hidden).*Foo.methodEv" { target *-*-solaris2* } } } */ #pragma GCC visibility push(hidden) diff --git a/gcc/testsuite/g++.dg/torture/pr54735.C b/gcc/testsuite/g++.dg/torture/pr54735.C new file mode 100644 index 00000000000..0604ec5179b --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr54735.C @@ -0,0 +1,179 @@ +// { dg-do compile } + +class Gmpfr +{}; +class M : Gmpfr +{ +public: + Gmpfr infconst; + M(int); +}; +template<typename>struct A; +template<typename, int, int, int = 0 ? : 0, int = 0, int = 0>class N; +template<typename>class O; +template<typename>struct B; +struct C +{ + enum + { value }; +}; +class D +{ +public: + enum + { ret }; +}; +struct F +{ + enum + { ret = 0 ? : 0 }; +}; +template<typename Derived>struct G +{ + typedef O<Derived>type; +}; +struct H +{ + void operator * (); +}; +struct I +{ + enum + { RequireInitialization = C::value ? : 0, ReadCost }; +}; +template<typename Derived>struct J +{ + enum + { ret = A<Derived>::InnerStrideAtCompileTime }; +}; +template<typename Derived>struct K +{ + enum + { ret = A<Derived>::OuterStrideAtCompileTime }; +}; +template<typename Derived>class P : H +{ +public: + using H::operator *; + typedef typename A<Derived>::Scalar Scalar; + enum + { RowsAtCompileTime = + A<Derived>::RowsAtCompileTime, ColsAtCompileTime = + A<Derived>::ColsAtCompileTime, SizeAtCompileTime = + F::ret, MaxRowsAtCompileTime = + A<Derived>::MaxRowsAtCompileTime, MaxColsAtCompileTime = + A<Derived>::MaxColsAtCompileTime, MaxSizeAtCompileTime = + F::ret, Flags = + A<Derived>::Flags ? : 0 ? : 0, CoeffReadCost = + A<Derived>::CoeffReadCost, InnerStrideAtCompileTime = + J<Derived>::ret, OuterStrideAtCompileTime = K<Derived>::ret }; + B<Derived> operator << (const Scalar&); +}; + +template<typename Derived>class O : public P<Derived> +{}; + +template<int _Cols>class L +{ +public: + + int cols() + { + return _Cols; + } +}; +template<typename Derived>class Q : public G<Derived>::type +{ +public: + typedef typename G<Derived>::type Base; + typedef typename A<Derived>::Index Index; + typedef typename A<Derived>::Scalar Scalar; + L<Base::ColsAtCompileTime> m_storage; + Index cols() + { + return m_storage.cols(); + } + + Scalar& coeffRef(Index, + Index); +}; + +template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, + int _MaxCols>struct A<N<_Scalar, _Rows, _Cols, _Options, _MaxRows, + _MaxCols> > +{ + typedef _Scalar Scalar; + typedef int Index; + enum + { RowsAtCompileTime, ColsAtCompileTime = + _Cols, MaxRowsAtCompileTime, MaxColsAtCompileTime, Flags = + D::ret, CoeffReadCost = + I::ReadCost, InnerStrideAtCompileTime, OuterStrideAtCompileTime = + 0 ? : 0 }; +}; +template<typename _Scalar, int, int _Cols, int, int, + int>class N : public Q<N<_Scalar, 0, _Cols> > +{ +public: + Q<N> Base; + template<typename T0, typename T1>N(const T0&, + const T1&); +}; +void +__assert_fail(int) +throw() __attribute__((__noreturn__)); +template<typename XprType>struct B +{ + typedef typename XprType::Scalar Scalar; + typedef typename XprType::Index Index; + B(XprType & p1, const Scalar &) : m_xpr(p1), m_col(), + m_currentBlockRows(1) + {} B& operator, (const Scalar&) + { + Index a; + + if (m_col == m_xpr.cols()) + { + m_col = 0; + m_currentBlockRows = 1; + a && "Too " ? static_cast<void>(0) : __assert_fail(0); + } + m_col < m_xpr.cols() + && "Too " ? static_cast<void>(0) : __assert_fail(1); + m_currentBlockRows ? static_cast<void>(0) : __assert_fail(4); + m_xpr.coeffRef(0, m_col++) = 0; + return *this; + } + ~B() + { + 1 + m_currentBlockRows && m_col + && "Too " ? static_cast<void>(0) : __assert_fail(0); + } + + XprType& m_xpr; + Index m_col; + Index m_currentBlockRows; +}; + +template<typename Derived>B<Derived>P< + Derived >::operator << (const Scalar&) +{ + return B<Derived>(*static_cast<Derived *>(this), 0); +} + +template<class NT, int s>void + check_() +{ + N<NT, 0, s>m(0, 0); + m << 0, 0, 0, 0; +} + +template<class NT>void check() +{ + check_<NT, 3>(); +} + +int main() +{ + check<M>(); +} diff --git a/gcc/testsuite/gcc.dg/lower-subreg-1.c b/gcc/testsuite/gcc.dg/lower-subreg-1.c index 58d95fe95aa..f5827e1db1f 100644 --- a/gcc/testsuite/gcc.dg/lower-subreg-1.c +++ b/gcc/testsuite/gcc.dg/lower-subreg-1.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { ! { mips64 || { arm*-*-* ia64-*-* spu-*-* tilegx-*-* } } } } } */ +/* { dg-do compile { target { ! { mips64 || { arm*-*-* ia64-*-* sparc*-*-* spu-*-* tilegx-*-* } } } } } */ /* { dg-options "-O -fdump-rtl-subreg1" } */ /* { dg-skip-if "" { { i?86-*-* x86_64-*-* } && x32 } { "*" } { "" } } */ /* { dg-require-effective-target ilp32 } */ diff --git a/gcc/testsuite/gcc.dg/lto/20120723_0.c b/gcc/testsuite/gcc.dg/lto/20120723_0.c index ea08a0067da..78cfdf77c5b 100644 --- a/gcc/testsuite/gcc.dg/lto/20120723_0.c +++ b/gcc/testsuite/gcc.dg/lto/20120723_0.c @@ -1,7 +1,9 @@ /* Make sure that by reference and by value aggregate jump functions do not get - mixed up. */ + mixed up. + ??? This testcase is invalid C and can only pass on specific platforms. */ /* { dg-lto-do run } */ -/* { dg-lto-options {{-O3 -fno-early-inlining -flto}} } */ +/* { dg-skip-if "" { { sparc*-*-* } && ilp32 } { "*" } { "" } } */ +/* { dg-lto-options { {-O3 -fno-early-inlining -flto}} } */ extern void abort (void); diff --git a/gcc/testsuite/gcc.dg/pr54782.c b/gcc/testsuite/gcc.dg/pr54782.c new file mode 100644 index 00000000000..2a30754493e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr54782.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffast-math -ftree-parallelize-loops=2 -g" } */ + +struct S +{ + int n; + float *a; +}; + +int +foo (struct S *s) +{ + float sum = 0; + int i; + for (i = 0; i < s->n; i++) + sum += s->a[i]; + return sum; +} diff --git a/gcc/testsuite/gcc.target/sh/pr51244-12.c b/gcc/testsuite/gcc.target/sh/pr51244-12.c new file mode 100644 index 00000000000..ca8e2d4b3bf --- /dev/null +++ b/gcc/testsuite/gcc.target/sh/pr51244-12.c @@ -0,0 +1,68 @@ +/* Check that the negc instruction is generated as expected for the cases + below. If we see a movrt or #-1 negc sequence it means that the pattern + which handles the inverted case does not work properly. */ +/* { dg-do compile { target "sh*-*-*" } } */ +/* { dg-options "-O1" } */ +/* { dg-skip-if "" { "sh*-*-*" } { "-m5*" } { "" } } */ +/* { dg-final { scan-assembler-times "negc" 10 } } */ +/* { dg-final { scan-assembler-not "movrt|#-1|add|sub" } } */ + +int +test00 (int a, int b, int* x) +{ + return (a == b) ? 0x7FFFFFFF : 0x80000000; +} + +int +test00_inv (int a, int b) +{ + return (a != b) ? 0x80000000 : 0x7FFFFFFF; +} + +int +test01 (int a, int b) +{ + return (a >= b) ? 0x7FFFFFFF : 0x80000000; +} + +int +test01_inv (int a, int b) +{ + return (a < b) ? 0x80000000 : 0x7FFFFFFF; +} + +int +test02 (int a, int b) +{ + return (a > b) ? 0x7FFFFFFF : 0x80000000; +} + +int +test02_inv (int a, int b) +{ + return (a <= b) ? 0x80000000 : 0x7FFFFFFF; +} + +int +test03 (int a, int b) +{ + return ((a & b) == 0) ? 0x7FFFFFFF : 0x80000000; +} + +int +test03_inv (int a, int b) +{ + return ((a & b) != 0) ? 0x80000000 : 0x7FFFFFFF; +} + +int +test04 (int a) +{ + return ((a & 0x55) == 0) ? 0x7FFFFFFF : 0x80000000; +} + +int +test04_inv (int a) +{ + return ((a & 0x55) != 0) ? 0x80000000 : 0x7FFFFFFF; +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index b14a3b929f5..af277b79e09 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6322,6 +6322,7 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb, use_operand_p use; tree op = PHI_RESULT (phi); ssa_op_iter oi; + unsigned i; if (virtual_operand_p (op)) { @@ -6340,6 +6341,23 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb, SET_USE (use, replace_ssa_name (op, d->vars_map, dest_cfun->decl)); } + for (i = 0; i < EDGE_COUNT (bb->preds); i++) + { + location_t locus = gimple_phi_arg_location (phi, i); + tree block = LOCATION_BLOCK (locus); + + if (locus == UNKNOWN_LOCATION) + continue; + if (d->orig_block == NULL_TREE || block == d->orig_block) + { + if (d->new_block == NULL_TREE) + locus = LOCATION_LOCUS (locus); + else + locus = COMBINE_LOCATION_DATA (line_table, locus, d->new_block); + gimple_phi_arg_set_location (phi, i, locus); + } + } + gsi_next (&si); } diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 86c33d31853..8dbbed236c7 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -4820,6 +4820,13 @@ do_pre (void) free_scc_vn (); + /* Tail merging invalidates the virtual SSA web, together with + cfg-cleanup opportunities exposed by PRE this will wreck the + SSA updating machinery. So make sure to run update-ssa + manually, before eventually scheduling cfg-cleanup as part of + the todo. */ + update_ssa (TODO_update_ssa_only_virtuals); + return todo; } @@ -4845,8 +4852,7 @@ struct gimple_opt_pass pass_pre = 0, /* properties_provided */ 0, /* properties_destroyed */ TODO_rebuild_alias, /* todo_flags_start */ - TODO_update_ssa_only_virtuals | TODO_ggc_collect - | TODO_verify_ssa /* todo_flags_finish */ + TODO_ggc_collect | TODO_verify_ssa /* todo_flags_finish */ } }; diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c index 73a81c9c3cc..fc6984583e8 100644 --- a/gcc/tree-streamer-in.c +++ b/gcc/tree-streamer-in.c @@ -792,22 +792,22 @@ static void lto_input_ts_block_tree_pointers (struct lto_input_block *ib, struct data_in *data_in, tree expr) { - /* Do not stream BLOCK_SOURCE_LOCATION. We cannot handle debug information - for early inlining so drop it on the floor instead of ICEing in - dwarf2out.c. */ BLOCK_VARS (expr) = streamer_read_chain (ib, data_in); - /* Do not stream BLOCK_NONLOCALIZED_VARS. We cannot handle debug information - for early inlining so drop it on the floor instead of ICEing in - dwarf2out.c. */ - BLOCK_SUPERCONTEXT (expr) = stream_read_tree (ib, data_in); - /* Do not stream BLOCK_ABSTRACT_ORIGIN. We cannot handle debug information - for early inlining so drop it on the floor instead of ICEing in + /* Stream BLOCK_ABSTRACT_ORIGIN and BLOCK_SOURCE_LOCATION for + the limited cases we can handle - those that represent inlined + function scopes. For the rest them on the floor instead of ICEing in dwarf2out.c. */ - BLOCK_FRAGMENT_ORIGIN (expr) = stream_read_tree (ib, data_in); - BLOCK_FRAGMENT_CHAIN (expr) = stream_read_tree (ib, data_in); + BLOCK_ABSTRACT_ORIGIN (expr) = stream_read_tree (ib, data_in); + BLOCK_SOURCE_LOCATION (expr) = lto_input_location (ib, data_in); + /* Do not stream BLOCK_NONLOCALIZED_VARS. We cannot handle debug information + for early inlined BLOCKs so drop it on the floor instead of ICEing in + dwarf2out.c. */ + + /* BLOCK_FRAGMENT_ORIGIN and BLOCK_FRAGMENT_CHAIN is not live at LTO + streaming time. */ /* We re-compute BLOCK_SUBBLOCKS of our parent here instead of streaming it. For non-BLOCK BLOCK_SUPERCONTEXTs we still diff --git a/gcc/tree-streamer-out.c b/gcc/tree-streamer-out.c index 63f7a02d587..4fccd7720d2 100644 --- a/gcc/tree-streamer-out.c +++ b/gcc/tree-streamer-out.c @@ -685,21 +685,32 @@ write_ts_exp_tree_pointers (struct output_block *ob, tree expr, bool ref_p) static void write_ts_block_tree_pointers (struct output_block *ob, tree expr, bool ref_p) { - /* Do not stream BLOCK_SOURCE_LOCATION. We cannot handle debug information - for early inlining so drop it on the floor instead of ICEing in - dwarf2out.c. */ streamer_write_chain (ob, BLOCK_VARS (expr), ref_p); + stream_write_tree (ob, BLOCK_SUPERCONTEXT (expr), ref_p); + + /* Stream BLOCK_ABSTRACT_ORIGIN and BLOCK_SOURCE_LOCATION for + the limited cases we can handle - those that represent inlined + function scopes. For the rest them on the floor instead of ICEing in + dwarf2out.c. */ + if (inlined_function_outer_scope_p (expr)) + { + tree ultimate_origin = block_ultimate_origin (expr); + stream_write_tree (ob, ultimate_origin, ref_p); + lto_output_location (ob, BLOCK_SOURCE_LOCATION (expr)); + } + else + { + stream_write_tree (ob, NULL_TREE, ref_p); + lto_output_location (ob, UNKNOWN_LOCATION); + } /* Do not stream BLOCK_NONLOCALIZED_VARS. We cannot handle debug information - for early inlining so drop it on the floor instead of ICEing in + for early inlined BLOCKs so drop it on the floor instead of ICEing in dwarf2out.c. */ - stream_write_tree (ob, BLOCK_SUPERCONTEXT (expr), ref_p); - /* Do not stream BLOCK_ABSTRACT_ORIGIN. We cannot handle debug information - for early inlining so drop it on the floor instead of ICEing in - dwarf2out.c. */ - stream_write_tree (ob, BLOCK_FRAGMENT_ORIGIN (expr), ref_p); - stream_write_tree (ob, BLOCK_FRAGMENT_CHAIN (expr), ref_p); + /* BLOCK_FRAGMENT_ORIGIN and BLOCK_FRAGMENT_CHAIN is not live at LTO + streaming time. */ + /* Do not output BLOCK_SUBBLOCKS. Instead on streaming-in this list is re-constructed from BLOCK_SUPERCONTEXT. */ } |