diff options
Diffstat (limited to 'gcc')
151 files changed, 3561 insertions, 529 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2985bfab12c..db5c5f1df45 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,403 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + +2014-06-04 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-05-13 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/57230 + * tree-ssa-strlen.c (handle_char_store): Add missing integer_zerop + check. + +2014-05-28 Georg-Johann Lay <avr@gjlay.de> + + PR target/61044 + * doc/extend.texi (Local Labels): Note that label differences are + not supported for AVR. + +2014-05-23 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-08-30 Richard Biener <rguenther@suse.de> + + PR tree-optimization/58228 + * tree-vect-data-refs.c (vect_analyze_data_ref_access): Do not + allow invariant loads in nested loop vectorization. + + 2013-09-26 Richard Biener <rguenther@suse.de> + + PR tree-optimization/58539 + * tree-vect-loop.c (vect_create_epilog_for_reduction): Honor + the fact that debug statements are not taking part in loop-closed + SSA construction. + +2014-05-22 Richard Earnshaw <rearnsha@arm.com> + + PR target/61208 + * arm.md (arm_cmpdi_unsigned): Fix length calculation for Thumb2. + +2014-05-20 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> + + Backport from mainline r210325 + 2014-05-12 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> + + PR target/60991 + * config/avr/avr.c (avr_out_store_psi): Use correct constant + to restore Y. + +2014-05-13 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2014-03-04 Richard Biener <rguenther@suse.de> + + PR tree-optimization/60382 + * tree-vect-loop.c (vect_is_simple_reduction_1): Do not consider + dead PHIs a reduction. + +2014-05-09 Georg-Johann Lay <avr@gjlay.de> + + Backport from 2014-05-09 trunk r210267 + + PR target/61055 + * config/avr/avr.md (cc): Add new attribute set_vzn. + (addqi3, negqi2) [cc]: + Set cc insn attribute to set_vzn instead of set_zn for alternatives + with INC, DEC or NEG. + * config/avr/avr.c (avr_notice_update_cc): Handle SET_VZN. + (avr_out_plus_1): ADIW sets cc0 to CC_SET_CZN. + INC, DEC set cc0 to CC_CLOBBER. + +2014-05-08 Charles Baylis <charles.baylis@linaro.org> + + Backport from mainline + 2014-04-07 Charles Baylis <charles.baylis@linaro.org> + + PR target/60609 + * config/arm/arm.h (ASM_OUTPUT_CASE_END): Remove. + (LABEL_ALIGN_AFTER_BARRIER): Align barriers which occur after + ADDR_DIFF_VEC. + +2014-05-07 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2013-10-21 Marek Polacek <polacek@redhat.com> + + PR middle-end/58809 + * fold-const.c (fold_range_test): Return 0 if the type is not + an integral type. + + 2013-12-03 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/59011 + * gimplify.c (nonlocal_vla_vars): New variable. + (gimplify_var_or_parm_decl): Put VAR_DECLs for VLAs into + nonlocal_vla_vars chain. + (gimplify_body): Call declare_vars on nonlocal_vla_vars chain + if outer_bind has DECL_INITIAL (current_function_decl) block. + + 2013-11-26 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/59014 + * tree-vrp.c (register_edge_assert_for_1): Don't look + through conversions from non-integral types or through + narrowing conversions. + + 2013-11-14 Jakub Jelinek <jakub@redhat.com> + Uros Bizjak <ubizjak@gmail.com> + + PR target/59101 + * config/i386/i386.md (*anddi_2): Only allow CCZmode if + operands[2] satisfies_constraint_Z that might have bit 31 set. + + 2013-09-30 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/58564 + * fold-const.c (fold_ternary_loc): For A < 0 : <sign bit of A> : 0 + optimization, punt if sign_bit_p looked through any zero extension. + + 2013-09-10 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/58365 + * cfgcleanup.c (merge_memattrs): Also clear MEM_READONLY_P + resp. MEM_NOTRAP_P if they differ, or set MEM_VOLATILE_P if + it differs. + + 2013-08-30 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/58277 + * tree-ssa-strlen.c (strlen_enter_block): If do_invalidate gave up + after seeing too many stmts with vdef in between dombb and current + bb, invalidate everything. + + 2013-08-23 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/58209 + * tree-tailcall.c (find_tail_calls): Give up for pointer result types + if m or a is non-NULL. + + 2013-07-03 Jakub Jelinek <jakub@redhat.com> + + PR target/57777 + * config/i386/predicates.md (vsib_address_operand): Disallow + SYMBOL_REF or LABEL_REF in parts.disp if TARGET_64BIT && flag_pic. + + 2013-06-27 Jakub Jelinek <jakub@redhat.com> + + PR target/57623 + * config/i386/i386.md (bmi_bextr_<mode>): Swap predicates and + constraints of operand 1 and 2. + + PR target/57623 + * config/i386/i386.md (bmi2_bzhi_<mode>3): Swap AND arguments + to match RTL canonicalization. Swap predicates and + constraints of operand 1 and 2. + +2014-05-07 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-11-19 Richard Biener <rguenther@suse.de> + + PR tree-optimization/59164 + * tree-vect-loop.c (vect_analyze_loop_operations): Adjust + check whether we can create an epilogue loop to reflect the + cases where we create one. + +2014-05-07 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-11-29 Richard Biener <rguenther@suse.de> + + PR tree-optimization/59334 + * tree-ssa-dce.c (eliminate_unnecessary_stmts): Fix bug + in previous commit. + + 2013-11-28 Richard Biener <rguenther@suse.de> + + PR tree-optimization/59330 + * tree-ssa-dce.c (eliminate_unnecessary_stmts): Simplify + and fix delayed marking of free calls not necessary. + + 2014-01-09 Richard Biener <rguenther@suse.de> + + PR tree-optimization/59715 + * tree-cfg.h (split_critical_edges): Declare. + * tree-cfg.c (split_critical_edges): Export. + * tree-ssa-sink.c (execute_sink_code): Split critical edges. + +2014-05-07 Richard Biener <rguenther@suse.de> + + PR tree-optimization/57864 + * tree-ssa-pre.c (phi_translate_1): Backport NAME case + simplification from mainline. Do not lookup the VN + value-number here. + +2014-05-07 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-08-29 Richard Biener <rguenther@suse.de> + + PR tree-optimization/58246 + * tree-ssa-dce.c (mark_aliased_reaching_defs_necessary_1): Properly + handle the dominance check inside a basic-block. + +2014-05-06 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-05-27 Richard Biener <rguenther@suse.de> + + PR tree-optimization/57417 + * tree-ssa-sccvn.c (set_ssa_val_to): Compare addresses using + get_addr_base_and_unit_offset. + +2014-04-25 Eric Botcazou <ebotcazou@adacore.com> + + PR target/60941 + * config/sparc/sparc.md (ashlsi3_extend): Delete. + +2014-04-23 Uros Bizjak <ubizjak@gmail.com> + + Backport from mainline + 2014-04-21 Uros Bizjak <ubizjak@gmail.com> + + PR target/60909 + * config/i386/i386.c (ix86_expand_builtin) + <case IX86_BUILTIN_RDRAND{16,32,64}_STEP>: Use temporary + register for target RTX. + +2014-04-07 Martin Jambor <mjambor@suse.cz> + + PR ipa/60640 + * ipa-cp.c (propagate_constants_accross_call): Do not propagate + accross thunks. + +2014-04-07 Dominique d'Humieres <dominiq@lps.ens.fr> + + Backport from mainline + 2013-09-14 Iain Sandoe <iains@gcc.gnu.org> + + PR target/48094 + * config/darwin.c (darwin_objc2_section): Note if ObjC Metadata + is seen. + (darwin_objc1_section): Likewise. + (darwin_file_end): Emit Image Info section when required. + +2014-04-04 Richard Biener <rguenther@suse.de> + + * tree-ssanames.c (make_ssa_name_fn): Fix assert. + +2014-04-01 Richard Biener <rguenther@suse.de> + + * gimple.h (struct gimple_statement_base): Align subcode to + 16 bits. + +2014-04-01 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * doc/invoke.texi (mapp-regs): Clarify. + +2014-03-23 Eric Botcazou <ebotcazou@adacore.com> + + PR rtl-optimization/60601 + * bb-reorder.c (fix_up_fall_thru_edges): Test EDGE_FALLTHRU everywhere. + +2014-03-20 Jakub Jelinek <jakub@redhat.com> + + PR target/60568 + * config/i386/i386.c (x86_output_mi_thunk): Surround UNSPEC_GOT + into CONST, put pic register as first operand of PLUS. Use + gen_const_mem for both 32-bit and 64-bit PIC got loads. + +2014-03-19 Eric Botcazou <ebotcazou@adacore.com> + + * tree-dfa.c (get_ref_base_and_extent) <ARRAY_REF>: Remove space. + +2014-03-18 Kai Tietz <ktietz@redhat.com> + + PR rtl-optimization/56356 + * sdbout.c (sdbout_parms): Verify that parms' + incoming argument is valid. + (sdbout_reg_parms): Likewise. + +2014-03-18 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-11-05 Richard Biener <rguenther@suse.de> + + PR middle-end/58941 + * tree-dfa.c (get_ref_base_and_extent): Merge common code + in MEM_REF and TARGET_MEM_REF handling. Make sure to + process trailing array detection before diving into the + view-converted object (and possibly apply some extra offset). + + 2012-05-07 Eric Botcazou <ebotcazou@adacore.com> + + * tree-dfa.c (get_ref_base_and_extent) <ARRAY_REF>: Do the offset + computation using the precision of the index type. + + 2012-05-31 Eric Botcazou <ebotcazou@adacore.com> + + * tree-dfa.c (get_ref_base_and_extent): Compute the offset using + double ints throughout. + +2014-03-18 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-08-27 Richard Biener <rguenther@suse.de> + + PR tree-optimization/57521 + * tree-if-conv.c (if_convertible_bb_p): Verify that at least + one edge is non-critical. + (find_phi_replacement_condition): Make sure to use a non-critical + edge. Cleanup and remove old bug workarounds. + (bb_postdominates_preds): Remove. + (if_convertible_loop_p_1): Do not compute post-dominators. + (combine_blocks): Do not free post-dominators. + (main_tree_if_conversion): Likewise. + + 2013-09-03 Richard Biener <rguenther@suse.de> + + PR middle-end/57656 + * fold-const.c (negate_expr_p): Fix division case. + (negate_expr): Likewise. + + 2013-11-19 Richard Biener <rguenther@suse.de> + + PR tree-optimization/57517 + * tree-predcom.c (combinable_refs_p): Verify the combination + is always executed when the refs are. + +2014-03-17 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-05-21 Richard Biener <rguenther@suse.de> + + PR tree-optimization/57303 + * tree-ssa-sink.c (statement_sink_location): Properly handle + self-assignments. + + 2013-12-02 Richard Biener <rguenther@suse.de> + + PR tree-optimization/59139 + * tree-ssa-loop-niter.c (chain_of_csts_start): Properly match + code in get_val_for. + (get_val_for): Use gcc_checking_asserts. + + 2014-02-14 Richard Biener <rguenther@suse.de> + + PR tree-optimization/60183 + * tree-ssa-phiprop.c (propagate_with_phi): Avoid speculating + loads. + (tree_ssa_phiprop): Calculate and free post-dominators. + +2014-03-14 Georg-Johann Lay <avr@gjlay.de> + + Backport from 2014-03-14 trunk r208562. + + PR target/59396 + * config/avr/avr.c (avr_set_current_function): Pass function name + through default_strip_name_encoding before sanity checking instead + of skipping the first char of the assembler name. + +2014-02-24 John David Anglin <danglin@gcc.gnu.org> + + * config/pa/pa.c (pa_output_move_double): Don't valididate when + adjusting offsetable addresses. + +2014-02-21 Uros Bizjak <ubizjak@gmail.com> + + Backport from mainline + 2014-02-21 Jakub Jelinek <jakub@redhat.com> + + * config/i386/i386.c (ix86_expand_vec_perm): Use V8SImode + mode for mask of V8SFmode permutation. + + Backport from 4.8 branch + 2014-02-20 Jakub Jelinek <jakub@redhat.com> + + PR target/57896 + * config/i386/i386.c (expand_vec_perm_interleave2): Don't call + gen_reg_rtx if d->testing_p. + (expand_vec_perm_pshufb2, expand_vec_perm_even_odd_1, + expand_vec_perm_broadcast_1): Return early if d->testing_p and + we will certainly return true. + +2014-02-20 Terry Guo <terry.guo@arm.com> + + Backport from mainline + 2014-02-08 Terry Guo <terry.guo@arm.com> + + * doc/invoke.texi: Document ARM -march=armv7e-m. + +2014-02-19 H.J. Lu <hongjiu.lu@intel.com> + + Backport from mainline + 2014-02-19 H.J. Lu <hongjiu.lu@intel.com> + + PR target/60207 + * config/i386/i386.c (construct_container): Remove TFmode check + for X86_64_INTEGER_CLASS. + 2014-02-18 Kai Tietz <ktietz@redhat.com> Backport from mainline diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 410ddac79b2..e00a573aab2 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20140218 +20140612 diff --git a/gcc/DEV-PHASE b/gcc/DEV-PHASE index 373fbc60bb9..e69de29bb2d 100644 --- a/gcc/DEV-PHASE +++ b/gcc/DEV-PHASE @@ -1 +0,0 @@ -prerelease diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index e8b55eb77e3..27a1b1b4cca 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,31 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + +2014-03-30 Eric Botcazou <ebotcazou@adacore.com> + + PR ada/60703 + * system-linux-alpha.ads: Adjust for Ada 2005. + * system-linux-mips.ads: Likewise. + * system-linux-mips64el.ads: Likewise. + * system-linux-mipsel.ads: Likewise. + * system-linux-s390.ads: Likewise. + * system-linux-s390x.ads: Likewise. + * system-linux-sparc.ads: Likewise. + * system-linux-sparcv9.ads: Likewise. + * system-rtems.ads: Likewise. + * system-vxworks-arm.ads: Likewise. + +2014-03-13 Eric Botcazou <ebotcazou@adacore.com> + + PR ada/51483 + * back_end.ads (Register_Type_Proc): Add 'precision' parameter. + * cstand.adb (Register_Float_Type): Add 'precision' parameter and use + it to set the RM size. Use directly 'size' for the Esize. + * gcc-interface/gigi.h (enumerate_modes): Add integer parameter. + * gcc-interface/misc.c (enumerate_modes): Likewise. Do not register + types for vector modes, pass the size in addition to the precision. + 2014-01-12 Eric Botcazou <ebotcazou@adacore.com> PR ada/59772 diff --git a/gcc/ada/back_end.ads b/gcc/ada/back_end.ads index bfa2eb5b440..9d92ce39c5c 100644 --- a/gcc/ada/back_end.ads +++ b/gcc/ada/back_end.ads @@ -55,6 +55,7 @@ package Back_End is Complex : Boolean; -- True iff type has real and imaginary parts Count : Natural; -- Number of elements in vector, 0 otherwise Float_Rep : Float_Rep_Kind; -- Representation used for fpt type + Precision : Positive; -- Precision of representation in bits Size : Positive; -- Size of representation in bits Alignment : Natural); -- Required alignment in bits pragma Convention (C, Register_Type_Proc); diff --git a/gcc/ada/cstand.adb b/gcc/ada/cstand.adb index c77afd2dc3c..5ec425cca49 100644 --- a/gcc/ada/cstand.adb +++ b/gcc/ada/cstand.adb @@ -151,6 +151,7 @@ package body CStand is Complex : Boolean; -- True iff type has real and imaginary parts Count : Natural; -- Number of elements in vector, 0 otherwise Float_Rep : Float_Rep_Kind; -- Representation used for fpt type + Precision : Positive; -- Precision of representation in bits Size : Positive; -- Size of representation in bits Alignment : Natural); -- Required alignment in bits pragma Convention (C, Register_Float_Type); @@ -2015,6 +2016,7 @@ package body CStand is Complex : Boolean; Count : Natural; Float_Rep : Float_Rep_Kind; + Precision : Positive; Size : Positive; Alignment : Natural) is @@ -2064,13 +2066,24 @@ package body CStand is else Write_Str ("mod 2**"); - Write_Int (Int (Size / Positive'Max (1, Count))); + Write_Int (Int (Precision / Positive'Max (1, Count))); Write_Line (";"); end if; - Write_Str ("for " & T & "'Size use "); - Write_Int (Int (Size)); - Write_Line (";"); + if Precision = Size then + Write_Str ("for " & T (1 .. Last) & "'Size use "); + Write_Int (Int (Size)); + Write_Line (";"); + + else + Write_Str ("for " & T (1 .. Last) & "'Value_Size use "); + Write_Int (Int (Precision)); + Write_Line (";"); + + Write_Str ("for " & T (1 .. Last) & "'Object_Size use "); + Write_Int (Int (Size)); + Write_Line (";"); + end if; Write_Str ("for " & T & "'Alignment use "); Write_Int (Int (Alignment / 8)); @@ -2093,15 +2106,13 @@ package body CStand is if Digs > 0 and then not Complex and then Count = 0 then declare Ent : constant Entity_Id := New_Standard_Entity; - Esize : constant Pos := Pos ((Size + Alignment - 1) - / Alignment * Alignment); begin Set_Defining_Identifier (New_Node (N_Full_Type_Declaration, Stloc), Ent); Make_Name (Ent, T (1 .. Last)); Set_Scope (Ent, Standard_Standard); - Build_Float_Type (Ent, Esize, Float_Rep, Pos (Digs)); - Set_RM_Size (Ent, UI_From_Int (Int (Size))); + Build_Float_Type (Ent, Int (Size), Float_Rep, Pos (Digs)); + Set_RM_Size (Ent, UI_From_Int (Int (Precision))); Set_Alignment (Ent, UI_From_Int (Int (Alignment / 8))); if No (Back_End_Float_Types) then diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 5a766b4515d..9651aea1ff1 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -992,7 +992,7 @@ extern Nat get_target_double_scalar_alignment (void); /* This function is called by the front-end to enumerate all the supported modes for the machine, as well as some predefined C types. */ extern void enumerate_modes (void (*f) (const char *, int, int, int, int, int, - int)); + int, int)); #ifdef __cplusplus } diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 08ca5bb92b3..d6296b46b28 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -632,7 +632,7 @@ must_pass_by_ref (tree gnu_type) /* This function is called by the front-end to enumerate all the supported modes for the machine, as well as some predefined C types. F is a function which is called back with the parameters as listed below, first a string, - then six ints. The name is any arbitrary null-terminated string and has + then seven ints. The name is any arbitrary null-terminated string and has no particular significance, except for the case of predefined C types, where it should be the name of the C type. For integer types, only signed types should be listed, unsigned versions are assumed. The order of types should @@ -648,11 +648,12 @@ must_pass_by_ref (tree gnu_type) COMPLEX_P nonzero is this represents a complex mode COUNT count of number of items, nonzero for vector mode FLOAT_REP Float_Rep_Kind for FP, otherwise undefined - SIZE number of bits used to store data + PRECISION number of bits used to store data + SIZE number of bits occupied by the mode ALIGN number of bits to which mode is aligned. */ void -enumerate_modes (void (*f) (const char *, int, int, int, int, int, int)) +enumerate_modes (void (*f) (const char *, int, int, int, int, int, int, int)) { const tree c_types[] = { float_type_node, double_type_node, long_double_type_node }; @@ -726,28 +727,26 @@ enumerate_modes (void (*f) (const char *, int, int, int, int, int, int)) /* First register any C types for this mode that the front end may need to know about, unless the mode should be skipped. */ - - if (!skip_p) + if (!skip_p && !vector_p) for (nameloop = 0; nameloop < ARRAY_SIZE (c_types); nameloop++) { - tree typ = c_types[nameloop]; - const char *nam = c_names[nameloop]; + tree type = c_types[nameloop]; + const char *name = c_names[nameloop]; - if (TYPE_MODE (typ) == i) + if (TYPE_MODE (type) == i) { - f (nam, digs, complex_p, - vector_p ? GET_MODE_NUNITS (i) : 0, float_rep, - TYPE_PRECISION (typ), TYPE_ALIGN (typ)); + f (name, digs, complex_p, 0, float_rep, TYPE_PRECISION (type), + TREE_INT_CST_LOW (TYPE_SIZE (type)), TYPE_ALIGN (type)); skip_p = true; } } /* If no predefined C types were found, register the mode itself. */ - if (!skip_p) f (GET_MODE_NAME (i), digs, complex_p, vector_p ? GET_MODE_NUNITS (i) : 0, float_rep, - GET_MODE_PRECISION (i), GET_MODE_ALIGNMENT (i)); + GET_MODE_PRECISION (i), GET_MODE_BITSIZE (i), + GET_MODE_ALIGNMENT (i)); } } diff --git a/gcc/ada/system-linux-alpha.ads b/gcc/ada/system-linux-alpha.ads index 154c01bf6c5..f5aa9506ff9 100644 --- a/gcc/ada/system-linux-alpha.ads +++ b/gcc/ada/system-linux-alpha.ads @@ -35,9 +35,10 @@ ------------------------------------------------------------------------------ package System is -pragma Pure (System); --- Note that we take advantage of the implementation permission to --- make this unit Pure instead of Preelaborable, see RM 13.7(36) + pragma Pure; + -- Note that we take advantage of the implementation permission to make + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada + -- 2005, this is Pure in any case (AI-362). type Name is (SYSTEM_NAME_GNAT); System_Name : constant Name := SYSTEM_NAME_GNAT; @@ -61,6 +62,7 @@ pragma Pure (System); -- Storage-related Declarations type Address is private; + pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := 8; diff --git a/gcc/ada/system-linux-mips.ads b/gcc/ada/system-linux-mips.ads index 885995c076c..8f5713fed3a 100644 --- a/gcc/ada/system-linux-mips.ads +++ b/gcc/ada/system-linux-mips.ads @@ -62,6 +62,7 @@ package System is -- Storage-related Declarations type Address is private; + pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := 8; diff --git a/gcc/ada/system-linux-mips64el.ads b/gcc/ada/system-linux-mips64el.ads index de3215b3ec4..ad94841c980 100644 --- a/gcc/ada/system-linux-mips64el.ads +++ b/gcc/ada/system-linux-mips64el.ads @@ -62,6 +62,7 @@ package System is -- Storage-related Declarations type Address is private; + pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := 8; diff --git a/gcc/ada/system-linux-mipsel.ads b/gcc/ada/system-linux-mipsel.ads index a25642a153c..5c2e0a54835 100644 --- a/gcc/ada/system-linux-mipsel.ads +++ b/gcc/ada/system-linux-mipsel.ads @@ -62,6 +62,7 @@ package System is -- Storage-related Declarations type Address is private; + pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := 8; diff --git a/gcc/ada/system-linux-s390.ads b/gcc/ada/system-linux-s390.ads index 19ad00025ad..7864db845af 100644 --- a/gcc/ada/system-linux-s390.ads +++ b/gcc/ada/system-linux-s390.ads @@ -35,9 +35,10 @@ ------------------------------------------------------------------------------ package System is -pragma Pure (System); --- Note that we take advantage of the implementation permission to --- make this unit Pure instead of Preelaborable, see RM 13.7(36) + pragma Pure; + -- Note that we take advantage of the implementation permission to make + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada + -- 2005, this is Pure in any case (AI-362). type Name is (SYSTEM_NAME_GNAT); System_Name : constant Name := SYSTEM_NAME_GNAT; @@ -61,6 +62,7 @@ pragma Pure (System); -- Storage-related Declarations type Address is private; + pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := 8; diff --git a/gcc/ada/system-linux-s390x.ads b/gcc/ada/system-linux-s390x.ads index 6ed5749aafd..7a28cccf1c3 100644 --- a/gcc/ada/system-linux-s390x.ads +++ b/gcc/ada/system-linux-s390x.ads @@ -35,9 +35,10 @@ ------------------------------------------------------------------------------ package System is -pragma Pure (System); --- Note that we take advantage of the implementation permission to --- make this unit Pure instead of Preelaborable, see RM 13.7(36) + pragma Pure; + -- Note that we take advantage of the implementation permission to make + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada + -- 2005, this is Pure in any case (AI-362). type Name is (SYSTEM_NAME_GNAT); System_Name : constant Name := SYSTEM_NAME_GNAT; @@ -61,6 +62,7 @@ pragma Pure (System); -- Storage-related Declarations type Address is private; + pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := 8; diff --git a/gcc/ada/system-linux-sparc.ads b/gcc/ada/system-linux-sparc.ads index 1f4f2207d45..ab8591675a7 100644 --- a/gcc/ada/system-linux-sparc.ads +++ b/gcc/ada/system-linux-sparc.ads @@ -35,9 +35,10 @@ ------------------------------------------------------------------------------ package System is -pragma Pure (System); --- Note that we take advantage of the implementation permission to --- make this unit Pure instead of Preelaborable, see RM 13.7(36) + pragma Pure; + -- Note that we take advantage of the implementation permission to make + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada + -- 2005, this is Pure in any case (AI-362). type Name is (SYSTEM_NAME_GNAT); System_Name : constant Name := SYSTEM_NAME_GNAT; @@ -61,6 +62,7 @@ pragma Pure (System); -- Storage-related Declarations type Address is private; + pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := 8; diff --git a/gcc/ada/system-linux-sparcv9.ads b/gcc/ada/system-linux-sparcv9.ads index 14d89f929b2..5b7598f3e43 100644 --- a/gcc/ada/system-linux-sparcv9.ads +++ b/gcc/ada/system-linux-sparcv9.ads @@ -7,7 +7,7 @@ -- S p e c -- -- (GNU/Linux-SPARCV9 Version) -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- @@ -35,9 +35,10 @@ ------------------------------------------------------------------------------ package System is -pragma Pure (System); --- Note that we take advantage of the implementation permission to --- make this unit Pure instead of Preelaborable, see RM 13.7(36) + pragma Pure; + -- Note that we take advantage of the implementation permission to make + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada + -- 2005, this is Pure in any case (AI-362). type Name is (SYSTEM_NAME_GNAT); System_Name : constant Name := SYSTEM_NAME_GNAT; @@ -61,6 +62,7 @@ pragma Pure (System); -- Storage-related Declarations type Address is private; + pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := 8; diff --git a/gcc/ada/system-rtems.ads b/gcc/ada/system-rtems.ads index 3cab22abfe4..50bf7ac6402 100644 --- a/gcc/ada/system-rtems.ads +++ b/gcc/ada/system-rtems.ads @@ -7,7 +7,7 @@ -- S p e c -- -- (Compiler Version) -- -- -- --- Copyright (C) 1992-2011 Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2014 Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- @@ -34,9 +34,8 @@ -- -- ------------------------------------------------------------------------------ --- This version of System is a RTEMS version that is used in building --- the compiler. This is based as closely as possible on the generic --- version with the following exceptions: +-- This version is for RTEMS. It is based as closely as possible on the +-- generic version with the following exceptions: -- + priority definitions package System is @@ -67,6 +66,7 @@ package System is -- Storage-related Declarations type Address is private; + pragma Preelaborable_Initialization (Address); Null_Address : constant Address; Storage_Unit : constant := Standard'Storage_Unit; diff --git a/gcc/ada/system-vxworks-arm.ads b/gcc/ada/system-vxworks-arm.ads index 484d40d95c7..265066aab33 100644 --- a/gcc/ada/system-vxworks-arm.ads +++ b/gcc/ada/system-vxworks-arm.ads @@ -35,10 +35,10 @@ ------------------------------------------------------------------------------ package System is -pragma Pure (System); --- Note that we take advantage of the implementation permission to make this --- unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada 2005, this is --- Pure in any case (AI-362). + pragma Pure; + -- Note that we take advantage of the implementation permission to make + -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada + -- 2005, this is Pure in any case (AI-362). type Name is (SYSTEM_NAME_GNAT); System_Name : constant Name := SYSTEM_NAME_GNAT; diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c index a35b8e62942..2ab2a910b57 100644 --- a/gcc/bb-reorder.c +++ b/gcc/bb-reorder.c @@ -1478,9 +1478,8 @@ fix_up_fall_thru_edges (void) edge e; edge_iterator ei; - /* Find EDGE_CAN_FALLTHRU edge. */ FOR_EACH_EDGE (e, ei, cur_bb->succs) - if (e->flags & EDGE_CAN_FALLTHRU) + if (e->flags & EDGE_FALLTHRU) { fall_thru = e; break; diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f09b3a61f9d..14864444965 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,16 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + +2014-04-07 Dominique d'Humieres <dominiq@lps.ens.fr> + + Backport from mainline + 2013-09-14 Iain Sandoe <iains@gcc.gnu.org> + + PR target/48094 + * c.opt (fgnu-runtime, fnext-runtime, fobjc-abi-version, + fobjc-gc, freplace-objc-classes): Accept for LTO. + 2013-09-01 Iain Sandoe <iain@codesourcery.com> Backported from 4.8 diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 40ff96cc50f..8c65e33c217 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -814,7 +814,7 @@ C++ ObjC++ Var(flag_no_gnu_keywords, 0) Recognize GNU-defined keywords fgnu-runtime -ObjC ObjC++ Report RejectNegative Var(flag_next_runtime,0) Init(NEXT_OBJC_RUNTIME) +ObjC ObjC++ LTO Report RejectNegative Var(flag_next_runtime,0) Init(NEXT_OBJC_RUNTIME) Generate code for GNU runtime environment fgnu89-inline @@ -888,7 +888,7 @@ fnew-abi C++ ObjC++ Ignore Warn(switch %qs is no longer supported) fnext-runtime -ObjC ObjC++ Report RejectNegative Var(flag_next_runtime) +ObjC ObjC++ LTO Report RejectNegative Var(flag_next_runtime) Generate code for NeXT (Apple Mac OS X) runtime environment fnil-receivers @@ -906,7 +906,7 @@ C++ ObjC++ Optimization Var(flag_nothrow_opt) Treat a throw() exception specification as noexcept to improve code size fobjc-abi-version= -ObjC ObjC++ Joined Report RejectNegative UInteger Var(flag_objc_abi) +ObjC ObjC++ LTO Joined Report RejectNegative UInteger Var(flag_objc_abi) Specify which ABI to use for Objective-C family code and meta-data generation. ; Generate special '- .cxx_construct' and '- .cxx_destruct' methods @@ -926,7 +926,7 @@ ObjC ObjC++ Var(flag_objc_exceptions) Enable Objective-C exception and synchronization syntax fobjc-gc -ObjC ObjC++ Var(flag_objc_gc) +ObjC ObjC++ LTO Var(flag_objc_gc) Enable garbage collection (GC) in Objective-C/Objective-C++ programs fobjc-nilcheck @@ -986,7 +986,7 @@ C++ ObjC++ Var(flag_pretty_templates) Init(1) -fno-pretty-templates Do not pretty-print template specializations as the template signature followed by the arguments freplace-objc-classes -ObjC ObjC++ Var(flag_replace_objc_classes) +ObjC ObjC++ LTO Var(flag_replace_objc_classes) Used in Fix-and-Continue mode to indicate that object files may be swapped in at runtime frepo diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 6ff161425fe..fae3aa656e5 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -922,6 +922,24 @@ merge_memattrs (rtx x, rtx y) set_mem_align (y, MEM_ALIGN (x)); } } + if (code == MEM) + { + if (MEM_READONLY_P (x) != MEM_READONLY_P (y)) + { + MEM_READONLY_P (x) = 0; + MEM_READONLY_P (y) = 0; + } + if (MEM_NOTRAP_P (x) != MEM_NOTRAP_P (y)) + { + MEM_NOTRAP_P (x) = 0; + MEM_NOTRAP_P (y) = 0; + } + if (MEM_VOLATILE_P (x) != MEM_VOLATILE_P (y)) + { + MEM_VOLATILE_P (x) = 1; + MEM_VOLATILE_P (y) = 1; + } + } fmt = GET_RTX_FORMAT (code); for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index fbbf041a4fb..e8236d69f38 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -2051,14 +2051,9 @@ extern int making_const_table; } \ while (0) -/* Make sure subsequent insns are aligned after a TBB. */ -#define ASM_OUTPUT_CASE_END(FILE, NUM, JUMPTABLE) \ - do \ - { \ - if (GET_MODE (PATTERN (JUMPTABLE)) == QImode) \ - ASM_OUTPUT_ALIGN (FILE, 1); \ - } \ - while (0) +#define LABEL_ALIGN_AFTER_BARRIER(LABEL) \ + (GET_CODE (PATTERN (prev_active_insn (LABEL))) == ADDR_DIFF_VEC \ + ? 1 : 0) #define ARM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \ do \ diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index bb417486758..96cb78f9604 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -7569,12 +7569,13 @@ (define_insn "*arm_cmpdi_unsigned" [(set (reg:CC_CZ CC_REGNUM) - (compare:CC_CZ (match_operand:DI 0 "s_register_operand" "r") - (match_operand:DI 1 "arm_di_operand" "rDi")))] + (compare:CC_CZ (match_operand:DI 0 "s_register_operand" "r,r") + (match_operand:DI 1 "arm_di_operand" "rDi,rDi")))] "TARGET_32BIT" "cmp\\t%R0, %R1\;it eq\;cmpeq\\t%Q0, %Q1" [(set_attr "conds" "set") - (set_attr "length" "8")] + (set_attr "arch" "a,t2") + (set_attr "length" "8,10")] ) (define_insn "*arm_cmpdi_zero" diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 93a4cc2d755..100be1bf2a2 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -552,10 +552,14 @@ avr_set_current_function (tree decl) const char *name; name = DECL_ASSEMBLER_NAME_SET_P (decl) - /* Remove the leading '*' added in set_user_assembler_name. */ - ? 1 + IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)) + ? IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)) : IDENTIFIER_POINTER (DECL_NAME (decl)); - + + /* Skip a leading '*' that might still prefix the assembler name, + e.g. in non-LTO runs. */ + + name = default_strip_name_encoding (name); + /* Silently ignore 'signal' if 'interrupt' is present. AVR-LibC startet using this when it switched from SIGNAL and INTERRUPT to ISR. */ @@ -2171,6 +2175,12 @@ notice_update_cc (rtx body ATTRIBUTE_UNUSED, rtx insn) } break; + case CC_SET_VZN: + /* Insn like INC, DEC, NEG that set Z,N,V. We currently don't make use + of this combination, cf. also PR61055. */ + CC_STATUS_INIT; + break; + case CC_SET_CZN: /* Insn sets the Z,N,C flags of CC to recog_operand[0]. The V flag may or may not be known but that's ok because @@ -3633,7 +3643,7 @@ avr_out_store_psi (rtx insn, rtx *op, int *plen) "std Y+61,%A1" CR_TAB "std Y+62,%B1" CR_TAB "std Y+63,%C1" CR_TAB - "sbiw r28,%o0-60", op, plen, -5); + "sbiw r28,%o0-61", op, plen, -5); return avr_asm_len ("subi r28,lo8(-%o0)" CR_TAB "sbci r29,hi8(-%o0)" CR_TAB @@ -5945,7 +5955,7 @@ avr_out_plus_1 (rtx *xop, int *plen, enum rtx_code code, int *pcc) op, plen, 1); if (n_bytes == 2 && PLUS == code) - *pcc = CC_SET_ZN; + *pcc = CC_SET_CZN; } i++; @@ -5967,6 +5977,7 @@ avr_out_plus_1 (rtx *xop, int *plen, enum rtx_code code, int *pcc) { avr_asm_len ((code == PLUS) ^ (val8 == 1) ? "dec %0" : "inc %0", op, plen, 1); + *pcc = CC_CLOBBER; break; } diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md index 3fe06da661c..a95d8476dc8 100644 --- a/gcc/config/avr/avr.md +++ b/gcc/config/avr/avr.md @@ -90,7 +90,7 @@ (include "constraints.md") ;; Condition code settings. -(define_attr "cc" "none,set_czn,set_zn,set_n,compare,clobber, +(define_attr "cc" "none,set_czn,set_vzn,set_zn,set_n,compare,clobber, out_plus, out_plus_noclobber,ldi" (const_string "none")) @@ -1056,7 +1056,7 @@ inc %0\;inc %0 dec %0\;dec %0" [(set_attr "length" "1,1,1,1,2,2") - (set_attr "cc" "set_czn,set_czn,set_zn,set_zn,set_zn,set_zn")]) + (set_attr "cc" "set_czn,set_czn,set_vzn,set_vzn,set_vzn,set_vzn")]) (define_expand "addhi3" @@ -3876,7 +3876,7 @@ "" "neg %0" [(set_attr "length" "1") - (set_attr "cc" "set_zn")]) + (set_attr "cc" "set_vzn")]) (define_insn "*negqihi2" [(set (match_operand:HI 0 "register_operand" "=r") diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index aec3d13d6d9..bc41687855f 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -1322,6 +1322,9 @@ is_objc_metadata (tree decl) return NULL_TREE; } +static int classes_seen; +static int objc_metadata_seen; + /* Return the section required for Objective C ABI 2 metadata. */ static section * darwin_objc2_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base) @@ -1331,12 +1334,9 @@ darwin_objc2_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base) gcc_assert (TREE_CODE (ident) == IDENTIFIER_NODE); p = IDENTIFIER_POINTER (ident); - /* If we are in LTO, then we don't know the state of flag_next_runtime - or flag_objc_abi when the code was generated. We set these from the - meta-data - which is needed to deal with const string constructors. */ + gcc_checking_assert (flag_next_runtime == 1 && flag_objc_abi == 2); - flag_next_runtime = 1; - flag_objc_abi = 2; + objc_metadata_seen = 1; if (base == data_section) base = darwin_sections[objc2_metadata_section]; @@ -1359,7 +1359,10 @@ darwin_objc2_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base) else if (!strncmp (p, "V2_NLCL", 7)) return darwin_sections[objc2_nonlazy_class_section]; else if (!strncmp (p, "V2_CLAB", 7)) - return darwin_sections[objc2_classlist_section]; + { + classes_seen = 1; + return darwin_sections[objc2_classlist_section]; + } else if (!strncmp (p, "V2_SRFS", 7)) return darwin_sections[objc2_selector_refs_section]; else if (!strncmp (p, "V2_NLCA", 7)) @@ -1394,12 +1397,9 @@ darwin_objc1_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base) gcc_assert (TREE_CODE (ident) == IDENTIFIER_NODE); p = IDENTIFIER_POINTER (ident); - /* If we are in LTO, then we don't know the state of flag_next_runtime - or flag_objc_abi when the code was generated. We set these from the - meta-data - which is needed to deal with const string constructors. */ - flag_next_runtime = 1; - if (!global_options_set.x_flag_objc_abi) - flag_objc_abi = 1; + gcc_checking_assert (flag_next_runtime == 1 && flag_objc_abi < 2); + + objc_metadata_seen = 1; /* String sections first, cos there are lots of strings. */ if (!strncmp (p, "V1_STRG", 7)) @@ -1412,7 +1412,10 @@ darwin_objc1_section (tree decl ATTRIBUTE_UNUSED, tree meta, section * base) return darwin_sections[objc_meth_var_types_section]; else if (!strncmp (p, "V1_CLAS", 7)) - return darwin_sections[objc_class_section]; + { + classes_seen = 1; + return darwin_sections[objc_class_section]; + } else if (!strncmp (p, "V1_META", 7)) return darwin_sections[objc_meta_class_section]; else if (!strncmp (p, "V1_CATG", 7)) @@ -1596,8 +1599,6 @@ machopic_select_section (tree decl, if (TREE_CODE (name) == TYPE_DECL) name = DECL_NAME (name); - /* FIXME: This is unsatisfactory for LTO, since it relies on other - metadata determining the source FE. */ if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_ObjCString")) { if (flag_next_runtime) @@ -2788,6 +2789,33 @@ darwin_file_start (void) void darwin_file_end (void) { + + /* If we are expecting to output NeXT ObjC meta-data, (and we actually see + some) then we output the fix-and-continue marker (Image Info). + This applies to Objective C, Objective C++ and LTO with either language + as part of the input. */ + if (flag_next_runtime && objc_metadata_seen) + { + unsigned int flags = 0; + if (flag_objc_abi >= 2) + { + flags = 16; + output_section_asm_op + (darwin_sections[objc2_image_info_section]->unnamed.data); + } + else + output_section_asm_op + (darwin_sections[objc_image_info_section]->unnamed.data); + + ASM_OUTPUT_ALIGN (asm_out_file, 2); + fputs ("L_OBJC_ImageInfo:\n", asm_out_file); + + flags |= (flag_replace_objc_classes && classes_seen) ? 1 : 0; + flags |= flag_objc_gc ? 2 : 0; + + fprintf (asm_out_file, "\t.long\t0\n\t.long\t%u\n", flags); + } + machopic_finish (asm_out_file); if (strcmp (lang_hooks.name, "GNU C++") == 0) { diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 05633a6e5c4..596093499c3 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -6445,7 +6445,7 @@ construct_container (enum machine_mode mode, enum machine_mode orig_mode, return gen_rtx_REG (XFmode, FIRST_STACK_REG); if (n == 2 && regclass[0] == X86_64_INTEGER_CLASS && regclass[1] == X86_64_INTEGER_CLASS - && (mode == CDImode || mode == TImode || mode == TFmode) + && (mode == CDImode || mode == TImode) && intreg[0] + 1 == intreg[1]) return gen_rtx_REG (mode, intreg[0]); @@ -20201,7 +20201,7 @@ ix86_expand_vec_perm (rtx operands[]) return; case V8SFmode: - mask = gen_lowpart (V8SFmode, mask); + mask = gen_lowpart (V8SImode, mask); if (one_operand_shuffle) emit_insn (gen_avx2_permvarv8sf (target, op0, mask)); else @@ -29819,7 +29819,8 @@ rdrand_step: else op2 = gen_rtx_SUBREG (SImode, op0, 0); - if (target == 0) + if (target == 0 + || !register_operand (target, SImode)) target = gen_reg_rtx (SImode); pat = gen_rtx_GEU (VOIDmode, gen_rtx_REG (CCCmode, FLAGS_REG), @@ -32532,7 +32533,7 @@ x86_output_mi_thunk (FILE *file, { tmp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, fnaddr), UNSPEC_GOTPCREL); tmp = gen_rtx_CONST (Pmode, tmp); - fnaddr = gen_rtx_MEM (Pmode, tmp); + fnaddr = gen_const_mem (Pmode, tmp); } } else @@ -32552,8 +32553,9 @@ x86_output_mi_thunk (FILE *file, output_set_got (tmp, NULL_RTX); fnaddr = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, fnaddr), UNSPEC_GOT); - fnaddr = gen_rtx_PLUS (Pmode, fnaddr, tmp); - fnaddr = gen_rtx_MEM (Pmode, fnaddr); + fnaddr = gen_rtx_CONST (Pmode, fnaddr); + fnaddr = gen_rtx_PLUS (Pmode, tmp, fnaddr); + fnaddr = gen_const_mem (Pmode, fnaddr); } } @@ -36781,7 +36783,9 @@ expand_vec_perm_interleave2 (struct expand_vec_perm_d *d) else dfinal.perm[i] = e; } - dfinal.op0 = gen_reg_rtx (dfinal.vmode); + + if (!d->testing_p) + dfinal.op0 = gen_reg_rtx (dfinal.vmode); dfinal.op1 = dfinal.op0; dremap.target = dfinal.op0; @@ -36979,6 +36983,9 @@ expand_vec_perm_pshufb2 (struct expand_vec_perm_d *d) return false; gcc_assert (d->op0 != d->op1); + if (d->testing_p) + return true; + nelt = d->nelt; eltsz = GET_MODE_SIZE (GET_MODE_INNER (d->vmode)); @@ -37178,6 +37185,8 @@ expand_vec_perm_even_odd_1 (struct expand_vec_perm_d *d, unsigned odd) switch (d->vmode) { case V4DFmode: + if (d->testing_p) + break; t1 = gen_reg_rtx (V4DFmode); t2 = gen_reg_rtx (V4DFmode); @@ -37197,6 +37206,8 @@ expand_vec_perm_even_odd_1 (struct expand_vec_perm_d *d, unsigned odd) { int mask = odd ? 0xdd : 0x88; + if (d->testing_p) + break; t1 = gen_reg_rtx (V8SFmode); t2 = gen_reg_rtx (V8SFmode); t3 = gen_reg_rtx (V8SFmode); @@ -37238,6 +37249,8 @@ expand_vec_perm_even_odd_1 (struct expand_vec_perm_d *d, unsigned odd) return expand_vec_perm_pshufb2 (d); else { + if (d->testing_p) + break; /* We need 2*log2(N)-1 operations to achieve odd/even with interleave. */ t1 = gen_reg_rtx (V8HImode); @@ -37259,6 +37272,8 @@ expand_vec_perm_even_odd_1 (struct expand_vec_perm_d *d, unsigned odd) return expand_vec_perm_pshufb2 (d); else { + if (d->testing_p) + break; t1 = gen_reg_rtx (V16QImode); t2 = gen_reg_rtx (V16QImode); t3 = gen_reg_rtx (V16QImode); @@ -37291,6 +37306,9 @@ expand_vec_perm_even_odd_1 (struct expand_vec_perm_d *d, unsigned odd) return expand_vec_perm_even_odd_1 (&d_copy, odd); } + if (d->testing_p) + break; + t1 = gen_reg_rtx (V4DImode); t2 = gen_reg_rtx (V4DImode); @@ -37317,6 +37335,9 @@ expand_vec_perm_even_odd_1 (struct expand_vec_perm_d *d, unsigned odd) return expand_vec_perm_even_odd_1 (&d_copy, odd); } + if (d->testing_p) + break; + t1 = gen_reg_rtx (V8SImode); t2 = gen_reg_rtx (V8SImode); @@ -37409,6 +37430,8 @@ expand_vec_perm_broadcast_1 (struct expand_vec_perm_d *d) case V16QImode: /* These can be implemented via interleave. We save one insn by stopping once we have promoted to V4SImode and then use pshufd. */ + if (d->testing_p) + return true; do { rtx dest; diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index fe801360b12..dea98abf60c 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -7943,7 +7943,18 @@ (const_int 0))) (set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm") (and:DI (match_dup 1) (match_dup 2)))] - "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) + "TARGET_64BIT + && ix86_match_ccmode + (insn, + /* If we are going to emit andl instead of andq, and the operands[2] + constant might have the SImode sign bit set, make sure the sign + flag isn't tested, because the instruction will set the sign flag + based on bit 31 rather than bit 63. If it isn't CONST_INT, + conservatively assume it might have bit 31 set. */ + (satisfies_constraint_Z (operands[2]) + && (!CONST_INT_P (operands[2]) + || val_signbit_known_set_p (SImode, INTVAL (operands[2])))) + ? CCZmode : CCNOmode) && ix86_binary_operator_ok (AND, DImode, operands)" "@ and{l}\t{%k2, %k0|%k0, %k2} @@ -12103,8 +12114,8 @@ (define_insn "bmi_bextr_<mode>" [(set (match_operand:SWI48 0 "register_operand" "=r") - (unspec:SWI48 [(match_operand:SWI48 1 "register_operand" "r") - (match_operand:SWI48 2 "nonimmediate_operand" "rm")] + (unspec:SWI48 [(match_operand:SWI48 1 "nonimmediate_operand" "rm") + (match_operand:SWI48 2 "register_operand" "r")] UNSPEC_BEXTR)) (clobber (reg:CC FLAGS_REG))] "TARGET_BMI" @@ -12153,9 +12164,9 @@ ;; BMI2 instructions. (define_insn "bmi2_bzhi_<mode>3" [(set (match_operand:SWI48 0 "register_operand" "=r") - (and:SWI48 (match_operand:SWI48 1 "register_operand" "r") - (lshiftrt:SWI48 (const_int -1) - (match_operand:SWI48 2 "nonimmediate_operand" "rm")))) + (and:SWI48 (lshiftrt:SWI48 (const_int -1) + (match_operand:SWI48 2 "register_operand" "r")) + (match_operand:SWI48 1 "nonimmediate_operand" "rm"))) (clobber (reg:CC FLAGS_REG))] "TARGET_BMI2" "bzhi\t{%2, %1, %0|%0, %1, %2}" diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 3cafdb9f79b..3ffc6272d61 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -854,19 +854,28 @@ return false; /* VSIB addressing doesn't support (%rip). */ - if (parts.disp && GET_CODE (parts.disp) == CONST) + if (parts.disp) { - disp = XEXP (parts.disp, 0); - if (GET_CODE (disp) == PLUS) - disp = XEXP (disp, 0); - if (GET_CODE (disp) == UNSPEC) - switch (XINT (disp, 1)) - { - case UNSPEC_GOTPCREL: - case UNSPEC_PCREL: - case UNSPEC_GOTNTPOFF: - return false; - } + disp = parts.disp; + if (GET_CODE (disp) == CONST) + { + disp = XEXP (disp, 0); + if (GET_CODE (disp) == PLUS) + disp = XEXP (disp, 0); + if (GET_CODE (disp) == UNSPEC) + switch (XINT (disp, 1)) + { + case UNSPEC_GOTPCREL: + case UNSPEC_PCREL: + case UNSPEC_GOTNTPOFF: + return false; + } + } + if (TARGET_64BIT + && flag_pic + && (GET_CODE (disp) == SYMBOL_REF + || GET_CODE (disp) == LABEL_REF)) + return false; } return true; diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 9649cbc2468..18da1ec2443 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -2585,14 +2585,14 @@ pa_output_move_double (rtx *operands) if (optype0 == REGOP) latehalf[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1); else if (optype0 == OFFSOP) - latehalf[0] = adjust_address (operands[0], SImode, 4); + latehalf[0] = adjust_address_nv (operands[0], SImode, 4); else latehalf[0] = operands[0]; if (optype1 == REGOP) latehalf[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1); else if (optype1 == OFFSOP) - latehalf[1] = adjust_address (operands[1], SImode, 4); + latehalf[1] = adjust_address_nv (operands[1], SImode, 4); else if (optype1 == CNSTOP) split_double (operands[1], &operands[1], &latehalf[1]); else diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md index 8a1bab06f76..3663b3507a0 100644 --- a/gcc/config/sparc/sparc.md +++ b/gcc/config/sparc/sparc.md @@ -5607,19 +5607,6 @@ } [(set_attr "type" "shift")]) -(define_insn "*ashlsi3_extend" - [(set (match_operand:DI 0 "register_operand" "=r") - (zero_extend:DI - (ashift:SI (match_operand:SI 1 "register_operand" "r") - (match_operand:SI 2 "arith_operand" "rI"))))] - "TARGET_ARCH64" -{ - if (GET_CODE (operands[2]) == CONST_INT) - operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f); - return "sll\t%1, %2, %0"; -} - [(set_attr "type" "shift")]) - (define_expand "ashldi3" [(set (match_operand:DI 0 "register_operand" "=r") (ashift:DI (match_operand:DI 1 "register_operand" "r") diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d32d4c4f380..8cdcfb471dc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,59 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + +2014-05-30 Jason Merrill <jason@redhat.com> + + PR c++/56947 + * pt.c (instantiate_decl): Don't defer instantiation of a nested + function. + +2014-05-07 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2013-11-28 Jakub Jelinek <jakub@redhat.com> + + PR c++/59297 + * semantics.c (finish_omp_atomic): Call finish_expr_stmt + rather than add_stmt. + + 2013-09-09 Jakub Jelinek <jakub@redhat.com> + + PR c++/58325 + * init.c (build_vec_delete): Call mark_rvalue_use on base. + + 2013-05-31 Jason Merrill <jason@redhat.com> + + PR c++/56930 + * semantics.c (potential_constant_expression_1): Handle OMP_ATOMIC*. + +2014-02-26 Fabien Chêne <fabien@gcc.gnu.org> + + PR c++/37140 + * parser.c (cp_parser_nonclass_name): Call strip_using_decl and + move the code handling dependent USING_DECLs... + * name-lookup.c (strip_using_decl): ...Here. + +2014-02-21 Jason Merrill <jason@redhat.com> + + PR c++/60248 + * mangle.c (mangle_decl): Don't make an alias for a TYPE_DECL. + +2014-02-20 Kai Tietz <ktietz@redhat.com> + + PR c++/58873 + * parser.c (cp_parser_functional_cast): Treat NULL_TREE + valued type argument as error_mark_node. + + PR c++/58835 + * semantics.c (finish_fname): Handle error_mark_node. + +2014-02-19 Jason Merrill <jason@redhat.com> + + PR c++/60046 + * pt.c (maybe_instantiate_noexcept): Don't instantiate exception + spec from template context. + 2014-01-31 Jason Merrill <jason@redhat.com> PR c++/57043 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index bb0e618fbee..4e4b613dd52 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3915,6 +3915,7 @@ build_vec_delete (tree base, tree maxindex, tree cookie_addr; tree size_ptr_type = build_pointer_type (sizetype); + base = mark_rvalue_use (base); if (TREE_SIDE_EFFECTS (base)) { base_init = get_target_expr (base); diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 2d1cd95831c..4f20af65333 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3378,6 +3378,7 @@ mangle_decl (const tree decl) if (G.need_abi_warning /* Don't do this for a fake symbol we aren't going to emit anyway. */ + && TREE_CODE (decl) != TYPE_DECL && !DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl) && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)) { diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 565d3966ca5..952903a7cd3 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -399,7 +399,8 @@ pop_binding (tree id, tree decl) } } -/* Strip non dependent using declarations. */ +/* Strip non dependent using declarations. If DECL is dependent, + surreptitiously create a typename_type and return it. */ tree strip_using_decl (tree decl) @@ -409,6 +410,23 @@ strip_using_decl (tree decl) while (TREE_CODE (decl) == USING_DECL && !DECL_DEPENDENT_P (decl)) decl = USING_DECL_DECLS (decl); + + if (TREE_CODE (decl) == USING_DECL && DECL_DEPENDENT_P (decl) + && USING_DECL_TYPENAME_P (decl)) + { + /* We have found a type introduced by a using + declaration at class scope that refers to a dependent + type. + + using typename :: [opt] nested-name-specifier unqualified-id ; + */ + decl = make_typename_type (TREE_TYPE (decl), + DECL_NAME (decl), + typename_type, tf_error); + if (decl != error_mark_node) + decl = TYPE_NAME (decl); + } + return decl; } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c230d90c63d..120360a4d92 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13846,25 +13846,7 @@ cp_parser_nonclass_name (cp_parser* parser) /* Look up the type-name. */ type_decl = cp_parser_lookup_name_simple (parser, identifier, token->location); - if (TREE_CODE (type_decl) == USING_DECL) - { - if (!DECL_DEPENDENT_P (type_decl)) - type_decl = strip_using_decl (type_decl); - else if (USING_DECL_TYPENAME_P (type_decl)) - { - /* We have found a type introduced by a using - declaration at class scope that refers to a dependent - type. - - using typename :: [opt] nested-name-specifier unqualified-id ; - */ - type_decl = make_typename_type (TREE_TYPE (type_decl), - DECL_NAME (type_decl), - typename_type, tf_error); - if (type_decl != error_mark_node) - type_decl = TYPE_NAME (type_decl); - } - } + type_decl = strip_using_decl (type_decl); if (TREE_CODE (type_decl) != TYPE_DECL && (objc_is_id (identifier) || objc_is_class_name (identifier))) @@ -21419,6 +21401,9 @@ cp_parser_functional_cast (cp_parser* parser, tree type) tree cast; bool nonconst_p; + if (!type) + type = error_mark_node; + if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) { maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ed33198dda2..e1cc59d5e46 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18093,6 +18093,10 @@ maybe_instantiate_noexcept (tree fn) { tree fntype, spec, noex, clone; + /* Don't instantiate a noexcept-specification from template context. */ + if (processing_template_decl) + return; + if (DECL_CLONED_FUNCTION_P (fn)) fn = DECL_CLONED_FUNCTION (fn); fntype = TREE_TYPE (fn); @@ -18187,6 +18191,7 @@ instantiate_decl (tree d, int defer_ok, if the variable has a constant value the referring expression can take advantage of that fact. */ if (TREE_CODE (d) == VAR_DECL + || decl_function_context (d) || DECL_DECLARED_CONSTEXPR_P (d)) defer_ok = 0; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1d95e3e930b..e71f7d99f2f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2430,7 +2430,8 @@ finish_fname (tree id) tree decl; decl = fname_decl (input_location, C_RID_CODE (id), id); - if (processing_template_decl && current_function_decl) + if (processing_template_decl && current_function_decl + && decl != error_mark_node) decl = DECL_NAME (decl); return decl; } @@ -4976,7 +4977,7 @@ finish_omp_atomic (enum tree_code code, enum tree_code opcode, tree lhs, } stmt = build2 (OMP_ATOMIC, void_type_node, integer_zero_node, stmt); } - add_stmt (stmt); + finish_expr_stmt (stmt); } void @@ -8593,6 +8594,12 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) } return false; + case OMP_ATOMIC: + case OMP_ATOMIC_READ: + case OMP_ATOMIC_CAPTURE_OLD: + case OMP_ATOMIC_CAPTURE_NEW: + return false; + default: sorry ("unexpected AST of kind %s", tree_code_name[TREE_CODE (t)]); gcc_unreachable(); diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 0887946a193..724d4862753 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -375,6 +375,8 @@ goto *(&&foo + array[i]); This is more friendly to code living in shared libraries, as it reduces the number of dynamic relocations that are needed, and by consequence, allows the data to be read-only. +This alternative with label differences is not supported for the AVR target, +please use the first approach for AVR programs. The @code{&&foo} expressions for the same label might have different values if the containing function is inlined or cloned. If a program diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 75af2b058cb..13e4ba1b8e2 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -10658,7 +10658,7 @@ of the @option{-mcpu=} option. Permissible names are: @samp{armv2}, @samp{armv5}, @samp{armv5t}, @samp{armv5e}, @samp{armv5te}, @samp{armv6}, @samp{armv6j}, @samp{armv6t2}, @samp{armv6z}, @samp{armv6zk}, @samp{armv6-m}, -@samp{armv7}, @samp{armv7-a}, @samp{armv7-r}, @samp{armv7-m}, +@samp{armv7}, @samp{armv7-a}, @samp{armv7-r}, @samp{armv7-m}, @samp{armv7e-m}, @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}. @option{-march=native} causes the compiler to auto-detect the architecture @@ -18327,8 +18327,9 @@ These @samp{-m} options are supported on the SPARC: @opindex mno-app-regs @opindex mapp-regs Specify @option{-mapp-regs} to generate output using the global registers -2 through 4, which the SPARC SVR4 ABI reserves for applications. This -is the default. +2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the +global register 1, each global register 2 through 4 is then treated as an +allocable register that is clobbered by function calls. This is the default. To be fully SVR4 ABI compliant at the cost of some performance loss, specify @option{-mno-app-regs}. You should compile libraries and system diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 1f864a78ce9..c3c8f7e0ac3 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -486,11 +486,24 @@ negate_expr_p (tree t) and actually traps on some architectures. But if overflow is undefined, we can negate, because - (INT_MIN / 1) is an overflow. */ - if (INTEGRAL_TYPE_P (TREE_TYPE (t)) - && !TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (t))) - break; - return negate_expr_p (TREE_OPERAND (t, 1)) - || negate_expr_p (TREE_OPERAND (t, 0)); + if (INTEGRAL_TYPE_P (TREE_TYPE (t))) + { + if (!TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (t))) + break; + /* If overflow is undefined then we have to be careful because + we ask whether it's ok to associate the negate with the + division which is not ok for example for + -((a - b) / c) where (-(a - b)) / c may invoke undefined + overflow because of negating INT_MIN. So do not use + negate_expr_p here but open-code the two important cases. */ + if (TREE_CODE (TREE_OPERAND (t, 0)) == NEGATE_EXPR + || (TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST + && may_negate_without_overflow_p (TREE_OPERAND (t, 0)))) + return true; + } + else if (negate_expr_p (TREE_OPERAND (t, 0))) + return true; + return negate_expr_p (TREE_OPERAND (t, 1)); case NOP_EXPR: /* Negate -((double)float) as (double)(-float). */ @@ -670,16 +683,20 @@ fold_negate_expr (location_t loc, tree t) return fold_build2_loc (loc, TREE_CODE (t), type, TREE_OPERAND (t, 0), negate_expr (tem)); } + /* If overflow is undefined then we have to be careful because + we ask whether it's ok to associate the negate with the + division which is not ok for example for + -((a - b) / c) where (-(a - b)) / c may invoke undefined + overflow because of negating INT_MIN. So do not use + negate_expr_p here but open-code the two important cases. */ tem = TREE_OPERAND (t, 0); - if (negate_expr_p (tem)) - { - if (INTEGRAL_TYPE_P (type) - && (TREE_CODE (tem) != INTEGER_CST - || tree_int_cst_equal (tem, TYPE_MIN_VALUE (type)))) - fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_MISC); - return fold_build2_loc (loc, TREE_CODE (t), type, - negate_expr (tem), TREE_OPERAND (t, 1)); - } + if ((INTEGRAL_TYPE_P (type) + && (TREE_CODE (tem) == NEGATE_EXPR + || (TREE_CODE (tem) == INTEGER_CST + && may_negate_without_overflow_p (tem)))) + || !INTEGRAL_TYPE_P (type)) + return fold_build2_loc (loc, TREE_CODE (t), type, + negate_expr (tem), TREE_OPERAND (t, 1)); } break; @@ -4862,12 +4879,16 @@ fold_range_test (location_t loc, enum tree_code code, tree type, int in0_p, in1_p, in_p; tree low0, low1, low, high0, high1, high; bool strict_overflow_p = false; - tree lhs = make_range (op0, &in0_p, &low0, &high0, &strict_overflow_p); - tree rhs = make_range (op1, &in1_p, &low1, &high1, &strict_overflow_p); - tree tem; + tree tem, lhs, rhs; const char * const warnmsg = G_("assuming signed overflow does not occur " "when simplifying range test"); + if (!INTEGRAL_TYPE_P (type)) + return 0; + + lhs = make_range (op0, &in0_p, &low0, &high0, &strict_overflow_p); + rhs = make_range (op1, &in1_p, &low1, &high1, &strict_overflow_p); + /* If this is an OR operation, invert both sides; we will invert again at the end. */ if (or_op) @@ -13832,14 +13853,29 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type, && integer_zerop (op2) && (tem = sign_bit_p (TREE_OPERAND (arg0, 0), arg1))) { + /* sign_bit_p looks through both zero and sign extensions, + but for this optimization only sign extensions are + usable. */ + tree tem2 = TREE_OPERAND (arg0, 0); + while (tem != tem2) + { + if (TREE_CODE (tem2) != NOP_EXPR + || TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (tem2, 0)))) + { + tem = NULL_TREE; + break; + } + tem2 = TREE_OPERAND (tem2, 0); + } /* sign_bit_p only checks ARG1 bits within A's precision. If <sign bit of A> has wider type than A, bits outside of A's precision in <sign bit of A> need to be checked. If they are all 0, this optimization needs to be done in unsigned A's type, if they are all 1 in signed A's type, otherwise this can't be done. */ - if (TYPE_PRECISION (TREE_TYPE (tem)) - < TYPE_PRECISION (TREE_TYPE (arg1)) + if (tem + && TYPE_PRECISION (TREE_TYPE (tem)) + < TYPE_PRECISION (TREE_TYPE (arg1)) && TYPE_PRECISION (TREE_TYPE (tem)) < TYPE_PRECISION (type)) { diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 46bb56c3929..c08002a21dd 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,99 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + +2014-05-26 Janne Blomqvist <jb@gcc.gnu.org> + + Backport from mainline + PR libfortran/61310 + * intrinsics.texi (CTIME): Remove mention of locale-dependent + behavior. + +2014-05-24 Dominique d'Humieres <dominiq@lps.ens.fr> + + Backport r195492 and r195815 + 2013-01-27 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/55789 + PR fortran/56047 + * gfortran.h : Add associate_var to symbol_attr. + * resolve.c (resolve_assoc_var): Set associate_var attribute. + If the target class_ok is set, set it for the associate + variable. + * check.c (allocatable_check): Associate variables should not + have the allocatable attribute even if their symbols do. + * class.c (gfc_build_class_symbol): Symbols with associate_var + set will always have a good class container. + + 2013-02-06 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/55789 + * trans-array.c (trans_array_constructor): Remove condition + 'dynamic' = true if the loop ubound is a VAR_DECL. + +2014-03-29 Mikael Morin <mikael@gcc.gnu.org> + + PR fortran/60677 + * trans-intrinsic.c (gfc_conv_intrinsic_ichar): Enlarge argument + list buffer. + +2014-03-29 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/60522 + * frontend-passes.c (cfe_code): Do not walk subtrees + for WHERE. + +2014-03-20 Tobias Burnus <burnus@net-b.de> + + PR fortran/60543 + PR fortran/60283 + * gfortran.h (gfc_unset_implicit_pure): New prototype. + * resolve.c (gfc_unset_implicit_pure): New. + (resolve_structure_cons, resolve_function, + pure_subroutine, resolve_ordinary_assign): Use it. + * decl.c (match_old_style_init, gfc_match_data, + match_pointer_init, variable_decl): Ditto. + * expr.c (gfc_check_pointer_assign): Ditto. + * intrinsic.c (gfc_intrinsic_sub_interface): Ditto. + * io.c (match_vtag, gfc_match_open, gfc_match_close, + match_filepos, gfc_match_inquire, gfc_match_print, + gfc_match_wait, check_io_constraints): Ditto. + * match.c (gfc_match_critical, gfc_match_stopcode, + lock_unlock_statement, sync_statement, gfc_match_allocate, + gfc_match_deallocate): Ditto. + * parse.c (decode_omp_directive): Ditto. + * symbol.c (gfc_add_save): Ditto. + +2014-03-09 Janus Weil <janus@gcc.gnu.org> + + Backport from 4.8 + 2014-03-08 Janus Weil <janus@gcc.gnu.org> + + PR fortran/60450 + * simplify.c (gfc_simplify_shape): Only clear shape if it was really + created successfully. + +2014-03-02 Mikael Morin <mikael@gcc.gnu.org> + + PR fortran/60341 + * frontend-passes.c (optimize_comparison): Guard two union accesses + with the corresponding tag checks. + +2014-02-22 Mikael Morin <mikael@gcc.gnu.org> + + PR fortran/59599 + * trans-intrinsic.c (gfc_conv_intrinsic_ichar): Calculate the + number of arguments. + +2014-02-20 Janus Weil <janus@gcc.gnu.org> + + Backport from mainline + 2014-02-17 Janus Weil <janus@gcc.gnu.org> + + PR fortran/55907 + * resolve.c (build_default_init_expr): Don't initialize character + variable if -fno-automatic is given. + 2014-02-08 Mikael Morin <mikael@gcc.gnu.org> PR fortran/57033 diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index f6195aa8b3a..e5fd0374829 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -454,7 +454,7 @@ allocatable_check (gfc_expr *e, int n) symbol_attribute attr; attr = gfc_variable_attr (e, NULL); - if (!attr.allocatable) + if (!attr.allocatable || attr.associate_var) { gfc_error ("'%s' argument of '%s' intrinsic at %L must be ALLOCATABLE", gfc_current_intrinsic_arg[n]->name, gfc_current_intrinsic, diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index d4ed6b043ac..55278cae075 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -493,7 +493,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr, return SUCCESS; attr->class_ok = attr->dummy || attr->pointer || attr->allocatable - || attr->select_type_temporary; + || attr->select_type_temporary || attr->associate_var; if (!attr->class_ok) /* We can not build the class container yet. */ diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 3e7c6e618aa..e86f107d969 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -509,9 +509,7 @@ match_old_style_init (const char *name) free (newdata); return MATCH_ERROR; } - - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (gfc_current_ns->proc_name); /* Mark the variable as having appeared in a data statement. */ if (gfc_add_data (&sym->attr, sym->name, &sym->declared_at) == FAILURE) @@ -570,9 +568,7 @@ gfc_match_data (void) gfc_error ("DATA statement at %C is not allowed in a PURE procedure"); return MATCH_ERROR; } - - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (gfc_current_ns->proc_name); return MATCH_YES; @@ -1730,6 +1726,7 @@ match_pointer_init (gfc_expr **init, int procptr) gfc_error ("Error in pointer initialization at %C"); return MATCH_ERROR; } + gfc_unset_implicit_pure (gfc_current_ns->proc_name); if (!procptr) gfc_resolve_expr (*init); @@ -2015,6 +2012,10 @@ variable_decl (int elem) m = MATCH_ERROR; } + if (current_attr.flavor != FL_PARAMETER + && gfc_state_stack->state != COMP_DERIVED) + gfc_unset_implicit_pure (gfc_current_ns->proc_name); + if (m != MATCH_YES) goto cleanup; } diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 59e06410fe1..05ecd20a874 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -442,12 +442,35 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees, to insert statements as needed. */ static int -cfe_code (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED, - void *data ATTRIBUTE_UNUSED) +cfe_code (gfc_code **c, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) { current_code = c; inserted_block = NULL; changed_statement = NULL; + + /* Do not do anything inside a WHERE statement; scalar assignments, BLOCKs + and allocation on assigment are prohibited inside WHERE, and finally + masking an expression would lead to wrong-code when replacing + + WHERE (a>0) + b = sum(foo(a) + foo(a)) + END WHERE + + with + + WHERE (a > 0) + tmp = foo(a) + b = sum(tmp + tmp) + END WHERE +*/ + + if ((*c)->op == EXEC_WHERE) + { + *walk_subtrees = 0; + return 0; + } + + return 0; } @@ -883,7 +906,9 @@ optimize_comparison (gfc_expr *e, gfc_intrinsic_op op) /* Replace A // B < A // C with B < C, and A // B < C // B with A < C. */ if (op1->ts.type == BT_CHARACTER && op2->ts.type == BT_CHARACTER + && op1->expr_type == EXPR_OP && op1->value.op.op == INTRINSIC_CONCAT + && op2->expr_type == EXPR_OP && op2->value.op.op == INTRINSIC_CONCAT) { gfc_expr *op1_left = op1->value.op.op1; diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 6e1fc780d66..7db6dc55055 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -786,8 +786,9 @@ typedef struct unsigned alloc_comp:1, pointer_comp:1, proc_pointer_comp:1, private_comp:1, zero_comp:1, coarray_comp:1, lock_comp:1; - /* This is a temporary selector for SELECT TYPE. */ - unsigned select_type_temporary:1; + /* This is a temporary selector for SELECT TYPE or an associate + variable for SELECT_TYPE or ASSOCIATE. */ + unsigned select_type_temporary:1, associate_var:1; /* Attributes set by compiler extensions (!GCC$ ATTRIBUTES). */ unsigned ext_attr:EXT_ATTR_NUM; @@ -2795,6 +2796,7 @@ void gfc_resolve_blocks (gfc_code *, gfc_namespace *); int gfc_impure_variable (gfc_symbol *); int gfc_pure (gfc_symbol *); int gfc_implicit_pure (gfc_symbol *); +void gfc_unset_implicit_pure (gfc_symbol *); int gfc_elemental (gfc_symbol *); gfc_try gfc_resolve_iterator (gfc_iterator *, bool); gfc_try find_forall_index (gfc_expr *, gfc_symbol *, int); diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index 38bcb273fdd..a2666f90e65 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -4217,13 +4217,16 @@ gfc_intrinsic_sub_interface (gfc_code *c, int error_flag) c->resolved_sym->attr.elemental = isym->elemental; } - if (gfc_pure (NULL) && !isym->pure) + if (!isym->pure && gfc_pure (NULL)) { gfc_error ("Subroutine call to intrinsic '%s' at %L is not PURE", name, &c->loc); return MATCH_ERROR; } + if (!isym->pure) + gfc_unset_implicit_pure (NULL); + c->resolved_sym->attr.noreturn = isym->noreturn; return MATCH_YES; diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index d0a29cc25ea..327bce74305 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -3314,10 +3314,8 @@ end program test_cshift @table @asis @item @emph{Description}: @code{CTIME} converts a system time value, such as returned by -@code{TIME8}, to a string. Unless the application has called -@code{setlocale}, the output will be in the default locale, of length -24 and of the form @samp{Sat Aug 19 18:13:14 1995}. In other locales, -a longer string may result. +@code{TIME8}, to a string. The output will be of the form @samp{Sat +Aug 19 18:13:14 1995}. This intrinsic is provided in both subroutine and function forms; however, only one form can be used in any given program unit. diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c index 7caadc5056c..86f158fdbc9 100644 --- a/gcc/fortran/io.c +++ b/gcc/fortran/io.c @@ -1307,7 +1307,8 @@ match_vtag (const io_tag *tag, gfc_expr **v) return MATCH_ERROR; } - if (gfc_pure (NULL) && gfc_impure_variable (result->symtree->n.sym)) + bool impure = gfc_impure_variable (result->symtree->n.sym); + if (impure && gfc_pure (NULL)) { gfc_error ("Variable %s cannot be assigned in PURE procedure at %C", tag->name); @@ -1315,8 +1316,8 @@ match_vtag (const io_tag *tag, gfc_expr **v) return MATCH_ERROR; } - if (gfc_implicit_pure (NULL) && gfc_impure_variable (result->symtree->n.sym)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + if (impure) + gfc_unset_implicit_pure (NULL); *v = result; return MATCH_YES; @@ -1836,8 +1837,7 @@ gfc_match_open (void) goto cleanup; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); warn = (open->err || open->iostat) ? true : false; @@ -2249,8 +2249,7 @@ gfc_match_close (void) goto cleanup; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); warn = (close->iostat || close->err) ? true : false; @@ -2417,8 +2416,7 @@ done: goto cleanup; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); new_st.op = op; new_st.ext.filepos = fp; @@ -3274,9 +3272,8 @@ if (condition) \ "an internal file in a PURE procedure", io_kind_name (k)); - if (gfc_implicit_pure (NULL) && (k == M_READ || k == M_WRITE)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; - + if (k == M_READ || k == M_WRITE) + gfc_unset_implicit_pure (NULL); } if (k != M_READ) @@ -3807,8 +3804,7 @@ gfc_match_print (void) return MATCH_ERROR; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); return MATCH_YES; } @@ -3966,8 +3962,7 @@ gfc_match_inquire (void) return MATCH_ERROR; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); new_st.block = gfc_get_code (); new_st.block->op = EXEC_IOLENGTH; @@ -4020,8 +4015,7 @@ gfc_match_inquire (void) goto cleanup; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); if (inquire->id != NULL && inquire->pending == NULL) { @@ -4206,8 +4200,7 @@ gfc_match_wait (void) goto cleanup; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); new_st.op = EXEC_WAIT; new_st.ext.wait = wait; diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index cb750cf67d2..194fafcb6d3 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -1754,8 +1754,7 @@ gfc_match_critical (void) return MATCH_ERROR; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); if (gfc_notify_std (GFC_STD_F2008, "Fortran 2008: CRITICAL statement at %C") == FAILURE) @@ -2684,8 +2683,7 @@ gfc_match_stopcode (gfc_statement st) goto cleanup; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); if (st == ST_STOP && gfc_find_state (COMP_CRITICAL) == SUCCESS) { @@ -2825,8 +2823,7 @@ lock_unlock_statement (gfc_statement st) return MATCH_ERROR; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); if (gfc_option.coarray == GFC_FCOARRAY_NONE) { @@ -3017,8 +3014,7 @@ sync_statement (gfc_statement st) return MATCH_ERROR; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); if (gfc_notify_std (GFC_STD_F2008, "Fortran 2008: SYNC statement at %C") == FAILURE) @@ -3493,15 +3489,15 @@ gfc_match_allocate (void) if (gfc_check_do_variable (tail->expr->symtree)) goto cleanup; - if (gfc_pure (NULL) && gfc_impure_variable (tail->expr->symtree->n.sym)) + bool impure = gfc_impure_variable (tail->expr->symtree->n.sym); + if (impure && gfc_pure (NULL)) { gfc_error ("Bad allocate-object at %C for a PURE procedure"); goto cleanup; } - if (gfc_implicit_pure (NULL) - && gfc_impure_variable (tail->expr->symtree->n.sym)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + if (impure) + gfc_unset_implicit_pure (NULL); if (tail->expr->ts.deferred) { @@ -3868,14 +3864,15 @@ gfc_match_deallocate (void) sym = tail->expr->symtree->n.sym; - if (gfc_pure (NULL) && gfc_impure_variable (sym)) + bool impure = gfc_impure_variable (sym); + if (impure && gfc_pure (NULL)) { gfc_error ("Illegal allocate-object at %C for a PURE procedure"); goto cleanup; } - if (gfc_implicit_pure (NULL) && gfc_impure_variable (sym)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + if (impure) + gfc_unset_implicit_pure (NULL); if (gfc_is_coarray (tail->expr) && gfc_find_state (COMP_DO_CONCURRENT) == SUCCESS) diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 5fbddd0e4b6..7132a937cb3 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -545,8 +545,7 @@ decode_omp_directive (void) return ST_NONE; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); old_locus = gfc_current_locus; diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 8e00739604d..7cd2a4069c0 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -1193,9 +1193,10 @@ resolve_structure_cons (gfc_expr *expr, int init) } /* F2003, C1272 (3). */ - if (gfc_pure (NULL) && cons->expr->expr_type == EXPR_VARIABLE - && (gfc_impure_variable (cons->expr->symtree->n.sym) - || gfc_is_coindexed (cons->expr))) + bool impure = cons->expr->expr_type == EXPR_VARIABLE + && (gfc_impure_variable (cons->expr->symtree->n.sym) + || gfc_is_coindexed (cons->expr)); + if (impure && gfc_pure (NULL)) { t = FAILURE; gfc_error ("Invalid expression in the structure constructor for " @@ -1203,12 +1204,8 @@ resolve_structure_cons (gfc_expr *expr, int init) comp->name, &cons->expr->where); } - if (gfc_implicit_pure (NULL) - && cons->expr->expr_type == EXPR_VARIABLE - && (gfc_impure_variable (cons->expr->symtree->n.sym) - || gfc_is_coindexed (cons->expr))) - gfc_current_ns->proc_name->attr.implicit_pure = 0; - + if (impure) + gfc_unset_implicit_pure (NULL); } return t; @@ -3203,8 +3200,7 @@ resolve_function (gfc_expr *expr) t = FAILURE; } - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); } /* Functions without the RECURSIVE attribution are not allowed to @@ -3269,8 +3265,7 @@ pure_subroutine (gfc_code *c, gfc_symbol *sym) gfc_error ("Subroutine call to '%s' at %L is not PURE", sym->name, &c->loc); - if (gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); } @@ -7996,6 +7991,13 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target) has no corank. */ sym->as->corank = 0; } + + /* Mark this as an associate variable. */ + sym->attr.associate_var = 1; + + /* If the target is a good class object, so is the associate variable. */ + if (sym->ts.type == BT_CLASS && gfc_expr_attr (target).class_ok) + sym->attr.class_ok = 1; } @@ -9224,7 +9226,7 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace *ns) if (lhs->expr_type == EXPR_VARIABLE && lhs->symtree->n.sym != gfc_current_ns->proc_name && lhs->symtree->n.sym->ns != gfc_current_ns) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); if (lhs->ts.type == BT_DERIVED && lhs->expr_type == EXPR_VARIABLE @@ -9232,11 +9234,11 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace *ns) && rhs->expr_type == EXPR_VARIABLE && (gfc_impure_variable (rhs->symtree->n.sym) || gfc_is_coindexed (rhs))) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); /* Fortran 2008, C1283. */ if (gfc_is_coindexed (lhs)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + gfc_unset_implicit_pure (NULL); } /* F03:7.4.1.2. */ @@ -10167,7 +10169,7 @@ build_default_init_expr (gfc_symbol *sym) init_expr = NULL; } if (!init_expr && gfc_option.flag_init_character == GFC_INIT_CHARACTER_ON - && sym->ts.u.cl->length) + && sym->ts.u.cl->length && gfc_option.flag_max_stack_var_size != 0) { gfc_actual_arglist *arg; init_expr = gfc_get_expr (); @@ -13288,6 +13290,33 @@ gfc_implicit_pure (gfc_symbol *sym) } +void +gfc_unset_implicit_pure (gfc_symbol *sym) +{ + gfc_namespace *ns; + + if (sym == NULL) + { + /* Check if the current procedure is implicit_pure. Walk up + the procedure list until we find a procedure. */ + for (ns = gfc_current_ns; ns; ns = ns->parent) + { + sym = ns->proc_name; + if (sym == NULL) + return; + + if (sym->attr.flavor == FL_PROCEDURE) + break; + } + } + + if (sym->attr.flavor == FL_PROCEDURE) + sym->attr.implicit_pure = 0; + else + sym->attr.pure = 0; +} + + /* Test whether the current procedure is elemental or not. */ int diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 515528d489b..c9fd122f6e3 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -5518,7 +5518,7 @@ gfc_simplify_shape (gfc_expr *source, gfc_expr *kind) if (e == &gfc_bad_expr || range_check (e, "SHAPE") == &gfc_bad_expr) { gfc_free_expr (result); - if (t) + if (t == SUCCESS) gfc_clear_shape (shape, source->rank); return &gfc_bad_expr; } @@ -5526,7 +5526,7 @@ gfc_simplify_shape (gfc_expr *source, gfc_expr *kind) gfc_constructor_append_expr (&result->value.constructor, e, NULL); } - if (t) + if (t == SUCCESS) gfc_clear_shape (shape, source->rank); return result; diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index dcf40d9a47f..52dfb166e48 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -1121,8 +1121,8 @@ gfc_add_save (symbol_attribute *attr, save_state s, const char *name, return FAILURE; } - if (s == SAVE_EXPLICIT && gfc_implicit_pure (NULL)) - gfc_current_ns->proc_name->attr.implicit_pure = 0; + if (s == SAVE_EXPLICIT) + gfc_unset_implicit_pure (NULL); if (s == SAVE_EXPLICIT && attr->save == SAVE_EXPLICIT) { diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 25340f58eea..b9574627f1d 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -2282,9 +2282,6 @@ trans_array_constructor (gfc_ss * ss, locus * where) } } - if (TREE_CODE (*loop_ubound0) == VAR_DECL) - dynamic = true; - gfc_trans_create_temp_array (&outer_loop->pre, &outer_loop->post, ss, type, NULL_TREE, dynamic, true, false, where); diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index f7afb786966..b8752995fca 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -4664,9 +4664,11 @@ gfc_conv_intrinsic_index_scan_verify (gfc_se * se, gfc_expr * expr, static void gfc_conv_intrinsic_ichar (gfc_se * se, gfc_expr * expr) { - tree args[2], type, pchartype; + tree args[3], type, pchartype; + int nargs; - gfc_conv_intrinsic_function_args (se, expr, args, 2); + nargs = gfc_intrinsic_argument_list_length (expr); + gfc_conv_intrinsic_function_args (se, expr, args, nargs); gcc_assert (POINTER_TYPE_P (TREE_TYPE (args[1]))); pchartype = gfc_get_pchar_type (expr->value.function.actual->expr->ts.kind); args[1] = fold_build1_loc (input_location, NOP_EXPR, pchartype, args[1]); diff --git a/gcc/gimple.h b/gcc/gimple.h index 97eec59fcb0..4a168207144 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -305,6 +305,9 @@ struct GTY(()) gimple_statement_base { /* Nonzero if this statement contains volatile operands. */ unsigned has_volatile_ops : 1; + /* Padding to get subcode to 16 bit alignment. */ + unsigned pad : 1; + /* The SUBCODE field can be used for tuple-specific flags for tuples that do not require subcodes. Note that SUBCODE should be at least as wide as tree codes, as several tuples store tree codes diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 531565e6499..abb580f8958 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1922,6 +1922,9 @@ gimplify_conversion (tree *expr_p) /* Nonlocal VLAs seen in the current function. */ static struct pointer_set_t *nonlocal_vlas; +/* The VAR_DECLs created for nonlocal VLAs for debug info purposes. */ +static tree nonlocal_vla_vars; + /* Gimplify a VAR_DECL or PARM_DECL. Return GS_OK if we expanded a DECL_VALUE_EXPR, and it's worth re-examining things. */ @@ -1968,14 +1971,13 @@ gimplify_var_or_parm_decl (tree *expr_p) ctx = ctx->outer_context; if (!ctx && !pointer_set_insert (nonlocal_vlas, decl)) { - tree copy = copy_node (decl), block; + tree copy = copy_node (decl); lang_hooks.dup_lang_specific_decl (copy); SET_DECL_RTL (copy, 0); TREE_USED (copy) = 1; - block = DECL_INITIAL (current_function_decl); - DECL_CHAIN (copy) = BLOCK_VARS (block); - BLOCK_VARS (block) = copy; + DECL_CHAIN (copy) = nonlocal_vla_vars; + nonlocal_vla_vars = copy; SET_DECL_VALUE_EXPR (copy, unshare_expr (value_expr)); DECL_HAS_VALUE_EXPR_P (copy) = 1; } @@ -8057,6 +8059,21 @@ gimplify_body (tree fndecl, bool do_parms) if (nonlocal_vlas) { + if (nonlocal_vla_vars) + { + /* tree-nested.c may later on call declare_vars (..., true); + which relies on BLOCK_VARS chain to be the tail of the + gimple_bind_vars chain. Ensure we don't violate that + assumption. */ + if (gimple_bind_block (outer_bind) + == DECL_INITIAL (current_function_decl)) + declare_vars (nonlocal_vla_vars, outer_bind, true); + else + BLOCK_VARS (DECL_INITIAL (current_function_decl)) + = chainon (BLOCK_VARS (DECL_INITIAL (current_function_decl)), + nonlocal_vla_vars); + nonlocal_vla_vars = NULL_TREE; + } pointer_set_destroy (nonlocal_vlas); nonlocal_vlas = NULL; } diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 149db5a258c..e1a9ba904e5 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,7 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + 2013-04-11 Release Manager * GCC 4.7.3 released. diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 454283aabb2..ddf6605b2d7 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1063,21 +1063,21 @@ propagate_constants_accross_call (struct cgraph_edge *cs) args_count = ipa_get_cs_argument_count (args); parms_count = ipa_get_param_count (callee_info); - /* If this call goes through a thunk we must not propagate to the first (0th) - parameter. However, we might need to uncover a thunk from below a series - of aliases first. */ + /* If this call goes through a thunk we should not propagate because we + cannot redirect edges to thunks. However, we might need to uncover a + thunk from below a series of aliases first. */ alias_or_thunk = cs->callee; while (alias_or_thunk->alias) alias_or_thunk = cgraph_alias_aliased_node (alias_or_thunk); if (alias_or_thunk->thunk.thunk_p) { - ret |= set_lattice_contains_variable (ipa_get_lattice (callee_info, 0)); - i = 1; + for (i = 0; i < parms_count; i++) + ret |= set_lattice_contains_variable (ipa_get_lattice (callee_info, i)); + + return ret; } - else - i = 0; - for (; (i < args_count) && (i < parms_count); i++) + for (i = 0; (i < args_count) && (i < parms_count); i++) { struct ipa_jump_func *jump_func = ipa_get_ith_jump_func (args, i); struct ipcp_lattice *dest_lat = ipa_get_lattice (callee_info, i); diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 1d40c988037..8fee34ea849 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,7 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + 2013-04-11 Release Manager * GCC 4.7.3 released. diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index fae2d0afff7..607a32490b3 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,7 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + 2013-04-11 Release Manager * GCC 4.7.3 released. diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index a2b987bc941..76cb030b9b4 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,18 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + +2014-04-07 Dominique d'Humieres <dominiq@lps.ens.fr> + + Backport from mainline + 2013-09-14 Iain Sandoe <iains@gcc.gnu.org> + + PR target/48094 + * objc-next-runtime-abi-01.c (generate_objc_image_info): Remove. + (objc_generate_v1_next_metadata): Remove generation of ImageInfo. + * objc-next-runtime-abi-02.c (generate_v2_objc_image_info): Remove. + (objc_generate_v2_next_metadata): Remove generation of ImageInfo. + 2013-09-01 Iain Sandoe <iain@codesourcery.com> Backported from 4.8 diff --git a/gcc/objc/objc-next-runtime-abi-01.c b/gcc/objc/objc-next-runtime-abi-01.c index 92bf6135e2b..699ed8ee827 100644 --- a/gcc/objc/objc-next-runtime-abi-01.c +++ b/gcc/objc/objc-next-runtime-abi-01.c @@ -2333,35 +2333,6 @@ generate_classref_translation_entry (tree chain) } -/* The Fix-and-Continue functionality available in Mac OS X 10.3 and - later requires that ObjC translation units participating in F&C be - specially marked. The following routine accomplishes this. */ - -/* static int _OBJC_IMAGE_INFO[2] = { 0, 1 }; */ - -static void -generate_objc_image_info (void) -{ - tree decl; - int flags - = ((flag_replace_objc_classes && imp_count ? 1 : 0) - | (flag_objc_gc ? 2 : 0)); - VEC(constructor_elt,gc) *v = NULL; - tree array_type; - - array_type = build_sized_array_type (integer_type_node, 2); - - decl = start_var_decl (array_type, "_OBJC_ImageInfo"); - - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, integer_zero_node); - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (integer_type_node, flags)); - /* The runtime wants this and refers to it in a manner hidden from the compiler. - So we must force the output. */ - DECL_PRESERVE_P (decl) = 1; - OBJCMETA (decl, objc_meta, meta_info); - finish_var_decl (decl, objc_build_constructor (TREE_TYPE (decl), v)); -} - static void objc_generate_v1_next_metadata (void) { @@ -2412,9 +2383,6 @@ objc_generate_v1_next_metadata (void) attr = build_tree_list (objc_meta, meta_modules); build_module_descriptor (vers, attr); - /* This conveys information on GC usage and zero-link. */ - generate_objc_image_info (); - /* Dump the class references. This forces the appropriate classes to be linked into the executable image, preserving unix archive semantics. */ diff --git a/gcc/objc/objc-next-runtime-abi-02.c b/gcc/objc/objc-next-runtime-abi-02.c index 4512c846cc0..678633a91b1 100644 --- a/gcc/objc/objc-next-runtime-abi-02.c +++ b/gcc/objc/objc-next-runtime-abi-02.c @@ -3341,31 +3341,6 @@ build_v2_ivar_offset_ref_table (void) finish_var_decl (ref->decl, ref->offset); } -/* static int _OBJC_IMAGE_INFO[2] = { 0, 16 | flags }; */ - -static void -generate_v2_objc_image_info (void) -{ - tree decl, array_type; - VEC(constructor_elt,gc) *v = NULL; - int flags = - ((flag_replace_objc_classes && imp_count ? 1 : 0) - | (flag_objc_gc ? 2 : 0)); - - flags |= 16; - - array_type = build_sized_array_type (integer_type_node, 2); - - decl = start_var_decl (array_type, "_OBJC_ImageInfo"); - - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, integer_zero_node); - CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (integer_type_node, flags)); - /* The Runtime wants this. */ - DECL_PRESERVE_P (decl) = 1; - OBJCMETA (decl, objc_meta, meta_info); - finish_var_decl (decl, objc_build_constructor (TREE_TYPE (decl), v)); -} - static void objc_generate_v2_next_metadata (void) { @@ -3417,9 +3392,6 @@ objc_generate_v2_next_metadata (void) build_v2_address_table (nonlazy_category_list, "_OBJC_NonLazyCategoryList$", meta_label_nonlazy_categorylist); - /* This conveys information on GC usage and zero-link. */ - generate_v2_objc_image_info (); - /* Generate catch objects for eh, if any are needed. */ build_v2_eh_catch_objects (); diff --git a/gcc/objcp/ChangeLog b/gcc/objcp/ChangeLog index 637abb7400c..e53cbfeca06 100644 --- a/gcc/objcp/ChangeLog +++ b/gcc/objcp/ChangeLog @@ -1,3 +1,7 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + 2013-04-11 Release Manager * GCC 4.7.3 released. diff --git a/gcc/po/ChangeLog b/gcc/po/ChangeLog index 5839fea0284..1d452bfc7d3 100644 --- a/gcc/po/ChangeLog +++ b/gcc/po/ChangeLog @@ -1,3 +1,7 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + 2013-04-11 Release Manager * GCC 4.7.3 released. diff --git a/gcc/sdbout.c b/gcc/sdbout.c index 255c68e7b04..4d42da9221e 100644 --- a/gcc/sdbout.c +++ b/gcc/sdbout.c @@ -1264,7 +1264,10 @@ static void sdbout_parms (tree parms) { for (; parms; parms = TREE_CHAIN (parms)) - if (DECL_NAME (parms)) + if (DECL_NAME (parms) + && TREE_TYPE (parms) != error_mark_node + && DECL_RTL_SET_P (parms) + && DECL_INCOMING_RTL (parms)) { int current_sym_value = 0; const char *name = IDENTIFIER_POINTER (DECL_NAME (parms)); @@ -1396,7 +1399,10 @@ static void sdbout_reg_parms (tree parms) { for (; parms; parms = TREE_CHAIN (parms)) - if (DECL_NAME (parms)) + if (DECL_NAME (parms) + && TREE_TYPE (parms) != error_mark_node + && DECL_RTL_SET_P (parms) + && DECL_INCOMING_RTL (parms)) { const char *name = IDENTIFIER_POINTER (DECL_NAME (parms)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9cca8d78779..46e4621a50b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,315 @@ +2014-06-12 Release Manager + + * GCC 4.7.4 released. + +2014-06-04 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-05-13 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/57230 + * gcc.dg/strlenopt-23.c: New test. + +2014-05-27 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/aliasing1.adb (dg-final): Robustify pattern matching. + +2014-05-24 Dominique d'Humieres <dominiq@lps.ens.fr> + + Backport r195492 and r195815 + 2013-01-27 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/55789 + * gfortran.dg/associate_14.f90: New test. + + PR fortran/56047 + * gfortran.dg/associate_13.f90: New test. + + 2013-02-06 Paul Thomas <pault@gcc.gnu.org> + + PR fortran/55789 + * gfortran.dg/array_constructor_41.f90: New test. + +2014-05-23 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-08-30 Richard Biener <rguenther@suse.de> + + PR tree-optimization/58228 + * gcc.dg/torture/pr58228.c: New testcase. + + 2013-09-26 Richard Biener <rguenther@suse.de> + + PR tree-optimization/58539 + * gcc.dg/torture/pr58539.c: New testcase. + +2014-05-20 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> + + Backport from mainline r210325 + 2014-05-12 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> + + PR target/60991 + * gcc.target/avr/pr60991.c: New testcase. + +2014-05-13 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2014-03-04 Richard Biener <rguenther@suse.de> + + PR tree-optimization/60382 + * gcc.dg/vect/pr60382.c: New testcase. + +2014-05-09 Georg-Johann Lay <avr@gjlay.de> + + Backport from 2014-05-09 trunk r210267 + + PR target/61055 + * gcc.target/avr/torture/pr61055.c: New test. + +2014-05-07 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2013-10-21 Marek Polacek <polacek@redhat.com> + + PR middle-end/58809 + * gcc.dg/gomp/pr58809.c: New test. + + 2013-12-03 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/59011 + * gcc.dg/pr59011.c: New test. + + 2013-11-28 Jakub Jelinek <jakub@redhat.com> + + PR c++/59297 + * g++.dg/gomp/pr59297.C: New test. + + 2013-11-27 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/59014 + * gcc.c-torture/execute/pr59014-2.c: New test. + + 2013-11-26 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/59014 + * gcc.c-torture/execute/pr59014.c: New test. + + 2013-11-14 Jakub Jelinek <jakub@redhat.com> + + PR target/59101 + * gcc.c-torture/execute/pr59101.c: New test. + + 2013-09-30 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/58564 + * gcc.c-torture/execute/pr58564.c: New test. + + 2013-09-10 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/58365 + * gcc.c-torture/execute/pr58365.c: New test. + + 2013-09-09 Jakub Jelinek <jakub@redhat.com> + + PR c++/58325 + * g++.dg/warn/Wunused-var-21.C: New test. + + 2013-08-30 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/58277 + * gcc.c-torture/execute/pr58277-1.c: New test. + * gcc.c-torture/execute/pr58277-2.c: New test. + + 2013-08-23 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/58209 + * gcc.c-torture/execute/pr58209.c: New test. + + 2013-07-03 Jakub Jelinek <jakub@redhat.com> + + PR target/57777 + * gcc.target/i386/pr57777.c: New test. + + 2013-06-27 Jakub Jelinek <jakub@redhat.com> + + PR target/57623 + * gcc.target/i386/bmi-bextr-3.c: New test. + + PR target/57623 + * gcc.target/i386/bmi2-bzhi-1.c: New test. + +2014-05-07 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-11-19 Richard Biener <rguenther@suse.de> + + PR tree-optimization/59164 + * gcc.dg/torture/pr59164.c: New testcase. + +2014-05-07 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-11-28 Richard Biener <rguenther@suse.de> + + PR tree-optimization/59330 + * gcc.dg/torture/pr59330.c: New testcase. + + 2014-01-09 Richard Biener <rguenther@suse.de> + + PR tree-optimization/59715 + * gcc.dg/torture/pr59715.c: New testcase. + +2014-05-07 Richard Biener <rguenther@suse.de> + + PR tree-optimization/57864 + * gcc.dg/torture/pr57864.c: New testcase. + +2014-05-07 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-08-29 Richard Biener <rguenther@suse.de> + + PR tree-optimization/58246 + * gcc.dg/torture/pr58246.c: New testcase. + +2014-05-06 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-05-27 Richard Biener <rguenther@suse.de> + + PR tree-optimization/57417 + * gcc.dg/torture/pr57417.c: New testcase. + +2014-04-25 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.c-torture/execute/20140425-1.c: New test. + +2014-04-23 Uros Bizjak <ubizjak@gmail.com> + + Backport from mainline + 2014-04-21 Uros Bizjak <ubizjak@gmail.com> + + PR target/60909 + * gcc.target/i386/pr60909.c: New test. + +2014-04-12 Jerry DeLisle <jvdelisle@gcc.gnu> + + Backport from mainline + PR libfortran/60810 + * gfortran.dg/arrayio_13.f90: New test. + +2014-04-07 Martin Jambor <mjambor@suse.cz> + + PR ipa/60640 + * g++.dg/ipa/pr60640-1.C: New test. + * g++.dg/ipa/pr60640-2.C: Likewise. + * g++.dg/ipa/pr60640-3.C: Likewise. + +2014-04-06 Dominique d'Humieres <dominiq@lps.ens.fr> + Iain Sandoe <iain@codesourcery.com> + + PR target/54083 + * gcc.dg/attr-weakref-1.c: Allow the test on darwin with + the additional options -Wl,-undefined,dynamic_lookup and + -Wl,-flat_namespace + * gcc.dg/torture/pr53922.c: Additional option + -Wl,-flat_namespace for darwin[89]. + +2014-04-29 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/60522 + * gfortran.dg/where_4.f90: New test case. + +2014-03-20 Tobias Burnus <burnus@net-b.de> + + PR fortran/60543 + PR fortran/60283 + * gfortran.dg/implicit_pure_4.f90: New. + +2014-03-18 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-11-05 Richard Biener <rguenther@suse.de> + + PR middle-end/58941 + * gcc.dg/torture/pr58941.c: New testcase. + +2014-03-18 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-08-27 Richard Biener <rguenther@suse.de> + + PR tree-optimization/57521 + * gcc.dg/torture/pr57521.c: New testcase. + + 2013-09-03 Richard Biener <rguenther@suse.de> + + PR middle-end/57656 + * gcc.dg/torture/pr57656.c: New testcase. + + 2013-11-19 Richard Biener <rguenther@suse.de> + + PR tree-optimization/57517 + * gfortran.fortran-torture/compile/pr57517.f90: New testcase. + * gcc.dg/torture/pr57517.c: Likewise. + +2014-03-17 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2013-05-21 Richard Biener <rguenther@suse.de> + + PR tree-optimization/57303 + * gcc.dg/torture/pr57303.c: New testcase. + + 2013-12-02 Richard Biener <rguenther@suse.de> + + PR tree-optimization/59139 + * gcc.dg/torture/pr59139.c: New testcase. + + 2014-02-14 Richard Biener <rguenther@suse.de> + + PR tree-optimization/60183 + * gcc.dg/torture/pr60183.c: New testcase. + +2014-03-15 Jerry DeLisle <jvdelisle@gcc.gnu> + + Backport from mainline + PR libfortran/58324 + * gfortran.dg/list_read_12.f90: New test. + +2014-03-09 Janus Weil <janus@gcc.gnu.org> + + Backport from 4.8 + 2014-03-08 Janus Weil <janus@gcc.gnu.org> + + PR fortran/60450 + * gfortran.dg/shape_8.f90: New. + +2014-03-02 Mikael Morin <mikael@gcc.gnu.org> + + PR fortran/60341 + * gfortran.dg/str_comp_optimize_1.f90: New test. + +2014-02-26 Fabien Chêne <fabien@gcc.gnu.org> + + PR c++/37140 + * g++.dg/template/using27.C: New. + * g++.dg/template/using28.C: New. + * g++.dg/template/using29.C: New. + +2014-02-22 Mikael Morin <mikael@gcc.gnu.org> + + PR fortran/59599 + * gfortran.dg/ichar_3.f90: New test. + +2014-02-20 Janus Weil <janus@gcc.gnu.org> + + Backport from mainline + 2014-02-17 Janus Weil <janus@gcc.gnu.org> + + PR fortran/55907 + * gfortran.dg/init_flag_12.f90: New. + 2014-02-18 Kai Tietz <ktietz@redhat.com> PR target/60193 diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept22.C b/gcc/testsuite/g++.dg/cpp0x/noexcept22.C new file mode 100644 index 00000000000..7aab0f43c4e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept22.C @@ -0,0 +1,21 @@ +// PR c++/60046 +// { dg-require-effective-target c++11 } + +constexpr bool foo () { return noexcept (true); } +template <typename T> +struct V +{ + void bar (V &) noexcept (foo ()) {} +}; +template <typename T> +struct W : public V <int> +{ + void bar (W &x) { V <int>::bar (x); } +}; + +int +main () +{ + W <int> a, b; + a.bar (b); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic149.C b/gcc/testsuite/g++.dg/cpp0x/variadic149.C new file mode 100644 index 00000000000..a250e7c296a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic149.C @@ -0,0 +1,11 @@ +// PR c++/60248 +// { dg-options "-std=c++11 -g -fabi-version=2" } + +template<int...> struct A {}; + +template<> struct A<0> +{ + typedef enum { e } B; +}; + +A<0> a; diff --git a/gcc/testsuite/g++.dg/eh/uncaught1.C b/gcc/testsuite/g++.dg/eh/uncaught1.C index afbf5af4d22..e96af334a8c 100644 --- a/gcc/testsuite/g++.dg/eh/uncaught1.C +++ b/gcc/testsuite/g++.dg/eh/uncaught1.C @@ -13,7 +13,7 @@ struct Check { static Check const data[] = { { 0, 0, false }, // construct [0] - { 1, 0, true }, // [1] = [0] + { 1, 0, false }, // [1] = [0] { 0, 0, true }, // destruct [0] { 2, 1, true }, // [2] = [1] { 2, 2, true }, // destruct [2] diff --git a/gcc/testsuite/g++.dg/eh/uncaught4.C b/gcc/testsuite/g++.dg/eh/uncaught4.C new file mode 100644 index 00000000000..227d11b330b --- /dev/null +++ b/gcc/testsuite/g++.dg/eh/uncaught4.C @@ -0,0 +1,29 @@ +// PR c++/41174 +// { dg-do run } + +#include <exception> + +#define assert(E) if (!(E)) __builtin_abort(); + +struct e { + e() + { + assert( !std::uncaught_exception() ); + try { + throw 1; + } catch (int i) { + assert( !std::uncaught_exception() ); + throw; + } + } +}; + +int main() +{ + try { + throw e(); + } catch (int i) { + assert( !std::uncaught_exception() ); + } + assert( !std::uncaught_exception() ); +} diff --git a/gcc/testsuite/g++.dg/gomp/pr59297.C b/gcc/testsuite/g++.dg/gomp/pr59297.C new file mode 100644 index 00000000000..330ed2e00b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr59297.C @@ -0,0 +1,25 @@ +// PR c++/59297 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template <typename T> +struct A +{ + ~A (); + const T &operator[] (int) const; +}; + +struct B +{ + int &operator () (A <int>); +}; + +void +foo (B &x, int &z) +{ + A<A<int> > y; + #pragma omp atomic + x (y[0]) += 1; + #pragma omp atomic + z += x(y[1]); +} diff --git a/gcc/testsuite/g++.dg/ipa/pr60640-1.C b/gcc/testsuite/g++.dg/ipa/pr60640-1.C new file mode 100644 index 00000000000..7a0b91893f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr60640-1.C @@ -0,0 +1,50 @@ +// { dg-do compile } +// { dg-options "-O3" } + +class ASN1Object +{ +public: + virtual ~ASN1Object (); +}; +class A +{ + virtual unsigned m_fn1 () const; +}; +class B +{ +public: + ASN1Object Element; + virtual unsigned m_fn1 (bool) const; +}; +template <class BASE> class C : public BASE +{ +}; + +class D : ASN1Object, public B +{ +}; +class G : public D +{ + unsigned m_fn1 (bool) const {} +}; +class F : A +{ +public: + F (A); + unsigned m_fn1 () const + { + int a; + a = m_fn2 ().m_fn1 (0); + return a; + } + const B &m_fn2 () const { return m_groupParameters; } + C<G> m_groupParameters; +}; +template <class D> void BenchMarkKeyAgreement (int *, int *, int) +{ + A f; + D d (f); +} + +void BenchmarkAll2 () { BenchMarkKeyAgreement<F>(0, 0, 0); } + diff --git a/gcc/testsuite/g++.dg/ipa/pr60640-2.C b/gcc/testsuite/g++.dg/ipa/pr60640-2.C new file mode 100644 index 00000000000..c6e614cc004 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr60640-2.C @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-O3" } + +struct B { virtual unsigned f () const; }; +struct C { virtual void f (); }; +struct F { virtual unsigned f (bool) const; ~F (); }; +struct J : C, F {}; +struct G : J { unsigned f (bool) const { return 0; } }; +struct H : B +{ + H (int); + unsigned f () const { return ((const F &) h).f (0); } + G h; +}; +H h (0); diff --git a/gcc/testsuite/g++.dg/ipa/pr60640-3.C b/gcc/testsuite/g++.dg/ipa/pr60640-3.C new file mode 100644 index 00000000000..21b1f58a040 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr60640-3.C @@ -0,0 +1,81 @@ +// { dg-do run } +// { dg-options "-O3" } + +struct Distraction +{ + char fc[8]; + virtual Distraction * return_self () + { return this; } +}; + +namespace { + +struct A; +static A * __attribute__ ((noinline, noclone)) get_an_A (); + +static int go; + +struct A +{ + int fi; + + A () : fi(777) {} + A (int pi) : fi (pi) {} + virtual A * foo (int p) = 0; +}; + +struct B; +static B * __attribute__ ((noinline, noclone)) get_a_B (); + +struct B : public Distraction, A +{ + B () : Distraction(), A() { } + B (int pi) : Distraction (), A (pi) {} + virtual B * foo (int p) + { + int o = fi; + for (int i = 0; i < p; i++) + o += i + i * i; + go = o; + + return get_a_B (); + } +}; + + +struct B gb1 (1111), gb2 (2); +static B * __attribute__ ((noinline, noclone)) +get_a_B () +{ + return &gb1; +} + +static A * __attribute__ ((noinline, noclone)) +get_an_A () +{ + return &gb2; +} + +} + +static int __attribute__ ((noinline, noclone)) +get_a_number () +{ + return 5; +} + +extern "C" void abort (void); + +int main (int argc, char *argv[]) +{ + for (int i = 0; i < get_a_number (); i++) + { + struct A *p = get_an_A (); + struct A *r = p->foo (4); + if (r->fi != 1111) + abort (); + if (go != 22) + abort (); + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/template/local8.C b/gcc/testsuite/g++.dg/template/local8.C new file mode 100644 index 00000000000..006bd8c40eb --- /dev/null +++ b/gcc/testsuite/g++.dg/template/local8.C @@ -0,0 +1,18 @@ +// PR c++/56947 + +struct A +{ + A (int); +}; + +template < typename > +void Fn () +{ + const int kCapacity = 0; + struct Q:A + { + Q ():A (kCapacity) { } + }; + Q q; +} +template void Fn < int >(); diff --git a/gcc/testsuite/g++.dg/template/using27.C b/gcc/testsuite/g++.dg/template/using27.C new file mode 100644 index 00000000000..f1835e17161 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/using27.C @@ -0,0 +1,33 @@ +// PR c++/37140 + +struct X +{ + typedef int nested_type; +}; + +template <class T> +struct A +{ + typedef X type; +}; + +template <class T> +struct B : A<T> +{ + using typename A<T>::type; + typename type::nested_type x; +}; + +template <class T> +struct C : B<T> +{ + using typename B<T>::type; + typename type::nested_type y; +}; + +struct D : C<int> +{ + using C<int>::type; + type::nested_type z; +}; + diff --git a/gcc/testsuite/g++.dg/template/using28.C b/gcc/testsuite/g++.dg/template/using28.C new file mode 100644 index 00000000000..52f68cfe467 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/using28.C @@ -0,0 +1,17 @@ +// PR c++/37140 + +struct C +{ + static const int block_size = 1; +}; + +template <typename T> struct A { + typedef C type; +}; + +template <typename T> struct B : public A<T> { + using typename A<T>::type; + static const int block_size = type::block_size; +}; + +template class B<int>; diff --git a/gcc/testsuite/g++.dg/template/using29.C b/gcc/testsuite/g++.dg/template/using29.C new file mode 100644 index 00000000000..8726547efdb --- /dev/null +++ b/gcc/testsuite/g++.dg/template/using29.C @@ -0,0 +1,21 @@ +// PR c++/58047 + +template <int N> +struct print_arg { }; + +struct const_holder { + static const int CONSTANT = 42; +}; + +template <typename T> +struct identity { + typedef T type; +}; + +template <class T> +struct test_case : public identity<T> { + using typename identity<T>::type; + print_arg<type::CONSTANT> printer; +}; + +template struct test_case<const_holder>; diff --git a/gcc/testsuite/g++.dg/torture/pr60609.C b/gcc/testsuite/g++.dg/torture/pr60609.C new file mode 100644 index 00000000000..9ddec0b601d --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr60609.C @@ -0,0 +1,252 @@ +/* { dg-do assemble } */ + +class exception +{ +}; +class bad_alloc:exception +{ +}; +class logic_error:exception +{ +}; +class domain_error:logic_error +{ +}; +class invalid_argument:logic_error +{ +}; +class length_error:logic_error +{ +}; +class overflow_error:exception +{ +}; +typedef int mpz_t[]; +template < class > class __gmp_expr; +template <> class __gmp_expr < mpz_t > +{ + ~__gmp_expr (); +}; + +class PIP_Solution_Node; +class internal_exception +{ + ~internal_exception (); +}; +class not_an_integer:internal_exception +{ +}; +class not_a_variable:internal_exception +{ +}; +class not_an_optimization_mode:internal_exception +{ +}; +class not_a_bounded_integer_type_width:internal_exception +{ +}; +class not_a_bounded_integer_type_representation:internal_exception +{ +}; +class not_a_bounded_integer_type_overflow:internal_exception +{ +}; +class not_a_complexity_class:internal_exception +{ +}; +class not_a_control_parameter_name:internal_exception +{ +}; +class not_a_control_parameter_value:internal_exception +{ +}; +class not_a_pip_problem_control_parameter_name:internal_exception +{ +}; +class not_a_pip_problem_control_parameter_value:internal_exception +{ +}; +class not_a_relation:internal_exception +{ +}; +class ppl_handle_mismatch:internal_exception +{ +}; +class timeout_exception +{ + ~timeout_exception (); +}; +class deterministic_timeout_exception:timeout_exception +{ +}; +void __assert_fail (const char *, const char *, int, int *) +__attribute__ ((__noreturn__)); +void PL_get_pointer (void *); +int Prolog_is_address (); +inline int +Prolog_get_address (void **p1) +{ + Prolog_is_address ()? static_cast < + void >(0) : __assert_fail ("Prolog_is_address", "./swi_cfli.hh", 0, 0); + PL_get_pointer (p1); + return 0; +} + +class non_linear:internal_exception +{ +}; +class not_unsigned_integer:internal_exception +{ +}; +class not_universe_or_empty:internal_exception +{ +}; +class not_a_nil_terminated_list:internal_exception +{ +}; +class PPL_integer_out_of_range +{ + __gmp_expr < mpz_t > n; +}; +void handle_exception (); +template < typename T > T * term_to_handle (int, const char *) +{ + if (Prolog_is_address ()) + { + void *p; + Prolog_get_address (&p); + return static_cast < T * >(0); + } + throw; +} + +void +ppl_new_MIP_Problem_from_MIP_Problem () +try +{ + term_to_handle < int >(0, "ppl_new_MIP_Problem_from_MIP_Problem/2"); +} + +catch (exception &) +{ +} + +int +ppl_PIP_Tree_Node_parametric_values () +{ + try + { + PIP_Solution_Node *a = term_to_handle < PIP_Solution_Node > (0, 0); + (void)a; + return 1; + } + catch (internal_exception &) + { + } + catch (not_unsigned_integer &) + { + handle_exception (); + } + catch (non_linear &) + { + handle_exception (); + } + catch (not_a_variable &) + { + handle_exception (); + } + catch (not_an_integer &) + { + handle_exception (); + } + catch (ppl_handle_mismatch &) + { + handle_exception (); + } + catch (not_an_optimization_mode &) + { + handle_exception (); + } + catch (not_a_complexity_class &) + { + handle_exception (); + } + catch (not_a_bounded_integer_type_width &) + { + handle_exception (); + } + catch (not_a_bounded_integer_type_representation &) + { + handle_exception (); + } + catch (not_a_bounded_integer_type_overflow &) + { + handle_exception (); + } + catch (not_a_control_parameter_name &) + { + handle_exception (); + } + catch (not_a_control_parameter_value &) + { + handle_exception (); + } + catch (not_a_pip_problem_control_parameter_name &) + { + handle_exception (); + } + catch (not_a_pip_problem_control_parameter_value &) + { + handle_exception (); + } + catch (not_universe_or_empty &) + { + handle_exception (); + } + catch (not_a_relation &) + { + handle_exception (); + } + catch (not_a_nil_terminated_list &) + { + handle_exception (); + } + catch (PPL_integer_out_of_range &) + { + handle_exception (); + } + catch (int &) + { + } catch (timeout_exception &) + { + handle_exception (); + } catch (deterministic_timeout_exception &) + { + handle_exception (); + } catch (overflow_error &) + { + handle_exception (); + } catch (domain_error &) + { + handle_exception (); + } catch (length_error &) + { + handle_exception (); + } catch (invalid_argument &) + { + handle_exception (); + } catch (logic_error &) + { + handle_exception (); + } catch (bad_alloc &) + { + handle_exception (); + } catch (exception &) + { + handle_exception (); + } catch ( ...) + { + handle_exception (); + } + return 0; +} diff --git a/gcc/testsuite/g++.dg/warn/Wunused-var-21.C b/gcc/testsuite/g++.dg/warn/Wunused-var-21.C new file mode 100644 index 00000000000..d279e598033 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-var-21.C @@ -0,0 +1,31 @@ +// PR c++/58325 +// { dg-do compile } +// { dg-options "-Wunused" } + +void +f1 () +{ + int *volatile a = new int[1]; + delete[] a; +} + +void +f2 () +{ + int *b = new int[1]; + delete[] b; +} + +void +f3 () +{ + int *volatile c = new int; + delete c; +} + +void +f4 () +{ + int *d = new int; + delete d; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/20140425-1.c b/gcc/testsuite/gcc.c-torture/execute/20140425-1.c new file mode 100644 index 00000000000..c447ef95b6c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20140425-1.c @@ -0,0 +1,23 @@ +/* PR target/60941 */ +/* Reported by Martin Husemann <martin@netbsd.org> */ + +extern void abort (void); + +static void __attribute__((noinline)) +set (unsigned long *l) +{ + *l = 31; +} + +int main (void) +{ + unsigned long l; + int i; + + set (&l); + i = (int) l; + l = (unsigned long)(2U << i); + if (l != 0) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58209.c b/gcc/testsuite/gcc.c-torture/execute/pr58209.c new file mode 100644 index 00000000000..78743bfb959 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr58209.c @@ -0,0 +1,32 @@ +/* PR tree-optimization/58209 */ + +extern void abort (void); +typedef __INTPTR_TYPE__ T; +T buf[1024]; + +T * +foo (T n) +{ + if (n == 0) + return (T *) buf; + T s = (T) foo (n - 1); + return (T *) (s + sizeof (T)); +} + +T * +bar (T n) +{ + if (n == 0) + return buf; + return foo (n - 1) + 1; +} + +int +main () +{ + int i; + for (i = 0; i < 27; i++) + if (foo (i) != buf + i || bar (i) != buf + i) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58277-1.c b/gcc/testsuite/gcc.c-torture/execute/pr58277-1.c new file mode 100644 index 00000000000..811988f4371 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr58277-1.c @@ -0,0 +1,102 @@ +/* PR tree-optimization/58277 */ + +extern void abort (void); +static int a[2]; +int b, c, d, *e, f, g, h, **i = &e, k, l = 1, n, o, p; +static int **volatile j = &e; +const int m; +char u; + +int +bar () +{ + u = 0; + return m; +} + +__attribute__((noinline, noclone)) void +baz () +{ + asm (""); +} + +static int +foo () +{ + int t1; + g = bar (); + if (l) + ; + else + for (;; h++) + { + *i = 0; + o = *e = 0; + if (p) + { + f = 0; + return 0; + } + for (;; k++) + { + int *t2 = 0; + int *const *t3[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, &t2, &t2, &t2, + &t2, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, &t2, + &t2, &t2, &t2, 0, 0, 0, 0, 0, 0, 0, &t2, 0, 0, 0, + &t2, 0, 0, 0, &t2, 0, &t2, 0, 0, &t2, 0, 0, 0, 0, + 0, &t2, 0, 0, 0, 0, &t2, &t2, 0, 0, 0, 0, &t2, 0, + 0, 0, 0, 0, 0, 0, &t2, 0, 0, 0, 0, 0, &t2, 0, 0, 0, + &t2, &t2 + }; + int *const **t4[] = {&t3[0]}; + **i = 0; + if (**j) + break; + u = 0; + } + *i = *j; + t1 = 0; + for (; t1 < 5; t1++) + *i = *j; + } + *j = 0; + return 1; +} + +int +main () +{ + int t5; + a[0] = 1; + { + int *t6[6] = {&d, &d}; + for (n = 1; n; n--) + if (foo()) + { + int *t7[] = {0}; + d = 0; + for (; u < 1; u++) + *i = *j; + *i = 0; + *i = 0; + int t8[5] = {0}; + *i = &t8[0]; + int *const *t9 = &t6[0]; + int *const **t10 = &t9; + *t10 = &t7[0]; + } + } + u = 0; + for (; b; b++) + for (t5 = 0; t5 < 10; t5++) + c = a[a[a[a[a[a[a[a[c]]]]]]]]; + + baz (); + + if (!a[a[a[a[a[a[a[a[a[a[a[a[a[a[a[u]]]]]]]]]]]]]]]) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58277-2.c b/gcc/testsuite/gcc.c-torture/execute/pr58277-2.c new file mode 100644 index 00000000000..d919c2f3f80 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr58277-2.c @@ -0,0 +1,98 @@ +/* PR tree-optimization/58277 */ + +extern void abort (void); +static int a[1], b, c, e, i, j, k, m, q[] = { 1, 1 }, t; +int volatile d; +int **r; +static int ***volatile s = &r; +int f, g, o, x; +static int *volatile h = &f, *p; +char n; + +static void +fn1 () +{ + b = a[a[a[a[a[a[a[a[b]]]]]]]]; + b = a[a[a[a[a[a[a[a[b]]]]]]]]; + b = a[a[b]]; + b = a[a[a[a[a[a[a[a[b]]]]]]]]; + b = a[a[a[a[a[a[a[a[b]]]]]]]]; +} + +static int +fn2 () +{ + n = 0; + for (; g; t++) + { + for (;; m++) + { + d; + int *u; + int **v[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, &u, 0, 0, 0, 0, &u, &u, &u, &u, &u, &u, &u, 0, + &u, 0, &u, &u, &u, 0, &u, &u, 0, &u, &u, &u, &u, 0, &u, &u, &u, + &u, &u, 0, &u, &u, 0, &u, 0, &u, &u, 0, &u, &u, &u, &u, &u, 0, + &u, 0, 0, 0, &u, &u, &u, 0, 0, &u, &u, &u, 0, &u, 0, &u, &u + }; + int ***w[] = { &v[0] }; + if (*p) + break; + return 0; + } + *h = 0; + } + return 1; +} + +static void +fn3 () +{ + int *y[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + for (; i; i++) + x = 0; + if (fn2 ()) + { + int *z[6] = { }; + for (; n < 1; n++) + *h = 0; + int t1[7]; + for (; c; c++) + o = t1[0]; + for (; e; e--) + { + int **t2 = &y[0]; + int ***t3 = &t2; + *t3 = &z[0]; + } + } + *s = 0; + for (n = 0;; n = 0) + { + int t4 = 0; + if (q[n]) + break; + *r = &t4; + } +} + +int +main () +{ + for (; j; j--) + a[0] = 0; + fn3 (); + for (; k; k++) + fn1 (); + fn1 (); + + if (n) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58365.c b/gcc/testsuite/gcc.c-torture/execute/pr58365.c new file mode 100644 index 00000000000..1e6079d8429 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr58365.c @@ -0,0 +1,35 @@ +/* PR rtl-optimization/58365 */ + +extern void abort (void); + +struct S +{ + volatile int a; + int b, c, d, e; +} f; +static struct S g, h; +int i = 1; + +char +foo (void) +{ + return i; +} + +static struct S +bar (void) +{ + if (foo ()) + return f; + return g; +} + +int +main () +{ + h = bar (); + f.b = 1; + if (h.b != 0) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58564.c b/gcc/testsuite/gcc.c-torture/execute/pr58564.c new file mode 100644 index 00000000000..967ee95d4ab --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr58564.c @@ -0,0 +1,14 @@ +/* PR middle-end/58564 */ + +extern void abort (void); +int a, b; +short *c, **d = &c; + +int +main () +{ + b = (0, 0 > ((&c == d) & (1 && (a ^ 1)))) | 0U; + if (b != 0) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c b/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c new file mode 100644 index 00000000000..18da0059eab --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/59014 */ + +__attribute__((noinline, noclone)) long long int +foo (long long int x, long long int y) +{ + if (((int) x | (int) y) != 0) + return 6; + return x + y; +} + +int +main () +{ + if (sizeof (long long) == sizeof (int)) + return 0; + int shift_half = sizeof (int) * __CHAR_BIT__ / 2; + long long int x = (3LL << shift_half) << shift_half; + long long int y = (5LL << shift_half) << shift_half; + long long int z = foo (x, y); + if (z != ((8LL << shift_half) << shift_half)) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59014.c b/gcc/testsuite/gcc.c-torture/execute/pr59014.c new file mode 100644 index 00000000000..10bf81a462f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr59014.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/59014 */ + +int a = 2, b, c, d; + +int +foo () +{ + for (;; c++) + if ((b > 0) | (a & 1)) + ; + else + { + d = a; + return 0; + } +} + +int +main () +{ + foo (); + if (d != 2) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59101.c b/gcc/testsuite/gcc.c-torture/execute/pr59101.c new file mode 100644 index 00000000000..ed6a7e8fa31 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr59101.c @@ -0,0 +1,15 @@ +/* PR target/59101 */ + +__attribute__((noinline, noclone)) int +foo (int a) +{ + return (~a & 4102790424LL) > 0 | 6; +} + +int +main () +{ + if (foo (0) != 7) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/attr-weakref-1.c b/gcc/testsuite/gcc.dg/attr-weakref-1.c index 31d5379e47c..0cd08454535 100644 --- a/gcc/testsuite/gcc.dg/attr-weakref-1.c +++ b/gcc/testsuite/gcc.dg/attr-weakref-1.c @@ -5,12 +5,14 @@ // is not available on alpha*-dec-osf* and hppa*-*-hpux*. The test is // skipped rather than xfailed to suppress the warning that would otherwise // arise. -// { dg-skip-if "" { "alpha*-dec-osf*" "*-*-darwin*" "hppa*-*-hpux*" } "*" { "" } } +// { dg-skip-if "" { "alpha*-dec-osf*" "hppa*-*-hpux*" } "*" { "" } } // For kernel modules and static RTPs, the loader treats undefined weak // symbols in the same way as undefined strong symbols. The test // therefore fails to load, so skip it. // { dg-skip-if "" { "*-*-vxworks*" && nonpic } "*" { "-non-static" } } // { dg-options "-O2" } +// { dg-additional-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } +// { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } // { dg-additional-sources "attr-weakref-1a.c" } // Copyright 2005 Free Software Foundation, Inc. diff --git a/gcc/testsuite/gcc.dg/gomp/pr58809.c b/gcc/testsuite/gcc.dg/gomp/pr58809.c new file mode 100644 index 00000000000..5dc02f65aa8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr58809.c @@ -0,0 +1,13 @@ +/* PR middle-end/58809 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -O" } */ + +int i; +#pragma omp threadprivate (i) + +void foo() +{ + _Complex int j; +#pragma omp parallel copyin (i) reduction (&&:j) + ; +} diff --git a/gcc/testsuite/gcc.dg/pr59011.c b/gcc/testsuite/gcc.dg/pr59011.c new file mode 100644 index 00000000000..2fb8187ad55 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr59011.c @@ -0,0 +1,22 @@ +/* PR middle-end/59011 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99" } */ + +void +foo (int m) +{ + int a[m]; + void + bar (void) + { + { + int + baz (void) + { + return a[0]; + } + } + a[0] = 42; + } + bar (); +} diff --git a/gcc/testsuite/gcc.dg/strlenopt-23.c b/gcc/testsuite/gcc.dg/strlenopt-23.c new file mode 100644 index 00000000000..75dab2ae0bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/strlenopt-23.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/57230 */ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include "strlenopt.h" + +int +main () +{ + char p[] = "hello world"; + p[0] = (char) (strlen (p) - 1); + if (strlen (p) != 11) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr53922.c b/gcc/testsuite/gcc.dg/torture/pr53922.c index 980bab589f1..750b006bf60 100644 --- a/gcc/testsuite/gcc.dg/torture/pr53922.c +++ b/gcc/testsuite/gcc.dg/torture/pr53922.c @@ -2,6 +2,8 @@ /* { dg-require-weak "" } */ /* { dg-skip-if "No undefined weak" { alpha*-*-osf* } } */ /* { dg-skip-if "No undefined weak" { hppa*-*-hpux* && { ! lp64 } } } */ +/* { dg-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */ +/* { dg-additional-options "-Wl,-flat_namespace" { target *-*-darwin[89]* } } */ int x(int a) { diff --git a/gcc/testsuite/gcc.dg/torture/pr57303.c b/gcc/testsuite/gcc.dg/torture/pr57303.c new file mode 100644 index 00000000000..1ddb5a8aab3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr57303.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ + +void abort (void); + +struct S0 +{ + int f0; +}; +struct S1 +{ + struct S0 f0; +}; + +struct S1 x = { {0} }; +struct S1 y = { {1} }; + +static void +foo (struct S0 p) +{ + struct S0 *l = &y.f0; + *l = x.f0; + if (p.f0) + *l = *l; +} + +int +main () +{ + foo(y.f0); + if (y.f0.f0 != 0) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr57417.c b/gcc/testsuite/gcc.dg/torture/pr57417.c new file mode 100644 index 00000000000..6eac6f932b8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr57417.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +int a, b; +volatile int *c; + +void foo () +{ + volatile int d[1]; + b = 0; + for (;; a--) + c = &d[b]; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr57517.c b/gcc/testsuite/gcc.dg/torture/pr57517.c new file mode 100644 index 00000000000..2422d8ee64a --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr57517.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ + +int x[1024], y[1024], z[1024], w[1024]; +void foo (void) +{ + int i; + for (i = 1; i < 1024; ++i) + { + int a = x[i]; + int b = y[i]; + int c = x[i-1]; + int d = y[i-1]; + if (w[i]) + z[i] = (a + b) + (c + d); + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr57521.c b/gcc/testsuite/gcc.dg/torture/pr57521.c new file mode 100644 index 00000000000..e7832cb00e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr57521.c @@ -0,0 +1,51 @@ +/* { dg-do run } */ +/* { dg-options "-ftree-loop-if-convert" } */ + +void abort (void); + +int a, b, c, d, o = 1, p; +short e; + +int +fn1 (int * p1) +{ + int f, g, h, j = 0, k = 0, l = 0; + unsigned int i; + int *m[1] = { &l }; + for (; b >= 0; b--) + { + if (*p1) + if (j >= 0) + { + int n = 1; + e = 1; + h = a ? a : 1 % n; + g = h > 0 ? 0 : h + 1; + k = c + g; + } + else + continue; + else + { + + f = d > 0 ? 0 : d + 1; + i = f; + j = 1 + i; + } + l++; + } + return k; +} + +int +main () +{ + for (;; p++) + { + fn1 (&o); + break; + } + if (e != 1) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr57656.c b/gcc/testsuite/gcc.dg/torture/pr57656.c new file mode 100644 index 00000000000..4f3645e4693 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr57656.c @@ -0,0 +1,13 @@ +/* { dg-do run } */ +/* { dg-options "-fstrict-overflow" } */ + +int main (void) +{ + int a = -1; + int b = __INT_MAX__; + int c = 2; + int t = 1 - ((a - b) / c); // t = 1 - ( __INT_MIN__ / 2 ) + if (t != (1 - (-1 - __INT_MAX__) / 2)) + __builtin_abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr57864.c b/gcc/testsuite/gcc.dg/torture/pr57864.c new file mode 100644 index 00000000000..93962c20e3f --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr57864.c @@ -0,0 +1,37 @@ +/* { dg-do compile } */ + +union U { + double val; + union U *ptr; +}; + +union U *d; +double a; +int b; +int c; + +static void fn1(union U *p1, int p2, _Bool p3) +{ + union U *e; + + if (p2 == 0) + a = ((union U*)((unsigned long)p1 & ~1))->val; + + if (b) { + e = p1; + } else if (c) { + e = ((union U*)((unsigned long)p1 & ~1))->ptr; + d = e; + } else { + e = 0; + d = ((union U*)0)->ptr; + } + + fn1 (e, 0, 0); + fn1 (0, 0, p3); +} + +void fn2 (void) +{ + fn1 (0, 0, 0); +} diff --git a/gcc/testsuite/gcc.dg/torture/pr58228.c b/gcc/testsuite/gcc.dg/torture/pr58228.c new file mode 100644 index 00000000000..d12303a008d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr58228.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ + +extern void abort (void); +int a[8][8] = {{1}}; +int b, c, d, e; + +int main () +{ + for (c = 0; c < 8; c++) + for (b = 0; b < 2; b++) + a[b + 4][c] = a[c][0]; + if (a[4][4] != 1) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr58246.c b/gcc/testsuite/gcc.dg/torture/pr58246.c new file mode 100644 index 00000000000..5417abf913d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr58246.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ + +extern void abort (void); + +int a, b; + +int main () +{ + int t[2] = {1,1}; + + for (a = 0; a < 2; a++) + { + b ^= t[a]; + t[a] = t[1] = 0; + } + + if (b != 1) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr58539.c b/gcc/testsuite/gcc.dg/torture/pr58539.c new file mode 100644 index 00000000000..a016150f18e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr58539.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-g" } */ + +int a, b; + +extern void baz (int); + +int foo (int p) +{ + return p ? p : 1; +} + +void bar () +{ + int *c = &a, *d = &a; + for (b = 0; b < 12; b++) + *d |= 1; + foo (*c); + baz (*c && 1); +} diff --git a/gcc/testsuite/gcc.dg/torture/pr58941.c b/gcc/testsuite/gcc.dg/torture/pr58941.c new file mode 100644 index 00000000000..c0eea073165 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr58941.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ + +extern void abort (void); + +typedef struct { + int msgLength; + unsigned char data[1000]; +} SMsg; + +typedef struct { + int dummy; + int d[0]; +} SData; + +int condition = 3; + +int main() +{ + SMsg msg; + SData *pData = (SData*)(msg.data); + unsigned int i = 0; + for (i = 0; i < 1; i++) + { + pData->d[i] = 0; + if(condition & 1) + pData->d[i] |= 0x55; + if(condition & 2) + pData->d[i] |= 0xaa; + } + if (pData->d[0] != 0xff) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr59139.c b/gcc/testsuite/gcc.dg/torture/pr59139.c new file mode 100644 index 00000000000..4ec9177ffe7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr59139.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ + +int a, b, c, d, e; +int fn1(p1, p2) { return p2 == 0 ? p1 : 1 % p2; } + +void fn2() +{ + c = 0; + for (;; c = (unsigned short)c) + { + b = 2; + for (; b; b = a) + { + e = fn1(2, c && 1); + d = c == 0 ? e : c; + if (d) + return; + } + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr59164.c b/gcc/testsuite/gcc.dg/torture/pr59164.c new file mode 100644 index 00000000000..1ec69610c21 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr59164.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +int a, d, e; +long b[10]; +int c[10][8]; + +int fn1(p1) +{ + return 1 >> p1; +} + +void fn2(void) +{ + int f; + for (a=1; a <= 4; a++) + { + f = fn1(0 < c[a][0]); + if (f || d) + e = b[a] = 1; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr59330.c b/gcc/testsuite/gcc.dg/torture/pr59330.c new file mode 100644 index 00000000000..74b832ea314 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr59330.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ + +void free(void *ptr) +{ +} + +void *foo(void) +{ + return 0; +} + +int main(void) +{ + void *p = foo(); + free(p); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr59715.c b/gcc/testsuite/gcc.dg/torture/pr59715.c new file mode 100644 index 00000000000..19c09de55d7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr59715.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ + +extern void abort (void); + +int a = 2, b; + +int +main () +{ + int c; + if (!b) + { + b = a; + c = a == 0 ? 1 : 1 % a; + if (c) + b = 0; + } + if (b != 0) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr60183.c b/gcc/testsuite/gcc.dg/torture/pr60183.c new file mode 100644 index 00000000000..3f676637ba8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr60183.c @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-require-effective-target size32plus } */ + +/* Large so an out-of-bound read will crash. */ +unsigned char c[0x30001] = { 1 }; +int j = 2; + +static void +foo (unsigned long *x, unsigned char *y) +{ + int i; + unsigned long w = x[0]; + for (i = 0; i < j; i++) + { + w += *y; + y += 0x10000; + w += *y; + y += 0x10000; + } + x[1] = w; +} + +__attribute__ ((noinline, noclone)) void +bar (unsigned long *x) +{ + foo (x, c); +} + +int +main () +{ + unsigned long a[2] = { 0, -1UL }; + asm volatile (""::"r" (c):"memory"); + c[0] = 0; + bar (a); + if (a[1] != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr60382.c b/gcc/testsuite/gcc.dg/vect/pr60382.c new file mode 100644 index 00000000000..a28c6313c40 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr60382.c @@ -0,0 +1,32 @@ +#include "tree-vect.h" + +int a, b, c, e, f; + +void +foo () +{ + for (b = 0; b < 3; b++) + if (e) + { + for (c = 0; c < 4; c++) + { + if (b) + continue; + f = 1; + for (a = 0; a < 2; a++) + f |= 1; + } + for (;;) + ; + } +} + +int +main () +{ + check_vect (); + foo (); + return 0; +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.target/avr/pr60991.c b/gcc/testsuite/gcc.target/avr/pr60991.c new file mode 100644 index 00000000000..a09f42a62b3 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr60991.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +/* This testcase (simplified from the original bug report) exposes + PR60991. The code generated for writing the __int24 value corrupts + the frame pointer if the offset is <= 63 + MAX_LD_OFFSET */ + +#include <stdlib.h> + +int main(void) +{ + volatile char junk[62]; + junk[0] = 5; + volatile __int24 staticConfig = 0; + + if (junk[0] != 5) + abort(); + + exit(0); + return 0; +} diff --git a/gcc/testsuite/gcc.target/avr/torture/pr61055.c b/gcc/testsuite/gcc.target/avr/torture/pr61055.c new file mode 100644 index 00000000000..9dd1f427d00 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/torture/pr61055.c @@ -0,0 +1,88 @@ +/* { dg-do run } */ +/* { dg-options { -fno-peephole2 } } */ + +#include <stdlib.h> + +typedef __UINT16_TYPE__ uint16_t; +typedef __INT16_TYPE__ int16_t; +typedef __UINT8_TYPE__ uint8_t; + +uint8_t __attribute__((noinline,noclone)) +fun_inc (uint8_t c0) +{ + register uint8_t c asm ("r15") = c0; + + /* Force target value into R15 (lower register) */ + asm ("" : "+l" (c)); + + c++; + if (c >= 0x80) + c = 0; + + asm ("" : "+l" (c)); + + return c; +} + +uint8_t __attribute__((noinline,noclone)) +fun_dec (uint8_t c0) +{ + register uint8_t c asm ("r15") = c0; + + /* Force target value into R15 (lower register) */ + asm ("" : "+l" (c)); + + c--; + if (c < 0x80) + c = 0; + + asm ("" : "+l" (c)); + + return c; +} + + +uint8_t __attribute__((noinline,noclone)) +fun_neg (uint8_t c0) +{ + register uint8_t c asm ("r15") = c0; + + c = -c; + if (c >= 0x80) + c = 0; + + return c; +} + +uint16_t __attribute__((noinline,noclone)) +fun_adiw (uint16_t c0) +{ + register uint16_t c asm ("r24") = c0; + + /* Force target value into R24 (for ADIW) */ + asm ("" : "+r" (c)); + + c += 2; + if (c >= 0x8000) + c = 0; + + asm ("" : "+r" (c)); + + return c; +} + + +int main() +{ + if (fun_inc (0x7f) != 0) + abort(); + + if (fun_neg (0x80) != 0) + abort(); + + if (fun_adiw (0x7ffe) != 0) + abort(); + + exit (0); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/bmi-bextr-3.c b/gcc/testsuite/gcc.target/i386/bmi-bextr-3.c new file mode 100644 index 00000000000..fe342b9e0ad --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/bmi-bextr-3.c @@ -0,0 +1,31 @@ +/* PR target/57623 */ +/* { dg-do assemble { target bmi } } */ +/* { dg-options "-O2 -mbmi" } */ + +#include <x86intrin.h> + +unsigned int +f1 (unsigned int x, unsigned int *y) +{ + return __bextr_u32 (x, *y); +} + +unsigned int +f2 (unsigned int *x, unsigned int y) +{ + return __bextr_u32 (*x, y); +} + +#ifdef __x86_64__ +unsigned long long +f3 (unsigned long long x, unsigned long long *y) +{ + return __bextr_u64 (x, *y); +} + +unsigned long long +f4 (unsigned long long *x, unsigned long long y) +{ + return __bextr_u64 (*x, y); +} +#endif diff --git a/gcc/testsuite/gcc.target/i386/bmi2-bzhi-1.c b/gcc/testsuite/gcc.target/i386/bmi2-bzhi-1.c new file mode 100644 index 00000000000..42e002d0630 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/bmi2-bzhi-1.c @@ -0,0 +1,31 @@ +/* PR target/57623 */ +/* { dg-do assemble { target bmi2 } } */ +/* { dg-options "-O2 -mbmi2" } */ + +#include <x86intrin.h> + +unsigned int +f1 (unsigned int x, unsigned int *y) +{ + return _bzhi_u32 (x, *y); +} + +unsigned int +f2 (unsigned int *x, unsigned int y) +{ + return _bzhi_u32 (*x, y); +} + +#ifdef __x86_64__ +unsigned long long +f3 (unsigned long long x, unsigned long long *y) +{ + return _bzhi_u64 (x, *y); +} + +unsigned long long +f4 (unsigned long long *x, unsigned long long y) +{ + return _bzhi_u64 (*x, y); +} +#endif diff --git a/gcc/testsuite/gcc.target/i386/pr57777.c b/gcc/testsuite/gcc.target/i386/pr57777.c new file mode 100644 index 00000000000..9c1a392aa9b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr57777.c @@ -0,0 +1,13 @@ +/* PR target/57777 */ +/* { dg-do assemble { target avx2 } } */ +/* { dg-options "-O3 -mavx2" } */ +/* { dg-additional-options "-fpic" { target fpic } } */ + +void +foo (unsigned long *x, int *y) +{ + static unsigned long b[2] = { 0x0UL, 0x9908b0dfUL }; + int c; + for (c = 0; c < 512; c++) + x[c] = b[x[c] & 1UL]; +} diff --git a/gcc/testsuite/gcc.target/i386/pr60909.c b/gcc/testsuite/gcc.target/i386/pr60909.c new file mode 100644 index 00000000000..5a1ac3c0f6c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr60909.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-mrdrnd" } */ + +extern void bar (int); + +void +foo (unsigned *u) +{ + int i = __builtin_ia32_rdrand32_step (u); + bar (i); +} diff --git a/gcc/testsuite/gfortran.dg/array_constructor_41.f90 b/gcc/testsuite/gfortran.dg/array_constructor_41.f90 new file mode 100644 index 00000000000..eb5fd92a1ee --- /dev/null +++ b/gcc/testsuite/gfortran.dg/array_constructor_41.f90 @@ -0,0 +1,33 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! Test fix for PR55789 +! +! Contributed by Joost VandVandole <Joost.VandeVondele@mat.ethz.ch> +! +MODULE M1 +CONTAINS + SUBROUTINE cp_1d_i4_sort(arr) + INTEGER(kind=4), DIMENSION(:), & + INTENT(inout) :: arr + arr = (/ (i, i = 1, SIZE(arr)) /) + END SUBROUTINE +END MODULE M1 + +PROGRAM TEST + USE M1 + INTEGER :: arr(1) + INTERFACE + SUBROUTINE mtrace() BIND(C,name="mtrace") + END SUBROUTINE + END INTERFACE + INTERFACE + SUBROUTINE muntrace() BIND(C,name="muntrace") + END SUBROUTINE + END INTERFACE + CALL mtrace() + CALL cp_1d_i4_sort(arr) + CALL muntrace() +END + +! { dg-final { scan-tree-dump-times "realloc" 0 "original" } } +! { dg-final { cleanup-tree-dump "original" } } diff --git a/gcc/testsuite/gfortran.dg/arrayio_13.f90 b/gcc/testsuite/gfortran.dg/arrayio_13.f90 new file mode 100644 index 00000000000..92a856bc869 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/arrayio_13.f90 @@ -0,0 +1,14 @@ +! { dg-do run } +! PR60810 Bogus end-of-file +program readstrlist + character(len=80), dimension(2) :: ver + integer :: a, b, c + a = 1 + b = 2 + c = 3 + ver(1) = '285 383' + ver(2) = '985' + read( ver, *) a, b, c + if (a /= 285 .or. b /= 383 .or. c /= 985) call abort + !write ( *, *) a, b, c +end diff --git a/gcc/testsuite/gfortran.dg/associate_13.f90 b/gcc/testsuite/gfortran.dg/associate_13.f90 new file mode 100644 index 00000000000..7c64d3f0aa7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_13.f90 @@ -0,0 +1,21 @@ +! { dg-do run } +! +! Tests the fix for PR56047. This is actually a development of +! the test case of comment #10. +! +! Reported by Juergen Reuter <juergen.reuter@desy.de> +! + implicit none + type :: process_variant_def_t + integer :: i + end type + type :: process_component_def_t + class(process_variant_def_t), allocatable :: variant_def + end type + type(process_component_def_t), dimension(1:2) :: initial + allocate (initial(1)%variant_def, source = process_variant_def_t (99)) + associate (template => initial(1)%variant_def) + template%i = 77 + end associate + if (initial(1)%variant_def%i .ne. 77) call abort +end diff --git a/gcc/testsuite/gfortran.dg/associate_14.f90 b/gcc/testsuite/gfortran.dg/associate_14.f90 new file mode 100644 index 00000000000..765e36520c6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_14.f90 @@ -0,0 +1,56 @@ +! { dg-do compile } +! Tests the fix for PR55984. +! +! Contributed by Sylwester Arabas <slayoo@staszic.waw.pl> +! +module bcd_m + type, abstract :: bcd_t + contains + procedure(bcd_fill_halos), deferred :: fill_halos + end type + abstract interface + subroutine bcd_fill_halos(this) + import :: bcd_t + class(bcd_t ) :: this + end subroutine + end interface +end module + +module solver_m + use bcd_m + type, abstract :: solver_t + integer :: n, hlo + class(bcd_t), pointer :: bcx, bcy + contains + procedure(solver_advop), deferred :: advop + end type + abstract interface + subroutine solver_advop(this) + import solver_t + class(solver_t) :: this + end subroutine + end interface + contains +end module + +module solver_mpdata_m + use solver_m + type :: mpdata_t + class(bcd_t), pointer :: bcx, bcy + contains + procedure :: advop => mpdata_advop + end type + contains + subroutine mpdata_advop(this) + class(mpdata_t) :: this + associate ( bcx => this%bcx, bcy => this%bcy ) + call bcx%fill_halos() + end associate + end subroutine +end module + + use solver_mpdata_m + class(mpdata_t), allocatable :: that + call mpdata_advop (that) +end + diff --git a/gcc/testsuite/gfortran.dg/ichar_3.f90 b/gcc/testsuite/gfortran.dg/ichar_3.f90 new file mode 100644 index 00000000000..d0f5c8b8cf8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ichar_3.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! +! PR fortran/59599 +! The call to ichar was triggering an ICE. +! +! Original testcase from Fran Martinez Fadrique <fmartinez@gmv.com> + +character(1) cpk(2) +integer res(2) +cpk = 'a' +res = ichar( cpk, kind=1 ) +print *, ichar( cpk, kind=1 ) +end diff --git a/gcc/testsuite/gfortran.dg/implicit_pure_4.f90 b/gcc/testsuite/gfortran.dg/implicit_pure_4.f90 new file mode 100644 index 00000000000..8563dd72108 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/implicit_pure_4.f90 @@ -0,0 +1,22 @@ +! { dg-do compile } +! +! PR fortran/60543 +! PR fortran/60283 +! +module m +contains + REAL(8) FUNCTION random() + CALL RANDOM_NUMBER(random) + END FUNCTION random + REAL(8) FUNCTION random2() + block + block + block + CALL RANDOM_NUMBER(random2) + end block + end block + end block + END FUNCTION random2 +end module m + +! { dg-final { scan-module-absence "m" "IMPLICIT_PURE" } } diff --git a/gcc/testsuite/gfortran.dg/init_flag_12.f90 b/gcc/testsuite/gfortran.dg/init_flag_12.f90 new file mode 100644 index 00000000000..5844398d534 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/init_flag_12.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } +! { dg-options "-fno-automatic -finit-local-zero" } +! +! PR 55907: [4.7/4.8/4.9 Regression] ICE with -fno-automatic -finit-local-zero +! +! Contributed by J.R. Garcia <garcia.espinosa.jr@gmail.com> + +subroutine cchaine (i) + implicit none + integer :: i + character(len=i) :: chaine + write(*,*) chaine +end subroutine diff --git a/gcc/testsuite/gfortran.dg/list_read_12.f90 b/gcc/testsuite/gfortran.dg/list_read_12.f90 new file mode 100644 index 00000000000..811ef152a5b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/list_read_12.f90 @@ -0,0 +1,11 @@ +! { dg-do run } +! PR58324 Bogus end of file condition +integer :: i, ios +open(99, access='stream', form='unformatted') +write(99) "5 a" +close(99) + +open(99, access='sequential', form='formatted') +read(99, *, iostat=ios) i +if (ios /= 0) call abort +end diff --git a/gcc/testsuite/gfortran.dg/shape_8.f90 b/gcc/testsuite/gfortran.dg/shape_8.f90 new file mode 100644 index 00000000000..edeb5fd8e93 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/shape_8.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! +! PR 60450: [4.7/4.8 Regression] ICE with SHAPE intrinsic +! +! Contributed by Dave Allured <dave.allured@noaa.gov> + + real, allocatable :: x(:,:) + allocate (x(3,2), source=99.) + print *, shape (x / 10.0) +end diff --git a/gcc/testsuite/gfortran.dg/str_comp_optimize_1.f90 b/gcc/testsuite/gfortran.dg/str_comp_optimize_1.f90 new file mode 100644 index 00000000000..84287b475a5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/str_comp_optimize_1.f90 @@ -0,0 +1,22 @@ +! { dg-do compile } +! { dg-options "-ffrontend-optimize" } +! +! PR fortran/60341 +! An unguarded union access was wrongly enabling a frontend optimization on a +! string comparison, leading to an ICE. +! +! Original testcase from Steve Chapel <steve.chapel@a2pg.com>. +! Reduced by Steven G. Kargl <kargl@gcc.gnu.org>. +! + + subroutine modelg(ncm) + implicit none + integer, parameter :: pc = 30, pm = pc - 1 + integer i + character*4 catt(pm,2) + integer ncm,iatt(pm,pc) + do i=1,ncm + if (catt(i,1)//catt(i,2).eq.'central') exit + end do + iatt(i,4)=1 + end diff --git a/gcc/testsuite/gfortran.dg/where_4.f90 b/gcc/testsuite/gfortran.dg/where_4.f90 new file mode 100644 index 00000000000..1ff2e4ca31a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/where_4.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! PR 60522 - this used to ICE. +! Original test case Roger Ferrer Ibanez +subroutine foo(a, b) + implicit none + integer, dimension(:), intent(inout) :: a + integer, dimension(:), intent(in) :: b + + where (b(:) > 0) + where (b(:) > 100) + a(lbound(a, 1):ubound(a, 1)) = b(lbound(b, 1):ubound(b, 1)) * b(lbound(b, 1):ubound(b, 1)) - 100 + elsewhere + a(lbound(a, 1):ubound(a, 1)) = b(lbound(b, 1):ubound(b, 1)) * b(lbound(b, 1):ubound(b, 1)) + end where + elsewhere + a(lbound(a, 1):ubound(a, 1)) = - b(lbound(b, 1):ubound(b, 1)) * b(lbound(b, 1):ubound(b, 1)) + end where +end subroutine foo diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/pr57517.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/pr57517.f90 new file mode 100644 index 00000000000..f32698aa3a6 --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/compile/pr57517.f90 @@ -0,0 +1,13 @@ +SUBROUTINE cal_helicity (uh, ph, phb, wavg, ims, ime, its, ite) + INTEGER, INTENT( IN ) :: ims, ime, its, ite + REAL, DIMENSION( ims:ime), INTENT( IN ) :: ph, phb, wavg + REAL, DIMENSION( ims:ime), INTENT( INOUT ) :: uh + INTEGER :: i + REAL :: zu + DO i = its, ite + zu = (ph(i ) + phb(i)) + (ph(i-1) + phb(i-1)) + IF (wavg(i) .GT. 0) THEN + uh(i) = uh(i) + zu + ENDIF + END DO +END SUBROUTINE cal_helicity diff --git a/gcc/testsuite/gnat.dg/aliasing1.adb b/gcc/testsuite/gnat.dg/aliasing1.adb index b2b7d123b1f..bffc4225b47 100644 --- a/gcc/testsuite/gnat.dg/aliasing1.adb +++ b/gcc/testsuite/gnat.dg/aliasing1.adb @@ -18,5 +18,5 @@ package body Aliasing1 is end Aliasing1; --- { dg-final { scan-tree-dump-not "__gnat_rcheck" "optimized" } } +-- { dg-final { scan-tree-dump-not "gnat_rcheck" "optimized" } } -- { dg-final { cleanup-tree-dump "optimized" } } diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index c4a1ffa4ef3..cfdf7aa4dce 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -109,7 +109,6 @@ static int locus_map_eq (const void *, const void *); static void assign_discriminator (location_t, basic_block); static edge gimple_redirect_edge_and_branch (edge, basic_block); static edge gimple_try_redirect_by_replacing_jump (edge, basic_block); -static unsigned int split_critical_edges (void); /* Various helpers. */ static inline bool stmt_starts_bb_p (gimple, gimple); @@ -7399,7 +7398,7 @@ struct cfg_hooks gimple_cfg_hooks = { /* Split all critical edges. */ -static unsigned int +unsigned int split_critical_edges (void) { basic_block bb; diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 0ecec816b6a..3bcca2b31f3 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -713,9 +713,9 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, HOST_WIDE_INT bitsize = -1; HOST_WIDE_INT maxsize = -1; tree size_tree = NULL_TREE; - HOST_WIDE_INT bit_offset = 0; + double_int bit_offset = double_int_zero; + HOST_WIDE_INT hbit_offset; bool seen_variable_array_ref = false; - tree base_type; /* First get the final access size from just the outermost expression. */ if (TREE_CODE (exp) == COMPONENT_REF) @@ -746,12 +746,12 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, and find the ultimate containing object. */ while (1) { - base_type = TREE_TYPE (exp); - switch (TREE_CODE (exp)) { case BIT_FIELD_REF: - bit_offset += TREE_INT_CST_LOW (TREE_OPERAND (exp, 2)); + bit_offset + = double_int_add (bit_offset, + tree_to_double_int (TREE_OPERAND (exp, 2))); break; case COMPONENT_REF: @@ -759,22 +759,23 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, tree field = TREE_OPERAND (exp, 1); tree this_offset = component_ref_field_offset (exp); - if (this_offset - && TREE_CODE (this_offset) == INTEGER_CST - && host_integerp (this_offset, 0)) + if (this_offset && TREE_CODE (this_offset) == INTEGER_CST) { - HOST_WIDE_INT hthis_offset = TREE_INT_CST_LOW (this_offset); - hthis_offset *= BITS_PER_UNIT; - hthis_offset - += TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)); - bit_offset += hthis_offset; + double_int doffset = tree_to_double_int (this_offset); + doffset = double_int_lshift (doffset, + BITS_PER_UNIT == 8 + ? 3 : exact_log2 (BITS_PER_UNIT), + HOST_BITS_PER_DOUBLE_INT, true); + doffset = double_int_add (doffset, + tree_to_double_int + (DECL_FIELD_BIT_OFFSET (field))); + bit_offset = double_int_add (bit_offset, doffset); /* If we had seen a variable array ref already and we just referenced the last field of a struct or a union member then we have to adjust maxsize by the padding at the end of our field. */ - if (seen_variable_array_ref - && maxsize != -1) + if (seen_variable_array_ref && maxsize != -1) { tree stype = TREE_TYPE (TREE_OPERAND (exp, 0)); tree next = DECL_CHAIN (field); @@ -786,10 +787,12 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, tree fsize = DECL_SIZE_UNIT (field); tree ssize = TYPE_SIZE_UNIT (stype); if (host_integerp (fsize, 0) - && host_integerp (ssize, 0)) + && host_integerp (ssize, 0) + && double_int_fits_in_shwi_p (doffset)) maxsize += ((TREE_INT_CST_LOW (ssize) - TREE_INT_CST_LOW (fsize)) - * BITS_PER_UNIT - hthis_offset); + * BITS_PER_UNIT + - double_int_to_shwi (doffset)); else maxsize = -1; } @@ -801,8 +804,12 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, /* We need to adjust maxsize to the whole structure bitsize. But we can subtract any constant offset seen so far, because that would get us out of the structure otherwise. */ - if (maxsize != -1 && csize && host_integerp (csize, 1)) - maxsize = TREE_INT_CST_LOW (csize) - bit_offset; + if (maxsize != -1 + && csize + && host_integerp (csize, 1) + && double_int_fits_in_shwi_p (bit_offset)) + maxsize = TREE_INT_CST_LOW (csize) + - double_int_to_shwi (bit_offset); else maxsize = -1; } @@ -817,18 +824,23 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, /* If the resulting bit-offset is constant, track it. */ if (TREE_CODE (index) == INTEGER_CST - && host_integerp (index, 0) && (low_bound = array_ref_low_bound (exp), - host_integerp (low_bound, 0)) + TREE_CODE (low_bound) == INTEGER_CST) && (unit_size = array_ref_element_size (exp), - host_integerp (unit_size, 1))) + TREE_CODE (unit_size) == INTEGER_CST)) { - HOST_WIDE_INT hindex = TREE_INT_CST_LOW (index); - - hindex -= TREE_INT_CST_LOW (low_bound); - hindex *= TREE_INT_CST_LOW (unit_size); - hindex *= BITS_PER_UNIT; - bit_offset += hindex; + double_int doffset + = double_int_sext + (double_int_sub (TREE_INT_CST (index), + TREE_INT_CST (low_bound)), + TYPE_PRECISION (TREE_TYPE (index))); + doffset = double_int_mul (doffset, + tree_to_double_int (unit_size)); + doffset = double_int_lshift (doffset, + BITS_PER_UNIT == 8 + ? 3 : exact_log2 (BITS_PER_UNIT), + HOST_BITS_PER_DOUBLE_INT, true); + bit_offset = double_int_add (bit_offset, doffset); /* An array ref with a constant index up in the structure hierarchy will constrain the size of any variable array ref @@ -841,8 +853,12 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, /* We need to adjust maxsize to the whole array bitsize. But we can subtract any constant offset seen so far, because that would get us outside of the array otherwise. */ - if (maxsize != -1 && asize && host_integerp (asize, 1)) - maxsize = TREE_INT_CST_LOW (asize) - bit_offset; + if (maxsize != -1 + && asize + && host_integerp (asize, 1) + && double_int_fits_in_shwi_p (bit_offset)) + maxsize = TREE_INT_CST_LOW (asize) + - double_int_to_shwi (bit_offset); else maxsize = -1; @@ -857,13 +873,45 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, break; case IMAGPART_EXPR: - bit_offset += bitsize; + bit_offset + = double_int_add (bit_offset, uhwi_to_double_int (bitsize)); break; case VIEW_CONVERT_EXPR: break; + case TARGET_MEM_REF: + /* Via the variable index or index2 we can reach the + whole object. Still hand back the decl here. */ + if (TREE_CODE (TMR_BASE (exp)) == ADDR_EXPR + && (TMR_INDEX (exp) || TMR_INDEX2 (exp))) + { + exp = TREE_OPERAND (TMR_BASE (exp), 0); + bit_offset = double_int_zero; + maxsize = -1; + goto done; + } + /* Fallthru. */ case MEM_REF: + /* We need to deal with variable arrays ending structures such as + struct { int length; int a[1]; } x; x.a[d] + struct { struct { int a; int b; } a[1]; } x; x.a[d].a + struct { struct { int a[1]; } a[1]; } x; x.a[0][d], x.a[d][0] + struct { int len; union { int a[1]; struct X x; } u; } x; x.u.a[d] + where we do not know maxsize for variable index accesses to + the array. The simplest way to conservatively deal with this + is to punt in the case that offset + maxsize reaches the + base type boundary. This needs to include possible trailing + padding that is there for alignment purposes. */ + if (seen_variable_array_ref + && maxsize != -1 + && (!double_int_fits_in_shwi_p (bit_offset) + || !host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1) + || (double_int_to_shwi (bit_offset) + maxsize + == (HOST_WIDE_INT) TREE_INT_CST_LOW + (TYPE_SIZE (TREE_TYPE (exp)))))) + maxsize = -1; + /* Hand back the decl for MEM[&decl, off]. */ if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR) { @@ -876,74 +924,45 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, BITS_PER_UNIT == 8 ? 3 : exact_log2 (BITS_PER_UNIT), HOST_BITS_PER_DOUBLE_INT, true); - off = double_int_add (off, shwi_to_double_int (bit_offset)); + off = double_int_add (off, bit_offset); if (double_int_fits_in_shwi_p (off)) { - bit_offset = double_int_to_shwi (off); + bit_offset = off; exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); } } } goto done; - case TARGET_MEM_REF: - /* Hand back the decl for MEM[&decl, off]. */ - if (TREE_CODE (TMR_BASE (exp)) == ADDR_EXPR) - { - /* Via the variable index or index2 we can reach the - whole object. */ - if (TMR_INDEX (exp) || TMR_INDEX2 (exp)) - { - exp = TREE_OPERAND (TMR_BASE (exp), 0); - bit_offset = 0; - maxsize = -1; - goto done; - } - if (integer_zerop (TMR_OFFSET (exp))) - exp = TREE_OPERAND (TMR_BASE (exp), 0); - else - { - double_int off = mem_ref_offset (exp); - off = double_int_lshift (off, - BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT), - HOST_BITS_PER_DOUBLE_INT, true); - off = double_int_add (off, shwi_to_double_int (bit_offset)); - if (double_int_fits_in_shwi_p (off)) - { - bit_offset = double_int_to_shwi (off); - exp = TREE_OPERAND (TMR_BASE (exp), 0); - } - } - } - goto done; - default: goto done; } exp = TREE_OPERAND (exp, 0); } - done: - - /* We need to deal with variable arrays ending structures such as - struct { int length; int a[1]; } x; x.a[d] - struct { struct { int a; int b; } a[1]; } x; x.a[d].a - struct { struct { int a[1]; } a[1]; } x; x.a[0][d], x.a[d][0] - struct { int len; union { int a[1]; struct X x; } u; } x; x.u.a[d] - where we do not know maxsize for variable index accesses to - the array. The simplest way to conservatively deal with this - is to punt in the case that offset + maxsize reaches the - base type boundary. This needs to include possible trailing padding - that is there for alignment purposes. */ + /* We need to deal with variable arrays ending structures. */ if (seen_variable_array_ref && maxsize != -1 - && (!host_integerp (TYPE_SIZE (base_type), 1) - || (bit_offset + maxsize - == (signed) TREE_INT_CST_LOW (TYPE_SIZE (base_type))))) + && (!double_int_fits_in_shwi_p (bit_offset) + || !host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1) + || (double_int_to_shwi (bit_offset) + maxsize + == (HOST_WIDE_INT) + TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp)))))) maxsize = -1; + done: + if (!double_int_fits_in_shwi_p (bit_offset)) + { + *poffset = 0; + *psize = bitsize; + *pmax_size = -1; + + return exp; + } + + hbit_offset = double_int_to_shwi (bit_offset); + /* In case of a decl or constant base object we can do better. */ if (DECL_P (exp)) @@ -952,7 +971,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, base decl. */ if (maxsize == -1 && host_integerp (DECL_SIZE (exp), 1)) - maxsize = TREE_INT_CST_LOW (DECL_SIZE (exp)) - bit_offset; + maxsize = TREE_INT_CST_LOW (DECL_SIZE (exp)) - hbit_offset; } else if (CONSTANT_CLASS_P (exp)) { @@ -960,13 +979,13 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, base type constant. */ if (maxsize == -1 && host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1)) - maxsize = TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))) - bit_offset; + maxsize = TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))) - hbit_offset; } /* ??? Due to negative offsets in ARRAY_REF we can end up with negative bit_offset here. We might want to store a zero offset in this case. */ - *poffset = bit_offset; + *poffset = hbit_offset; *psize = bitsize; *pmax_size = maxsize; diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 319be2bb618..d39abbe5f77 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -466,6 +466,7 @@ extern basic_block move_sese_region_to_fn (struct function *, basic_block, basic_block, tree); void remove_edge_and_dominated_blocks (edge); bool tree_node_can_be_shared (tree); +extern unsigned int split_critical_edges (void); /* In tree-cfgcleanup.c */ extern bitmap cfgcleanup_altered_bbs; diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 9d09f0f4d26..316b4e2d57d 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -758,20 +758,6 @@ if_convertible_stmt_p (gimple stmt, VEC (data_reference_p, heap) *refs) return true; } -/* Return true when BB post-dominates all its predecessors. */ - -static bool -bb_postdominates_preds (basic_block bb) -{ - unsigned i; - - for (i = 0; i < EDGE_COUNT (bb->preds); i++) - if (!dominated_by_p (CDI_POST_DOMINATORS, EDGE_PRED (bb, i)->src, bb)) - return false; - - return true; -} - /* Return true when BB is if-convertible. This routine does not check basic block's statements and phis. @@ -830,10 +816,23 @@ if_convertible_bb_p (struct loop *loop, basic_block bb, basic_block exit_bb) return false; } - if (EDGE_COUNT (bb->preds) == 2 - && bb != loop->header - && !bb_postdominates_preds (bb)) - return false; + /* At least one incoming edge has to be non-critical as otherwise edge + predicates are not equal to basic-block predicates of the edge + source. */ + if (EDGE_COUNT (bb->preds) > 1 + && bb != loop->header) + { + bool found = false; + FOR_EACH_EDGE (e, ei, bb->preds) + if (EDGE_COUNT (e->src->succs) == 1) + found = true; + if (!found) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "only critical predecessors\n"); + return false; + } + } return true; } @@ -1048,7 +1047,6 @@ if_convertible_loop_p_1 (struct loop *loop, return false; calculate_dominance_info (CDI_DOMINATORS); - calculate_dominance_info (CDI_POST_DOMINATORS); /* Allow statements that can be handled during if-conversion. */ ifc_bbs = get_loop_body_in_if_conv_order (loop); @@ -1184,8 +1182,7 @@ if_convertible_loop_p (struct loop *loop) if-conversion. */ static basic_block -find_phi_replacement_condition (struct loop *loop, - basic_block bb, tree *cond, +find_phi_replacement_condition (basic_block bb, tree *cond, gimple_stmt_iterator *gsi) { edge first_edge, second_edge; @@ -1195,34 +1192,10 @@ find_phi_replacement_condition (struct loop *loop, first_edge = EDGE_PRED (bb, 0); second_edge = EDGE_PRED (bb, 1); - /* Use condition based on following criteria: - 1) - S1: x = !c ? a : b; - - S2: x = c ? b : a; - - S2 is preferred over S1. Make 'b' first_bb and use its condition. - - 2) Do not make loop header first_bb. - - 3) - S1: x = !(c == d)? a : b; - - S21: t1 = c == d; - S22: x = t1 ? b : a; - - S3: x = (c == d) ? b : a; - - S3 is preferred over S1 and S2*, Make 'b' first_bb and use - its condition. - - 4) If pred B is dominated by pred A then use pred B's condition. - See PR23115. */ - - /* Select condition that is not TRUTH_NOT_EXPR. */ + /* Prefer an edge with a not negated predicate. + ??? That's a very weak cost model. */ tmp_cond = bb_predicate (first_edge->src); gcc_assert (tmp_cond); - if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR) { edge tmp_edge; @@ -1232,11 +1205,9 @@ find_phi_replacement_condition (struct loop *loop, second_edge = tmp_edge; } - /* Check if FIRST_BB is loop header or not and make sure that - FIRST_BB does not dominate SECOND_BB. */ - if (first_edge->src == loop->header - || dominated_by_p (CDI_DOMINATORS, - second_edge->src, first_edge->src)) + /* Check if the edge we take the condition from is not critical. + We know that at least one non-critical edge exists. */ + if (EDGE_COUNT (first_edge->src->succs) > 1) { *cond = bb_predicate (second_edge->src); @@ -1311,9 +1282,6 @@ predicate_scalar_phi (gimple phi, tree cond, arg_1 = gimple_phi_arg_def (phi, 1); } - gcc_checking_assert (bb == bb->loop_father->header - || bb_postdominates_preds (bb)); - /* Build new RHS using selected condition and arguments. */ rhs = build3 (COND_EXPR, TREE_TYPE (res), unshare_expr (cond), arg_0, arg_1); @@ -1359,7 +1327,7 @@ predicate_all_scalar_phis (struct loop *loop) /* BB has two predecessors. Using predecessor's aux field, set appropriate condition for the PHI node replacement. */ gsi = gsi_after_labels (bb); - true_bb = find_phi_replacement_condition (loop, bb, &cond, &gsi); + true_bb = find_phi_replacement_condition (bb, &cond, &gsi); while (!gsi_end_p (phi_gsi)) { @@ -1791,8 +1759,6 @@ main_tree_if_conversion (void) if (changed && flag_tree_loop_if_convert_stores) todo |= TODO_update_ssa_only_virtuals; - free_dominance_info (CDI_POST_DOMINATORS); - return todo; } diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c index 1566902e3d7..61a1c741d1c 100644 --- a/gcc/tree-predcom.c +++ b/gcc/tree-predcom.c @@ -2117,7 +2117,11 @@ combinable_refs_p (dref r1, dref r2, stmt = find_common_use_stmt (&name1, &name2); - if (!stmt) + if (!stmt + /* A simple post-dominance check - make sure the combination + is executed under the same condition as the references. */ + || (gimple_bb (stmt) != gimple_bb (r1->stmt) + && gimple_bb (stmt) != gimple_bb (r2->stmt))) return false; acode = gimple_assign_rhs_code (stmt); diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c index ace9ef9972d..bb1ef08ece8 100644 --- a/gcc/tree-ssa-dce.c +++ b/gcc/tree-ssa-dce.c @@ -576,6 +576,11 @@ mark_aliased_reaching_defs_necessary_1 (ao_ref *ref, tree vdef, void *data) in the references (gcc.c-torture/execute/pr42142.c). The simplest way is to check if the kill dominates the use. */ + /* But when both are in the same block we cannot + easily tell whether we came from a backedge + unless we decide to compute stmt UIDs + (see PR58246). */ + && (basic_block) data != gimple_bb (def_stmt) && dominated_by_p (CDI_DOMINATORS, (basic_block) data, gimple_bb (def_stmt)) && operand_equal_p (ref->ref, lhs, 0)) @@ -1305,26 +1310,19 @@ eliminate_unnecessary_stmts (void) stats.total++; /* We can mark a call to free as not necessary if the - defining statement of its argument is an allocation - function and that is not necessary itself. */ - if (gimple_call_builtin_p (stmt, BUILT_IN_FREE)) + defining statement of its argument is not necessary + (and thus is getting removed). */ + if (gimple_plf (stmt, STMT_NECESSARY) + && gimple_call_builtin_p (stmt, BUILT_IN_FREE)) { tree ptr = gimple_call_arg (stmt, 0); - tree callee2; - gimple def_stmt; - if (TREE_CODE (ptr) != SSA_NAME) - continue; - def_stmt = SSA_NAME_DEF_STMT (ptr); - if (!is_gimple_call (def_stmt) - || gimple_plf (def_stmt, STMT_NECESSARY)) - continue; - callee2 = gimple_call_fndecl (def_stmt); - if (callee2 == NULL_TREE - || DECL_BUILT_IN_CLASS (callee2) != BUILT_IN_NORMAL - || (DECL_FUNCTION_CODE (callee2) != BUILT_IN_MALLOC - && DECL_FUNCTION_CODE (callee2) != BUILT_IN_CALLOC)) - continue; - gimple_set_plf (stmt, STMT_NECESSARY, false); + if (TREE_CODE (ptr) == SSA_NAME) + { + gimple def_stmt = SSA_NAME_DEF_STMT (ptr); + if (!gimple_nop_p (def_stmt) + && !gimple_plf (def_stmt, STMT_NECESSARY)) + gimple_set_plf (stmt, STMT_NECESSARY, false); + } } /* If GSI is not necessary then remove it. */ diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 15ea06b8b9b..9c02122295f 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2068,7 +2068,8 @@ chain_of_csts_start (struct loop *loop, tree x) return NULL; } - if (gimple_code (stmt) != GIMPLE_ASSIGN) + if (gimple_code (stmt) != GIMPLE_ASSIGN + || gimple_assign_rhs_class (stmt) == GIMPLE_TERNARY_RHS) return NULL; code = gimple_assign_rhs_code (stmt); @@ -2136,7 +2137,7 @@ get_val_for (tree x, tree base) { gimple stmt; - gcc_assert (is_gimple_min_invariant (base)); + gcc_checking_assert (is_gimple_min_invariant (base)); if (!x) return base; @@ -2145,7 +2146,7 @@ get_val_for (tree x, tree base) if (gimple_code (stmt) == GIMPLE_PHI) return base; - gcc_assert (is_gimple_assign (stmt)); + gcc_checking_assert (is_gimple_assign (stmt)); /* STMT must be either an assignment of a single SSA name or an expression involving an SSA name and a constant. Try to fold that diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index 30644372564..7dd94a4f566 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -314,6 +314,12 @@ propagate_with_phi (basic_block bb, gimple phi, struct phiprop_d *phivn, gimple def_stmt; tree vuse; + /* Only replace loads in blocks that post-dominate the PHI node. That + makes sure we don't end up speculating loads. */ + if (!dominated_by_p (CDI_POST_DOMINATORS, + bb, gimple_bb (use_stmt))) + continue; + /* Check whether this is a load of *ptr. */ if (!(is_gimple_assign (use_stmt) && TREE_CODE (gimple_assign_lhs (use_stmt)) == SSA_NAME @@ -385,6 +391,7 @@ tree_ssa_phiprop (void) size_t n; calculate_dominance_info (CDI_DOMINATORS); + calculate_dominance_info (CDI_POST_DOMINATORS); n = num_ssa_names; phivn = XCNEWVEC (struct phiprop_d, n); @@ -402,6 +409,8 @@ tree_ssa_phiprop (void) VEC_free (basic_block, heap, bbs); free (phivn); + free_dominance_info (CDI_POST_DOMINATORS); + return 0; } diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 727614a4215..4f710515a08 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -1756,39 +1756,26 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, case NAME: { - gimple phi = NULL; - edge e; - gimple def_stmt; tree name = PRE_EXPR_NAME (expr); - - def_stmt = SSA_NAME_DEF_STMT (name); + gimple def_stmt = SSA_NAME_DEF_STMT (name); + /* If the SSA name is defined by a PHI node in this block, + translate it. */ if (gimple_code (def_stmt) == GIMPLE_PHI && gimple_bb (def_stmt) == phiblock) - phi = def_stmt; - else - return expr; - - e = find_edge (pred, gimple_bb (phi)); - if (e) { - tree def = PHI_ARG_DEF (phi, e->dest_idx); - pre_expr newexpr; - - if (TREE_CODE (def) == SSA_NAME) - def = VN_INFO (def)->valnum; + edge e = find_edge (pred, gimple_bb (def_stmt)); + tree def = PHI_ARG_DEF (def_stmt, e->dest_idx); /* Handle constant. */ if (is_gimple_min_invariant (def)) return get_or_alloc_expr_for_constant (def); - if (TREE_CODE (def) == SSA_NAME && ssa_undefined_value_p (def)) - return NULL; - - newexpr = get_or_alloc_expr_for_name (def); - return newexpr; + return get_or_alloc_expr_for_name (def); } + /* Otherwise return it unchanged - it will get cleaned if its + value is not available in PREDs AVAIL_OUT set of expressions. */ + return expr; } - return expr; default: gcc_unreachable (); diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index c2bd59d6416..1e4dc14434d 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -2483,6 +2483,7 @@ static inline bool set_ssa_val_to (tree from, tree to) { tree currval = SSA_VAL (from); + HOST_WIDE_INT toff, coff; if (from != to) { @@ -2518,7 +2519,17 @@ set_ssa_val_to (tree from, tree to) print_generic_expr (dump_file, to, 0); } - if (currval != to && !operand_equal_p (currval, to, OEP_PURE_SAME)) + if (currval != to + && !operand_equal_p (currval, to, OEP_PURE_SAME) + /* ??? For addresses involving volatile objects or types operand_equal_p + does not reliably detect ADDR_EXPRs as equal. We know we are only + getting invariant gimple addresses here, so can use + get_addr_base_and_unit_offset to do this comparison. */ + && !(TREE_CODE (currval) == ADDR_EXPR + && TREE_CODE (to) == ADDR_EXPR + && (get_addr_base_and_unit_offset (TREE_OPERAND (currval, 0), &coff) + == get_addr_base_and_unit_offset (TREE_OPERAND (to, 0), &toff)) + && coff == toff)) { VN_INFO (from)->valnum = to; if (dump_file && (dump_flags & TDF_DETAILS)) diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c index d42b46a1801..0222dac1a4a 100644 --- a/gcc/tree-ssa-sink.c +++ b/gcc/tree-ssa-sink.c @@ -412,7 +412,15 @@ statement_sink_location (gimple stmt, basic_block frombb, && gimple_vdef (use_stmt) && operand_equal_p (gimple_assign_lhs (stmt), gimple_assign_lhs (use_stmt), 0)) - continue; + { + /* If use_stmt is or might be a nop assignment then USE_STMT + acts as a use as well as definition. */ + if (stmt != use_stmt + && ref_maybe_used_by_stmt_p (use_stmt, + gimple_assign_lhs (stmt))) + return false; + continue; + } if (gimple_code (use_stmt) != GIMPLE_PHI) return false; @@ -628,7 +636,7 @@ static void execute_sink_code (void) { loop_optimizer_init (LOOPS_NORMAL); - + split_critical_edges (); connect_infinite_loops_to_exit (); memset (&sink_stats, 0, sizeof (sink_stats)); calculate_dominance_info (CDI_DOMINATORS); diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 304c2940576..532bdac3faa 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -1693,7 +1693,7 @@ handle_char_store (gimple_stmt_iterator *gsi) its length may be decreased. */ adjust_last_stmt (si, stmt, false); } - else if (si != NULL) + else if (si != NULL && integer_zerop (gimple_assign_rhs1 (stmt))) { si = unshare_strinfo (si); si->length = build_int_cst (size_type_node, 0); @@ -1896,6 +1896,29 @@ strlen_enter_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, int count_vdef = 100; do_invalidate (dombb, phi, visited, &count_vdef); BITMAP_FREE (visited); + if (count_vdef == 0) + { + /* If there were too many vdefs in between immediate + dominator and current bb, invalidate everything. + If stridx_to_strinfo has been unshared, we need + to free it, otherwise just set it to NULL. */ + if (!strinfo_shared ()) + { + unsigned int i; + strinfo si; + + for (i = 1; + VEC_iterate (strinfo, stridx_to_strinfo, i, si); + ++i) + { + free_strinfo (si); + VEC_replace (strinfo, stridx_to_strinfo, + i, NULL); + } + } + else + stridx_to_strinfo = NULL; + } break; } } diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index 42eb9243252..f14ee439575 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -133,7 +133,7 @@ make_ssa_name_fn (struct function *fn, tree var, gimple stmt) /* The node was cleared out when we put it on the free list, so there is no need to do so again here. */ - gcc_assert (ssa_name (SSA_NAME_VERSION (t)) == NULL); + gcc_assert (VEC_index (tree, SSANAMES (fn), SSA_NAME_VERSION (t)) == NULL); VEC_replace (tree, SSANAMES (fn), SSA_NAME_VERSION (t), t); } else diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index f07297e86c9..e5387008b8b 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -576,6 +576,11 @@ find_tail_calls (basic_block bb, struct tailcall **ret) if (!tail_recursion && (m || a)) return; + /* For pointers don't allow additions or multiplications. */ + if ((m || a) + && POINTER_TYPE_P (TREE_TYPE (DECL_RESULT (current_function_decl)))) + return; + nw = XNEW (struct tailcall); nw->call_gsi = gsi; diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 0faf1a93c9d..07253ec011d 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -2332,6 +2332,12 @@ vect_analyze_data_ref_access (struct data_reference *dr) if (loop_vinfo && dr_step == 0) { GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) = NULL; + if (nested_in_vect_loop_p (loop, stmt)) + { + if (vect_print_dump_info (REPORT_DETAILS)) + fprintf (vect_dump, "zero step in inner loop of nest"); + return false; + } return DR_IS_READ (dr); } diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index b6f85d8e19c..8dea3cfbd6c 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -1466,7 +1466,7 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp) if (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) || LOOP_VINFO_INT_NITERS (loop_vinfo) % vectorization_factor != 0 - || LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo)) + || LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)) { if (vect_print_dump_info (REPORT_DETAILS)) fprintf (vect_dump, "epilog loop required."); @@ -2009,6 +2009,12 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi, || (!check_reduction && flow_loop_nested_p (vect_loop, loop))); name = PHI_RESULT (phi); + /* ??? If there are no uses of the PHI result the inner loop reduction + won't be detected as possibly double-reduction by vectorizable_reduction + because that tries to walk the PHI arg from the preheader edge which + can be constant. See PR60382. */ + if (has_zero_uses (name)) + return NULL; nloop_uses = 0; FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name) { @@ -4158,7 +4164,8 @@ vect_finalize_reduction: result. (The reduction result is expected to have two immediate uses - one at the latch block, and one at the loop exit). */ FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest) - if (!flow_bb_inside_loop_p (loop, gimple_bb (USE_STMT (use_p)))) + if (!flow_bb_inside_loop_p (loop, gimple_bb (USE_STMT (use_p))) + && !is_gimple_debug (USE_STMT (use_p))) VEC_safe_push (gimple, heap, phis, USE_STMT (use_p)); /* We expect to have found an exit_phi because of loop-closed-ssa @@ -4286,7 +4293,10 @@ vect_finalize_reduction: FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest) { if (!flow_bb_inside_loop_p (loop, gimple_bb (USE_STMT (use_p)))) - VEC_safe_push (gimple, heap, phis, USE_STMT (use_p)); + { + if (!is_gimple_debug (USE_STMT (use_p))) + VEC_safe_push (gimple, heap, phis, USE_STMT (use_p)); + } else { if (double_reduc && gimple_code (USE_STMT (use_p)) == GIMPLE_PHI) @@ -4296,7 +4306,8 @@ vect_finalize_reduction: FOR_EACH_IMM_USE_FAST (phi_use_p, phi_imm_iter, phi_res) { if (!flow_bb_inside_loop_p (loop, - gimple_bb (USE_STMT (phi_use_p)))) + gimple_bb (USE_STMT (phi_use_p))) + && !is_gimple_debug (USE_STMT (phi_use_p))) VEC_safe_push (gimple, heap, phis, USE_STMT (phi_use_p)); } diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index a65266c27fa..1bb1775f697 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4536,9 +4536,13 @@ register_edge_assert_for_1 (tree op, enum tree_code code, } else if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (op_def))) { - /* Recurse through the type conversion. */ - retval |= register_edge_assert_for_1 (gimple_assign_rhs1 (op_def), - code, e, bsi); + /* Recurse through the type conversion, unless it is a narrowing + conversion or conversion from non-integral type. */ + tree rhs = gimple_assign_rhs1 (op_def); + if (INTEGRAL_TYPE_P (TREE_TYPE (rhs)) + && (TYPE_PRECISION (TREE_TYPE (rhs)) + <= TYPE_PRECISION (TREE_TYPE (op)))) + retval |= register_edge_assert_for_1 (rhs, code, e, bsi); } return retval; |