diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2018-04-25 13:36:44 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2018-04-25 13:36:44 +0000 |
commit | 9fd777e570c1f99ada82b1dfc1147e7009a0f7b9 (patch) | |
tree | 0525f361046905aeb53f5119315e1f0cd350e462 | |
parent | d0468e277dbf6467436837290db02134ab20f2d1 (diff) |
Merge branches/gcc-7-branch rev 259627.
Change-Id: I562fdd470b8fb23137c91e670eab4f0ba8d87204
167 files changed, 3603 insertions, 865 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dcd28d01e45..b841dafaf6f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,356 @@ +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-04-17 Martin Liska <mliska@suse.cz> + + PR lto/85405 + * ipa-devirt.c (odr_types_equivalent_p): Remove trailing + in message, remote space in between '_G' and '('. + +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-04-17 Jan Hubicka <jh@suse.cz> + + PR lto/85405 + * ipa-devirt.c (odr_types_equivalent_p): Handle bit fields. + +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-03-28 Jakub Jelinek <jakub@redhat.com> + Martin Liska <mliska@suse.cz> + + PR sanitizer/85081 + * gimplify.c (asan_poison_variable): Don't do the check for + gimplify_omp_ctxp here. + (gimplify_decl_expr): Do it here. + (gimplify_target_expr): Likewise. + +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-03-21 Martin Liska <mliska@suse.cz> + + PR ipa/84963 + * ipa-icf.c (sem_item_optimizer::fixup_points_to_sets): Remove + not intended return statement. + +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-03-13 Martin Liska <mliska@suse.cz> + + PR ipa/84658. + * (sem_item_optimizer::sem_item_optimizer): Initialize new + vector. + (sem_item_optimizer::~sem_item_optimizer): Release it. + (sem_item_optimizer::merge_classes): Register variable aliases. + (sem_item_optimizer::fixup_pt_set): New function. + (sem_item_optimizer::fixup_points_to_sets): Likewise. + * ipa-icf.h: Declare new variables and functions. + +2018-04-23 Aaron Sawdey <acsawdey@linux.ibm.com> + + Backport from mainline + 2018-04-16 Aaron Sawdey <acsawdey@linux.ibm.com> + + PR target/83660 + * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Mark + vec_extract expression as having side effects to make sure it gets + a cleanup point. + +2018-04-23 Eric Botcazou <ebotcazou@adacore.com> + + PR middle-end/85496 + * expr.c (store_field): In the bitfield case, if the value comes from + a function call and is returned in registers by means of a PARALLEL, + do not change the mode of the temporary unless BLKmode and VOIDmode. + +2018-04-20 Peter Bergner <bergner@vnet.ibm.com> + + Backport from mainline + 2018-03-09 Peter Bergner <bergner@vnet.ibm.com> + + PR target/83969 + * config/rs6000/rs6000.c (rs6000_offsettable_memref_p): New prototype. + Add strict argument and use it. + (rs6000_split_multireg_move): Update for new strict argument. + (mem_operand_gpr): Disallow all non-offsettable addresses. + * config/rs6000/rs6000.md (*movdi_internal64): Use YZ constraint. + +2018-04-18 Thomas Preud'homme <thomas.preudhomme@arm.com> + + Backport from mainline + 2018-04-11 Thomas Preud'homme <thomas.preudhomme@arm.com> + + PR target/85261 + * config/arm/arm-builtins.c (arm_expand_builtin): Force input operand + into register. + +2018-04-12 Andreas Krebbel <krebbel@linux.vnet.ibm.com> + + Backport from mainline + 2018-04-12 Andreas Krebbel <krebbel@linux.vnet.ibm.com> + + * config/s390/s390.c (s390_output_indirect_thunk_function): Check + also for flag_dwarf2_cfi_asm. + +2018-04-11 Uros Bizjak <ubizjak@gmail.com> + + * config/alpha/alpha.md (stack_probe_internal): Rename + from "probe_stack". Update all callers. + +2018-04-11 Thomas Preud'homme <thomas.preudhomme@arm.com> + + Backport from mainline + 2018-04-04 Thomas Preud'homme <thomas.preudhomme@arm.com> + + PR target/85203 + * config/arm/arm-builtins.c (arm_expand_builtin): Change + expansion to perform a bitwise AND of the argument followed by a + boolean negation of the result. + +2018-04-10 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + Backport from mainline + 2018-03-08 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + PR target/84748 + * config/aarch64/aarch64.md (*compare_cstore<mode>_insn): Mark pattern + as clobbering CC_REGNUM. + +2018-04-06 Eric Botcazou <ebotcazou@adacore.com> + + PR target/85196 + * config/sparc/sparc.c (sparc_expand_move): Deal with symbolic operands + based on LABEL_REF. Remove useless assertion. + (pic_address_needs_scratch): Fix formatting. + (sparc_legitimize_pic_address): Minor tweaks. + (sparc_delegitimize_address): Adjust assertion accordingly. + * config/sparc/sparc.md (movsi_pic_label_ref): Change label_ref_operand + into symbolic_operand. + (movsi_high_pic_label_ref): Likewise. + (movsi_lo_sum_pic_label_ref): Likewise. + (movdi_pic_label_ref): Likewise. + (movdi_high_pic_label_ref): Likewise. + (movdi_lo_sum_pic_label_ref): Likewise. + +2018-04-06 Amaan Cheval <amaan.cheval@gmail.com> + + * config.gcc (x86_64-*-rtems*): Add rtems.h to tm_file for + custom LIB_SPEC setup. + +2018-04-05 Uros Bizjak <ubizjak@gmail.com> + + PR target/85193 + * config/i386/i386.md (define_attr "memory"): Handle rotate1 type. + +2018-04-04 Peter Bergner <bergner@vnet.ibm.com> + + Backport from mainline + 2018-04-04 Peter Bergner <bergner@vnet.ibm.com> + + PR rtl-optimization/84878 + * ddg.c (add_cross_iteration_register_deps): Use DF_REF_BB to determine + the basic block. Assert the use reference is not artificial and that + it has an associated insn. + +2018-04-03 Uros Bizjak <ubizjak@gmail.com> + + * config/i386/i386.c (emit_i387_cw_initialization): Always use logic + instructions when changing rounding bits to preserve precision bits + in the x87 control word. + +2018-04-03 Cesar Philippidis <cesar@codesourcery.com> + + Backport from mainline + 2018-03-27 Cesar Philippidis <cesar@codesourcery.com> + + PR target/85056 + * config/nvptx/nvptx.c (nvptx_assemble_decl_begin): Add '[]' to + extern array declarations. + +2018-04-02 Peter Bergner <bergner@vnet.ibm.com> + + Backport from mainline + 2018-03-28 Peter Bergner <bergner@vnet.ibm.com> + + PR target/84912 + * config/rs6000/rs6000.h: Update copyright date. + (RS6000_BTM_POWERPC64): New define. + (RS6000_BTM_COMMON): Add RS6000_BTM_POWERPC64. + * config/rs6000/rs6000.c: Update copyright date. + (rs6000_builtin_mask_calculate): Add support for RS6000_BTM_POWERPC64. + (rs6000_invalid_builtin): Add handling for RS6000_BTM_POWERPC64 + (rs6000_builtin_mask_names): Add RS6000_BTM_POWERPC64. + * config/rs6000/rs6000-builtin.def: Update copyright date. + (BU_P7_POWERPC64_MISC_2): New macro definition. + (DIVDE): Use it. + (DIVDEU): Likewise. + + Backport from mainline + 2018-03-28 Peter Bergner <bergner@vnet.ibm.com> + + PR target/84912 + * config/rs6000/rs6000-builtin.def (DIVWEO): Delete macro expansion. + (DIVWEUO): Likewise. + (DIVDEO): Likewise. + (DIVDEUO): Likewise. + * config/rs6000/rs6000.c (builtin_function_type): Remove support for + DIVWEUO and DIVDEUO. + * config/rs6000/rs6000.md: Update copyright date. + (UNSPEC_DIVEO, UNSPEC_DIVEUO): Delete unspecs. + (UNSPEC_DIV_EXTEND): Remove deleted unspecs. + (div_extend): Likewise. + * doc/extend.texi: Update copyright date. + (__builtin_divweo): Remove documentation for deleted builtin function. + (__builtin_divweuo): Likewise. + (__builtin_divdeo): Likewise. + (__builtin_divdeuo): Likewise. + +2018-04-02 Peter Bergner <bergner@vnet.ibm.com> + + Backport from mainline + 2018-03-30 Peter Bergner <bergner@vnet.ibm.com> + + PR target/80546 + * config/rs6000/vsx.md (??r): New mode attribute. + (*vsx_mov<mode>_64bit): Use it. + (*vsx_mov<mode>_32bit): Likewise. + +2018-03-29 Sebastian Peryt <sebastian.peryt@intel.com> + + PR c++/84783 + * config/i386/avx512vlintrin.h (_mm256_permutexvar_epi64) + (_mm256_permutexvar_epi32, _mm256_permutex_epi64): New intrinsics. + +2018-03-29 Sudakshina Das <sudi.das@arm.com> + + Backport from mainline + 2018-03-22 Sudakshina Das <sudi.das@arm.com> + + PR target/84826 + * config/arm/arm.h (machine_function): Add static_chain_stack_bytes. + * config/arm/arm.c (arm_compute_static_chain_stack_bytes): Avoid + re-computing once computed. + (arm_expand_prologue): Compute machine->static_chain_stack_bytes. + (arm_init_machine_status): Initialize + machine->static_chain_stack_bytes. + +2018-03-28 Sudakshina Das <sudi.das@arm.com> + + 2018-03-19 Sudakshina Das <sudi.das@arm.com> + PR target/81647 + + * config/aarch64/aarch64-simd.md (vec_cmp<mode><v_cmp_result>): Modify + instructions for UNLT, UNLE, UNGT, UNGE, UNEQ, UNORDERED and ORDERED. + +2018-03-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + Backport from mainline + 2018-03-23 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + PR target/85026 + * config/arm/arm.md (unaligned_loadhis): Remove first alternative. + Clean up attributes. + +2018-03-28 Segher Boessenkool <segher@kernel.crashing.org> + + Backport from mainline + 2018-03-08 Segher Boessenkool <segher@kernel.crashing.org> + + PR target/82411 + * config/rs6000/rs6000.c (rs6000_elf_in_small_data_p): Don't put + readonly data in sdata, if that is disabled. + * config/rs6000/sysv4.opt (mreadonly-in-sdata): New option. + * doc/invoke.texi (RS/6000 and PowerPC Options): Document + -mreadonly-in-sdata option. + +2018-03-27 Sudakshina Das <sudi.das@arm.com> + + Backport from mainline: + 2018-03-20 Sudakshina Das <sudi.das@arm.com> + + PR target/82989 + * config/arm/neon.md (ashldi3_neon): Update ?s for constraints + to favor GPR over NEON registers. + (<shift>di3_neon): Likewise. + +2018-03-27 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + Backport from mainline + 2018-03-20 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + PR target/82518 + * config/arm/arm.c (arm_array_mode_supported_p): Return false for + BYTES_BIG_ENDIAN. + +2018-03-23 Peter Bergner <bergner@vnet.ibm.com> + + Backport from mainline + 2018-03-20 Peter Bergner <bergner@vnet.ibm.com> + + PR target/83789 + * config/rs6000/altivec.md (altivec_lvx_<mode>_2op): Delete define_insn. + (altivec_lvx_<mode>_1op): Likewise. + (altivec_stvx_<mode>_2op): Likewise. + (altivec_stvx_<mode>_1op): Likewise. + (altivec_lvx_<VM2:mode>): New define_expand. + (altivec_stvx_<VM2:mode>): Likewise. + (altivec_lvx_<VM2:mode>_2op_<P:mptrsize>): New define_insn. + (altivec_lvx_<VM2:mode>_1op_<P:mptrsize>): Likewise. + (altivec_stvx_<VM2:mode>_2op_<P:mptrsize>): Likewise. + (altivec_stvx_<VM2:mode>_1op_<P:mptrsize>): Likewise. + * config/rs6000/rs6000.c (altivec_expand_lv_builtin): Likewise. + (altivec_expand_stv_builtin): Likewise. + (altivec_expand_builtin): Likewise. + * config/rs6000/vector.md: Likewise. + +2018-03-23 Carl Love <cel@us.ibm.com> + + Backport from mainline: + 2018-03-14 Carl Love <cel@us.ibm.com> + + * config/rs6000/r6000.c (rtx_is_swappable_p): Add case UNSPEC_VPERMXOR. + +2018-03-22 Tom de Vries <tom@codesourcery.com> + + backport from trunk: + 2018-03-22 Tom de Vries <tom@codesourcery.com> + + PR tree-optimization/84956 + * tree-ssa-tail-merge.c (find_clusters_1): Skip bbs with + bb_has_abnormal_pred. + +2018-03-19 H.J. Lu <hongjiu.lu@intel.com> + + Backport from mainline + 2018-03-15 H.J. Lu <hongjiu.lu@intel.com> + + PR target/84574 + * config/i386/i386.c (indirect_thunk_needed): Update comments. + (indirect_thunk_bnd_needed): Likewise. + (indirect_thunks_used): Likewise. + (indirect_thunks_bnd_used): Likewise. + (indirect_return_needed): New. + (indirect_return_bnd_needed): Likewise. + (output_indirect_thunk_function): Add a bool argument for + function return. + (output_indirect_thunk_function): Don't generate alias for + function return thunk. + (ix86_code_end): Call output_indirect_thunk_function to generate + function return thunks. + (ix86_output_function_return): Set indirect_return_bnd_needed + and indirect_return_needed instead of indirect_thunk_bnd_needed + and indirect_thunk_needed. + +2018-03-14 John David Anglin <danglin@gcc.gnu.org> + + PR target/83451 + * config/pa/pa.c (pa_emit_move_sequence): Always emit secondary reload + insn for floating-point loads and stores. + 2018-03-12 Jonathan Wakely <jwakely@redhat.com> * doc/invoke.texi (-mclflushopt): Fix spelling of option. diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 396833387ce..cdc90b450c7 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20180314 +20180425 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1cc0c11e6b2..da154469753 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2018-04-12 Sebastian Huber <sebastian.huber@embedded-brains.de> + + Backport from mainline + 2018-03-07 Sebastian Huber <sebastian.huber@embedded-brains.de> + + * gcc-interface/Makefile.in (OSCONS_CPP): Remove redundant + $(GNATLIBCFLAGS). + (OSCONS_EXTRACT): Add $(GNATLIBCFLAGS_FOR_C). + 2018-03-12 Eric Botcazou <ebotcazou@adacore.com> PR ada/82813 diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index 7a570196a88..439347a677b 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -2756,9 +2756,9 @@ OSCONS_CC=$(subst ./xgcc,../../xgcc,$(subst -B./, -B../../,$(GCC_FOR_TARGET))) # ada/types.h does not conflict with a same-named system header (VxWorks # has a <types.h> header). -OSCONS_CPP=$(OSCONS_CC) $(GNATLIBCFLAGS) $(GNATLIBCFLAGS_FOR_C) -E -C \ +OSCONS_CPP=$(OSCONS_CC) $(GNATLIBCFLAGS_FOR_C) -E -C \ -DTARGET=\"$(target)\" -iquote $(fsrcpfx)ada $(fsrcpfx)ada/s-oscons-tmplt.c > s-oscons-tmplt.i -OSCONS_EXTRACT=$(OSCONS_CC) -S s-oscons-tmplt.i +OSCONS_EXTRACT=$(OSCONS_CC) $(GNATLIBCFLAGS_FOR_C) -S s-oscons-tmplt.i # Note: if you need to build with a non-GNU compiler, you could adapt the # following definitions (written for VMS DEC-C) diff --git a/gcc/config.gcc b/gcc/config.gcc index b189ba66b0f..64b944a5d2c 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1461,7 +1461,7 @@ x86_64-*-elf*) tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h" ;; x86_64-*-rtems*) - tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h i386/rtemself.h" + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h i386/rtemself.h rtems.h" ;; i[34567]86-*-rdos*) tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/rdos.h" diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md index df5e62ae7ef..de2ff1012b2 100644 --- a/gcc/config/aarch64/aarch64-simd.md +++ b/gcc/config/aarch64/aarch64-simd.md @@ -2580,10 +2580,10 @@ break; } /* Fall through. */ - case UNGE: + case UNLT: std::swap (operands[2], operands[3]); /* Fall through. */ - case UNLE: + case UNGT: case GT: comparison = gen_aarch64_cmgt<mode>; break; @@ -2594,10 +2594,10 @@ break; } /* Fall through. */ - case UNGT: + case UNLE: std::swap (operands[2], operands[3]); /* Fall through. */ - case UNLT: + case UNGE: case GE: comparison = gen_aarch64_cmge<mode>; break; @@ -2620,21 +2620,35 @@ case UNGT: case UNLE: case UNLT: - case NE: - /* FCM returns false for lanes which are unordered, so if we use - the inverse of the comparison we actually want to emit, then - invert the result, we will end up with the correct result. - Note that a NE NaN and NaN NE b are true for all a, b. - - Our transformations are: - a UNGE b -> !(b GT a) - a UNGT b -> !(b GE a) - a UNLE b -> !(a GT b) - a UNLT b -> !(a GE b) - a NE b -> !(a EQ b) */ - gcc_assert (comparison != NULL); - emit_insn (comparison (operands[0], operands[2], operands[3])); - emit_insn (gen_one_cmpl<v_cmp_result>2 (operands[0], operands[0])); + { + /* All of the above must not raise any FP exceptions. Thus we first + check each operand for NaNs and force any elements containing NaN to + zero before using them in the compare. + Example: UN<cc> (a, b) -> UNORDERED (a, b) | + (cm<cc> (isnan (a) ? 0.0 : a, + isnan (b) ? 0.0 : b)) + We use the following transformations for doing the comparisions: + a UNGE b -> a GE b + a UNGT b -> a GT b + a UNLE b -> b GE a + a UNLT b -> b GT a. */ + + rtx tmp0 = gen_reg_rtx (<V_cmp_result>mode); + rtx tmp1 = gen_reg_rtx (<V_cmp_result>mode); + rtx tmp2 = gen_reg_rtx (<V_cmp_result>mode); + emit_insn (gen_aarch64_cmeq<mode> (tmp0, operands[2], operands[2])); + emit_insn (gen_aarch64_cmeq<mode> (tmp1, operands[3], operands[3])); + emit_insn (gen_and<v_cmp_result>3 (tmp2, tmp0, tmp1)); + emit_insn (gen_and<v_cmp_result>3 (tmp0, tmp0, + lowpart_subreg (<V_cmp_result>mode, operands[2], <MODE>mode))); + emit_insn (gen_and<v_cmp_result>3 (tmp1, tmp1, + lowpart_subreg (<V_cmp_result>mode, operands[3], <MODE>mode))); + gcc_assert (comparison != NULL); + emit_insn (comparison (operands[0], + lowpart_subreg (<MODE>mode, tmp0, <V_cmp_result>mode), + lowpart_subreg (<MODE>mode, tmp1, <V_cmp_result>mode))); + emit_insn (gen_orn<v_cmp_result>3 (operands[0], tmp2, operands[0])); + } break; case LT: @@ -2642,25 +2656,19 @@ case GT: case GE: case EQ: + case NE: /* The easy case. Here we emit one of FCMGE, FCMGT or FCMEQ. As a LT b <=> b GE a && a LE b <=> b GT a. Our transformations are: a GE b -> a GE b a GT b -> a GT b a LE b -> b GE a a LT b -> b GT a - a EQ b -> a EQ b */ + a EQ b -> a EQ b + a NE b -> ~(a EQ b) */ gcc_assert (comparison != NULL); emit_insn (comparison (operands[0], operands[2], operands[3])); - break; - - case UNEQ: - /* We first check (a > b || b > a) which is !UNEQ, inverting - this result will then give us (a == b || a UNORDERED b). */ - emit_insn (gen_aarch64_cmgt<mode> (operands[0], - operands[2], operands[3])); - emit_insn (gen_aarch64_cmgt<mode> (tmp, operands[3], operands[2])); - emit_insn (gen_ior<v_cmp_result>3 (operands[0], operands[0], tmp)); - emit_insn (gen_one_cmpl<v_cmp_result>2 (operands[0], operands[0])); + if (code == NE) + emit_insn (gen_one_cmpl<v_cmp_result>2 (operands[0], operands[0])); break; case LTGT: @@ -2672,21 +2680,22 @@ emit_insn (gen_ior<v_cmp_result>3 (operands[0], operands[0], tmp)); break; - case UNORDERED: - /* Operands are ORDERED iff (a > b || b >= a), so we can compute - UNORDERED as !ORDERED. */ - emit_insn (gen_aarch64_cmgt<mode> (tmp, operands[2], operands[3])); - emit_insn (gen_aarch64_cmge<mode> (operands[0], - operands[3], operands[2])); - emit_insn (gen_ior<v_cmp_result>3 (operands[0], operands[0], tmp)); - emit_insn (gen_one_cmpl<v_cmp_result>2 (operands[0], operands[0])); - break; - case ORDERED: - emit_insn (gen_aarch64_cmgt<mode> (tmp, operands[2], operands[3])); - emit_insn (gen_aarch64_cmge<mode> (operands[0], - operands[3], operands[2])); - emit_insn (gen_ior<v_cmp_result>3 (operands[0], operands[0], tmp)); + case UNORDERED: + case UNEQ: + /* cmeq (a, a) & cmeq (b, b). */ + emit_insn (gen_aarch64_cmeq<mode> (operands[0], + operands[2], operands[2])); + emit_insn (gen_aarch64_cmeq<mode> (tmp, operands[3], operands[3])); + emit_insn (gen_and<v_cmp_result>3 (operands[0], operands[0], tmp)); + + if (code == UNORDERED) + emit_insn (gen_one_cmpl<v_cmp_result>2 (operands[0], operands[0])); + else if (code == UNEQ) + { + emit_insn (gen_aarch64_cmeq<mode> (tmp, operands[2], operands[3])); + emit_insn (gen_orn<v_cmp_result>3 (operands[0], operands[0], tmp)); + } break; default: diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index e17d9e9645b..e6b8bc67715 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -3076,7 +3076,8 @@ (define_insn_and_split "*compare_cstore<mode>_insn" [(set (match_operand:GPI 0 "register_operand" "=r") (EQL:GPI (match_operand:GPI 1 "register_operand" "r") - (match_operand:GPI 2 "aarch64_imm24" "n")))] + (match_operand:GPI 2 "aarch64_imm24" "n"))) + (clobber (reg:CC CC_REGNUM))] "!aarch64_move_imm (INTVAL (operands[2]), <MODE>mode) && !aarch64_plus_operand (operands[2], <MODE>mode) && !reload_completed" diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 15011aabcc7..75a2af1e3de 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -7750,13 +7750,13 @@ alpha_expand_prologue (void) int probed; for (probed = 4096; probed < probed_size; probed += 8192) - emit_insn (gen_probe_stack (GEN_INT (-probed))); + emit_insn (gen_stack_probe_internal (GEN_INT (-probed))); /* We only have to do this probe if we aren't saving registers or if we are probing beyond the frame because of -fstack-check. */ if ((sa_size == 0 && probed_size > probed - 4096) || flag_stack_check) - emit_insn (gen_probe_stack (GEN_INT (-probed_size))); + emit_insn (gen_stack_probe_internal (GEN_INT (-probed_size))); } if (frame_size != 0) diff --git a/gcc/config/alpha/alpha.md b/gcc/config/alpha/alpha.md index 97838a5083a..14c18656d82 100644 --- a/gcc/config/alpha/alpha.md +++ b/gcc/config/alpha/alpha.md @@ -4915,7 +4915,7 @@ ;; Subroutine of stack space allocation. Perform a stack probe. -(define_expand "probe_stack" +(define_expand "stack_probe_internal" [(set (match_dup 1) (match_operand:DI 0 "const_int_operand"))] "" { @@ -4950,12 +4950,14 @@ int probed = 4096; - emit_insn (gen_probe_stack (GEN_INT (- probed))); + emit_insn (gen_stack_probe_internal (GEN_INT (- probed))); while (probed + 8192 < INTVAL (operands[1])) - emit_insn (gen_probe_stack (GEN_INT (- (probed += 8192)))); + emit_insn (gen_stack_probe_internal + (GEN_INT (- (probed += 8192)))); if (probed + 4096 < INTVAL (operands[1])) - emit_insn (gen_probe_stack (GEN_INT (- INTVAL(operands[1])))); + emit_insn (gen_stack_probe_internal + (GEN_INT (- INTVAL(operands[1])))); } operands[1] = GEN_INT (- INTVAL (operands[1])); diff --git a/gcc/config/arm/arm-builtins.c b/gcc/config/arm/arm-builtins.c index 39ef48f0aef..34d68c0de69 100644 --- a/gcc/config/arm/arm-builtins.c +++ b/gcc/config/arm/arm-builtins.c @@ -2590,7 +2590,7 @@ arm_expand_builtin (tree exp, icode = CODE_FOR_set_fpscr; arg0 = CALL_EXPR_ARG (exp, 0); op0 = expand_normal (arg0); - pat = GEN_FCN (icode) (op0); + pat = GEN_FCN (icode) (force_reg (SImode, op0)); } emit_insn (pat); return target; @@ -2598,7 +2598,9 @@ arm_expand_builtin (tree exp, case ARM_BUILTIN_CMSE_NONSECURE_CALLER: target = gen_reg_rtx (SImode); op0 = arm_return_addr (0, NULL_RTX); - emit_insn (gen_addsi3 (target, op0, const1_rtx)); + emit_insn (gen_andsi3 (target, op0, const1_rtx)); + op1 = gen_rtx_EQ (SImode, target, const0_rtx); + emit_insn (gen_cstoresi4 (target, op1, target, const0_rtx)); return target; case ARM_BUILTIN_TEXTRMSB: diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 2856b1afd5c..2050dc3499a 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -19112,6 +19112,11 @@ arm_r3_live_at_start_p (void) static int arm_compute_static_chain_stack_bytes (void) { + /* Once the value is updated from the init value of -1, do not + re-compute. */ + if (cfun->machine->static_chain_stack_bytes != -1) + return cfun->machine->static_chain_stack_bytes; + /* See the defining assertion in arm_expand_prologue. */ if (IS_NESTED (arm_current_func_type ()) && ((TARGET_APCS_FRAME && frame_pointer_needed && TARGET_ARM) @@ -21418,6 +21423,11 @@ arm_expand_prologue (void) emit_insn (gen_movsi (stack_pointer_rtx, r1)); } + /* Let's compute the static_chain_stack_bytes required and store it. Right + now the value must the -1 as stored by arm_init_machine_status (). */ + cfun->machine->static_chain_stack_bytes + = arm_compute_static_chain_stack_bytes (); + /* The static chain register is the same as the IP register. If it is clobbered when creating the frame, we need to save and restore it. */ clobber_ip = IS_NESTED (func_type) @@ -24559,6 +24569,7 @@ arm_init_machine_status (void) #if ARM_FT_UNKNOWN != 0 machine->func_type = ARM_FT_UNKNOWN; #endif + machine->static_chain_stack_bytes = -1; return machine; } @@ -26870,7 +26881,10 @@ static bool arm_array_mode_supported_p (machine_mode mode, unsigned HOST_WIDE_INT nelems) { - if (TARGET_NEON + /* We don't want to enable interleaved loads and stores for BYTES_BIG_ENDIAN + for now, as the lane-swapping logic needs to be extended in the expanders. + See PR target/82518. */ + if (TARGET_NEON && !BYTES_BIG_ENDIAN && (VALID_NEON_DREG_MODE (mode) || VALID_NEON_QREG_MODE (mode)) && (nelems >= 2 && nelems <= 4)) return true; diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 39d8b1aba5c..9096af974ce 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -1426,6 +1426,9 @@ typedef struct GTY(()) machine_function machine_mode thumb1_cc_mode; /* Set to 1 after arm_reorg has started. */ int after_arm_reorg; + /* The number of bytes used to store the static chain register on the + stack, above the stack frame. */ + int static_chain_stack_bytes; } machine_function; #endif diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 2b782668e3b..58f72fd5e76 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -4547,16 +4547,13 @@ (set_attr "type" "load1")]) (define_insn "unaligned_loadhis" - [(set (match_operand:SI 0 "s_register_operand" "=l,r") + [(set (match_operand:SI 0 "s_register_operand" "=r") (sign_extend:SI - (unspec:HI [(match_operand:HI 1 "memory_operand" "Uw,Uh")] + (unspec:HI [(match_operand:HI 1 "memory_operand" "Uh")] UNSPEC_UNALIGNED_LOAD)))] "unaligned_access" "ldrsh%?\t%0, %1\t@ unaligned" - [(set_attr "arch" "t2,any") - (set_attr "length" "2,4") - (set_attr "predicable" "yes") - (set_attr "predicable_short_it" "yes,no") + [(set_attr "predicable" "yes") (set_attr "type" "load_byte")]) (define_insn "unaligned_loadhiu" diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md index 971dd4cea51..1cccdcabcc3 100644 --- a/gcc/config/arm/neon.md +++ b/gcc/config/arm/neon.md @@ -1180,12 +1180,12 @@ ) (define_insn_and_split "ashldi3_neon" - [(set (match_operand:DI 0 "s_register_operand" "= w, w,?&r,?r,?&r, ?w,w") - (ashift:DI (match_operand:DI 1 "s_register_operand" " 0w, w, 0r, 0, r, 0w,w") - (match_operand:SI 2 "general_operand" "rUm, i, r, i, i,rUm,i"))) - (clobber (match_scratch:SI 3 "= X, X,?&r, X, X, X,X")) - (clobber (match_scratch:SI 4 "= X, X,?&r, X, X, X,X")) - (clobber (match_scratch:DI 5 "=&w, X, X, X, X, &w,X")) + [(set (match_operand:DI 0 "s_register_operand" "= w, w, &r, r, &r, ?w,?w") + (ashift:DI (match_operand:DI 1 "s_register_operand" " 0w, w, 0r, 0, r, 0w, w") + (match_operand:SI 2 "general_operand" "rUm, i, r, i, i,rUm, i"))) + (clobber (match_scratch:SI 3 "= X, X, &r, X, X, X, X")) + (clobber (match_scratch:SI 4 "= X, X, &r, X, X, X, X")) + (clobber (match_scratch:DI 5 "=&w, X, X, X, X, &w, X")) (clobber (reg:CC_C CC_REGNUM))] "TARGET_NEON" "#" @@ -1280,7 +1280,7 @@ ;; ashrdi3_neon ;; lshrdi3_neon (define_insn_and_split "<shift>di3_neon" - [(set (match_operand:DI 0 "s_register_operand" "= w, w,?&r,?r,?&r,?w,?w") + [(set (match_operand:DI 0 "s_register_operand" "= w, w, &r, r, &r,?w,?w") (RSHIFTS:DI (match_operand:DI 1 "s_register_operand" " 0w, w, 0r, 0, r,0w, w") (match_operand:SI 2 "reg_or_int_operand" " r, i, r, i, i, r, i"))) (clobber (match_scratch:SI 3 "=2r, X, &r, X, X,2r, X")) diff --git a/gcc/config/i386/avx512vlintrin.h b/gcc/config/i386/avx512vlintrin.h index f62f641188e..301713ba907 100644 --- a/gcc/config/i386/avx512vlintrin.h +++ b/gcc/config/i386/avx512vlintrin.h @@ -9099,6 +9099,17 @@ _mm_maskz_mul_epi32 (__mmask8 __M, __m128i __X, __m128i __Y) extern __inline __m256i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_permutexvar_epi64 (__m256i __X, __m256i __Y) +{ + return (__m256i) __builtin_ia32_permvardi256_mask ((__v4di) __Y, + (__v4di) __X, + (__v4di) + _mm256_setzero_si256 (), + (__mmask8) -1); +} + +extern __inline __m256i +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm256_mask_permutexvar_epi64 (__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y) { @@ -9163,6 +9174,17 @@ _mm_maskz_mul_epu32 (__mmask8 __M, __m128i __X, __m128i __Y) extern __inline __m256i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_permutexvar_epi32 (__m256i __X, __m256i __Y) +{ + return (__m256i) __builtin_ia32_permvarsi256_mask ((__v8si) __Y, + (__v8si) __X, + (__v8si) + _mm256_setzero_si256 (), + (__mmask8) -1); +} + +extern __inline __m256i +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm256_mask_permutexvar_epi32 (__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y) { @@ -9751,6 +9773,17 @@ _mm_cmple_epi64_mask (__m128i __X, __m128i __Y) #ifdef __OPTIMIZE__ extern __inline __m256i __attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm256_permutex_epi64 (__m256i __X, const int __I) +{ + return (__m256i) __builtin_ia32_permdi256_mask ((__v4di) __X, + __I, + (__v4di) + _mm256_setzero_si256 (), + (__mmask8) -1); +} + +extern __inline __m256i +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) _mm256_mask_permutex_epi64 (__m256i __W, __mmask8 __M, __m256i __X, const int __I) { @@ -12367,6 +12400,13 @@ _mm256_permutex_pd (__m256d __X, const int __M) _mm256_undefined_pd (), \ (__mmask8)-1)) +#define _mm256_permutex_epi64(X, I) \ + ((__m256i) __builtin_ia32_permdi256_mask ((__v4di)(__m256i)(X), \ + (int)(I), \ + (__v4di)(__m256i) \ + (_mm256_setzero_si256 ()),\ + (__mmask8) -1)) + #define _mm256_maskz_permutex_epi64(M, X, I) \ ((__m256i) __builtin_ia32_permdi256_mask ((__v4di)(__m256i)(X), \ (int)(I), \ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index a5b05f9eb5e..f90fa6fe9e4 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -12031,19 +12031,23 @@ ix86_setup_frame_addresses (void) labels in call and return thunks. */ static int indirectlabelno; -/* True if call and return thunk functions are needed. */ +/* True if call thunk function is needed. */ static bool indirect_thunk_needed = false; -/* True if call and return thunk functions with the BND prefix are - needed. */ +/* True if call thunk function with the BND prefix is needed. */ static bool indirect_thunk_bnd_needed = false; /* Bit masks of integer registers, which contain branch target, used - by call and return thunks functions. */ + by call thunk functions. */ static int indirect_thunks_used; /* Bit masks of integer registers, which contain branch target, used - by call and return thunks functions with the BND prefix. */ + by call thunk functions with the BND prefix. */ static int indirect_thunks_bnd_used; +/* True if return thunk function is needed. */ +static bool indirect_return_needed = false; +/* True if return thunk function with the BND prefix is needed. */ +static bool indirect_return_bnd_needed = false; + /* True if return thunk function via CX is needed. */ static bool indirect_return_via_cx; /* True if return thunk function via CX with the BND prefix is @@ -12190,16 +12194,18 @@ output_indirect_thunk (bool need_bnd_p, unsigned int regno) /* Output a funtion with a call and return thunk for indirect branch. If BND_P is true, the BND prefix is needed. If REGNO != INVALID_REGNUM, the function address is in REGNO. Otherwise, the function address is - on the top of stack. */ + on the top of stack. Thunk is used for function return if RET_P is + true. */ static void -output_indirect_thunk_function (bool need_bnd_p, unsigned int regno) +output_indirect_thunk_function (bool need_bnd_p, unsigned int regno, + bool ret_p) { char name[32]; tree decl; /* Create __x86_indirect_thunk/__x86_indirect_thunk_bnd. */ - indirect_thunk_name (name, regno, need_bnd_p, false); + indirect_thunk_name (name, regno, need_bnd_p, ret_p); decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, get_identifier (name), build_function_type_list (void_type_node, NULL_TREE)); @@ -12242,50 +12248,6 @@ output_indirect_thunk_function (bool need_bnd_p, unsigned int regno) ASM_OUTPUT_LABEL (asm_out_file, name); } - /* Create alias for __x86_return_thunk/__x86_return_thunk_bnd or - __x86_return_thunk_ecx/__x86_return_thunk_ecx_bnd. */ - bool need_alias; - if (regno == INVALID_REGNUM) - need_alias = true; - else if (regno == CX_REG) - { - if (need_bnd_p) - need_alias = indirect_return_via_cx_bnd; - else - need_alias = indirect_return_via_cx; - } - else - need_alias = false; - - if (need_alias) - { - char alias[32]; - - indirect_thunk_name (alias, regno, need_bnd_p, true); -#if TARGET_MACHO - if (TARGET_MACHO) - { - fputs ("\t.weak_definition\t", asm_out_file); - assemble_name (asm_out_file, alias); - fputs ("\n\t.private_extern\t", asm_out_file); - assemble_name (asm_out_file, alias); - putc ('\n', asm_out_file); - ASM_OUTPUT_LABEL (asm_out_file, alias); - } -#else - ASM_OUTPUT_DEF (asm_out_file, alias, name); - if (USE_HIDDEN_LINKONCE) - { - fputs ("\t.globl\t", asm_out_file); - assemble_name (asm_out_file, alias); - putc ('\n', asm_out_file); - fputs ("\t.hidden\t", asm_out_file); - assemble_name (asm_out_file, alias); - putc ('\n', asm_out_file); - } -#endif - } - DECL_INITIAL (decl) = make_node (BLOCK); current_function_decl = decl; allocate_struct_function (decl, false); @@ -12332,19 +12294,29 @@ ix86_code_end (void) rtx xops[2]; unsigned int regno; + if (indirect_return_needed) + output_indirect_thunk_function (false, INVALID_REGNUM, true); + if (indirect_return_bnd_needed) + output_indirect_thunk_function (true, INVALID_REGNUM, true); + + if (indirect_return_via_cx) + output_indirect_thunk_function (false, CX_REG, true); + if (indirect_return_via_cx_bnd) + output_indirect_thunk_function (true, CX_REG, true); + if (indirect_thunk_needed) - output_indirect_thunk_function (false, INVALID_REGNUM); + output_indirect_thunk_function (false, INVALID_REGNUM, false); if (indirect_thunk_bnd_needed) - output_indirect_thunk_function (true, INVALID_REGNUM); + output_indirect_thunk_function (true, INVALID_REGNUM, false); for (regno = FIRST_REX_INT_REG; regno <= LAST_REX_INT_REG; regno++) { unsigned int i = regno - FIRST_REX_INT_REG + LAST_INT_REG + 1; if ((indirect_thunks_used & (1 << i))) - output_indirect_thunk_function (false, regno); + output_indirect_thunk_function (false, regno, false); if ((indirect_thunks_bnd_used & (1 << i))) - output_indirect_thunk_function (true, regno); + output_indirect_thunk_function (true, regno, false); } for (regno = AX_REG; regno <= SP_REG; regno++) @@ -12353,10 +12325,10 @@ ix86_code_end (void) tree decl; if ((indirect_thunks_used & (1 << regno))) - output_indirect_thunk_function (false, regno); + output_indirect_thunk_function (false, regno, false); if ((indirect_thunks_bnd_used & (1 << regno))) - output_indirect_thunk_function (true, regno); + output_indirect_thunk_function (true, regno, false); if (!(pic_labels_used & (1 << regno))) continue; @@ -19826,72 +19798,36 @@ emit_i387_cw_initialization (int mode) emit_insn (gen_x86_fnstcw_1 (stored_mode)); emit_move_insn (reg, copy_rtx (stored_mode)); - if (TARGET_64BIT || TARGET_PARTIAL_REG_STALL - || optimize_insn_for_size_p ()) - { - switch (mode) - { - case I387_CW_TRUNC: - /* round toward zero (truncate) */ - emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0c00))); - slot = SLOT_CW_TRUNC; - break; - - case I387_CW_FLOOR: - /* round down toward -oo */ - emit_insn (gen_andhi3 (reg, reg, GEN_INT (~0x0c00))); - emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0400))); - slot = SLOT_CW_FLOOR; - break; - - case I387_CW_CEIL: - /* round up toward +oo */ - emit_insn (gen_andhi3 (reg, reg, GEN_INT (~0x0c00))); - emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0800))); - slot = SLOT_CW_CEIL; - break; - - case I387_CW_MASK_PM: - /* mask precision exception for nearbyint() */ - emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0020))); - slot = SLOT_CW_MASK_PM; - break; - - default: - gcc_unreachable (); - } - } - else + switch (mode) { - switch (mode) - { - case I387_CW_TRUNC: - /* round toward zero (truncate) */ - emit_insn (gen_insvsi_1 (reg, GEN_INT (0xc))); - slot = SLOT_CW_TRUNC; - break; + case I387_CW_TRUNC: + /* round toward zero (truncate) */ + emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0c00))); + slot = SLOT_CW_TRUNC; + break; - case I387_CW_FLOOR: - /* round down toward -oo */ - emit_insn (gen_insvsi_1 (reg, GEN_INT (0x4))); - slot = SLOT_CW_FLOOR; - break; + case I387_CW_FLOOR: + /* round down toward -oo */ + emit_insn (gen_andhi3 (reg, reg, GEN_INT (~0x0c00))); + emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0400))); + slot = SLOT_CW_FLOOR; + break; - case I387_CW_CEIL: - /* round up toward +oo */ - emit_insn (gen_insvsi_1 (reg, GEN_INT (0x8))); - slot = SLOT_CW_CEIL; - break; + case I387_CW_CEIL: + /* round up toward +oo */ + emit_insn (gen_andhi3 (reg, reg, GEN_INT (~0x0c00))); + emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0800))); + slot = SLOT_CW_CEIL; + break; - case I387_CW_MASK_PM: - /* mask precision exception for nearbyint() */ - emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0020))); - slot = SLOT_CW_MASK_PM; - break; + case I387_CW_MASK_PM: + /* mask precision exception for nearbyint() */ + emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0020))); + slot = SLOT_CW_MASK_PM; + break; - default: - gcc_unreachable (); - } + default: + gcc_unreachable (); } gcc_assert (slot < MAX_386_STACK_LOCALS); @@ -29168,12 +29104,12 @@ ix86_output_function_return (bool long_p) true); if (need_bnd_p) { - indirect_thunk_bnd_needed |= need_thunk; + indirect_return_bnd_needed |= need_thunk; fprintf (asm_out_file, "\tbnd jmp\t%s\n", thunk_name); } else { - indirect_thunk_needed |= need_thunk; + indirect_return_needed |= need_thunk; fprintf (asm_out_file, "\tjmp\t%s\n", thunk_name); } } diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 10abb165bd9..ed09ee0bdc2 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -739,7 +739,7 @@ (if_then_else (match_operand 1 "constant_call_address_operand") (const_string "none") (const_string "load")) - (and (eq_attr "type" "alu1,negnot,ishift1,sselog1,sseshuf1") + (and (eq_attr "type" "alu1,negnot,ishift1,rotate1,sselog1,sseshuf1") (match_operand 1 "memory_operand")) (const_string "both") (and (match_operand 0 "memory_operand") @@ -750,7 +750,7 @@ (match_operand 1 "memory_operand") (const_string "load") (and (eq_attr "type" - "!alu1,negnot,ishift1, + "!alu1,negnot,ishift1,rotate1, imov,imovx,icmp,test,bitmanip, fmov,fcmp,fsgn, sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt, diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 70a8f0de245..af2c4a23dfe 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -2008,6 +2008,9 @@ static void nvptx_assemble_decl_begin (FILE *file, const char *name, const char *section, const_tree type, HOST_WIDE_INT size, unsigned align) { + bool atype = (TREE_CODE (type) == ARRAY_TYPE) + && (TYPE_DOMAIN (type) == NULL_TREE); + while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); @@ -2047,6 +2050,8 @@ nvptx_assemble_decl_begin (FILE *file, const char *name, const char *section, /* We make everything an array, to simplify any initialization emission. */ fprintf (file, "[" HOST_WIDE_INT_PRINT_DEC "]", init_frag.remaining); + else if (atype) + fprintf (file, "[]"); } /* Called when the initializer for a decl has been completely output through diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index e6ac34acec9..9368d4504a8 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -1725,9 +1725,7 @@ pa_emit_move_sequence (rtx *operands, machine_mode mode, rtx scratch_reg) } else emit_move_insn (scratch_reg, XEXP (op1, 0)); - emit_insn (gen_rtx_SET (operand0, - replace_equiv_address (op1, scratch_reg))); - return 1; + op1 = replace_equiv_address (op1, scratch_reg); } } else if ((!INT14_OK_STRICT && symbolic_memory_operand (op1, VOIDmode)) @@ -1737,10 +1735,10 @@ pa_emit_move_sequence (rtx *operands, machine_mode mode, rtx scratch_reg) /* Load memory address into SCRATCH_REG. */ scratch_reg = force_mode (word_mode, scratch_reg); emit_move_insn (scratch_reg, XEXP (op1, 0)); - emit_insn (gen_rtx_SET (operand0, - replace_equiv_address (op1, scratch_reg))); - return 1; + op1 = replace_equiv_address (op1, scratch_reg); } + emit_insn (gen_rtx_SET (operand0, op1)); + return 1; } else if (scratch_reg && FP_REG_P (operand1) @@ -1778,9 +1776,7 @@ pa_emit_move_sequence (rtx *operands, machine_mode mode, rtx scratch_reg) } else emit_move_insn (scratch_reg, XEXP (op0, 0)); - emit_insn (gen_rtx_SET (replace_equiv_address (op0, scratch_reg), - operand1)); - return 1; + op0 = replace_equiv_address (op0, scratch_reg); } } else if ((!INT14_OK_STRICT && symbolic_memory_operand (op0, VOIDmode)) @@ -1790,10 +1786,10 @@ pa_emit_move_sequence (rtx *operands, machine_mode mode, rtx scratch_reg) /* Load memory address into SCRATCH_REG. */ scratch_reg = force_mode (word_mode, scratch_reg); emit_move_insn (scratch_reg, XEXP (op0, 0)); - emit_insn (gen_rtx_SET (replace_equiv_address (op0, scratch_reg), - operand1)); - return 1; + op0 = replace_equiv_address (op0, scratch_reg); } + emit_insn (gen_rtx_SET (op0, operand1)); + return 1; } /* Handle secondary reloads for loads of FP registers from constant expressions by forcing the constant into memory. For the most part, diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index 53c6eb81154..32dfa8f999a 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -2615,39 +2615,49 @@ "lvx %0,%y1" [(set_attr "type" "vecload")]) -; The next two patterns embody what lvx should usually look like. -(define_insn "altivec_lvx_<mode>_2op" - [(set (match_operand:VM2 0 "register_operand" "=v") - (mem:VM2 (and:DI (plus:DI (match_operand:DI 1 "register_operand" "b") - (match_operand:DI 2 "register_operand" "r")) - (const_int -16))))] - "TARGET_ALTIVEC && TARGET_64BIT" - "lvx %0,%1,%2" - [(set_attr "type" "vecload")]) - -(define_insn "altivec_lvx_<mode>_1op" - [(set (match_operand:VM2 0 "register_operand" "=v") - (mem:VM2 (and:DI (match_operand:DI 1 "register_operand" "r") - (const_int -16))))] - "TARGET_ALTIVEC && TARGET_64BIT" - "lvx %0,0,%1" - [(set_attr "type" "vecload")]) +; The following patterns embody what lvx should usually look like. +(define_expand "altivec_lvx_<VM2:mode>" + [(set (match_operand:VM2 0 "register_operand") + (match_operand:VM2 1 "altivec_indexed_or_indirect_operand"))] + "TARGET_ALTIVEC" +{ + rtx addr = XEXP (operand1, 0); + if (GET_CODE (addr) == PLUS + && REG_P (XEXP (addr, 0)) + && REG_P (XEXP (addr, 1))) + { + rtx op1 = XEXP (addr, 0); + rtx op2 = XEXP (addr, 1); + if (TARGET_64BIT) + emit_insn (gen_altivec_lvx_<VM2:mode>_2op_di (operand0, op1, op2)); + else + emit_insn (gen_altivec_lvx_<VM2:mode>_2op_si (operand0, op1, op2)); + } + else + { + if (TARGET_64BIT) + emit_insn (gen_altivec_lvx_<VM2:mode>_1op_di (operand0, addr)); + else + emit_insn (gen_altivec_lvx_<VM2:mode>_1op_si (operand0, addr)); + } + DONE; +}) -; 32-bit versions of the above. -(define_insn "altivec_lvx_<mode>_2op_si" +; The next two patterns embody what lvx should usually look like. +(define_insn "altivec_lvx_<VM2:mode>_2op_<P:mptrsize>" [(set (match_operand:VM2 0 "register_operand" "=v") - (mem:VM2 (and:SI (plus:SI (match_operand:SI 1 "register_operand" "b") - (match_operand:SI 2 "register_operand" "r")) - (const_int -16))))] - "TARGET_ALTIVEC && TARGET_32BIT" + (mem:VM2 (and:P (plus:P (match_operand:P 1 "register_operand" "b") + (match_operand:P 2 "register_operand" "r")) + (const_int -16))))] + "TARGET_ALTIVEC" "lvx %0,%1,%2" [(set_attr "type" "vecload")]) -(define_insn "altivec_lvx_<mode>_1op_si" +(define_insn "altivec_lvx_<VM2:mode>_1op_<P:mptrsize>" [(set (match_operand:VM2 0 "register_operand" "=v") - (mem:VM2 (and:SI (match_operand:SI 1 "register_operand" "r") - (const_int -16))))] - "TARGET_ALTIVEC && TARGET_32BIT" + (mem:VM2 (and:P (match_operand:P 1 "register_operand" "r") + (const_int -16))))] + "TARGET_ALTIVEC" "lvx %0,0,%1" [(set_attr "type" "vecload")]) @@ -2663,39 +2673,49 @@ "stvx %1,%y0" [(set_attr "type" "vecstore")]) -; The next two patterns embody what stvx should usually look like. -(define_insn "altivec_stvx_<mode>_2op" - [(set (mem:VM2 (and:DI (plus:DI (match_operand:DI 1 "register_operand" "b") - (match_operand:DI 2 "register_operand" "r")) - (const_int -16))) - (match_operand:VM2 0 "register_operand" "v"))] - "TARGET_ALTIVEC && TARGET_64BIT" - "stvx %0,%1,%2" - [(set_attr "type" "vecstore")]) - -(define_insn "altivec_stvx_<mode>_1op" - [(set (mem:VM2 (and:DI (match_operand:DI 1 "register_operand" "r") - (const_int -16))) - (match_operand:VM2 0 "register_operand" "v"))] - "TARGET_ALTIVEC && TARGET_64BIT" - "stvx %0,0,%1" - [(set_attr "type" "vecstore")]) +; The following patterns embody what stvx should usually look like. +(define_expand "altivec_stvx_<VM2:mode>" + [(set (match_operand:VM2 1 "altivec_indexed_or_indirect_operand") + (match_operand:VM2 0 "register_operand"))] + "TARGET_ALTIVEC" +{ + rtx addr = XEXP (operand1, 0); + if (GET_CODE (addr) == PLUS + && REG_P (XEXP (addr, 0)) + && REG_P (XEXP (addr, 1))) + { + rtx op1 = XEXP (addr, 0); + rtx op2 = XEXP (addr, 1); + if (TARGET_64BIT) + emit_insn (gen_altivec_stvx_<VM2:mode>_2op_di (operand0, op1, op2)); + else + emit_insn (gen_altivec_stvx_<VM2:mode>_2op_si (operand0, op1, op2)); + } + else + { + if (TARGET_64BIT) + emit_insn (gen_altivec_stvx_<VM2:mode>_1op_di (operand0, addr)); + else + emit_insn (gen_altivec_stvx_<VM2:mode>_1op_si (operand0, addr)); + } + DONE; +}) -; 32-bit versions of the above. -(define_insn "altivec_stvx_<mode>_2op_si" - [(set (mem:VM2 (and:SI (plus:SI (match_operand:SI 1 "register_operand" "b") - (match_operand:SI 2 "register_operand" "r")) - (const_int -16))) - (match_operand:VM2 0 "register_operand" "v"))] - "TARGET_ALTIVEC && TARGET_32BIT" +; The next two patterns embody what stvx should usually look like. +(define_insn "altivec_stvx_<VM2:mode>_2op_<P:mptrsize>" + [(set (mem:VM2 (and:P (plus:P (match_operand:P 1 "register_operand" "b") + (match_operand:P 2 "register_operand" "r")) + (const_int -16))) + (match_operand:VM2 0 "register_operand" "v"))] + "TARGET_ALTIVEC" "stvx %0,%1,%2" [(set_attr "type" "vecstore")]) -(define_insn "altivec_stvx_<mode>_1op_si" - [(set (mem:VM2 (and:SI (match_operand:SI 1 "register_operand" "r") - (const_int -16))) - (match_operand:VM2 0 "register_operand" "v"))] - "TARGET_ALTIVEC && TARGET_32BIT" +(define_insn "altivec_stvx_<VM2:mode>_1op_<P:mptrsize>" + [(set (mem:VM2 (and:P (match_operand:P 1 "register_operand" "r") + (const_int -16))) + (match_operand:VM2 0 "register_operand" "v"))] + "TARGET_ALTIVEC" "stvx %0,0,%1" [(set_attr "type" "vecstore")]) diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index 00e8e602095..2cc07c6b5ae 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -1,5 +1,5 @@ /* Builtin functions for rs6000/powerpc. - Copyright (C) 2009-2017 Free Software Foundation, Inc. + Copyright (C) 2009-2018 Free Software Foundation, Inc. Contributed by Michael Meissner (meissner@linux.vnet.ibm.com) This file is part of GCC. @@ -659,6 +659,14 @@ | RS6000_BTC_BINARY), \ CODE_FOR_ ## ICODE) /* ICODE */ +#define BU_P7_POWERPC64_MISC_2(ENUM, NAME, ATTR, ICODE) \ + RS6000_BUILTIN_2 (MISC_BUILTIN_ ## ENUM, /* ENUM */ \ + "__builtin_" NAME, /* NAME */ \ + RS6000_BTM_POPCNTD /* MASK */ \ + | RS6000_BTM_POWERPC64, \ + (RS6000_BTC_ ## ATTR /* ATTR */ \ + | RS6000_BTC_BINARY), \ + CODE_FOR_ ## ICODE) /* ICODE */ /* Miscellaneous builtins for instructions added in ISA 2.07. These instructions do require the ISA 2.07 vector support, but they aren't vector @@ -2104,13 +2112,9 @@ BU_P9V_OVERLOAD_1 (VCTZLSBB, "vctzlsbb") /* 2 argument extended divide functions added in ISA 2.06. */ BU_P7_MISC_2 (DIVWE, "divwe", CONST, dive_si) -BU_P7_MISC_2 (DIVWEO, "divweo", CONST, diveo_si) BU_P7_MISC_2 (DIVWEU, "divweu", CONST, diveu_si) -BU_P7_MISC_2 (DIVWEUO, "divweuo", CONST, diveuo_si) -BU_P7_MISC_2 (DIVDE, "divde", CONST, dive_di) -BU_P7_MISC_2 (DIVDEO, "divdeo", CONST, diveo_di) -BU_P7_MISC_2 (DIVDEU, "divdeu", CONST, diveu_di) -BU_P7_MISC_2 (DIVDEUO, "divdeuo", CONST, diveuo_di) +BU_P7_POWERPC64_MISC_2 (DIVDE, "divde", CONST, dive_di) +BU_P7_POWERPC64_MISC_2 (DIVDEU, "divdeu", CONST, diveu_di) /* 1 argument DFP (decimal floating point) functions added in ISA 2.05. */ BU_DFP_MISC_1 (DXEX, "dxex", CONST, dfp_dxex_dd) diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c index c6fd52439eb..24904d1bd74 100644 --- a/gcc/config/rs6000/rs6000-c.c +++ b/gcc/config/rs6000/rs6000-c.c @@ -6075,6 +6075,15 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, stmt = build_binary_op (loc, PLUS_EXPR, stmt, arg2, 1); stmt = build_indirect_ref (loc, stmt, RO_NULL); + /* PR83660: We mark this as having side effects so that + downstream in fold_build_cleanup_point_expr () it will get a + CLEANUP_POINT_EXPR. If it does not we can run into an ICE + later in gimplify_cleanup_point_expr (). Potentially this + causes missed optimization because the actually is no side + effect. */ + if (c_dialect_cxx ()) + TREE_SIDE_EFFECTS (stmt) = 1; + return stmt; } diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 0d7fc51a5f5..2bee615602c 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1,5 +1,5 @@ /* Subroutines used for code generation on IBM RS/6000. - Copyright (C) 1991-2017 Free Software Foundation, Inc. + Copyright (C) 1991-2018 Free Software Foundation, Inc. Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) This file is part of GCC. @@ -1372,6 +1372,7 @@ static rtx rs6000_debug_legitimize_reload_address (rtx, machine_mode, int, int, int, int *); static bool rs6000_mode_dependent_address (const_rtx); static bool rs6000_debug_mode_dependent_address (const_rtx); +static bool rs6000_offsettable_memref_p (rtx, machine_mode, bool); static enum reg_class rs6000_secondary_reload_class (enum reg_class, machine_mode, rtx); static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class, @@ -3890,6 +3891,7 @@ rs6000_builtin_mask_calculate (void) | ((TARGET_P9_MISC) ? RS6000_BTM_P9_MISC : 0) | ((TARGET_MODULO) ? RS6000_BTM_MODULO : 0) | ((TARGET_64BIT) ? RS6000_BTM_64BIT : 0) + | ((TARGET_POWERPC64) ? RS6000_BTM_POWERPC64 : 0) | ((TARGET_CRYPTO) ? RS6000_BTM_CRYPTO : 0) | ((TARGET_HTM) ? RS6000_BTM_HTM : 0) | ((TARGET_DFP) ? RS6000_BTM_DFP : 0) @@ -8563,10 +8565,8 @@ mem_operand_gpr (rtx op, machine_mode mode) int extra; rtx addr = XEXP (op, 0); - /* Don't allow altivec type addresses like (mem (and (plus ...))). - See PR target/84279. */ - - if (GET_CODE (addr) == AND) + /* Don't allow non-offsettable addresses. See PRs 83969 and 84279. */ + if (!rs6000_offsettable_memref_p (op, mode, false)) return false; op = address_offset (addr); @@ -10339,7 +10339,7 @@ rs6000_find_base_term (rtx op) in 32-bit mode, that the recog predicate rejects. */ static bool -rs6000_offsettable_memref_p (rtx op, machine_mode reg_mode) +rs6000_offsettable_memref_p (rtx op, machine_mode reg_mode, bool strict) { bool worst_case; @@ -10347,7 +10347,7 @@ rs6000_offsettable_memref_p (rtx op, machine_mode reg_mode) return false; /* First mimic offsettable_memref_p. */ - if (offsettable_address_p (true, GET_MODE (op), XEXP (op, 0))) + if (offsettable_address_p (strict, GET_MODE (op), XEXP (op, 0))) return true; /* offsettable_address_p invokes rs6000_mode_dependent_address, but @@ -10361,7 +10361,7 @@ rs6000_offsettable_memref_p (rtx op, machine_mode reg_mode) worst_case = ((TARGET_POWERPC64 && GET_MODE_CLASS (reg_mode) == MODE_INT) || GET_MODE_SIZE (reg_mode) == 4); return rs6000_legitimate_offset_address_p (GET_MODE (op), XEXP (op, 0), - true, worst_case); + strict, worst_case); } /* Determine the reassociation width to be used in reassociate_bb. @@ -15098,12 +15098,12 @@ altivec_expand_lv_builtin (enum insn_code icode, tree exp, rtx target, bool blk) /* For LVX, express the RTL accurately by ANDing the address with -16. LVXL and LVE*X expand to use UNSPECs to hide their special behavior, so the raw address is fine. */ - if (icode == CODE_FOR_altivec_lvx_v2df_2op - || icode == CODE_FOR_altivec_lvx_v2di_2op - || icode == CODE_FOR_altivec_lvx_v4sf_2op - || icode == CODE_FOR_altivec_lvx_v4si_2op - || icode == CODE_FOR_altivec_lvx_v8hi_2op - || icode == CODE_FOR_altivec_lvx_v16qi_2op) + if (icode == CODE_FOR_altivec_lvx_v2df + || icode == CODE_FOR_altivec_lvx_v2di + || icode == CODE_FOR_altivec_lvx_v4sf + || icode == CODE_FOR_altivec_lvx_v4si + || icode == CODE_FOR_altivec_lvx_v8hi + || icode == CODE_FOR_altivec_lvx_v16qi) { rtx rawaddr; if (op0 == const0_rtx) @@ -15289,12 +15289,12 @@ altivec_expand_stv_builtin (enum insn_code icode, tree exp) /* For STVX, express the RTL accurately by ANDing the address with -16. STVXL and STVE*X expand to use UNSPECs to hide their special behavior, so the raw address is fine. */ - if (icode == CODE_FOR_altivec_stvx_v2df_2op - || icode == CODE_FOR_altivec_stvx_v2di_2op - || icode == CODE_FOR_altivec_stvx_v4sf_2op - || icode == CODE_FOR_altivec_stvx_v4si_2op - || icode == CODE_FOR_altivec_stvx_v8hi_2op - || icode == CODE_FOR_altivec_stvx_v16qi_2op) + if (icode == CODE_FOR_altivec_stvx_v2df + || icode == CODE_FOR_altivec_stvx_v2di + || icode == CODE_FOR_altivec_stvx_v4sf + || icode == CODE_FOR_altivec_stvx_v4si + || icode == CODE_FOR_altivec_stvx_v8hi + || icode == CODE_FOR_altivec_stvx_v16qi) { if (op1 == const0_rtx) rawaddr = op2; @@ -16195,18 +16195,18 @@ altivec_expand_builtin (tree exp, rtx target, bool *expandedp) switch (fcode) { case ALTIVEC_BUILTIN_STVX_V2DF: - return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v2df_2op, exp); + return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v2df, exp); case ALTIVEC_BUILTIN_STVX_V2DI: - return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v2di_2op, exp); + return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v2di, exp); case ALTIVEC_BUILTIN_STVX_V4SF: - return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v4sf_2op, exp); + return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v4sf, exp); case ALTIVEC_BUILTIN_STVX: case ALTIVEC_BUILTIN_STVX_V4SI: - return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v4si_2op, exp); + return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v4si, exp); case ALTIVEC_BUILTIN_STVX_V8HI: - return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v8hi_2op, exp); + return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v8hi, exp); case ALTIVEC_BUILTIN_STVX_V16QI: - return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v16qi_2op, exp); + return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v16qi, exp); case ALTIVEC_BUILTIN_STVEBX: return altivec_expand_stv_builtin (CODE_FOR_altivec_stvebx, exp); case ALTIVEC_BUILTIN_STVEHX: @@ -16470,23 +16470,23 @@ altivec_expand_builtin (tree exp, rtx target, bool *expandedp) return altivec_expand_lv_builtin (CODE_FOR_altivec_lvxl_v16qi, exp, target, false); case ALTIVEC_BUILTIN_LVX_V2DF: - return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v2df_2op, + return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v2df, exp, target, false); case ALTIVEC_BUILTIN_LVX_V2DI: - return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v2di_2op, + return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v2di, exp, target, false); case ALTIVEC_BUILTIN_LVX_V4SF: - return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v4sf_2op, + return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v4sf, exp, target, false); case ALTIVEC_BUILTIN_LVX: case ALTIVEC_BUILTIN_LVX_V4SI: - return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v4si_2op, + return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v4si, exp, target, false); case ALTIVEC_BUILTIN_LVX_V8HI: - return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v8hi_2op, + return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v8hi, exp, target, false); case ALTIVEC_BUILTIN_LVX_V16QI: - return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v16qi_2op, + return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v16qi, exp, target, false); case ALTIVEC_BUILTIN_LVLX: return altivec_expand_lv_builtin (CODE_FOR_altivec_lvlx, @@ -17050,6 +17050,11 @@ rs6000_invalid_builtin (enum rs6000_builtins fncode) error ("Builtin function %s requires the -mhard-float option", name); else if ((fnmask & RS6000_BTM_FLOAT128) != 0) error ("Builtin function %s requires the -mfloat128 option", name); + else if ((fnmask & (RS6000_BTM_POPCNTD | RS6000_BTM_POWERPC64)) + == (RS6000_BTM_POPCNTD | RS6000_BTM_POWERPC64)) + error ("builtin function %qs requires the %qs (or newer), and " + "%qs or %qs options", + name, "-mcpu=power7", "-m64", "-mpowerpc64"); else error ("Builtin function %s is not supported with the current options", name); @@ -18814,9 +18819,7 @@ builtin_function_type (machine_mode mode_ret, machine_mode mode_arg0, case CRYPTO_BUILTIN_VPMSUM: case MISC_BUILTIN_ADDG6S: case MISC_BUILTIN_DIVWEU: - case MISC_BUILTIN_DIVWEUO: case MISC_BUILTIN_DIVDEU: - case MISC_BUILTIN_DIVDEUO: h.uns_p[0] = 1; h.uns_p[1] = 1; h.uns_p[2] = 1; @@ -26555,7 +26558,7 @@ rs6000_split_multireg_move (rtx dst, rtx src) emit_insn (gen_add3_insn (breg, breg, delta_rtx)); src = replace_equiv_address (src, breg); } - else if (! rs6000_offsettable_memref_p (src, reg_mode)) + else if (! rs6000_offsettable_memref_p (src, reg_mode, true)) { if (GET_CODE (XEXP (src, 0)) == PRE_MODIFY) { @@ -26622,7 +26625,7 @@ rs6000_split_multireg_move (rtx dst, rtx src) emit_insn (gen_add3_insn (breg, breg, delta_rtx)); dst = replace_equiv_address (dst, breg); } - else if (!rs6000_offsettable_memref_p (dst, reg_mode) + else if (!rs6000_offsettable_memref_p (dst, reg_mode, true) && GET_CODE (XEXP (dst, 0)) != LO_SUM) { if (GET_CODE (XEXP (dst, 0)) == PRE_MODIFY) @@ -26661,7 +26664,7 @@ rs6000_split_multireg_move (rtx dst, rtx src) } } else if (GET_CODE (XEXP (dst, 0)) != LO_SUM) - gcc_assert (rs6000_offsettable_memref_p (dst, reg_mode)); + gcc_assert (rs6000_offsettable_memref_p (dst, reg_mode, true)); } for (i = 0; i < nregs; i++) @@ -35615,6 +35618,11 @@ rs6000_elf_in_small_data_p (const_tree decl) } else { + /* If we are told not to put readonly data in sdata, then don't. */ + if (TREE_READONLY (decl) && rs6000_sdata != SDATA_EABI + && !rs6000_readonly_in_sdata) + return false; + HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl)); if (size > 0 @@ -39135,6 +39143,7 @@ static struct rs6000_opt_mask const rs6000_builtin_mask_names[] = { "hard-dfp", RS6000_BTM_DFP, false, false }, { "hard-float", RS6000_BTM_HARD_FLOAT, false, false }, { "long-double-128", RS6000_BTM_LDBL128, false, false }, + { "powerpc64", RS6000_BTM_POWERPC64, false, false }, { "float128", RS6000_BTM_FLOAT128, false, false }, }; @@ -41872,6 +41881,7 @@ rtx_is_swappable_p (rtx op, unsigned int *special) case UNSPEC_VPERM_UNS: case UNSPEC_VPERMHI: case UNSPEC_VPERMSI: + case UNSPEC_VPERMXOR: case UNSPEC_VPKPX: case UNSPEC_VSLDOI: case UNSPEC_VSLO: diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index 3780a49d902..76c44ef31b3 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -1,5 +1,5 @@ /* Definitions of target machine for GNU compiler, for IBM RS/6000. - Copyright (C) 1992-2017 Free Software Foundation, Inc. + Copyright (C) 1992-2018 Free Software Foundation, Inc. Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) This file is part of GCC. @@ -2735,6 +2735,7 @@ extern int frame_pointer_needed; #define RS6000_BTM_HARD_FLOAT MASK_SOFT_FLOAT /* Hardware floating point. */ #define RS6000_BTM_LDBL128 MASK_MULTIPLE /* 128-bit long double. */ #define RS6000_BTM_64BIT MASK_64BIT /* 64-bit addressing. */ +#define RS6000_BTM_POWERPC64 MASK_POWERPC64 /* 64-bit registers. */ #define RS6000_BTM_FLOAT128 MASK_FLOAT128_TYPE /* IEEE 128-bit float. */ #define RS6000_BTM_COMMON (RS6000_BTM_ALTIVEC \ @@ -2754,6 +2755,7 @@ extern int frame_pointer_needed; | RS6000_BTM_DFP \ | RS6000_BTM_HARD_FLOAT \ | RS6000_BTM_LDBL128 \ + | RS6000_BTM_POWERPC64 \ | RS6000_BTM_FLOAT128) /* Define builtin enum index. */ diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index e83f80b7121..ca7c04e275a 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -1,5 +1,5 @@ ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler -;; Copyright (C) 1990-2017 Free Software Foundation, Inc. +;; Copyright (C) 1990-2018 Free Software Foundation, Inc. ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) ;; This file is part of GCC. @@ -135,9 +135,7 @@ UNSPEC_CDTBCD UNSPEC_CBCDTD UNSPEC_DIVE - UNSPEC_DIVEO UNSPEC_DIVEU - UNSPEC_DIVEUO UNSPEC_UNPACK_128BIT UNSPEC_PACK_128BIT UNSPEC_LSQ @@ -8642,14 +8640,14 @@ ;; FPR->GPR GPR->FPR VSX->GPR GPR->VSX (define_insn "*movdi_internal64" [(set (match_operand:DI 0 "nonimmediate_operand" - "=Y, r, r, r, r, r, + "=YZ, r, r, r, r, r, ^m, ^d, ^d, ^wY, $Z, $wb, $wv, ^wi, *wo, *wo, *wv, *wi, *wi, *wv, *wv, r, *h, *h, ?*r, ?*wg, ?*r, ?*wj") (match_operand:DI 1 "input_operand" - "r, Y, r, I, L, nF, + "r, YZ, r, I, L, nF, d, m, d, wb, wv, wY, Z, wi, Oj, wM, OjwM, Oj, wM, wS, wB, *h, r, 0, @@ -14383,14 +14381,10 @@ (set_attr "length" "4")]) (define_int_iterator UNSPEC_DIV_EXTEND [UNSPEC_DIVE - UNSPEC_DIVEO - UNSPEC_DIVEU - UNSPEC_DIVEUO]) + UNSPEC_DIVEU]) (define_int_attr div_extend [(UNSPEC_DIVE "e") - (UNSPEC_DIVEO "eo") - (UNSPEC_DIVEU "eu") - (UNSPEC_DIVEUO "euo")]) + (UNSPEC_DIVEU "eu")]) (define_insn "div<div_extend>_<mode>" [(set (match_operand:GPR 0 "register_operand" "=r") diff --git a/gcc/config/rs6000/sysv4.opt b/gcc/config/rs6000/sysv4.opt index 423300b8148..1492871da7d 100644 --- a/gcc/config/rs6000/sysv4.opt +++ b/gcc/config/rs6000/sysv4.opt @@ -27,6 +27,10 @@ msdata= Target RejectNegative Joined Var(rs6000_sdata_name) Select method for sdata handling. +mreadonly-in-sdata +Target Report Var(rs6000_readonly_in_sdata) Init(1) Save +Allow readonly data in sdata. + mtls-size= Target RejectNegative Joined Var(rs6000_tls_size) Enum(rs6000_tls_size) Specify bit size of immediate TLS offsets. diff --git a/gcc/config/rs6000/vector.md b/gcc/config/rs6000/vector.md index ea8169fabe0..a9ec9a9981a 100644 --- a/gcc/config/rs6000/vector.md +++ b/gcc/config/rs6000/vector.md @@ -180,12 +180,7 @@ operands[1] = rs6000_address_for_altivec (operands[1]); rtx and_op = XEXP (operands[1], 0); gcc_assert (GET_CODE (and_op) == AND); - rtx addr = XEXP (and_op, 0); - if (GET_CODE (addr) == PLUS) - emit_insn (gen_altivec_lvx_<mode>_2op (operands[0], XEXP (addr, 0), - XEXP (addr, 1))); - else - emit_insn (gen_altivec_lvx_<mode>_1op (operands[0], operands[1])); + emit_insn (gen_altivec_lvx_<mode> (operands[0], operands[1])); DONE; } }") @@ -203,12 +198,7 @@ operands[0] = rs6000_address_for_altivec (operands[0]); rtx and_op = XEXP (operands[0], 0); gcc_assert (GET_CODE (and_op) == AND); - rtx addr = XEXP (and_op, 0); - if (GET_CODE (addr) == PLUS) - emit_insn (gen_altivec_stvx_<mode>_2op (operands[1], XEXP (addr, 0), - XEXP (addr, 1))); - else - emit_insn (gen_altivec_stvx_<mode>_1op (operands[1], operands[0])); + emit_insn (gen_altivec_stvx_<mode> (operands[1], operands[0])); DONE; } }") diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index e63ed24476a..eef53578abb 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -157,6 +157,22 @@ (TF "wp") (KF "wq")]) +;; A mode attribute to disparage use of GPR registers, except for scalar +;; interger modes. +(define_mode_attr ??r [(V16QI "??r") + (V8HI "??r") + (V4SI "??r") + (V4SF "??r") + (V2DI "??r") + (V2DF "??r") + (DI "r") + (DF "??r") + (SF "??r") + (V1TI "??r") + (TI "r") + (TF "??r") + (KF "??r")]) + ;; Same size integer type for floating point data (define_mode_attr VSi [(V4SF "v4si") (V2DF "v2di") @@ -961,7 +977,7 @@ (define_insn "*vsx_mov<mode>_64bit" [(set (match_operand:VSX_M 0 "nonimmediate_operand" "=ZwO, <VSa>, <VSa>, r, we, ?wQ, - ?&r, ??r, ??Y, ??r, wo, v, + ?&r, ??r, ??Y, <??r>, wo, v, ?<VSa>, *r, v, ??r, wZ, v") (match_operand:VSX_M 1 "input_operand" @@ -990,7 +1006,7 @@ ;; LVX (VMX) STVX (VMX) (define_insn "*vsx_mov<mode>_32bit" [(set (match_operand:VSX_M 0 "nonimmediate_operand" - "=ZwO, <VSa>, <VSa>, ??r, ??Y, ??r, + "=ZwO, <VSa>, <VSa>, ??r, ??Y, <??r>, wo, v, ?<VSa>, *r, v, ??r, wZ, v") diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index bc8e71a883d..603f5d6486e 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -15965,7 +15965,7 @@ s390_output_indirect_thunk_function (unsigned int regno, bool z10_p) Stopping in the thunk: backtrace will point to the thunk target is if it was interrupted by a signal. For a call this means that the call chain will be: caller->callee->thunk */ - if (flag_asynchronous_unwind_tables) + if (flag_asynchronous_unwind_tables && flag_dwarf2_cfi_asm) { fputs ("\t.cfi_signal_frame\n", asm_out_file); fprintf (asm_out_file, "\t.cfi_return_column %d\n", regno); diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index b9c8dcc57c1..ed3bea2a9a7 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -2188,7 +2188,7 @@ sparc_expand_move (machine_mode mode, rtx *operands) } } - /* Fixup TLS cases. */ + /* Fix up TLS cases. */ if (TARGET_HAVE_TLS && CONSTANT_P (operands[1]) && sparc_tls_referenced_p (operands [1])) @@ -2197,15 +2197,20 @@ sparc_expand_move (machine_mode mode, rtx *operands) return false; } - /* Fixup PIC cases. */ + /* Fix up PIC cases. */ if (flag_pic && CONSTANT_P (operands[1])) { if (pic_address_needs_scratch (operands[1])) operands[1] = sparc_legitimize_pic_address (operands[1], NULL_RTX); /* We cannot use the mov{si,di}_pic_label_ref patterns in all cases. */ - if (GET_CODE (operands[1]) == LABEL_REF - && can_use_mov_pic_label_ref (operands[1])) + if ((GET_CODE (operands[1]) == LABEL_REF + && can_use_mov_pic_label_ref (operands[1])) + || (GET_CODE (operands[1]) == CONST + && GET_CODE (XEXP (operands[1], 0)) == PLUS + && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF + && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT + && can_use_mov_pic_label_ref (XEXP (XEXP (operands[1], 0), 0)))) { if (mode == SImode) { @@ -2215,7 +2220,6 @@ sparc_expand_move (machine_mode mode, rtx *operands) if (mode == DImode) { - gcc_assert (TARGET_ARCH64); emit_insn (gen_movdi_pic_label_ref (operands[0], operands[1])); return true; } @@ -4216,10 +4220,11 @@ int pic_address_needs_scratch (rtx x) { /* An address which is a symbolic plus a non SMALL_INT needs a temp reg. */ - if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS + if (GET_CODE (x) == CONST + && GET_CODE (XEXP (x, 0)) == PLUS && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT - && ! SMALL_INT (XEXP (XEXP (x, 0), 1))) + && !SMALL_INT (XEXP (XEXP (x, 0), 1))) return 1; return 0; @@ -4667,16 +4672,15 @@ sparc_legitimize_tls_address (rtx addr) static rtx sparc_legitimize_pic_address (rtx orig, rtx reg) { - bool gotdata_op = false; - if (GET_CODE (orig) == SYMBOL_REF /* See the comment in sparc_expand_move. */ || (GET_CODE (orig) == LABEL_REF && !can_use_mov_pic_label_ref (orig))) { + bool gotdata_op = false; rtx pic_ref, address; rtx_insn *insn; - if (reg == 0) + if (!reg) { gcc_assert (can_create_pseudo_p ()); reg = gen_reg_rtx (Pmode); @@ -4687,8 +4691,7 @@ sparc_legitimize_pic_address (rtx orig, rtx reg) /* If not during reload, allocate another temp reg here for loading in the address, so that these instructions can be optimized properly. */ - rtx temp_reg = (! can_create_pseudo_p () - ? reg : gen_reg_rtx (Pmode)); + rtx temp_reg = can_create_pseudo_p () ? gen_reg_rtx (Pmode) : reg; /* Must put the SYMBOL_REF inside an UNSPEC here so that cse won't get confused into thinking that these two instructions @@ -4704,6 +4707,7 @@ sparc_legitimize_pic_address (rtx orig, rtx reg) emit_insn (gen_movsi_high_pic (temp_reg, orig)); emit_insn (gen_movsi_lo_sum_pic (temp_reg, temp_reg, orig)); } + address = temp_reg; gotdata_op = true; } @@ -4744,7 +4748,7 @@ sparc_legitimize_pic_address (rtx orig, rtx reg) && XEXP (XEXP (orig, 0), 0) == pic_offset_table_rtx) return orig; - if (reg == 0) + if (!reg) { gcc_assert (can_create_pseudo_p ()); reg = gen_reg_rtx (Pmode); @@ -4853,7 +4857,11 @@ sparc_delegitimize_address (rtx x) && XINT (XEXP (XEXP (x, 1), 1), 1) == UNSPEC_MOVE_PIC_LABEL) { x = XVECEXP (XEXP (XEXP (x, 1), 1), 0, 0); - gcc_assert (GET_CODE (x) == LABEL_REF); + gcc_assert (GET_CODE (x) == LABEL_REF + || (GET_CODE (x) == CONST + && GET_CODE (XEXP (x, 0)) == PLUS + && GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF + && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT)); } return x; diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md index 4ddbe56fbf4..55d41ef8dc7 100644 --- a/gcc/config/sparc/sparc.md +++ b/gcc/config/sparc/sparc.md @@ -1758,7 +1758,7 @@ (define_expand "movsi_pic_label_ref" [(set (match_dup 3) (high:SI - (unspec:SI [(match_operand:SI 1 "label_ref_operand" "") + (unspec:SI [(match_operand:SI 1 "symbolic_operand" "") (match_dup 2)] UNSPEC_MOVE_PIC_LABEL))) (set (match_dup 4) (lo_sum:SI (match_dup 3) (unspec:SI [(match_dup 1) (match_dup 2)] UNSPEC_MOVE_PIC_LABEL))) @@ -1784,7 +1784,7 @@ (define_insn "*movsi_high_pic_label_ref" [(set (match_operand:SI 0 "register_operand" "=r") (high:SI - (unspec:SI [(match_operand:SI 1 "label_ref_operand" "") + (unspec:SI [(match_operand:SI 1 "symbolic_operand" "") (match_operand:SI 2 "" "")] UNSPEC_MOVE_PIC_LABEL)))] "flag_pic" "sethi\t%%hi(%a2-(%a1-.)), %0") @@ -1792,7 +1792,7 @@ (define_insn "*movsi_lo_sum_pic_label_ref" [(set (match_operand:SI 0 "register_operand" "=r") (lo_sum:SI (match_operand:SI 1 "register_operand" "r") - (unspec:SI [(match_operand:SI 2 "label_ref_operand" "") + (unspec:SI [(match_operand:SI 2 "symbolic_operand" "") (match_operand:SI 3 "" "")] UNSPEC_MOVE_PIC_LABEL)))] "flag_pic" "or\t%1, %%lo(%a3-(%a2-.)), %0") @@ -1896,7 +1896,7 @@ visl") (define_expand "movdi_pic_label_ref" [(set (match_dup 3) (high:DI - (unspec:DI [(match_operand:DI 1 "label_ref_operand" "") + (unspec:DI [(match_operand:DI 1 "symbolic_operand" "") (match_dup 2)] UNSPEC_MOVE_PIC_LABEL))) (set (match_dup 4) (lo_sum:DI (match_dup 3) (unspec:DI [(match_dup 1) (match_dup 2)] UNSPEC_MOVE_PIC_LABEL))) @@ -1922,7 +1922,7 @@ visl") (define_insn "*movdi_high_pic_label_ref" [(set (match_operand:DI 0 "register_operand" "=r") (high:DI - (unspec:DI [(match_operand:DI 1 "label_ref_operand" "") + (unspec:DI [(match_operand:DI 1 "symbolic_operand" "") (match_operand:DI 2 "" "")] UNSPEC_MOVE_PIC_LABEL)))] "TARGET_ARCH64 && flag_pic" "sethi\t%%hi(%a2-(%a1-.)), %0") @@ -1930,7 +1930,7 @@ visl") (define_insn "*movdi_lo_sum_pic_label_ref" [(set (match_operand:DI 0 "register_operand" "=r") (lo_sum:DI (match_operand:DI 1 "register_operand" "r") - (unspec:DI [(match_operand:DI 2 "label_ref_operand" "") + (unspec:DI [(match_operand:DI 2 "symbolic_operand" "") (match_operand:DI 3 "" "")] UNSPEC_MOVE_PIC_LABEL)))] "TARGET_ARCH64 && flag_pic" "or\t%1, %%lo(%a3-(%a2-.)), %0") diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1eb8b0af0cf..ac3becb1c13 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,143 @@ +2018-04-23 Ville Voutilainen <ville.voutilainen@gmail.com> + + Backport from mainline + 2018-04-05 Ville Voutilainen <ville.voutilainen@gmail.com> + + Implement P0969 + * decl.c (find_decomp_class_base): Check accessibility instead + of declared access, adjust diagnostic. + +2018-04-23 Jakub Jelinek <jakub@redhat.com> + Jason Merrill <jason@redhat.com> + + PR c++/85470 - wrong error with static data member. + * decl.c (check_initializer): Check DECL_INITIALIZED_IN_CLASS_P. + * typeck2.c (store_init_value): Likewise. + +2018-04-23 Ville Voutilainen <ville.voutilainen@gmail.com> + + Backport from mainline + 2018-04-05 Ville Voutilainen <ville.voutilainen@gmail.com> + + Implement P0961 + * decl.c (get_tuple_decomp_init): Check the templatedness + of a member get. + +2018-04-19 Jonathan Wakely <jwakely@redhat.com> + + PR c++/85464 - missing location for -Wignored-qualifiers diagnostic + * decl.c (grokdeclarator): If declspecs->locations[ds_type_spec] + is UNKNOWN_LOCATION fall back to input_location. + +2018-04-09 Jason Merrill <jason@redhat.com> + + PR c++/85279 - dump_expr doesn't understand decltype. + * error.c (dump_expr): Handle DECLTYPE_TYPE. + +2018-04-05 Jason Merrill <jason@redhat.com> + + PR c++/82152 - ICE with class deduction and inherited ctor. + * pt.c (do_class_deduction): Ignore inherited ctors. + + PR c++/84665 - ICE with array of empty class. + * decl2.c (cp_check_const_attributes): Use fold_non_dependent_expr. + + PR c++/85006 - -fconcepts ICE with A<auto...> return type + * pt.c (tsubst_pack_expansion): Allow unsubstituted auto pack. + +2018-04-04 Jason Merrill <jason@redhat.com> + + PR c++/85118 - wrong error with generic lambda and std::bind. + * call.c (add_template_conv_candidate): Disable if there are any + call operators. + + PR c++/85148 - ICE with 'this' in array NSDMI. + * tree.c (replace_placeholders_r): Use handled_component_p. + +2018-04-03 Jason Merrill <jason@redhat.com> + + PR c++/85113 - ICE with constexpr and __builtin_constant_p. + * constexpr.c (cxx_eval_builtin_function_call): Only defer + __builtin_constant_p if ctx->quiet. + + * typeck.c (merge_types): Limit matching attribute shortcut to + the default case. + + PR c++/64095 - auto... parameter pack. + * parser.c (cp_parser_parameter_declaration): Handle turning autos + into packs here. + (cp_parser_parameter_declaration_list): Not here. + + PR c++/85060 - wrong-code with call to base member in template. + * search.c (any_dependent_bases_p): Check uses_template_parms + rather than processing_template_decl. + +2018-03-29 Ville Voutilainen <ville.voutilainen@gmail.com> + + Backport from mainline + 2018-03-23 Ville Voutilainen <ville.voutilainen@gmail.com> + + Implement P0962 + * parser.c (cp_parser_perform_range_for_lookup): Change + the condition for deciding whether to use members. + +2018-03-23 Jason Merrill <jason@redhat.com> + + PR c++/78489 - Substitution in wrong order + PR c++/84489 + * pt.c (type_unification_real): Revert last two changes. + + PR c++/71834 - template-id with too few arguments. + * pt.c (coerce_template_parms): Make sure we gave an error. + + PR c++/84937 - ICE with class deduction and auto. + * pt.c (rewrite_template_parm): Fix auto handling. + + PR c++/80227 - SFINAE and negative array size. + * decl.c (compute_array_index_type): Convert to signed for negative + check. + + PR c++/84839 - ICE with decltype of parameter pack. + * pt.c (tsubst_pack_expansion): Set cp_unevaluated_operand while + instantiating dummy parms. + + PR c++/84798 - ICE with auto in abstract function declarator. + * parser.c (cp_parser_parameter_declaration_clause): Check + parser->default_arg_ok_p. + + PR c++/84355 - ICE with deduction for member class template. + * pt.c (tsubst) [TEMPLATE_TYPE_PARM]: Always substitute into + CLASS_PLACEHOLDER_TEMPLATE. + +2018-03-23 Paolo Carlini <paolo.carlini@oracle.com> + Jason Merrill <jason@redhat.com> + + PR c++/82336 - link error with list-init default argument. + * decl.c (check_default_argument): Unshare an initializer list. + +2018-03-22 Marek Polacek <polacek@redhat.com> + + Backported from mainline + 2018-03-22 Marek Polacek <polacek@redhat.com> + + PR c++/84854 + * semantics.c (finish_if_stmt_cond): Check if the type of the condition + is boolean. + + 2018-03-19 Marek Polacek <polacek@redhat.com> + + PR c++/84927 + * constexpr.c (cxx_eval_bare_aggregate): Update constructor's flags + as we evaluate the elements. + (cxx_eval_constant_expression): Verify constructor's flags + unconditionally. + + 2018-03-21 Marek Polacek <polacek@redhat.com> + + PR c++/71638, ICE with NSDMI and reference. + * constexpr.c (cxx_eval_bare_aggregate): Update constructor's flags + even when we replace an element. + 2018-03-09 Jason Merrill <jason@redhat.com> PR c++/84785 - ICE with alias template and default targs. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 87729ac01e8..012134fd47a 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3259,10 +3259,10 @@ add_template_conv_candidate (struct z_candidate **candidates, tree tmpl, tree return_type, tree access_path, tree conversion_path, tsubst_flags_t complain) { - /* Making this work broke PR 71117, so until the committee resolves core - issue 2189, let's disable this candidate if there are any viable call + /* Making this work broke PR 71117 and 85118, so until the committee resolves + core issue 2189, let's disable this candidate if there are any call operators. */ - if (any_strictly_viable (*candidates)) + if (*candidates) return NULL; return diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 49dab47c149..96f8277bdf2 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1140,7 +1140,10 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun, /* Don't fold __builtin_constant_p within a constexpr function. */ bool bi_const_p = (DECL_FUNCTION_CODE (fun) == BUILT_IN_CONSTANT_P); + /* If we aren't requiring a constant expression, defer __builtin_constant_p + in a constexpr function until we have values for the parameters. */ if (bi_const_p + && ctx->quiet && current_function_decl && DECL_DECLARED_CONSTEXPR_P (current_function_decl)) { @@ -2785,14 +2788,20 @@ cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t, gcc_assert (is_empty_class (TREE_TYPE (TREE_TYPE (index)))); changed = true; } - else if (new_ctx.ctor != ctx->ctor) + else { - /* We appended this element above; update the value. */ - gcc_assert ((*p)->last().index == index); - (*p)->last().value = elt; + if (new_ctx.ctor != ctx->ctor) + { + /* We appended this element above; update the value. */ + gcc_assert ((*p)->last().index == index); + (*p)->last().value = elt; + } + else + CONSTRUCTOR_APPEND_ELT (*p, index, elt); + /* Adding or replacing an element might change the ctor's flags. */ + TREE_CONSTANT (ctx->ctor) = constant_p; + TREE_SIDE_EFFECTS (ctx->ctor) = side_effects_p; } - else - CONSTRUCTOR_APPEND_ELT (*p, index, elt); } if (*non_constant_p || !changed) return t; @@ -4439,11 +4448,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, { /* Don't re-process a constant CONSTRUCTOR, but do fold it to VECTOR_CST if applicable. */ - /* FIXME after GCC 6 branches, make the verify unconditional. */ - if (CHECKING_P) - verify_constructor_flags (t); - else - recompute_constructor_flags (t); + verify_constructor_flags (t); if (TREE_CONSTANT (t)) return fold (t); } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 730a6f1be37..836506ef7be 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -6400,7 +6400,9 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups) } if (init_code - && (DECL_IN_AGGR_P (decl) && !DECL_VAR_DECLARED_INLINE_P (decl))) + && (DECL_IN_AGGR_P (decl) + && DECL_INITIALIZED_IN_CLASS_P (decl) + && !DECL_VAR_DECLARED_INLINE_P (decl))) { static int explained = 0; @@ -7228,9 +7230,9 @@ find_decomp_class_base (location_t loc, tree type, tree ret) inform (DECL_SOURCE_LOCATION (field), "declared here"); return error_mark_node; } - else if (TREE_PRIVATE (field) || TREE_PROTECTED (field)) + else if (!accessible_p (type, field, true)) { - error_at (loc, "cannot decompose non-public member %qD of %qT", + error_at (loc, "cannot decompose inaccessible member %qD of %qT", field, type); inform (DECL_SOURCE_LOCATION (field), TREE_PRIVATE (field) @@ -7338,7 +7340,29 @@ get_tuple_decomp_init (tree decl, unsigned i) tree fns = lookup_qualified_name (TREE_TYPE (e), get_id, /*type*/false, /*complain*/false); - if (fns != error_mark_node) + bool use_member_get = false; + + /* To use a member get, member lookup must find at least one + declaration that is a function template + whose first template parameter is a non-type parameter. */ + for (tree iter = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns; + iter; + iter = OVL_NEXT (iter)) + { + tree fn = OVL_CURRENT (iter); + if (TREE_CODE (fn) == TEMPLATE_DECL) + { + tree tparms = DECL_TEMPLATE_PARMS (fn); + tree parm = TREE_VEC_ELT (INNERMOST_TEMPLATE_PARMS (tparms), 0); + if (TREE_CODE (TREE_VALUE (parm)) == PARM_DECL) + { + use_member_get = true; + break; + } + } + } + + if (use_member_get) { fns = lookup_template_function (fns, targs); return build_new_method_call (e, fns, /*args*/NULL, @@ -9524,7 +9548,8 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) constant_expression_error (size); /* An array must have a positive number of elements. */ - if (tree_int_cst_lt (size, integer_zero_node)) + tree signed_size = fold_convert (ssizetype, size); + if (tree_int_cst_lt (signed_size, integer_zero_node)) { if (!(complain & tf_error)) return error_mark_node; @@ -10104,6 +10129,8 @@ grokdeclarator (const cp_declarator *declarator, declspecs->locations); if (typespec_loc == UNKNOWN_LOCATION) typespec_loc = declspecs->locations[ds_type_spec]; + if (typespec_loc == UNKNOWN_LOCATION) + typespec_loc = input_location; /* Look inside a declarator for the name being declared and get it as a string, for an error message. */ @@ -12563,7 +12590,9 @@ check_default_argument (tree decl, tree arg, tsubst_flags_t complain) A default argument expression is implicitly converted to the parameter type. */ ++cp_unevaluated_operand; - perform_implicit_conversion_flags (decl_type, arg, complain, + /* Avoid digest_init clobbering the initializer. */ + tree carg = BRACE_ENCLOSED_INITIALIZER_P (arg) ? unshare_expr (arg): arg; + perform_implicit_conversion_flags (decl_type, carg, complain, LOOKUP_IMPLICIT); --cp_unevaluated_operand; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index b1c3c30521f..982f35f558f 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1360,7 +1360,7 @@ cp_check_const_attributes (tree attributes) { tree expr = TREE_VALUE (arg); if (EXPR_P (expr)) - TREE_VALUE (arg) = maybe_constant_value (expr); + TREE_VALUE (arg) = fold_non_dependent_expr (expr); } } } diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 38bc0b2474a..989a5e8eda1 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2695,6 +2695,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) case INTEGER_TYPE: case COMPLEX_TYPE: case VECTOR_TYPE: + case DECLTYPE_TYPE: pp_type_specifier_seq (pp, t); break; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ede8ca8097c..9a65d945232 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -11858,7 +11858,7 @@ cp_parser_perform_range_for_lookup (tree range, tree *begin, tree *end) /*protect=*/2, /*want_type=*/false, tf_warning_or_error); - if (member_begin != NULL_TREE || member_end != NULL_TREE) + if (member_begin != NULL_TREE && member_end != NULL_TREE) { /* Use the member functions. */ if (member_begin != NULL_TREE) @@ -20969,7 +20969,10 @@ cp_parser_parameter_declaration_clause (cp_parser* parser) if (!processing_specialization && !processing_template_parmlist - && !processing_explicit_instantiation) + && !processing_explicit_instantiation + /* default_arg_ok_p tracks whether this is a parameter-clause for an + actual function or a random abstract declarator. */ + && parser->default_arg_ok_p) if (!current_function_decl || (current_class_type && LAMBDA_TYPE_P (current_class_type))) parser->auto_is_implicit_function_template_parm_p = true; @@ -21078,9 +21081,6 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error) cp_parameter_declarator *parameter; tree decl = error_mark_node; bool parenthesized_p = false; - int template_parm_idx = (function_being_declared_is_template_p (parser)? - TREE_VEC_LENGTH (INNERMOST_TEMPLATE_PARMS - (current_template_parms)) : 0); /* Parse the parameter. */ parameter @@ -21094,22 +21094,6 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error) if (parameter) { - /* If a function parameter pack was specified and an implicit template - parameter was introduced during cp_parser_parameter_declaration, - change any implicit parameters introduced into packs. */ - if (parser->implicit_template_parms - && parameter->declarator - && parameter->declarator->parameter_pack_p) - { - int latest_template_parm_idx = TREE_VEC_LENGTH - (INNERMOST_TEMPLATE_PARMS (current_template_parms)); - - if (latest_template_parm_idx != template_parm_idx) - parameter->decl_specifiers.type = convert_generic_types_to_packs - (parameter->decl_specifiers.type, - template_parm_idx, latest_template_parm_idx); - } - decl = grokdeclarator (parameter->declarator, ¶meter->decl_specifiers, PARM, @@ -21267,6 +21251,10 @@ cp_parser_parameter_declaration (cp_parser *parser, parser->type_definition_forbidden_message = G_("types may not be defined in parameter types"); + int template_parm_idx = (function_being_declared_is_template_p (parser) ? + TREE_VEC_LENGTH (INNERMOST_TEMPLATE_PARMS + (current_template_parms)) : 0); + /* Parse the declaration-specifiers. */ cp_parser_decl_specifier_seq (parser, CP_PARSER_FLAGS_NONE, @@ -21355,6 +21343,23 @@ cp_parser_parameter_declaration (cp_parser *parser, parameter pack expansion expression. Otherwise, leave the ellipsis for a C-style variadic function. */ token = cp_lexer_peek_token (parser->lexer); + + /* If a function parameter pack was specified and an implicit template + parameter was introduced during cp_parser_parameter_declaration, + change any implicit parameters introduced into packs. */ + if (parser->implicit_template_parms + && (token->type == CPP_ELLIPSIS + || (declarator && declarator->parameter_pack_p))) + { + int latest_template_parm_idx = TREE_VEC_LENGTH + (INNERMOST_TEMPLATE_PARMS (current_template_parms)); + + if (latest_template_parm_idx != template_parm_idx) + decl_specifiers.type = convert_generic_types_to_packs + (decl_specifiers.type, + template_parm_idx, latest_template_parm_idx); + } + if (cp_lexer_next_token_is (parser->lexer, CPP_ELLIPSIS)) { tree type = decl_specifiers.type; diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b4032550849..9a1e632fb22 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8265,7 +8265,11 @@ coerce_template_parms (tree parms, } if (lost) - return error_mark_node; + { + if ((complain & tf_error) && !seen_error()) + error ("wrong number of template arguments"); + return error_mark_node; + } if (CHECKING_P && !NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args)) SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args, @@ -11475,7 +11479,9 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, { /* This parameter pack was used in an unevaluated context. Just make a dummy decl, since it's only used for its type. */ + ++cp_unevaluated_operand; arg_pack = tsubst_decl (parm_pack, args, complain); + --cp_unevaluated_operand; if (arg_pack && DECL_PACK_P (arg_pack)) /* Partial instantiation of the parm_pack, we can't build up an argument pack yet. */ @@ -11545,7 +11551,7 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, /* We can't substitute for this parameter pack. We use a flag as well as the missing_level counter because function parameter packs don't have a level. */ - gcc_assert (processing_template_decl); + gcc_assert (processing_template_decl || is_auto (parm_pack)); unsubstituted_packs = true; } } @@ -13776,8 +13782,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) = tsubst_constraint (constr, args, complain, in_decl); else if (tree pl = CLASS_PLACEHOLDER_TEMPLATE (t)) { - if (DECL_TEMPLATE_TEMPLATE_PARM_P (pl)) - pl = tsubst (pl, args, complain, in_decl); + pl = tsubst_copy (pl, args, complain, in_decl); CLASS_PLACEHOLDER_TEMPLATE (r) = pl; } } @@ -19490,17 +19495,11 @@ type_unification_real (tree tparms, location_t save_loc = input_location; if (DECL_P (parm)) input_location = DECL_SOURCE_LOCATION (parm); - - if (saw_undeduced == 1) - ++processing_template_decl; arg = tsubst_template_arg (arg, full_targs, complain, NULL_TREE); - if (saw_undeduced == 1) - --processing_template_decl; - - if (arg != error_mark_node && !uses_template_parms (arg)) + if (!uses_template_parms (arg)) arg = convert_template_argument (parm, arg, full_targs, complain, i, NULL_TREE); - else if (saw_undeduced == 1) + else if (saw_undeduced < 2) arg = NULL_TREE; else arg = error_mark_node; @@ -25136,8 +25135,21 @@ rewrite_template_parm (tree olddecl, unsigned index, unsigned level, = TEMPLATE_TYPE_PARM_FOR_CLASS (oldtype); } else - newtype = tsubst (TREE_TYPE (olddecl), tsubst_args, - complain, NULL_TREE); + { + newtype = TREE_TYPE (olddecl); + if (type_uses_auto (newtype)) + { + // Substitute once to fix references to other template parameters. + newtype = tsubst (newtype, tsubst_args, + complain|tf_partial, NULL_TREE); + // Now substitute again to reduce the level of the auto. + newtype = tsubst (newtype, current_template_args (), + complain, NULL_TREE); + } + else + newtype = tsubst (newtype, tsubst_args, + complain, NULL_TREE); + } tree newdecl = build_decl (DECL_SOURCE_LOCATION (olddecl), TREE_CODE (olddecl), @@ -25417,6 +25429,9 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags, // FIXME cache artificial deduction guides for (tree fns = CLASSTYPE_CONSTRUCTORS (type); fns; fns = OVL_NEXT (fns)) { + if (TREE_CODE (fns) == OVERLOAD && OVL_USED (fns)) + continue; + tree fn = OVL_CURRENT (fns); tree guide = build_deduction_guide (fn, outer_args, complain); cands = ovl_cons (guide, cands); diff --git a/gcc/cp/search.c b/gcc/cp/search.c index f9d770ad8ee..e72ce5a427c 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -2879,7 +2879,7 @@ original_binfo (tree binfo, tree here) bool any_dependent_bases_p (tree type) { - if (!type || !CLASS_TYPE_P (type) || !processing_template_decl) + if (!type || !CLASS_TYPE_P (type) || !uses_template_parms (type)) return false; unsigned i; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index e0663764638..481c88b0728 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -730,7 +730,10 @@ finish_if_stmt_cond (tree cond, tree if_stmt) cond = maybe_convert_cond (cond); if (IF_STMT_CONSTEXPR_P (if_stmt) && require_potential_rvalue_constant_expression (cond) - && !value_dependent_expression_p (cond)) + && !value_dependent_expression_p (cond) + /* Wait until instantiation time, since only then COND has been + converted to bool. */ + && TREE_TYPE (cond) == boolean_type_node) { cond = instantiate_non_dependent_expr (cond); cond = cxx_constant_value (cond, NULL_TREE); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 65277584aa2..5fef52674f6 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2798,7 +2798,7 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_) for (; !same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (*t), TREE_TYPE (x)); x = TREE_OPERAND (x, 0)) - gcc_assert (TREE_CODE (x) == COMPONENT_REF); + gcc_assert (handled_component_p (x)); *t = x; *walk_subtrees = false; d->seen = true; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index d79b724ecca..9d7c9aa27d0 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -905,14 +905,14 @@ merge_types (tree t1, tree t2) return t1; default:; + if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes)) + return t1; + else if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes)) + return t2; + break; } - if (attribute_list_equal (TYPE_ATTRIBUTES (t1), attributes)) - return t1; - else if (attribute_list_equal (TYPE_ATTRIBUTES (t2), attributes)) - return t2; - else - return cp_build_type_attribute_variant (t1, attributes); + return cp_build_type_attribute_variant (t1, attributes); } /* Return the ARRAY_TYPE type without its domain. */ diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 1f0eb454754..764fbca832d 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -817,9 +817,12 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags) bool const_init; value = instantiate_non_dependent_expr (value); if (DECL_DECLARED_CONSTEXPR_P (decl) - || (DECL_IN_AGGR_P (decl) && !DECL_VAR_DECLARED_INLINE_P (decl))) + || (DECL_IN_AGGR_P (decl) + && DECL_INITIALIZED_IN_CLASS_P (decl) + && !DECL_VAR_DECLARED_INLINE_P (decl))) { - /* Diagnose a non-constant initializer for constexpr. */ + /* Diagnose a non-constant initializer for constexpr variable or + non-inline in-class-initialized static data member. */ if (processing_template_decl && !require_potential_constant_expression (value)) value = error_mark_node; diff --git a/gcc/ddg.c b/gcc/ddg.c index 9ea98d6f40f..68a77f8043e 100644 --- a/gcc/ddg.c +++ b/gcc/ddg.c @@ -295,11 +295,14 @@ add_cross_iteration_register_deps (ddg_ptr g, df_ref last_def) /* Create inter-loop true dependences and anti dependences. */ for (r_use = DF_REF_CHAIN (last_def); r_use != NULL; r_use = r_use->next) { - rtx_insn *use_insn = DF_REF_INSN (r_use->ref); - - if (BLOCK_FOR_INSN (use_insn) != g->bb) + if (DF_REF_BB (r_use->ref) != g->bb) continue; + gcc_assert (!DF_REF_IS_ARTIFICIAL (r_use->ref) + && DF_REF_INSN_INFO (r_use->ref) != NULL); + + rtx_insn *use_insn = DF_REF_INSN (r_use->ref); + /* ??? Do not handle uses with DF_REF_IN_NOTE notes. */ use_node = get_node_of_insn (g, use_insn); gcc_assert (use_node); diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 977664ffd11..b0a1b7ffac6 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -1,4 +1,4 @@ -@c Copyright (C) 1988-2017 Free Software Foundation, Inc. +@c Copyright (C) 1988-2018 Free Software Foundation, Inc. @c This is part of the GCC manual. @c For copying conditions, see the file gcc.texi. @@ -15165,21 +15165,16 @@ or @option{-mpopcntd}): @smallexample long __builtin_bpermd (long, long); int __builtin_divwe (int, int); -int __builtin_divweo (int, int); unsigned int __builtin_divweu (unsigned int, unsigned int); -unsigned int __builtin_divweuo (unsigned int, unsigned int); long __builtin_divde (long, long); -long __builtin_divdeo (long, long); unsigned long __builtin_divdeu (unsigned long, unsigned long); -unsigned long __builtin_divdeuo (unsigned long, unsigned long); unsigned int cdtbcd (unsigned int); unsigned int cbcdtd (unsigned int); unsigned int addg6s (unsigned int, unsigned int); @end smallexample -The @code{__builtin_divde}, @code{__builtin_divdeo}, -@code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a -64-bit environment support ISA 2.06 or later. +The @code{__builtin_divde} and @code{__builtin_divdeu} functions +require a 64-bit environment supporting ISA 2.06 or later. The following built-in functions are available for the PowerPC family of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}): diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index fbb99aa8936..4822ec3f96f 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1024,7 +1024,7 @@ See RS/6000 and PowerPC Options. -mfloat-gprs=yes -mfloat-gprs=no -mfloat-gprs=single -mfloat-gprs=double @gol -mprototype -mno-prototype @gol -msim -mmvme -mads -myellowknife -memb -msdata @gol --msdata=@var{opt} -mvxworks -G @var{num} @gol +-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} @gol -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision @gol -mno-recip-precision @gol -mveclibabi=@var{type} -mfriz -mno-friz @gol @@ -22093,6 +22093,13 @@ On embedded PowerPC systems, put all initialized global and static data in the @code{.data} section, and all uninitialized data in the @code{.bss} section. +@item -mreadonly-in-sdata +@itemx -mreadonly-in-sdata +@opindex mreadonly-in-sdata +@opindex mno-readonly-in-sdata +Put read-only objects in the @code{.sdata} section as well. This is the +default. + @item -mblock-move-inline-limit=@var{num} @opindex mblock-move-inline-limit Inline all block moves (such as calls to @code{memcpy} or structure diff --git a/gcc/expr.c b/gcc/expr.c index c0dbd643831..0d287ecbe68 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -6893,8 +6893,9 @@ store_field (rtx target, HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos, if (GET_CODE (temp) == PARALLEL) { HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (exp)); - machine_mode temp_mode - = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT); + machine_mode temp_mode = GET_MODE (temp); + if (temp_mode == BLKmode || temp_mode == VOIDmode) + temp_mode = smallest_mode_for_size (size * BITS_PER_UNIT, MODE_INT); rtx temp_target = gen_reg_rtx (temp_mode); emit_group_store (temp_target, temp, TREE_TYPE (exp), size); temp = temp_target; diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6156644ad48..55ee7920b6b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,49 @@ +2018-04-24 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/85520 + * decl.c (gfc_match_char_spec): Check for negative length and set to 0. + +2018-03-28 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/85084 + Backport from trunk. + * frontend-passes.c (gfc_run_passes): Do not run front-end + optimizations if a previous error occurred. + +2018-03-20 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/85001 + * interface.c (symbol_rank): Remove bogus null pointer check that + crept in when translating a ternary operator into an if-else + constructor. + +2018-03-19 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/84931 + Backport from trunk + * simplify.c (gfc_convert_constant): Correctly handle iterators + for type conversion. + +2018-03-19 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77414 + * decl.c (get_proc_name): Check for a subroutine re-defined in + the contain portion of a subroutine. Change language of existing + error message to better describe the issue. While here fix whitespace + issues. + +2018-03-19 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/65453 + * decl.c (get_proc_name): Catch clash between a procedure statement + and a contained subprogram + +2018-03-15 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/78741 + * decl.c (get_proc_name): Check for clash of entry name with + subroutine name. + 2018-03-12 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/83939 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index e46b8394853..69d21633f78 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1129,14 +1129,12 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry) if (sym->attr.proc == PROC_ST_FUNCTION) return rc; - if (sym->attr.module_procedure - && sym->attr.if_source == IFSRC_IFBODY) + if (sym->attr.module_procedure && sym->attr.if_source == IFSRC_IFBODY) { /* Create a partially populated interface symbol to carry the characteristics of the procedure and the result. */ sym->tlink = gfc_new_symbol (name, sym->ns); - gfc_add_type (sym->tlink, &(sym->ts), - &gfc_current_locus); + gfc_add_type (sym->tlink, &(sym->ts), &gfc_current_locus); gfc_copy_attr (&sym->tlink->attr, &sym->attr, NULL); if (sym->attr.dimension) sym->tlink->as = gfc_copy_array_spec (sym->as); @@ -1166,11 +1164,22 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry) accessible names. */ if (sym->attr.flavor != 0 && sym->attr.proc != 0 - && (sym->attr.subroutine || sym->attr.function) + && (sym->attr.subroutine || sym->attr.function || sym->attr.entry) && sym->attr.if_source != IFSRC_UNKNOWN) gfc_error_now ("Procedure %qs at %C is already defined at %L", name, &sym->declared_at); + if (sym->attr.flavor != 0 + && sym->attr.entry && sym->attr.if_source != IFSRC_UNKNOWN) + gfc_error_now ("Procedure %qs at %C is already defined at %L", + name, &sym->declared_at); + + if (sym->attr.external && sym->attr.procedure + && gfc_current_state () == COMP_CONTAINS) + gfc_error_now ("Contained procedure %qs at %C clashes with " + "procedure defined at %L", + name, &sym->declared_at); + /* Trap a procedure with a name the same as interface in the encompassing scope. */ if (sym->attr.generic != 0 @@ -1190,7 +1199,16 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry) && sym->attr.access == 0 && !module_fcn_entry) gfc_error_now ("Procedure %qs at %C has an explicit interface " - "and must not have attributes declared at %L", + "from a previous declaration", name); + } + + if (sym && !sym->gfc_new + && sym->attr.flavor != FL_UNKNOWN + && sym->attr.referenced == 0 && sym->attr.subroutine == 1 + && gfc_state_stack->state == COMP_CONTAINS + && gfc_state_stack->previous->state == COMP_SUBROUTINE) + { + gfc_error_now ("Procedure %qs at %C is already defined at %L", name, &sym->declared_at); } @@ -1215,10 +1233,10 @@ get_proc_name (const char *name, gfc_symbol **result, bool module_fcn_entry) /* See if the procedure should be a module procedure. */ if (((sym->ns->proc_name != NULL - && sym->ns->proc_name->attr.flavor == FL_MODULE - && sym->attr.proc != PROC_MODULE) - || (module_fcn_entry && sym->attr.proc != PROC_MODULE)) - && !gfc_add_procedure (&sym->attr, PROC_MODULE, sym->name, NULL)) + && sym->ns->proc_name->attr.flavor == FL_MODULE + && sym->attr.proc != PROC_MODULE) + || (module_fcn_entry && sym->attr.proc != PROC_MODULE)) + && !gfc_add_procedure (&sym->attr, PROC_MODULE, sym->name, NULL)) rc = 2; return rc; @@ -2989,7 +3007,11 @@ done: e = gfc_copy_expr (len); gfc_reduce_init_expr (e); if (e->expr_type == EXPR_CONSTANT) - gfc_replace_expr (len, e); + { + gfc_replace_expr (len, e); + if (mpz_cmp_si (len->value.integer, 0) < 0) + mpz_set_ui (len->value.integer, 0); + } else gfc_free_expr (e); cl->length = len; diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 8a5829a3358..d7b4f23fe89 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -135,6 +135,10 @@ gfc_run_passes (gfc_namespace *ns) check_locus (ns); #endif + gfc_get_errors (&w, &e); + if (e > 0) + return; + if (flag_frontend_optimize) { optimize_namespace (ns); @@ -145,10 +149,6 @@ gfc_run_passes (gfc_namespace *ns) expr_array.release (); } - gfc_get_errors (&w, &e); - if (e > 0) - return; - if (flag_realloc_lhs) realloc_strings (ns); } diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 162f7772970..bd7707efc88 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1263,7 +1263,7 @@ symbol_rank (gfc_symbol *sym) { gfc_array_spec *as = NULL; - if (sym->ts.type == BT_CLASS && CLASS_DATA (sym) && CLASS_DATA (sym)->as) + if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)) as = CLASS_DATA (sym)->as; else as = sym->as; diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index c537e645060..e34deada3fc 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -7175,26 +7175,32 @@ gfc_convert_constant (gfc_expr *e, bt type, int kind) { gfc_expr *tmp; if (c->iterator == NULL) - tmp = f (c->expr, kind); + { + tmp = f (c->expr, kind); + if (tmp == NULL) + { + gfc_free_expr (result); + return NULL; + } + + gfc_constructor_append_expr (&result->value.constructor, + tmp, &c->where); + } else { + gfc_constructor *n; g = gfc_convert_constant (c->expr, type, kind); - if (g == &gfc_bad_expr) + if (g == NULL || g == &gfc_bad_expr) { gfc_free_expr (result); return g; } - tmp = g; - } - - if (tmp == NULL) - { - gfc_free_expr (result); - return NULL; + n = gfc_constructor_get (); + n->expr = g; + n->iterator = gfc_copy_iterator (c->iterator); + n->where = c->where; + gfc_constructor_append (&result->value.constructor, n); } - - gfc_constructor_append_expr (&result->value.constructor, - tmp, &c->where); } break; diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 5264a4f3d40..15fc7c9ae8f 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1125,10 +1125,6 @@ static void asan_poison_variable (tree decl, bool poison, gimple_stmt_iterator *it, bool before) { - /* When within an OMP context, do not emit ASAN_MARK internal fns. */ - if (gimplify_omp_ctxp) - return; - tree unit_size = DECL_SIZE_UNIT (decl); tree base = build_fold_addr_expr (decl); @@ -1640,7 +1636,8 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p) && TREE_ADDRESSABLE (decl) && !TREE_STATIC (decl) && !DECL_HAS_VALUE_EXPR_P (decl) - && dbg_cnt (asan_use_after_scope)) + && dbg_cnt (asan_use_after_scope) + && !gimplify_omp_ctxp) { asan_poisoned_variables->add (decl); asan_poison_variable (decl, false, seq_p); @@ -6458,7 +6455,8 @@ gimplify_target_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) clobber = build2 (MODIFY_EXPR, TREE_TYPE (temp), temp, clobber); gimple_push_cleanup (temp, clobber, false, pre_p, true); } - if (asan_poisoned_variables && dbg_cnt (asan_use_after_scope)) + if (asan_poisoned_variables && dbg_cnt (asan_use_after_scope) + && !gimplify_omp_ctxp) { tree asan_cleanup = build_asan_poison_call_expr (temp); if (asan_cleanup) diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 0d214170c24..c1b7aa3bea6 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -1577,8 +1577,15 @@ odr_types_equivalent_p (tree t1, tree t2, bool warn, bool *warned, "in another translation unit")); return false; } - gcc_assert (DECL_NONADDRESSABLE_P (f1) - == DECL_NONADDRESSABLE_P (f2)); + if (DECL_BIT_FIELD (f1) != DECL_BIT_FIELD (f2)) + { + warn_odr (t1, t2, f1, f2, warn, warned, + G_("one field is bitfield while other is not")); + return false; + } + else + gcc_assert (DECL_NONADDRESSABLE_P (f1) + == DECL_NONADDRESSABLE_P (f2)); } /* If one aggregate has more fields than the other, they diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 95fad30e83a..c8ca9566cb7 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -2132,23 +2132,6 @@ sem_variable::get_hash (void) return m_hash; } -/* Set all points-to UIDs of aliases pointing to node N as UID. */ - -static void -set_alias_uids (symtab_node *n, int uid) -{ - ipa_ref *ref; - FOR_EACH_ALIAS (n, ref) - { - if (dump_file) - fprintf (dump_file, " Setting points-to UID of [%s] as %d\n", - xstrdup_for_dump (ref->referring->asm_name ()), uid); - - SET_DECL_PT_UID (ref->referring->decl, uid); - set_alias_uids (ref->referring, uid); - } -} - /* Merges instance with an ALIAS_ITEM, where alias, thunk or redirection can be applied. */ @@ -2275,7 +2258,6 @@ sem_variable::merge (sem_item *alias_item) if (dump_file) fprintf (dump_file, "Unified; Variable alias has been created.\n"); - set_alias_uids (original, DECL_UID (original->decl)); return true; } } @@ -2295,7 +2277,7 @@ unsigned int sem_item_optimizer::class_id = 0; sem_item_optimizer::sem_item_optimizer () : worklist (0), m_classes (0), m_classes_count (0), m_cgraph_node_hooks (NULL), - m_varpool_node_hooks (NULL) + m_varpool_node_hooks (NULL), m_merged_variables () { m_items.create (0); bitmap_obstack_initialize (&m_bmstack); @@ -2320,6 +2302,7 @@ sem_item_optimizer::~sem_item_optimizer () m_items.release (); bitmap_obstack_release (&m_bmstack); + m_merged_variables.release (); } /* Write IPA ICF summary for symbols. */ @@ -3571,13 +3554,103 @@ sem_item_optimizer::merge_classes (unsigned int prev_class_count) } if (dbg_cnt (merged_ipa_icf)) - merged_p |= source->merge (alias); + { + bool merged = source->merge (alias); + merged_p |= merged; + + if (merged && alias->type == VAR) + { + symtab_pair p = symtab_pair (source->node, alias->node); + m_merged_variables.safe_push (p); + } + } } } + if (!m_merged_variables.is_empty ()) + fixup_points_to_sets (); + return merged_p; } +/* Fixup points to set PT. */ + +void +sem_item_optimizer::fixup_pt_set (struct pt_solution *pt) +{ + if (pt->vars == NULL) + return; + + unsigned i; + symtab_pair *item; + FOR_EACH_VEC_ELT (m_merged_variables, i, item) + if (bitmap_bit_p (pt->vars, DECL_UID (item->second->decl))) + bitmap_set_bit (pt->vars, DECL_UID (item->first->decl)); +} + +/* Set all points-to UIDs of aliases pointing to node N as UID. */ + +static void +set_alias_uids (symtab_node *n, int uid) +{ + ipa_ref *ref; + FOR_EACH_ALIAS (n, ref) + { + if (dump_file) + fprintf (dump_file, " Setting points-to UID of [%s] as %d\n", + xstrdup_for_dump (ref->referring->asm_name ()), uid); + + SET_DECL_PT_UID (ref->referring->decl, uid); + set_alias_uids (ref->referring, uid); + } +} + +/* Fixup points to analysis info. */ + +void +sem_item_optimizer::fixup_points_to_sets (void) +{ + /* TODO: remove in GCC 9 and trigger PTA re-creation after IPA passes. */ + cgraph_node *cnode; + + FOR_EACH_DEFINED_FUNCTION (cnode) + { + tree name; + unsigned i; + function *fn = DECL_STRUCT_FUNCTION (cnode->decl); + if (!gimple_in_ssa_p (fn)) + continue; + + FOR_EACH_SSA_NAME (i, name, fn) + if (POINTER_TYPE_P (TREE_TYPE (name)) + && SSA_NAME_PTR_INFO (name)) + fixup_pt_set (&SSA_NAME_PTR_INFO (name)->pt); + fixup_pt_set (&fn->gimple_df->escaped); + + /* The above get's us to 99% I guess, at least catching the + address compares. Below also gets us aliasing correct + but as said we're giving leeway to the situation with + readonly vars anyway, so ... */ + basic_block bb; + FOR_EACH_BB_FN (bb, fn) + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) + { + gcall *call = dyn_cast<gcall *> (gsi_stmt (gsi)); + if (call) + { + fixup_pt_set (gimple_call_use_set (call)); + fixup_pt_set (gimple_call_clobber_set (call)); + } + } + } + + unsigned i; + symtab_pair *item; + FOR_EACH_VEC_ELT (m_merged_variables, i, item) + set_alias_uids (item->first, DECL_UID (item->first->decl)); +} + /* Dump function prints all class members to a FILE with an INDENT. */ void diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h index c57224c1517..2101747bfd6 100644 --- a/gcc/ipa-icf.h +++ b/gcc/ipa-icf.h @@ -141,6 +141,8 @@ public: unsigned int index; }; +typedef std::pair<symtab_node *, symtab_node *> symtab_pair; + /* Semantic item is a base class that encapsulates all shared functionality for both semantic function and variable items. */ class sem_item @@ -563,6 +565,12 @@ private: processed. */ bool merge_classes (unsigned int prev_class_count); + /* Fixup points to analysis info. */ + void fixup_points_to_sets (void); + + /* Fixup points to set PT. */ + void fixup_pt_set (struct pt_solution *pt); + /* Adds a newly created congruence class CLS to worklist. */ void worklist_push (congruence_class *cls); @@ -632,6 +640,10 @@ private: /* Bitmap stack. */ bitmap_obstack m_bmstack; + + /* Vector of merged variables. Needed for fixup of points-to-analysis + info. */ + vec <symtab_pair> m_merged_variables; }; // class sem_item_optimizer } // ipa_icf namespace diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 1ebbb907ec1..17431acfe90 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,29 @@ +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-04-19 Martin Liska <mliska@suse.cz> + + * lto-symtab.c (lto_symtab_resolve_symbols): Do not bail out + for multiple PREVAILING_DEF_IRONLY for common symbols. + +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-04-10 Martin Liska <mliska@suse.cz> + + PR lto/85248 + * lto-symtab.c (lto_symtab_merge_p): Do not check for + TREE_VALUES of error attributes. + +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-04-10 Richard Biener <rguenther@suse.de> + Martin Liska <mliska@suse.cz> + + PR lto/85248 + * lto-symtab.c (lto_symtab_merge_p): Handle noreturn attribute. + 2018-03-06 Martin Liska <mliska@suse.cz> Backport from mainline diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c index 10c3fbe49f3..01cc0b7602e 100644 --- a/gcc/lto/lto-symtab.c +++ b/gcc/lto/lto-symtab.c @@ -465,9 +465,14 @@ lto_symtab_resolve_symbols (symtab_node *first) /* If the chain is already resolved there is nothing else to do. */ if (prevailing) { - /* Assert it's the only one. */ + /* Assert it's the only one. + GCC should silence multiple PREVAILING_DEF_IRONLY defs error + on COMMON symbols since it isn't error. + See: https://sourceware.org/bugzilla/show_bug.cgi?id=23079. */ for (e = prevailing->next_sharing_asm_name; e; e = e->next_sharing_asm_name) if (lto_symtab_symbol_p (e) + && !DECL_COMMON (prevailing->decl) + && !DECL_COMMON (e->decl) && (e->resolution == LDPR_PREVAILING_DEF_IRONLY || e->resolution == LDPR_PREVAILING_DEF_IRONLY_EXP || e->resolution == LDPR_PREVAILING_DEF)) @@ -571,6 +576,9 @@ lto_symtab_merge_p (tree prevailing, tree decl) return false; } } + + /* FIXME: after MPX is removed, use flags_from_decl_or_type + function instead. PR lto/85248. */ if (DECL_ATTRIBUTES (prevailing) != DECL_ATTRIBUTES (decl)) { tree prev_attr = lookup_attribute ("error", DECL_ATTRIBUTES (prevailing)); @@ -598,6 +606,16 @@ lto_symtab_merge_p (tree prevailing, tree decl) "warning attribute mismatch\n"); return false; } + + prev_attr = lookup_attribute ("noreturn", DECL_ATTRIBUTES (prevailing)); + attr = lookup_attribute ("noreturn", DECL_ATTRIBUTES (decl)); + if ((prev_attr == NULL) != (attr == NULL)) + { + if (symtab->dump_file) + fprintf (symtab->dump_file, "Not merging decls; " + "noreturn attribute mismatch\n"); + return false; + } } return true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 68e6b47d96f..f655439d65b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,299 @@ +2018-04-24 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/85520 + * gfortran.dg/pr85520.f90: New test. + +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-04-10 Jakub Jelinek <jakub@redhat.com> + + PR lto/85248 + * gcc.dg/lto/pr85248_0.c: New test. + * gcc.dg/lto/pr85248_1.c: New test. + +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-03-28 Jakub Jelinek <jakub@redhat.com> + Martin Liska <mliska@suse.cz> + + PR sanitizer/85081 + * g++.dg/asan/pr85081.C: New test. + +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-03-21 Martin Liska <mliska@suse.cz> + + PR ipa/84963 + * gfortran.dg/goacc/pr84963.f90: New test. + +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-03-13 Martin Liska <mliska@suse.cz> + + PR ipa/84658. + * g++.dg/ipa/pr84658.C: New test. + +2018-04-23 Aaron Sawdey <acsawdey@linux.ibm.com> + + Backport from mainline + 2018-04-16 Aaron Sawdey <acsawdey@linux.ibm.com> + + PR target/83660 + * gcc.target/powerpc/pr83660.C: New test. + +2018-04-23 Eric Botcazou <ebotcazou@adacore.com> + + * g++.dg/torture/pr85496.C: New test. + +2018-04-20 Peter Bergner <bergner@vnet.ibm.com> + + PR target/85436 + * go.dg/pr85436.go: New test. + + Backport from mainline + 2018-03-09 Peter Bergner <bergner@vnet.ibm.com> + + PR target/83969 + * gcc.target/powerpc/pr83969.c: New test. + +2018-04-19 Jonathan Wakely <jwakely@redhat.com> + + PR c++/85464 - missing location for -Wignored-qualifiers diagnostic + * g++.dg/diagnostic/pr85464.C: New. + +2018-04-18 Thomas Preud'homme <thomas.preudhomme@arm.com> + + Backport from mainline + 2018-04-11 Thomas Preud'homme <thomas.preudhomme@arm.com> + + PR target/85261 + * gcc.target/arm/fpscr.c: Add call to __builtin_arm_set_fpscr with + literal value. Expect 2 MCR instruction. Fix function prototype. + Remove volatile keyword. + +2018-04-12 Andreas Krebbel <krebbel@linux.vnet.ibm.com> + + Backport from mainline + 2018-04-12 Andreas Krebbel <krebbel@linux.vnet.ibm.com> + + * gcc.target/s390/nobp-no-dwarf2-cfi.c: New test. + +2018-04-11 Thomas Preud'homme <thomas.preudhomme@arm.com> + + Backport from mainline + 2018-04-04 Thomas Preud'homme <thomas.preudhomme@arm.com> + + PR target/85203 + * gcc.target/arm/cmse/cmse-1.c: Tighten cmse_nonsecure_caller RTL scan + to match a single insn of the baz function. Move scan directives at + the end of the file below the functions they are trying to test for + better readability. + * gcc.target/arm/cmse/cmse-16.c: New testcase. + +2018-04-10 Thomas Schwinge <thomas@codesourcery.com> + + PR target/85056 + * gcc.target/nvptx/pr85056.c (main): Initialize "sum". + +2018-04-10 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + Backport from mainline + 2018-03-08 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + PR target/84748 + * gcc.c-torture/execute/pr84748.c: New test. + +2018-04-06 Eric Botcazou <ebotcazou@adacore.com> + + * g++.dg/opt/pr85196.C: New test. + +2018-04-05 Uros Bizjak <ubizjak@gmail.com> + + PR target/85193 + * gcc.target/i386/pr85193.c: New test. + +2018-04-04 Peter Bergner <bergner@vnet.ibm.com> + + Backport from mainline + 2018-04-04 Peter Bergner <bergner@vnet.ibm.com> + + PR rtl-optimization/84878 + * gcc.target/powerpc/pr84878.c: New test. + +2018-04-03 Cesar Philippidis <cesar@codesourcery.com> + + Backport from mainline + 2018-03-27 Cesar Philippidis <cesar@codesourcery.com> + + PR target/85056 + * testsuite/gcc.target/nvptx/pr85056.c: New test. + * testsuite/gcc.target/nvptx/pr85056a.c: New test. + +2018-04-02 Peter Bergner <bergner@vnet.ibm.com> + + Backport from mainline + 2018-03-28 Peter Bergner <bergner@vnet.ibm.com> + + PR target/84912 + * gcc.target/powerpc/extend-divide-1.c (div_weo): Remove test for + deleted builtin function. + (div_weuo): Likewise. + * gcc.target/powerpc/extend-divide-2.c (div_deo): Likewise. + (div_deuo): Likewise. + +2018-04-02 Peter Bergner <bergner@vnet.ibm.com> + + Backport from mainline + 2018-02-08 Peter Bergner <bergner@vnet.ibm.com> + + PR target/81143 + * gcc.target/powerpc/pr79799-2.c: Use __LITTLE_ENDIAN__. + +2018-03-29 Sebastian Peryt <sebastian.peryt@intel.com> + + PR c++/84783 + * gcc.target/i386/avx512vl-vpermd-1.c (_mm256_permutexvar_epi32): + Test new intrinsic. + * gcc.target/i386/avx512vl-vpermq-imm-1.c (_mm256_permutex_epi64): + Ditto. + * gcc.target/i386/avx512vl-vpermq-var-1.c (_mm256_permutexvar_epi64): + Ditto. + * gcc.target/i386/avx512f-vpermd-2.c: Do not check for AVX512F_LEN. + * gcc.target/i386/avx512f-vpermq-imm-2.c: Ditto. + * gcc.target/i386/avx512f-vpermq-var-2.c: Ditto. + +2018-03-29 Sudakshina Das <sudi.das@arm.com> + + * gcc.target/arm/pr84826.c: Change dg-option to -fstack-check. + + Backport from mainline + 2018-03-23 Sudakshina Das <sudi.das@arm.com> + + PR target/84826 + * gcc.target/arm/pr84826.c: Add dg directive. + + Backport from mainline + 2018-03-22 Sudakshina Das <sudi.das@arm.com> + + PR target/84826 + * gcc.target/arm/pr84826.c: New test. + +2018-03-28 Carl Love <cel@us.ibm.com> + + * gcc.target/powerpc/crypto-builtin-1-runnable: Add + p8vector_hw to dg-do run. + +2018-03-28 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/85084 + Backport from trunk. + * gfortran.dg/matmul_rank_1.f90: New test. + +2018-03-28 Sudakshina Das <sudi.das@arm.com> + Christophe Lyon <christophe.lyon@linaro.org> + + 2018-03-20 Christophe Lyon <christophe.lyon@linaro.org> + + PR target/81647 + * gcc.target/aarch64/pr81647.c: Require fenv_exceptions. + + 2018-03-19 Sudakshina Das <sudi.das@arm.com> + + PR target/81647 + * gcc.target/aarch64/pr81647.c: New. + +2018-03-28 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + Backport from mainline + 2018-03-23 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + PR target/85026 + * g++.dg/pr85026.C: New test. + +2018-03-28 Segher Boessenkool <segher@kernel.crashing.org> + + Backport from mainline + 2018-03-08 Segher Boessenkool <segher@kernel.crashing.org> + + PR target/82411 + * gcc.target/powerpc/ppc-sdata-2.c: Skip if -mno-readonly-in-sdata. + +2018-03-27 Sudakshina Das <sudi.das@arm.com> + + Backport from mainline: + 2018-03-20 Sudakshina Das <sudi.das@arm.com> + + PR target/82989 + * gcc.target/arm/pr82989.c: New test. + + Backport from mainline: + 2018-03-21 Sudakshina Das <sudi.das@arm.com> + + PR target/82989 + * gcc.target/arm/pr82989.c: Change dg scan-assembly directives. + +2018-03-27 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + Backport from mainline + 2018-03-20 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + PR target/82518 + * lib/target-supports.exp (check_effective_target_vect_load_lanes): + Disable for armeb targets. + * gcc.target/arm/pr82518.c: New test. + +2018-03-23 Carl Love <cel@us.ibm.com> + + * gcc.target/powerpc/crypto-builtin-1-runnable.c: New test file. + +2018-03-22 Tom de Vries <tom@codesourcery.com> + + backport from trunk: + 2018-03-22 Tom de Vries <tom@codesourcery.com> + + PR tree-optimization/84956 + * gcc.dg/pr84956.c: New test. + +2018-03-20 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/85001 + * gfortran.dg/interface_41.f90: New test. + +2018-03-19 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/84931 + Backport from trunk + * gfortran.dg/array_constructor_52.f90: New test. + +2018-03-19 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77414 + * gfortran.dg/pr77414.f90: New test. + * gfortran.dg/internal_references_1.f90: Adjust error message. + +2018-03-19 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/65453 + * gfortran.dg/pr65453.f90: New test. + +2018-03-19 H.J. Lu <hongjiu.lu@intel.com> + + Backport from mainline + 2018-03-15 H.J. Lu <hongjiu.lu@intel.com> + + PR target/84574 + * gcc.target/i386/ret-thunk-9.c: Expect __x86_return_thunk + label instead of __x86_indirect_thunk label. + +2018-03-15 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/78741 + * gfortran.dg/pr78741.f90: New test. + 2018-03-12 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/83939 diff --git a/gcc/testsuite/g++.dg/asan/pr85081.C b/gcc/testsuite/g++.dg/asan/pr85081.C new file mode 100644 index 00000000000..d7dec311450 --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr85081.C @@ -0,0 +1,20 @@ +/* PR sanitizer/85081 */ +/* { dg-do run } */ +/* { dg-options "-fopenmp-simd" } */ +/* { dg-require-effective-target fopenmp } */ + +inline const int& max(const int& a, const int& b) +{ + return a < b ? b : a; +} + +int main() +{ + #pragma omp simd + for ( int i = 0; i < 20; ++i ) + { + const int j = max(i, 1); + } + + return 0; +} diff --git a/gcc/testsuite/g++.dg/concepts/auto4.C b/gcc/testsuite/g++.dg/concepts/auto4.C new file mode 100644 index 00000000000..e80341ec038 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/auto4.C @@ -0,0 +1,11 @@ +// PR c++/85006 +// { dg-additional-options "-std=c++17 -fconcepts" } + +template<typename... Ts> struct A {}; + +template<typename... Us> A<auto...> foo() { return A{}; } + +void bar() +{ + foo(); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-63.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-63.C deleted file mode 100644 index 04fb42d9e09..00000000000 --- a/gcc/testsuite/g++.dg/cpp0x/alias-decl-63.C +++ /dev/null @@ -1,18 +0,0 @@ -// PR c++/84785 -// { dg-do compile { target c++11 } } - -template <typename> struct A; -template <bool> struct B; -template <bool B, typename> using enable_if_t = typename B<B>::type; -template <long> using type_pack_element = int; -struct variant { - variant() {} - template <typename Arg, long I = Arg::type::value, - typename = type_pack_element<I>, enable_if_t<A<Arg>::value, int>> - variant(Arg &&); -}; - -struct S { - variant var; -}; -int main() { S s; } diff --git a/gcc/testsuite/g++.dg/cpp0x/auto-60626.C b/gcc/testsuite/g++.dg/cpp0x/auto-60626.C new file mode 100644 index 00000000000..35671924ea9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto-60626.C @@ -0,0 +1,6 @@ +// PR c++/60626 +// { dg-do compile { target c++14 } } + +struct A {}; + +void (*A::p)(auto) = 0; // { dg-error "auto|static data member|template" } diff --git a/gcc/testsuite/g++.dg/cpp0x/auto51.C b/gcc/testsuite/g++.dg/cpp0x/auto51.C new file mode 100644 index 00000000000..dfb08336b53 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto51.C @@ -0,0 +1,9 @@ +// PR c++/84798 +// { dg-do compile { target c++11 } } + +template<typename T> +struct S { + static constexpr T value = 0; +}; + +constexpr auto x = S<void(*)(auto)>::value; // { dg-error "auto" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype67.C b/gcc/testsuite/g++.dg/cpp0x/decltype67.C new file mode 100644 index 00000000000..e8042ac59e7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype67.C @@ -0,0 +1,7 @@ +// PR c++/85279 +// { dg-do compile { target c++11 } } + +template<typename T> struct A +{ + void foo(decltype(T())::Y); // { dg-error {decltype\(T\(\)\)::Y} } +}; diff --git a/gcc/testsuite/g++.dg/cpp0x/extern_template-4.C b/gcc/testsuite/g++.dg/cpp0x/extern_template-4.C new file mode 100644 index 00000000000..9f0c7d720ab --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/extern_template-4.C @@ -0,0 +1,23 @@ +// PR c++/85470 +// { dg-do compile { target c++11 } } + +template <class T> +struct StaticObject +{ + static T& create() + { + static T t; + return t; + } + + static T & instance; +}; + +template <class T> T & StaticObject<T>::instance = StaticObject<T>::create(); + +extern template class StaticObject<int>; + +void test() +{ + StaticObject<int>::instance; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg7.C b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg7.C deleted file mode 100644 index 636bf1afd88..00000000000 --- a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg7.C +++ /dev/null @@ -1,10 +0,0 @@ -// PR c++/84489 -// { dg-do compile { target c++11 } } - -template <class T = int, T N = T(), bool B = (N >> 1)> -T f1() {return 0;} - -int main() -{ - f1(); // Bug here -} diff --git a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg8.C b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg8.C new file mode 100644 index 00000000000..8d9b2d26f01 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg8.C @@ -0,0 +1,10 @@ +// PR c++/80227 +// { dg-do compile { target c++11 } } + +template <class T> +int foo (T); + +template <class T, class U = T [sizeof (T) - 5]> +int foo (T, U* = 0); + +int i = foo (123); diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-defarg2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-defarg2.C new file mode 100644 index 00000000000..65240355fc3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-defarg2.C @@ -0,0 +1,8 @@ +// PR c++/82336 +// { dg-do link { target c++11 } } + +struct foo { int x = 5; }; +struct bar : foo { bar() = default; }; +struct baz { bar x; }; +void qux(baz = {}){} +int main() { qux(); } diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi14.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi14.C new file mode 100644 index 00000000000..aac6fa1c81b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi14.C @@ -0,0 +1,19 @@ +// PR c++/71638 +// { dg-do compile { target c++11 } } +// { dg-options "-Wall" } + +struct A { + struct { + int i; + int &j = i; + } b; + int a = b.j; +}; + +void bar (A); + +void +foo () +{ + bar (A{}); +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for13.C b/gcc/testsuite/g++.dg/cpp0x/range-for13.C index 100f531f760..7babd713cfb 100644 --- a/gcc/testsuite/g++.dg/cpp0x/range-for13.C +++ b/gcc/testsuite/g++.dg/cpp0x/range-for13.C @@ -3,16 +3,6 @@ // { dg-do compile { target c++11 } } -//These should not be used -template<typename T> int *begin(T &t) -{ - T::fail; -} -template<typename T> int *end(T &t) -{ - T::fail; -} - struct container1 { int *begin(); @@ -87,10 +77,37 @@ struct container10 static function end; }; +namespace N +{ +template<typename T> int *begin(T &t) +{ + return 0; +} +template<typename T> int *end(T &t) +{ + return 0; +} +struct container11 +{ + int *begin(); + //no end +}; + +struct container12 +{ + int *end(); + //no begin +}; + +struct container13 +{ +}; +} + void test1() { - for (int x : container1()); // { dg-error "member but not" } - for (int x : container2()); // { dg-error "member but not" } + for (int x : container1()); // { dg-error "'begin' was not declared|'end' was not declared" } + for (int x : container2()); // { dg-error "'begin' was not declared|'end' was not declared" } for (int x : container3()); // { dg-error "within this context" } for (int x : container4()); // { dg-error "cannot be used as a function" } for (int x : container5()); // { dg-error "invalid use of" } @@ -99,4 +116,7 @@ void test1() for (int x : container8()); for (int x : container9()); // { dg-error "within this context" } for (int x : container10()); + for (int x : N::container11()); + for (int x : N::container12()); + for (int x : N::container13()); } diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae60.C b/gcc/testsuite/g++.dg/cpp0x/sfinae60.C new file mode 100644 index 00000000000..cfb4dc0b9a7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae60.C @@ -0,0 +1,25 @@ +// PR c++/78489 +// { dg-do compile { target c++11 } } + +template <bool P, class T = void> struct enable_if { using type = T; }; +template <class T> struct enable_if<false, T> {}; + +template <class Dummy> struct use_type { using type = int; }; + +template <bool Pred> +struct get_type { + static_assert(Pred, ""); + using type = int; +}; + +template <bool Val, + class = typename enable_if<Val>::type, // Evaluation/Substitution should end here + class ValT = typename get_type<Val>::type, // This should not be instantiated + typename use_type<ValT>::type = 0 // This NTTP causes ValT to be required + > +constexpr bool test(int) { return false; } + +template <bool> +constexpr bool test(long) { return true; } + +static_assert(test<false>(0), ""); // should call test(long) diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-nested2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-nested2.C new file mode 100644 index 00000000000..ce18f99ea50 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-nested2.C @@ -0,0 +1,9 @@ +// PR c++/84839 +// { dg-do compile { target c++11 } } + +template<typename... T> +struct S { + using fptr = void(*)(T... x, decltype(x)... y); +}; + +using F = S<int>::fptr; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-nested3.C b/gcc/testsuite/g++.dg/cpp0x/variadic-nested3.C new file mode 100644 index 00000000000..381ff731c09 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-nested3.C @@ -0,0 +1,10 @@ +// PR c++/71834 +// { dg-do compile { target c++11 } } + +template < typename ... Ts > struct A +{ + template < Ts ..., typename U > struct B {}; +}; + +// should be, e.g.: A < int >::B < 0, int > e; +A < int >::B < 0 > e; // { dg-error "wrong number of template arguments" } diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic16.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic16.C new file mode 100644 index 00000000000..a9292253453 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic16.C @@ -0,0 +1,8 @@ +// PR c++/64095 +// { dg-do compile { target c++14 } } + +void f() +{ + [](auto...){}(); + [](auto&&...){}(); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic17.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic17.C new file mode 100644 index 00000000000..4a7392f93bc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic17.C @@ -0,0 +1,125 @@ +// PR c++/85118 +// { dg-do compile { target c++14 } } + +namespace std +{ + template<typename _Tp> + struct remove_const + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_const<_Tp const> + { typedef _Tp type; }; + + + template<typename _Tp> + struct remove_volatile + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_volatile<_Tp volatile> + { typedef _Tp type; }; + + + template<typename _Tp> + struct remove_cv + { + typedef typename + remove_const<typename remove_volatile<_Tp>::type>::type type; + }; + + template<typename _Tp> + struct remove_reference + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_reference<_Tp&> + { typedef _Tp type; }; + + template<typename _Tp> + struct remove_reference<_Tp&&> + { typedef _Tp type; }; + + template<typename _Tp> + struct decay + { + using type = typename remove_reference<typename remove_const<_Tp>::type>::type; + }; + + template<typename _Tp> + _Tp&& + declval() noexcept; + + template<typename _Tp> + constexpr _Tp&& + forward(typename std::remove_reference<_Tp>::type& __t) noexcept + { return static_cast<_Tp&&>(__t); } + + + template<typename _Arg> + struct _Mu + { + template<typename _CVArg, typename _Tuple> + _CVArg&& + operator()(_CVArg&& __arg, _Tuple&) const volatile + { return std::forward<_CVArg>(__arg); } + }; + + template<typename _Functor, typename _Bound_args> + struct _Bind + { + _Functor _M_f; + _Bound_args _M_bound_args; + + template<typename _Args, typename _Result + = decltype( std::declval<_Functor&>()( + _Mu<_Bound_args>()( std::declval<_Bound_args&>(), + std::declval<_Args&>() ) ) )> + _Result + operator()(_Args&& __args) { return {}; } + + template<typename _Args, typename _Result + = decltype( std::declval<volatile _Functor&>()( + _Mu<_Bound_args>()( std::declval<volatile _Bound_args&>(), + std::declval<_Args&>() ) ) )> + _Result + operator()(_Args&& __args) volatile; + + }; + + template<typename _Func, typename _BoundArgs> + _Bind<typename decay<_Func>::type, typename decay<_BoundArgs>::type> + bind(_Func&& __f, _BoundArgs&& __args) + { + return { + std::forward<_Func>(__f), + std::forward<_BoundArgs>(__args) + }; + } + +} // namespace std + + +template <typename T> +bool isOneOf(const T& ) +{ + return false; +} + +template <typename T, typename FirstType, typename... Tail> +bool isOneOf(const T& t, const FirstType& firstValue, const Tail&... tail) +{ + return t == firstValue || isOneOf(t, tail...); +} + +int main() +{ + const auto isOneOfHelper = [](auto&&... params) + { + return isOneOf(std::forward<decltype(params)>(params)...); + }; + + auto isO = std::bind(isOneOfHelper, 'o'); + + isO('o'); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-mangle-1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-mangle-1.C index ca0910be503..8f135358465 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-mangle-1.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-mangle-1.C @@ -85,4 +85,4 @@ void Baz () // { dg-final { scan-assembler "_Z3eatIZ3FoovEUlPT_PT0_E4_Z3FoovEUlS1_S3_E5_EvRS0_RS2_:" } } // { dg-final { scan-assembler "_Z3eatIPiZ3BarIsEvvEUlPsPfS3_E_EvRT_RT0_:" } } // { dg-final { scan-assembler "_Z3eatIPiZ3BarIsEvvEUlPsPT_PT0_E0_EvRS3_RS5_:" } } -// { dg-final { scan-assembler "_Z3eatIPiZ3BarIsEvvEUlPsPT_zE1_EvRS3_RT0_:" } } +// { dg-final { scan-assembler "_Z3eatIPiZ3BarIsEvvEUlPsDpPT_E1_EvRT_RT0_:" } } diff --git a/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr10.C b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr10.C new file mode 100644 index 00000000000..1dc396d9ca5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr10.C @@ -0,0 +1,7 @@ +// PR c++/71638 +// { dg-do compile { target c++14 } } + +struct { + int &&a; + int b{a}; +} c[] { { 2 } }; diff --git a/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr11.C b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr11.C new file mode 100644 index 00000000000..09591df3807 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr11.C @@ -0,0 +1,12 @@ +// PR c++/85148 +// { dg-do compile { target c++14 } } + +template<typename T> struct A +{ + T x[1]{(__PTRDIFF_TYPE__)this}; +}; + +void foo() +{ + A<A<__PTRDIFF_TYPE__>> a{}; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr9.C b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr9.C new file mode 100644 index 00000000000..4e13fc5c9d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr9.C @@ -0,0 +1,14 @@ +// PR c++/84927 - ICE with NSDMI and reference +// { dg-do compile { target c++14 } } + +struct A +{ + int& r; + int i = r; +}; + +void foo() +{ + int j; + A a = A{j}; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60393.C b/gcc/testsuite/g++.dg/cpp1y/pr60393.C index 27fe2b72296..2ae21ed1147 100644 --- a/gcc/testsuite/g++.dg/cpp1y/pr60393.C +++ b/gcc/testsuite/g++.dg/cpp1y/pr60393.C @@ -1,8 +1,7 @@ // PR c++/60393 // { dg-do compile { target c++14 } } -// { dg-options "" } -void (*f)(auto) + 0; // { dg-error "expected" } +void (*f)(auto) + 0; // { dg-error "auto|expected" } struct A { diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60626.C b/gcc/testsuite/g++.dg/cpp1y/pr60626.C deleted file mode 100644 index 311464472da..00000000000 --- a/gcc/testsuite/g++.dg/cpp1y/pr60626.C +++ /dev/null @@ -1,7 +0,0 @@ -// PR c++/60626 -// { dg-do compile { target c++14 } } -// { dg-options "" } - -struct A {}; - -void (*A::p)(auto) = 0; // { dg-error "static data member|template" } diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction50.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction50.C new file mode 100644 index 00000000000..e8cdd8c710f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction50.C @@ -0,0 +1,22 @@ +// PR c++/84355 +// { dg-additional-options -std=c++17 } + +template <class, class> struct same; +template <class T> struct same<T,T> {}; + +template<typename T> struct A +{ + template<class U> struct B + { + B(U); + }; + + A() { + B b(0); + same<decltype(b),B<int>>{}; + } +}; + +struct C {}; + +A<C> a; diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction51.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction51.C new file mode 100644 index 00000000000..eba7972c3c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction51.C @@ -0,0 +1,11 @@ +// PR c++/84937 +// { dg-additional-options -std=c++17 } + +template<int, int> struct A {}; + +template<int I> struct B +{ + template<auto J> B(A<I,J>); +}; + +B b(A<0,0>{}); diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction54.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction54.C new file mode 100644 index 00000000000..e51398bbbb0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction54.C @@ -0,0 +1,15 @@ +// PR c++/82152 +// { dg-additional-options -std=c++17 } + +struct Base {}; + +template<typename T> +struct Derived : public Base { + using Base::Base; +}; + +Derived() -> Derived< void >; + +int main() { + Derived x; +} diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if13.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if13.C new file mode 100644 index 00000000000..9a9053c3305 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if13.C @@ -0,0 +1,11 @@ +// PR c++/84854 +// { dg-options -std=c++17 } + +constexpr int foo () { return 1; } +constexpr int foo (int) { return 2; } + +template <typename> +void a() +{ + if constexpr(foo) { }; +} diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp10.C b/gcc/testsuite/g++.dg/cpp1z/decomp10.C index f27cbfbc0d9..95d8bf6364e 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp10.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp10.C @@ -20,7 +20,7 @@ void f3() { auto [ x ] = a3; } // { dg-error "get" } struct A3a { int i,j; int get(); } a3a; template<> struct std::tuple_size<A3a> { enum { value = 1 }; }; -void f3a() { auto [ x ] = a3a; } // { dg-error "get<0>" } +void f3a() { auto [ x ] = a3a; } // { dg-error "get" } struct A3b { int i,j; } a3b; int get(A3b&&); diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp37.C b/gcc/testsuite/g++.dg/cpp1z/decomp37.C new file mode 100644 index 00000000000..dc47908cddf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp37.C @@ -0,0 +1,62 @@ +// { dg-additional-options -std=c++17 } +// { dg-do compile } + +#include <memory> +#include <tuple> +#include <string> + +struct X : private std::shared_ptr<int> +{ + std::string fun_payload; +}; + +template<int N> std::string& get(X& x) +{ + if constexpr(N==0) return x.fun_payload; +} + +namespace std { + template<> class tuple_size<X> : public std::integral_constant<int, 1> {}; + template<> class tuple_element<0, X> {public: using type = std::string;}; +} + +struct X2 : private std::shared_ptr<int> +{ + int fun_payload; + template <class T> void get(); +}; + +template<int N> int& get(X2& x) +{ + if constexpr(N==0) return x.fun_payload; +} + +namespace std { + template<> class tuple_size<X2> : public std::integral_constant<int, 1> {}; + template<> class tuple_element<0, X2> {public: using type = int;}; +} + +class X3 +{ + double fun_payload; +public: + template <int N> double& get() + { + if constexpr(N==0) return fun_payload; + } +}; + +namespace std { + template<> class tuple_size<X3> : public std::integral_constant<int, 1> {}; + template<> class tuple_element<0, X3> {public: using type = double;}; +} + +int main() +{ + X x; + auto& [b1] = x; + X2 x2; + auto& [b2] = x2; + X3 x3; + auto& [b3] = x3; +} diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp38.C b/gcc/testsuite/g++.dg/cpp1z/decomp38.C new file mode 100644 index 00000000000..fc69c02e4d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp38.C @@ -0,0 +1,48 @@ +// { dg-additional-options -std=c++17 } +// { dg-do compile } + +class X +{ + int a, b; + void f() + { + auto[x,y] = *this; + } +}; + +class X2 +{ + int a, b; + void f(X2& other) + { + auto[x,y] = other; + } +}; + +struct X3 +{ + friend void foo(); +private: + int a; +}; + +void foo() +{ + X3 x; + auto [a] = x; +} + +struct X4 +{ + int a; +}; + +struct X5 : private X4 +{ + friend void foo2(); +}; + +void foo2() { + X5 x; + auto [a] = x; +} diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp4.C b/gcc/testsuite/g++.dg/cpp1z/decomp4.C index bc85263e986..30068592553 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp4.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp4.C @@ -18,10 +18,10 @@ test (A &a, B &b, C &c, D &d, E &e, F &f, G &g, H &h, I &i) // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 } auto [ k ] { b }; // { dg-error "cannot decompose class type 'B' because it has an anonymous union member" } // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 } - auto [ l, l2 ] = c; // { dg-error "cannot decompose non-public member 'C::b' of 'C'" } + auto [ l, l2 ] = c; // { dg-error "cannot decompose inaccessible member 'C::b' of 'C'" } // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 } auto [ m ] = d; // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } } - auto [ n ] { e }; // { dg-error "cannot decompose non-public member 'E::a' of 'E'" } + auto [ n ] { e }; // { dg-error "cannot decompose inaccessible member 'E::a' of 'E'" } // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 } auto [ o ] { f }; // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } } auto & [ p ] { g }; // { dg-error "cannot decompose class type 'G': both it and its base class 'F' have non-static data members" } diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.C b/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.C new file mode 100644 index 00000000000..2fc2b033ba6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.C @@ -0,0 +1,12 @@ +// { dg-do compile { target c++11 } } + +#include "noexcept-type19.h" + +extern "C" void *malloc (size_t); + +template<class T> void f(T*); + +int main() +{ + f<decltype(malloc)>(operator new); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.h b/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.h new file mode 100644 index 00000000000..33a29357e7f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/noexcept-type19.h @@ -0,0 +1,4 @@ +#pragma GCC system_header + +typedef decltype(sizeof(0)) size_t; +extern "C" void *malloc (size_t) throw(); diff --git a/gcc/testsuite/g++.dg/diagnostic/pr85464.C b/gcc/testsuite/g++.dg/diagnostic/pr85464.C new file mode 100644 index 00000000000..ee8b65185e5 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/pr85464.C @@ -0,0 +1,5 @@ +// { dg-options "-Wignored-qualifiers" } +struct Test { + operator int const(); // { dg-warning "type qualifiers ignored" } + operator int const() const; // { dg-warning "type qualifiers ignored" } +}; diff --git a/gcc/testsuite/g++.dg/ext/attr-noinline-4.C b/gcc/testsuite/g++.dg/ext/attr-noinline-4.C new file mode 100644 index 00000000000..27c7ae80fec --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attr-noinline-4.C @@ -0,0 +1,10 @@ +// PR c++/84665 + +struct S {} a[1]; + +template <int N> +void +foo () +{ + __attribute__ ((noinline (a[0]))) int c = 0; // { dg-error "wrong number of arguments" } +} diff --git a/gcc/testsuite/g++.dg/ext/builtin12.C b/gcc/testsuite/g++.dg/ext/builtin12.C new file mode 100644 index 00000000000..1d6bb75cd77 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/builtin12.C @@ -0,0 +1,10 @@ +// PR c++/85113 +// { dg-do compile { target c++14 } } + +template<bool> struct A {}; + +constexpr int foo() +{ + A<__builtin_constant_p(0)> a{}; + return 0; +} diff --git a/gcc/testsuite/g++.dg/init/new44.C b/gcc/testsuite/g++.dg/init/new44.C index ab6e3484cc8..4ab73209e22 100644 --- a/gcc/testsuite/g++.dg/init/new44.C +++ b/gcc/testsuite/g++.dg/init/new44.C @@ -87,10 +87,10 @@ test_one_dim_short_array () static void __attribute__ ((used)) test_two_dim_char_array () { - p = new char [1][MAX]; // { dg-error "size of unnamed array" } - p = new char [1][MAX - 1]; // { dg-error "size of unnamed array" } - p = new char [1][MAX - 2]; // { dg-error "size of unnamed array" } - p = new char [1][MAX - 99]; // { dg-error "size of unnamed array" } + p = new char [1][MAX]; // { dg-error "size of (unnamed )?array" } + p = new char [1][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new char [1][MAX - 2]; // { dg-error "size of (unnamed )?array" } + p = new char [1][MAX - 99]; // { dg-error "size of (unnamed )?array" } p = new char [1][MAX / 2]; // { dg-error "size of array" } p = new char [1][MAX / 2 - 1]; // { dg-error "size of array" } p = new char [1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -104,18 +104,18 @@ test_two_dim_char_array () p = new char [1][MAX / 2 - 7]; // okay p = new char [1][MAX / 2 - 8]; // okay - p = new char [2][MAX]; // { dg-error "size of unnamed array" } - p = new char [2][MAX - 1]; // { dg-error "size of unnamed array" } - p = new char [2][MAX - 2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX - 2]; // { dg-error "size of (unnamed )?array" } p = new char [2][MAX / 2]; // { dg-error "size of array" } p = new char [2][MAX / 2 - 1]; // { dg-error "size of array" } p = new char [2][MAX / 2 - 2]; // { dg-error "size of array" } p = new char [2][MAX / 2 - 7]; // { dg-error "size of array" } p = new char [2][MAX / 2 - 8]; // { dg-error "size of array" } - p = new char [MAX][MAX]; // { dg-error "size of unnamed array" } - p = new char [MAX][MAX - 1]; // { dg-error "size of unnamed array" } - p = new char [MAX][MAX - 2]; // { dg-error "size of unnamed array" } + p = new char [MAX][MAX]; // { dg-error "size of (unnamed )?array" } + p = new char [MAX][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new char [MAX][MAX - 2]; // { dg-error "size of (unnamed )?array" } p = new char [MAX][MAX / 2]; // { dg-error "size of array" } p = new char [MAX][MAX / 2 - 1]; // { dg-error "size of array" } p = new char [MAX][MAX / 2 - 2]; // { dg-error "size of array" } @@ -142,10 +142,10 @@ test_two_dim_char_array () static __attribute__ ((used)) void test_three_dim_char_array () { - p = new char [1][1][MAX]; // { dg-error "size of unnamed array" } - p = new char [1][1][MAX - 1]; // { dg-error "size of unnamed array" } - p = new char [1][1][MAX - 2]; // { dg-error "size of unnamed array" } - p = new char [1][1][MAX - 99]; // { dg-error "size of unnamed array" } + p = new char [1][1][MAX]; // { dg-error "size of (unnamed )?array" } + p = new char [1][1][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new char [1][1][MAX - 2]; // { dg-error "size of (unnamed )?array" } + p = new char [1][1][MAX - 99]; // { dg-error "size of (unnamed )?array" } p = new char [1][1][MAX / 2]; // { dg-error "size of array" } p = new char [1][1][MAX / 2 - 1]; // { dg-error "size of array" } p = new char [1][1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -159,19 +159,19 @@ test_three_dim_char_array () p = new char [1][1][MAX / 2 - 7]; // okay p = new char [1][1][MAX / 2 - 8]; // okay - p = new char [1][2][MAX]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX - 1]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX - 2]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX - 99]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX / 2]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX / 2 - 1]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX / 2 - 2]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX / 2 - 3]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX / 2 - 4]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX / 2 - 5]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX / 2 - 6]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX / 2 - 7]; // { dg-error "size of unnamed array" } - p = new char [1][2][MAX / 2 - 8]; // { dg-error "size of unnamed array" } + p = new char [1][2][MAX]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX - 2]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX - 99]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX / 2]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX / 2 - 1]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX / 2 - 2]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX / 2 - 3]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX / 2 - 4]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX / 2 - 5]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX / 2 - 6]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX / 2 - 7]; // { dg-error "size of (unnamed )?array" } + p = new char [1][2][MAX / 2 - 8]; // { dg-error "size of (unnamed )?array" } p = new char [1][2][MAX / 4]; // { dg-error "size of array" } // Avoid exercising data model-dependent expressions. @@ -181,10 +181,10 @@ test_three_dim_char_array () p = new char [1][2][MAX / 4 - 3]; // okay p = new char [1][2][MAX / 4 - 4]; // okay - p = new char [2][1][MAX]; // { dg-error "size of unnamed array" } - p = new char [2][1][MAX - 1]; // { dg-error "size of unnamed array" } - p = new char [2][1][MAX - 2]; // { dg-error "size of unnamed array" } - p = new char [2][1][MAX - 99]; // { dg-error "size of unnamed array" } + p = new char [2][1][MAX]; // { dg-error "size of (unnamed )?array" } + p = new char [2][1][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new char [2][1][MAX - 2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][1][MAX - 99]; // { dg-error "size of (unnamed )?array" } p = new char [2][1][MAX / 2]; // { dg-error "size of array" } p = new char [2][1][MAX / 2 - 1]; // { dg-error "size of array" } p = new char [2][1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -203,19 +203,19 @@ test_three_dim_char_array () p = new char [2][1][MAX / 4 - 3]; // okay p = new char [2][1][MAX / 4 - 4]; // okay - p = new char [2][2][MAX]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX - 1]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX - 2]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX - 99]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX / 2]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX / 2 - 1]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX / 2 - 2]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX / 2 - 3]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX / 2 - 4]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX / 2 - 5]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX / 2 - 6]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX / 2 - 7]; // { dg-error "size of unnamed array" } - p = new char [2][2][MAX / 2 - 8]; // { dg-error "size of unnamed array" } + p = new char [2][2][MAX]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX - 2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX - 99]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX / 2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX / 2 - 1]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX / 2 - 2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX / 2 - 3]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX / 2 - 4]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX / 2 - 5]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX / 2 - 6]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX / 2 - 7]; // { dg-error "size of (unnamed )?array" } + p = new char [2][2][MAX / 2 - 8]; // { dg-error "size of (unnamed )?array" } p = new char [2][2][MAX / 4]; // { dg-error "size of array" } p = new char [2][2][MAX / 4 - 1]; // { dg-error "size of array" } p = new char [2][2][MAX / 4 - 2]; // { dg-error "size of array" } @@ -227,19 +227,19 @@ test_three_dim_char_array () p = new char [2][2][MAX / 8 - 2]; p = new char [2][2][MAX / 8 - 3]; - p = new char [2][MAX][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX - 1][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX - 2][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX - 99][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX / 2][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX / 2 - 1][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX / 2 - 2][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX / 2 - 3][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX / 2 - 4][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX / 2 - 5][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX / 2 - 6][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX / 2 - 7][2]; // { dg-error "size of unnamed array" } - p = new char [2][MAX / 2 - 8][2]; // { dg-error "size of unnamed array" } + p = new char [2][MAX][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX - 1][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX - 2][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX - 99][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX / 2][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX / 2 - 1][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX / 2 - 2][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX / 2 - 3][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX / 2 - 4][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX / 2 - 5][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX / 2 - 6][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX / 2 - 7][2]; // { dg-error "size of (unnamed )?array" } + p = new char [2][MAX / 2 - 8][2]; // { dg-error "size of (unnamed )?array" } p = new char [2][MAX / 4][2]; // { dg-error "size of array" } p = new char [2][MAX / 4 - 1][2]; // { dg-error "size of array" } p = new char [2][MAX / 4 - 2][2]; // { dg-error "size of array" } @@ -275,11 +275,11 @@ test_three_dim_char_array () p = new char [MAX / 8 - 2][2][2]; p = new char [MAX / 8 - 3][2][2]; - p = new char [MAX][MAX][MAX]; // { dg-error "size of unnamed array" } - p = new char [MAX][MAX][MAX / 2]; // { dg-error "size of unnamed array" } - p = new char [MAX][MAX / 2][MAX]; // { dg-error "size of unnamed array" } - p = new char [MAX][MAX / 2][MAX / 2]; // { dg-error "size of unnamed array" } - p = new char [MAX / 2][MAX / 2][MAX / 2]; // { dg-error "size of unnamed array" } + p = new char [MAX][MAX][MAX]; // { dg-error "size of (unnamed )?array" } + p = new char [MAX][MAX][MAX / 2]; // { dg-error "size of (unnamed )?array" } + p = new char [MAX][MAX / 2][MAX]; // { dg-error "size of (unnamed )?array" } + p = new char [MAX][MAX / 2][MAX / 2]; // { dg-error "size of (unnamed )?array" } + p = new char [MAX / 2][MAX / 2][MAX / 2]; // { dg-error "size of (unnamed )?array" } } // Exercise new expression with N-dimensional arrays where N is @@ -342,10 +342,10 @@ test_one_dim_byte_array (void *p) static void __attribute__ ((used)) test_placement_two_dim_byte_struct_array (void *p) { - p = new (p) B [1][MAX]; // { dg-error "size of unnamed array" } - p = new (p) B [1][MAX - 1]; // { dg-error "size of unnamed array" } - p = new (p) B [1][MAX - 2]; // { dg-error "size of unnamed array" } - p = new (p) B [1][MAX - 99]; // { dg-error "size of unnamed array" } + p = new (p) B [1][MAX]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][MAX - 2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][MAX - 99]; // { dg-error "size of (unnamed )?array" } p = new (p) B [1][MAX / 2]; // { dg-error "size of array" } p = new (p) B [1][MAX / 2 - 1]; // { dg-error "size of array" } p = new (p) B [1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -359,18 +359,18 @@ test_placement_two_dim_byte_struct_array (void *p) p = new (p) B [1][MAX / 2 - 7]; // okay p = new (p) B [1][MAX / 2 - 8]; // okay - p = new (p) B [2][MAX]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX - 1]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX - 2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX - 2]; // { dg-error "size of (unnamed )?array" } p = new (p) B [2][MAX / 2]; // { dg-error "size of array" } p = new (p) B [2][MAX / 2 - 1]; // { dg-error "size of array" } p = new (p) B [2][MAX / 2 - 2]; // { dg-error "size of array" } p = new (p) B [2][MAX / 2 - 7]; // { dg-error "size of array" } p = new (p) B [2][MAX / 2 - 8]; // { dg-error "size of array" } - p = new (p) B [MAX][MAX]; // { dg-error "size of unnamed array" } - p = new (p) B [MAX][MAX - 1]; // { dg-error "size of unnamed array" } - p = new (p) B [MAX][MAX - 2]; // { dg-error "size of unnamed array" } + p = new (p) B [MAX][MAX]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [MAX][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [MAX][MAX - 2]; // { dg-error "size of (unnamed )?array" } p = new (p) B [MAX][MAX / 2]; // { dg-error "size of array" } p = new (p) B [MAX][MAX / 2 - 1]; // { dg-error "size of array" } p = new (p) B [MAX][MAX / 2 - 2]; // { dg-error "size of array" } @@ -397,10 +397,10 @@ test_placement_two_dim_byte_struct_array (void *p) static __attribute__ ((used)) void test_placement_three_dim_byte_struct_array (void *p) { - p = new (p) B [1][1][MAX]; // { dg-error "size of unnamed array" } - p = new (p) B [1][1][MAX - 1]; // { dg-error "size of unnamed array" } - p = new (p) B [1][1][MAX - 2]; // { dg-error "size of unnamed array" } - p = new (p) B [1][1][MAX - 99]; // { dg-error "size of unnamed array" } + p = new (p) B [1][1][MAX]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][1][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][1][MAX - 2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][1][MAX - 99]; // { dg-error "size of (unnamed )?array" } p = new (p) B [1][1][MAX / 2]; // { dg-error "size of array" } p = new (p) B [1][1][MAX / 2 - 1]; // { dg-error "size of array" } p = new (p) B [1][1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -414,19 +414,19 @@ test_placement_three_dim_byte_struct_array (void *p) p = new (p) B [1][1][MAX / 2 - 7]; // okay p = new (p) B [1][1][MAX / 2 - 8]; // okay - p = new (p) B [1][2][MAX]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX - 1]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX - 2]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX - 99]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX / 2]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX / 2 - 1]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX / 2 - 2]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX / 2 - 3]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX / 2 - 4]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX / 2 - 5]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX / 2 - 6]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX / 2 - 7]; // { dg-error "size of unnamed array" } - p = new (p) B [1][2][MAX / 2 - 8]; // { dg-error "size of unnamed array" } + p = new (p) B [1][2][MAX]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX - 2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX - 99]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX / 2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX / 2 - 1]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX / 2 - 2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX / 2 - 3]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX / 2 - 4]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX / 2 - 5]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX / 2 - 6]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX / 2 - 7]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [1][2][MAX / 2 - 8]; // { dg-error "size of (unnamed )?array" } p = new (p) B [1][2][MAX / 4]; // { dg-error "size of array" } // Avoid exercising data model-dependent expressions. @@ -436,10 +436,10 @@ test_placement_three_dim_byte_struct_array (void *p) p = new (p) B [1][2][MAX / 4 - 3]; // okay p = new (p) B [1][2][MAX / 4 - 4]; // okay - p = new (p) B [2][1][MAX]; // { dg-error "size of unnamed array" } - p = new (p) B [2][1][MAX - 1]; // { dg-error "size of unnamed array" } - p = new (p) B [2][1][MAX - 2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][1][MAX - 99]; // { dg-error "size of unnamed array" } + p = new (p) B [2][1][MAX]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][1][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][1][MAX - 2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][1][MAX - 99]; // { dg-error "size of (unnamed )?array" } p = new (p) B [2][1][MAX / 2]; // { dg-error "size of array" } p = new (p) B [2][1][MAX / 2 - 1]; // { dg-error "size of array" } p = new (p) B [2][1][MAX / 2 - 2]; // { dg-error "size of array" } @@ -458,19 +458,19 @@ test_placement_three_dim_byte_struct_array (void *p) p = new (p) B [2][1][MAX / 4 - 3]; // okay p = new (p) B [2][1][MAX / 4 - 4]; // okay - p = new (p) B [2][2][MAX]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX - 1]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX - 2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX - 99]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX / 2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX / 2 - 1]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX / 2 - 2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX / 2 - 3]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX / 2 - 4]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX / 2 - 5]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX / 2 - 6]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX / 2 - 7]; // { dg-error "size of unnamed array" } - p = new (p) B [2][2][MAX / 2 - 8]; // { dg-error "size of unnamed array" } + p = new (p) B [2][2][MAX]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX - 1]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX - 2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX - 99]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX / 2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX / 2 - 1]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX / 2 - 2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX / 2 - 3]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX / 2 - 4]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX / 2 - 5]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX / 2 - 6]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX / 2 - 7]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][2][MAX / 2 - 8]; // { dg-error "size of (unnamed )?array" } p = new (p) B [2][2][MAX / 4]; // { dg-error "size of array" } p = new (p) B [2][2][MAX / 4 - 1]; // { dg-error "size of array" } p = new (p) B [2][2][MAX / 4 - 2]; // { dg-error "size of array" } @@ -482,19 +482,19 @@ test_placement_three_dim_byte_struct_array (void *p) p = new (p) B [2][2][MAX / 8 - 2]; p = new (p) B [2][2][MAX / 8 - 3]; - p = new (p) B [2][MAX][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX - 1][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX - 2][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX - 99][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX / 2][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX / 2 - 1][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX / 2 - 2][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX / 2 - 3][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX / 2 - 4][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX / 2 - 5][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX / 2 - 6][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX / 2 - 7][2]; // { dg-error "size of unnamed array" } - p = new (p) B [2][MAX / 2 - 8][2]; // { dg-error "size of unnamed array" } + p = new (p) B [2][MAX][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX - 1][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX - 2][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX - 99][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX / 2][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX / 2 - 1][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX / 2 - 2][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX / 2 - 3][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX / 2 - 4][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX / 2 - 5][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX / 2 - 6][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX / 2 - 7][2]; // { dg-error "size of (unnamed )?array" } + p = new (p) B [2][MAX / 2 - 8][2]; // { dg-error "size of (unnamed )?array" } p = new (p) B [2][MAX / 4][2]; // { dg-error "size of array" } p = new (p) B [2][MAX / 4 - 1][2]; // { dg-error "size of array" } p = new (p) B [2][MAX / 4 - 2][2]; // { dg-error "size of array" } diff --git a/gcc/testsuite/g++.dg/ipa/pr84658.C b/gcc/testsuite/g++.dg/ipa/pr84658.C new file mode 100644 index 00000000000..6846e1832bd --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr84658.C @@ -0,0 +1,30 @@ +/* PR ipa/84658 */ +/* { dg-do run } */ +/* { dg-options "-O2 -fmerge-all-constants -std=c++11" } */ + +const int kTestCasesFoo[] = { 0, 1, 2, 3, 4, 5, 8, 15, 16, 17, 512, 1020, 1021, 1022, 1023, 1024 }; +const int kTestCasesBar[] = { 0, 1, 2, 3, 4, 5, 8, 15, 16, 17, 512, 1020, 1021, 1022, 1023, 1024 }; + +void Foo() { + __builtin_printf("foo:"); + for (int count : kTestCasesFoo) { + __builtin_printf("%d,", count); + } + __builtin_printf(";\n"); +} + +void Bar() { + __builtin_printf("bar:"); + for (int count : kTestCasesBar) { + __builtin_printf("%d,", count); + } + __builtin_printf(";\n"); +} + +int main() { + Foo(); + Bar(); +} + +/* { dg-output "foo:0,1,2,3,4,5,8,15,16,17,512,1020,1021,1022,1023,1024,;(\n|\n\r|\r)*" } */ +/* { dg-output "bar:0,1,2,3,4,5,8,15,16,17,512,1020,1021,1022,1023,1024,;(\n|\n\r|\r)*" } */ diff --git a/gcc/testsuite/g++.dg/opt/pr85196.C b/gcc/testsuite/g++.dg/opt/pr85196.C new file mode 100644 index 00000000000..04d7abde4fa --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/pr85196.C @@ -0,0 +1,89 @@ +// PR target/85196 +// Testcase by Rainer Orth <ro@gcc.gnu.org> + +// { dg-do compile } +// { dg-options "-O -fpermissive -w" } +// { dg-additional-options "-fPIC" { target fpic } } + +class a; +template <typename> class b; +template <typename k> class d : public b<k> {}; +class e {}; +void f(int); +template <class> class g { +public: + h(); + a i(); +}; +template <> class b<e> : public g<e> {}; +typedef (*j)(d<e>); +template <class k> class l { +public: + k operator->() { return 0; } +}; +enum m { n, aa, o, ab, q, p }; +inline s(m ac) { + switch (ac) { + case n: + case aa: + case p: + return 1; + case o: + case ab: + return 2; + } +} +class D { + int ad; + +public: + *ae() { return &ad; } +}; +class a { + l<D *> af; + +public: + *r() { return af->ae(); } + t(int *c) { + int *w = af->ae(); + return w == c; + } +}; +class F : a { +public: + static int ah[]; + static e v(F *); + unsigned long ai() const; +}; +inline unsigned long F::ai() const { + m aj = r() - &ah[0]; + return s(aj); +} +inline e F::v(F *ak) { + long al = ak->ai(); + f(al); +} +template <typename> am() { return q; } +class an : F { +public: + static ao(d<e> u) { + int *ap; + m aq = am<unsigned>(); + ap = &ah[aq]; + return u.h() && u.i().t(ap); + } + template <e ar(F *)> static as() { + F at; + ar(&at); + } + template <e ar(F *)> static au(int *, unsigned, e *) { + j av = ao; + d<e> aw; + if (av(aw)) + as<ar>(); + } +}; +int *ax; +int ay; +e az; +ba() { an::au<an::v>(ax, ay, &az); } diff --git a/gcc/testsuite/g++.dg/pr85026.C b/gcc/testsuite/g++.dg/pr85026.C new file mode 100644 index 00000000000..e1e3ccd2e35 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr85026.C @@ -0,0 +1,61 @@ +/* PR target/85026. */ +/* { dg-do assemble } */ +/* { dg-options "-O2 -std=gnu++11" } */ + +template <class> class a; +class b; +struct c { + typedef a<b> &g; +}; +template <typename d> struct e { typedef typename d::f iter; }; +class h { +public: + void __attribute__((noreturn)) i(); +} ab; +template <class> class a { +public: + typedef b *f; + b &operator[](unsigned m) { + if (ac) + ab.i(); + return ad[m]; + } + f n() { return ad; } + f m_fn3(); + b *ad; + unsigned ac; +}; +class b { +public: + short j; + short k; + signed l; +} __attribute__((__packed__)); +void o(a<b> &m, b &p2, b &p) { + p2 = p = m[0]; + if (bool at = false) + ; + else + for (c::g au(m);; at = true) + if (bool av = false) + ; + else + for (e<a<int>>::iter aw = au.n(), ax = au.m_fn3(); ax; + av ? (void)0 : (void)0) + if (bool ay = 0) + ; + else + for (b az = *aw; !ay; ay = true) { + if (p2.j) + p2.j = az.j; + else if (p.j) + p.j = az.j; + if (p2.k) + p2.k = az.k; + else if (az.k > p.k) + p.k = az.k; + if (az.l < p2.l) + if (az.l > p.l) + p.l = az.l; + } +} diff --git a/gcc/testsuite/g++.dg/template/dependent-base3.C b/gcc/testsuite/g++.dg/template/dependent-base3.C new file mode 100644 index 00000000000..e38b968e774 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/dependent-base3.C @@ -0,0 +1,26 @@ +// PR c++/85060 +// { dg-do compile { target c++14 } } + +struct CA { + constexpr int foo() const { return 42; } +}; + +template <class T> +struct CB : CA { }; + +template <class T> +struct CC : CB<T> { + constexpr int bar() const { + const int m = CA::foo(); + return m; + } + + constexpr int baz() const { + const T m = CA::foo(); + return m; + } +}; + +constexpr CC<double> c; + +static_assert( c.bar() == 42, "" ); diff --git a/gcc/testsuite/g++.dg/torture/pr85496.C b/gcc/testsuite/g++.dg/torture/pr85496.C new file mode 100644 index 00000000000..3f504a37791 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr85496.C @@ -0,0 +1,18 @@ +// PR middle-end/85496 +// Reported by Marek Polacek <mpolacek@gcc.gnu.org> + +template <typename> class complex; +template <typename _Tp> complex<_Tp> operator*(complex<_Tp>, complex<_Tp>); +template <> struct complex<float> { _Complex float _M_value; }; +class A { + complex<float> _f0, _f1; + +public: + complex<float> &m_fn1() { return _f1; } +}; +complex<float> a; +void cos() { + A b; + complex<float> c; + b.m_fn1() = c * a; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr84748.c b/gcc/testsuite/gcc.c-torture/execute/pr84748.c new file mode 100644 index 00000000000..9572ab285c6 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr84748.c @@ -0,0 +1,34 @@ +/* { dg-require-effective-target int128 } */ + +typedef unsigned __int128 u128; + +int a, c, d; +u128 b; + +unsigned long long g0, g1; + +void +store (unsigned long long a0, unsigned long long a1) +{ + g0 = a0; + g1 = a1; +} + +void +foo (void) +{ + b += a; + c = d != 84347; + b /= c; + u128 x = b; + store (x >> 0, x >> 64); +} + +int +main (void) +{ + foo (); + if (g0 != 0 || g1 != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr85248_0.c b/gcc/testsuite/gcc.dg/lto/pr85248_0.c new file mode 100644 index 00000000000..df61ac976a5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr85248_0.c @@ -0,0 +1,45 @@ +/* PR lto/85248 */ +/* { dg-lto-do run } */ +/* { dg-lto-options { { -flto -O2 } } } */ + +extern void test_alias (int s, int e) __asm__ (__USER_LABEL_PREFIX__ "test"); +extern void test_noreturn (int s, int e) __asm__ (__USER_LABEL_PREFIX__ "test") + __attribute__ ((__noreturn__)); + +extern inline __attribute__ ((__always_inline__, __gnu_inline__)) void +test (int s, int e) +{ + if (__builtin_constant_p (s) && s != 0) + test_noreturn (s, e); + else + test_alias (s, e); +} + +int +foo (void) +{ + static volatile int a; + return a; +} + +static void +bar (void) +{ + test (0, 1); + __builtin_exit (0); +} + +static void +baz () +{ + test (1, 0); +} + +int +main () +{ + if (foo ()) + baz (); + bar (); + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/lto/pr85248_1.c b/gcc/testsuite/gcc.dg/lto/pr85248_1.c new file mode 100644 index 00000000000..5ce257181fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr85248_1.c @@ -0,0 +1,9 @@ +/* { dg-options "-fno-lto" } */ + +void +test (int s, int e) +{ + asm volatile ("" : "+g" (s), "+g" (e) : : "memory"); + if (s) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/pr84956.c b/gcc/testsuite/gcc.dg/pr84956.c new file mode 100644 index 00000000000..055a749d635 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr84956.c @@ -0,0 +1,27 @@ +/* { dg-options "-O2 -ftree-tail-merge" } */ + +char a; +int c; +unsigned b (); + +unsigned +setjmp () +{ +} + +static void +d () +{ + if (b ()) + c = 3; +} + +void +e () +{ + d (); + a && ({ setjmp (); }); + a && ({ setjmp (); }); + a && ({ setjmp (); }); +} + diff --git a/gcc/testsuite/gcc.target/aarch64/pr81647.c b/gcc/testsuite/gcc.target/aarch64/pr81647.c new file mode 100644 index 00000000000..2d764030dc8 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr81647.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -fdump-tree-ssa" } */ +/* { dg-require-effective-target fenv_exceptions } */ + +#include <fenv.h> + +double x[28], y[28]; +int res[28]; + +int +main (void) +{ + int i; + for (i = 0; i < 28; ++i) + { + x[i] = __builtin_nan (""); + y[i] = i; + } + __asm__ volatile ("" ::: "memory"); + feclearexcept (FE_ALL_EXCEPT); + for (i = 0; i < 4; ++i) + res[i] = __builtin_isgreater (x[i], y[i]); + for (i = 4; i < 8; ++i) + res[i] = __builtin_isgreaterequal (x[i], y[i]); + for (i = 8; i < 12; ++i) + res[i] = __builtin_isless (x[i], y[i]); + for (i = 12; i < 16; ++i) + res[i] = __builtin_islessequal (x[i], y[i]); + for (i = 16; i < 20; ++i) + res[i] = __builtin_islessgreater (x[i], y[i]); + for (i = 20; i < 24; ++i) + res[i] = __builtin_isunordered (x[i], y[i]); + for (i = 24; i < 28; ++i) + res[i] = !(__builtin_isunordered (x[i], y[i])); + __asm__ volatile ("" ::: "memory"); + return fetestexcept (FE_ALL_EXCEPT) != 0; +} + +/* { dg-final { scan-tree-dump " u> " "ssa" } } */ +/* { dg-final { scan-tree-dump " u>= " "ssa" } } */ +/* { dg-final { scan-tree-dump " u< " "ssa" } } */ +/* { dg-final { scan-tree-dump " u<= " "ssa" } } */ +/* { dg-final { scan-tree-dump " u== " "ssa" } } */ +/* { dg-final { scan-tree-dump " unord " "ssa" } } */ +/* { dg-final { scan-tree-dump " ord " "ssa" } } */ diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-1.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-1.c index c13272eed68..f764153cb17 100644 --- a/gcc/testsuite/gcc.target/arm/cmse/cmse-1.c +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-1.c @@ -71,6 +71,20 @@ baz (void) { return cmse_nonsecure_caller (); } +/* { dg-final { scan-assembler "baz:" } } */ +/* { dg-final { scan-assembler "__acle_se_baz:" } } */ +/* { dg-final { scan-assembler-not "\tcmse_nonsecure_caller" } } */ +/* Look for an andsi of 1 with a register in function baz, ie. + +;; Function baz<anything> +<any line without '('> +(insn <anything but '('> (set (reg<any register modifier>:SI <anything but ')'>) + (and:SI (reg<any register modifier>:SI <anything but ')'>) + (const_int 1 <anything but ')'>)<anything but '('> + <optional: (nil)<anything but '('>> +(insn +*/ +/* { dg-final { scan-rtl-dump "\n;; Function baz\[^\n\]*\[^(\]+\[^;\]*\n\\(insn \[^(\]+ \\(set \\(reg\[^:\]*:SI \[^)\]+\\)\[^(\]*\\(and:SI \\(reg\[^:\]*:SI \[^)\]+\\)\[^(\]*\\((const_int 1|reg\[^:\]*:SI) \[^)\]+\\)\[^(\]+(\\(nil\\)\[^(\]+)?\\(insn" expand } } */ typedef int __attribute__ ((cmse_nonsecure_call)) (int_nsfunc_t) (void); @@ -86,6 +100,11 @@ qux (int_nsfunc_t * callback) { fp = cmse_nsfptr_create (callback); } +/* { dg-final { scan-assembler "qux:" } } */ +/* { dg-final { scan-assembler "__acle_se_qux:" } } */ +/* { dg-final { scan-assembler "bic" } } */ +/* { dg-final { scan-assembler "push\t\{r4, r5, r6" } } */ +/* { dg-final { scan-assembler "msr\tAPSR_nzcvq" } } */ int call_callback (void) { @@ -94,13 +113,4 @@ int call_callback (void) else return default_callback (); } -/* { dg-final { scan-assembler "baz:" } } */ -/* { dg-final { scan-assembler "__acle_se_baz:" } } */ -/* { dg-final { scan-assembler "qux:" } } */ -/* { dg-final { scan-assembler "__acle_se_qux:" } } */ -/* { dg-final { scan-assembler-not "\tcmse_nonsecure_caller" } } */ -/* { dg-final { scan-rtl-dump "and.*reg.*const_int 1" expand } } */ -/* { dg-final { scan-assembler "bic" } } */ -/* { dg-final { scan-assembler "push\t\{r4, r5, r6" } } */ -/* { dg-final { scan-assembler "msr\tAPSR_nzcvq" } } */ /* { dg-final { scan-assembler-times "bl\\s+__gnu_cmse_nonsecure_call" 1 } } */ diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-16.c b/gcc/testsuite/gcc.target/arm/cmse/cmse-16.c new file mode 100644 index 00000000000..3fb0380afaa --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-16.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-options "-Os -mcmse" } */ + +#include <arm_cmse.h> + +int +foo (void) +{ + return cmse_nonsecure_caller (); +} + +int +main (void) +{ + /* Return success (0) if main is secure, ie if cmse_nonsecure_caller/foo + returns false (0). */ + return foo (); +} diff --git a/gcc/testsuite/gcc.target/arm/fpscr.c b/gcc/testsuite/gcc.target/arm/fpscr.c index 7b4d71d72d8..4c3eaf7fcf7 100644 --- a/gcc/testsuite/gcc.target/arm/fpscr.c +++ b/gcc/testsuite/gcc.target/arm/fpscr.c @@ -6,11 +6,14 @@ /* { dg-add-options arm_fp } */ void -test_fpscr () +test_fpscr (void) { - volatile unsigned int status = __builtin_arm_get_fpscr (); + unsigned status; + + __builtin_arm_set_fpscr (0); + status = __builtin_arm_get_fpscr (); __builtin_arm_set_fpscr (status); } /* { dg-final { scan-assembler "mrc\tp10, 7, r\[0-9\]+, cr1, cr0, 0" } } */ -/* { dg-final { scan-assembler "mcr\tp10, 7, r\[0-9\]+, cr1, cr0, 0" } } */ +/* { dg-final { scan-assembler-times "mcr\tp10, 7, r\[0-9\]+, cr1, cr0, 0" 2 } } */ diff --git a/gcc/testsuite/gcc.target/arm/pr82518.c b/gcc/testsuite/gcc.target/arm/pr82518.c new file mode 100644 index 00000000000..ce820b78a8d --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr82518.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-require-effective-target arm_neon_hw } */ +/* { dg-additional-options "-O3 -fno-inline -std=gnu99" } */ +/* { dg-add-options arm_neon } */ + +typedef struct { int x, y; } X; + +void f4(X *p, int n) +{ + for (int i = 0; i < n; i++) + { p[i].x = i; + p[i].y = i + 1; + } +} + +__attribute ((aligned (16))) X arr[100]; + +int main(void) +{ + volatile int fail = 0; + f4 (arr, 100); + for (int i = 0; i < 100; i++) + if (arr[i].y != i+1 || arr[i].x != i) + fail = 1; + if (fail) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/pr82989.c b/gcc/testsuite/gcc.target/arm/pr82989.c new file mode 100644 index 00000000000..8519c3fdc82 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr82989.c @@ -0,0 +1,33 @@ +/* PR target/82989. */ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_neon_ok } */ +/* { dg-skip-if "avoid conflicts with multilib options" { *-*-* } { "-mcpu=*" } { "-mcpu=cortex-a8" } } */ +/* { dg-skip-if "avoid conflicts with multilib options" { *-*-* } { "-mfpu=*" } { "-mfpu=neon" } } */ +/* { dg-skip-if "avoid conflicts with multilib options" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" } } */ +/* { dg-options "-O2 -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=hard" } */ +/* { dg-add-options arm_neon } */ + +typedef unsigned long long uint64_t; + +void f_shr_imm (uint64_t *a) +{ + *a += *a >> 32; +} + +void f_shr_reg (uint64_t *a, uint64_t b) +{ + *a += *a >> b; +} + +void f_shl_imm (uint64_t *a) +{ + *a += *a << 32; +} + +void f_shl_reg (uint64_t *a, uint64_t b) +{ + *a += *a << b; +} +/* { dg-final { scan-assembler-not "vshl*" } } */ +/* { dg-final { scan-assembler-not "vshr*" } } */ +/* { dg-final { scan-assembler-not "vmov*" } } */ diff --git a/gcc/testsuite/gcc.target/arm/pr84826.c b/gcc/testsuite/gcc.target/arm/pr84826.c new file mode 100644 index 00000000000..563ce51b76f --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr84826.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_thumb2_ok } */ +/* { dg-options "-Ofast -fstack-check" } */ + +void d (void *); + +void a () +{ + int b; + void bar (int c) + { + if (__builtin_expect (c, 0)) + ++b; + } + d (bar); +} diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpermd-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpermd-2.c index dbd4544c39e..b36a9c2da0a 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpermd-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpermd-2.c @@ -41,18 +41,14 @@ TEST (void) res3.a[i] = DEFAULT_VALUE; } -#if AVX512F_LEN == 512 res1.x = INTRINSIC (_permutexvar_epi32) (src1.x, src2.x); -#endif res2.x = INTRINSIC (_maskz_permutexvar_epi32) (mask, src1.x, src2.x); res3.x = INTRINSIC (_mask_permutexvar_epi32) (res3.x, mask, src1.x, src2.x); CALC (src1.a, src2.a, res_ref); -#if AVX512F_LEN == 512 if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref)) abort (); -#endif MASK_ZERO (i_d) (res_ref, mask, SIZE); if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref)) diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpermq-imm-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpermq-imm-2.c index 770d5623f5f..dd88cd46c0b 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpermq-imm-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpermq-imm-2.c @@ -40,18 +40,14 @@ TEST (void) res3.a[i] = DEFAULT_VALUE; } -#if AVX512F_LEN == 512 res1.x = INTRINSIC (_permutex_epi64) (src1.x, IMM_MASK); -#endif res2.x = INTRINSIC (_maskz_permutex_epi64) (mask, src1.x, IMM_MASK); res3.x = INTRINSIC (_mask_permutex_epi64) (res3.x, mask, src1.x, IMM_MASK); CALC (src1.a, IMM_MASK, res_ref); -#if AVX512F_LEN == 512 if (UNION_CHECK (AVX512F_LEN, i_q) (res1, res_ref)) abort (); -#endif MASK_ZERO (i_q) (res_ref, mask, SIZE); if (UNION_CHECK (AVX512F_LEN, i_q) (res2, res_ref)) diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vpermq-var-2.c b/gcc/testsuite/gcc.target/i386/avx512f-vpermq-var-2.c index c596b1d9c40..6c222888e88 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-vpermq-var-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-vpermq-var-2.c @@ -41,18 +41,14 @@ TEST (void) res3.a[i] = DEFAULT_VALUE; } -#if AVX512F_LEN == 512 res1.x = INTRINSIC (_permutexvar_epi64) (src1.x, src2.x); -#endif res2.x = INTRINSIC (_maskz_permutexvar_epi64) (mask, src1.x, src2.x); res3.x = INTRINSIC (_mask_permutexvar_epi64) (res3.x, mask, src1.x, src2.x); CALC (src1.a, src2.a, res_ref); -#if AVX512F_LEN == 512 if (UNION_CHECK (AVX512F_LEN, i_q) (res1, res_ref)) abort (); -#endif MASK_ZERO (i_q) (res_ref, mask, SIZE); if (UNION_CHECK (AVX512F_LEN, i_q) (res2, res_ref)) diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpermd-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpermd-1.c index fa1aaa390ab..069bb5d6c63 100644 --- a/gcc/testsuite/gcc.target/i386/avx512vl-vpermd-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpermd-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512vl -O2" } */ +/* { dg-final { scan-assembler-times "vpermd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpermd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpermd\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ @@ -11,6 +12,7 @@ volatile __mmask8 m; void extern avx512vl_test (void) { + x = _mm256_permutexvar_epi32 (x, x); x = _mm256_maskz_permutexvar_epi32 (m, x, x); x = _mm256_mask_permutexvar_epi32 (x, m, x, x); } diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpermq-imm-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpermq-imm-1.c index c74c8ce96c7..2340a6d9993 100644 --- a/gcc/testsuite/gcc.target/i386/avx512vl-vpermq-imm-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpermq-imm-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512vl -O2" } */ +/* { dg-final { scan-assembler-times "vpermq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpermq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpermq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ @@ -11,6 +12,7 @@ volatile __mmask8 m; void extern avx512vl_test (void) { + x = _mm256_permutex_epi64 (x, 13); x = _mm256_mask_permutex_epi64 (x, m, x, 13); x = _mm256_maskz_permutex_epi64 (m, x, 13); } diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpermq-var-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpermq-var-1.c index 43ccad3d6c1..69185e50f76 100644 --- a/gcc/testsuite/gcc.target/i386/avx512vl-vpermq-var-1.c +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpermq-var-1.c @@ -1,5 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-mavx512vl -O2" } */ +/* { dg-final { scan-assembler-times "vpermq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\](?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpermq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}\{z\}(?:\n|\[ \\t\]+#)" 1 } } */ /* { dg-final { scan-assembler-times "vpermq\[ \\t\]+\[^\{\n\]*%ymm\[0-9\]+\{%k\[1-7\]\}(?:\n|\[ \\t\]+#)" 1 } } */ @@ -11,6 +12,7 @@ volatile __mmask8 m; void extern avx512vl_test (void) { + x = _mm256_permutexvar_epi64 (x, x); x = _mm256_maskz_permutexvar_epi64 (m, x, x); x = _mm256_mask_permutexvar_epi64 (x, m, x, x); } diff --git a/gcc/testsuite/gcc.target/i386/pr85193.c b/gcc/testsuite/gcc.target/i386/pr85193.c new file mode 100644 index 00000000000..98e3dafc7ae --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr85193.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Wno-psabi -O2 -fno-tree-ccp -fno-tree-fre -mno-sse" } */ + +typedef unsigned char U __attribute__((vector_size(16))); +typedef unsigned int V __attribute__((vector_size(16))); +typedef unsigned long long W __attribute__((vector_size(16))); + +extern void bar(U, U); + +V v; + +void +foo(U f) +{ + f[0] = f[0] << (unsigned char)~v[0] | f[~((W)(U){0, 0, 0, 0, 0, 0, 0, 0, 5})[1] & 5] >> (-(unsigned char)~v[0] & 7); + bar(f, (U){}); +} diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c index d2df8b874e0..eee230ca2f6 100644 --- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c +++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c @@ -13,7 +13,7 @@ foo (void) /* { dg-final { scan-assembler "jmp\[ \t\]*__x86_return_thunk" } } */ /* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */ /* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */ -/* { dg-final { scan-assembler "__x86_indirect_thunk:" } } */ +/* { dg-final { scan-assembler "__x86_return_thunk:" } } */ /* { dg-final { scan-assembler "mov(?:l|q)\[ \t\]*_?bar" { target *-*-linux* } } } */ /* { dg-final { scan-assembler-times {\tpause} 2 } } */ /* { dg-final { scan-assembler-times {\tlfence} 2 } } */ diff --git a/gcc/testsuite/gcc.target/nvptx/pr85056.c b/gcc/testsuite/gcc.target/nvptx/pr85056.c new file mode 100644 index 00000000000..2471cb83b9e --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/pr85056.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-additional-sources "pr85056a.c" } */ + +extern void abort (); + +extern int a[]; + +int +main () +{ + int i, sum; + + sum = 0; + for (i = 0; i < 10; i++) + sum += a[i]; + + if (sum != 55) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/nvptx/pr85056a.c b/gcc/testsuite/gcc.target/nvptx/pr85056a.c new file mode 100644 index 00000000000..a45a5f2b07f --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/pr85056a.c @@ -0,0 +1,3 @@ +/* { dg-skip-if "" { *-*-* } } */ + +int a[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; diff --git a/gcc/testsuite/gcc.target/powerpc/crypto-builtin-1-runnable.c b/gcc/testsuite/gcc.target/powerpc/crypto-builtin-1-runnable.c new file mode 100644 index 00000000000..25c27bf9a37 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/crypto-builtin-1-runnable.c @@ -0,0 +1,109 @@ +/* { dg-do run { target { powerpc*-*-* && p8vector_hw } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O2 " } */ + +/* Make sure the test case compiled with -O2 generates the same expected + results. The expected results were generated with -O0. */ + +#include <altivec.h> +#define TRUE 1 +#define FALSE 0 + +#define DEBUG 1 + +#ifdef DEBUG +#include <stdio.h> +#endif + +void abort (void); + +typedef vector unsigned long long crypto_t; +typedef vector unsigned long long v2di_t; +typedef vector unsigned int v4si_t; +typedef vector unsigned short v8hi_t; +typedef vector unsigned char v16qi_t; + +v16qi_t crypto6a (v16qi_t a, v16qi_t b, v16qi_t c) +{ + return __builtin_crypto_vpermxor (a, b, c); +} + +v8hi_t crypto6b (v8hi_t a, v8hi_t b, v8hi_t c) +{ + return __builtin_crypto_vpermxor (a, b, c); +} + +v4si_t crypto6c (v4si_t a, v4si_t b, v4si_t c) +{ + return __builtin_crypto_vpermxor (a, b, c); +} + +v2di_t crypto6d (v2di_t a, v2di_t b, v2di_t c) +{ + return __builtin_crypto_vpermxor (a, b, c); +} + +int main() +{ + int i; + v16qi_t expected_v16qi, result_v16qi; + v8hi_t expected_v8hi, result_v8hi; + v4si_t expected_v4si, result_v4si; + v2di_t expected_v2di, result_v2di; + v16qi_t v16qi_arg_a, v16qi_arg_b, v16qi_arg_c; + v8hi_t v8hi_arg_a, v8hi_arg_b, v8hi_arg_c; + v4si_t v4si_arg_a, v4si_arg_b, v4si_arg_c; + v2di_t v2di_arg_a, v2di_arg_b, v2di_arg_c; + + v16qi_arg_a = (vector unsigned char){ 7, 6, 5, 4, 3, 2, 1, 0, + 1, 2, 3, 4, 5, 6, 7, 8 }; + v16qi_arg_b = (vector unsigned char){ 1, 2, 3, 4, 5, 6, 7, 8, + 7, 6, 5, 4, 3, 2, 1, 0 }; + v16qi_arg_c = (vector unsigned char){ 7, 2, 5, 4, 3, 6, 1, 8, + 1, 6, 3, 4, 5, 2, 7, 0 }; + expected_v16qi = (vector unsigned char){ 15, 10, 13, 12, 11, 14, 9, 0, + 9, 14, 11, 12, 13, 10, 15, 8 }; + + result_v16qi = crypto6a (v16qi_arg_a, v16qi_arg_b, v16qi_arg_c); + + for (i = 0; i < 16; i++) + if (expected_v16qi[i] != result_v16qi[i]) + printf("crypto6a: result_v16qi[%d] = %d, expected = %d\n", + i, result_v16qi[i], expected_v16qi[i]); + + v8hi_arg_a = (vector unsigned short int){ 7, 6, 5, 4, 3, 2, 1, 0}; + v8hi_arg_b = (vector unsigned short int){ 1, 2, 3, 4, 5, 6, 7, 8}; + v8hi_arg_c = (vector unsigned short int){ 7, 2, 5, 4, 3, 6, 1, 8}; + expected_v8hi = (vector unsigned short int){ 5, 0, 6, 0, 7, 0, 8}; + + result_v8hi = crypto6b (v8hi_arg_a, v8hi_arg_b, v8hi_arg_c); + + for (i = 0; i < 8; i++) + if (expected_v8hi[i] != result_v8hi[i]) + printf("crypto6a: result_v8hi[%d] = %d, expected = %d\n", + i, result_v8hi[i], expected_v8hi[i]); + + v4si_arg_a = (vector unsigned int){ 7, 6, 5, 4}; + v4si_arg_b = (vector unsigned int){ 15, 6, 7, 8}; + v4si_arg_c = (vector unsigned int){ 7, 14, 3, 6}; + expected_v4si = (vector unsigned int){ 7, 0, 8, 0}; + + result_v4si = crypto6c (v4si_arg_a, v4si_arg_b, v4si_arg_c); + + for (i = 0; i < 4; i++) + if (expected_v4si[i] != result_v4si[i]) + printf("crypto6a: result_v4si[%d] = %d, expected = %d\n", + i, result_v4si[i], expected_v4si[i]); + + v2di_arg_a = (vector unsigned long long int){ 7, 6, }; + v2di_arg_b = (vector unsigned long long int){ 15, 6, }; + v2di_arg_c = (vector unsigned long long int){ 7, 14}; + expected_v2di = (vector unsigned long long int){ 6, 0}; + + result_v2di = crypto6d (v2di_arg_a, v2di_arg_b, v2di_arg_c); + + for (i = 0; i < 2; i++) + if (expected_v2di[i] != result_v2di[i]) + printf("crypto6a: result_v2di[%d] = %d, expected = %d\n", + i, result_v2di[i], expected_v2di[i]); +} diff --git a/gcc/testsuite/gcc.target/powerpc/extend-divide-1.c b/gcc/testsuite/gcc.target/powerpc/extend-divide-1.c index 365dead9fac..aaf9b40fc24 100644 --- a/gcc/testsuite/gcc.target/powerpc/extend-divide-1.c +++ b/gcc/testsuite/gcc.target/powerpc/extend-divide-1.c @@ -5,9 +5,7 @@ /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */ /* { dg-options "-mcpu=power7 -O2" } */ /* { dg-final { scan-assembler-times "divwe " 1 } } */ -/* { dg-final { scan-assembler-times "divweo " 1 } } */ /* { dg-final { scan-assembler-times "divweu " 1 } } */ -/* { dg-final { scan-assembler-times "divweuo " 1 } } */ /* { dg-final { scan-assembler-not "bl __builtin" } } */ int @@ -16,20 +14,8 @@ div_we (int a, int b) return __builtin_divwe (a, b); } -int -div_weo (int a, int b) -{ - return __builtin_divweo (a, b); -} - unsigned int div_weu (unsigned int a, unsigned int b) { return __builtin_divweu (a, b); } - -unsigned int -div_weuo (unsigned int a, unsigned int b) -{ - return __builtin_divweuo (a, b); -} diff --git a/gcc/testsuite/gcc.target/powerpc/extend-divide-2.c b/gcc/testsuite/gcc.target/powerpc/extend-divide-2.c index 829cd40cae8..92e494aa136 100644 --- a/gcc/testsuite/gcc.target/powerpc/extend-divide-2.c +++ b/gcc/testsuite/gcc.target/powerpc/extend-divide-2.c @@ -5,9 +5,7 @@ /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */ /* { dg-options "-mcpu=power7 -O2" } */ /* { dg-final { scan-assembler-times "divde " 1 } } */ -/* { dg-final { scan-assembler-times "divdeo " 1 } } */ /* { dg-final { scan-assembler-times "divdeu " 1 } } */ -/* { dg-final { scan-assembler-times "divdeuo " 1 } } */ /* { dg-final { scan-assembler-not "bl __builtin" } } */ long @@ -16,20 +14,8 @@ div_de (long a, long b) return __builtin_divde (a, b); } -long -div_deo (long a, long b) -{ - return __builtin_divdeo (a, b); -} - unsigned long div_deu (unsigned long a, unsigned long b) { return __builtin_divdeu (a, b); } - -unsigned long -div_deuo (unsigned long a, unsigned long b) -{ - return __builtin_divdeuo (a, b); -} diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-sdata-2.c b/gcc/testsuite/gcc.target/powerpc/ppc-sdata-2.c index 570c81f7e33..ee77456ca4f 100644 --- a/gcc/testsuite/gcc.target/powerpc/ppc-sdata-2.c +++ b/gcc/testsuite/gcc.target/powerpc/ppc-sdata-2.c @@ -5,6 +5,7 @@ /* { dg-final { scan-assembler-not "\\.section\[ \t\]\\.sdata2," } } */ /* { dg-final { scan-assembler "sdat@sdarel\\(13\\)" } } */ /* { dg-final { scan-assembler "sdat2@sdarel\\(13\\)" } } */ +/* { dg-skip-if "" { *-*-* } { "-mno-readonly-in-sdata" } { "" } } */ int sdat = 2; diff --git a/gcc/testsuite/gcc.target/powerpc/pr79799-2.c b/gcc/testsuite/gcc.target/powerpc/pr79799-2.c index 793e3b9b66c..b1a0b09cbf7 100644 --- a/gcc/testsuite/gcc.target/powerpc/pr79799-2.c +++ b/gcc/testsuite/gcc.target/powerpc/pr79799-2.c @@ -8,7 +8,7 @@ /* Optimize x = vec_insert (vec_extract (v2, N), v1, M) for SFmode if N is the default scalar position. */ -#if __ORDER_LITTLE_ENDIAN__ +#if __LITTLE_ENDIAN__ #define ELE 2 #else #define ELE 1 diff --git a/gcc/testsuite/gcc.target/powerpc/pr83660.C b/gcc/testsuite/gcc.target/powerpc/pr83660.C new file mode 100644 index 00000000000..60adcdacb4b --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr83660.C @@ -0,0 +1,14 @@ +/* PR target/83660 */ +/* { dg-do compile } */ +/* { dg-options "-mcpu=power7" } */ + +#include <altivec.h> + +typedef __vector unsigned int uvec32_t __attribute__((__aligned__(16))); + +unsigned get_word(uvec32_t v) +{ + return ({const unsigned _B1 = 32; + vec_extract((uvec32_t)v, 2);}); +} + diff --git a/gcc/testsuite/gcc.target/powerpc/pr83969.c b/gcc/testsuite/gcc.target/powerpc/pr83969.c new file mode 100644 index 00000000000..fe61594be16 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr83969.c @@ -0,0 +1,14 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=G5" } } */ +/* { dg-options "-O1 -mcpu=G5 -fno-split-wide-types -ftree-loop-vectorize" } */ + +long long int +n7 (int po, long long int r4) +{ + while (po < 1) + { + r4 |= 1; + ++po; + } + return r4; +} diff --git a/gcc/testsuite/gcc.target/powerpc/pr84878.c b/gcc/testsuite/gcc.target/powerpc/pr84878.c new file mode 100644 index 00000000000..f96d3803d06 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr84878.c @@ -0,0 +1,18 @@ +/* PR rtl-optimization/84878 */ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-O2 -maltivec -mno-vsx -fmodulo-sched -ftree-vectorize -funroll-loops -fassociative-math -fno-signed-zeros -fno-trapping-math" } */ + +int ek; +float zu; + +int +k5 (int ks) +{ + while (ek < 1) + { + ks += (int)(0x1000000 + zu + !ek); + ++ek; + } + return ks; +} diff --git a/gcc/testsuite/gcc.target/s390/nobp-no-dwarf2-cfi.c b/gcc/testsuite/gcc.target/s390/nobp-no-dwarf2-cfi.c new file mode 100644 index 00000000000..75e32a1c7c0 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/nobp-no-dwarf2-cfi.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-O3 -march=z900 --save-temps -mfunction-return-reg=thunk -mindirect-branch-table -fno-dwarf2-cfi-asm" } */ + +/* Make sure that we do not emit .cfi directives when -fno-dwarf2-cfi-asm is being used. */ + +int +main () +{ + return 0; +} + +/* 1 x main +/* { dg-final { scan-assembler-times "jg\t__s390_indirect_jump" 1 } } */ +/* { dg-final { scan-assembler "ex\t" } } */ + +/* { dg-final { scan-assembler-not "section\t.s390_indirect_jump" } } */ +/* { dg-final { scan-assembler-not "section\t.s390_indirect_call" } } */ +/* { dg-final { scan-assembler "section\t.s390_return_reg" } } */ +/* { dg-final { scan-assembler-not "section\t.s390_return_mem" } } */ diff --git a/gcc/testsuite/gfortran.dg/array_constructor_52.f90 b/gcc/testsuite/gfortran.dg/array_constructor_52.f90 new file mode 100644 index 00000000000..63581acf989 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/array_constructor_52.f90 @@ -0,0 +1,11 @@ +! { dg-do run } +! PR 84931 - long array constructors with type conversion were not +! handled correctly. +program test + implicit none + integer, parameter :: n = 2**16 + real, dimension(n) :: y + integer :: i + y = (/ (1, i=1, n) /) + if (y(2) /= 1) stop 1 +end program test diff --git a/gcc/testsuite/gfortran.dg/goacc/pr84963.f90 b/gcc/testsuite/gfortran.dg/goacc/pr84963.f90 new file mode 100644 index 00000000000..4548082bee3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr84963.f90 @@ -0,0 +1,7 @@ +! PR ipa/84963 +! { dg-options "-O2" } + +program p + print *, sin([1.0, 2.0]) + print *, cos([1.0, 2.0]) +end diff --git a/gcc/testsuite/gfortran.dg/interface_41.f90 b/gcc/testsuite/gfortran.dg/interface_41.f90 new file mode 100644 index 00000000000..b5ea8af189d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/interface_41.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! PR fortran/85001 +! Contributed by Gerhard Steinmetz. +program p + type t + end type + call s +contains + real function f(x) + class(t) :: x + dimension :: x(:) + f = 1.0 + end + subroutine s + type(t) :: x(2) + real :: z + z = f(x) ! { dg-error "Rank mismatch in argument" } + end +end diff --git a/gcc/testsuite/gfortran.dg/internal_references_1.f90 b/gcc/testsuite/gfortran.dg/internal_references_1.f90 index 12041df9d70..2434e28d5e3 100644 --- a/gcc/testsuite/gfortran.dg/internal_references_1.f90 +++ b/gcc/testsuite/gfortran.dg/internal_references_1.f90 @@ -11,7 +11,7 @@ module m implicit none contains - subroutine p (i) ! { dg-error "is already defined" } + subroutine p (i) ! { dg-error "(1)" } integer :: i end subroutine @@ -22,14 +22,15 @@ end module ! ! PR25124 - would happily ignore the declaration of foo in the main program. program test -real :: foo, x ! { dg-error "explicit interface and must not have attributes declared" } +real :: foo, x x = bar () ! This is OK because it is a regular reference. x = foo () contains - function foo () ! { dg-error "explicit interface and must not have attributes declared" } + function foo () ! { dg-error "explicit interface from a previous" } foo = 1.0 end function foo function bar () bar = 1.0 end function bar end program test + diff --git a/gcc/testsuite/gfortran.dg/matmul_rank_1.f90 b/gcc/testsuite/gfortran.dg/matmul_rank_1.f90 new file mode 100644 index 00000000000..f111b26018f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/matmul_rank_1.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! { dg-additional-options "-ffrontend-optimize" } +! PR 85044 - used to die on allocating a negative amount of memory. +! Test case by Gerhard Steinmetz. +program p + real :: a(3,3) = 1.0 + real :: b(33) + b = matmul(a, a) ! { dg-error "Incompatible ranks" } +end diff --git a/gcc/testsuite/gfortran.dg/pr65453.f90 b/gcc/testsuite/gfortran.dg/pr65453.f90 new file mode 100644 index 00000000000..8d30116b79d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr65453.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/65453 +! Contributed by Tobias Burnus <burnus at gcc.gnu.org> +procedure() :: foo ! { dg-error "(1)" } + contains + subroutine foo() ! { dg-error "clashes with procedure" } + end +end diff --git a/gcc/testsuite/gfortran.dg/pr77414.f90 b/gcc/testsuite/gfortran.dg/pr77414.f90 new file mode 100644 index 00000000000..222c1a31542 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77414.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/77414 +subroutine a(x) ! { dg-error "(1)" } + character(*) :: x + contains + subroutine a(x) ! { dg-error " is already defined at" } + character(*) :: x + end subroutine a +end subroutine a diff --git a/gcc/testsuite/gfortran.dg/pr78741.f90 b/gcc/testsuite/gfortran.dg/pr78741.f90 new file mode 100644 index 00000000000..6eb85789f94 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr78741.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! PR fortran/78741 +! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran at t-online.de> +subroutine s(n, x) + integer :: n + character(n) :: x + character, pointer :: z(:) + x = 'a' + return +entry g(n, x) ! { dg-error "is already defined" } + x = 'b' +contains + subroutine g ! { dg-error "(1)" } + z(1) = x(1:1) + end +end diff --git a/gcc/testsuite/gfortran.dg/pr85520.f90 b/gcc/testsuite/gfortran.dg/pr85520.f90 new file mode 100644 index 00000000000..3e66a9020f8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr85520.f90 @@ -0,0 +1,7 @@ +! { dg-do run } +! PR fortran/85520 +! Original code from Gerhard Steinmetz <gscfq at t-online dot de> +program p + character(-huge(1)) :: c = ' ' + if (len(c) /= 0) stop 1 +end diff --git a/gcc/testsuite/go.dg/pr85436.go b/gcc/testsuite/go.dg/pr85436.go new file mode 100644 index 00000000000..225c2734561 --- /dev/null +++ b/gcc/testsuite/go.dg/pr85436.go @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -mcpu=power9" { target { powerpc*-*-* } } } */ + +package main +import ( + "go/ast" + "go/parser" + "go/token" +) +type testFuncs struct { } +func (t *testFuncs) load(filename, pkg string, doImport, seen *bool) { + var testFileSet = token.NewFileSet() + f, err := parser.ParseFile(testFileSet, filename, nil, parser.ParseComments) + if err != nil { } + for _, d := range f.Decls { + n, ok := d.(*ast.FuncDecl) + if !ok { } + ptr := n.Type.Params.List[0].Type.(*ast.StarExpr) + if sel := ptr.X.(*ast.SelectorExpr); sel.Sel.Name == "M" { } + } +} diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 25c8b603f8a..e2a67c622bc 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -6022,7 +6022,8 @@ proc check_effective_target_vect_load_lanes { } { verbose "check_effective_target_vect_load_lanes: using cached result" 2 } else { set et_vect_load_lanes 0 - if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) + # We don't support load_lanes correctly on big-endian arm. + if { ([istarget arm-*-*] && [check_effective_target_arm_neon_ok]) || [istarget aarch64*-*-*] } { set et_vect_load_lanes 1 } diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c index 01c25d43e0d..1a0ac316c53 100644 --- a/gcc/tree-ssa-tail-merge.c +++ b/gcc/tree-ssa-tail-merge.c @@ -1454,7 +1454,8 @@ find_clusters_1 (same_succ *same_succ) /* TODO: handle blocks with phi-nodes. We'll have to find corresponding phi-nodes in bb1 and bb2, with the same alternatives for the same preds. */ - if (bb_has_non_vop_phi (bb1) || bb_has_eh_pred (bb1)) + if (bb_has_non_vop_phi (bb1) || bb_has_eh_pred (bb1) + || bb_has_abnormal_pred (bb1)) continue; nr_comparisons = 0; @@ -1462,7 +1463,8 @@ find_clusters_1 (same_succ *same_succ) { bb2 = BASIC_BLOCK_FOR_FN (cfun, j); - if (bb_has_non_vop_phi (bb2) || bb_has_eh_pred (bb2)) + if (bb_has_non_vop_phi (bb2) || bb_has_eh_pred (bb2) + || bb_has_abnormal_pred (bb2)) continue; if (BB_CLUSTER (bb1) != NULL && BB_CLUSTER (bb1) == BB_CLUSTER (bb2)) diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 7ad7e9f1c54..70e5bc3baa2 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,21 @@ +2018-04-02 H.J. Lu <hongjiu.lu@intel.com> + + Backport from mainline + 2018-03-29 H.J. Lu <hongjiu.lu@intel.com> + + PR target/85100 + * config/i386/cpuinfo.c (XCR_XFEATURE_ENABLED_MASK): New. + (XSTATE_FP): Likewise. + (XSTATE_SSE): Likewise. + (XSTATE_YMM): Likewise. + (XSTATE_OPMASK): Likewise. + (XSTATE_ZMM): Likewise. + (XSTATE_HI_ZMM): Likewise. + (XCR_AVX_ENABLED_MASK): Likewise. + (XCR_AVX512F_ENABLED_MASK): Likewise. + (get_available_features): Enable AVX and AVX512 features only + if their states are supported by OSXSAVE. + 2018-03-11 John David Anglin <danglin@gcc.gnu.org> Backport from mainline diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c index a1dc011525f..29a1f80b1ad 100644 --- a/libgcc/config/i386/cpuinfo.c +++ b/libgcc/config/i386/cpuinfo.c @@ -220,6 +220,40 @@ get_available_features (unsigned int ecx, unsigned int edx, unsigned int features = 0; + /* Get XCR_XFEATURE_ENABLED_MASK register with xgetbv. */ +#define XCR_XFEATURE_ENABLED_MASK 0x0 +#define XSTATE_FP 0x1 +#define XSTATE_SSE 0x2 +#define XSTATE_YMM 0x4 +#define XSTATE_OPMASK 0x20 +#define XSTATE_ZMM 0x40 +#define XSTATE_HI_ZMM 0x80 + +#define XCR_AVX_ENABLED_MASK \ + (XSTATE_SSE | XSTATE_YMM) +#define XCR_AVX512F_ENABLED_MASK \ + (XSTATE_SSE | XSTATE_YMM | XSTATE_OPMASK | XSTATE_ZMM | XSTATE_HI_ZMM) + + /* Check if AVX and AVX512 are usable. */ + int avx_usable = 0; + int avx512_usable = 0; + if ((ecx & bit_OSXSAVE)) + { + /* Check if XMM, YMM, OPMASK, upper 256 bits of ZMM0-ZMM15 and + ZMM16-ZMM31 states are supported by OSXSAVE. */ + unsigned int xcrlow; + unsigned int xcrhigh; + asm (".byte 0x0f, 0x01, 0xd0" + : "=a" (xcrlow), "=d" (xcrhigh) + : "c" (XCR_XFEATURE_ENABLED_MASK)); + if ((xcrlow & XCR_AVX_ENABLED_MASK) == XCR_AVX_ENABLED_MASK) + { + avx_usable = 1; + avx512_usable = ((xcrlow & XCR_AVX512F_ENABLED_MASK) + == XCR_AVX512F_ENABLED_MASK); + } + } + if (edx & bit_CMOV) features |= (1 << FEATURE_CMOV); if (edx & bit_MMX) @@ -242,10 +276,13 @@ get_available_features (unsigned int ecx, unsigned int edx, features |= (1 << FEATURE_SSE4_1); if (ecx & bit_SSE4_2) features |= (1 << FEATURE_SSE4_2); - if (ecx & bit_AVX) - features |= (1 << FEATURE_AVX); - if (ecx & bit_FMA) - features |= (1 << FEATURE_FMA); + if (avx_usable) + { + if (ecx & bit_AVX) + features |= (1 << FEATURE_AVX); + if (ecx & bit_FMA) + features |= (1 << FEATURE_FMA); + } /* Get Advanced Features at level 7 (eax = 7, ecx = 0). */ if (max_cpuid_level >= 7) @@ -253,34 +290,40 @@ get_available_features (unsigned int ecx, unsigned int edx, __cpuid_count (7, 0, eax, ebx, ecx, edx); if (ebx & bit_BMI) features |= (1 << FEATURE_BMI); - if (ebx & bit_AVX2) - features |= (1 << FEATURE_AVX2); + if (avx_usable) + { + if (ebx & bit_AVX2) + features |= (1 << FEATURE_AVX2); + } if (ebx & bit_BMI2) features |= (1 << FEATURE_BMI2); - if (ebx & bit_AVX512F) - features |= (1 << FEATURE_AVX512F); - if (ebx & bit_AVX512VL) - features |= (1 << FEATURE_AVX512VL); - if (ebx & bit_AVX512BW) - features |= (1 << FEATURE_AVX512BW); - if (ebx & bit_AVX512DQ) - features |= (1 << FEATURE_AVX512DQ); - if (ebx & bit_AVX512CD) - features |= (1 << FEATURE_AVX512CD); - if (ebx & bit_AVX512PF) - features |= (1 << FEATURE_AVX512PF); - if (ebx & bit_AVX512ER) - features |= (1 << FEATURE_AVX512ER); - if (ebx & bit_AVX512IFMA) - features |= (1 << FEATURE_AVX512IFMA); - if (ecx & bit_AVX512VBMI) - features |= (1 << FEATURE_AVX512VBMI); - if (ecx & bit_AVX512VPOPCNTDQ) - features |= (1 << FEATURE_AVX512VPOPCNTDQ); - if (edx & bit_AVX5124VNNIW) - features |= (1 << FEATURE_AVX5124VNNIW); - if (edx & bit_AVX5124FMAPS) - features |= (1 << FEATURE_AVX5124FMAPS); + if (avx512_usable) + { + if (ebx & bit_AVX512F) + features |= (1 << FEATURE_AVX512F); + if (ebx & bit_AVX512VL) + features |= (1 << FEATURE_AVX512VL); + if (ebx & bit_AVX512BW) + features |= (1 << FEATURE_AVX512BW); + if (ebx & bit_AVX512DQ) + features |= (1 << FEATURE_AVX512DQ); + if (ebx & bit_AVX512CD) + features |= (1 << FEATURE_AVX512CD); + if (ebx & bit_AVX512PF) + features |= (1 << FEATURE_AVX512PF); + if (ebx & bit_AVX512ER) + features |= (1 << FEATURE_AVX512ER); + if (ebx & bit_AVX512IFMA) + features |= (1 << FEATURE_AVX512IFMA); + if (ecx & bit_AVX512VBMI) + features |= (1 << FEATURE_AVX512VBMI); + if (ecx & bit_AVX512VPOPCNTDQ) + features |= (1 << FEATURE_AVX512VPOPCNTDQ); + if (edx & bit_AVX5124VNNIW) + features |= (1 << FEATURE_AVX5124VNNIW); + if (edx & bit_AVX5124FMAPS) + features |= (1 << FEATURE_AVX5124FMAPS); + } } /* Check cpuid level of extended features. */ @@ -292,10 +335,13 @@ get_available_features (unsigned int ecx, unsigned int edx, if (ecx & bit_SSE4a) features |= (1 << FEATURE_SSE4_A); - if (ecx & bit_FMA4) - features |= (1 << FEATURE_FMA4); - if (ecx & bit_XOP) - features |= (1 << FEATURE_XOP); + if (avx_usable) + { + if (ecx & bit_FMA4) + features |= (1 << FEATURE_FMA4); + if (ecx & bit_XOP) + features |= (1 << FEATURE_XOP); + } } __cpu_model.__cpu_features[0] = features; diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index 2c213f18e0c..07096babbda 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,3 +1,12 @@ +2018-04-24 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2018-04-18 Bill Seurer <seurer@linux.vnet.ibm.com> + + PR sanitizer/85389 + * asan/asan_allocator.h (kAllocatorSpace): For __powerpc64__ change + from 0xa0000000000ULL to ~(uptr)0. + 2018-01-25 Release Manager * GCC 7.3.0 released. diff --git a/libsanitizer/asan/asan_allocator.h b/libsanitizer/asan/asan_allocator.h index 7eeddadd547..dacfddd5ddf 100644 --- a/libsanitizer/asan/asan_allocator.h +++ b/libsanitizer/asan/asan_allocator.h @@ -115,7 +115,7 @@ struct AsanMapUnmapCallback { #if SANITIZER_CAN_USE_ALLOCATOR64 # if defined(__powerpc64__) -const uptr kAllocatorSpace = 0xa0000000000ULL; +const uptr kAllocatorSpace = ~(uptr)0; const uptr kAllocatorSize = 0x20000000000ULL; // 2T. typedef DefaultSizeClassMap SizeClassMap; # elif defined(__aarch64__) && SANITIZER_ANDROID diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 41ab6772495..5f76ed34181 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,68 @@ +2018-04-18 Jonathan Wakely <jwakely@redhat.com> + Jakub Jelinek <jakub@redhat.com> + + PR libstdc++/85442 + * src/c++11/Makefile.am: Don't generate debuginfo again for + cxx11-ios_failure-lt.s and cxx11-ios_failure.s files. + * src/c++11/Makefile.in: Regenerate. + +2018-04-13 Jonathan Wakely <jwakely@redhat.com> + + * src/c++11/Makefile.am: Fix sed command. + * src/c++11/Makefile.in: Regenerate. + + * src/c++11/Makefile.am: Rewrite sed rule to be less fragile and to + handle mangled names starting with double underscores on darwin. + * src/c++11/Makefile.in: Regenerate. + +2018-04-12 Jonathan Wakely <jwakely@redhat.com> + + * src/c++11/Makefile.am: Fix comment. + * src/c++11/Makefile.in: Regenerate. + * src/c++11/cxx11-ios_failure.cc: Fix comment. + * src/c++98/ios_failure.cc: Likewise. + + Backport from mainline + 2018-04-10 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/85222 + * src/c++11/Makefile.am [ENABLE_DUAL_ABI]: Add special rules for + cxx11-ios_failure.cc to rewrite type info for __ios_failure. + * src/c++11/Makefile.in: Regenerate. + * src/c++11/cxx11-ios_failure.cc (__ios_failure, __iosfail_type_info): + New types. + [_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure): Define here. + * src/c++11/ios.cc (__throw_ios_failure): Remove definition. + (_GLIBCXX_USE_CXX11_ABI): Don't define here. + * src/c++98/ios_failure.cc (__construct_ios_failure) + (__destroy_ios_failure, is_ios_failure_handler): New functions. + [!_GLIBCXX_USE_DUAL_ABI] (__throw_ios_failure): Define here. + * testsuite/27_io/ios_base/failure/dual_abi.cc: New. + * testsuite/27_io/basic_ios/copyfmt/char/1.cc: Revert changes to + handler types, to always catch std::ios_base::failure. + * testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise. + * testsuite/27_io/basic_istream/extractors_arithmetic/char/ + exceptions_failbit.cc: Likewise. + * testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/ + exceptions_failbit.cc: Likewise. + * testsuite/27_io/basic_istream/extractors_other/char/ + exceptions_null.cc: Likewise. + * testsuite/27_io/basic_istream/extractors_other/wchar_t/ + exceptions_null.cc: Likewise. + * testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise. + * testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise. + * testsuite/27_io/basic_ostream/inserters_other/char/ + exceptions_null.cc: Likewise. + * testsuite/27_io/basic_ostream/inserters_other/wchar_t/ + exceptions_null.cc: Likewise. + * testsuite/27_io/ios_base/storage/2.cc: Likewise. + +2018-03-22 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> + + PR libstdc++/77691 + * testsuite/experimental/memory_resource/resource_adaptor.cc: + xfail execution on 32-bit Solaris/x86. + 2018-03-13 Jonathan Wakely <jwakely@redhat.com> Backport from mainline diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am index cf73d4d5c4c..776a4ba36e3 100644 --- a/libstdc++-v3/src/c++11/Makefile.am +++ b/libstdc++-v3/src/c++11/Makefile.am @@ -126,6 +126,26 @@ hashtable_c++0x.lo: hashtable_c++0x.cc hashtable_c++0x.o: hashtable_c++0x.cc $(CXXCOMPILE) -fimplicit-templates -c $< +if ENABLE_DUAL_ABI +# Rewrite the type info for __ios_failure. +rewrite_ios_failure_typeinfo = sed -e '/^_*_ZTISt13__ios_failure:/,/_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' + +cxx11-ios_failure-lt.s: cxx11-ios_failure.cc + $(LTCXXCOMPILE) -S $< -o tmp-cxx11-ios_failure-lt.s + -test -f tmp-cxx11-ios_failure-lt.o && mv -f tmp-cxx11-ios_failure-lt.o tmp-cxx11-ios_failure-lt.s + $(rewrite_ios_failure_typeinfo) tmp-$@ > $@ + -rm -f tmp-$@ +cxx11-ios_failure.s: cxx11-ios_failure.cc + $(CXXCOMPILE) -S $< -o tmp-$@ + $(rewrite_ios_failure_typeinfo) tmp-$@ > $@ + -rm -f tmp-$@ + +cxx11-ios_failure.lo: cxx11-ios_failure-lt.s + $(LTCXXCOMPILE) -g0 -c $< -o $@ +cxx11-ios_failure.o: cxx11-ios_failure.s + $(CXXCOMPILE) -g0 -c $< +endif + # AM_CXXFLAGS needs to be in each subdirectory so that it can be # modified in a per-library or per-sub-library way. Need to manually # set this option because CONFIG_CXXFLAGS has to be after diff --git a/libstdc++-v3/src/c++11/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in index 295d915b436..6d78fd81f50 100644 --- a/libstdc++-v3/src/c++11/Makefile.in +++ b/libstdc++-v3/src/c++11/Makefile.in @@ -433,6 +433,9 @@ sources = \ libc__11convenience_la_SOURCES = $(sources) $(inst_sources) +# Rewrite the type info for __ios_failure. +@ENABLE_DUAL_ABI_TRUE@rewrite_ios_failure_typeinfo = sed -e '/^_*_ZTISt13__ios_failure:/,/_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' + # AM_CXXFLAGS needs to be in each subdirectory so that it can be # modified in a per-library or per-sub-library way. Need to manually # set this option because CONFIG_CXXFLAGS has to be after @@ -748,6 +751,21 @@ hashtable_c++0x.lo: hashtable_c++0x.cc hashtable_c++0x.o: hashtable_c++0x.cc $(CXXCOMPILE) -fimplicit-templates -c $< +@ENABLE_DUAL_ABI_TRUE@cxx11-ios_failure-lt.s: cxx11-ios_failure.cc +@ENABLE_DUAL_ABI_TRUE@ $(LTCXXCOMPILE) -S $< -o tmp-cxx11-ios_failure-lt.s +@ENABLE_DUAL_ABI_TRUE@ -test -f tmp-cxx11-ios_failure-lt.o && mv -f tmp-cxx11-ios_failure-lt.o tmp-cxx11-ios_failure-lt.s +@ENABLE_DUAL_ABI_TRUE@ $(rewrite_ios_failure_typeinfo) tmp-$@ > $@ +@ENABLE_DUAL_ABI_TRUE@ -rm -f tmp-$@ +@ENABLE_DUAL_ABI_TRUE@cxx11-ios_failure.s: cxx11-ios_failure.cc +@ENABLE_DUAL_ABI_TRUE@ $(CXXCOMPILE) -S $< -o tmp-$@ +@ENABLE_DUAL_ABI_TRUE@ $(rewrite_ios_failure_typeinfo) tmp-$@ > $@ +@ENABLE_DUAL_ABI_TRUE@ -rm -f tmp-$@ + +@ENABLE_DUAL_ABI_TRUE@cxx11-ios_failure.lo: cxx11-ios_failure-lt.s +@ENABLE_DUAL_ABI_TRUE@ $(LTCXXCOMPILE) -g0 -c $< -o $@ +@ENABLE_DUAL_ABI_TRUE@cxx11-ios_failure.o: cxx11-ios_failure.s +@ENABLE_DUAL_ABI_TRUE@ $(CXXCOMPILE) -g0 -c $< + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc index 2f60408782e..8833ba8c91a 100644 --- a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc +++ b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc @@ -28,6 +28,15 @@ #define _GLIBCXX_USE_CXX11_ABI 1 #include <ios> +#include <bits/functexcept.h> +#include <cxxabi.h> + +#ifdef _GLIBCXX_USE_NLS +# include <libintl.h> +# define _(msgid) gettext (msgid) +#else +# define _(msgid) (msgid) +#endif #if ! _GLIBCXX_USE_DUAL_ABI # error This file should not be compiled for this configuration. @@ -91,5 +100,66 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ios_base::failure::what() const throw() { return runtime_error::what(); } +#if __cpp_rtti + // These functions are defined in src/c++98/ios_failure.cc + extern void __construct_ios_failure(void*, const char*); + extern void __destroy_ios_failure(void*); + extern bool __is_ios_failure_handler(const __cxxabiv1::__class_type_info*); + + // The type thrown to report errors during stream buffer operations. + // In addition to the ios::failure[abi:cxx11] base class it also has a + // member of the gcc4-compatible ios::failure type (in an opaque buffer). + struct __ios_failure : std::ios::failure + { + __ios_failure(const char* s) : failure(s) + { __construct_ios_failure(buf, runtime_error::what()); } + + ~__ios_failure() + { __destroy_ios_failure(buf); } + + // Use std::runtime_error as a proxy for the gcc4-compatible ios::failure + // (which can't be declared here because _GLIBCXX_USE_CXX11_ABI == 1). + // There are assertions in src/c++98/ios_failure.cc to ensure the size + // and alignment assumptions are valid. + alignas(runtime_error) unsigned char buf[sizeof(runtime_error)]; + }; + + // Custom type info for __ios_failure. + class __iosfail_type_info : __cxxabiv1::__si_class_type_info + { + ~__iosfail_type_info(); + + bool + __do_upcast (const __class_type_info *dst_type, + void **obj_ptr) const override; + }; + + __iosfail_type_info::~__iosfail_type_info() = default; + + // This function gets called to see if an exception of type + // __ios_failure can be upcast to the type in a catch handler. + bool + __iosfail_type_info::__do_upcast(const __class_type_info *dst_type, + void **obj_ptr) const + { + // If the handler is for the gcc4-compatible ios::failure type then + // catch the object stored in __ios_failure::buf instead of + // the __ios_failure exception object itself. + if (__is_ios_failure_handler(dst_type)) + { + *obj_ptr = static_cast<__ios_failure*>(*obj_ptr)->buf; + return true; + } + // Otherwise proceed as normal to see if the handler matches. + return __class_type_info::__do_upcast(dst_type, obj_ptr); + } +#else // ! __cpp_rtti + using __ios_failure = ios::failure; +#endif + + void + __throw_ios_failure(const char* __s __attribute__((unused))) + { _GLIBCXX_THROW_OR_ABORT(__ios_failure(_(__s))); } + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/src/c++11/ios.cc b/libstdc++-v3/src/c++11/ios.cc index 9061989f806..ef0da960007 100644 --- a/libstdc++-v3/src/c++11/ios.cc +++ b/libstdc++-v3/src/c++11/ios.cc @@ -26,29 +26,13 @@ // ISO C++ 14882: 27.4 Iostreams base classes // -// Determines the version of ios_base::failure thrown by __throw_ios_failure. -// If !_GLIBCXX_USE_DUAL_ABI this will get undefined automatically. -#define _GLIBCXX_USE_CXX11_ABI 1 - #include <ios> #include <limits> -#include <bits/functexcept.h> - -#ifdef _GLIBCXX_USE_NLS -# include <libintl.h> -# define _(msgid) gettext (msgid) -#else -# define _(msgid) (msgid) -#endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - void - __throw_ios_failure(const char* __s __attribute__((unused))) - { _GLIBCXX_THROW_OR_ABORT(ios_base::failure(_(__s))); } - // Definitions for static const members of ios_base. const ios_base::fmtflags ios_base::boolalpha; const ios_base::fmtflags ios_base::dec; diff --git a/libstdc++-v3/src/c++98/ios_failure.cc b/libstdc++-v3/src/c++98/ios_failure.cc index 3ba25f81279..e7f35e21e2c 100644 --- a/libstdc++-v3/src/c++98/ios_failure.cc +++ b/libstdc++-v3/src/c++98/ios_failure.cc @@ -29,6 +29,18 @@ #define _GLIBCXX_USE_CXX11_ABI 0 #include <ios> +#if _GLIBCXX_USE_DUAL_ABI && __cpp_rtti +#include <cxxabi.h> +#include <typeinfo> +#endif + +#ifdef _GLIBCXX_USE_NLS +# include <libintl.h> +# define _(msgid) gettext (msgid) +#else +# define _(msgid) (msgid) +#endif + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -43,5 +55,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ios_base::failure::what() const throw() { return _M_msg.c_str(); } +#if _GLIBCXX_USE_DUAL_ABI + // When the dual ABI is enabled __throw_ios_failure() is defined in + // src/c++11/cxx11-ios_failure.cc +#if __cpp_rtti + // If RTTI is enabled the exception type thrown will use these functions to + // construct/destroy a gcc4-compatible ios::failure object in a buffer, + // and to catch that object via a handler of the gcc4-compatible type. + void + __construct_ios_failure(void* buf, const char* msg) + { ::new(buf) ios_base::failure(msg); } + + void + __destroy_ios_failure(void* buf) + { static_cast<ios_base::failure*>(buf)->~failure(); } + + bool + __is_ios_failure_handler(const __cxxabiv1::__class_type_info* type) + { return *type == typeid(ios::failure); } + + namespace { + // C++98-style static assertions to ensure ios::failure fits in a buffer + // with the same size and alignment as runtime_error: + typedef char S[1 / (sizeof(ios::failure) <= sizeof(runtime_error))]; + typedef char A[1 / (__alignof(ios::failure) <= __alignof(runtime_error))]; + } +#endif // __cpp_rtti + +#else // ! _GLIBCXX_USE_DUAL_ABI + + void + __throw_ios_failure(const char* __s __attribute__((unused))) + { _GLIBCXX_THROW_OR_ABORT(ios::failure(_(__s))); } + +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/testsuite/27_io/basic_ios/copyfmt/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ios/copyfmt/char/1.cc index 840017e4e85..aa05679ddbe 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ios/copyfmt/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ios/copyfmt/char/1.cc @@ -46,13 +46,6 @@ void test02() } { - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - std::ios ios_01(0); std::ios ios_02(0); ios_01.clear(std::ios_base::eofbit); @@ -62,7 +55,7 @@ void test02() ios_01.copyfmt(ios_02); VERIFY( false ); } - catch(exception_type&) { + catch(std::ios_base::failure&) { VERIFY( true ); } catch(...) { diff --git a/libstdc++-v3/testsuite/27_io/basic_ios/exceptions/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_ios/exceptions/char/1.cc index 152e783640a..89342d9ffe3 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ios/exceptions/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ios/exceptions/char/1.cc @@ -50,20 +50,13 @@ void test01() } { - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - std::ios ios_01(0); ios_01.clear(std::ios_base::eofbit); try { ios_01.exceptions(std::ios_base::eofbit); VERIFY( false ); } - catch(exception_type&) { + catch(std::ios_base::failure&) { iostate02 = ios_01.exceptions(); VERIFY( static_cast<bool>(iostate02 & std::ios_base::eofbit) ); } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_failbit.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_failbit.cc index 5fa3f1f34a0..b4dde2047f6 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_failbit.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/char/exceptions_failbit.cc @@ -27,20 +27,13 @@ void test_failbit() istringstream stream("jaylib - champion sound"); stream.exceptions(ios_base::failbit); - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - try { T i; stream >> i; VERIFY( false ); } - catch (const exception_type&) + catch (const std::ios_base::failure&) { // stream should set failbit and throw ios_base::failure. VERIFY( stream.fail() ); diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit.cc index 4ff48f73712..41d2f1fc24a 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/exceptions_failbit.cc @@ -27,20 +27,13 @@ void test_failbit() wistringstream stream(L"jaylib - champion sound"); stream.exceptions(ios_base::failbit); - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - try { T i; stream >> i; VERIFY( false ); } - catch (const exception_type&) + catch (const std::ios_base::failure&) { // stream should set failbit and throw ios_base::failure. VERIFY( stream.fail() ); diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_null.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_null.cc index 088aaa42808..1d146ddd5dd 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_null.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/exceptions_null.cc @@ -35,19 +35,12 @@ void test4() istringstream stream; stream.exceptions(ios_base::failbit); - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - try { stream >> static_cast<streambuf*>(0); VERIFY(false); } - catch (exception_type&) + catch (std::ios_base::failure&) { } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc index fd6322b4cdb..d51bcd5e469 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/exceptions_null.cc @@ -35,19 +35,12 @@ void test4() wistringstream stream; stream.exceptions(ios_base::failbit); - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - try { stream >> static_cast<wstreambuf*>(0); VERIFY( false ); } - catch (exception_type&) + catch (std::ios_base::failure&) { } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/12297.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/12297.cc index 0900a70d148..708f343dd37 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/12297.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/12297.cc @@ -26,19 +26,12 @@ int main() istringstream stream; stream.exceptions(ios_base::eofbit); - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - try { istream::sentry sentry(stream, false); VERIFY( false ); } - catch (exception_type&) + catch (std::ios_base::failure&) { VERIFY( stream.rdstate() == (ios_base::eofbit | ios_base::failbit) ); } diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc index e72fe1a03a0..6e572cc653d 100644 --- a/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc +++ b/libstdc++-v3/testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc @@ -26,19 +26,12 @@ int main() wistringstream stream; stream.exceptions(ios_base::eofbit); - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - try { wistream::sentry sentry(stream, false); VERIFY( false ); } - catch (exception_type&) + catch (std::ios_base::failure&) { VERIFY( stream.rdstate() == (ios_base::eofbit | ios_base::failbit) ); } diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/exceptions_null.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/exceptions_null.cc index 9a7bd06f21a..481f04e588c 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/exceptions_null.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/exceptions_null.cc @@ -37,19 +37,12 @@ void test3() ostringstream stream; stream.exceptions(ios_base::badbit); - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - try { stream << static_cast<streambuf*>(0); VERIFY( false ); } - catch (exception_type&) + catch (std::ios_base::failure&) { } diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_null.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_null.cc index fcfb37d2dac..177cecb2edf 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_null.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/exceptions_null.cc @@ -37,19 +37,12 @@ void test3() wostringstream stream; stream.exceptions(ios_base::badbit); - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - try { stream << static_cast<wstreambuf*>(0); VERIFY( false ); } - catch (exception_type&) + catch (std::ios_base::failure&) { } diff --git a/libstdc++-v3/testsuite/27_io/ios_base/failure/dual_abi.cc b/libstdc++-v3/testsuite/27_io/ios_base/failure/dual_abi.cc new file mode 100644 index 00000000000..9bd72a1baf9 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/ios_base/failure/dual_abi.cc @@ -0,0 +1,99 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-D_GLIBCXX_USE_CXX11_ABI=0" } +// { dg-do run { target c++11 } } + +#include <fstream> +#include <system_error> +#include <testsuite_hooks.h> + +void +test01() +{ + using std::ios; + bool caught_ios_failure = false; + bool rethrown = false; + bool caught_system_error = false; + try { + std::ifstream f; + f.exceptions(ios::failbit | ios::badbit | ios::eofbit); + try { + f.get(); + } + catch (const ios::failure&) // catch as old ABI type + { + caught_ios_failure = true; +#if _GLIBCXX_USE_DUAL_ABI || _GLIBCXX_USE_CXX11_ABI == 1 + rethrown = true; + throw; // re-throw, to catch as new ABI type +#endif + } + } + catch (const std::system_error& e) + { + caught_system_error = true; + } + + VERIFY( caught_ios_failure ); + if (rethrown) + VERIFY( caught_system_error ); +} + +void +test02() +{ + using std::ios; + const std::exception* p = nullptr; + bool caught_ios_failure = false; + bool caught_exception = false; + try { + std::ifstream f; + f.exceptions(ios::failbit | ios::badbit | ios::eofbit); + try { + f.get(); + } + catch (const std::exception& e1) + { + caught_exception = true; + p = &e1; + throw; + } + } + catch (const ios::failure& e2) + { + caught_ios_failure = true; +#if _GLIBCXX_USE_DUAL_ABI + // If the Dual ABI is active the library throws the new type, + // so e1 was an object of that new type and so &e1 != &e2. + VERIFY( p != &e2 ); +#else + // Otherwise there's only one type of ios::failure, so &e1 == &e2. + VERIFY( p == &e2 ); +#endif + } + + VERIFY( caught_exception ); + VERIFY( caught_ios_failure ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/27_io/ios_base/storage/2.cc b/libstdc++-v3/testsuite/27_io/ios_base/storage/2.cc index 8fa306f61a2..2ec234a1bfb 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/storage/2.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/storage/2.cc @@ -50,18 +50,11 @@ void test02() ios.pword(1) = v; VERIFY( ios.pword(1) == v ); - // The library throws the new definition of std::ios::failure -#if _GLIBCXX_USE_CXX11_ABI - typedef std::ios_base::failure exception_type; -#else - typedef std::exception exception_type; -#endif - try { v = ios.pword(max); } - catch(exception_type&) + catch(std::ios_base::failure&) { // Ok. VERIFY( ios.bad() ); @@ -80,7 +73,7 @@ void test02() { v = ios.pword(std::numeric_limits<int>::max()); } - catch(exception_type&) + catch(std::ios_base::failure&) { // Ok. VERIFY( ios.bad() ); @@ -99,7 +92,7 @@ void test02() { l = ios.iword(max); } - catch(exception_type&) + catch(std::ios_base::failure&) { // Ok. VERIFY( ios.bad() ); @@ -118,7 +111,7 @@ void test02() { l = ios.iword(std::numeric_limits<int>::max()); } - catch(exception_type&) + catch(std::ios_base::failure&) { // Ok. VERIFY( ios.bad() ); diff --git a/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc b/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc index 8e639f22380..b85c5c8be45 100644 --- a/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc +++ b/libstdc++-v3/testsuite/experimental/memory_resource/resource_adaptor.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++14 } } +// { dg-xfail-run-if "PR libstdc++/77691" { { i?86-*-solaris2.* x86_64-*-solaris2.* } && ilp32 } } // Copyright (C) 2016-2017 Free Software Foundation, Inc. // |