aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYvan Roux <yvan.roux@linaro.org>2017-09-13 22:08:01 +0200
committerYvan Roux <yvan.roux@linaro.org>2017-09-13 22:08:01 +0200
commitc9ea5a776f51a9c5c5a7acabd054d0f2c1d49b66 (patch)
treecb3c91ed24da10b24f0cbbfad54c3aaf2efa2762
parentb637432f10f34af6d5680363f853f929d0472652 (diff)
Merge branches/gcc-7-branch rev 252337.
Change-Id: Iea4913cc1bf65480f6d85f4cc97252e9e59c3631
-rw-r--r--gcc/ChangeLog335
-rw-r--r--gcc/DATESTAMP2
-rw-r--r--gcc/ada/ChangeLog47
-rw-r--r--gcc/ada/gcc-interface/decl.c162
-rw-r--r--gcc/ada/gcc-interface/trans.c23
-rw-r--r--gcc/ada/gcc-interface/utils.c34
-rw-r--r--gcc/ada/sem_ch3.adb4
-rw-r--r--gcc/ada/sem_util.adb14
-rw-r--r--gcc/ada/sem_util.ads6
-rw-r--r--gcc/asan.c7
-rw-r--r--gcc/bb-reorder.c6
-rw-r--r--gcc/c-family/ChangeLog15
-rw-r--r--gcc/c-family/c-cppbuiltin.c2
-rw-r--r--gcc/c-family/c-omp.c21
-rw-r--r--gcc/calls.c30
-rw-r--r--gcc/config.gcc2
-rw-r--r--gcc/config/avr/avr.c28
-rw-r--r--gcc/config/gnu-user.h34
-rw-r--r--gcc/config/i386/i386.c24
-rw-r--r--gcc/config/riscv/rtems.h31
-rw-r--r--gcc/config/rs6000/altivec.md78
-rw-r--r--gcc/config/rs6000/rs6000.c160
-rw-r--r--gcc/config/rs6000/rtems.h60
-rw-r--r--gcc/config/rs6000/sysv4.h46
-rw-r--r--gcc/config/rs6000/vsx.md176
-rw-r--r--gcc/config/sol2.h12
-rw-r--r--gcc/config/sparc/sparc.md17
-rw-r--r--gcc/config/xtensa/xtensa.c1
-rw-r--r--gcc/cp/ChangeLog29
-rw-r--r--gcc/cp/cp-gimplify.c6
-rw-r--r--gcc/cp/cp-objcp-common.c45
-rw-r--r--gcc/cp/typeck.c1
-rw-r--r--gcc/doc/extend.texi2
-rw-r--r--gcc/dwarf2out.c146
-rw-r--r--gcc/fold-const.c25
-rw-r--r--gcc/fortran/ChangeLog21
-rw-r--r--gcc/fortran/expr.c3
-rw-r--r--gcc/fortran/trans-io.c26
-rw-r--r--gcc/fortran/trans-stmt.c5
-rw-r--r--gcc/gcc.c14
-rw-r--r--gcc/gimple-fold.c2
-rw-r--r--gcc/gimple-ssa-strength-reduction.c183
-rw-r--r--gcc/lra-remat.c2
-rw-r--r--gcc/omp-expand.c12
-rw-r--r--gcc/omp-low.c10
-rw-r--r--gcc/po/ChangeLog4
-rw-r--r--gcc/po/de.po110
-rw-r--r--gcc/testsuite/ChangeLog260
-rw-r--r--gcc/testsuite/c-c++-common/pr81052.c28
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr80932.c17
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr81065.c13
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/pr81088.c11
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C6
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C6
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C8
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/feat-neg.C8
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C6
-rw-r--r--gcc/testsuite/g++.dg/other/bitfield6.C9
-rw-r--r--gcc/testsuite/g++.dg/pr80287.C13
-rw-r--r--gcc/testsuite/g++.dg/torture/pr81884.C39
-rw-r--r--gcc/testsuite/g++.dg/torture/pr81977.C55
-rw-r--r--gcc/testsuite/g++.dg/torture/pr81987.C61
-rw-r--r--gcc/testsuite/g++.dg/warn/Wbool-operation-1.C11
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr81503.c15
-rw-r--r--gcc/testsuite/gcc.dg/asan/pr81923.c10
-rw-r--r--gcc/testsuite/gcc.dg/gomp/pr81768-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/gomp/pr81768-2.c15
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-7.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr81621.c5
-rw-r--r--gcc/testsuite/gcc.dg/pr81650.c9
-rw-r--r--gcc/testsuite/gcc.dg/pr81988.c22
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr81181.c30
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr81588.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/mpx/mpx-check.h23
-rw-r--r--gcc/testsuite/gcc.target/i386/mpx/mpx-os-support.h16
-rw-r--r--gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-lbv.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-nov.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-ubv.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-lbv.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-nov.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-ubv.c2
-rw-r--r--gcc/testsuite/gcc.target/i386/pr81921.c14
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr72804.c25
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr80210.c10
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr80695-p8.c18
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr80695-p9.c18
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr81833-1.c59
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr81833-2.c59
-rw-r--r--gcc/testsuite/gcc.target/powerpc/vec-setup-be-double.c12
-rw-r--r--gcc/testsuite/gcc.target/powerpc/vec-setup-be-long.c11
-rw-r--r--gcc/testsuite/gcc.target/powerpc/vec-setup-double.c11
-rw-r--r--gcc/testsuite/gcc.target/powerpc/vec-setup-long.c9
-rw-r--r--gcc/testsuite/gcc.target/powerpc/vec-setup.h366
-rw-r--r--gcc/testsuite/gcc.target/powerpc/vsx-extract-6.c25
-rw-r--r--gcc/testsuite/gcc.target/powerpc/vsx-extract-7.c25
-rw-r--r--gcc/testsuite/gfortran.dg/array_temporaries_4.f9059
-rw-r--r--gcc/testsuite/gfortran.dg/dtio_12.f906
-rw-r--r--gcc/testsuite/gfortran.dg/pr81723.f56
-rw-r--r--gcc/testsuite/gfortran.dg/warn_target_lifetime_3.f902
-rw-r--r--gcc/testsuite/gfortran.dg/warn_target_lifetime_4.f9028
-rw-r--r--gcc/testsuite/gnat.dg/array29.adb26
-rw-r--r--gcc/testsuite/gnat.dg/array29.ads7
-rw-r--r--gcc/testsuite/gnat.dg/debug13.adb38
-rw-r--r--gcc/testsuite/gnat.dg/debug13.ads5
-rw-r--r--gcc/testsuite/gnat.dg/incomplete5.adb10
-rw-r--r--gcc/testsuite/gnat.dg/incomplete5.ads25
-rw-r--r--gcc/testsuite/gnat.dg/incomplete5_pkg.adb13
-rw-r--r--gcc/testsuite/gnat.dg/incomplete5_pkg.ads15
-rw-r--r--gcc/testsuite/gnat.dg/pack9.adb3
-rw-r--r--gcc/testsuite/gnat.dg/specs/atomic3.ads33
-rw-r--r--gcc/testsuite/gnat.dg/specs/uc2.ads18
-rw-r--r--gcc/testsuite/gnat.dg/specs/vfa1.ads (renamed from gcc/testsuite/gnat.dg/specs/vfa.ads)4
-rw-r--r--gcc/testsuite/gnat.dg/specs/vfa2.ads110
-rw-r--r--gcc/testsuite/lib/target-supports.exp1
-rw-r--r--gcc/tree-cfg.c25
-rw-r--r--gcc/tree-chkp.c2
-rw-r--r--gcc/tree-ssa-alias.c31
-rw-r--r--gcc/tree-ssa-pre.c12
-rw-r--r--gcc/tree-ssa-sccvn.c2
-rw-r--r--gcc/tree-vect-slp.c87
-rw-r--r--gcc/tree.c63
-rw-r--r--gcc/tree.h10
-rw-r--r--libgomp/ChangeLog15
-rw-r--r--libgomp/testsuite/libgomp.c++/pr45784.C5
-rw-r--r--libgomp/testsuite/libgomp.c/pr45784.c41
-rw-r--r--libgomp/testsuite/libgomp.c/pr81687-1.c23
-rw-r--r--libgomp/testsuite/libgomp.c/pr81687-2.c27
-rw-r--r--libsanitizer/ChangeLog7
-rw-r--r--libsanitizer/include/system/sys/ptrace.h7
-rw-r--r--libstdc++-v3/ChangeLog219
-rw-r--r--libstdc++-v3/doc/doxygen/mainpage.html6
-rw-r--r--libstdc++-v3/doc/html/manual/ext_demangling.html2
-rw-r--r--libstdc++-v3/doc/html/manual/status.html6
-rw-r--r--libstdc++-v3/doc/xml/manual/extensions.xml2
-rw-r--r--libstdc++-v3/doc/xml/manual/status_cxx2017.xml5
-rw-r--r--libstdc++-v3/include/bits/basic_string.h552
-rw-r--r--libstdc++-v3/include/bits/char_traits.h101
-rw-r--r--libstdc++-v3/include/bits/hashtable.h13
-rw-r--r--libstdc++-v3/include/bits/sstream.tcc19
-rw-r--r--libstdc++-v3/include/bits/stl_iterator_base_types.h3
-rw-r--r--libstdc++-v3/include/bits/stl_stack.h2
-rw-r--r--libstdc++-v3/include/bits/string_view.tcc20
-rw-r--r--libstdc++-v3/include/experimental/bits/string_view.tcc20
-rw-r--r--libstdc++-v3/include/experimental/string_view107
-rw-r--r--libstdc++-v3/include/ext/new_allocator.h2
-rw-r--r--libstdc++-v3/include/std/chrono3
-rw-r--r--libstdc++-v3/include/std/sstream21
-rw-r--r--libstdc++-v3/include/std/string_view121
-rw-r--r--libstdc++-v3/include/std/type_traits18
-rw-r--r--libstdc++-v3/libsupc++/cxxabi.h2
-rw-r--r--libstdc++-v3/testsuite/17_intro/names.cc5
-rw-r--r--libstdc++-v3/testsuite/20_util/duration/cons/dr1177.cc41
-rw-r--r--libstdc++-v3/testsuite/20_util/duration/literals/range.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/time_point/cons/81468.cc34
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/79162.cc37
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc41
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc19
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc19
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc19
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc19
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/swap/char/1.cc35
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t/1.cc35
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/1.cc23
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/2.cc30
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/70483.cc89
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/wchar_t/1.cc24
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/wchar_t/2.cc30
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/1.cc78
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/2.cc74
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/3.cc70
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/1.cc77
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/2.cc74
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/3.cc70
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operators/char/2.cc137
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/operators/wchar_t/2.cc141
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/char/1.cc18
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc20
-rw-r--r--libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc16
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/cons/81891.cc68
-rw-r--r--libstdc++-v3/testsuite/24_iterators/container_access.cc3
-rw-r--r--libstdc++-v3/testsuite/24_iterators/range_access.cc2
-rw-r--r--libstdc++-v3/testsuite/24_iterators/range_access_cpp14.cc2
-rw-r--r--libstdc++-v3/testsuite/24_iterators/range_access_cpp17.cc57
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_stringstream/assign/81338.cc40
-rw-r--r--libstdc++-v3/testsuite/experimental/string_view/operations/compare/char/70483.cc68
185 files changed, 5941 insertions, 1048 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f3a23107eb0..c7b62274448 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,338 @@
+2017-09-12 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ Backport from mainline
+ 2017-09-05 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR target/81833
+ * config/rs6000/altivec.md (altivec_vsum2sws): Convert from a
+ define_insn to a define_expand.
+ (altivec_vsum2sws_direct): New define_insn.
+ (altivec_vsumsws): Convert from a define_insn to a define_expand.
+
+2017-09-11 Max Filippov <jcmvbkbc@gmail.com>
+
+ Backport from mainline
+ PR target/82181
+ * config/xtensa/xtensa.c (xtensa_mem_offset): Check that both
+ words of DImode object are reachable by xtensa_uimm8x4 access.
+
+2017-09-10 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ Backport from mainline
+ 2017-05-11 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR target/80695
+ * config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost):
+ Account for direct move costs for vec_construct of integer
+ vectors.
+
+ Backport from mainline
+ 2017-07-23 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR target/80695
+ * config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost):
+ Reduce cost estimate for direct moves.
+
+2017-09-08 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR target/81988
+ * config/sparc/sparc.md (mulsi3): Rename into *mulsi3_sp32.
+ (*mulsi3_sp64): New instruction.
+ (mulsi3): New expander.
+
+2017-09-07 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2017-09-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/81768
+ * omp-low.c (lower_omp_for): Recompute tree invariant if
+ gimple_omp_for_initial/final is ADDR_EXPR.
+
+ PR middle-end/81768
+ * omp-expand.c (expand_omp_simd): Force second operands of COND_EXPR
+ into gimple val before gimplification fo the COND_EXPR.
+
+ 2017-09-04 Jakub Jelinek <jakub@redhat.com>
+
+ * lra-remat.c (reg_overlap_for_remat_p): Fix a pasto.
+
+ 2017-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR sanitizer/81923
+ * asan.c (create_odr_indicator): Strip name encoding from assembler
+ name before appending it after __odr_asan_.
+
+ 2017-08-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/81687
+ * omp-low.c (omp_copy_decl): Don't remap FORCED_LABEL or DECL_NONLOCAL
+ LABEL_DECLs.
+ * tree-cfg.c (move_stmt_op): Don't adjust DECL_CONTEXT of FORCED_LABEL
+ or DECL_NONLOCAL labels.
+ (move_stmt_r) <case GIMPLE_LABEL>: Adjust DECL_CONTEXT of FORCED_LABEL
+ or DECL_NONLOCAL labels here.
+
+ 2017-08-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/81621
+ * bb-reorder.c (pass_partition_blocks::execute): Return TODO_df_finish
+ after setting changeable df flags.
+
+ PR driver/81650
+ * calls.c (alloc_max_size): Use HOST_WIDE_INT_UC (10??)
+ instead of 10??LU, perform unit multiplication in wide_int,
+ don't change alloc_object_size_limit if the limit is larger
+ than SSIZE_MAX.
+
+ PR middle-end/81052
+ * omp-low.c (diagnose_sb_0): Handle flag_openmp_simd like flag_openmp.
+ (pass_diagnose_omp_blocks::gate): Enable also for flag_openmp_simd.
+
+2017-09-06 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ Backport from mainline:
+ 2017-08-30 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR tree-optimization/81987
+ * gimple-ssa-strength-reduction.c (insert_initializers): Don't
+ insert an initializer in a location not dominated by the stride
+ definition.
+
+2017-09-05 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ Backport from mainline
+ 2017-08-29 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+ Jakub Jelinek <jakub@redhat.com>
+ Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81503
+ * gimple-ssa-strength-reduction.c (replace_mult_candidate): Ensure
+ folded constant fits in the target type; reorder tests for clarity.
+
+2017-09-05 Pierre-Marie de Rodat <derodat@adacore.com>
+
+ Backport from trunk
+ PR ada/79542
+ * dwarf2out.c (modified_type_die): For C typedef types that have
+ an ultimate origin, process the ultimate origin instead of the
+ input type.
+ (gen_typedef_die): Assert that input DECLs have no ultimate
+ origin.
+ (gen_type_die_with_usage): For typedef variants that have an
+ ultimate origin, just call gen_decl_die on the original DECL.
+ (process_scope_var): Avoid creating DIEs for local typedefs and
+ concrete static variables.
+
+2017-08-31 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ Backport from mainline
+ 2017-08-25 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR target/81504
+ * config/rs6000/rs6000.c (find_alignment_op): Add reference
+ parameter and_insn and return it.
+ (recombine_lvx_pattern): Insert a copy to ensure availability of
+ the base register of the copied masking operation at the point of
+ the instruction replacement.
+ (recombine_stvx_pattern): Likewise.
+
+2017-08-29 Michael Meissner <meissner@linux.vnet.ibm.com>
+
+ Back port from trunk
+ 2017-08-07 Michael Meissner <meissner@linux.vnet.ibm.com>
+
+ PR target/81593
+ * config/rs6000/vsx.md (vsx_concat_<mode>_1): New combiner insns
+ to recognize inserting into a vector from a double word element
+ that was extracted from another vector, and eliminate extra
+ XXPERMDI instructions.
+ (vsx_concat_<mode>_2): Likewise.
+ (vsx_concat_<mode>_3): Likewise.
+ (vsx_set_<mode>, VSX_D): Rewrite vector set in terms of vector
+ concat to allow optimizing inserts from previous extracts.
+
+2017-08-29 Alan Modra <amodra@gmail.com>
+
+ Apply from mainline
+ 2017-08-12 Alan Modra <amodra@gmail.com>
+ PR target/81170
+ PR target/81295
+ * config/rs6000/sysv4.h (STARTFILE_LINUX_SPEC): Upgrade to
+ match gnu-user.h startfile.
+ (ENDFILE_LINUX_SPEC): Similarly.
+
+ 2017-08-08 Alan Modra <amodra@gmail.com>
+ H.J. Lu <hongjiu.lu@intel.com>
+ PR target/81170
+ PR target/81295
+ PR driver/81523
+ * gcc.c (NO_PIE_SPEC): Delete.
+ (PIE_SPEC): Define as !no-pie/pie. Move static|shared|r
+ exclusion..
+ (LINK_PIE_SPEC): ..to here.
+ (LINK_COMMAND_SPEC): Support -no-pie.
+ * config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Correct
+ chain of crtbegin*.o selection, update for PIE_SPEC changes and
+ format.
+ (GNU_USER_TARGET_ENDFILE_SPEC): Similarly.
+ * config/sol2.h (STARTFILE_CRTBEGIN_SPEC): Similarly.
+ (ENDFILE_CRTEND_SPEC): Similarly.
+
+2017-08-29 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2017-08-28 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81977
+ * tree-ssa-sccvn.c (vn_reference_lookup_3): Fix look through
+ memcpy.
+
+ 2017-08-28 Richard Biener <rguenther@suse.de>
+
+ PR debug/81993
+ * dwarf2out.c (gen_remaining_tmpl_value_param_die_attributes):
+ Do nothing for removed DIEs.
+
+2017-08-28 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2017-06-14 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/81088
+ * fold-const.c (split_tree): Drop TREE_OVERFLOW flag from
+ literal constants.
+ (fold_binary_loc): When associating do not treat pre-existing
+ TREE_OVERFLOW on literal constants as a reason to allow
+ TREE_OVERFLOW on associated literal constants.
+
+ 2017-06-13 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/81065
+ * fold-const.c (extract_muldiv_1): Remove bogus distribution
+ case of C * (x * C2 + C3).
+ (fold_addr_of_array_ref_difference): Properly fold index difference.
+
+ 2017-06-07 Marek Polacek <polacek@redhat.com>
+
+ PR sanitizer/80932
+ * fold-const.c (extract_muldiv_1) <case MINUS_EXPR>: Add
+ TYPE_OVERFLOW_WRAPS check.
+
+2017-08-28 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2017-08-21 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/81884
+ * tree-ssa-alias.c (stmt_kills_ref_p): Handle array accesses
+ at struct end conservatively when comparing common bases.
+
+ 2017-05-04 Richard Biener <rguenther@suse.de>
+
+ * tree.c (array_at_struct_end_p): Handle arrays at struct
+ end with flexarrays more conservatively. Refactor and treat
+ arrays of arrays or aggregates more strict. Fix
+ VIEW_CONVERT_EXPR handling. Remove allow_compref argument.
+ * tree.h (array_at_struct_end_p): Adjust prototype.
+ * gimple-fold.c (get_range_strlen): Likewise.
+ * tree-chkp.c (chkp_may_narrow_to_field): Likewise.
+
+2017-08-28 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2017-08-01 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81181
+ * tree-ssa-pre.c (compute_antic_aux): Defer clean() to ...
+ (compute_antic): ... end of iteration here.
+
+ 2017-08-08 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81723
+ * tree-vect-slp.c (struct bst_traits): New hash traits.
+ (bst_fail): New global.
+ (vect_build_slp_tree_2): New worker, split out from ...
+ (vect_build_slp_tree): ... this now wrapping it with using
+ bst_fail set to cache SLP tree build fails. Properly handle
+ max_tree_size.
+ (vect_analyze_slp_instance): Allocate and free bst_fail.
+
+ 2017-08-24 Richard Biener <rguenther@suse.de>
+
+ PR target/81921
+ * config/i386/i386.c: Include symbol-summary.h, ipa-prop.h
+ and ipa-inline.h.
+ (ix86_can_inline_p): When ix86_fpmath flags do not match
+ check whether the callee uses FP math at all.
+
+2017-08-23 Peter Bergner <bergner@vnet.ibm.com>
+
+ Backport from mainline
+ 2017-08-17 Peter Bergner <bergner@vnet.ibm.com>
+
+ PR target/72804
+ * config/rs6000/vsx.md (*vsx_le_permute_<mode>): Add support for
+ operands residing in integer registers.
+ (*vsx_le_perm_load_<mode>): Likewise.
+ (*vsx_le_perm_store_<mode>): Likewise.
+ (define_peephole2): Add peepholes to optimize the above.
+
+2017-08-22 Peter Bergner <bergner@vnet.ibm.com>
+
+ Backport from mainline
+ 2017-08-17 Peter Bergner <bergner@vnet.ibm.com>
+
+ PR target/80210
+ * config/rs6000/rs6000.c (rs6000_activate_target_options): New function.
+ (rs6000_set_current_function): Rewrite function to use it.
+
+2017-08-22 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ Backport from mainline
+ 2017-08-22 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ * config.gcc (powerpc-*-rtems*): Add rs6000/linux64.opt.
+ * config/rs6000/rtems.h (ASM_PREFERRED_EH_DATA_FORMAT): New define.
+ (DOT_SYMBOLS): Likewise.
+ (MINIMAL_TOC_SECTION_ASM_OP): Likewise.
+ (RELOCATABLE_NEEDS_FIXUP): Likewise.
+ (RS6000_ABI_NAME): Likewise.
+ (TARGET_CMODEL): Likewise.
+ (TOC_SECTION_ASM_OP): Likewise.
+ (SET_CMODEL): New macro.
+ (SUBSUBTARGET_OVERRIDE_OPTIONS): Evaluate cmodel options.
+
+2017-08-22 Georg-Johann Lay <avr@gjlay.de>
+
+ Backport from 2017-08-22 trunk r251256.
+
+ PR target/81910
+ * config/avr/avr.c (avr_handle_addr_attribute): Early return if
+ not VAR_P. Filter attribute warnings with OPT_Wattributes.
+ (avr_attribute_table) <io, io_low, address>: Initialize
+ .decl_required with true.
+
+2017-08-21 Georg-Johann Lay <avr@gjlay.de>
+
+ PR target/79883
+ * config/avr/avr.c (avr_set_current_function): Typo in diagnostic.
+
+2017-08-19 Uros Bizjak <ubizjak@gmail.com>
+
+ PR target/81894
+ * doc/extend.texi (x86 Built-in Functions): Correct the name of
+ __builtin_ia32_lzcnt_u16.
+
+2017-08-17 Uros Bizjak <ubizjak@gmail.com>
+
+ Backport from mainline
+ 2017-08-17 Maxim Ostapenko <m.ostapenko@samsung.com>
+
+ PR target/81861
+ * config/i386/i386.c (ix86_option_override_internal): Save target
+ specific options after ix86_stack_protector_guard_reg was changed.
+
2017-08-16 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Backport from mainline
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 45e4024d99f..8afc9469ac6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20170817
+20170913
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 6d9827b5c6b..8f296affdbb 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,50 @@
+2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/decl.c (promote_object_alignment): New function taken
+ from...
+ (gnat_to_gnu_entity) <E_Variable>: ...here. Invoke it.
+ (gnat_to_gnu_field): If the field is Atomic or VFA, invoke it and
+ create a padding type on success before doing the atomic check.
+
+2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Apply the
+ promotion to static memory earlier in the processing.
+
+2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
+
+ * sem_util.ads (Set_Rep_Info): New inline procedure.
+ * sem_util.adb (Set_Rep_Info): Implement it.
+ * sem_ch3.adb (Process_Subtype): If the case of a constraint present,
+ always copy the representation aspects onto the subtype.
+ * gcc-interface/decl.c (gnat_to_gnu_entity): Only set the TYPE_ALIGN_OK
+ and TYPE_BY_REFERENCE_P flags on types after various promotions.
+ * gcc-interface/trans.c (node_has_volatile_full_access) <N_Identifier>:
+ Consider all kinds of entities.
+
+2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR ada/62235
+ * gcc-interface/decl.c (gnat_to_gnu_entity): Skip regular processing
+ for Itypes that are E_Record_Subtype with a cloned subtype.
+ <E_Record_Subtype>: Use the DECL of the cloned type directly, if any.
+
+2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/utils.c (unchecked_convert): When the result type is a
+ non-biased integral type with size 0, set the result to 0 directly.
+
+2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/trans.c (Call_to_gnu): If this is a function call and
+ there is no target, do not create a temporary for the return value for
+ an allocator either.
+
+2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/trans.c (pos_to_constructor): Skip conversions to an
+ unconstrained array type.
+
2017-08-14 Release Manager
* GCC 7.2.0 released.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index ed8a5035074..e057749e956 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -229,6 +229,7 @@ static vec<variant_desc> build_variant_list (tree,
static tree validate_size (Uint, tree, Entity_Id, enum tree_code, bool, bool);
static void set_rm_size (Uint, tree, Entity_Id);
static unsigned int validate_alignment (Uint, Entity_Id, unsigned int);
+static unsigned int promote_object_alignment (tree, Entity_Id);
static void check_ok_for_atomic_type (tree, Entity_Id, bool);
static tree create_field_decl_from (tree, tree, tree, tree, tree,
vec<subst_pair> );
@@ -309,11 +310,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
/* Since a use of an Itype is a definition, process it as such if it is in
the main unit, except for E_Access_Subtype because it's actually a use
- of its base type, see below. */
+ of its base type, and for E_Record_Subtype with cloned subtype because
+ it's actually a use of the cloned subtype, see below. */
if (!definition
&& is_type
&& Is_Itype (gnat_entity)
- && Ekind (gnat_entity) != E_Access_Subtype
+ && !(kind == E_Access_Subtype
+ || (kind == E_Record_Subtype
+ && Present (Cloned_Subtype (gnat_entity))))
&& !present_gnu_tree (gnat_entity)
&& In_Extended_Main_Code_Unit (gnat_entity))
{
@@ -847,45 +851,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
&& No (Renamed_Object (gnat_entity))
&& No (Address_Clause (gnat_entity))))
&& TREE_CODE (TYPE_SIZE (gnu_type)) == INTEGER_CST)
- {
- unsigned int size_cap, align_cap;
-
- /* No point in promoting the alignment if this doesn't prevent
- BLKmode access to the object, in particular block copy, as
- this will for example disable the NRV optimization for it.
- No point in jumping through all the hoops needed in order
- to support BIGGEST_ALIGNMENT if we don't really have to.
- So we cap to the smallest alignment that corresponds to
- a known efficient memory access pattern of the target. */
- if (Is_Atomic_Or_VFA (gnat_entity))
- {
- size_cap = UINT_MAX;
- align_cap = BIGGEST_ALIGNMENT;
- }
- else
- {
- size_cap = MAX_FIXED_MODE_SIZE;
- align_cap = get_mode_alignment (ptr_mode);
- }
-
- if (!tree_fits_uhwi_p (TYPE_SIZE (gnu_type))
- || compare_tree_int (TYPE_SIZE (gnu_type), size_cap) > 0)
- align = 0;
- else if (compare_tree_int (TYPE_SIZE (gnu_type), align_cap) > 0)
- align = align_cap;
- else
- align = ceil_pow2 (tree_to_uhwi (TYPE_SIZE (gnu_type)));
-
- /* But make sure not to under-align the object. */
- if (align <= TYPE_ALIGN (gnu_type))
- align = 0;
-
- /* And honor the minimum valid atomic alignment, if any. */
-#ifdef MINIMUM_ATOMIC_ALIGNMENT
- else if (align < MINIMUM_ATOMIC_ALIGNMENT)
- align = MINIMUM_ATOMIC_ALIGNMENT;
-#endif
- }
+ align = promote_object_alignment (gnu_type, gnat_entity);
/* If the object is set to have atomic components, find the component
type and validate it.
@@ -1413,6 +1379,19 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
gnu_size = NULL_TREE;
}
+ /* If this is an aggregate constant initialized to a constant, force it
+ to be statically allocated. This saves an initialization copy. */
+ if (!static_flag
+ && const_flag
+ && gnu_expr
+ && TREE_CONSTANT (gnu_expr)
+ && AGGREGATE_TYPE_P (gnu_type)
+ && tree_fits_uhwi_p (TYPE_SIZE_UNIT (gnu_type))
+ && !(TYPE_IS_PADDING_P (gnu_type)
+ && !tree_fits_uhwi_p (TYPE_SIZE_UNIT
+ (TREE_TYPE (TYPE_FIELDS (gnu_type))))))
+ static_flag = true;
+
/* If this is an aliased object with an unconstrained array nominal
subtype, we make its type a thin reference, i.e. the reference
counterpart of a thin pointer, so it points to the array part.
@@ -1463,18 +1442,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
&& No (Address_Clause (gnat_entity))))
gnu_ext_name = create_concat_name (gnat_entity, NULL);
- /* If this is an aggregate constant initialized to a constant, force it
- to be statically allocated. This saves an initialization copy. */
- if (!static_flag
- && const_flag
- && gnu_expr && TREE_CONSTANT (gnu_expr)
- && AGGREGATE_TYPE_P (gnu_type)
- && tree_fits_uhwi_p (TYPE_SIZE_UNIT (gnu_type))
- && !(TYPE_IS_PADDING_P (gnu_type)
- && !tree_fits_uhwi_p (TYPE_SIZE_UNIT
- (TREE_TYPE (TYPE_FIELDS (gnu_type))))))
- static_flag = true;
-
/* Deal with a pragma Linker_Section on a constant or variable. */
if ((kind == E_Constant || kind == E_Variable)
&& Present (Linker_Section_Pragma (gnat_entity)))
@@ -3391,7 +3358,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
{
gnu_decl = gnat_to_gnu_entity (Cloned_Subtype (gnat_entity),
NULL_TREE, false);
- maybe_present = true;
+ saved = true;
break;
}
@@ -4505,18 +4472,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
already defined so we cannot pass true for IN_PLACE here. */
process_attributes (&gnu_type, &attr_list, false, gnat_entity);
- /* Tell the middle-end that objects of tagged types are guaranteed to
- be properly aligned. This is necessary because conversions to the
- class-wide type are translated into conversions to the root type,
- which can be less aligned than some of its derived types. */
- if (Is_Tagged_Type (gnat_entity)
- || Is_Class_Wide_Equivalent_Type (gnat_entity))
- TYPE_ALIGN_OK (gnu_type) = 1;
-
- /* Record whether the type is passed by reference. */
- if (!VOID_TYPE_P (gnu_type) && Is_By_Reference_Type (gnat_entity))
- TYPE_BY_REFERENCE_P (gnu_type) = 1;
-
/* ??? Don't set the size for a String_Literal since it is either
confirming or we don't handle it properly (if the low bound is
non-constant). */
@@ -4726,17 +4681,29 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
/* If this is not an unconstrained array type, set some flags. */
if (TREE_CODE (gnu_type) != UNCONSTRAINED_ARRAY_TYPE)
{
+ /* Tell the middle-end that objects of tagged types are guaranteed to
+ be properly aligned. This is necessary because conversions to the
+ class-wide type are translated into conversions to the root type,
+ which can be less aligned than some of its derived types. */
+ if (Is_Tagged_Type (gnat_entity)
+ || Is_Class_Wide_Equivalent_Type (gnat_entity))
+ TYPE_ALIGN_OK (gnu_type) = 1;
+
+ /* Record whether the type is passed by reference. */
+ if (Is_By_Reference_Type (gnat_entity) && !VOID_TYPE_P (gnu_type))
+ TYPE_BY_REFERENCE_P (gnu_type) = 1;
+
+ /* Record whether an alignment clause was specified. */
if (Present (Alignment_Clause (gnat_entity)))
TYPE_USER_ALIGN (gnu_type) = 1;
+ /* Record whether a pragma Universal_Aliasing was specified. */
if (Universal_Aliasing (gnat_entity) && !TYPE_IS_DUMMY_P (gnu_type))
TYPE_UNIVERSAL_ALIASING_P (gnu_type) = 1;
/* If it is passed by reference, force BLKmode to ensure that
objects of this type will always be put in memory. */
- if (TYPE_MODE (gnu_type) != BLKmode
- && AGGREGATE_TYPE_P (gnu_type)
- && TYPE_BY_REFERENCE_P (gnu_type))
+ if (AGGREGATE_TYPE_P (gnu_type) && TYPE_BY_REFERENCE_P (gnu_type))
SET_TYPE_MODE (gnu_type, BLKmode);
}
@@ -7114,7 +7081,15 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
}
if (Is_Atomic_Or_VFA (gnat_field))
- check_ok_for_atomic_type (gnu_field_type, gnat_field, false);
+ {
+ const unsigned int align
+ = promote_object_alignment (gnu_field_type, gnat_field);
+ if (align > 0)
+ gnu_field_type
+ = maybe_pad_type (gnu_field_type, NULL_TREE, align, gnat_field,
+ false, false, definition, true);
+ check_ok_for_atomic_type (gnu_field_type, gnat_field, false);
+ }
if (Present (Component_Clause (gnat_field)))
{
@@ -8788,6 +8763,53 @@ validate_alignment (Uint alignment, Entity_Id gnat_entity, unsigned int align)
return align;
}
+/* Promote the alignment of GNU_TYPE corresponding to GNAT_ENTITY. Return
+ a positive value on success or zero on failure. */
+
+static unsigned int
+promote_object_alignment (tree gnu_type, Entity_Id gnat_entity)
+{
+ unsigned int align, size_cap, align_cap;
+
+ /* No point in promoting the alignment if this doesn't prevent BLKmode access
+ to the object, in particular block copy, as this will for example disable
+ the NRV optimization for it. No point in jumping through all the hoops
+ needed in order to support BIGGEST_ALIGNMENT if we don't really have to.
+ So we cap to the smallest alignment that corresponds to a known efficient
+ memory access pattern, except for Atomic and Volatile_Full_Access. */
+ if (Is_Atomic_Or_VFA (gnat_entity))
+ {
+ size_cap = UINT_MAX;
+ align_cap = BIGGEST_ALIGNMENT;
+ }
+ else
+ {
+ size_cap = MAX_FIXED_MODE_SIZE;
+ align_cap = get_mode_alignment (ptr_mode);
+ }
+
+ /* Do the promotion within the above limits. */
+ if (!tree_fits_uhwi_p (TYPE_SIZE (gnu_type))
+ || compare_tree_int (TYPE_SIZE (gnu_type), size_cap) > 0)
+ align = 0;
+ else if (compare_tree_int (TYPE_SIZE (gnu_type), align_cap) > 0)
+ align = align_cap;
+ else
+ align = ceil_pow2 (tree_to_uhwi (TYPE_SIZE (gnu_type)));
+
+ /* But make sure not to under-align the object. */
+ if (align <= TYPE_ALIGN (gnu_type))
+ align = 0;
+
+ /* And honor the minimum valid atomic alignment, if any. */
+#ifdef MINIMUM_ATOMIC_ALIGNMENT
+ else if (align < MINIMUM_ATOMIC_ALIGNMENT)
+ align = MINIMUM_ATOMIC_ALIGNMENT;
+#endif
+
+ return align;
+}
+
/* Verify that TYPE is something we can implement atomically. If not, issue
an error for GNAT_ENTITY. COMPONENT_P is true if we are being called to
process a component type. */
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 0a7ddfcfdbb..d1d1b433667 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -4058,8 +4058,6 @@ node_has_volatile_full_access (Node_Id gnat_node)
case N_Identifier:
case N_Expanded_Name:
gnat_entity = Entity (gnat_node);
- if (Ekind (gnat_entity) != E_Variable)
- break;
return Is_Volatile_Full_Access (gnat_entity)
|| Is_Volatile_Full_Access (Etype (gnat_entity));
@@ -4326,11 +4324,11 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target,
parameters.
2. There is no target and the call is made for neither an object nor a
- renaming declaration, nor a return statement, and the return type has
- variable size, because in this case the gimplifier cannot create the
- temporary, or more generally is simply an aggregate type, because the
- gimplifier would create the temporary in the outermost scope instead
- of locally.
+ renaming declaration, nor a return statement, nor an allocator, and
+ the return type has variable size because in this case the gimplifier
+ cannot create the temporary, or more generally is simply an aggregate
+ type, because the gimplifier would then create the temporary in the
+ outermost scope instead of locally.
3. There is a target and it is a slice or an array with fixed size,
and the return type has variable size, because the gimplifier
@@ -4349,6 +4347,8 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target,
&& Nkind (Parent (gnat_node)) != N_Object_Declaration
&& Nkind (Parent (gnat_node)) != N_Object_Renaming_Declaration
&& Nkind (Parent (gnat_node)) != N_Simple_Return_Statement
+ && !(Nkind (Parent (gnat_node)) == N_Qualified_Expression
+ && Nkind (Parent (Parent (gnat_node))) == N_Allocator)
&& AGGREGATE_TYPE_P (gnu_result_type)
&& !TYPE_IS_FAT_POINTER_P (gnu_result_type))
|| (gnu_target
@@ -9702,7 +9702,14 @@ pos_to_constructor (Node_Id gnat_expr, tree gnu_array_type,
gnat_component_type);
else
{
- gnu_expr = gnat_to_gnu (gnat_expr);
+ /* If the expression is a conversion to an unconstrained array type,
+ skip it to avoid spilling to memory. */
+ if (Nkind (gnat_expr) == N_Type_Conversion
+ && Is_Array_Type (Etype (gnat_expr))
+ && !Is_Constrained (Etype (gnat_expr)))
+ gnu_expr = gnat_to_gnu (Expression (gnat_expr));
+ else
+ gnu_expr = gnat_to_gnu (gnat_expr);
/* Before assigning the element to the array, make sure it is
in range. */
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 0a6d6af5b52..6eed8e8b7a6 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -5230,20 +5230,26 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
? TYPE_RM_SIZE (etype)
: TYPE_SIZE (etype)) == 0)))
{
- tree base_type
- = gnat_type_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
- type_unsigned_for_rm (type));
- tree shift_expr
- = convert (base_type,
- size_binop (MINUS_EXPR,
- TYPE_SIZE (type), TYPE_RM_SIZE (type)));
- expr
- = convert (type,
- build_binary_op (RSHIFT_EXPR, base_type,
- build_binary_op (LSHIFT_EXPR, base_type,
- convert (base_type, expr),
- shift_expr),
- shift_expr));
+ if (integer_zerop (TYPE_RM_SIZE (type)))
+ expr = build_int_cst (type, 0);
+ else
+ {
+ tree base_type
+ = gnat_type_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
+ type_unsigned_for_rm (type));
+ tree shift_expr
+ = convert (base_type,
+ size_binop (MINUS_EXPR,
+ TYPE_SIZE (type), TYPE_RM_SIZE (type)));
+ expr
+ = convert (type,
+ build_binary_op (RSHIFT_EXPR, base_type,
+ build_binary_op (LSHIFT_EXPR, base_type,
+ convert (base_type,
+ expr),
+ shift_expr),
+ shift_expr));
+ }
}
/* An unchecked conversion should never raise Constraint_Error. The code
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 7c3f7e601c0..ddf82bdff82 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -21211,9 +21211,11 @@ package body Sem_Ch3 is
Error_Msg_N ("invalid subtype mark in subtype indication", S);
end case;
- -- Size and Convention are always inherited from the base type
+ -- Size, Alignment, Representation aspects and Convention are always
+ -- inherited from the base type.
Set_Size_Info (Def_Id, (Subtype_Mark_Id));
+ Set_Rep_Info (Def_Id, (Subtype_Mark_Id));
Set_Convention (Def_Id, Convention (Subtype_Mark_Id));
return Def_Id;
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 93d8bd58d81..1a7b6ab92af 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -20302,6 +20302,20 @@ package body Sem_Util is
end if;
end Set_Referenced_Modified;
+ ------------------
+ -- Set_Rep_Info --
+ ------------------
+
+ procedure Set_Rep_Info (T1, T2 : Entity_Id) is
+ begin
+ Set_Is_Atomic (T1, Is_Atomic (T2));
+ Set_Is_Independent (T1, Is_Independent (T2));
+ Set_Is_Volatile_Full_Access (T1, Is_Volatile_Full_Access (T2));
+ if Is_Base_Type (T1) then
+ Set_Is_Volatile (T1, Is_Volatile (T2));
+ end if;
+ end Set_Rep_Info;
+
----------------------------
-- Set_Scope_Is_Transient --
----------------------------
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index f9ab8135481..cfec762dcb3 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -2313,6 +2313,12 @@ package Sem_Util is
-- (Referenced_As_LHS if Out_Param is False, Referenced_As_Out_Parameter
-- if Out_Param is True) is set True, and the other flag set False.
+ procedure Set_Rep_Info (T1, T2 : Entity_Id);
+ pragma Inline (Set_Rep_Info);
+ -- Copies the Is_Atomic, Is_Independent and Is_Volatile_Full_Access flags
+ -- from sub(type) entity T2 to (sub)type entity T1, as well as Is_Volatile
+ -- if T1 is a base type.
+
procedure Set_Scope_Is_Transient (V : Boolean := True);
-- Set the flag Is_Transient of the current scope
diff --git a/gcc/asan.c b/gcc/asan.c
index 31bc060eaf1..fa48f789082 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -2315,9 +2315,12 @@ create_odr_indicator (tree decl, tree type)
/* DECL_NAME theoretically might be NULL. Bail out with 0 in this case. */
if (decl_name == NULL_TREE)
return build_int_cst (uptr, 0);
- size_t len = strlen (IDENTIFIER_POINTER (decl_name)) + sizeof ("__odr_asan_");
+ const char *dname = IDENTIFIER_POINTER (decl_name);
+ if (HAS_DECL_ASSEMBLER_NAME_P (decl))
+ dname = targetm.strip_name_encoding (dname);
+ size_t len = strlen (dname) + sizeof ("__odr_asan_");
name = XALLOCAVEC (char, len);
- snprintf (name, len, "__odr_asan_%s", IDENTIFIER_POINTER (decl_name));
+ snprintf (name, len, "__odr_asan_%s", dname);
#ifndef NO_DOT_IN_LABEL
name[sizeof ("__odr_asan") - 1] = '.';
#elif !defined(NO_DOLLAR_IN_LABEL)
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index a8d42564c4b..b297fea5de8 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -2881,7 +2881,8 @@ pass_partition_blocks::execute (function *fun)
crossing_edges = find_rarely_executed_basic_blocks_and_crossing_edges ();
if (!crossing_edges.exists ())
- return 0;
+ /* Make sure to process deferred rescans and clear changeable df flags. */
+ return TODO_df_finish;
crtl->has_bb_partition = true;
@@ -2947,7 +2948,8 @@ pass_partition_blocks::execute (function *fun)
df_analyze ();
}
- return 0;
+ /* Make sure to process deferred rescans and clear changeable df flags. */
+ return TODO_df_finish;
}
} // anon namespace
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 264200b050e..14482a53d3f 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,18 @@
+2017-09-10 Jonathan Wakely <jwakely@redhat.com>
+
+ PR c++/81852
+ * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_threadsafe_static_init.
+
+2017-09-07 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2017-07-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/45784
+ * c-omp.c (c_finish_omp_for): If the condition is wrapped in
+ rhs of COMPOUND_EXPR(s), skip them and readd their lhs into
+ new COMPOUND_EXPRs around the rhs of the comparison.
+
2017-08-14 Release Manager
* GCC 7.2.0 released.
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 083d5fdf4cf..c5fadaa6aa2 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -987,6 +987,8 @@ c_cpp_builtins (cpp_reader *pfile)
}
if (flag_new_ttp)
cpp_define (pfile, "__cpp_template_template_args=201611");
+ if (flag_threadsafe_statics)
+ cpp_define (pfile, "__cpp_threadsafe_static_init=200806");
}
/* Note that we define this for C as well, so that we know if
__attribute__((cleanup)) will interface with EH. */
diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index 519c4e4ce66..977cb0ea153 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -531,6 +531,12 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv,
{
bool cond_ok = false;
+ /* E.g. C sizeof (vla) could add COMPOUND_EXPRs with
+ evaluation of the vla VAR_DECL. We need to readd
+ them to the non-decl operand. See PR45784. */
+ while (TREE_CODE (cond) == COMPOUND_EXPR)
+ cond = TREE_OPERAND (cond, 1);
+
if (EXPR_HAS_LOCATION (cond))
elocus = EXPR_LOCATION (cond);
@@ -605,6 +611,21 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv,
else if (code != CILK_SIMD && code != CILK_FOR)
cond_ok = false;
}
+
+ if (cond_ok && TREE_VEC_ELT (condv, i) != cond)
+ {
+ tree ce = NULL_TREE, *pce = &ce;
+ tree type = TREE_TYPE (TREE_OPERAND (cond, 1));
+ for (tree c = TREE_VEC_ELT (condv, i); c != cond;
+ c = TREE_OPERAND (c, 1))
+ {
+ *pce = build2 (COMPOUND_EXPR, type, TREE_OPERAND (c, 0),
+ TREE_OPERAND (cond, 1));
+ pce = &TREE_OPERAND (*pce, 1);
+ }
+ TREE_OPERAND (cond, 1) = ce;
+ TREE_VEC_ELT (condv, i) = cond;
+ }
}
if (!cond_ok)
diff --git a/gcc/calls.c b/gcc/calls.c
index 68721767429..b183be63dd4 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -1220,32 +1220,38 @@ alloc_max_size (void)
else if (!strcasecmp (end, "KiB") || strcmp (end, "KB"))
unit = 1024;
else if (!strcmp (end, "MB"))
- unit = 1000LU * 1000;
+ unit = HOST_WIDE_INT_UC (1000) * 1000;
else if (!strcasecmp (end, "MiB"))
- unit = 1024LU * 1024;
+ unit = HOST_WIDE_INT_UC (1024) * 1024;
else if (!strcasecmp (end, "GB"))
- unit = 1000LU * 1000 * 1000;
+ unit = HOST_WIDE_INT_UC (1000) * 1000 * 1000;
else if (!strcasecmp (end, "GiB"))
- unit = 1024LU * 1024 * 1024;
+ unit = HOST_WIDE_INT_UC (1024) * 1024 * 1024;
else if (!strcasecmp (end, "TB"))
- unit = 1000LU * 1000 * 1000 * 1000;
+ unit = HOST_WIDE_INT_UC (1000) * 1000 * 1000 * 1000;
else if (!strcasecmp (end, "TiB"))
- unit = 1024LU * 1024 * 1024 * 1024;
+ unit = HOST_WIDE_INT_UC (1024) * 1024 * 1024 * 1024;
else if (!strcasecmp (end, "PB"))
- unit = 1000LU * 1000 * 1000 * 1000 * 1000;
+ unit = HOST_WIDE_INT_UC (1000) * 1000 * 1000 * 1000 * 1000;
else if (!strcasecmp (end, "PiB"))
- unit = 1024LU * 1024 * 1024 * 1024 * 1024;
+ unit = HOST_WIDE_INT_UC (1024) * 1024 * 1024 * 1024 * 1024;
else if (!strcasecmp (end, "EB"))
- unit = 1000LU * 1000 * 1000 * 1000 * 1000 * 1000;
+ unit = HOST_WIDE_INT_UC (1000) * 1000 * 1000 * 1000 * 1000
+ * 1000;
else if (!strcasecmp (end, "EiB"))
- unit = 1024LU * 1024 * 1024 * 1024 * 1024 * 1024;
+ unit = HOST_WIDE_INT_UC (1024) * 1024 * 1024 * 1024 * 1024
+ * 1024;
else
unit = 0;
}
if (unit)
- alloc_object_size_limit
- = build_int_cst (ssizetype, limit * unit);
+ {
+ wide_int w = wi::uhwi (limit, HOST_BITS_PER_WIDE_INT + 64);
+ w *= unit;
+ if (wi::ltu_p (w, alloc_object_size_limit))
+ alloc_object_size_limit = wide_int_to_tree (ssizetype, w);
+ }
}
}
}
diff --git a/gcc/config.gcc b/gcc/config.gcc
index b7ef01dd2ae..56d3953a47d 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2416,7 +2416,7 @@ powerpc-*-eabi*)
;;
powerpc-*-rtems*)
tm_file="rs6000/biarch64.h ${tm_file} dbxelf.h elfos.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/e500.h rs6000/rtems.h rtems.h"
- extra_options="${extra_options} rs6000/sysv4.opt"
+ extra_options="${extra_options} rs6000/sysv4.opt rs6000/linux64.opt"
tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-rtems rs6000/t-ppccomm"
;;
powerpc*-*-linux*)
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index c3bd06a5d49..ee3bd66e93f 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -1095,7 +1095,7 @@ avr_set_current_function (tree decl)
|| 0 == strcmp ("INTERRUPT", name)
|| 0 == strcmp ("SIGNAL", name))
{
- warning_at (loc, OPT_Wmisspelled_isr, "%qs is a reserved indentifier"
+ warning_at (loc, OPT_Wmisspelled_isr, "%qs is a reserved identifier"
" in AVR-LibC. Consider %<#include <avr/interrupt.h>%>"
" before using the %qs macro", name, name);
}
@@ -9549,10 +9549,12 @@ avr_handle_addr_attribute (tree *node, tree name, tree args,
bool io_p = (strncmp (IDENTIFIER_POINTER (name), "io", 2) == 0);
location_t loc = DECL_SOURCE_LOCATION (*node);
- if (TREE_CODE (*node) != VAR_DECL)
+ if (!VAR_P (*node))
{
- warning_at (loc, 0, "%qE attribute only applies to variables", name);
+ warning_at (loc, OPT_Wattributes, "%qE attribute only applies to "
+ "variables", name);
*no_add = true;
+ return NULL_TREE;
}
if (args != NULL_TREE)
@@ -9562,8 +9564,8 @@ avr_handle_addr_attribute (tree *node, tree name, tree args,
tree arg = TREE_VALUE (args);
if (TREE_CODE (arg) != INTEGER_CST)
{
- warning (0, "%qE attribute allows only an integer constant argument",
- name);
+ warning_at (loc, OPT_Wattributes, "%qE attribute allows only an "
+ "integer constant argument", name);
*no_add = true;
}
else if (io_p
@@ -9572,19 +9574,20 @@ avr_handle_addr_attribute (tree *node, tree name, tree args,
? low_io_address_operand : io_address_operand)
(GEN_INT (TREE_INT_CST_LOW (arg)), QImode)))
{
- warning_at (loc, 0, "%qE attribute address out of range", name);
+ warning_at (loc, OPT_Wattributes, "%qE attribute address "
+ "out of range", name);
*no_add = true;
}
else
{
tree attribs = DECL_ATTRIBUTES (*node);
- const char *names[] = { "io", "io_low", "address", NULL } ;
+ const char *names[] = { "io", "io_low", "address", NULL };
for (const char **p = names; *p; p++)
{
tree other = lookup_attribute (*p, attribs);
if (other && TREE_VALUE (other))
{
- warning_at (loc, 0,
+ warning_at (loc, OPT_Wattributes,
"both %s and %qE attribute provide address",
*p, name);
*no_add = true;
@@ -9595,7 +9598,8 @@ avr_handle_addr_attribute (tree *node, tree name, tree args,
}
if (*no_add == false && io_p && !TREE_THIS_VOLATILE (*node))
- warning_at (loc, 0, "%qE attribute on non-volatile variable", name);
+ warning_at (loc, OPT_Wattributes, "%qE attribute on non-volatile variable",
+ name);
return NULL_TREE;
}
@@ -9643,11 +9647,11 @@ avr_attribute_table[] =
false },
{ "OS_main", 0, 0, false, true, true, avr_handle_fntype_attribute,
false },
- { "io", 0, 1, false, false, false, avr_handle_addr_attribute,
+ { "io", 0, 1, true, false, false, avr_handle_addr_attribute,
false },
- { "io_low", 0, 1, false, false, false, avr_handle_addr_attribute,
+ { "io_low", 0, 1, true, false, false, avr_handle_addr_attribute,
false },
- { "address", 1, 1, false, false, false, avr_handle_addr_attribute,
+ { "address", 1, 1, true, false, false, avr_handle_addr_attribute,
false },
{ "absdata", 0, 0, true, false, false, avr_handle_absdata_attribute,
false },
diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 2787a3d16be..de605b0c466 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -50,19 +50,28 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined HAVE_LD_PIE
#define GNU_USER_TARGET_STARTFILE_SPEC \
- "%{!shared: %{pg|p|profile:gcrt1.o%s;: \
- %{" PIE_SPEC ":Scrt1.o%s} %{" NO_PIE_SPEC ":crt1.o%s}}} \
- crti.o%s %{static:crtbeginT.o%s;: %{shared:crtbeginS.o%s} \
- %{" PIE_SPEC ":crtbeginS.o%s} \
- %{" NO_PIE_SPEC ":crtbegin.o%s}} \
+ "%{shared:; \
+ pg|p|profile:gcrt1.o%s; \
+ static:crt1.o%s; \
+ " PIE_SPEC ":Scrt1.o%s; \
+ :crt1.o%s} \
+ crti.o%s \
+ %{static:crtbeginT.o%s; \
+ shared|" PIE_SPEC ":crtbeginS.o%s; \
+ :crtbegin.o%s} \
%{fvtable-verify=none:%s; \
fvtable-verify=preinit:vtv_start_preinit.o%s; \
fvtable-verify=std:vtv_start.o%s} \
" CRTOFFLOADBEGIN
#else
#define GNU_USER_TARGET_STARTFILE_SPEC \
- "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
- crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \
+ "%{shared:; \
+ pg|p|profile:gcrt1.o%s; \
+ :crt1.o%s} \
+ crti.o%s \
+ %{static:crtbeginT.o%s; \
+ shared|pie:crtbeginS.o%s; \
+ :crtbegin.o%s} \
%{fvtable-verify=none:%s; \
fvtable-verify=preinit:vtv_start_preinit.o%s; \
fvtable-verify=std:vtv_start.o%s} \
@@ -82,15 +91,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
"%{fvtable-verify=none:%s; \
fvtable-verify=preinit:vtv_end_preinit.o%s; \
fvtable-verify=std:vtv_end.o%s} \
- %{shared:crtendS.o%s;: %{" PIE_SPEC ":crtendS.o%s} \
- %{" NO_PIE_SPEC ":crtend.o%s}} crtn.o%s \
+ %{static:crtend.o%s; \
+ shared|" PIE_SPEC ":crtendS.o%s; \
+ :crtend.o%s} \
+ crtn.o%s \
" CRTOFFLOADEND
#else
#define GNU_USER_TARGET_ENDFILE_SPEC \
"%{fvtable-verify=none:%s; \
fvtable-verify=preinit:vtv_end_preinit.o%s; \
fvtable-verify=std:vtv_end.o%s} \
- %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s \
+ %{static:crtend.o%s; \
+ shared|pie:crtendS.o%s; \
+ :crtend.o%s} \
+ crtn.o%s \
" CRTOFFLOADEND
#endif
#undef ENDFILE_SPEC
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 423e97c5040..47a28055cab 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -85,6 +85,9 @@ along with GCC; see the file COPYING3. If not see
#include "print-rtl.h"
#include "intl.h"
#include "ifcvt.h"
+#include "symbol-summary.h"
+#include "ipa-prop.h"
+#include "ipa-inline.h"
/* This file should be included last. */
#include "target-def.h"
@@ -6288,12 +6291,6 @@ ix86_option_override_internal (bool main_args_p,
gcc_assert ((opts->x_target_flags & MASK_LONG_DOUBLE_64) == 0
|| (opts->x_target_flags & MASK_LONG_DOUBLE_128) == 0);
- /* Save the initial options in case the user does function specific
- options. */
- if (main_args_p)
- target_option_default_node = target_option_current_node
- = build_target_option_node (opts);
-
/* Handle stack protector */
if (!opts_set->x_ix86_stack_protector_guard)
opts->x_ix86_stack_protector_guard
@@ -6314,6 +6311,12 @@ ix86_option_override_internal (bool main_args_p,
free (str);
}
+ /* Save the initial options in case the user does function specific
+ options. */
+ if (main_args_p)
+ target_option_default_node = target_option_current_node
+ = build_target_option_node (opts);
+
return true;
}
@@ -7114,7 +7117,14 @@ ix86_can_inline_p (tree caller, tree callee)
else if (caller_opts->tune != callee_opts->tune)
ret = false;
- else if (caller_opts->x_ix86_fpmath != callee_opts->x_ix86_fpmath)
+ else if (caller_opts->x_ix86_fpmath != callee_opts->x_ix86_fpmath
+ /* If the calle doesn't use FP expressions differences in
+ ix86_fpmath can be ignored. We are called from FEs
+ for multi-versioning call optimization, so beware of
+ inline_summaries not available. */
+ && (! inline_summaries
+ || inline_summaries->get
+ (cgraph_node::get (callee))->fp_expressions))
ret = false;
else if (caller_opts->branch_cost != callee_opts->branch_cost)
diff --git a/gcc/config/riscv/rtems.h b/gcc/config/riscv/rtems.h
new file mode 100644
index 00000000000..221e2f69815
--- /dev/null
+++ b/gcc/config/riscv/rtems.h
@@ -0,0 +1,31 @@
+/* Definitions for RISC-V RTEMS systems with ELF format.
+ Copyright (C) 2017 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC 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.
+
+ GCC 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.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \
+ do { \
+ builtin_define ("__rtems__"); \
+ builtin_define ("__USE_INIT_FINI__"); \
+ builtin_assert ("system=rtems"); \
+ } while (0)
diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md
index 649f1810d16..2ad21619df9 100644
--- a/gcc/config/rs6000/altivec.md
+++ b/gcc/config/rs6000/altivec.md
@@ -1749,51 +1749,61 @@
"vsum4s<VI_char>s %0,%1,%2"
[(set_attr "type" "veccomplex")])
-;; FIXME: For the following two patterns, the scratch should only be
-;; allocated for !VECTOR_ELT_ORDER_BIG, and the instructions should
-;; be emitted separately.
-(define_insn "altivec_vsum2sws"
- [(set (match_operand:V4SI 0 "register_operand" "=v")
- (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
- (match_operand:V4SI 2 "register_operand" "v")]
- UNSPEC_VSUM2SWS))
- (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))
- (clobber (match_scratch:V4SI 3 "=v"))]
+(define_expand "altivec_vsum2sws"
+ [(use (match_operand:V4SI 0 "register_operand"))
+ (use (match_operand:V4SI 1 "register_operand"))
+ (use (match_operand:V4SI 2 "register_operand"))]
"TARGET_ALTIVEC"
{
if (VECTOR_ELT_ORDER_BIG)
- return "vsum2sws %0,%1,%2";
+ emit_insn (gen_altivec_vsum2sws_direct (operands[0], operands[1],
+ operands[2]));
else
- return "vsldoi %3,%2,%2,12\n\tvsum2sws %3,%1,%3\n\tvsldoi %0,%3,%3,4";
-}
- [(set_attr "type" "veccomplex")
- (set (attr "length")
- (if_then_else
- (match_test "VECTOR_ELT_ORDER_BIG")
- (const_string "4")
- (const_string "12")))])
-
-(define_insn "altivec_vsumsws"
+ {
+ rtx tmp1 = gen_reg_rtx (V4SImode);
+ rtx tmp2 = gen_reg_rtx (V4SImode);
+ emit_insn (gen_altivec_vsldoi_v4si (tmp1, operands[2],
+ operands[2], GEN_INT (12)));
+ emit_insn (gen_altivec_vsum2sws_direct (tmp2, operands[1], tmp1));
+ emit_insn (gen_altivec_vsldoi_v4si (operands[0], tmp2, tmp2,
+ GEN_INT (4)));
+ }
+ DONE;
+})
+
+; FIXME: This can probably be expressed without an UNSPEC.
+(define_insn "altivec_vsum2sws_direct"
[(set (match_operand:V4SI 0 "register_operand" "=v")
(unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
- (match_operand:V4SI 2 "register_operand" "v")]
- UNSPEC_VSUMSWS))
- (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))
- (clobber (match_scratch:V4SI 3 "=v"))]
+ (match_operand:V4SI 2 "register_operand" "v")]
+ UNSPEC_VSUM2SWS))
+ (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
+ "TARGET_ALTIVEC"
+ "vsum2sws %0,%1,%2"
+ [(set_attr "type" "veccomplex")])
+
+(define_expand "altivec_vsumsws"
+ [(use (match_operand:V4SI 0 "register_operand"))
+ (use (match_operand:V4SI 1 "register_operand"))
+ (use (match_operand:V4SI 2 "register_operand"))]
"TARGET_ALTIVEC"
{
if (VECTOR_ELT_ORDER_BIG)
- return "vsumsws %0,%1,%2";
+ emit_insn (gen_altivec_vsumsws_direct (operands[0], operands[1],
+ operands[2]));
else
- return "vspltw %3,%2,0\n\tvsumsws %3,%1,%3\n\tvsldoi %0,%3,%3,12";
-}
- [(set_attr "type" "veccomplex")
- (set (attr "length")
- (if_then_else
- (match_test "(VECTOR_ELT_ORDER_BIG)")
- (const_string "4")
- (const_string "12")))])
+ {
+ rtx tmp1 = gen_reg_rtx (V4SImode);
+ rtx tmp2 = gen_reg_rtx (V4SImode);
+ emit_insn (gen_altivec_vspltw_direct (tmp1, operands[2], const0_rtx));
+ emit_insn (gen_altivec_vsumsws_direct (tmp2, operands[1], tmp1));
+ emit_insn (gen_altivec_vsldoi_v4si (operands[0], tmp2, tmp2,
+ GEN_INT (12)));
+ }
+ DONE;
+})
+; FIXME: This can probably be expressed without an UNSPEC.
(define_insn "altivec_vsumsws_direct"
[(set (match_operand:V4SI 0 "register_operand" "=v")
(unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index db9136f264d..a7ec6846b70 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -5766,8 +5766,20 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
if (SCALAR_FLOAT_TYPE_P (elem_type)
&& TYPE_PRECISION (elem_type) == 32)
return 5;
+ /* On POWER9, integer vector types are built up in GPRs and then
+ use a direct move (2 cycles). For POWER8 this is even worse,
+ as we need two direct moves and a merge, and the direct moves
+ are five cycles. */
+ else if (INTEGRAL_TYPE_P (elem_type))
+ {
+ if (TARGET_P9_VECTOR)
+ return TYPE_VECTOR_SUBPARTS (vectype) - 1 + 2;
+ else
+ return TYPE_VECTOR_SUBPARTS (vectype) - 1 + 5;
+ }
else
- return max (2, TYPE_VECTOR_SUBPARTS (vectype) - 1);
+ /* V2DFmode doesn't need a direct move. */
+ return 2;
default:
gcc_unreachable ();
@@ -39555,23 +39567,30 @@ rs6000_pragma_target_parse (tree args, tree pop_target)
/* Remember the last target of rs6000_set_current_function. */
static GTY(()) tree rs6000_previous_fndecl;
+/* Restore target's globals from NEW_TREE and invalidate the
+ rs6000_previous_fndecl cache. */
+
+static void
+rs6000_activate_target_options (tree new_tree)
+{
+ cl_target_option_restore (&global_options, TREE_TARGET_OPTION (new_tree));
+ if (TREE_TARGET_GLOBALS (new_tree))
+ restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
+ else if (new_tree == target_option_default_node)
+ restore_target_globals (&default_target_globals);
+ else
+ TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
+ rs6000_previous_fndecl = NULL_TREE;
+}
+
/* Establish appropriate back-end context for processing the function
FNDECL. The argument might be NULL to indicate processing at top
level, outside of any function scope. */
static void
rs6000_set_current_function (tree fndecl)
{
- tree old_tree = (rs6000_previous_fndecl
- ? DECL_FUNCTION_SPECIFIC_TARGET (rs6000_previous_fndecl)
- : NULL_TREE);
-
- tree new_tree = (fndecl
- ? DECL_FUNCTION_SPECIFIC_TARGET (fndecl)
- : NULL_TREE);
-
if (TARGET_DEBUG_TARGET)
{
- bool print_final = false;
fprintf (stderr, "\n==================== rs6000_set_current_function");
if (fndecl)
@@ -39584,58 +39603,60 @@ rs6000_set_current_function (tree fndecl)
fprintf (stderr, ", prev_fndecl (%p)", (void *)rs6000_previous_fndecl);
fprintf (stderr, "\n");
+ }
+
+ /* Only change the context if the function changes. This hook is called
+ several times in the course of compiling a function, and we don't want to
+ slow things down too much or call target_reinit when it isn't safe. */
+ if (fndecl == rs6000_previous_fndecl)
+ return;
+
+ tree old_tree;
+ if (rs6000_previous_fndecl == NULL_TREE)
+ old_tree = target_option_current_node;
+ else if (DECL_FUNCTION_SPECIFIC_TARGET (rs6000_previous_fndecl))
+ old_tree = DECL_FUNCTION_SPECIFIC_TARGET (rs6000_previous_fndecl);
+ else
+ old_tree = target_option_default_node;
+
+ tree new_tree;
+ if (fndecl == NULL_TREE)
+ {
+ if (old_tree != target_option_current_node)
+ new_tree = target_option_current_node;
+ else
+ new_tree = NULL_TREE;
+ }
+ else
+ {
+ new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
+ if (new_tree == NULL_TREE)
+ new_tree = target_option_default_node;
+ }
+
+ if (TARGET_DEBUG_TARGET)
+ {
if (new_tree)
{
fprintf (stderr, "\nnew fndecl target specific options:\n");
debug_tree (new_tree);
- print_final = true;
}
if (old_tree)
{
fprintf (stderr, "\nold fndecl target specific options:\n");
debug_tree (old_tree);
- print_final = true;
}
- if (print_final)
+ if (old_tree != NULL_TREE || new_tree != NULL_TREE)
fprintf (stderr, "--------------------\n");
}
- /* Only change the context if the function changes. This hook is called
- several times in the course of compiling a function, and we don't want to
- slow things down too much or call target_reinit when it isn't safe. */
- if (fndecl && fndecl != rs6000_previous_fndecl)
- {
- rs6000_previous_fndecl = fndecl;
- if (old_tree == new_tree)
- ;
-
- else if (new_tree && new_tree != target_option_default_node)
- {
- cl_target_option_restore (&global_options,
- TREE_TARGET_OPTION (new_tree));
- if (TREE_TARGET_GLOBALS (new_tree))
- restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
- else
- TREE_TARGET_GLOBALS (new_tree)
- = save_target_globals_default_opts ();
- }
+ if (new_tree && old_tree != new_tree)
+ rs6000_activate_target_options (new_tree);
- else if (old_tree && old_tree != target_option_default_node)
- {
- new_tree = target_option_current_node;
- cl_target_option_restore (&global_options,
- TREE_TARGET_OPTION (new_tree));
- if (TREE_TARGET_GLOBALS (new_tree))
- restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
- else if (new_tree == target_option_default_node)
- restore_target_globals (&default_target_globals);
- else
- TREE_TARGET_GLOBALS (new_tree)
- = save_target_globals_default_opts ();
- }
- }
+ if (fndecl)
+ rs6000_previous_fndecl = fndecl;
}
@@ -42693,9 +42714,10 @@ alignment_mask (rtx_insn *insn)
}
/* Given INSN that's a load or store based at BASE_REG, look for a
- feeding computation that aligns its address on a 16-byte boundary. */
+ feeding computation that aligns its address on a 16-byte boundary.
+ Return the rtx and its containing AND_INSN. */
static rtx
-find_alignment_op (rtx_insn *insn, rtx base_reg)
+find_alignment_op (rtx_insn *insn, rtx base_reg, rtx_insn **and_insn)
{
df_ref base_use;
struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
@@ -42716,8 +42738,8 @@ find_alignment_op (rtx_insn *insn, rtx base_reg)
if (DF_REF_IS_ARTIFICIAL (base_def_link->ref))
break;
- rtx_insn *and_insn = DF_REF_INSN (base_def_link->ref);
- and_operation = alignment_mask (and_insn);
+ *and_insn = DF_REF_INSN (base_def_link->ref);
+ and_operation = alignment_mask (*and_insn);
if (and_operation != 0)
break;
}
@@ -42739,7 +42761,8 @@ recombine_lvx_pattern (rtx_insn *insn, del_info *to_delete)
rtx mem = XEXP (SET_SRC (body), 0);
rtx base_reg = XEXP (mem, 0);
- rtx and_operation = find_alignment_op (insn, base_reg);
+ rtx_insn *and_insn;
+ rtx and_operation = find_alignment_op (insn, base_reg, &and_insn);
if (and_operation != 0)
{
@@ -42763,7 +42786,21 @@ recombine_lvx_pattern (rtx_insn *insn, del_info *to_delete)
to_delete[INSN_UID (swap_insn)].replace = true;
to_delete[INSN_UID (swap_insn)].replace_insn = swap_insn;
- XEXP (mem, 0) = and_operation;
+ /* However, first we must be sure that we make the
+ base register from the AND operation available
+ in case the register has been overwritten. Copy
+ the base register to a new pseudo and use that
+ as the base register of the AND operation in
+ the new LVX instruction. */
+ rtx and_base = XEXP (and_operation, 0);
+ rtx new_reg = gen_reg_rtx (GET_MODE (and_base));
+ rtx copy = gen_rtx_SET (new_reg, and_base);
+ rtx_insn *new_insn = emit_insn_after (copy, and_insn);
+ set_block_for_insn (new_insn, BLOCK_FOR_INSN (and_insn));
+ df_insn_rescan (new_insn);
+
+ XEXP (mem, 0) = gen_rtx_AND (GET_MODE (and_base), new_reg,
+ XEXP (and_operation, 1));
SET_SRC (body) = mem;
INSN_CODE (insn) = -1; /* Force re-recognition. */
df_insn_rescan (insn);
@@ -42786,7 +42823,8 @@ recombine_stvx_pattern (rtx_insn *insn, del_info *to_delete)
rtx mem = SET_DEST (body);
rtx base_reg = XEXP (mem, 0);
- rtx and_operation = find_alignment_op (insn, base_reg);
+ rtx_insn *and_insn;
+ rtx and_operation = find_alignment_op (insn, base_reg, &and_insn);
if (and_operation != 0)
{
@@ -42814,7 +42852,21 @@ recombine_stvx_pattern (rtx_insn *insn, del_info *to_delete)
to_delete[INSN_UID (swap_insn)].replace = true;
to_delete[INSN_UID (swap_insn)].replace_insn = swap_insn;
- XEXP (mem, 0) = and_operation;
+ /* However, first we must be sure that we make the
+ base register from the AND operation available
+ in case the register has been overwritten. Copy
+ the base register to a new pseudo and use that
+ as the base register of the AND operation in
+ the new STVX instruction. */
+ rtx and_base = XEXP (and_operation, 0);
+ rtx new_reg = gen_reg_rtx (GET_MODE (and_base));
+ rtx copy = gen_rtx_SET (new_reg, and_base);
+ rtx_insn *new_insn = emit_insn_after (copy, and_insn);
+ set_block_for_insn (new_insn, BLOCK_FOR_INSN (and_insn));
+ df_insn_rescan (new_insn);
+
+ XEXP (mem, 0) = gen_rtx_AND (GET_MODE (and_base), new_reg,
+ XEXP (and_operation, 1));
SET_SRC (body) = src_reg;
INSN_CODE (insn) = -1; /* Force re-recognition. */
df_insn_rescan (insn);
diff --git a/gcc/config/rs6000/rtems.h b/gcc/config/rs6000/rtems.h
index 8a62fdcbaf3..7ea9ebdb77b 100644
--- a/gcc/config/rs6000/rtems.h
+++ b/gcc/config/rs6000/rtems.h
@@ -37,6 +37,15 @@
#undef TARGET_AIX
#define TARGET_AIX TARGET_64BIT
+/* Simplified copy and paste from linux64.h and freebsd64.h */
+#undef DOT_SYMBOLS
+#define DOT_SYMBOLS 0
+
+/* Copy and paste from linux64.h and freebsd64.h */
+#undef TARGET_CMODEL
+#define TARGET_CMODEL rs6000_current_cmodel
+#define SET_CMODEL(opt) rs6000_current_cmodel = opt
+
#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS() \
do \
@@ -64,6 +73,15 @@
while (0)
/* Copy and paste from linux64.h and freebsd64.h */
+#undef RELOCATABLE_NEEDS_FIXUP
+#define RELOCATABLE_NEEDS_FIXUP \
+ (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
+
+/* Copy and paste from linux64.h */
+#undef RS6000_ABI_NAME
+#define RS6000_ABI_NAME "linux"
+
+/* Copy and paste from linux64.h and freebsd64.h */
#define INVALID_64BIT "-m%s not supported in this configuration"
/* A lot of copy and paste from linux64.h and freebsd64.h */
@@ -95,6 +113,24 @@
rs6000_isa_flags |= OPTION_MASK_POWERPC64; \
error ("-m64 requires a PowerPC64 cpu"); \
} \
+ if ((rs6000_isa_flags_explicit \
+ & OPTION_MASK_MINIMAL_TOC) != 0) \
+ { \
+ if (global_options_set.x_rs6000_current_cmodel \
+ && rs6000_current_cmodel != CMODEL_SMALL) \
+ error ("-mcmodel incompatible with other toc options"); \
+ SET_CMODEL (CMODEL_SMALL); \
+ } \
+ else \
+ { \
+ if (!global_options_set.x_rs6000_current_cmodel) \
+ SET_CMODEL (CMODEL_MEDIUM); \
+ if (rs6000_current_cmodel != CMODEL_SMALL) \
+ { \
+ TARGET_NO_FP_IN_TOC = 0; \
+ TARGET_NO_SUM_IN_TOC = 0; \
+ } \
+ } \
} \
} \
while (0)
@@ -141,6 +177,30 @@
#define RESTORE_FP_SUFFIX ""
/* Copy and paste from linux64.h and freebsd64.h */
+#undef ASM_PREFERRED_EH_DATA_FORMAT
+#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
+ (TARGET_64BIT || flag_pic \
+ ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
+ | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
+ : DW_EH_PE_absptr)
+
+/* Copy and paste from linux64.h and freebsd64.h */
+#undef TOC_SECTION_ASM_OP
+#define TOC_SECTION_ASM_OP \
+ (TARGET_64BIT \
+ ? "\t.section\t\".toc\",\"aw\"" \
+ : "\t.section\t\".got\",\"aw\"")
+
+/* Copy and paste from linux64.h and freebsd64.h */
+#undef MINIMAL_TOC_SECTION_ASM_OP
+#define MINIMAL_TOC_SECTION_ASM_OP \
+ (TARGET_64BIT \
+ ? "\t.section\t\".toc1\",\"aw\"" \
+ : (flag_pic \
+ ? "\t.section\t\".got2\",\"aw\"" \
+ : "\t.section\t\".got1\",\"aw\""))
+
+/* Copy and paste from linux64.h and freebsd64.h */
#undef ASM_DECLARE_FUNCTION_SIZE
#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
do \
diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
index de386291a51..cbee89140dd 100644
--- a/gcc/config/rs6000/sysv4.h
+++ b/gcc/config/rs6000/sysv4.h
@@ -757,24 +757,34 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
#define CRTOFFLOADEND ""
#endif
-#ifdef HAVE_LD_PIE
-#define STARTFILE_LINUX_SPEC "\
-%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
-%{mnewlib:ecrti.o%s;:crti.o%s} \
-%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \
-" CRTOFFLOADBEGIN
-#else
-#define STARTFILE_LINUX_SPEC "\
-%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
-%{mnewlib:ecrti.o%s;:crti.o%s} \
-%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \
-" CRTOFFLOADBEGIN
-#endif
-
-#define ENDFILE_LINUX_SPEC "\
-%{shared|pie:crtendS.o%s;:crtend.o%s} \
-%{mnewlib:ecrtn.o%s;:crtn.o%s} \
-" CRTOFFLOADEND
+/* STARTFILE_LINUX_SPEC should be the same as GNU_USER_TARGET_STARTFILE_SPEC
+ but with the mnewlib ecrti.o%s selection substituted for crti.o%s. */
+#define STARTFILE_LINUX_SPEC \
+ "%{shared:; \
+ pg|p|profile:gcrt1.o%s; \
+ static:crt1.o%s; \
+ " PIE_SPEC ":Scrt1.o%s; \
+ :crt1.o%s} \
+ %{mnewlib:ecrti.o%s;:crti.o%s} \
+ %{static:crtbeginT.o%s; \
+ shared|" PIE_SPEC ":crtbeginS.o%s; \
+ :crtbegin.o%s} \
+ %{fvtable-verify=none:%s; \
+ fvtable-verify=preinit:vtv_start_preinit.o%s; \
+ fvtable-verify=std:vtv_start.o%s} \
+ " CRTOFFLOADBEGIN
+
+/* ENDFILE_LINUX_SPEC should be the same as GNU_USER_TARGET_ENDFILE_SPEC
+ but with the mnewlib ecrtn.o%s selection substituted for crtn.o%s. */
+#define ENDFILE_LINUX_SPEC \
+ "%{fvtable-verify=none:%s; \
+ fvtable-verify=preinit:vtv_end_preinit.o%s; \
+ fvtable-verify=std:vtv_end.o%s} \
+ %{static:crtend.o%s; \
+ shared|" PIE_SPEC ":crtendS.o%s; \
+ :crtend.o%s} \
+ %{mnewlib:ecrtn.o%s;:crtn.o%s} \
+ " CRTOFFLOADEND
#define LINK_START_LINUX_SPEC ""
diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index 71b897bd97f..449574b893c 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -736,17 +736,20 @@
;; special V1TI container class, which it is not appropriate to use vec_select
;; for the type.
(define_insn "*vsx_le_permute_<mode>"
- [(set (match_operand:VSX_LE_128 0 "nonimmediate_operand" "=<VSa>,<VSa>,Z")
+ [(set (match_operand:VSX_LE_128 0 "nonimmediate_operand" "=<VSa>,<VSa>,Z,&r,&r,Q")
(rotate:VSX_LE_128
- (match_operand:VSX_LE_128 1 "input_operand" "<VSa>,Z,<VSa>")
+ (match_operand:VSX_LE_128 1 "input_operand" "<VSa>,Z,<VSa>,r,Q,r")
(const_int 64)))]
"!BYTES_BIG_ENDIAN && TARGET_VSX && !TARGET_P9_VECTOR"
"@
xxpermdi %x0,%x1,%x1,2
lxvd2x %x0,%y1
- stxvd2x %x1,%y0"
- [(set_attr "length" "4")
- (set_attr "type" "vecperm,vecload,vecstore")])
+ stxvd2x %x1,%y0
+ mr %0,%L1\;mr %L0,%1
+ ld%U1%X1 %0,%L1\;ld%U1%X1 %L0,%1
+ std%U0%X0 %L1,%0\;std%U0%X0 %1,%L0"
+ [(set_attr "length" "4,4,4,8,8,8")
+ (set_attr "type" "vecperm,vecload,vecstore,*,load,store")])
(define_insn_and_split "*vsx_le_undo_permute_<mode>"
[(set (match_operand:VSX_LE_128 0 "vsx_register_operand" "=<VSa>,<VSa>")
@@ -772,10 +775,12 @@
(set_attr "type" "veclogical")])
(define_insn_and_split "*vsx_le_perm_load_<mode>"
- [(set (match_operand:VSX_LE_128 0 "vsx_register_operand" "=<VSa>")
- (match_operand:VSX_LE_128 1 "memory_operand" "Z"))]
+ [(set (match_operand:VSX_LE_128 0 "vsx_register_operand" "=<VSa>,r")
+ (match_operand:VSX_LE_128 1 "memory_operand" "Z,Q"))]
"!BYTES_BIG_ENDIAN && TARGET_VSX && !TARGET_P9_VECTOR"
- "#"
+ "@
+ #
+ #"
"!BYTES_BIG_ENDIAN && TARGET_VSX && !TARGET_P9_VECTOR"
[(set (match_dup 2)
(rotate:VSX_LE_128 (match_dup 1)
@@ -789,16 +794,18 @@
: operands[0];
}
"
- [(set_attr "type" "vecload")
- (set_attr "length" "8")])
+ [(set_attr "type" "vecload,load")
+ (set_attr "length" "8,8")])
(define_insn "*vsx_le_perm_store_<mode>"
- [(set (match_operand:VSX_LE_128 0 "memory_operand" "=Z")
- (match_operand:VSX_LE_128 1 "vsx_register_operand" "+<VSa>"))]
+ [(set (match_operand:VSX_LE_128 0 "memory_operand" "=Z,Q")
+ (match_operand:VSX_LE_128 1 "vsx_register_operand" "+<VSa>,r"))]
"!BYTES_BIG_ENDIAN && TARGET_VSX && !TARGET_P9_VECTOR"
- "#"
- [(set_attr "type" "vecstore")
- (set_attr "length" "12")])
+ "@
+ #
+ #"
+ [(set_attr "type" "vecstore,store")
+ (set_attr "length" "12,8")])
(define_split
[(set (match_operand:VSX_LE_128 0 "memory_operand" "")
@@ -815,6 +822,31 @@
: operands[0];
})
+;; Peepholes to catch loads and stores for TImode if TImode landed in
+;; GPR registers on a little endian system.
+(define_peephole2
+ [(set (match_operand:VSX_LE_128 0 "int_reg_operand")
+ (rotate:VSX_LE_128 (match_operand:VSX_LE_128 1 "memory_operand")
+ (const_int 64)))
+ (set (match_operand:VSX_LE_128 2 "int_reg_operand")
+ (rotate:VSX_LE_128 (match_dup 0)
+ (const_int 64)))]
+ "!BYTES_BIG_ENDIAN && TARGET_VSX && TARGET_VSX_TIMODE && !TARGET_P9_VECTOR
+ && (rtx_equal_p (operands[0], operands[2])
+ || peep2_reg_dead_p (2, operands[0]))"
+ [(set (match_dup 2) (match_dup 1))])
+
+(define_peephole2
+ [(set (match_operand:VSX_LE_128 0 "int_reg_operand")
+ (rotate:VSX_LE_128 (match_operand:VSX_LE_128 1 "int_reg_operand")
+ (const_int 64)))
+ (set (match_operand:VSX_LE_128 2 "memory_operand")
+ (rotate:VSX_LE_128 (match_dup 0)
+ (const_int 64)))]
+ "!BYTES_BIG_ENDIAN && TARGET_VSX && TARGET_VSX_TIMODE && !TARGET_P9_VECTOR
+ && peep2_reg_dead_p (2, operands[0])"
+ [(set (match_dup 2) (match_dup 1))])
+
;; Peephole to catch memory to memory transfers for TImode if TImode landed in
;; VSX registers on a little endian system. The vector types and IEEE 128-bit
;; floating point are handled by the more generic swap elimination pass.
@@ -2017,6 +2049,80 @@
}
[(set_attr "type" "vecperm")])
+;; Combiner patterns to allow creating XXPERMDI's to access either double
+;; word element in a vector register.
+(define_insn "*vsx_concat_<mode>_1"
+ [(set (match_operand:VSX_D 0 "vsx_register_operand" "=<VSa>")
+ (vec_concat:VSX_D
+ (vec_select:<VS_scalar>
+ (match_operand:VSX_D 1 "gpc_reg_operand" "<VSa>")
+ (parallel [(match_operand:QI 2 "const_0_to_1_operand" "n")]))
+ (match_operand:<VS_scalar> 3 "gpc_reg_operand" "<VSa>")))]
+ "VECTOR_MEM_VSX_P (<MODE>mode)"
+{
+ HOST_WIDE_INT dword = INTVAL (operands[2]);
+ if (BYTES_BIG_ENDIAN)
+ {
+ operands[4] = GEN_INT (2*dword);
+ return "xxpermdi %x0,%x1,%x3,%4";
+ }
+ else
+ {
+ operands[4] = GEN_INT (!dword);
+ return "xxpermdi %x0,%x3,%x1,%4";
+ }
+}
+ [(set_attr "type" "vecperm")])
+
+(define_insn "*vsx_concat_<mode>_2"
+ [(set (match_operand:VSX_D 0 "vsx_register_operand" "=<VSa>")
+ (vec_concat:VSX_D
+ (match_operand:<VS_scalar> 1 "gpc_reg_operand" "<VSa>")
+ (vec_select:<VS_scalar>
+ (match_operand:VSX_D 2 "gpc_reg_operand" "<VSa>")
+ (parallel [(match_operand:QI 3 "const_0_to_1_operand" "n")]))))]
+ "VECTOR_MEM_VSX_P (<MODE>mode)"
+{
+ HOST_WIDE_INT dword = INTVAL (operands[3]);
+ if (BYTES_BIG_ENDIAN)
+ {
+ operands[4] = GEN_INT (dword);
+ return "xxpermdi %x0,%x1,%x2,%4";
+ }
+ else
+ {
+ operands[4] = GEN_INT (2 * !dword);
+ return "xxpermdi %x0,%x2,%x1,%4";
+ }
+}
+ [(set_attr "type" "vecperm")])
+
+(define_insn "*vsx_concat_<mode>_3"
+ [(set (match_operand:VSX_D 0 "vsx_register_operand" "=<VSa>")
+ (vec_concat:VSX_D
+ (vec_select:<VS_scalar>
+ (match_operand:VSX_D 1 "gpc_reg_operand" "<VSa>")
+ (parallel [(match_operand:QI 2 "const_0_to_1_operand" "n")]))
+ (vec_select:<VS_scalar>
+ (match_operand:VSX_D 3 "gpc_reg_operand" "<VSa>")
+ (parallel [(match_operand:QI 4 "const_0_to_1_operand" "n")]))))]
+ "VECTOR_MEM_VSX_P (<MODE>mode)"
+{
+ HOST_WIDE_INT dword1 = INTVAL (operands[2]);
+ HOST_WIDE_INT dword2 = INTVAL (operands[4]);
+ if (BYTES_BIG_ENDIAN)
+ {
+ operands[5] = GEN_INT ((2 * dword1) + dword2);
+ return "xxpermdi %x0,%x1,%x3,%5";
+ }
+ else
+ {
+ operands[5] = GEN_INT ((2 * !dword2) + !dword1);
+ return "xxpermdi %x0,%x3,%x1,%5";
+ }
+}
+ [(set_attr "type" "vecperm")])
+
;; Special purpose concat using xxpermdi to glue two single precision values
;; together, relying on the fact that internally scalar floats are represented
;; as doubles. This is used to initialize a V4SF vector with 4 floats
@@ -2217,25 +2323,35 @@
DONE;
})
-;; Set the element of a V2DI/VD2F mode
-(define_insn "vsx_set_<mode>"
- [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wd,?<VSa>")
- (unspec:VSX_D
- [(match_operand:VSX_D 1 "vsx_register_operand" "wd,<VSa>")
- (match_operand:<VS_scalar> 2 "vsx_register_operand" "<VS_64reg>,<VSa>")
- (match_operand:QI 3 "u5bit_cint_operand" "i,i")]
- UNSPEC_VSX_SET))]
+;; Rewrite V2DF/V2DI set in terms of VEC_CONCAT
+(define_expand "vsx_set_<mode>"
+ [(use (match_operand:VSX_D 0 "vsx_register_operand"))
+ (use (match_operand:VSX_D 1 "vsx_register_operand"))
+ (use (match_operand:<VS_scalar> 2 "gpc_reg_operand"))
+ (use (match_operand:QI 3 "const_0_to_1_operand"))]
"VECTOR_MEM_VSX_P (<MODE>mode)"
{
- int idx_first = BYTES_BIG_ENDIAN ? 0 : 1;
- if (INTVAL (operands[3]) == idx_first)
- return \"xxpermdi %x0,%x2,%x1,1\";
- else if (INTVAL (operands[3]) == 1 - idx_first)
- return \"xxpermdi %x0,%x1,%x2,0\";
+ rtx dest = operands[0];
+ rtx vec_reg = operands[1];
+ rtx value = operands[2];
+ rtx ele = operands[3];
+ rtx tmp = gen_reg_rtx (<VS_scalar>mode);
+
+ if (ele == const0_rtx)
+ {
+ emit_insn (gen_vsx_extract_<mode> (tmp, vec_reg, const1_rtx));
+ emit_insn (gen_vsx_concat_<mode> (dest, value, tmp));
+ DONE;
+ }
+ else if (ele == const1_rtx)
+ {
+ emit_insn (gen_vsx_extract_<mode> (tmp, vec_reg, const0_rtx));
+ emit_insn (gen_vsx_concat_<mode> (dest, tmp, value));
+ DONE;
+ }
else
gcc_unreachable ();
-}
- [(set_attr "type" "vecperm")])
+})
;; Extract a DF/DI element from V2DF/V2DI
;; Optimize cases were we can do a simple or direct move.
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
index 1ae7f9f0e01..bc53a1ca284 100644
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -174,9 +174,9 @@ along with GCC; see the file COPYING3. If not see
%{!ansi:values-Xa.o%s}"
#if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
-#define STARTFILE_CRTBEGIN_SPEC "%{shared:crtbeginS.o%s} \
- %{" PIE_SPEC ":crtbeginS.o%s} \
- %{" NO_PIE_SPEC ":crtbegin.o%s}"
+#define STARTFILE_CRTBEGIN_SPEC "%{static:crtbegin.o%s; \
+ shared|" PIE_SPEC ":crtbeginS.o%s; \
+ :crtbegin.o%s}"
#else
#define STARTFILE_CRTBEGIN_SPEC "crtbegin.o%s"
#endif
@@ -224,9 +224,9 @@ along with GCC; see the file COPYING3. If not see
#endif
#if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
-#define ENDFILE_CRTEND_SPEC "%{shared:crtendS.o%s;: \
- %{" PIE_SPEC ":crtendS.o%s} \
- %{" NO_PIE_SPEC ":crtend.o%s}}"
+#define ENDFILE_CRTEND_SPEC "%{static:crtend.o%s; \
+ shared|" PIE_SPEC ":crtendS.o%s; \
+ :crtend.o%s}"
#else
#define ENDFILE_CRTEND_SPEC "crtend.o%s"
#endif
diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md
index 5e1f0b76eed..321c0d8b9fe 100644
--- a/gcc/config/sparc/sparc.md
+++ b/gcc/config/sparc/sparc.md
@@ -4518,7 +4518,14 @@ visl")
;; The 32-bit multiply/divide instructions are deprecated on v9, but at
;; least in UltraSPARC I, II and IIi it is a win tick-wise.
-(define_insn "mulsi3"
+(define_expand "mulsi3"
+ [(set (match_operand:SI 0 "register_operand" "")
+ (mult:SI (match_operand:SI 1 "arith_operand" "")
+ (match_operand:SI 2 "arith_operand" "")))]
+ "TARGET_HARD_MUL || TARGET_ARCH64"
+ "")
+
+(define_insn "*mulsi3_sp32"
[(set (match_operand:SI 0 "register_operand" "=r")
(mult:SI (match_operand:SI 1 "arith_operand" "%r")
(match_operand:SI 2 "arith_operand" "rI")))]
@@ -4526,6 +4533,14 @@ visl")
"smul\t%1, %2, %0"
[(set_attr "type" "imul")])
+(define_insn "*mulsi3_sp64"
+ [(set (match_operand:SI 0 "register_operand" "=r")
+ (mult:SI (match_operand:SI 1 "arith_operand" "%r")
+ (match_operand:SI 2 "arith_operand" "rI")))]
+ "TARGET_ARCH64"
+ "mulx\t%1, %2, %0"
+ [(set_attr "type" "imul")])
+
(define_expand "muldi3"
[(set (match_operand:DI 0 "register_operand" "")
(mult:DI (match_operand:DI 1 "arith_operand" "")
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 25e4a2894c3..8c404187107 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -605,6 +605,7 @@ xtensa_mem_offset (unsigned v, machine_mode mode)
case HImode:
return xtensa_uimm8x2 (v);
+ case DImode:
case DFmode:
return (xtensa_uimm8x4 (v) && xtensa_uimm8x4 (v + 4));
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fa0dfd6b378..4c1518995e0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,11 +1,36 @@
+2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR bootstrap/81926
+ * cp-objcp-common.c (struct debug_type_hasher): New class.
+ (debug_type_hash): New variable.
+ (cp_get_debug_type): Associate the OFFSET_TYPEs with the types.
+
+2017-09-01 Marek Polacek <polacek@redhat.com>
+
+ Backported from mainline
+ 2017-09-01 Marek Polacek <polacek@redhat.com>
+
+ PR c++/82040
+ * typeck.c (cp_build_unary_op): Avoid re-entering reporting routines.
+
+2017-08-25 Marek Polacek <polacek@redhat.com>
+
+ Backported from mainline
+ 2017-08-08 Marek Polacek <polacek@redhat.com>
+
+ PR c++/81607
+ * cp-gimplify.c (cp_fold): If folding exposed a branch of
+ a COND_EXPR, convert it to the original type of the COND_EXPR, if
+ they differ.
+
2017-08-14 Release Manager
* GCC 7.2.0 released.
2017-08-09 Leonid Koppel <lkoppel@uwaterloo.ca>
- PR c++/67054 - Inherited ctor with non-default-constructible members
- * method.c (walk_field_subobs) Consider member initializers (NSDMIs)
+ PR c++/67054 - Inherited ctor with non-default-constructible members
+ * method.c (walk_field_subobs) Consider member initializers (NSDMIs)
when deducing an inheriting constructor.
2017-07-27 Paolo Carlini <paolo.carlini@oracle.com>
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 0ff1dd439d1..eae2a55a029 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -2311,9 +2311,9 @@ cp_fold (tree x)
/* A COND_EXPR might have incompatible types in branches if one or both
arms are bitfields. If folding exposed such a branch, fix it up. */
- if (TREE_CODE (x) != code)
- if (tree type = is_bitfield_expr_with_lowered_type (x))
- x = fold_convert (type, x);
+ if (TREE_CODE (x) != code
+ && !useless_type_conversion_p (TREE_TYPE (org_x), TREE_TYPE (x)))
+ x = fold_convert (TREE_TYPE (org_x), x);
break;
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index 2c93252c4b6..126cf137686 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -131,6 +131,20 @@ cxx_types_compatible_p (tree x, tree y)
return same_type_ignoring_top_level_qualifiers_p (x, y);
}
+struct debug_type_hasher : ggc_cache_ptr_hash<tree_map>
+{
+ static hashval_t hash (tree_map *m) { return tree_map_hash (m); }
+ static bool equal (tree_map *a, tree_map *b) { return tree_map_eq (a, b); }
+
+ static int
+ keep_cache_entry (tree_map *&e)
+ {
+ return ggc_marked_p (e->base.from);
+ }
+};
+
+static GTY((cache)) hash_table<debug_type_hasher> *debug_type_hash;
+
/* Return a type to use in the debug info instead of TYPE, or NULL_TREE to
keep TYPE. */
@@ -138,8 +152,35 @@ tree
cp_get_debug_type (const_tree type)
{
if (TYPE_PTRMEMFUNC_P (type) && !typedef_variant_p (type))
- return build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type),
- TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type)));
+ {
+ if (debug_type_hash == NULL)
+ debug_type_hash = hash_table<debug_type_hasher>::create_ggc (512);
+
+ /* We cannot simply use build_offset_type here because the function uses
+ the type canonicalization hashtable, which is GC-ed, so its behavior
+ depends on the actual collection points. Since we are building these
+ types on the fly for the debug info only, they would not be attached
+ to any GC root and always be swept, so we would make the contents of
+ the debug info depend on the collection points. */
+ struct tree_map in, *h;
+
+ in.base.from = CONST_CAST_TREE (type);
+ in.hash = htab_hash_pointer (type);
+ h = debug_type_hash->find_with_hash (&in, in.hash);
+ if (h)
+ return h->to;
+
+ tree t = build_offset_type (TYPE_PTRMEMFUNC_OBJECT_TYPE (type),
+ TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type)));
+
+ h = ggc_alloc<tree_map> ();
+ h->base.from = CONST_CAST_TREE (type);
+ h->hash = htab_hash_pointer (type);
+ h->to = t;
+ *debug_type_hash->find_slot_with_hash (h, h->hash, INSERT) = h;
+
+ return t;
+ }
return NULL_TREE;
}
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 0bcf6d0ac97..cd7732bdd37 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5927,6 +5927,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
{
/* Warn if the expression has boolean value. */
if (TREE_CODE (TREE_TYPE (arg)) == BOOLEAN_TYPE
+ && (complain & tf_warning)
&& warning_at (location, OPT_Wbool_operation,
"%<~%> on an expression of type bool"))
inform (location, "did you mean to use logical not (%<!%>)?");
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index a5edb3264e3..bac9d022420 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -20635,7 +20635,7 @@ unsigned long long _pext_u64 (unsigned long long, unsigned long long)
The following built-in functions are available when @option{-mlzcnt} is used.
All of them generate the machine instruction that is part of the name.
@smallexample
-unsigned short __builtin_ia32_lzcnt_16(unsigned short);
+unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
@end smallexample
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 276990b1794..9e324c1f9d7 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -12514,6 +12514,15 @@ modified_type_die (tree type, int cv_quals, bool reverse,
if (qualified_type == dtype)
{
+ tree origin = decl_ultimate_origin (name);
+
+ /* Typedef variants that have an abstract origin don't get their own
+ type DIE (see gen_typedef_die), so fall back on the ultimate
+ abstract origin instead. */
+ if (origin != NULL)
+ return modified_type_die (TREE_TYPE (origin), cv_quals, reverse,
+ context_die);
+
/* For a named type, use the typedef. */
gen_type_die (qualified_type, context_die);
return lookup_type_die (qualified_type);
@@ -24346,7 +24355,7 @@ static void
gen_typedef_die (tree decl, dw_die_ref context_die)
{
dw_die_ref type_die;
- tree origin;
+ tree type;
if (TREE_ASM_WRITTEN (decl))
{
@@ -24355,75 +24364,71 @@ gen_typedef_die (tree decl, dw_die_ref context_die)
return;
}
+ /* As we avoid creating DIEs for local typedefs (see decl_ultimate_origin
+ checks in process_scope_var and modified_type_die), this should be called
+ only for original types. */
+ gcc_assert (decl_ultimate_origin (decl) == NULL);
+
TREE_ASM_WRITTEN (decl) = 1;
type_die = new_die (DW_TAG_typedef, context_die, decl);
- origin = decl_ultimate_origin (decl);
- if (origin != NULL)
- add_abstract_origin_attribute (type_die, origin);
- else
+
+ add_name_and_src_coords_attributes (type_die, decl);
+ if (DECL_ORIGINAL_TYPE (decl))
{
- tree type = TREE_TYPE (decl);
+ type = DECL_ORIGINAL_TYPE (decl);
+ if (type == error_mark_node)
+ return;
+ gcc_assert (type != TREE_TYPE (decl));
+ equate_type_number_to_die (TREE_TYPE (decl), type_die);
+ }
+ else
+ {
+ type = TREE_TYPE (decl);
if (type == error_mark_node)
return;
- add_name_and_src_coords_attributes (type_die, decl);
- if (DECL_ORIGINAL_TYPE (decl))
+ if (is_naming_typedef_decl (TYPE_NAME (type)))
{
- type = DECL_ORIGINAL_TYPE (decl);
+ /* Here, we are in the case of decl being a typedef naming
+ an anonymous type, e.g:
+ typedef struct {...} foo;
+ In that case TREE_TYPE (decl) is not a typedef variant
+ type and TYPE_NAME of the anonymous type is set to the
+ TYPE_DECL of the typedef. This construct is emitted by
+ the C++ FE.
- if (type == error_mark_node)
- return;
+ TYPE is the anonymous struct named by the typedef
+ DECL. As we need the DW_AT_type attribute of the
+ DW_TAG_typedef to point to the DIE of TYPE, let's
+ generate that DIE right away. add_type_attribute
+ called below will then pick (via lookup_type_die) that
+ anonymous struct DIE. */
+ if (!TREE_ASM_WRITTEN (type))
+ gen_tagged_type_die (type, context_die, DINFO_USAGE_DIR_USE);
- gcc_assert (type != TREE_TYPE (decl));
- equate_type_number_to_die (TREE_TYPE (decl), type_die);
- }
- else
- {
- if (is_naming_typedef_decl (TYPE_NAME (type)))
- {
- /* Here, we are in the case of decl being a typedef naming
- an anonymous type, e.g:
- typedef struct {...} foo;
- In that case TREE_TYPE (decl) is not a typedef variant
- type and TYPE_NAME of the anonymous type is set to the
- TYPE_DECL of the typedef. This construct is emitted by
- the C++ FE.
-
- TYPE is the anonymous struct named by the typedef
- DECL. As we need the DW_AT_type attribute of the
- DW_TAG_typedef to point to the DIE of TYPE, let's
- generate that DIE right away. add_type_attribute
- called below will then pick (via lookup_type_die) that
- anonymous struct DIE. */
- if (!TREE_ASM_WRITTEN (type))
- gen_tagged_type_die (type, context_die, DINFO_USAGE_DIR_USE);
-
- /* This is a GNU Extension. We are adding a
- DW_AT_linkage_name attribute to the DIE of the
- anonymous struct TYPE. The value of that attribute
- is the name of the typedef decl naming the anonymous
- struct. This greatly eases the work of consumers of
- this debug info. */
- add_linkage_name_raw (lookup_type_die (type), decl);
- }
+ /* This is a GNU Extension. We are adding a
+ DW_AT_linkage_name attribute to the DIE of the
+ anonymous struct TYPE. The value of that attribute
+ is the name of the typedef decl naming the anonymous
+ struct. This greatly eases the work of consumers of
+ this debug info. */
+ add_linkage_name_raw (lookup_type_die (type), decl);
}
+ }
- add_type_attribute (type_die, type, decl_quals (decl), false,
- context_die);
-
- if (is_naming_typedef_decl (decl))
- /* We want that all subsequent calls to lookup_type_die with
- TYPE in argument yield the DW_TAG_typedef we have just
- created. */
- equate_type_number_to_die (type, type_die);
+ add_type_attribute (type_die, type, decl_quals (decl), false,
+ context_die);
- type = TREE_TYPE (decl);
+ if (is_naming_typedef_decl (decl))
+ /* We want that all subsequent calls to lookup_type_die with
+ TYPE in argument yield the DW_TAG_typedef we have just
+ created. */
+ equate_type_number_to_die (type, type_die);
- add_alignment_attribute (type_die, type);
+ add_alignment_attribute (type_die, TREE_TYPE (decl));
- add_accessibility_attribute (type_die, decl);
- }
+ add_accessibility_attribute (type_die, decl);
if (DECL_ABSTRACT_P (decl))
equate_decl_number_to_die (decl, type_die);
@@ -24535,15 +24540,23 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
if (TREE_ASM_WRITTEN (type))
return;
+ tree name = TYPE_NAME (type);
+ tree origin = decl_ultimate_origin (name);
+ if (origin != NULL)
+ {
+ gen_decl_die (origin, NULL, NULL, context_die);
+ return;
+ }
+
/* Prevent broken recursion; we can't hand off to the same type. */
- gcc_assert (DECL_ORIGINAL_TYPE (TYPE_NAME (type)) != type);
+ gcc_assert (DECL_ORIGINAL_TYPE (name) != type);
/* Give typedefs the right scope. */
context_die = scope_die_for (type, context_die);
TREE_ASM_WRITTEN (type) = 1;
- gen_decl_die (TYPE_NAME (type), NULL, NULL, context_die);
+ gen_decl_die (name, NULL, NULL, context_die);
return;
}
@@ -24862,6 +24875,22 @@ process_scope_var (tree stmt, tree decl, tree origin, dw_die_ref context_die)
else
die = NULL;
+ /* Avoid creating DIEs for local typedefs and concrete static variables that
+ will only be pruned later. */
+ if ((origin || decl_ultimate_origin (decl))
+ && (TREE_CODE (decl_or_origin) == TYPE_DECL
+ || (VAR_P (decl_or_origin) && TREE_STATIC (decl_or_origin))))
+ {
+ origin = decl_ultimate_origin (decl_or_origin);
+ if (decl && VAR_P (decl) && die != NULL)
+ {
+ die = lookup_decl_die (origin);
+ if (die != NULL)
+ equate_decl_number_to_die (decl, die);
+ }
+ return;
+ }
+
if (die != NULL && die->die_parent == NULL)
add_child_die (context_die, die);
else if (TREE_CODE (decl_or_origin) == IMPORTED_DECL)
@@ -26058,7 +26087,8 @@ gen_remaining_tmpl_value_param_die_attribute (void)
j = 0;
FOR_EACH_VEC_ELT (*tmpl_value_parm_die_table, i, e)
{
- if (!tree_add_const_value_attribute (e->die, e->arg))
+ if (!e->die->removed
+ && !tree_add_const_value_attribute (e->die, e->arg))
{
dw_loc_descr_ref loc = NULL;
if (! early_dwarf
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 7010cced4f5..66a494d5ca6 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -877,6 +877,13 @@ split_tree (location_t loc, tree in, tree type, enum tree_code code,
}
}
+ if (*litp
+ && TREE_OVERFLOW_P (*litp))
+ *litp = drop_tree_overflow (*litp);
+ if (*minus_litp
+ && TREE_OVERFLOW_P (*minus_litp))
+ *minus_litp = drop_tree_overflow (*minus_litp);
+
return var;
}
@@ -6175,6 +6182,7 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type,
t1 = extract_muldiv (op0, c, code, wide_type, &sub_strict_overflow_p);
t2 = extract_muldiv (op1, c, code, wide_type, &sub_strict_overflow_p);
if (t1 != 0 && t2 != 0
+ && TYPE_OVERFLOW_WRAPS (ctype)
&& (code == MULT_EXPR
/* If not multiplication, we can only do this if both operands
are divisible by c. */
@@ -6237,11 +6245,6 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type,
if (TYPE_UNSIGNED (ctype) && ctype != type)
break;
- /* If we were able to eliminate our operation from the first side,
- apply our operation to the second side and reform the PLUS. */
- if (t1 != 0 && (TREE_CODE (t1) != code || code == MULT_EXPR))
- return fold_build2 (tcode, ctype, fold_convert (ctype, t1), op1);
-
/* The last case is if we are a multiply. In that case, we can
apply the distributive law to commute the multiply and addition
if the multiplication of the constants doesn't overflow
@@ -8879,7 +8882,7 @@ fold_addr_of_array_ref_difference (location_t loc, tree type,
tree op0 = fold_convert_loc (loc, type, TREE_OPERAND (aref0, 1));
tree op1 = fold_convert_loc (loc, type, TREE_OPERAND (aref1, 1));
tree esz = fold_convert_loc (loc, type, array_ref_element_size (aref0));
- tree diff = build2 (MINUS_EXPR, type, op0, op1);
+ tree diff = fold_build2_loc (loc, MINUS_EXPR, type, op0, op1);
return fold_build2_loc (loc, PLUS_EXPR, type,
base_offset,
fold_build2_loc (loc, MULT_EXPR, type,
@@ -9638,11 +9641,6 @@ fold_binary_loc (location_t loc,
+ (lit0 != 0) + (lit1 != 0)
+ (minus_lit0 != 0) + (minus_lit1 != 0))))
{
- bool any_overflows = false;
- if (lit0) any_overflows |= TREE_OVERFLOW (lit0);
- if (lit1) any_overflows |= TREE_OVERFLOW (lit1);
- if (minus_lit0) any_overflows |= TREE_OVERFLOW (minus_lit0);
- if (minus_lit1) any_overflows |= TREE_OVERFLOW (minus_lit1);
var0 = associate_trees (loc, var0, var1, code, atype);
con0 = associate_trees (loc, con0, con1, code, atype);
lit0 = associate_trees (loc, lit0, lit1, code, atype);
@@ -9673,9 +9671,8 @@ fold_binary_loc (location_t loc,
}
/* Don't introduce overflows through reassociation. */
- if (!any_overflows
- && ((lit0 && TREE_OVERFLOW_P (lit0))
- || (minus_lit0 && TREE_OVERFLOW_P (minus_lit0))))
+ if ((lit0 && TREE_OVERFLOW_P (lit0))
+ || (minus_lit0 && TREE_OVERFLOW_P (minus_lit0)))
return NULL_TREE;
if (minus_lit0)
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index fb36d2c3438..2d802f128f0 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,24 @@
+2017-09-02 Janus Weil <janus@gcc.gnu.org>
+
+ Backport from trunk
+ PR fortran/81770
+ * expr.c (gfc_check_pointer_assign): Improve the check whether pointer
+ may outlive pointer target.
+
+2017-08-22 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ Backport from trunk
+ PR fortran/81296
+ * trans-io.c (get_dtio_proc): Add check for format label and set
+ formatted flag accordingly. Reorganize the code a little.
+
+2017-08-18 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ Backport from trunk
+ PR fortran/80164
+ * trans-stmt.c (gfc_trans_call): If no code expr, use code->loc
+ as warning/error locus.
+
2017-08-14 Release Manager
* GCC 7.2.0 released.
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index c7d3e549c5b..1718e4a55b8 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3806,7 +3806,8 @@ gfc_check_pointer_assign (gfc_expr *lvalue, gfc_expr *rvalue)
if (warn_target_lifetime
&& rvalue->expr_type == EXPR_VARIABLE
&& !rvalue->symtree->n.sym->attr.save
- && !attr.pointer && !rvalue->symtree->n.sym->attr.host_assoc
+ && !rvalue->symtree->n.sym->attr.pointer && !attr.pointer
+ && !rvalue->symtree->n.sym->attr.host_assoc
&& !rvalue->symtree->n.sym->attr.in_common
&& !rvalue->symtree->n.sym->attr.use_assoc
&& !rvalue->symtree->n.sym->attr.dummy)
diff --git a/gcc/fortran/trans-io.c b/gcc/fortran/trans-io.c
index c3c56f29623..aa974eb3805 100644
--- a/gcc/fortran/trans-io.c
+++ b/gcc/fortran/trans-io.c
@@ -2214,18 +2214,24 @@ get_dtio_proc (gfc_typespec * ts, gfc_code * code, gfc_symbol **dtio_sub)
bool formatted = false;
gfc_dt *dt = code->ext.dt;
- if (dt && dt->format_expr)
+ if (dt)
{
- char *fmt;
- fmt = gfc_widechar_to_char (dt->format_expr->value.character.string,
- -1);
- if (strtok (fmt, "DT") != NULL)
+ char *fmt = NULL;
+
+ if (dt->format_label == &format_asterisk)
+ {
+ /* List directed io must call the formatted DTIO procedure. */
+ formatted = true;
+ }
+ else if (dt->format_expr)
+ fmt = gfc_widechar_to_char (dt->format_expr->value.character.string,
+ -1);
+ else if (dt->format_label)
+ fmt = gfc_widechar_to_char (dt->format_label->format->value.character.string,
+ -1);
+ if (fmt && strtok (fmt, "DT") != NULL)
formatted = true;
- }
- else if (dt && dt->format_label == &format_asterisk)
- {
- /* List directed io must call the formatted DTIO procedure. */
- formatted = true;
+
}
if (ts->type == BT_CLASS)
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index 98687c80637..d71e01e53ac 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -452,7 +452,10 @@ gfc_trans_call (gfc_code * code, bool dependency_check,
subscripts. This could be prevented in the elemental case
as temporaries are handled separatedly
(below in gfc_conv_elemental_dependencies). */
- gfc_conv_loop_setup (&loop, &code->expr1->where);
+ if (code->expr1)
+ gfc_conv_loop_setup (&loop, &code->expr1->where);
+ else
+ gfc_conv_loop_setup (&loop, &code->loc);
gfc_mark_ss_chain_used (ss, 1);
/* Convert the arguments, checking for dependencies. */
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 9721f94b4f6..9a6f3ee700e 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -872,8 +872,7 @@ proper position among the other output files. */
#endif
#ifdef ENABLE_DEFAULT_PIE
-#define NO_PIE_SPEC "no-pie|static"
-#define PIE_SPEC NO_PIE_SPEC "|r|shared:;"
+#define PIE_SPEC "!no-pie"
#define NO_FPIE1_SPEC "fno-pie"
#define FPIE1_SPEC NO_FPIE1_SPEC ":;"
#define NO_FPIE2_SPEC "fno-PIE"
@@ -894,7 +893,6 @@ proper position among the other output files. */
#define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
#else
#define PIE_SPEC "pie"
-#define NO_PIE_SPEC PIE_SPEC "|r|shared:;"
#define FPIE1_SPEC "fpie"
#define NO_FPIE1_SPEC FPIE1_SPEC ":;"
#define FPIE2_SPEC "fPIE"
@@ -923,7 +921,7 @@ proper position among the other output files. */
#else
#define LD_PIE_SPEC ""
#endif
-#define LINK_PIE_SPEC "%{no-pie:} " "%{" PIE_SPEC ":" LD_PIE_SPEC "} "
+#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
#endif
#ifndef LINK_BUILDID_SPEC
@@ -1011,8 +1009,10 @@ proper position among the other output files. */
#endif
/* -u* was put back because both BSD and SysV seem to support it. */
-/* %{static:} simply prevents an error message if the target machine
- doesn't handle -static. */
+/* %{static|no-pie:} simply prevents an error message:
+ 1. If the target machine doesn't handle -static.
+ 2. If PIE isn't enabled by default.
+ */
/* We want %{T*} after %{L*} and %D so that it can be used to specify linker
scripts which exist in user specified directories, or in standard
directories. */
@@ -1029,7 +1029,7 @@ proper position among the other output files. */
"%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
"%X %{o*} %{e*} %{N} %{n} %{r}\
%{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \
- %{static:} %{L*} %(mfwrap) %(link_libgcc) " \
+ %{static|no-pie:} %{L*} %(mfwrap) %(link_libgcc) " \
VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \
%{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
%:include(libgomp.spec)%(link_gomp)}\
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 20c1add3002..a8ad9fc0719 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -1236,7 +1236,7 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, int type,
the NUL.
Set *FLEXP to true if the array whose bound is being
used is at the end of a struct. */
- if (array_at_struct_end_p (arg, true))
+ if (array_at_struct_end_p (arg))
*flexp = true;
arg = TREE_OPERAND (arg, 1);
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index 233ece48738..4cb9137dcf0 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -2044,104 +2044,104 @@ replace_mult_candidate (slsr_cand_t c, tree basis_name, widest_int bump)
tree target_type = TREE_TYPE (gimple_assign_lhs (c->cand_stmt));
enum tree_code cand_code = gimple_assign_rhs_code (c->cand_stmt);
- /* It is highly unlikely, but possible, that the resulting
- bump doesn't fit in a HWI. Abandon the replacement
- in this case. This does not affect siblings or dependents
- of C. Restriction to signed HWI is conservative for unsigned
- types but allows for safe negation without twisted logic. */
- if (wi::fits_shwi_p (bump)
- && bump.to_shwi () != HOST_WIDE_INT_MIN
- /* It is not useful to replace casts, copies, negates, or adds of
- an SSA name and a constant. */
- && cand_code != SSA_NAME
- && !CONVERT_EXPR_CODE_P (cand_code)
- && cand_code != PLUS_EXPR
- && cand_code != POINTER_PLUS_EXPR
- && cand_code != MINUS_EXPR
- && cand_code != NEGATE_EXPR)
- {
- enum tree_code code = PLUS_EXPR;
- tree bump_tree;
- gimple *stmt_to_print = NULL;
+ /* It is not useful to replace casts, copies, negates, or adds of
+ an SSA name and a constant. */
+ if (cand_code == SSA_NAME
+ || CONVERT_EXPR_CODE_P (cand_code)
+ || cand_code == PLUS_EXPR
+ || cand_code == POINTER_PLUS_EXPR
+ || cand_code == MINUS_EXPR
+ || cand_code == NEGATE_EXPR)
+ return;
+
+ enum tree_code code = PLUS_EXPR;
+ tree bump_tree;
+ gimple *stmt_to_print = NULL;
- /* If the basis name and the candidate's LHS have incompatible
- types, introduce a cast. */
- if (!useless_type_conversion_p (target_type, TREE_TYPE (basis_name)))
- basis_name = introduce_cast_before_cand (c, target_type, basis_name);
- if (wi::neg_p (bump))
- {
- code = MINUS_EXPR;
- bump = -bump;
- }
+ /* If the basis name and the candidate's LHS have incompatible
+ types, introduce a cast. */
+ if (!useless_type_conversion_p (target_type, TREE_TYPE (basis_name)))
+ basis_name = introduce_cast_before_cand (c, target_type, basis_name);
+ if (wi::neg_p (bump))
+ {
+ code = MINUS_EXPR;
+ bump = -bump;
+ }
- bump_tree = wide_int_to_tree (target_type, bump);
+ /* It is possible that the resulting bump doesn't fit in target_type.
+ Abandon the replacement in this case. This does not affect
+ siblings or dependents of C. */
+ if (bump != wi::ext (bump, TYPE_PRECISION (target_type),
+ TYPE_SIGN (target_type)))
+ return;
+
+ bump_tree = wide_int_to_tree (target_type, bump);
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fputs ("Replacing: ", dump_file);
+ print_gimple_stmt (dump_file, c->cand_stmt, 0, 0);
+ }
+
+ if (bump == 0)
+ {
+ tree lhs = gimple_assign_lhs (c->cand_stmt);
+ gassign *copy_stmt = gimple_build_assign (lhs, basis_name);
+ gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
+ slsr_cand_t cc = c;
+ gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));
+ gsi_replace (&gsi, copy_stmt, false);
+ c->cand_stmt = copy_stmt;
+ while (cc->next_interp)
+ {
+ cc = lookup_cand (cc->next_interp);
+ cc->cand_stmt = copy_stmt;
+ }
if (dump_file && (dump_flags & TDF_DETAILS))
+ stmt_to_print = copy_stmt;
+ }
+ else
+ {
+ tree rhs1, rhs2;
+ if (cand_code != NEGATE_EXPR) {
+ rhs1 = gimple_assign_rhs1 (c->cand_stmt);
+ rhs2 = gimple_assign_rhs2 (c->cand_stmt);
+ }
+ if (cand_code != NEGATE_EXPR
+ && ((operand_equal_p (rhs1, basis_name, 0)
+ && operand_equal_p (rhs2, bump_tree, 0))
+ || (operand_equal_p (rhs1, bump_tree, 0)
+ && operand_equal_p (rhs2, basis_name, 0))))
{
- fputs ("Replacing: ", dump_file);
- print_gimple_stmt (dump_file, c->cand_stmt, 0, 0);
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fputs ("(duplicate, not actually replacing)", dump_file);
+ stmt_to_print = c->cand_stmt;
+ }
}
-
- if (bump == 0)
+ else
{
- tree lhs = gimple_assign_lhs (c->cand_stmt);
- gassign *copy_stmt = gimple_build_assign (lhs, basis_name);
gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
slsr_cand_t cc = c;
- gimple_set_location (copy_stmt, gimple_location (c->cand_stmt));
- gsi_replace (&gsi, copy_stmt, false);
- c->cand_stmt = copy_stmt;
+ gimple_assign_set_rhs_with_ops (&gsi, code,
+ basis_name, bump_tree);
+ update_stmt (gsi_stmt (gsi));
+ c->cand_stmt = gsi_stmt (gsi);
while (cc->next_interp)
{
cc = lookup_cand (cc->next_interp);
- cc->cand_stmt = copy_stmt;
+ cc->cand_stmt = gsi_stmt (gsi);
}
if (dump_file && (dump_flags & TDF_DETAILS))
- stmt_to_print = copy_stmt;
- }
- else
- {
- tree rhs1, rhs2;
- if (cand_code != NEGATE_EXPR) {
- rhs1 = gimple_assign_rhs1 (c->cand_stmt);
- rhs2 = gimple_assign_rhs2 (c->cand_stmt);
- }
- if (cand_code != NEGATE_EXPR
- && ((operand_equal_p (rhs1, basis_name, 0)
- && operand_equal_p (rhs2, bump_tree, 0))
- || (operand_equal_p (rhs1, bump_tree, 0)
- && operand_equal_p (rhs2, basis_name, 0))))
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fputs ("(duplicate, not actually replacing)", dump_file);
- stmt_to_print = c->cand_stmt;
- }
- }
- else
- {
- gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt);
- slsr_cand_t cc = c;
- gimple_assign_set_rhs_with_ops (&gsi, code,
- basis_name, bump_tree);
- update_stmt (gsi_stmt (gsi));
- c->cand_stmt = gsi_stmt (gsi);
- while (cc->next_interp)
- {
- cc = lookup_cand (cc->next_interp);
- cc->cand_stmt = gsi_stmt (gsi);
- }
- if (dump_file && (dump_flags & TDF_DETAILS))
- stmt_to_print = gsi_stmt (gsi);
- }
+ stmt_to_print = gsi_stmt (gsi);
}
-
- if (dump_file && (dump_flags & TDF_DETAILS))
- {
- fputs ("With: ", dump_file);
- print_gimple_stmt (dump_file, stmt_to_print, 0, 0);
- fputs ("\n", dump_file);
- }
+ }
+
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fputs ("With: ", dump_file);
+ print_gimple_stmt (dump_file, stmt_to_print, 0, 0);
+ fputs ("\n", dump_file);
}
}
@@ -3201,6 +3201,23 @@ insert_initializers (slsr_cand_t c)
that block, the earliest one will be returned in WHERE. */
bb = nearest_common_dominator_for_cands (c, incr, &where);
+ /* If the NCD is not dominated by the block containing the
+ definition of the stride, we can't legally insert a
+ single initializer. Mark the increment as unprofitable
+ so we don't make any replacements. FIXME: Multiple
+ initializers could be placed with more analysis. */
+ gimple *stride_def = SSA_NAME_DEF_STMT (c->stride);
+ basic_block stride_bb = gimple_bb (stride_def);
+
+ if (stride_bb && !dominated_by_p (CDI_DOMINATORS, bb, stride_bb))
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file,
+ "Initializer #%d cannot be legally placed\n", i);
+ incr_vec[i].cost = COST_INFINITE;
+ continue;
+ }
+
/* If the nominal stride has a different type than the recorded
stride type, build a cast from the nominal stride to that type. */
if (!types_compatible_p (TREE_TYPE (c->stride), c->stride_type))
diff --git a/gcc/lra-remat.c b/gcc/lra-remat.c
index 5cba7412d79..c221f7899ea 100644
--- a/gcc/lra-remat.c
+++ b/gcc/lra-remat.c
@@ -684,7 +684,7 @@ reg_overlap_for_remat_p (lra_insn_reg *reg, rtx_insn *insn)
if (regno2 >= FIRST_PSEUDO_REGISTER && reg_renumber[regno2] >= 0)
regno2 = reg_renumber[regno2];
- if (regno >= FIRST_PSEUDO_REGISTER)
+ if (regno2 >= FIRST_PSEUDO_REGISTER)
nregs2 = 1;
else
nregs2 = hard_regno_nregs[regno2][reg->biggest_mode];
diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index 5c48b7867c2..a1e668d99d2 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -4725,24 +4725,28 @@ expand_omp_simd (struct omp_region *region, struct omp_for_data *fd)
tree itype2 = TREE_TYPE (fd->loops[i - 1].v);
if (POINTER_TYPE_P (itype2))
itype2 = signed_type_for (itype2);
+ t = fold_convert (itype2, fd->loops[i - 1].step);
+ t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true,
+ GSI_SAME_STMT);
t = build3 (COND_EXPR, itype2,
build2 (fd->loops[i].cond_code, boolean_type_node,
fd->loops[i].v,
fold_convert (itype, fd->loops[i].n2)),
- build_int_cst (itype2, 0),
- fold_convert (itype2, fd->loops[i - 1].step));
+ build_int_cst (itype2, 0), t);
if (POINTER_TYPE_P (TREE_TYPE (fd->loops[i - 1].v)))
t = fold_build_pointer_plus (fd->loops[i - 1].v, t);
else
t = fold_build2 (PLUS_EXPR, itype2, fd->loops[i - 1].v, t);
expand_omp_build_assign (&gsi, fd->loops[i - 1].v, t);
+ t = fold_convert (itype, fd->loops[i].n1);
+ t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE, true,
+ GSI_SAME_STMT);
t = build3 (COND_EXPR, itype,
build2 (fd->loops[i].cond_code, boolean_type_node,
fd->loops[i].v,
fold_convert (itype, fd->loops[i].n2)),
- fd->loops[i].v,
- fold_convert (itype, fd->loops[i].n1));
+ fd->loops[i].v, t);
expand_omp_build_assign (&gsi, fd->loops[i].v, t);
}
}
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 968075c3df5..2d1ba3f52c3 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -800,6 +800,8 @@ omp_copy_decl (tree var, copy_body_data *cb)
if (TREE_CODE (var) == LABEL_DECL)
{
+ if (FORCED_LABEL (var) || DECL_NONLOCAL (var))
+ return var;
new_var = create_artificial_label (DECL_SOURCE_LOCATION (var));
DECL_CONTEXT (new_var) = current_function_decl;
insert_decl_map (&ctx->cb, var, new_var);
@@ -6925,10 +6927,14 @@ lower_omp_for (gimple_stmt_iterator *gsi_p, omp_context *ctx)
rhs_p = gimple_omp_for_initial_ptr (stmt, i);
if (!is_gimple_min_invariant (*rhs_p))
*rhs_p = get_formal_tmp_var (*rhs_p, &body);
+ else if (TREE_CODE (*rhs_p) == ADDR_EXPR)
+ recompute_tree_invariant_for_addr_expr (*rhs_p);
rhs_p = gimple_omp_for_final_ptr (stmt, i);
if (!is_gimple_min_invariant (*rhs_p))
*rhs_p = get_formal_tmp_var (*rhs_p, &body);
+ else if (TREE_CODE (*rhs_p) == ADDR_EXPR)
+ recompute_tree_invariant_for_addr_expr (*rhs_p);
rhs_p = &TREE_OPERAND (gimple_omp_for_incr (stmt, i), 1);
if (!is_gimple_min_invariant (*rhs_p))
@@ -9089,7 +9095,7 @@ diagnose_sb_0 (gimple_stmt_iterator *gsi_p,
}
if (kind == NULL)
{
- gcc_checking_assert (flag_openmp);
+ gcc_checking_assert (flag_openmp || flag_openmp_simd);
kind = "OpenMP";
}
@@ -9349,7 +9355,7 @@ public:
/* opt_pass methods: */
virtual bool gate (function *)
{
- return flag_cilkplus || flag_openacc || flag_openmp;
+ return flag_cilkplus || flag_openacc || flag_openmp || flag_openmp_simd;
}
virtual unsigned int execute (function *)
{
diff --git a/gcc/po/ChangeLog b/gcc/po/ChangeLog
index 022a5f2ad5e..4236564b5ee 100644
--- a/gcc/po/ChangeLog
+++ b/gcc/po/ChangeLog
@@ -1,3 +1,7 @@
+2017-08-21 Joseph Myers <joseph@codesourcery.com>
+
+ * de.po: Update.
+
2017-08-16 Joseph Myers <joseph@codesourcery.com>
* fr.po: Update.
diff --git a/gcc/po/de.po b/gcc/po/de.po
index d66ab6024b8..e7b6990401b 100644
--- a/gcc/po/de.po
+++ b/gcc/po/de.po
@@ -8,10 +8,10 @@
# Roland Illig <roland.illig@gmx.de>, 2015, 2017.
msgid ""
msgstr ""
-"Project-Id-Version: gcc 7.1.0\n"
+"Project-Id-Version: gcc 7.2.0\n"
"Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n"
"POT-Creation-Date: 2017-08-04 22:17+0000\n"
-"PO-Revision-Date: 2017-05-03 22:55+0200\n"
+"PO-Revision-Date: 2017-08-20 23:01+0200\n"
"Last-Translator: Roland Illig <roland.illig@gmx.de>\n"
"Language-Team: German <translation-team-de@lists.sourceforge.net>\n"
"Language: de\n"
@@ -20,7 +20,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Bugs: Report translation errors to the Language-Team address.\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: Poedit 2.0.1\n"
+"X-Generator: Poedit 2.0.3\n"
#: cfgrtl.c:2661
msgid "flow control insn inside a basic block"
@@ -10223,10 +10223,8 @@ msgid "Use UltraSPARC Visual Instruction Set version 4.0 extensions."
msgstr "Visuelle Befehlssatzerweiterungen Version 4.0 für UltraSPARC verwenden."
#: config/sparc/sparc.opt:86
-#, fuzzy
-#| msgid "Use vector and scalar instructions added in ISA 2.07."
msgid "Use additional VIS instructions introduced in OSA2017."
-msgstr "Vektor-/skalare (VSX) Befehle verwenden, die in ISA 2.07 hinzugefügt wurden."
+msgstr "Zusätzliche VIS-Befehle verwenden, die in OSA2017 hinzugefügt wurden."
#: config/sparc/sparc.opt:90
msgid "Use UltraSPARC Compare-and-Branch extensions."
@@ -10237,10 +10235,8 @@ msgid "Use UltraSPARC Fused Multiply-Add extensions."
msgstr "Multiplizier-Addier-Erweiterungen für UltraSPARC verwenden."
#: config/sparc/sparc.opt:98
-#, fuzzy
-#| msgid "Use hardware floating-point divide and square root instructions."
msgid "Use Floating-point Multiply Single to Double (FsMULd) instruction."
-msgstr "Hardware-Gleitkommabefehle für Division und Quadratwurzel verwenden."
+msgstr "Hardware-Gleitkommabefehle für Multiplikation von einfacher auf doppelte Genauigkeit (FsMULd) verwenden."
#: config/sparc/sparc.opt:102
msgid "Use UltraSPARC Population-Count instruction."
@@ -10307,16 +10303,12 @@ msgid "Enable workarounds for the errata of the UT699 processor."
msgstr "Workaround für Errata des UT699-Prozessors einschalten."
#: config/sparc/sparc.opt:246
-#, fuzzy
-#| msgid "Enable workarounds for the errata of the UT699 processor."
msgid "Enable workarounds for the errata of the UT699E/UT700 processor."
-msgstr "Workaround für Errata des UT699-Prozessors einschalten."
+msgstr "Workarounds für Errata des UT699E/UT700-Prozessors einschalten."
#: config/sparc/sparc.opt:250
-#, fuzzy
-#| msgid "Enable workarounds for the errata of the UT699 processor."
msgid "Enable workarounds for the errata of the GR712RC processor."
-msgstr "Workaround für Errata des UT699-Prozessors einschalten."
+msgstr "Workarounds für Errata des GR712RC-Prozessors einschalten."
#: config/sparc/sparc.opt:283
msgid "Specify the memory model in effect for the program."
@@ -14662,8 +14654,6 @@ msgid "Detect paths that trigger erroneous or undefined behavior due to derefere
msgstr "Ausführungspfade erkennen, die durch Dereferenzieren eines Nullzeigers fehlerhaftes oder undefiniertes Verhalten auslösen. Solche Pfade werden aus dem Hauptablauf herausgenommen und durch eine Trap ersetzt."
#: common.opt:2495
-#, fuzzy
-#| msgid "Detect paths that trigger erroneous or undefined behavior due a null value being used in a way forbidden by a returns_nonnull or nonnull attribute. Isolate those paths from the main control flow and turn the statement with erroneous or undefined behavior into a trap."
msgid "Detect paths that trigger erroneous or undefined behavior due to a null value being used in a way forbidden by a returns_nonnull or nonnull attribute. Isolate those paths from the main control flow and turn the statement with erroneous or undefined behavior into a trap."
msgstr "Ausführungspfade erkennen, die ausgelöst werden, indem ein Nullwert auf eine Weise verwendet wird, die durch ein »returns_nonnull«- oder »nonnull«-Attribut verboten ist. Solche Pfade werden aus dem Hauptablauf herausgenommen und durch eine Trap ersetzt."
@@ -17417,10 +17407,9 @@ msgid "input file %qs is the same as output file"
msgstr "Eingabedatei %qs ist dieselbe wie die Ausgabedatei"
#: gcc.c:4476
-#, fuzzy, gcc-internal-format
-#| msgid "output file not specified"
+#, gcc-internal-format
msgid "output filename may not be empty"
-msgstr "keine Ausgabedatei angegeben"
+msgstr "Name der Ausgabedatei darf nicht leer sein"
#: gcc.c:4501
#, gcc-internal-format
@@ -18721,8 +18710,7 @@ msgid "types have different parameter counts"
msgstr "Typen haben unterschiedliche Anzahl von Parametern"
#: ipa-devirt.c:1229
-#, fuzzy, gcc-internal-format
-#| msgid "type %qT itself violate the C++ One Definition Rule"
+#, gcc-internal-format
msgid "type %qT itself violates the C++ One Definition Rule"
msgstr "Typ %qT verletzt für sich genommen die One-Definition-Rule von C++"
@@ -18822,8 +18810,7 @@ msgid "a field of same name but different type is defined in another translation
msgstr "ein Feld mit selbem Namen aber unterschiedlichem Typ ist in einer anderen Übersetzungseinheit definiert"
#: ipa-devirt.c:1576
-#, fuzzy, gcc-internal-format
-#| msgid "fields has different layout in another translation unit"
+#, gcc-internal-format
msgid "fields have different layout in another translation unit"
msgstr "Felder haben unterschiedliches Layout in einer anderen Übersetzungseinheit"
@@ -19638,16 +19625,14 @@ msgid "-fsanitize-address-use-after-scope requires -fstack-reuse=none option"
msgstr "»-fsanitize-address-use-after-scope« erfordert »-fstack-reuse=none«"
#: opts.c:1012
-#, fuzzy, gcc-internal-format
-#| msgid "transactional memory is not supported with non-call exceptions"
+#, gcc-internal-format
msgid "transactional memory is not supported with %<-fsanitize=address%>"
-msgstr "transaktionsbasierter Speicher wird von Nicht-Aufruf-Ausnahmen nicht unterstützt"
+msgstr "transaktionsbasierter Speicher wird von %<-fsanitize=address%> nicht unterstützt"
#: opts.c:1015
-#, fuzzy, gcc-internal-format
-#| msgid "transactional memory is not supported with non-call exceptions"
+#, gcc-internal-format
msgid "transactional memory is not supported with %<-fsanitize=kernel-address%>"
-msgstr "transaktionsbasierter Speicher wird von Nicht-Aufruf-Ausnahmen nicht unterstützt"
+msgstr "transaktionsbasierter Speicher wird von %<-fsanitize=kernel-address%> nicht unterstützt"
#: opts.c:1417
#, gcc-internal-format
@@ -26855,7 +26840,7 @@ msgstr "Attribut %qE kann nur auf Basistypen von Funktionszeiger angewandt werde
#: config/arm/arm.c:8656
#, gcc-internal-format
msgid "accessing thread-local storage is not currently supported with -mpure-code or -mslow-flash-data"
-msgstr ""
+msgstr "Zugriff auf threadlokalen Speicher wird derzeit mit %<-mpure-code%> oder %<-mslow-flash-data%> nicht unterstützt"
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79871
#: config/arm/arm.c:12232
@@ -27014,15 +26999,14 @@ msgstr "Funktion %qs kann keinen Wert zurückgeben"
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79883
#: config/avr/avr.c:1085
-#, fuzzy, gcc-internal-format
-#| msgid "%qs appears to be a misspelled %s handler, missing __vector prefix"
+#, gcc-internal-format
msgid "%qs appears to be a misspelled %qs handler, missing %<__vector%> prefix"
-msgstr "%qs scheint ein falsch geschriebener %qs-Handler zu sein, __vector-Präfix fehlt"
+msgstr "%qs scheint ein falsch geschriebener %qs-Handler zu sein, das Präfix %<__vector%> fehlt"
#: config/avr/avr.c:1098
#, gcc-internal-format
msgid "%qs is a reserved indentifier in AVR-LibC. Consider %<#include <avr/interrupt.h>%> before using the %qs macro"
-msgstr ""
+msgstr "%qs ist in der AVR-LibC ein reservierter Bezeichner. Erwägen Sie %<#include <avr/interrupt.h>%> vor der Benutzung des Makros %qs"
#: config/avr/avr.c:1327
#, gcc-internal-format
@@ -27132,10 +27116,9 @@ msgstr "Nur uninitialisierte Variablen können im .noinit-Bereich platziert werd
#. This might happen with C++ if stuff needs constructing.
#: config/avr/avr.c:10149
-#, fuzzy, gcc-internal-format
-#| msgid "uninitialized variable %q+D put into program memory area"
+#, gcc-internal-format
msgid "variable %q+D with dynamic initialization put into program memory area"
-msgstr "nicht initialisierte Variable %q+D in Programmspeicherbereich platziert"
+msgstr "dynamisch initialisierte Variable %q+D in Programmspeicherbereich platziert"
#: config/avr/avr.c:10160
#, gcc-internal-format
@@ -29986,7 +29969,7 @@ msgstr "hwcap %s ist ein ungültiges Argument für eingebaute Funktion %s"
#: config/rs6000/rs6000.c:15598
#, gcc-internal-format, gfc-internal-format
msgid "%s needs GLIBC (2.23 and newer) that exports hardware capability bits"
-msgstr ""
+msgstr "%s erfordert GLIBC (2.23 oder neuer), die Hardware-Fähigkeits-Bits exportiert"
#: config/rs6000/rs6000.c:15651
#, gcc-internal-format
@@ -30558,10 +30541,9 @@ msgid "%qF requires -mvx"
msgstr "%qF erfordert -mvx"
#: config/s390/s390-c.c:889
-#, fuzzy, gcc-internal-format
-#| msgid "%qF requires -march=arch12 or higher"
+#, gcc-internal-format
msgid "%qF requires z14 or higher"
-msgstr "%qF erfordert -march=arch12 oder höher"
+msgstr "%qF erfordert z14 oder höher"
#: config/s390/s390-c.c:903
#, gcc-internal-format
@@ -30579,10 +30561,9 @@ msgid "ambiguous overload for intrinsic %qs"
msgstr "mehrdeutiges Überladen für intrinsisches %qs"
#: config/s390/s390-c.c:966
-#, fuzzy, gcc-internal-format
-#| msgid "%qs matching variant requires -march=arch12 or higher"
+#, gcc-internal-format
msgid "%qs matching variant requires z14 or higher"
-msgstr "passende %qs-Variante erfordert -march=arch12 oder höher"
+msgstr "passende %qs-Variante erfordert z14 oder höher"
#: config/s390/s390-c.c:972
#, gcc-internal-format
@@ -30617,10 +30598,9 @@ msgid "builtin %qF requires -mvx (default with -march=z13 and higher)."
msgstr "eingebautes %qF wird nur mit -mvx unterstützt (standardmäßig für -march=z13 und höher eingeschaltet)"
#: config/s390/s390.c:853
-#, fuzzy, gcc-internal-format
-#| msgid "Builtin %qF requires arch12 or higher."
+#, gcc-internal-format
msgid "Builtin %qF requires z14 or higher."
-msgstr "Eingebaute %qF erfordert arch12 oder höher."
+msgstr "Eingebaute %qF erfordert z14 oder höher."
#: config/s390/s390.c:872
#, gcc-internal-format
@@ -30823,8 +30803,7 @@ msgid "bad value (%s) for -mcmodel= switch"
msgstr "Falscher Wert (%s) für Schalter -mcmodel="
#: config/sparc/sparc.c:1541
-#, fuzzy, gcc-internal-format
-#| msgid "-mcmodel= is not supported on 32 bit systems"
+#, gcc-internal-format
msgid "-mcmodel= is not supported on 32-bit systems"
msgstr "-mcmodel= wird auf 32-Bit-Systemen nicht unterstützt"
@@ -42886,10 +42865,9 @@ msgid "empty decomposition declaration"
msgstr "Leere Dekompositions-Deklaration"
#: cp/parser.c:13054
-#, fuzzy, gcc-internal-format
-#| msgid "invalid initializer for member function %qD"
+#, gcc-internal-format
msgid "invalid initializer for structured binding declaration"
-msgstr "ungültige Initialisierung für Elementfunktion %qD"
+msgstr "ungültige Initialisierung für strukturierte Bindungsdeklaration"
#: cp/parser.c:13220
#, gcc-internal-format
@@ -43614,14 +43592,12 @@ msgid "a brace-enclosed initializer is not allowed here"
msgstr "eine geschweift geklammerte Initialisierung ist hier nicht erlaubt"
#: cp/parser.c:23703
-#, fuzzy, gcc-internal-format
-#| msgid "%<virtual%> specified more than once in base-specified"
+#, gcc-internal-format
msgid "%<virtual%> specified more than once in base-specifier"
msgstr "%<virtual%> mehr als einmal in Basisspezifikation angegeben"
#: cp/parser.c:23723
-#, fuzzy, gcc-internal-format
-#| msgid "more than one access specifier in base-specified"
+#, gcc-internal-format
msgid "more than one access specifier in base-specifier"
msgstr "mehr als ein Zugriff in Basisspezifikation angegeben"
@@ -44879,22 +44855,19 @@ msgid "%qE is not a valid template argument of type %qT because %qD has no linka
msgstr "%qE ist kein gültiges Templateargument für Typ %qT, weil %qD keine Bindung hat"
#: cp/pt.c:6625
-#, fuzzy, gcc-internal-format
-#| msgid " variable-sized array type %qT is not a valid template argument"
+#, gcc-internal-format
msgid "the address of %qD is not a valid template argument"
-msgstr " Arraytyp %qT mit veränderlicher Größe ist kein gültiges Templateargument"
+msgstr "die Adresse von %qD ist kein gültiges Templateargument"
#: cp/pt.c:6634
-#, fuzzy, gcc-internal-format
-#| msgid " variable-sized array type %qT is not a valid template argument"
+#, gcc-internal-format
msgid "the address of the %qT subobject of %qD is not a valid template argument"
-msgstr " Arraytyp %qT mit veränderlicher Größe ist kein gültiges Templateargument"
+msgstr "die Adresse des %qT-Teilobjekts von %qD ist kein gültiges Templateargument"
#: cp/pt.c:6641
-#, fuzzy, gcc-internal-format
-#| msgid "%qE is not a valid template argument of type %qT because %qD does not have external linkage"
+#, gcc-internal-format
msgid "the address of %qD is not a valid template argument because it does not have static storage duration"
-msgstr "%qE ist kein gültiges Templateargument des Typs %qT, weil %qD keine externe Bindung hat"
+msgstr "die Adresse von %qD ist kein gültiges Templateargument, weil sie keine statische Lebensdauer hat"
#: cp/pt.c:6672
#, gcc-internal-format
@@ -52497,10 +52470,9 @@ msgid "NAMELIST object %qs in namelist %qs at %L with ALLOCATABLE or POINTER com
msgstr "NAMELIST-Objekt %qs in Namensliste %qs bei %L mit ALLOCATABLE- oder POINTER-Komponenten"
#: fortran/io.c:3317
-#, fuzzy, gcc-internal-format
-#| msgid "NAMELIST object %qs in namelist %qs at %L is polymorphic and requires a defined input/output procedure"
+#, gcc-internal-format
msgid "NAMELIST object %qs in namelist %qs at %L has ALLOCATABLE or POINTER components and thus requires a defined input/output procedure"
-msgstr "NAMELIST-Objekt %qs in Namensliste %qs bei %L ist polymorph und erfordert eine definierte Ein-/Ausgabeprozedur"
+msgstr "NAMELIST-Objekt %qs in Namensliste %qs bei %L hat ALLOCATABLE- oder POINTER-Komponenten erfordert daher eine definierte Ein-/Ausgabeprozedur"
#: fortran/io.c:3328
#, gcc-internal-format, gfc-internal-format
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ba84b703ee4..b91509e26c1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,263 @@
+2017-09-12 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ Backport from mainline
+ 2017-09-05 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR target/81833
+ * gcc.target/powerpc/pr81833-1.c: New file.
+ * gcc.target/powerpc/pr81833-2.c: New file.
+
+2017-09-10 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ Backport from mainline
+ 2017-05-11 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR target/80695
+ * gcc.target/powerpc/pr80695-p8.c: New file.
+ * gcc.target/powerpc/pr80695-p9.c: New file.
+
+2017-09-10 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR ada/79441
+ * gnat.dg/pack9.adb: Robustify.
+
+2017-09-10 Jonathan Wakely <jwakely@redhat.com>
+
+ PR c++/81852
+ * g++.dg/cpp1y/feat-cxx11.C: Check __cpp_threadsafe_static_init.
+ * g++.dg/cpp1y/feat-cxx14.C: Likewise.
+ * g++.dg/cpp1y/feat-cxx98.C: Likewise.
+ * g++.dg/cpp1y/feat-neg.C: Likewise.
+ * g++.dg/cpp1z/feat-cxx1z.C: Likewise.
+
+2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/specs/atomic3.ads: New test.
+
+2017-09-09 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/specs/vfa.ads: Rename into...
+ * gnat.dg/specs/vfa1.ads: ...this.
+ * gnat.dg/specs/vfa2.ads: New test.
+
+2017-09-08 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc.dg/pr81988.c: New test.
+
+2017-09-07 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2017-09-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/81768
+ * gcc.dg/gomp/pr81768-2.c: New test.
+
+ PR middle-end/81768
+ * gcc.dg/gomp/pr81768-1.c: New test.
+
+ 2017-09-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR sanitizer/81923
+ * gcc.dg/asan/pr81923.c: New test.
+
+ 2017-08-03 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/81621
+ * gcc.dg/pr81621.c: New test.
+
+ PR driver/81650
+ * gcc.dg/pr81650.c: New test.
+
+ PR middle-end/81052
+ * c-c++-common/pr81052.c: New test.
+
+2017-09-06 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ Backport from mainline:
+ 2017-08-30 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ PR tree-optimization/81987
+ * g++.dg/torture/pr81987.C: New file.
+
+2017-09-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR testsuite/82120
+ * gcc.dg/tree-ssa/pr81588.c: Don't run on logical_op_short_circuit
+ targets except for those where -mbranch-cost=2 is supported.
+
+2017-09-05 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+
+ Backport from mainline
+ 2017-08-29 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
+ Jakub Jelinek <jakub@redhat.com>
+ Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81503
+ * gcc.c-torture/execute/pr81503.c: New file.
+
+2017-09-05 Pierre-Marie de Rodat <derodat@adacore.com>
+
+ Backport from trunk
+ PR ada/79542
+ * gnat.dg/debug13.ads, gnat.dg/debug13.adb: New testcase.
+
+2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/incomplete5.ad[sb]: New test.
+ * gnat.dg/incomplete5_pkg.ad[sb]: New helper.
+
+2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/specs/uc2.ads: New test.
+
+2017-09-05 Eric Botcazou <ebotcazou@adacore.com>
+
+ * testsuite/gnat.dg/array29.ad[sb]: New test.
+
+2017-09-04 Uros Bizjak <ubizjak@gmail.com>
+
+ * gcc.target/i386/mpx/mpx-os-support.h: New file.
+ * gcc.target/i386/mpx/mpx-check.h: Include mpx-os-support.h.
+ (check_osxsave): New function.
+ (main): Use __get_cpuid_count and return NORUNRES on failure.
+ Use check_osxsave.
+ * gcc.target/i386/mpx/va-arg-pack-1-lbv.c (foo1): Use
+ __builtin_va_arg_pack instead of __va_arg_pack.
+ * gcc.target/i386/mpx/va-arg-pack-1-nov.c (foo1): Ditto.
+ * gcc.target/i386/mpx/va-arg-pack-1-ubv.c (foo1): Ditto.
+ * gcc.target/i386/mpx/va-arg-pack-2-lbv.c (foo1): Ditto.
+ * gcc.target/i386/mpx/va-arg-pack-2-nov.c (foo1): Ditto.
+ * gcc.target/i386/mpx/va-arg-pack-2-ubv.c (foo1): Ditto.
+
+2017-09-02 Janus Weil <janus@gcc.gnu.org>
+
+ Backport from trunk
+ PR fortran/81770
+ * gfortran.dg/warn_target_lifetime_3.f90: Fix a typo.
+ * gfortran.dg/warn_target_lifetime_4.f90: New testcase.
+
+2017-08-29 Michael Meissner <meissner@linux.vnet.ibm.com>
+
+ Back port from trunk
+ 2017-08-07 Michael Meissner <meissner@linux.vnet.ibm.com>
+
+ PR target/81593
+ * gcc.target/powerpc/vec-setup.h: New tests to test various
+ combinations of setting up vectors of 2 double word elements.
+ * gcc.target/powerpc/vec-setup-long.c: Likewise.
+ * gcc.target/powerpc/vec-setup-double.c: Likewise.
+ * gcc.target/powerpc/vec-setup-be-long.c: Likewise.
+ * gcc.target/powerpc/vec-setup-be-double.c: Likewise.
+ * gcc.target/powerpc/vsx-extract-6.c: New tests for optimzing
+ vector inserts from vector extracts.
+ * gcc.target/powerpc/vsx-extract-7.c: Likewise.
+
+2017-08-29 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2017-08-28 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81977
+ * g++.dg/torture/pr81977.C: New testcase.
+
+2017-08-28 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2017-06-14 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/81088
+ * c-c++-common/ubsan/pr81088.c: New testcase.
+
+ 2017-06-13 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/81065
+ * c-c++-common/ubsan/pr81065.c: New testcase.
+
+ 2017-06-08 Marek Polacek <polacek@redhat.com>
+
+ PR sanitize/80932
+ * c-c++-common/ubsan/pr80932.c: Test with ints, not with long ints.
+
+ 2017-06-07 Marek Polacek <polacek@redhat.com>
+
+ PR sanitizer/80932
+ * c-c++-common/ubsan/pr80932.c: New test.
+
+2017-08-28 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2017-08-21 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/81884
+ * g++.dg/torture/pr81884.C: New testcase.
+
+2017-08-28 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2017-08-01 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81181
+ * gcc.dg/torture/pr81181.c: New testcase.
+
+ 2017-08-08 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81723
+ * gfortran.dg/pr81723.f: New testcase.
+
+ 2017-08-24 Richard Biener <rguenther@suse.de>
+
+ PR target/81921
+ * gcc/testsuite/gcc.target/i386/pr81921.c: New testcase.
+
+2017-05-19 Uros Bizjak <ubizjak@gmail.com>
+
+ Backport from mainline
+ 2017-08-23 Daniel Santos <daniel.santos@pobox.com>
+
+ * lib/target-supports.exp (check_avx2_hw_available):
+ Fix breakage due NULL being undefined.
+
+2017-08-23 Peter Bergner <bergner@vnet.ibm.com>
+
+ Backport from mainline
+ 2017-08-17 Peter Bergner <bergner@vnet.ibm.com>
+
+ PR target/72804
+ * gcc.target/powerpc/pr72804.c: New test.
+
+2017-08-22 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ Backport from trunk
+ PR fortran/81296
+ * gfortran.dg/dtio_12.f90: Update test.
+
+2017-08-22 Peter Bergner <bergner@vnet.ibm.com>
+
+ Backport from mainline
+ 2017-08-17 Peter Bergner <bergner@vnet.ibm.com>
+
+ PR target/80210
+ * gcc.target/powerpc/pr80210.c: New test.
+
+2017-08-22 Yvan Roux <yvan.roux@linaro.org>
+
+ Backport from mainline
+ 2017-08-22 Yvan Roux <yvan.roux@linaro.org>
+
+ PR c++/80287
+ * g++.dg/pr80287.C: New test.
+
+2017-08-20 John David Anglin <danglin@gcc.gnu.org>
+
+ PR ipa/77732
+ * gcc.dg/ipa/ipcp-cstagg-7.c: Xfail on 32-bit hppa.
+
+2017-08-18 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ Backport from trunk
+ PR fortran/80164
+ * gfortran.dg/array_temporaries_4.f90: New test.
+
2017-08-16 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Backport from mainline
diff --git a/gcc/testsuite/c-c++-common/pr81052.c b/gcc/testsuite/c-c++-common/pr81052.c
new file mode 100644
index 00000000000..6bc2879951e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr81052.c
@@ -0,0 +1,28 @@
+/* PR middle-end/81052 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp-simd -O2" } */
+
+int
+foo (int x, int y)
+{
+ int i;
+#pragma omp simd
+ for (i = x; i < y; ++i)
+ return 0; /* { dg-error "invalid branch to/from OpenMP structured block" } */
+ return 1;
+}
+
+#ifdef __cplusplus
+template <typename T>
+T
+bar (T x, T y)
+{
+ T i;
+#pragma omp simd
+ for (i = x; i < y; ++i)
+ return 0; /* { dg-error "invalid branch to/from OpenMP structured block" "" { target c++ } } */
+ return 1;
+}
+
+int x = bar (1, 7);
+#endif
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr80932.c b/gcc/testsuite/c-c++-common/ubsan/pr80932.c
new file mode 100644
index 00000000000..92903f7e0ee
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/pr80932.c
@@ -0,0 +1,17 @@
+/* PR sanitizer/80932 */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+
+int x = 1;
+
+int
+foo (void)
+{
+ return ((int) (2855545792U * x) - (int) (3269399503U * x)) * -5;
+}
+
+int
+main ()
+{
+ foo ();
+}
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr81065.c b/gcc/testsuite/c-c++-common/ubsan/pr81065.c
new file mode 100644
index 00000000000..1b342273f95
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/pr81065.c
@@ -0,0 +1,13 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+
+unsigned char x = 154;
+int foo() {
+ // 8575 * (254408 - 9057) = 8575 * 245351 = 2103884825 = 0x7d66bc19
+ return 8575 * (1652 * x - 9057);
+}
+
+int main() {
+ foo();
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr81088.c b/gcc/testsuite/c-c++-common/ubsan/pr81088.c
new file mode 100644
index 00000000000..6753d77fbad
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/pr81088.c
@@ -0,0 +1,11 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined -fsanitize-undefined-trap-on-error" } */
+
+short s = 2;
+short y = 1;
+int i;
+int main()
+{
+ i = -(s + (int)(~(unsigned)(0 / y))) + 0x7fffffff;
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C
index 98112218d8f..b18fcfabad4 100644
--- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C
+++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C
@@ -125,6 +125,12 @@
# error "__cpp_alias_templates != 200704"
#endif
+#ifndef __cpp_threadsafe_static_init
+# error "__cpp_threadsafe_static_init"
+#elif __cpp_threadsafe_static_init != 200806
+# error "__cpp_threadsafe_static_init != 200806"
+#endif
+
// C++14 features allowed in C++11 in non-ANSI modes:
#ifndef __cpp_binary_literals
diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C
index 3b141ef67c4..412b9a33b8f 100644
--- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C
+++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C
@@ -118,6 +118,12 @@
# error "__cpp_alias_templates != 200704"
#endif
+#ifndef __cpp_threadsafe_static_init
+# error "__cpp_threadsafe_static_init"
+#elif __cpp_threadsafe_static_init != 200806
+# error "__cpp_threadsafe_static_init != 200806"
+#endif
+
// C++14 features:
#ifndef __cpp_binary_literals
diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C
index d15e7aadcee..4db499cc2f4 100644
--- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C
+++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C
@@ -15,6 +15,14 @@
# error "__cpp_exceptions != 199711"
#endif
+// C++11 features allowed in C++98:
+
+#ifndef __cpp_threadsafe_static_init
+# error "__cpp_threadsafe_static_init"
+#elif __cpp_threadsafe_static_init != 200806
+# error "__cpp_threadsafe_static_init != 200806"
+#endif
+
// C++14 features allowed in C++98 in non-ANSI modes:
#ifndef __cpp_binary_literals
diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-neg.C
index 9f4a0412403..5e95418dfe4 100644
--- a/gcc/testsuite/g++.dg/cpp1y/feat-neg.C
+++ b/gcc/testsuite/g++.dg/cpp1y/feat-neg.C
@@ -1,5 +1,5 @@
// { dg-do compile }
-// { dg-options "-fno-rtti -fno-exceptions" }
+// { dg-options "-fno-rtti -fno-exceptions -fno-threadsafe-statics" }
// C++98 features with explicit opt-out:
@@ -10,3 +10,9 @@
#ifndef __cpp_exceptions
# error "__cpp_exceptions" // { dg-error "error" }
#endif
+
+// C++11 features with explicit opt-out:
+
+#ifndef __cpp_threadsafe_static_init
+# error "__cpp_threadsafe_static_init" // { dg-error "error" }
+#endif
diff --git a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C
index e424e1c0ff0..a7c6cfe5169 100644
--- a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C
+++ b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C
@@ -106,6 +106,12 @@
# error "__cpp_alias_templates != 200704"
#endif
+#ifndef __cpp_threadsafe_static_init
+# error "__cpp_threadsafe_static_init"
+#elif __cpp_threadsafe_static_init != 200806
+# error "__cpp_threadsafe_static_init != 200806"
+#endif
+
// C++14 features:
#ifndef __cpp_binary_literals
diff --git a/gcc/testsuite/g++.dg/other/bitfield6.C b/gcc/testsuite/g++.dg/other/bitfield6.C
new file mode 100644
index 00000000000..c1e8a17989b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/bitfield6.C
@@ -0,0 +1,9 @@
+// PR c++/81607
+
+int a;
+
+struct b {
+ long c : 32;
+} d;
+
+char f = (903092 ? int(d.c) : 0) << a;
diff --git a/gcc/testsuite/g++.dg/pr80287.C b/gcc/testsuite/g++.dg/pr80287.C
new file mode 100644
index 00000000000..da8d3fab150
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr80287.C
@@ -0,0 +1,13 @@
+// PR c++/80287
+// { dg-do compile { target c++11 } }
+// { dg-options "-g" }
+
+struct A {
+ operator long() {}
+} __attribute__((__may_alias__));
+
+struct {
+ A ino;
+} a;
+
+char b = a.ino;
diff --git a/gcc/testsuite/g++.dg/torture/pr81884.C b/gcc/testsuite/g++.dg/torture/pr81884.C
new file mode 100644
index 00000000000..f545355ce35
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr81884.C
@@ -0,0 +1,39 @@
+/* { dg-do run } */
+
+typedef unsigned long uint64_t;
+
+struct value_t {
+ uint64_t _count;
+ value_t(uint64_t c) : _count(c) {}
+};
+
+struct X {
+ value_t eventTime;
+ uint64_t arr[0];
+};
+
+X* x;
+
+__attribute__((noclone, noinline))
+void initialize()
+{
+ x->arr[0] = 11;
+ x->arr[1] = 12;
+ x->eventTime = value_t(10);
+ x->arr[2] = 13;
+ x->arr[3] = 14;
+}
+
+int main()
+{
+ char buffer[sizeof(X) + sizeof(uint64_t)*4];
+ x = (X*)buffer;
+ x->eventTime = value_t(999);
+ x->arr[0] = 1;
+ x->arr[1] = 2;
+ x->arr[2] = 3;
+ x->arr[3] = 4;
+ initialize();
+ if (x->arr[0] != 11 || x->arr[1] != 12 || x->arr[2] != 13 || x->arr[3] != 14)
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr81977.C b/gcc/testsuite/g++.dg/torture/pr81977.C
new file mode 100644
index 00000000000..a8c8ba02b00
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr81977.C
@@ -0,0 +1,55 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+#include <cstdint>
+
+typedef struct
+{
+ uint16_t x ;
+ uint16_t y ;
+ uint64_t z ;
+} __attribute__((packed, aligned(1))) TestMsgType;
+
+struct Payload
+{
+ uint16_t header_info[2];
+ TestMsgType _pref;
+ void Pack(uint8_t *buffer)
+ {
+ __builtin_memcpy(buffer, &_pref, sizeof(_pref));
+ }
+ void UnPack(uint8_t *buffer)
+ {
+ __builtin_memcpy(&_pref, buffer, sizeof(_pref));
+ }
+};
+
+
+struct Msg
+{
+ Payload _payload;
+ void Pack(uint8_t *buffer)
+ {
+ _payload.Pack(buffer);
+ }
+
+ void UnPack(uint8_t *buffer)
+ {
+ _payload.UnPack(buffer);
+ }
+};
+
+int main()
+{
+ uint8_t * buffer = new uint8_t [30];
+ Msg msg;
+ Msg msg1;
+ msg._payload._pref.x = 0xabcd;
+ msg._payload._pref.y = 0xa;
+ msg._payload._pref.z = 0x0001020304051617;
+ msg.Pack(&buffer[0]);
+ msg1.UnPack(&buffer[0]);
+ if (msg1._payload._pref.x != 0xabcd)
+ __builtin_abort ();
+ delete [] buffer;
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr81987.C b/gcc/testsuite/g++.dg/torture/pr81987.C
new file mode 100644
index 00000000000..4579332ad71
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr81987.C
@@ -0,0 +1,61 @@
+extern short var_1;
+extern const short var_3;
+extern unsigned long int var_9;
+extern short var_13;
+extern const unsigned long int var_15;
+extern const unsigned long int var_37;
+extern unsigned long int var_40;
+extern long long int var_47;
+extern short var_48;
+extern const short var_54;
+extern long long int var_79;
+extern long long int var_81;
+extern long long int var_94;
+extern long long int var_95;
+extern long long int var_701;
+extern unsigned long int var_786;
+extern short var_788;
+extern long long int var_844;
+
+struct struct_1 {
+ short member_1_2 : 15;
+ static long long int member_1_3;
+};
+
+extern struct_1 struct_obj_6;
+extern struct_1 struct_obj_8;
+
+void foo() {
+ int a = var_3 <= 602154393864UL;
+ if (var_81 ? 0 : var_3 && var_9)
+ ;
+ else {
+ var_94 = 0;
+ if (var_3 && var_48 || var_13) {
+ if (var_48)
+ var_95 = 0;
+ short b((2364461588881776511UL + var_3) * (2 ? var_13 : 0) || var_1);
+ struct_obj_8.member_1_2 = b;
+ if (var_15) {
+ if (var_81)
+ if (var_47)
+ ;
+ else if (var_40)
+ var_701 = 0;
+ } else {
+ if (var_40)
+ var_79 = 0;
+ if (var_54) {
+ if (var_37)
+ var_786 = 0;
+ else
+ var_788 = 0;
+ struct_obj_6.member_1_3 =
+ (2364461588881776511UL + var_3) * (2 ? var_13 : 0);
+ }
+ }
+ if ((2364461588881776511UL + var_3) * (2 ? var_13 : 0))
+ var_844 = 0;
+ }
+ }
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wbool-operation-1.C b/gcc/testsuite/g++.dg/warn/Wbool-operation-1.C
new file mode 100644
index 00000000000..4512b858287
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wbool-operation-1.C
@@ -0,0 +1,11 @@
+// PR c++/82040
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wbool-operation" }
+
+template <class c>
+decltype (~c{})
+call ()
+{
+ return ~false; // { dg-warning "on an expression of type bool" }
+}
+template int call<bool>();
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr81503.c b/gcc/testsuite/gcc.c-torture/execute/pr81503.c
new file mode 100644
index 00000000000..5fc6cb0e83c
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr81503.c
@@ -0,0 +1,15 @@
+unsigned short a = 41461;
+unsigned short b = 3419;
+int c = 0;
+
+void foo() {
+ if (a + b * ~(0 != 5))
+ c = -~(b * ~(0 != 5)) + 2147483647;
+}
+
+int main() {
+ foo();
+ if (c != 2147476810)
+ return -1;
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/asan/pr81923.c b/gcc/testsuite/gcc.dg/asan/pr81923.c
new file mode 100644
index 00000000000..f81d512c96e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr81923.c
@@ -0,0 +1,10 @@
+/* PR sanitizer/81923 */
+/* { dg-do link } */
+
+int foobar __asm (__USER_LABEL_PREFIX__ "barbaz") = 34;
+
+int
+main ()
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/pr81768-1.c b/gcc/testsuite/gcc.dg/gomp/pr81768-1.c
new file mode 100644
index 00000000000..3b8c26a23ec
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/pr81768-1.c
@@ -0,0 +1,15 @@
+/* PR middle-end/81768 */
+/* { dg-do compile } */
+
+float b[10][15][10];
+
+void
+foo (void)
+{
+ float *i;
+#pragma omp target parallel for simd schedule(static, 32) collapse(3)
+ for (i = &b[0][0][0]; i < &b[0][0][10]; i++)
+ for (float *j = &b[0][15][0]; j > &b[0][0][0]; j -= 10)
+ for (float *k = &b[0][0][10]; k > &b[0][0][0]; --k)
+ b[i - &b[0][0][0]][(j - &b[0][0][0]) / 10 - 1][(k - &b[0][0][0]) - 1] -= 3.5;
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/pr81768-2.c b/gcc/testsuite/gcc.dg/gomp/pr81768-2.c
new file mode 100644
index 00000000000..64ae66f16ea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/pr81768-2.c
@@ -0,0 +1,15 @@
+/* PR middle-end/81768 */
+/* { dg-do compile } */
+
+float b[10][15][10];
+
+void
+foo (void)
+{
+ float *i;
+#pragma omp target parallel for schedule(static, 32) collapse(3)
+ for (i = &b[0][0][0]; i < &b[0][0][10]; i++)
+ for (float *j = &b[0][15][0]; j > &b[0][0][0]; j -= 10)
+ for (float *k = &b[0][0][10]; k > &b[0][0][0]; --k)
+ b[i - &b[0][0][0]][(j - &b[0][0][0]) / 10 - 1][(k - &b[0][0][0]) - 1] -= 3.5;
+}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-7.c b/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-7.c
index 6af8bda6d8e..b08c420cd86 100644
--- a/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-7.c
+++ b/gcc/testsuite/gcc.dg/ipa/ipcp-cstagg-7.c
@@ -62,4 +62,4 @@ h (int x)
return bar (s, x);
}
-/* { dg-final { scan-ipa-dump-times "Discovered an indirect call to a known target" 3 "cp" } } */
+/* { dg-final { scan-ipa-dump-times "Discovered an indirect call to a known target" 3 "cp" { xfail { hppa*-*-* && { ! lp64 } } } } } */
diff --git a/gcc/testsuite/gcc.dg/pr81621.c b/gcc/testsuite/gcc.dg/pr81621.c
new file mode 100644
index 00000000000..fb41eab8961
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr81621.c
@@ -0,0 +1,5 @@
+/* PR target/81621 */
+/* { dg-do compile { target freorder } } */
+/* { dg-options "-Og -fno-split-wide-types -freorder-blocks-and-partition" } */
+
+#include "graphite/scop-10.c"
diff --git a/gcc/testsuite/gcc.dg/pr81650.c b/gcc/testsuite/gcc.dg/pr81650.c
new file mode 100644
index 00000000000..99e84ded30d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr81650.c
@@ -0,0 +1,9 @@
+/* PR driver/81650 */
+/* { dg-do compile } */
+/* { dg-options "-Walloc-size-larger-than=9223372036854775807" } */
+
+void *
+foo (void)
+{
+ return __builtin_malloc (5);
+}
diff --git a/gcc/testsuite/gcc.dg/pr81988.c b/gcc/testsuite/gcc.dg/pr81988.c
new file mode 100644
index 00000000000..dbbf436f27b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr81988.c
@@ -0,0 +1,22 @@
+/* PR target/81988 */
+/* Testcase by James Cowgill <jcowgill+gcc@jcowgill.uk> */
+
+/* { dg-do assemble } */
+/* { dg-require-effective-target pie } */
+/* { dg-options "-O3 -fpie" } */
+
+int c, d;
+
+short **e;
+int *a;
+
+void foo(void)
+{
+ int g[64 * 35], *h = g;
+ do {
+ short *f = e[d];
+ for (int i = 0; i < 4; i++)
+ a[i] = a[i] + (h[364] + f[4] * h[64] + f[5] * h[i] + f[6] * h[i + 3 * 4] +
+ f[7] * h[i + 4]);
+ } while (c);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr81181.c b/gcc/testsuite/gcc.dg/torture/pr81181.c
new file mode 100644
index 00000000000..e7216d7bf3e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr81181.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+
+unsigned int lh;
+
+void
+ny (int t3, int ys, int rt, int p8)
+{
+ if (lh != 0)
+ {
+ if (0)
+ {
+oo:
+ do
+ {
+ rt = (p8 != 0) ? t3 : 0;
+ rt = (rt != 0 || lh != (unsigned int)ys);
+ rt += lh + ys;
+ }
+ while (t3 <= 0);
+
+ lh = ys;
+ ys = rt;
+ }
+
+ if (lh != 0)
+ p8 = lh;
+ }
+
+ goto oo;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81588.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81588.c
index 1abbd71d03f..4ed8b16c97f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr81588.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81588.c
@@ -1,5 +1,5 @@
/* PR tree-optimization/81588 */
-/* { dg-do compile { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* hppa*-*-* nios2*-*-*" } } } */
+/* { dg-do compile { target { ! { { logical_op_short_circuit && { ! "mips*-*-* avr-*-* s390*-*-*" } } || { m68k*-*-* bfin*-*-* v850*-*-* moxie*-*-* m32c*-*-* fr30*-*-* mcore*-*-* xtensa*-*-* hppa*-*-* } } } } } */
/* { dg-options "-O2 -fdump-tree-reassoc1-details" } */
/* { dg-additional-options "-mbranch-cost=2" { target mips*-*-* avr-*-* s390*-*-* i?86-*-* x86_64-*-* } } */
diff --git a/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h b/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h
index 73aa01f2565..e622934fe32 100644
--- a/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h
+++ b/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h
@@ -1,8 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
-
#include "cpuid.h"
+#include "mpx-os-support.h"
static int
__attribute__ ((noinline))
@@ -16,14 +16,13 @@ mpx_test (int, const char **);
#define DEBUG
-#define XSTATE_BNDREGS (1 << 3)
-
-/* This should be an intrinsic, but isn't. */
-static int xgetbv (unsigned x)
+static int
+check_osxsave (void)
{
- unsigned eax, edx;
- asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (x));
- return eax;
+ unsigned int eax, ebx, ecx, edx;
+
+ __cpuid (1, eax, ebx, ecx, edx);
+ return (ecx & bit_OSXSAVE) != 0;
}
int
@@ -31,13 +30,11 @@ main (int argc, const char **argv)
{
unsigned int eax, ebx, ecx, edx;
- if (__get_cpuid_max (0, NULL) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
+ if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
+ return NORUNRES;
/* Run MPX test only if host has MPX support. */
- if ((ebx & bit_MPX) && (xgetbv (0) & XSTATE_BNDREGS))
+ if (check_osxsave () && (ebx & bit_MPX) && mpx_os_support ())
mpx_test (argc, argv);
else
{
diff --git a/gcc/testsuite/gcc.target/i386/mpx/mpx-os-support.h b/gcc/testsuite/gcc.target/i386/mpx/mpx-os-support.h
new file mode 100644
index 00000000000..8c9294d33a5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/mpx-os-support.h
@@ -0,0 +1,16 @@
+/* Check if the OS supports executing MPX instructions. */
+
+#define XCR_XFEATURE_ENABLED_MASK 0x0
+
+#define XSTATE_BNDREGS 0x8
+
+static int
+mpx_os_support (void)
+{
+ unsigned int eax, edx;
+ unsigned int ecx = XCR_XFEATURE_ENABLED_MASK;
+
+ __asm__ ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (ecx));
+
+ return (eax & XSTATE_BNDREGS) != 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-lbv.c
index 5aa60072df3..bbbb256ae30 100644
--- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-lbv.c
+++ b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-lbv.c
@@ -28,7 +28,7 @@ foo2 (int i1, int *p1, ...)
static __attribute__((always_inline)) int
foo1 (int *p1, ...)
{
- return foo2 (10, p1, __va_arg_pack ());
+ return foo2 (10, p1, __builtin_va_arg_pack ());
}
int prebuf[100];
diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-nov.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-nov.c
index 55c65d92bd9..4beda02b951 100644
--- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-nov.c
+++ b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-nov.c
@@ -25,7 +25,7 @@ foo2 (int i1, int *p1, ...)
static __attribute__((always_inline)) int
foo1 (int *p1, ...)
{
- return foo2 (10, p1, __va_arg_pack ());
+ return foo2 (10, p1, __builtin_va_arg_pack ());
}
int prebuf[100];
diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-ubv.c
index 11b498eba47..4b763842755 100644
--- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-ubv.c
+++ b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-1-ubv.c
@@ -28,7 +28,7 @@ foo2 (int i1, int *p1, ...)
static __attribute__((always_inline)) int
foo1 (int *p1, ...)
{
- return foo2 (10, p1, __va_arg_pack ());
+ return foo2 (10, p1, __builtin_va_arg_pack ());
}
int prebuf[100];
diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-lbv.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-lbv.c
index 9f1941d69f1..dab1dc86792 100644
--- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-lbv.c
+++ b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-lbv.c
@@ -30,7 +30,7 @@ foo2 (int i1, int *p1, ...)
static __attribute__((always_inline)) int
foo1 (int *p1, ...)
{
- return foo2 (10, p1, __va_arg_pack ());
+ return foo2 (10, p1, __builtin_va_arg_pack ());
}
int prebuf[100];
diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-nov.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-nov.c
index 903afbce292..6bf4721f75a 100644
--- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-nov.c
+++ b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-nov.c
@@ -27,7 +27,7 @@ foo2 (int i1, int *p1, ...)
static __attribute__((always_inline)) int
foo1 (int *p1, ...)
{
- return foo2 (10, p1, __va_arg_pack ());
+ return foo2 (10, p1, __builtin_va_arg_pack ());
}
int prebuf[100];
diff --git a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-ubv.c b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-ubv.c
index f5d842abf0d..4af59758fb0 100644
--- a/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-ubv.c
+++ b/gcc/testsuite/gcc.target/i386/mpx/va-arg-pack-2-ubv.c
@@ -30,7 +30,7 @@ foo2 (int i1, int *p1, ...)
static __attribute__((always_inline)) int
foo1 (int *p1, ...)
{
- return foo2 (10, p1, __va_arg_pack ());
+ return foo2 (10, p1, __builtin_va_arg_pack ());
}
int prebuf[100];
diff --git a/gcc/testsuite/gcc.target/i386/pr81921.c b/gcc/testsuite/gcc.target/i386/pr81921.c
new file mode 100644
index 00000000000..332c0b81a35
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr81921.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target lto } */
+/* { dg-options "-flto -march=x86-64" } */
+
+extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__, target("sse2")))
+_mm_loadu_si128 (int const *__P)
+{
+ return *__P;
+}
+
+void __attribute__((target("ssse3"))) foo (void *p)
+{
+ volatile int x = _mm_loadu_si128 (p);
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr72804.c b/gcc/testsuite/gcc.target/powerpc/pr72804.c
new file mode 100644
index 00000000000..b83b6350d75
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr72804.c
@@ -0,0 +1,25 @@
+/* { dg-do compile { target { lp64 } } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O2 -mvsx" } */
+
+__int128_t
+foo (__int128_t *src)
+{
+ return ~*src;
+}
+
+void
+bar (__int128_t *dst, __int128_t src)
+{
+ *dst = ~src;
+}
+
+/* { dg-final { scan-assembler-times "not " 4 } } */
+/* { dg-final { scan-assembler-times "std " 2 } } */
+/* { dg-final { scan-assembler-times "ld " 2 } } */
+/* { dg-final { scan-assembler-not "lxvd2x" } } */
+/* { dg-final { scan-assembler-not "stxvd2x" } } */
+/* { dg-final { scan-assembler-not "xxpermdi" } } */
+/* { dg-final { scan-assembler-not "mfvsrd" } } */
+/* { dg-final { scan-assembler-not "mfvsrd" } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr80210.c b/gcc/testsuite/gcc.target/powerpc/pr80210.c
new file mode 100644
index 00000000000..9e2f2d9da49
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr80210.c
@@ -0,0 +1,10 @@
+/* Test for ICE arising from GCC target pragma. */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+double
+foo (double a)
+{
+ return __builtin_sqrt (a);
+}
+#pragma GCC target "no-powerpc-gpopt"
diff --git a/gcc/testsuite/gcc.target/powerpc/pr80695-p8.c b/gcc/testsuite/gcc.target/powerpc/pr80695-p8.c
new file mode 100644
index 00000000000..165079a3a6c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr80695-p8.c
@@ -0,0 +1,18 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
+/* { dg-require-effective-target vect_int } */
+/* { dg-options "-mcpu=power8 -O3 -fdump-tree-slp-details" } */
+
+/* PR80695: Verify cost model for vec_construct on POWER8. */
+
+long a[10] __attribute__((aligned(16)));
+
+void foo (long i, long j, long k, long l)
+{
+ a[6] = i;
+ a[7] = j;
+ a[8] = k;
+ a[9] = l;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorization is not profitable" 1 "slp2" } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr80695-p9.c b/gcc/testsuite/gcc.target/powerpc/pr80695-p9.c
new file mode 100644
index 00000000000..a81f90ac3c4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr80695-p9.c
@@ -0,0 +1,18 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target vect_int } */
+/* { dg-options "-mcpu=power9 -O3 -fdump-tree-slp-details" } */
+
+/* PR80695: Verify cost model for vec_construct on POWER9. */
+
+long a[10] __attribute__((aligned(16)));
+
+void foo (long i, long j, long k, long l)
+{
+ a[6] = i;
+ a[7] = j;
+ a[8] = k;
+ a[9] = l;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorization is not profitable" 1 "slp2" } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr81833-1.c b/gcc/testsuite/gcc.target/powerpc/pr81833-1.c
new file mode 100644
index 00000000000..ca5ce006d20
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr81833-1.c
@@ -0,0 +1,59 @@
+/* PR81833: This used to fail due to improper implementation of vec_msum. */
+/* Test case relies on -mcpu=power7 or later. Currently we don't have
+ machinery to express that, so we have two separate tests for -mcpu=power7
+ and -mcpu=power8 to catch 32-bit BE on P7 and 64-bit BE/LE on P8. */
+
+/* { dg-do run } */
+/* { dg-require-effective-target p8vector_hw } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
+/* { dg-options "-mcpu=power8 -O2" } */
+
+#include <altivec.h>
+
+#define vec_u8 vector unsigned char
+#define vec_s8 vector signed char
+#define vec_u16 vector unsigned short
+#define vec_s16 vector signed short
+#define vec_u32 vector unsigned int
+#define vec_s32 vector signed int
+#define vec_f vector float
+
+#define LOAD_ZERO const vec_u8 zerov = vec_splat_u8 (0)
+
+#define zero_u8v (vec_u8) zerov
+#define zero_s8v (vec_s8) zerov
+#define zero_u16v (vec_u16) zerov
+#define zero_s16v (vec_s16) zerov
+#define zero_u32v (vec_u32) zerov
+#define zero_s32v (vec_s32) zerov
+
+signed int __attribute__((noinline))
+scalarproduct_int16_vsx (const signed short *v1, const signed short *v2,
+ int order)
+{
+ int i;
+ LOAD_ZERO;
+ register vec_s16 vec1;
+ register vec_s32 res = vec_splat_s32 (0), t;
+ signed int ires;
+
+ for (i = 0; i < order; i += 8) {
+ vec1 = vec_vsx_ld (0, v1);
+ t = vec_msum (vec1, vec_vsx_ld (0, v2), zero_s32v);
+ res = vec_sums (t, res);
+ v1 += 8;
+ v2 += 8;
+ }
+ res = vec_splat (res, 3);
+ vec_ste (res, 0, &ires);
+
+ return ires;
+}
+
+int main(void)
+{
+ const signed short test_vec[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
+ if (scalarproduct_int16_vsx (test_vec, test_vec, 8) != 8)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr81833-2.c b/gcc/testsuite/gcc.target/powerpc/pr81833-2.c
new file mode 100644
index 00000000000..e9286833469
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr81833-2.c
@@ -0,0 +1,59 @@
+/* PR81833: This used to fail due to improper implementation of vec_msum. */
+/* Test case relies on -mcpu=power7 or later. Currently we don't have
+ machinery to express that, so we have two separate tests for -mcpu=power7
+ and -mcpu=power8 to catch 32-bit BE on P7 and 64-bit BE/LE on P8. */
+
+/* { dg-do run } */
+/* { dg-require-effective-target vsx_hw } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
+/* { dg-options "-mcpu=power7 -O2" } */
+
+#include <altivec.h>
+
+#define vec_u8 vector unsigned char
+#define vec_s8 vector signed char
+#define vec_u16 vector unsigned short
+#define vec_s16 vector signed short
+#define vec_u32 vector unsigned int
+#define vec_s32 vector signed int
+#define vec_f vector float
+
+#define LOAD_ZERO const vec_u8 zerov = vec_splat_u8 (0)
+
+#define zero_u8v (vec_u8) zerov
+#define zero_s8v (vec_s8) zerov
+#define zero_u16v (vec_u16) zerov
+#define zero_s16v (vec_s16) zerov
+#define zero_u32v (vec_u32) zerov
+#define zero_s32v (vec_s32) zerov
+
+signed int __attribute__((noinline))
+scalarproduct_int16_vsx (const signed short *v1, const signed short *v2,
+ int order)
+{
+ int i;
+ LOAD_ZERO;
+ register vec_s16 vec1;
+ register vec_s32 res = vec_splat_s32 (0), t;
+ signed int ires;
+
+ for (i = 0; i < order; i += 8) {
+ vec1 = vec_vsx_ld (0, v1);
+ t = vec_msum (vec1, vec_vsx_ld (0, v2), zero_s32v);
+ res = vec_sums (t, res);
+ v1 += 8;
+ v2 += 8;
+ }
+ res = vec_splat (res, 3);
+ vec_ste (res, 0, &ires);
+
+ return ires;
+}
+
+int main(void)
+{
+ const signed short test_vec[] = { 1, 1, 1, 1, 1, 1, 1, 1 };
+ if (scalarproduct_int16_vsx (test_vec, test_vec, 8) != 8)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-setup-be-double.c b/gcc/testsuite/gcc.target/powerpc/vec-setup-be-double.c
new file mode 100644
index 00000000000..acf429acaa9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec-setup-be-double.c
@@ -0,0 +1,12 @@
+/* { dg-do run { target { powerpc*-*-linux* } } } */
+/* { dg-require-effective-target vsx_hw } */
+/* { dg-options "-O2 -mvsx" } */
+
+/* Test various ways of creating vectors with 2 double words and accessing the
+ elements. This test uses the double datatype.
+
+ This test explicitly tests -maltivec=be to make sure things are correct. */
+
+#define DO_DOUBLE
+
+#include "vec-setup.h"
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-setup-be-long.c b/gcc/testsuite/gcc.target/powerpc/vec-setup-be-long.c
new file mode 100644
index 00000000000..492cd2d76a2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec-setup-be-long.c
@@ -0,0 +1,11 @@
+/* { dg-do run { target { powerpc64le*-*-linux* } } } */
+/* { dg-require-effective-target vsx_hw } */
+/* { dg-options "-O2 -mvsx -maltivec=be" } */
+
+/* Test various ways of creating vectors with 2 double words and accessing the
+ elements. This test uses the long (on 64-bit systems) or long long datatype
+ (on 32-bit systems).
+
+ This test explicitly tests -maltivec=be to make sure things are correct. */
+
+#include "vec-setup.h"
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-setup-double.c b/gcc/testsuite/gcc.target/powerpc/vec-setup-double.c
new file mode 100644
index 00000000000..36c6405caf7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec-setup-double.c
@@ -0,0 +1,11 @@
+/* { dg-do run { target { powerpc*-*-linux* } } } */
+/* { dg-require-effective-target vsx_hw } */
+/* { dg-options "-O2 -mvsx" } */
+
+/* Test various ways of creating vectors with 2 double words and accessing the
+ elements. This test uses the double datatype and the default endian
+ order. */
+
+#define DO_DOUBLE
+
+#include "vec-setup.h"
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-setup-long.c b/gcc/testsuite/gcc.target/powerpc/vec-setup-long.c
new file mode 100644
index 00000000000..5588e1586f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec-setup-long.c
@@ -0,0 +1,9 @@
+/* { dg-do run { target { powerpc*-*-linux* } } } */
+/* { dg-require-effective-target vsx_hw } */
+/* { dg-options "-O2 -mvsx" } */
+
+/* Test various ways of creating vectors with 2 double words and accessing the
+ elements. This test uses the long (on 64-bit systems) or long long datatype
+ (on 32-bit systems). The default endian order is used. */
+
+#include "vec-setup.h"
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-setup.h b/gcc/testsuite/gcc.target/powerpc/vec-setup.h
new file mode 100644
index 00000000000..9e251646d2d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec-setup.h
@@ -0,0 +1,366 @@
+#include <altivec.h>
+
+/* Test various ways of creating vectors with 2 double words and accessing the
+ elements. This include files supports:
+
+ testing double
+ testing long on 64-bit systems
+ testing long long on 32-bit systems.
+
+ The endian support is:
+
+ big endian
+ little endian with little endian element ordering
+ little endian with big endian element ordering. */
+
+#ifdef DEBUG
+#include <stdio.h>
+#define DEBUG0(STR) fputs (STR, stdout)
+#define DEBUG2(STR,A,B) printf (STR, A, B)
+
+static int errors = 0;
+
+#else
+#include <stdlib.h>
+#define DEBUG0(STR)
+#define DEBUG2(STR,A,B)
+#endif
+
+#if defined(DO_DOUBLE)
+#define TYPE double
+#define STYPE "double"
+#define ZERO 0.0
+#define ONE 1.0
+#define TWO 2.0
+#define THREE 3.0
+#define FOUR 4.0
+#define FIVE 5.0
+#define SIX 6.0
+#define FMT "g"
+
+#elif defined(_ARCH_PPC64)
+#define TYPE long
+#define STYPE "long"
+#define ZERO 0L
+#define ONE 1L
+#define TWO 2L
+#define THREE 3L
+#define FOUR 4L
+#define FIVE 5L
+#define SIX 6L
+#define FMT "ld"
+
+#else
+#define TYPE long long
+#define STYPE "long long"
+#define ZERO 0LL
+#define ONE 1LL
+#define TWO 2LL
+#define THREE 3LL
+#define FOUR 4LL
+#define FIVE 5LL
+#define SIX 6LL
+#define FMT "lld"
+#endif
+
+/* Macros to order the left/right values correctly. Note, -maltivec=be does
+ not change the order for static initializations, so we have to handle it
+ specially. */
+
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#define INIT_ORDER(A, B) (TYPE) A, (TYPE) B
+#define ELEMENT_ORDER(A, B) (TYPE) A, (TYPE) B
+#define ENDIAN "-mbig"
+
+#elif __VEC_ELEMENT_REG_ORDER__ == __ORDER_BIG_ENDIAN__
+#define NO_ARRAY
+#define INIT_ORDER(A, B) (TYPE) B, (TYPE) A
+#define ELEMENT_ORDER(A, B) (TYPE) A, (TYPE) B
+#define ENDIAN "-mlittle -maltivec=be"
+
+#else
+#define INIT_ORDER(A, B) (TYPE) B, (TYPE) A
+#define ELEMENT_ORDER(A, B) (TYPE) B, (TYPE) A
+#define ENDIAN "-mlittle"
+#endif
+
+static volatile TYPE five = FIVE;
+static volatile TYPE six = SIX;
+static volatile vector TYPE s_v12 = { ONE, TWO };
+static volatile vector TYPE g_v34 = { THREE, FOUR };
+
+
+__attribute__((__noinline__))
+static void
+vector_check (vector TYPE v, TYPE expect_hi, TYPE expect_lo)
+{
+ TYPE actual_hi, actual_lo;
+#ifdef DEBUG
+ const char *pass_fail;
+#endif
+
+ __asm__ ("xxlor %x0,%x1,%x1" : "=&wa" (actual_hi) : "wa" (v));
+ __asm__ ("xxpermdi %x0,%x1,%x1,3" : "=&wa" (actual_lo) : "wa" (v));
+
+#ifdef DEBUG
+ if ((actual_hi == expect_hi) && (actual_lo == expect_lo))
+ pass_fail = ", pass";
+ else
+ {
+ pass_fail = ", fail";
+ errors++;
+ }
+
+ printf ("Expected %" FMT ", %" FMT ", got %" FMT ", %" FMT "%s\n",
+ expect_hi, expect_lo,
+ actual_hi, actual_lo,
+ pass_fail);
+#else
+ if ((actual_hi != expect_hi) || (actual_lo != expect_lo))
+ abort ();
+#endif
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+combine (TYPE op0, TYPE op1)
+{
+ return (vector TYPE) { op0, op1 };
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+combine_insert (TYPE op0, TYPE op1)
+{
+ vector TYPE ret = (vector TYPE) { ZERO, ZERO };
+ ret = vec_insert (op0, ret, 0);
+ ret = vec_insert (op1, ret, 1);
+ return ret;
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+concat_extract_00 (vector TYPE a, vector TYPE b)
+{
+ return (vector TYPE) { vec_extract (a, 0), vec_extract (b, 0) };
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+concat_extract_01 (vector TYPE a, vector TYPE b)
+{
+ return (vector TYPE) { vec_extract (a, 0), vec_extract (b, 1) };
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+concat_extract_10 (vector TYPE a, vector TYPE b)
+{
+ return (vector TYPE) { vec_extract (a, 1), vec_extract (b, 0) };
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+concat_extract_11 (vector TYPE a, vector TYPE b)
+{
+ return (vector TYPE) { vec_extract (a, 1), vec_extract (b, 1) };
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+concat_extract2_0s (vector TYPE a, TYPE b)
+{
+ return (vector TYPE) { vec_extract (a, 0), b };
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+concat_extract2_1s (vector TYPE a, TYPE b)
+{
+ return (vector TYPE) { vec_extract (a, 1), b };
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+concat_extract2_s0 (TYPE a, vector TYPE b)
+{
+ return (vector TYPE) { a, vec_extract (b, 0) };
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+concat_extract2_s1 (TYPE a, vector TYPE b)
+{
+ return (vector TYPE) { a, vec_extract (b, 1) };
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+concat_extract_nn (vector TYPE a, vector TYPE b, size_t i, size_t j)
+{
+ return (vector TYPE) { vec_extract (a, i), vec_extract (b, j) };
+}
+
+#ifndef NO_ARRAY
+__attribute__((__noinline__))
+static vector TYPE
+array_0 (vector TYPE v, TYPE a)
+{
+ v[0] = a;
+ return v;
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+array_1 (vector TYPE v, TYPE a)
+{
+ v[1] = a;
+ return v;
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+array_01 (vector TYPE v, TYPE a, TYPE b)
+{
+ v[0] = a;
+ v[1] = b;
+ return v;
+}
+
+__attribute__((__noinline__))
+static vector TYPE
+array_01b (TYPE a, TYPE b)
+{
+ vector TYPE v = (vector TYPE) { 0, 0 };
+ v[0] = a;
+ v[1] = b;
+ return v;
+}
+#endif
+
+int
+main (void)
+{
+ vector TYPE a = (vector TYPE) { ONE, TWO };
+ vector TYPE b = (vector TYPE) { THREE, FOUR };
+ size_t i, j;
+
+#ifndef NO_ARRAY
+ vector TYPE z = (vector TYPE) { ZERO, ZERO };
+#endif
+
+ DEBUG2 ("Endian: %s, type: %s\n", ENDIAN, STYPE);
+ DEBUG0 ("\nStatic/global initialization\n");
+ vector_check (s_v12, INIT_ORDER (1, 2));
+ vector_check (g_v34, INIT_ORDER (3, 4));
+
+ DEBUG0 ("\nVector via constant runtime intiialization\n");
+ vector_check (a, INIT_ORDER (1, 2));
+ vector_check (b, INIT_ORDER (3, 4));
+
+ DEBUG0 ("\nCombine scalars using vector initialization\n");
+ vector_check (combine (1, 2), INIT_ORDER (1, 2));
+ vector_check (combine (3, 4), INIT_ORDER (3, 4));
+
+ DEBUG0 ("\nSetup with vec_insert\n");
+ a = combine_insert (1, 2);
+ b = combine_insert (3, 4);
+ vector_check (a, ELEMENT_ORDER (1, 2));
+ vector_check (b, ELEMENT_ORDER (3, 4));
+
+#ifndef NO_ARRAY
+ DEBUG0 ("\nTesting array syntax\n");
+ vector_check (array_0 (a, FIVE), ELEMENT_ORDER (5, 2));
+ vector_check (array_1 (b, SIX), ELEMENT_ORDER (3, 6));
+ vector_check (array_01 (z, FIVE, SIX), ELEMENT_ORDER (5, 6));
+ vector_check (array_01b (FIVE, SIX), ELEMENT_ORDER (5, 6));
+
+ vector_check (array_0 (a, five), ELEMENT_ORDER (5, 2));
+ vector_check (array_1 (b, six), ELEMENT_ORDER (3, 6));
+ vector_check (array_01 (z, five, six), ELEMENT_ORDER (5, 6));
+ vector_check (array_01b (five, six), ELEMENT_ORDER (5, 6));
+#else
+ DEBUG0 ("\nSkipping array syntax on -maltivec=be\n");
+#endif
+
+ DEBUG0 ("\nTesting concat and extract\n");
+ vector_check (concat_extract_00 (a, b), INIT_ORDER (1, 3));
+ vector_check (concat_extract_01 (a, b), INIT_ORDER (1, 4));
+ vector_check (concat_extract_10 (a, b), INIT_ORDER (2, 3));
+ vector_check (concat_extract_11 (a, b), INIT_ORDER (2, 4));
+
+ DEBUG0 ("\nTesting concat and extract #2\n");
+ vector_check (concat_extract2_0s (a, FIVE), INIT_ORDER (1, 5));
+ vector_check (concat_extract2_1s (a, FIVE), INIT_ORDER (2, 5));
+ vector_check (concat_extract2_s0 (SIX, a), INIT_ORDER (6, 1));
+ vector_check (concat_extract2_s1 (SIX, a), INIT_ORDER (6, 2));
+
+ DEBUG0 ("\nTesting variable concat and extract\n");
+ for (i = 0; i < 2; i++)
+ {
+ for (j = 0; j < 2; j++)
+ {
+ static struct {
+ TYPE hi;
+ TYPE lo;
+ } hilo[2][2] =
+ { { { ONE, THREE }, { ONE, FOUR } },
+ { { TWO, THREE }, { TWO, FOUR } } };
+
+ vector_check (concat_extract_nn (a, b, i, j),
+ INIT_ORDER (hilo[i][j].hi, hilo[i][j].lo));
+ }
+ }
+
+ DEBUG0 ("\nTesting separate function\n");
+ vector_check (combine (vec_extract (a, 0), vec_extract (b, 0)),
+ INIT_ORDER (1, 3));
+
+ vector_check (combine (vec_extract (a, 0), vec_extract (b, 1)),
+ INIT_ORDER (1, 4));
+
+ vector_check (combine (vec_extract (a, 1), vec_extract (b, 0)),
+ INIT_ORDER (2, 3));
+
+ vector_check (combine (vec_extract (a, 1), vec_extract (b, 1)),
+ INIT_ORDER (2, 4));
+
+ vector_check (combine_insert (vec_extract (a, 0), vec_extract (b, 0)),
+ ELEMENT_ORDER (1, 3));
+
+ vector_check (combine_insert (vec_extract (a, 0), vec_extract (b, 1)),
+ ELEMENT_ORDER (1, 4));
+
+ vector_check (combine_insert (vec_extract (a, 1), vec_extract (b, 0)),
+ ELEMENT_ORDER (2, 3));
+
+ vector_check (combine_insert (vec_extract (a, 1), vec_extract (b, 1)),
+ ELEMENT_ORDER (2, 4));
+
+
+#if defined(DO_DOUBLE)
+ DEBUG0 ("\nTesting explicit 2df concat\n");
+ vector_check (__builtin_vsx_concat_2df (FIVE, SIX), INIT_ORDER (5, 6));
+ vector_check (__builtin_vsx_concat_2df (five, six), INIT_ORDER (5, 6));
+
+#elif defined(_ARCH_PPC64)
+ DEBUG0 ("\nTesting explicit 2di concat\n");
+ vector_check (__builtin_vsx_concat_2di (FIVE, SIX), INIT_ORDER (5, 6));
+ vector_check (__builtin_vsx_concat_2di (five, six), INIT_ORDER (5, 6));
+
+#else
+ DEBUG0 ("\nSkip explicit 2di concat on 32-bit\n");
+#endif
+
+#ifdef DEBUG
+ if (errors)
+ printf ("\n%d error%s were found", errors, (errors == 1) ? "" : "s");
+ else
+ printf ("\nNo errors were found.\n");
+
+ return errors;
+
+#else
+ return 0;
+#endif
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-extract-6.c b/gcc/testsuite/gcc.target/powerpc/vsx-extract-6.c
new file mode 100644
index 00000000000..8a5eb573f79
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vsx-extract-6.c
@@ -0,0 +1,25 @@
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O2 -mvsx" } */
+
+vector unsigned long
+test_vpasted (vector unsigned long high, vector unsigned long low)
+{
+ vector unsigned long res;
+ res[1] = high[1];
+ res[0] = low[0];
+ return res;
+}
+
+/* { dg-final { scan-assembler-times {\mxxpermdi\M} 1 } } */
+/* { dg-final { scan-assembler-not {\mvspltisw\M} } } */
+/* { dg-final { scan-assembler-not {\mxxlor\M} } } */
+/* { dg-final { scan-assembler-not {\mxxlxor\M} } } */
+/* { dg-final { scan-assembler-not {\mxxspltib\M} } } */
+/* { dg-final { scan-assembler-not {\mlxvx?\M} } } */
+/* { dg-final { scan-assembler-not {\mlxv[dw][24]x\M} } } */
+/* { dg-final { scan-assembler-not {\mlvx\M} } } */
+/* { dg-final { scan-assembler-not {\mstxvx?\M} } } */
+/* { dg-final { scan-assembler-not {\mstxv[dw][24]x\M} } } */
+/* { dg-final { scan-assembler-not {\mstvx\M} } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-extract-7.c b/gcc/testsuite/gcc.target/powerpc/vsx-extract-7.c
new file mode 100644
index 00000000000..961a980794e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vsx-extract-7.c
@@ -0,0 +1,25 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O2 -mvsx" } */
+
+vector double
+test_vpasted (vector double high, vector double low)
+{
+ vector double res;
+ res[1] = high[1];
+ res[0] = low[0];
+ return res;
+}
+
+/* { dg-final { scan-assembler-times {\mxxpermdi\M} 1 } } */
+/* { dg-final { scan-assembler-not {\mvspltisw\M} } } */
+/* { dg-final { scan-assembler-not {\mxxlor\M} } } */
+/* { dg-final { scan-assembler-not {\mxxlxor\M} } } */
+/* { dg-final { scan-assembler-not {\mxxspltib\M} } } */
+/* { dg-final { scan-assembler-not {\mlxvx?\M} } } */
+/* { dg-final { scan-assembler-not {\mlxv[dw][24]x\M} } } */
+/* { dg-final { scan-assembler-not {\mlvx\M} } } */
+/* { dg-final { scan-assembler-not {\mstxvx?\M} } } */
+/* { dg-final { scan-assembler-not {\mstxv[dw][24]x\M} } } */
+/* { dg-final { scan-assembler-not {\mstvx\M} } } */
diff --git a/gcc/testsuite/gfortran.dg/array_temporaries_4.f90 b/gcc/testsuite/gfortran.dg/array_temporaries_4.f90
new file mode 100644
index 00000000000..d022ce88557
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/array_temporaries_4.f90
@@ -0,0 +1,59 @@
+! { dg-do compile }
+! { dg-options "-Warray-temporaries" }
+! Tests the fix for PR80164, in which the compiler segfaulted on this
+! when using -Warray-temporaries
+!
+!******************************************************************************
+module global
+ type :: a
+ integer :: b
+ character(8):: c
+ end type a
+ interface assignment(=)
+ module procedure a_to_a, c_to_a, a_to_c
+ end interface
+ interface operator(.ne.)
+ module procedure a_ne_a
+ end interface
+
+ type(a) :: x(4), y(4)
+ logical :: l1(4), t = .true., f= .false.
+contains
+!******************************************************************************
+ elemental subroutine a_to_a (m, n)
+ type(a), intent(in) :: n
+ type(a), intent(out) :: m
+ m%b = len ( trim(n%c))
+ m%c = n%c
+ end subroutine a_to_a
+ elemental subroutine c_to_a (m, n)
+ character(8), intent(in) :: n
+ type(a), intent(out) :: m
+ m%b = m%b + 1
+ m%c = n
+ end subroutine c_to_a
+ elemental subroutine a_to_c (m, n)
+ type(a), intent(in) :: n
+ character(8), intent(out) :: m
+ m = n%c
+ end subroutine a_to_c
+!******************************************************************************
+ elemental logical function a_ne_a (m, n)
+ type(a), intent(in) :: n
+ type(a), intent(in) :: m
+ a_ne_a = (m%b .ne. n%b) .or. (m%c .ne. n%c)
+ end function a_ne_a
+!******************************************************************************
+ elemental function foo (m)
+ type(a) :: foo
+ type(a), intent(in) :: m
+ foo%b = 0
+ foo%c = m%c
+ end function foo
+end module global
+!******************************************************************************
+program test
+ use global
+ x = (/a (0, "one"),a (0, "two"),a (0, "three"),a (0, "four")/) ! { dg-warning "Creating array temporary" }
+ y = x
+end program test
diff --git a/gcc/testsuite/gfortran.dg/dtio_12.f90 b/gcc/testsuite/gfortran.dg/dtio_12.f90
index 213f7ebbb1e..cf1bfe38e2f 100644
--- a/gcc/testsuite/gfortran.dg/dtio_12.f90
+++ b/gcc/testsuite/gfortran.dg/dtio_12.f90
@@ -70,5 +70,11 @@ end module
rewind (10)
read (10, *) msg
if (trim (msg) .ne. "77") call abort
+ rewind (10)
+ write (10,40) child (77) ! Modified using format label
+40 format(DT)
+ rewind (10)
+ read (10, *) msg
+ if (trim (msg) .ne. "77") call abort
close(10)
end
diff --git a/gcc/testsuite/gfortran.dg/pr81723.f b/gcc/testsuite/gfortran.dg/pr81723.f
new file mode 100644
index 00000000000..977c1b69bbf
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr81723.f
@@ -0,0 +1,56 @@
+! { dg-do compile }
+! { dg-options "-O3 -fno-automatic" }
+
+ FUNCTION WWERF(Z)
+
+ IMPLICIT DOUBLE PRECISION (A-H,O-Z)
+ COMPLEX*16 WWERF
+ COMPLEX*16 Z,ZH,R(37),S,T,V,W
+
+ PARAMETER (Z1 = 1, HF = Z1/2, Z10 = 10)
+ PARAMETER (C1 = 74/Z10, C2 = 83/Z10, C3 = Z10/32, C4 = 16/Z10)
+ PARAMETER (C = 1.12837 91670 95512 57D0, P = (2*C4)**33)
+
+ DOUBLE PRECISION GREAL,GIMAG,XARG,YARG
+ COMPLEX*16 ZARG,GCONJG,GCMPLX
+ GREAL( ZARG)=DREAL( ZARG)
+ GIMAG( ZARG)=DIMAG( ZARG)
+ GCONJG(ZARG)=DCONJG(ZARG)
+ GCMPLX(XARG,YARG)=DCMPLX(XARG,YARG)
+
+ X=Z
+ Y=GIMAG(Z)
+ XA=ABS(X)
+ YA=ABS(Y)
+ IF(YA .LT. C1 .AND. XA .LT. C2) THEN
+ ZH=GCMPLX(YA+C4,XA)
+ R(37)=0
+ DO 1 N = 36,1,-1
+ T=ZH+N*GCONJG(R(N+1))
+ 1 R(N)=HF*T/(GREAL(T)**2+GIMAG(T)**2)
+ XL=P
+ S=0
+ DO 2 N = 33,1,-1
+ XL=C3*XL
+ 2 S=R(N)*(S+XL)
+ V=C*S
+ ELSE
+ ZH=GCMPLX(YA,XA)
+ R(1)=0
+ DO 3 N = 9,1,-1
+ T=ZH+N*GCONJG(R(1))
+ 3 R(1)=HF*T/(GREAL(T)**2+GIMAG(T)**2)
+ V=C*R(1)
+ END IF
+ IF(YA .EQ. 0) V=GCMPLX(EXP(-XA**2),GIMAG(V))
+ IF(Y .LT. 0) THEN
+ V=2*EXP(-GCMPLX(XA,YA)**2)-V
+ IF(X .GT. 0) V=GCONJG(V)
+ ELSE
+ IF(X .LT. 0) V=GCONJG(V)
+ END IF
+
+ WWERF=V
+
+ RETURN
+ END
diff --git a/gcc/testsuite/gfortran.dg/warn_target_lifetime_3.f90 b/gcc/testsuite/gfortran.dg/warn_target_lifetime_3.f90
index 6c8ea5b9458..0ef1e2d19c7 100644
--- a/gcc/testsuite/gfortran.dg/warn_target_lifetime_3.f90
+++ b/gcc/testsuite/gfortran.dg/warn_target_lifetime_3.f90
@@ -3,7 +3,7 @@
!
! PR fortran/55476
!
-! Contribued by Janus Weil
+! Contributed by Janus Weil
!
subroutine test
integer, pointer :: p
diff --git a/gcc/testsuite/gfortran.dg/warn_target_lifetime_4.f90 b/gcc/testsuite/gfortran.dg/warn_target_lifetime_4.f90
new file mode 100644
index 00000000000..d2972a92283
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/warn_target_lifetime_4.f90
@@ -0,0 +1,28 @@
+! { dg-do compile }
+! { dg-options "-Wtarget-lifetime" }
+!
+! PR fortran/81770: [5/6/7 Regression] Bogus warning: Pointer in pointer assignment might outlive the pointer target
+!
+! Contributed by Janus Weil <janus@gcc.gnu.org>
+
+module m
+
+ type t
+ integer, allocatable :: l
+ end type
+
+contains
+
+ subroutine sub(c_in, list)
+ type(t), target, intent(in) :: c_in
+ integer, pointer, intent(out) :: list
+
+ type(t), pointer :: container
+
+ container => c_in
+
+ list => container%l
+
+ end subroutine
+
+end
diff --git a/gcc/testsuite/gnat.dg/array29.adb b/gcc/testsuite/gnat.dg/array29.adb
new file mode 100644
index 00000000000..9736941f3a1
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/array29.adb
@@ -0,0 +1,26 @@
+-- { dg-do compile }
+-- { dg-options "-O" }
+
+package body Array29 is
+
+ procedure Copy (Src : in Matrix; Dst : out Matrix) is
+ begin
+ for I in Src'Range (1) loop
+ for J in Src'Range (2) loop
+ Dst (I, J) := Src (I, J);
+ end loop;
+ end loop;
+ end;
+
+ procedure Proc is
+ N : constant := 2;
+ FM1 : constant Matrix (1 .. N, 1 .. N) := ((1.0, 2.0), (3.0, 4.0));
+ FM2 : constant Matrix (1 .. N, 1 .. N) := ((1.0, 2.0), (3.0, 4.0));
+ A : constant array (1 .. 2) of Matrix (1 .. N, 1 .. N)
+ := (Matrix (FM1), Matrix (FM2));
+ Final : Matrix (1 .. N, 1 .. N);
+ begin
+ Copy (Src => A (1), Dst => Final);
+ end;
+
+end Array29;
diff --git a/gcc/testsuite/gnat.dg/array29.ads b/gcc/testsuite/gnat.dg/array29.ads
new file mode 100644
index 00000000000..049ca1f3c66
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/array29.ads
@@ -0,0 +1,7 @@
+package Array29 is
+
+ type Matrix is array (Integer range <>, Integer range <>) of Long_Float;
+
+ procedure Proc;
+
+end Array29;
diff --git a/gcc/testsuite/gnat.dg/debug13.adb b/gcc/testsuite/gnat.dg/debug13.adb
new file mode 100644
index 00000000000..4b94b3e6bf1
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug13.adb
@@ -0,0 +1,38 @@
+-- { dg-options "-cargs -O2 -g -margs" }
+
+package body Debug13 is
+
+ procedure Compile (P : Natural)
+ is
+ Max_Pos : constant Natural := P;
+ type Position_Set is array (1 .. Max_Pos) of Boolean;
+
+ Empty : constant Position_Set := (others => False);
+
+ type Position_Set_Array is array (1 .. Max_Pos) of Position_Set;
+
+ Follow : Position_Set_Array := (others => Empty);
+
+ function Get_Follows return Position_Set;
+
+ procedure Make_DFA;
+
+ function Get_Follows return Position_Set is
+ Result : Position_Set := Empty;
+ begin
+ Result := Result or Follow (1);
+
+ return Result;
+ end Get_Follows;
+
+ procedure Make_DFA is
+ Next : constant Position_Set := Get_Follows;
+ begin
+ null;
+ end Make_DFA;
+
+ begin
+ Make_DFA;
+ end Compile;
+
+end Debug13;
diff --git a/gcc/testsuite/gnat.dg/debug13.ads b/gcc/testsuite/gnat.dg/debug13.ads
new file mode 100644
index 00000000000..512a9ef75bb
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug13.ads
@@ -0,0 +1,5 @@
+package Debug13 is
+
+ procedure Compile (P : Natural);
+
+end Debug13;
diff --git a/gcc/testsuite/gnat.dg/incomplete5.adb b/gcc/testsuite/gnat.dg/incomplete5.adb
new file mode 100644
index 00000000000..f6b4879dc00
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/incomplete5.adb
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+
+package body Incomplete5 is
+
+ function Get (O: Base_Object) return Integer is
+ begin
+ return Get_Handle(O).I;
+ end;
+
+end Incomplete5;
diff --git a/gcc/testsuite/gnat.dg/incomplete5.ads b/gcc/testsuite/gnat.dg/incomplete5.ads
new file mode 100644
index 00000000000..0e0394212c8
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/incomplete5.ads
@@ -0,0 +1,25 @@
+with Incomplete5_Pkg;
+
+package Incomplete5 is
+
+ type Rec1 is private;
+
+ type Rec2 is private;
+
+ package My_G is new Incomplete5_Pkg (Rec1);
+
+ use My_G;
+
+ function Get (O: Base_Object) return Integer;
+
+private
+
+ type Rec1 is record
+ I : Integer;
+ end record;
+
+ type Rec2 is record
+ A : Access_Type;
+ end record;
+
+end Incomplete5;
diff --git a/gcc/testsuite/gnat.dg/incomplete5_pkg.adb b/gcc/testsuite/gnat.dg/incomplete5_pkg.adb
new file mode 100644
index 00000000000..44b1411e404
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/incomplete5_pkg.adb
@@ -0,0 +1,13 @@
+package body Incomplete5_Pkg is
+
+ function Get_Handle (Object: Base_Object) return Access_Type is
+ begin
+ return Object.Handle;
+ end;
+
+ function From_Handle (Handle: Access_Type) return Base_Object is
+ begin
+ return (Handle=>Handle);
+ end;
+
+end Incomplete5_Pkg;
diff --git a/gcc/testsuite/gnat.dg/incomplete5_pkg.ads b/gcc/testsuite/gnat.dg/incomplete5_pkg.ads
new file mode 100644
index 00000000000..28f3809d746
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/incomplete5_pkg.ads
@@ -0,0 +1,15 @@
+generic
+ type Record_Type;
+package Incomplete5_Pkg is
+
+ type Access_Type is access Record_Type;
+
+ type Base_Object is tagged record
+ Handle: Access_Type;
+ end record;
+
+ function Get_Handle(Object: Base_Object) return Access_Type;
+
+ function From_Handle(Handle: Access_Type) return Base_Object;
+
+end Incomplete5_Pkg;
diff --git a/gcc/testsuite/gnat.dg/pack9.adb b/gcc/testsuite/gnat.dg/pack9.adb
index f433a1a74a7..b15a9df030e 100644
--- a/gcc/testsuite/gnat.dg/pack9.adb
+++ b/gcc/testsuite/gnat.dg/pack9.adb
@@ -1,6 +1,7 @@
-- { dg-do compile }
-- { dg-options "-O2 -gnatp -fdump-tree-optimized" }
--- See PR tree-optimization/46801 for the expected failure
+
+pragma Optimize_Alignment (Space);
package body Pack9 is
diff --git a/gcc/testsuite/gnat.dg/specs/atomic3.ads b/gcc/testsuite/gnat.dg/specs/atomic3.ads
new file mode 100644
index 00000000000..875f2236274
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/atomic3.ads
@@ -0,0 +1,33 @@
+-- { dg-do compile }
+
+package Atomic3 is
+
+ type Four_Bits is mod 2**4;
+ type Fourteen_Bits is mod 2**14;
+ type Twenty_Eight_Bits is mod 2**28;
+
+ type Rec1 (Mode : Boolean := True) is record
+ Reserved : Four_Bits;
+ case Mode is
+ when True =>
+ High_Part : Fourteen_Bits;
+ Low_Part : Fourteen_Bits;
+ when False =>
+ Data : Twenty_Eight_Bits;
+ end case;
+ end record;
+ for Rec1 use record
+ Reserved at 0 range 28 .. 31;
+ High_Part at 0 range 14 .. 27;
+ Low_Part at 0 range 0 .. 13;
+ Data at 0 range 0 .. 27;
+ end record;
+ for Rec1'Size use 32;
+ pragma Unchecked_Union (Rec1);
+
+ type Rec2 is record
+ A : Rec1;
+ pragma Atomic (A);
+ end record;
+
+end Atomic3;
diff --git a/gcc/testsuite/gnat.dg/specs/uc2.ads b/gcc/testsuite/gnat.dg/specs/uc2.ads
new file mode 100644
index 00000000000..84d4e043291
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/uc2.ads
@@ -0,0 +1,18 @@
+-- { dg-do compile }
+-- { dg-options "-O" }
+
+with Ada.Unchecked_Conversion;
+
+package UC2 is
+
+ subtype Word_Type is Integer range 0 .. 0;
+ type Arr is array (1 .. Word_Type'Size) of Boolean;
+ pragma Pack(Arr);
+
+ function Conv is
+ new Ada.Unchecked_Conversion (Source => Arr, Target => Word_Type);
+
+ A : Arr;
+ W : Word_Type := Conv(A);
+
+end UC2;
diff --git a/gcc/testsuite/gnat.dg/specs/vfa.ads b/gcc/testsuite/gnat.dg/specs/vfa1.ads
index a63be969d55..cf918c20a03 100644
--- a/gcc/testsuite/gnat.dg/specs/vfa.ads
+++ b/gcc/testsuite/gnat.dg/specs/vfa1.ads
@@ -1,7 +1,7 @@
-- { dg-do compile }
-- { dg-options "-g" }
-package VFA is
+package VFA1 is
type Rec is record
A : Short_Integer;
@@ -11,4 +11,4 @@ package VFA is
type Rec_VFA is new Rec;
pragma Volatile_Full_Access (Rec_VFA);
-end VFA;
+end VFA1;
diff --git a/gcc/testsuite/gnat.dg/specs/vfa2.ads b/gcc/testsuite/gnat.dg/specs/vfa2.ads
new file mode 100644
index 00000000000..8ca9687a39e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/vfa2.ads
@@ -0,0 +1,110 @@
+-- { dg-do compile }
+-- { dg-options "-O" }
+
+package VFA2 is
+
+ type Bit is mod 2**1
+ with Size => 1;
+ type UInt2 is mod 2**2
+ with Size => 2;
+ type UInt22 is mod 2**22
+ with Size => 22;
+
+ type MODE_ENUM is
+ (
+ Function_0_Default,
+ Function_1,
+ Function_2,
+ Function_3,
+ Function_4,
+ Function_5,
+ Function_6,
+ Function_7)
+ with Size => 3;
+
+ type EPD_ENUM is
+ (
+ Disable_Pull_Down,
+ Enable_Pull_Down)
+ with Size => 1;
+
+ type EPUN_ENUM is
+ (
+ Enable_Pull_Up,
+ Disable_Pull_Up)
+ with Size => 1;
+
+ type EHS_ENUM is
+ (
+ Slow_Low_Noise_With,
+ Fast_Medium_Noise_W)
+ with Size => 1;
+
+ type EZI_ENUM is
+ (
+ Disable_Input_Buffer,
+ Enable_Input_Buffer)
+ with Size => 1;
+
+ type ZIF_ENUM is
+ (
+ Enable_Input_Glitch,
+ Disable_Input_Glitch)
+ with Size => 1;
+
+ type EHD_ENUM is
+ (
+ Normal_Drive_4_Ma_D,
+ Medium_Drive_8_Ma_D,
+ High_Drive_14_Ma_Dr,
+ Ultra_High_Drive_20)
+ with Size => 2;
+
+ type Pin_Type is (Normal_Drive, High_Drive, High_Speed);
+
+ type SFS_Register(Pin : Pin_Type := Normal_Drive) is record
+ MODE : MODE_ENUM;
+ EPD : EPD_ENUM;
+ EPUN : EPUN_ENUM;
+ EZI : EZI_ENUM;
+ ZIF : ZIF_ENUM;
+ RESERVED : UInt22;
+
+ case Pin is
+ when Normal_Drive =>
+
+ ND_EHS_RESERVED : Bit;
+ ND_EHD_RESERVED : UInt2;
+
+ when High_Drive =>
+
+ EHD : EHD_ENUM;
+ HD_EHS_RESERVED : Bit;
+
+ when High_Speed =>
+ EHS : EHS_ENUM;
+ HS_EHD_RESERVED : UInt2;
+
+ end case;
+ end record
+ with Unchecked_Union, Size => 32, Volatile_Full_Access;
+
+ for SFS_Register use record
+ MODE at 0 range 0 .. 2;
+ EPD at 0 range 3 .. 3;
+ EPUN at 0 range 4 .. 4;
+ ND_EHS_RESERVED at 0 range 5 .. 5;
+ HD_EHS_RESERVED at 0 range 5 .. 5;
+ EHS at 0 range 5 .. 5;
+ EZI at 0 range 6 .. 6;
+ ZIF at 0 range 7 .. 7;
+ ND_EHD_RESERVED at 0 range 8 .. 9;
+ EHD at 0 range 8 .. 9;
+ HS_EHD_RESERVED at 0 range 8 .. 9;
+ RESERVED at 0 range 10 .. 31;
+ end record;
+
+ type Normal_Drive_Pins is array (Integer range <>)
+ of SFS_Register(Normal_Drive) with Volatile;
+
+end VFA2;
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 11bae767568..671604cd8ed 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1788,6 +1788,7 @@ proc check_avx2_hw_available { } {
expr 0
} else {
check_runtime_nocache avx2_hw_available {
+ #include <stddef.h>
#include "cpuid.h"
int main ()
{
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index a540416cbb5..540349dbc44 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6667,7 +6667,15 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data)
*tp = t = out->to;
}
- DECL_CONTEXT (t) = p->to_context;
+ /* For FORCED_LABELs we can end up with references from other
+ functions if some SESE regions are outlined. It is UB to
+ jump in between them, but they could be used just for printing
+ addresses etc. In that case, DECL_CONTEXT on the label should
+ be the function containing the glabel stmt with that LABEL_DECL,
+ rather than whatever function a reference to the label was seen
+ last time. */
+ if (!FORCED_LABEL (t) && !DECL_NONLOCAL (t))
+ DECL_CONTEXT (t) = p->to_context;
}
else if (p->remap_decls_p)
{
@@ -6785,6 +6793,21 @@ move_stmt_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
case GIMPLE_OMP_RETURN:
case GIMPLE_OMP_CONTINUE:
break;
+
+ case GIMPLE_LABEL:
+ {
+ /* For FORCED_LABEL, move_stmt_op doesn't adjust DECL_CONTEXT,
+ so that such labels can be referenced from other regions.
+ Make sure to update it when seeing a GIMPLE_LABEL though,
+ that is the owner of the label. */
+ walk_gimple_op (stmt, move_stmt_op, wi);
+ *handled_ops_p = true;
+ tree label = gimple_label_label (as_a <glabel *> (stmt));
+ if (FORCED_LABEL (label) || DECL_NONLOCAL (label))
+ DECL_CONTEXT (label) = p->to_context;
+ }
+ break;
+
default:
if (is_gimple_omp (stmt))
{
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index b1ff21851c6..23f5af98ae3 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -3277,7 +3277,7 @@ chkp_may_narrow_to_field (tree ref, tree field)
return DECL_SIZE (field) && TREE_CODE (DECL_SIZE (field)) == INTEGER_CST
&& tree_to_uhwi (DECL_SIZE (field)) != 0
&& !(flag_chkp_flexible_struct_trailing_arrays
- && array_at_struct_end_p (ref, true))
+ && array_at_struct_end_p (ref))
&& (!DECL_FIELD_OFFSET (field)
|| TREE_CODE (DECL_FIELD_OFFSET (field)) == INTEGER_CST)
&& (!DECL_FIELD_BIT_OFFSET (field)
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 3f0c650475d..4cedcb2392f 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -2415,6 +2415,7 @@ stmt_kills_ref_p (gimple *stmt, ao_ref *ref)
if (ref->ref)
{
tree base = ref->ref;
+ tree innermost_dropped_array_ref = NULL_TREE;
if (handled_component_p (base))
{
tree saved_lhs0 = NULL_TREE;
@@ -2434,6 +2435,11 @@ stmt_kills_ref_p (gimple *stmt, ao_ref *ref)
TREE_OPERAND (base, 0) = saved_base0;
if (res)
break;
+ /* Remember if we drop an array-ref that we need to
+ double-check not being at struct end. */
+ if (TREE_CODE (base) == ARRAY_REF
+ || TREE_CODE (base) == ARRAY_RANGE_REF)
+ innermost_dropped_array_ref = base;
/* Otherwise drop handled components of the access. */
base = saved_base0;
}
@@ -2442,15 +2448,22 @@ stmt_kills_ref_p (gimple *stmt, ao_ref *ref)
TREE_OPERAND (lhs, 0) = saved_lhs0;
}
/* Finally check if the lhs has the same address and size as the
- base candidate of the access. */
- if (lhs == base
- || (((TYPE_SIZE (TREE_TYPE (lhs))
- == TYPE_SIZE (TREE_TYPE (base)))
- || (TYPE_SIZE (TREE_TYPE (lhs))
- && TYPE_SIZE (TREE_TYPE (base))
- && operand_equal_p (TYPE_SIZE (TREE_TYPE (lhs)),
- TYPE_SIZE (TREE_TYPE (base)), 0)))
- && operand_equal_p (lhs, base, OEP_ADDRESS_OF)))
+ base candidate of the access. Watch out if we have dropped
+ an array-ref that was at struct end, this means ref->ref may
+ be outside of the TYPE_SIZE of its base. */
+ if ((! innermost_dropped_array_ref
+ || ! array_at_struct_end_p (innermost_dropped_array_ref))
+ && (lhs == base
+ || (((TYPE_SIZE (TREE_TYPE (lhs))
+ == TYPE_SIZE (TREE_TYPE (base)))
+ || (TYPE_SIZE (TREE_TYPE (lhs))
+ && TYPE_SIZE (TREE_TYPE (base))
+ && operand_equal_p (TYPE_SIZE (TREE_TYPE (lhs)),
+ TYPE_SIZE (TREE_TYPE (base)),
+ 0)))
+ && operand_equal_p (lhs, base,
+ OEP_ADDRESS_OF
+ | OEP_MATCH_SIDE_EFFECTS))))
return true;
}
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index c6aa5879739..f8f03807ef0 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -2090,7 +2090,8 @@ static sbitmap has_abnormal_preds;
ANTIC_OUT[BLOCK] = phi_translate (ANTIC_IN[succ(BLOCK)])
ANTIC_IN[BLOCK] = clean(ANTIC_OUT[BLOCK] U EXP_GEN[BLOCK] - TMP_GEN[BLOCK])
-*/
+
+ Note that clean() is deferred until after the iteration. */
static bool
compute_antic_aux (basic_block block, bool block_has_abnormal_pred_edge)
@@ -2190,7 +2191,8 @@ compute_antic_aux (basic_block block, bool block_has_abnormal_pred_edge)
bitmap_value_insert_into_set (ANTIC_IN (block),
expression_for_id (bii));
- clean (ANTIC_IN (block));
+ /* clean (ANTIC_IN (block)) is defered to after the iteration converged
+ because it can cause non-convergence, see for example PR81181. */
if (!was_visited || !bitmap_set_equal (old, ANTIC_IN (block)))
changed = true;
@@ -2424,6 +2426,12 @@ compute_antic (void)
gcc_checking_assert (num_iterations < 500);
}
+ /* We have to clean after the dataflow problem converged as cleaning
+ can cause non-convergence because it is based on expressions
+ rather than values. */
+ FOR_EACH_BB_FN (block, cfun)
+ clean (ANTIC_IN (block));
+
statistics_histogram_event (cfun, "compute_antic iterations",
num_iterations);
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index ac3bfd2cb03..20f5ce2d140 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -2304,7 +2304,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
memset (&op, 0, sizeof (op));
op.type = vr->type;
op.opcode = MEM_REF;
- op.op0 = build_int_cst (ptr_type_node, at - rhs_offset);
+ op.op0 = build_int_cst (ptr_type_node, at - lhs_offset + rhs_offset);
op.off = at - lhs_offset + rhs_offset;
vr->operands[0] = op;
op.type = TREE_TYPE (rhs);
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index c8bcce01bb4..0ee4f9b373b 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -905,12 +905,49 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap,
return true;
}
-/* Recursively build an SLP tree starting from NODE.
- Fail (and return a value not equal to zero) if def-stmts are not
- isomorphic, require data permutation or are of unsupported types of
- operation. Otherwise, return 0.
- The value returned is the depth in the SLP tree where a mismatch
- was found. */
+/* Traits for the hash_set to record failed SLP builds for a stmt set.
+ Note we never remove apart from at destruction time so we do not
+ need a special value for deleted that differs from empty. */
+struct bst_traits
+{
+ typedef vec <gimple *> value_type;
+ typedef vec <gimple *> compare_type;
+ static inline hashval_t hash (value_type);
+ static inline bool equal (value_type existing, value_type candidate);
+ static inline bool is_empty (value_type x) { return !x.exists (); }
+ static inline bool is_deleted (value_type x) { return !x.exists (); }
+ static inline void mark_empty (value_type &x) { x.release (); }
+ static inline void mark_deleted (value_type &x) { x.release (); }
+ static inline void remove (value_type &x) { x.release (); }
+};
+inline hashval_t
+bst_traits::hash (value_type x)
+{
+ inchash::hash h;
+ for (unsigned i = 0; i < x.length (); ++i)
+ h.add_int (gimple_uid (x[i]));
+ return h.end ();
+}
+inline bool
+bst_traits::equal (value_type existing, value_type candidate)
+{
+ if (existing.length () != candidate.length ())
+ return false;
+ for (unsigned i = 0; i < existing.length (); ++i)
+ if (existing[i] != candidate[i])
+ return false;
+ return true;
+}
+
+static hash_set <vec <gimple *>, bst_traits> *bst_fail;
+
+static slp_tree
+vect_build_slp_tree_2 (vec_info *vinfo,
+ vec<gimple *> stmts, unsigned int group_size,
+ unsigned int *max_nunits,
+ vec<slp_tree> *loads,
+ bool *matches, unsigned *npermutes, unsigned *tree_size,
+ unsigned max_tree_size);
static slp_tree
vect_build_slp_tree (vec_info *vinfo,
@@ -920,6 +957,39 @@ vect_build_slp_tree (vec_info *vinfo,
bool *matches, unsigned *npermutes, unsigned *tree_size,
unsigned max_tree_size)
{
+ if (bst_fail->contains (stmts))
+ return NULL;
+ slp_tree res = vect_build_slp_tree_2 (vinfo, stmts, group_size, max_nunits,
+ loads, matches, npermutes, tree_size,
+ max_tree_size);
+ /* When SLP build fails for stmts record this, otherwise SLP build
+ can be exponential in time when we allow to construct parts from
+ scalars, see PR81723. */
+ if (! res)
+ {
+ vec <gimple *> x;
+ x.create (stmts.length ());
+ x.splice (stmts);
+ bst_fail->add (x);
+ }
+ return res;
+}
+
+/* Recursively build an SLP tree starting from NODE.
+ Fail (and return a value not equal to zero) if def-stmts are not
+ isomorphic, require data permutation or are of unsupported types of
+ operation. Otherwise, return 0.
+ The value returned is the depth in the SLP tree where a mismatch
+ was found. */
+
+static slp_tree
+vect_build_slp_tree_2 (vec_info *vinfo,
+ vec<gimple *> stmts, unsigned int group_size,
+ unsigned int *max_nunits,
+ vec<slp_tree> *loads,
+ bool *matches, unsigned *npermutes, unsigned *tree_size,
+ unsigned max_tree_size)
+{
unsigned nops, i, this_tree_size = 0, this_max_nunits = *max_nunits;
gimple *stmt;
slp_tree node;
@@ -979,6 +1049,9 @@ vect_build_slp_tree (vec_info *vinfo,
stmt = stmts[0];
+ if (tree_size)
+ max_tree_size -= *tree_size;
+
/* Create SLP_TREE nodes for the definition node/s. */
FOR_EACH_VEC_ELT (oprnds_info, i, oprnd_info)
{
@@ -1874,9 +1947,11 @@ vect_analyze_slp_instance (vec_info *vinfo,
/* Build the tree for the SLP instance. */
bool *matches = XALLOCAVEC (bool, group_size);
unsigned npermutes = 0;
+ bst_fail = new hash_set <vec <gimple *>, bst_traits> ();
node = vect_build_slp_tree (vinfo, scalar_stmts, group_size,
&max_nunits, &loads, matches, &npermutes,
NULL, max_tree_size);
+ delete bst_fail;
if (node != NULL)
{
/* Calculate the unrolling factor based on the smallest type. */
diff --git a/gcc/tree.c b/gcc/tree.c
index ef9b292d773..d7d01bb4e52 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -13219,18 +13219,26 @@ array_ref_up_bound (tree exp)
return NULL_TREE;
}
-/* Returns true if REF is an array reference to an array at the end of
- a structure. If this is the case, the array may be allocated larger
- than its upper bound implies. When ALLOW_COMPREF is true considers
- REF when it's a COMPONENT_REF in addition ARRAY_REF and
- ARRAY_RANGE_REF. */
+/* Returns true if REF is an array reference or a component reference
+ to an array at the end of a structure.
+ If this is the case, the array may be allocated larger
+ than its upper bound implies. */
bool
-array_at_struct_end_p (tree ref, bool allow_compref)
+array_at_struct_end_p (tree ref)
{
- if (TREE_CODE (ref) != ARRAY_REF
- && TREE_CODE (ref) != ARRAY_RANGE_REF
- && (!allow_compref || TREE_CODE (ref) != COMPONENT_REF))
+ tree atype;
+
+ if (TREE_CODE (ref) == ARRAY_REF
+ || TREE_CODE (ref) == ARRAY_RANGE_REF)
+ {
+ atype = TREE_TYPE (TREE_OPERAND (ref, 0));
+ ref = TREE_OPERAND (ref, 0);
+ }
+ else if (TREE_CODE (ref) == COMPONENT_REF
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 1))) == ARRAY_TYPE)
+ atype = TREE_TYPE (TREE_OPERAND (ref, 1));
+ else
return false;
while (handled_component_p (ref))
@@ -13238,19 +13246,42 @@ array_at_struct_end_p (tree ref, bool allow_compref)
/* If the reference chain contains a component reference to a
non-union type and there follows another field the reference
is not at the end of a structure. */
- if (TREE_CODE (ref) == COMPONENT_REF
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 0))) == RECORD_TYPE)
+ if (TREE_CODE (ref) == COMPONENT_REF)
{
- tree nextf = DECL_CHAIN (TREE_OPERAND (ref, 1));
- while (nextf && TREE_CODE (nextf) != FIELD_DECL)
- nextf = DECL_CHAIN (nextf);
- if (nextf)
- return false;
+ if (TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 0))) == RECORD_TYPE)
+ {
+ tree nextf = DECL_CHAIN (TREE_OPERAND (ref, 1));
+ while (nextf && TREE_CODE (nextf) != FIELD_DECL)
+ nextf = DECL_CHAIN (nextf);
+ if (nextf)
+ return false;
+ }
}
+ /* If we have a multi-dimensional array we do not consider
+ a non-innermost dimension as flex array if the whole
+ multi-dimensional array is at struct end.
+ Same for an array of aggregates with a trailing array
+ member. */
+ else if (TREE_CODE (ref) == ARRAY_REF)
+ return false;
+ else if (TREE_CODE (ref) == ARRAY_RANGE_REF)
+ ;
+ /* If we view an underlying object as sth else then what we
+ gathered up to now is what we have to rely on. */
+ else if (TREE_CODE (ref) == VIEW_CONVERT_EXPR)
+ break;
+ else
+ gcc_unreachable ();
ref = TREE_OPERAND (ref, 0);
}
+ /* The array now is at struct end. Treat flexible arrays as
+ always subject to extend, even into just padding constrained by
+ an underlying decl. */
+ if (! TYPE_SIZE (atype))
+ return true;
+
tree size = NULL;
if (TREE_CODE (ref) == MEM_REF
diff --git a/gcc/tree.h b/gcc/tree.h
index 0d805c0ca2a..375edcd4ba6 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4870,12 +4870,10 @@ extern tree array_ref_up_bound (tree);
EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */
extern tree array_ref_low_bound (tree);
-/* Returns true if REF is an array reference to an array at the end of
- a structure. If this is the case, the array may be allocated larger
- than its upper bound implies. When second argument is true considers
- REF when it's a COMPONENT_REF in addition ARRAY_REF and
- ARRAY_RANGE_REF. */
-extern bool array_at_struct_end_p (tree, bool = false);
+/* Returns true if REF is an array reference or a component reference
+ to an array at the end of a structure. If this is the case, the array
+ may be allocated larger than its upper bound implies. */
+extern bool array_at_struct_end_p (tree);
/* Return a tree representing the offset, in bytes, of the field referenced
by EXP. This does not include any offset in DECL_FIELD_BIT_OFFSET. */
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 7532a96d26d..93bfedf43c0 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,18 @@
+2017-09-07 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2017-08-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/81687
+ * testsuite/libgomp.c/pr81687-1.c: New test.
+ * testsuite/libgomp.c/pr81687-2.c: New test.
+
+ 2017-07-27 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/45784
+ * testsuite/libgomp.c/pr45784.c: New test.
+ * testsuite/libgomp.c++/pr45784.C: New test.
+
2017-08-14 Release Manager
* GCC 7.2.0 released.
diff --git a/libgomp/testsuite/libgomp.c++/pr45784.C b/libgomp/testsuite/libgomp.c++/pr45784.C
new file mode 100644
index 00000000000..306246c754a
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr45784.C
@@ -0,0 +1,5 @@
+// PR c/45784
+// { dg-do run }
+
+#include "../libgomp.c/pr45784.c"
+
diff --git a/libgomp/testsuite/libgomp.c/pr45784.c b/libgomp/testsuite/libgomp.c/pr45784.c
new file mode 100644
index 00000000000..78612108bf6
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/pr45784.c
@@ -0,0 +1,41 @@
+/* PR c/45784 */
+/* { dg-do run } */
+
+void
+foo (int n)
+{
+ char *p, vla[2 * n];
+ int i;
+ #pragma omp parallel for
+ for (p = vla; p < vla + (sizeof (vla) / sizeof (vla[0])); p++)
+ *p = ' ';
+ #pragma omp parallel for
+ for (i = 0; i < 2 * n; i++)
+ if (vla[i] != ' ')
+ __builtin_abort ();
+}
+
+void
+bar (int n)
+{
+ char *p, vla1[n], vla2[n * 2], vla3[n * 3], vla4[n * 4];
+ int i;
+ __builtin_memset (vla4, ' ', n * 4);
+ #pragma omp parallel for
+ for (p = vla4 + sizeof (vla1); p < vla4 + sizeof (vla3) - sizeof (vla2) + sizeof (vla1); p += sizeof (vla4) / sizeof (vla4))
+ p[0] = '!';
+ #pragma omp parallel for
+ for (i = 0; i < n * 4; i++)
+ if (vla4[i] != ((i >= n && i < 2 * n) ? '!' : ' '))
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ volatile int n;
+ n = 128;
+ foo (n);
+ bar (n);
+ return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/pr81687-1.c b/libgomp/testsuite/libgomp.c/pr81687-1.c
new file mode 100644
index 00000000000..768ec4484d4
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/pr81687-1.c
@@ -0,0 +1,23 @@
+/* PR c/81687 */
+/* { dg-do link } */
+/* { dg-additional-options "-O2" } */
+
+extern int printf (const char *, ...);
+
+int
+main ()
+{
+ #pragma omp parallel
+ {
+ lab1:
+ printf ("lab1=%p\n", (void *)(&&lab1));
+ }
+ lab2:
+ #pragma omp parallel
+ {
+ lab3:
+ printf ("lab2=%p\n", (void *)(&&lab2));
+ }
+ printf ("lab3=%p\n", (void *)(&&lab3));
+ return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/pr81687-2.c b/libgomp/testsuite/libgomp.c/pr81687-2.c
new file mode 100644
index 00000000000..e819f762032
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/pr81687-2.c
@@ -0,0 +1,27 @@
+/* PR c/81687 */
+/* { dg-do link } */
+/* { dg-additional-options "-O2" } */
+
+int
+main ()
+{
+ __label__ lab4, lab5, lab6;
+ volatile int l = 0;
+ int m = l;
+ void foo (int x) { if (x == 1) goto lab4; }
+ void bar (int x) { if (x == 2) goto lab5; }
+ void baz (int x) { if (x == 3) goto lab6; }
+ #pragma omp parallel
+ {
+ foo (m + 1);
+ lab4:;
+ }
+ #pragma omp task
+ {
+ bar (m + 2);
+ lab5:;
+ }
+ baz (m + 3);
+ lab6:;
+ return 0;
+}
diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index d4c9d4b1536..7aa9d287804 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,3 +1,10 @@
+2017-09-07 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2017-08-07 Jakub Jelinek <jakub@redhat.com>
+
+ * include/system/sys/ptrace.h: New file.
+
2017-08-14 Release Manager
* GCC 7.2.0 released.
diff --git a/libsanitizer/include/system/sys/ptrace.h b/libsanitizer/include/system/sys/ptrace.h
new file mode 100644
index 00000000000..1cfe4ce96e0
--- /dev/null
+++ b/libsanitizer/include/system/sys/ptrace.h
@@ -0,0 +1,7 @@
+#include_next <sys/ptrace.h>
+#ifndef PTRACE_GETREGSET
+/* glibc before
+ https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=cbff0d9689c4d68578b6a4f0a17807232506ea27
+ doesn't define PTRACE_GETREGSET. */
+#define PTRACE_GETREGSET 0x4204
+#endif
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 44b65fa9c5f..d36184ea211 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,222 @@
+2017-09-13 Jonathan Wakely <jwakely@redhat.com>
+
+ Backport from mainline
+ 2017-09-04 Daniel Kruegler <daniel.kruegler@gmail.com>
+
+ PR libstdc++/79162
+ Implement LWG 2946, LWG 2758's resolution missed further corrections
+ * include/bits/basic_string.h (basic_string::compare): Add missing
+ required noexcept specifications.
+ (basic_string): Introduce internal _S_to_string_view and __sv_wrapper
+ for implicit string_view conversion.
+ (basic_string::basic_string): Fix explicit string_view conversion by
+ implicit conversion using _S_to_string_view and __sv_wrapper.
+ (basic_string): Introduce internal basic_string(__sv_wrapper, Alloc)
+ constructor.
+ (basic_string): Fix operator=(T) template by operator=(const T&)
+ template for uncopyable types (PR 79162).
+ (basic_string::operator+=, basic_string::append, basic_string::assign)
+ (basic_string::insert, basic_string::replace, basic_string::find)
+ (basic_string::rfind, basic_string::find_first_of)
+ (basic_string::find_last_of, basic_string::find_first_not_of)
+ (basic_string::find_last_not_of, basic_string::compare): Replace
+ __sv_type argument by template const T& (LWG 2946) and correct
+ documentation describing __sv_type argument.
+ (basic_string::find, basic_string::rfind, basic_string::find_first_of)
+ (basic_string::find_last_of, basic_string::find_first_not_of)
+ (basic_string::find_last_not_of, basic_string::compare): Replace
+ unconditional noexcept specification by conditional noexcept
+ specification to partially balance the removal of noexcept by LWG 2946.
+ * testsuite/21_strings/basic_string/79162.cc: New.
+ * testsuite/21_strings/basic_string/lwg2946.cc: New.
+
+2017-09-13 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/81468
+ * include/std/chrono (time_point(const time_point<_Dur2>&)): Add
+ missing constraint from LWG DR 1177.
+ * testsuite/20_util/duration/cons/dr1177.cc: New.
+ * testsuite/20_util/time_point/cons/81468.cc: New.
+ * testsuite/20_util/duration/literals/range.cc: Update dg-error line.
+
+ * doc/doxygen/mainpage.html: Fix broken URLs.
+
+ PR libstdc++/81835
+ * doc/xml/manual/extensions.xml: Replace unstable URL.
+ * doc/html/manual/ext_demangling.html: Regenerate.
+ * libsupc++/cxxabi.h (__cxa_demangle): Fix broken URL.
+
+2017-09-12 Jonathan Wakely <jwakely@redhat.com>
+
+ Backport from mainline
+ 2017-09-12 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/70483
+ * include/experimental/bits/string_view.tcc (basic_string_view::find)
+ (basic_string_view::rfind, basic_string_view::find_first_of)
+ (basic_string_view::find_last_of, basic_string_view::find_first_not_of)
+ (basic_string_view::find_last_not_of): Add constexpr specifier.
+ * include/experimental/string_view (basic_string_view::remove_prefix)
+ (basic_string_view::remove_suffix, basic_string_view::swap)
+ (basic_string_view::compare, basic_string_view::find)
+ (basic_string_view::rfind, basic_string_view::find_first_of)
+ (basic_string_view::find_last_of, basic_string_view::find_first_not_of)
+ (basic_string_view::find_last_not_of, operator==, operator!=)
+ (operator<, operator>, operator<=, operator>=): Likewise.
+ * testsuite/experimental/string_view/operations/compare/char/70483.cc:
+ New.
+
+ Backport from mainline
+ 2017-09-11 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/70483
+ * include/bits/string_view.tcc (basic_string_view::find)
+ (basic_string_view::rfind, basic_string_view::find_first_of)
+ (basic_string_view::find_last_of, basic_string_view::find_first_not_of)
+ (basic_string_view::find_last_not_of): Add constexpr specifier.
+ * include/std/string_view (basic_string_view::operator=)
+ (basic_string_view::rbegin, basic_string_view::rend)
+ (basic_string_view::crbegin, basic_string_view::crend)
+ (basic_string_view::remove_prefix, basic_string_view::remove_suffix)
+ (basic_string_view::swap, basic_string_view::compare)
+ (basic_string_view::find, basic_string_view::rfind)
+ (basic_string_view::find_first_of, basic_string_view::find_last_of)
+ (basic_string_view::find_first_not_of)
+ (basic_string_view::find_last_not_of, basic_string_view::_M_check)
+ (basic_string_view::_M_limit, operator==, operator!=, operator<)
+ (operator>, operator<=, operator>=): Likewise.
+ * testsuite/21_strings/basic_string_view/modifiers/remove_prefix/
+ char/1.cc: Repeat tests in constexpr context.
+ * testsuite/21_strings/basic_string_view/modifiers/remove_prefix/
+ wchar_t/1.cc: Likewise.
+ * testsuite/21_strings/basic_string_view/modifiers/remove_suffix/
+ char/1.cc: Likewise.
+ * testsuite/21_strings/basic_string_view/modifiers/remove_suffix/
+ wchar_t/1.cc: Likewise.
+ * testsuite/21_strings/basic_string_view/operations/find/char/1.cc:
+ Likewise.
+ * testsuite/21_strings/basic_string_view/operations/find/char/2.cc:
+ Likewise.
+ * testsuite/21_strings/basic_string_view/operations/find/char/3.cc:
+ Likewise.
+ * testsuite/21_strings/basic_string_view/operations/find/wchar_t/1.cc:
+ Likewise.
+ * testsuite/21_strings/basic_string_view/operations/find/wchar_t/2.cc:
+ Likewise.
+ * testsuite/21_strings/basic_string_view/operations/find/wchar_t/3.cc:
+ Likewise.
+ * testsuite/21_strings/basic_string_view/operators/char/2.cc:
+ Likewise.
+ * testsuite/21_strings/basic_string_view/operators/wchar_t/2.cc:
+ Likewise.
+ * testsuite/21_strings/basic_string_view/range_access/char/1.cc: Test
+ cbegin, cend, rbegin, rend, crbegin and crend.
+ * testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc:
+ Likewise.
+ * testsuite/21_strings/basic_string_view/operations/compare/char/1.cc:
+ Remove trailing whitespace.
+ * testsuite/21_strings/basic_string_view/operations/compare/wchar_t/
+ 1.cc: Likewise.
+ * testsuite/21_strings/basic_string_view/modifiers/swap/char/1.cc:
+ New.
+ * testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t/1.cc:
+ New.
+ * testsuite/21_strings/basic_string_view/operations/compare/char/2.cc:
+ New.
+ * testsuite/21_strings/basic_string_view/operations/compare/wchar_t/
+ 2.cc: New.
+
+ Backport from mainline
+ 2017-06-12 Pedro Alves <palves@redhat.com>
+
+ * doc/xml/manual/status_cxx2017.xml: Update C++17 constexpr
+ char_traits status.
+ * doc/html/*: Regenerate.
+
+ * include/bits/char_traits.h (_GLIBCXX_ALWAYS_INLINE): Define if
+ not already defined.
+ (__cpp_lib_constexpr_char_traits): Uncomment.
+ (__constant_string_p, __constant_char_array_p): New.
+ (std::char_traits<char>, std::char_traits<wchar_t>): Add
+ _GLIBCXX17_CONSTEXPR on compare, length and find and use
+ __constant_string_p, __constant_char_array_p and
+ __builtin_constant_p to defer to __gnu_cxx::char_traits at compile
+ time.
+
+ * testsuite/21_strings/char_traits/requirements/
+ constexpr_functions_c++17.cc: Uncomment
+ __cpp_lib_constexpr_char_traits tests. Uncomment
+ test_compare<char>, test_length<char>, test_find<char>,
+ test_compare<wchar_t>, test_length<wchar_t> and test_find<wchar_t>
+ static_assert tests.
+
+2017-09-04 Jonathan Wakely <jwakely@redhat.com>
+
+ Backport from mainline
+ 2017-08-31 Jonathan Wakely <jwakely@redhat.com>
+
+ PR c++/82039
+ * include/ext/new_allocator.h (__gnu_cxx::new_allocator::allocate):
+ Adjust null pointer constant to avoid warning.
+
+ Backport from mainline
+ 2017-08-21 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/81912
+ * include/bits/stl_iterator_base_types.h (__iterator_category): Add
+ constexpr for C++11 and later.
+ * testsuite/24_iterators/container_access.cc: Add target selector.
+ * testsuite/24_iterators/range_access.cc: Fix clause number in
+ comment.
+ * testsuite/24_iterators/range_access_cpp14.cc: Likewise.
+ * testsuite/24_iterators/range_access_cpp17.cc: New.
+
+ Backport from mainline
+ 2017-08-09 Jonathan Wakely <jwakely@redhat.com>
+
+ * include/std/type_traits (_GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP):
+ Replace with _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP and use
+ __is_identifier to set it.
+
+ Backport from mainline
+ 2017-08-09 Katsuhiko Nishimra <ktns.87@gmail.com>
+
+ * include/std/type_traits (_GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE): Use
+ __is_identifier instead of __has_builtin.
+
+ Backport from mainline
+ 2017-08-18 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/81891
+ * include/bits/hashtable.h (_Hashtable(_InputIterator, _InputIterator,
+ size_type, const _H1&, const _H2&, const _Hash&, const _Equal&,
+ const _ExtractKey&, const allocator_type&)): Let destructor do clean
+ up if an exception is thrown.
+ * testsuite/23_containers/unordered_map/cons/81891.cc: New.
+
+ Backport from mainline
+ 2017-07-31 Marek Polacek <polacek@redhat.com>
+
+ PR libstdc++/81599
+ * include/bits/stl_stack.h: Fix typo.
+
+ Backport from mainline
+ 2017-07-10 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/81338
+ * include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI] (basic_string):
+ Declare basic_stringbuf to be a friend.
+ * include/bits/sstream.tcc (basic_stringbuf::overflow)
+ [_GLIBCXX_USE_CXX11_ABI]: Use unused capacity before reallocating.
+ * include/std/sstream (basic_stringbuf::__xfer_bufptrs): Update string
+ length to buffer length.
+ * testsuite/27_io/basic_stringstream/assign/81338.cc: New.
+
+2017-08-20 John David Anglin <danglin@gcc.gnu.org>
+
+ PR testsuite/81056
+ * testsuite/17_intro/names.cc: Undef 'd' and 'r' on __hpux__.
+
2017-08-14 Jonathan Wakely <jwakely@redhat.com>
Backport from mainline
diff --git a/libstdc++-v3/doc/doxygen/mainpage.html b/libstdc++-v3/doc/doxygen/mainpage.html
index aa650bafeda..b54482a74e9 100644
--- a/libstdc++-v3/doc/doxygen/mainpage.html
+++ b/libstdc++-v3/doc/doxygen/mainpage.html
@@ -28,7 +28,7 @@
<p>There are two types of documentation for libstdc++. One is the
distribution documentation, which can be read online
- <a href="http://gcc.gnu.org/onlinedocs/libstdc++/index.html">here</a>
+ <a href="https://gcc.gnu.org/onlinedocs/libstdc++/index.html">here</a>
or offline from the file doc/html/index.html in the library source
directory.
</p>
@@ -78,11 +78,11 @@
pages. See the section "Documentation Style"
in <code>doc/xml/manual/appendix_contributing.xml</code> in the
source tree for how to create (and write) the doxygen markup.
- This style guide can also be viewed on the <a href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01apas04.html">web</a>.
+ This style guide can also be viewed on the <a href="https://gcc.gnu.org/onlinedocs/libstdc++/manual/documentation_hacking.html">web</a>.
<h2>License, Copyright, and Other Lawyerly Verbosity</h2>
<p>The libstdc++ documentation is released under
- <a href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch01s02.html">
+ <a href="https://gcc.gnu.org/onlinedocs/libstdc++/manual/appendix_gpl.html">
these terms</a>.
</p>
<p>Part of the generated documentation involved comments and notes from
diff --git a/libstdc++-v3/doc/html/manual/ext_demangling.html b/libstdc++-v3/doc/html/manual/ext_demangling.html
index 3091976c4fb..7d6df2d8c41 100644
--- a/libstdc++-v3/doc/html/manual/ext_demangling.html
+++ b/libstdc++-v3/doc/html/manual/ext_demangling.html
@@ -7,7 +7,7 @@
original C++ source identifiers is called
<span class="quote">“<span class="quote">demangling.</span>”</span>
</p><p>
- If you have read the <a class="link" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01115.html" target="_top">source
+ If you have read the <a class="link" href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html" target="_top">source
documentation for <code class="code">namespace abi</code></a> then you are
aware of the cross-vendor C++ ABI in use by GCC. One of the
exposed functions is used for demangling,
diff --git a/libstdc++-v3/doc/html/manual/status.html b/libstdc++-v3/doc/html/manual/status.html
index c3b6201462a..483a0ffad19 100644
--- a/libstdc++-v3/doc/html/manual/status.html
+++ b/libstdc++-v3/doc/html/manual/status.html
@@ -684,11 +684,11 @@ Feature-testing recommendations for C++</a>.
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0505r0.html" target="_top">
P0505R0
</a>
- </td><td align="center"> 7 </td><td align="left"><code class="code"> ??? </code></td></tr><tr bgcolor="#B0B0B0"><td align="left"> Constexpr for <code class="code">std::char_traits</code> </td><td align="left">
+ </td><td align="center"> 7 </td><td align="left"><code class="code"> ??? </code></td></tr><tr><td align="left"> Constexpr for <code class="code">std::char_traits</code> </td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0426r1.html" target="_top">
P0426R1
</a>
- </td><td align="center"> 7 (partial) </td><td align="left"><code class="code"> ??? </code></td></tr><tr><td align="left"> Integrating <code class="code">std::string_view</code> and <code class="code">std::string</code> </td><td align="left">
+ </td><td align="center"> 7.3 </td><td align="left"><code class="code"> __cpp_lib_constexpr_char_traits &gt;= 201611 </code></td></tr><tr><td align="left"> Integrating <code class="code">std::string_view</code> and <code class="code">std::string</code> </td><td align="left">
<a class="link" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0254r2.pdf" target="_top">
P0254R2
</a>
@@ -961,4 +961,4 @@ particular release.
</td></tr></tbody></table></div></div><br class="table-break" /></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="intro.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="intro.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="license.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part I. 
Introduction
- </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> License</td></tr></table></div></body></html> \ No newline at end of file
+ </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> License</td></tr></table></div></body></html>
diff --git a/libstdc++-v3/doc/xml/manual/extensions.xml b/libstdc++-v3/doc/xml/manual/extensions.xml
index 41b1a801325..a6e4db2b6f7 100644
--- a/libstdc++-v3/doc/xml/manual/extensions.xml
+++ b/libstdc++-v3/doc/xml/manual/extensions.xml
@@ -502,7 +502,7 @@ get_temporary_buffer(5, (int*)0);
<quote>demangling.</quote>
</para>
<para>
- If you have read the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01115.html">source
+ If you have read the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html">source
documentation for <code>namespace abi</code></link> then you are
aware of the cross-vendor C++ ABI in use by GCC. One of the
exposed functions is used for demangling,
diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
index a2082380043..05cf41c3489 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
@@ -482,15 +482,14 @@ Feature-testing recommendations for C++</link>.
</row>
<row>
- <?dbhtml bgcolor="#B0B0B0" ?>
<entry> Constexpr for <code>std::char_traits</code> </entry>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0426r1.html">
P0426R1
</link>
</entry>
- <entry align="center"> 7 (partial) </entry>
- <entry><code> ??? </code></entry>
+ <entry align="center"> 7.3 </entry>
+ <entry><code> __cpp_lib_constexpr_char_traits >= 201611 </code></entry>
</row>
<row>
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index b6693c440c0..94ac2b3275b 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -117,6 +117,21 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
__and_<is_convertible<const _Tp&, __sv_type>,
__not_<is_convertible<const _Tp&, const _CharT*>>>::value,
_Res>;
+
+ // Allows an implicit conversion to __sv_type.
+ static __sv_type
+ _S_to_string_view(__sv_type __svt) noexcept
+ { return __svt; }
+
+ // Wraps a string_view by explicit conversion and thus
+ // allows to add an internal constructor that does not
+ // participate in overload resolution when a string_view
+ // is provided.
+ struct __sv_wrapper
+ {
+ explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
+ __sv_type _M_sv;
+ };
#endif
// Use empty-base optimization: http://www.cantrip.org/emptyopt.html
@@ -593,7 +608,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Construct string from a substring of a string_view.
- * @param __t Source string view.
+ * @param __t Source object convertible to string view.
* @param __pos The index of the first character to copy from __t.
* @param __n The number of characters to copy from __t.
* @param __a Allocator to use.
@@ -601,16 +616,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
template<typename _Tp, typename = _If_sv<_Tp, void>>
basic_string(const _Tp& __t, size_type __pos, size_type __n,
const _Alloc& __a = _Alloc())
- : basic_string(__sv_type(__t).substr(__pos, __n), __a) { }
+ : basic_string(_S_to_string_view(__t).substr(__pos, __n), __a) { }
/**
* @brief Construct string from a string_view.
- * @param __sv Source string view.
+ * @param __t Source object convertible to string view.
* @param __a Allocator to use (default is default allocator).
*/
+ template<typename _Tp, typename = _If_sv<_Tp, void>>
+ explicit
+ basic_string(const _Tp& __t, const _Alloc& __a = _Alloc())
+ : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
+
+ /**
+ * @brief Only internally used: Construct string from a string view
+ * wrapper.
+ * @param __svw string view wrapper.
+ * @param __a Allocator to use.
+ */
explicit
- basic_string(__sv_type __sv, const _Alloc& __a = _Alloc())
- : basic_string(__sv.data(), __sv.size(), __a) { }
+ basic_string(__sv_wrapper __svw, const _Alloc& __a)
+ : basic_string(__svw._M_sv.data(), __svw._M_sv.size(), __a) { }
#endif // C++17
/**
@@ -756,19 +782,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Set value to string constructed from a string_view.
- * @param __sv A string_view.
+ * @param __svt An object convertible to string_view.
*/
- template<typename _Tp>
- _If_sv<_Tp, basic_string&>
- operator=(_Tp __sv)
- { return this->assign(__sv); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ operator=(const _Tp& __svt)
+ { return this->assign(__svt); }
/**
* @brief Convert to a string_view.
* @return A string_view.
*/
operator __sv_type() const noexcept
- { return __sv_type(data(), size()); }
+ { return __sv_type(data(), size()); }
#endif // C++17
// Iterators:
@@ -1157,12 +1183,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Append a string_view.
- * @param __sv The string_view to be appended.
+ * @param __svt An object convertible to string_view to be appended.
* @return Reference to this string.
*/
- basic_string&
- operator+=(__sv_type __sv)
- { return this->append(__sv); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ operator+=(const _Tp& __svt)
+ { return this->append(__svt); }
#endif // C++17
/**
@@ -1265,22 +1292,26 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Append a string_view.
- * @param __sv The string_view to be appended.
+ * @param __svt An object convertible to string_view to be appended.
* @return Reference to this string.
*/
- basic_string&
- append(__sv_type __sv)
- { return this->append(__sv.data(), __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ append(const _Tp& __svt)
+ {
+ __sv_type __sv = __svt;
+ return this->append(__sv.data(), __sv.size());
+ }
/**
* @brief Append a range of characters from a string_view.
- * @param __sv The string_view to be appended from.
+ * @param __svt An object convertible to string_view to be appended from.
* @param __pos The position in the string_view to append from.
* @param __n The number of characters to append from the string_view.
* @return Reference to this string.
*/
- template <typename _Tp>
- _If_sv<_Tp, basic_string&>
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
append(const _Tp& __svt, size_type __pos, size_type __n = npos)
{
__sv_type __sv = __svt;
@@ -1433,21 +1464,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Set value from a string_view.
- * @param __sv The source string_view.
+ * @param __svt The source object convertible to string_view.
* @return Reference to this string.
*/
- basic_string&
- assign(__sv_type __sv)
- { return this->assign(__sv.data(), __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ assign(const _Tp& __svt)
+ {
+ __sv_type __sv = __svt;
+ return this->assign(__sv.data(), __sv.size());
+ }
/**
* @brief Set value from a range of characters in a string_view.
- * @param __sv The source string_view.
+ * @param __svt The source object convertible to string_view.
* @param __pos The position in the string_view to assign from.
* @param __n The number of characters to assign.
* @return Reference to this string.
*/
- template <typename _Tp>
+ template<typename _Tp>
_If_sv<_Tp, basic_string&>
assign(const _Tp& __svt, size_type __pos, size_type __n = npos)
{
@@ -1692,23 +1727,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
/**
* @brief Insert a string_view.
* @param __pos Iterator referencing position in string to insert at.
- * @param __sv The string_view to insert.
+ * @param __svt The object convertible to string_view to insert.
* @return Reference to this string.
*/
- basic_string&
- insert(size_type __pos, __sv_type __sv)
- { return this->insert(__pos, __sv.data(), __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ insert(size_type __pos, const _Tp& __svt)
+ {
+ __sv_type __sv = __svt;
+ return this->insert(__pos, __sv.data(), __sv.size());
+ }
/**
* @brief Insert a string_view.
* @param __pos Iterator referencing position in string to insert at.
- * @param __sv The string_view to insert from.
+ * @param __svt The object convertible to string_view to insert from.
* @param __pos Iterator referencing position in string_view to insert
* from.
* @param __n The number of characters to insert.
* @return Reference to this string.
*/
- template <typename _Tp>
+ template<typename _Tp>
_If_sv<_Tp, basic_string&>
insert(size_type __pos1, const _Tp& __svt,
size_type __pos2, size_type __n = npos)
@@ -2120,23 +2159,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
* @brief Replace range of characters with string_view.
* @param __pos The position to replace at.
* @param __n The number of characters to replace.
- * @param __sv The string_view to insert.
+ * @param __svt The object convertible to string_view to insert.
* @return Reference to this string.
*/
- basic_string&
- replace(size_type __pos, size_type __n, __sv_type __sv)
- { return this->replace(__pos, __n, __sv.data(), __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ replace(size_type __pos, size_type __n, const _Tp& __svt)
+ {
+ __sv_type __sv = __svt;
+ return this->replace(__pos, __n, __sv.data(), __sv.size());
+ }
/**
* @brief Replace range of characters with string_view.
* @param __pos1 The position to replace at.
* @param __n1 The number of characters to replace.
- * @param __sv The string_view to insert from.
+ * @param __svt The object convertible to string_view to insert from.
* @param __pos2 The position in the string_view to insert from.
* @param __n2 The number of characters to insert.
* @return Reference to this string.
*/
- template <typename _Tp>
+ template<typename _Tp>
_If_sv<_Tp, basic_string&>
replace(size_type __pos1, size_type __n1, const _Tp& __svt,
size_type __pos2, size_type __n2 = npos)
@@ -2153,12 +2196,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
to replace at.
* @param __i2 An iterator referencing the end position
for the replace.
- * @param __sv The string_view to insert from.
+ * @param __svt The object convertible to string_view to insert from.
* @return Reference to this string.
*/
- basic_string&
- replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
- { return this->replace(__i1 - begin(), __i2 - __i1, __sv); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ replace(const_iterator __i1, const_iterator __i2, const _Tp& __svt)
+ {
+ __sv_type __sv = __svt;
+ return this->replace(__i1 - begin(), __i2 - __i1, __sv);
+ }
#endif // C++17
private:
@@ -2288,13 +2335,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find position of a string_view.
- * @param __sv The string_view to locate.
+ * @param __svt The object convertible to string_view to locate.
* @param __pos Index of character to search from (default 0).
* @return Index of start of first occurrence.
*/
- size_type
- find(__sv_type __sv, size_type __pos = 0) const noexcept
- { return this->find(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ find(const _Tp& __svt, size_type __pos = 0) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->find(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -2345,13 +2397,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find last position of a string_view.
- * @param __sv The string_view to locate.
+ * @param __svt The object convertible to string_view to locate.
* @param __pos Index of character to search back from (default end).
* @return Index of start of last occurrence.
*/
- size_type
- rfind(__sv_type __sv, size_type __pos = npos) const noexcept
- { return this->rfind(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ rfind(const _Tp& __svt, size_type __pos = npos) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->rfind(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -2419,13 +2476,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find position of a character of a string_view.
- * @param __sv A string_view containing characters to locate.
+ * @param __svt An object convertible to string_view containing
+ * characters to locate.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*/
- size_type
- find_first_of(__sv_type __sv, size_type __pos = 0) const noexcept
- { return this->find_first_of(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ find_first_of(const _Tp& __svt, size_type __pos = 0) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->find_first_of(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -2497,13 +2560,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find last position of a character of string.
- * @param __sv A string_view containing characters to locate.
+ * @param __svt An object convertible to string_view containing
+ * characters to locate.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*/
- size_type
- find_last_of(__sv_type __sv, size_type __pos = npos) const noexcept
- { return this->find_last_of(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ find_last_of(const _Tp& __svt, size_type __pos = npos) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->find_last_of(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -2574,13 +2643,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find position of a character not in a string_view.
- * @param __sv A string_view containing characters to avoid.
+ * @param __svt A object convertible to string_view containing
+ * characters to avoid.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*/
- size_type
- find_first_not_of(__sv_type __sv, size_type __pos = 0) const noexcept
- { return this->find_first_not_of(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ find_first_not_of(const _Tp& __svt, size_type __pos = 0) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->find_first_not_of(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -2650,13 +2725,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find last position of a character not in a string_view.
- * @param __sv A string_view containing characters to avoid.
+ * @param __svt An object convertible to string_view containing
+ * characters to avoid.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*/
- size_type
- find_last_not_of(__sv_type __sv, size_type __pos = npos) const noexcept
- { return this->find_last_not_of(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ find_last_not_of(const _Tp& __svt, size_type __pos = npos) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->find_last_not_of(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -2754,46 +2835,57 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Compare to a string_view.
- * @param __sv A string_view to compare against.
+ * @param __svt An object convertible to string_view to compare against.
* @return Integer < 0, 0, or > 0.
*/
- int
- compare(__sv_type __sv) const
- {
- const size_type __size = this->size();
- const size_type __osize = __sv.size();
- const size_type __len = std::min(__size, __osize);
-
- int __r = traits_type::compare(_M_data(), __sv.data(), __len);
- if (!__r)
- __r = _S_compare(__size, __osize);
- return __r;
- }
+ template<typename _Tp>
+ _If_sv<_Tp, int>
+ compare(const _Tp& __svt) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ const size_type __size = this->size();
+ const size_type __osize = __sv.size();
+ const size_type __len = std::min(__size, __osize);
+
+ int __r = traits_type::compare(_M_data(), __sv.data(), __len);
+ if (!__r)
+ __r = _S_compare(__size, __osize);
+ return __r;
+ }
/**
* @brief Compare to a string_view.
* @param __pos A position in the string to start comparing from.
* @param __n The number of characters to compare.
- * @param __sv A string_view to compare against.
+ * @param __svt An object convertible to string_view to compare
+ * against.
* @return Integer < 0, 0, or > 0.
*/
- int
- compare(size_type __pos, size_type __n, __sv_type __sv) const
- { return __sv_type(*this).substr(__pos, __n).compare(__sv); }
+ template<typename _Tp>
+ _If_sv<_Tp, int>
+ compare(size_type __pos, size_type __n, const _Tp& __svt) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return __sv_type(*this).substr(__pos, __n).compare(__sv);
+ }
/**
* @brief Compare to a string_view.
* @param __pos1 A position in the string to start comparing from.
* @param __n1 The number of characters to compare.
- * @param __sv A string_view to compare against.
+ * @param __svt An object convertible to string_view to compare
+ * against.
* @param __pos2 A position in the string_view to start comparing from.
* @param __n2 The number of characters to compare.
* @return Integer < 0, 0, or > 0.
*/
- template <typename _Tp>
+ template<typename _Tp>
_If_sv<_Tp, int>
compare(size_type __pos1, size_type __n1, const _Tp& __svt,
size_type __pos2, size_type __n2 = npos) const
+ noexcept(is_same<_Tp, __sv_type>::value)
{
__sv_type __sv = __svt;
return __sv_type(*this)
@@ -2918,7 +3010,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
int
compare(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2) const;
- };
+
+ // Allow basic_stringbuf::__xfer_bufptrs to call _M_length:
+ template<typename, typename, typename> friend class basic_stringbuf;
+ };
_GLIBCXX_END_NAMESPACE_CXX11
#else // !_GLIBCXX_USE_CXX11_ABI
// Reference-counted COW string implentation
@@ -3345,6 +3440,21 @@ _GLIBCXX_END_NAMESPACE_CXX11
__and_<is_convertible<const _Tp&, __sv_type>,
__not_<is_convertible<const _Tp&, const _CharT*>>>::value,
_Res>;
+
+ // Allows an implicit conversion to __sv_type.
+ static __sv_type
+ _S_to_string_view(__sv_type __svt) noexcept
+ { return __svt; }
+
+ // Wraps a string_view by explicit conversion and thus
+ // allows to add an internal constructor that does not
+ // participate in overload resolution when a string_view
+ // is provided.
+ struct __sv_wrapper
+ {
+ explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
+ __sv_type _M_sv;
+ };
#endif
public:
@@ -3471,7 +3581,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Construct string from a substring of a string_view.
- * @param __t Source string view.
+ * @param __t Source object convertible to string view.
* @param __pos The index of the first character to copy from __t.
* @param __n The number of characters to copy from __t.
* @param __a Allocator to use.
@@ -3479,16 +3589,27 @@ _GLIBCXX_END_NAMESPACE_CXX11
template<typename _Tp, typename = _If_sv<_Tp, void>>
basic_string(const _Tp& __t, size_type __pos, size_type __n,
const _Alloc& __a = _Alloc())
- : basic_string(__sv_type(__t).substr(__pos, __n), __a) { }
+ : basic_string(_S_to_string_view(__t).substr(__pos, __n), __a) { }
/**
* @brief Construct string from a string_view.
- * @param __sv Source string view.
+ * @param __t Source object convertible to string view.
* @param __a Allocator to use (default is default allocator).
*/
+ template<typename _Tp, typename = _If_sv<_Tp, void>>
+ explicit
+ basic_string(const _Tp& __t, const _Alloc& __a = _Alloc())
+ : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
+
+ /**
+ * @brief Only internally used: Construct string from a string view
+ * wrapper.
+ * @param __svw string view wrapper.
+ * @param __a Allocator to use.
+ */
explicit
- basic_string(__sv_type __sv, const _Alloc& __a = _Alloc())
- : basic_string(__sv.data(), __sv.size(), __a) { }
+ basic_string(__sv_wrapper __svw, const _Alloc& __a)
+ : basic_string(__svw._M_sv.data(), __svw._M_sv.size(), __a) { }
#endif // C++17
/**
@@ -3559,12 +3680,12 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Set value to string constructed from a string_view.
- * @param __sv A string_view.
+ * @param __svt An object convertible to string_view.
*/
template<typename _Tp>
_If_sv<_Tp, basic_string&>
- operator=(_Tp __sv)
- { return this->assign(__sv); }
+ operator=(const _Tp& __svt)
+ { return this->assign(__svt); }
/**
* @brief Convert to a string_view.
@@ -3981,12 +4102,13 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Append a string_view.
- * @param __sv The string_view to be appended.
+ * @param __svt The object convertible to string_view to be appended.
* @return Reference to this string.
*/
- basic_string&
- operator+=(__sv_type __sv)
- { return this->append(__sv); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ operator+=(const _Tp& __svt)
+ { return this->append(__svt); }
#endif // C++17
/**
@@ -4072,22 +4194,27 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Append a string_view.
- * @param __sv The string_view to be appended.
+ * @param __svt The object convertible to string_view to be appended.
* @return Reference to this string.
*/
- basic_string&
- append(__sv_type __sv)
- { return this->append(__sv.data(), __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ append(const _Tp& __svt)
+ {
+ __sv_type __sv = __svt;
+ return this->append(__sv.data(), __sv.size());
+ }
/**
* @brief Append a range of characters from a string_view.
- * @param __sv The string_view to be appended from.
+ * @param __svt The object convertible to string_view to be appended
+ * from.
* @param __pos The position in the string_view to append from.
* @param __n The number of characters to append from the string_view.
* @return Reference to this string.
*/
- template <typename _Tp>
- _If_sv<_Tp, basic_string&>
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
append(const _Tp& __svt, size_type __pos, size_type __n = npos)
{
__sv_type __sv = __svt;
@@ -4225,23 +4352,27 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Set value from a string_view.
- * @param __sv The source string_view.
+ * @param __svt The source object convertible to string_view.
* @return Reference to this string.
*/
- basic_string&
- assign(__sv_type __sv)
- { return this->assign(__sv.data(), __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ assign(const _Tp& __svt)
+ {
+ __sv_type __sv = __svt;
+ return this->assign(__sv.data(), __sv.size());
+ }
/**
* @brief Set value from a range of characters in a string_view.
- * @param __sv The source string_view.
+ * @param __svt The source object convertible to string_view.
* @param __pos The position in the string_view to assign from.
* @param __n The number of characters to assign.
* @return Reference to this string.
*/
- template <typename _Tp>
- _If_sv<_Tp, basic_string&>
- assign(const _Tp& __svt, size_type __pos, size_type __n = npos)
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ assign(const _Tp& __svt, size_type __pos, size_type __n = npos)
{
__sv_type __sv = __svt;
return assign(__sv.data()
@@ -4429,25 +4560,29 @@ _GLIBCXX_END_NAMESPACE_CXX11
/**
* @brief Insert a string_view.
* @param __pos Iterator referencing position in string to insert at.
- * @param __sv The string_view to insert.
+ * @param __svt The object convertible to string_view to insert.
* @return Reference to this string.
*/
- basic_string&
- insert(size_type __pos, __sv_type __sv)
- { return this->insert(__pos, __sv.data(), __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ insert(size_type __pos, const _Tp& __svt)
+ {
+ __sv_type __sv = __svt;
+ return this->insert(__pos, __sv.data(), __sv.size());
+ }
/**
* @brief Insert a string_view.
* @param __pos Iterator referencing position in string to insert at.
- * @param __sv The string_view to insert from.
+ * @param __svt The object convertible to string_view to insert from.
* @param __pos Iterator referencing position in string_view to insert
* from.
* @param __n The number of characters to insert.
* @return Reference to this string.
*/
- template <typename _Tp>
- _If_sv<_Tp, basic_string&>
- insert(size_type __pos1, const _Tp& __svt,
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ insert(size_type __pos1, const _Tp& __svt,
size_type __pos2, size_type __n = npos)
{
__sv_type __sv = __svt;
@@ -4790,7 +4925,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1.base(), __k2 - __k1);
}
-
+
#if __cplusplus >= 201103L
/**
* @brief Replace range of characters with initializer_list.
@@ -4816,31 +4951,35 @@ _GLIBCXX_END_NAMESPACE_CXX11
* @brief Replace range of characters with string_view.
* @param __pos The position to replace at.
* @param __n The number of characters to replace.
- * @param __sv The string_view to insert.
+ * @param __svt The object convertible to string_view to insert.
* @return Reference to this string.
*/
- basic_string&
- replace(size_type __pos, size_type __n, __sv_type __sv)
- { return this->replace(__pos, __n, __sv.data(), __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ replace(size_type __pos, size_type __n, const _Tp& __svt)
+ {
+ __sv_type __sv = __svt;
+ return this->replace(__pos, __n, __sv.data(), __sv.size());
+ }
/**
* @brief Replace range of characters with string_view.
* @param __pos1 The position to replace at.
* @param __n1 The number of characters to replace.
- * @param __sv The string_view to insert from.
+ * @param __svt The object convertible to string_view to insert from.
* @param __pos2 The position in the string_view to insert from.
* @param __n2 The number of characters to insert.
* @return Reference to this string.
*/
- template <typename _Tp>
- _If_sv<_Tp, basic_string&>
- replace(size_type __pos1, size_type __n1, const _Tp& __svt,
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ replace(size_type __pos1, size_type __n1, const _Tp& __svt,
size_type __pos2, size_type __n2 = npos)
{
__sv_type __sv = __svt;
- return this->replace(__pos1, __n1, __sv.data()
- + __sv._M_check(__pos2, "basic_string::replace"),
- __sv._M_limit(__pos2, __n2));
+ return this->replace(__pos1, __n1,
+ __sv.data() + __sv._M_check(__pos2, "basic_string::replace"),
+ __sv._M_limit(__pos2, __n2));
}
/**
@@ -4849,12 +4988,16 @@ _GLIBCXX_END_NAMESPACE_CXX11
to replace at.
* @param __i2 An iterator referencing the end position
for the replace.
- * @param __sv The string_view to insert from.
+ * @param __svt The object convertible to string_view to insert from.
* @return Reference to this string.
*/
- basic_string&
- replace(const_iterator __i1, const_iterator __i2, __sv_type __sv)
- { return this->replace(__i1 - begin(), __i2 - __i1, __sv); }
+ template<typename _Tp>
+ _If_sv<_Tp, basic_string&>
+ replace(const_iterator __i1, const_iterator __i2, const _Tp& __svt)
+ {
+ __sv_type __sv = __svt;
+ return this->replace(__i1 - begin(), __i2 - __i1, __sv);
+ }
#endif // C++17
private:
@@ -5059,13 +5202,18 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find position of a string_view.
- * @param __sv The string_view to locate.
+ * @param __svt The object convertible to string_view to locate.
* @param __pos Index of character to search from (default 0).
* @return Index of start of first occurrence.
*/
- size_type
- find(__sv_type __sv, size_type __pos = 0) const noexcept
- { return this->find(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ find(const _Tp& __svt, size_type __pos = 0) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->find(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -5132,13 +5280,18 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find last position of a string_view.
- * @param __sv The string_view to locate.
+ * @param __svt The object convertible to string_view to locate.
* @param __pos Index of character to search back from (default end).
* @return Index of start of last occurrence.
*/
- size_type
- rfind(__sv_type __sv, size_type __pos = npos) const noexcept
- { return this->rfind(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ rfind(const _Tp& __svt, size_type __pos = npos) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->rfind(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -5210,13 +5363,19 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find position of a character of a string_view.
- * @param __sv A string_view containing characters to locate.
+ * @param __svt An object convertible to string_view containing
+ * characters to locate.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*/
- size_type
- find_first_of(__sv_type __sv, size_type __pos = 0) const noexcept
- { return this->find_first_of(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ find_first_of(const _Tp& __svt, size_type __pos = 0) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->find_first_of(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -5288,13 +5447,19 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find last position of a character of string.
- * @param __sv A string_view containing characters to locate.
+ * @param __svt An object convertible to string_view containing
+ * characters to locate.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*/
- size_type
- find_last_of(__sv_type __sv, size_type __pos = npos) const noexcept
- { return this->find_last_of(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ find_last_of(const _Tp& __svt, size_type __pos = npos) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->find_last_of(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -5363,13 +5528,19 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find position of a character not in a string_view.
- * @param __sv A string_view containing characters to avoid.
+ * @param __svt An object convertible to string_view containing
+ * characters to avoid.
* @param __pos Index of character to search from (default 0).
* @return Index of first occurrence.
*/
- size_type
- find_first_not_of(__sv_type __sv, size_type __pos = 0) const noexcept
- { return this->find_first_not_of(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ find_first_not_of(const _Tp& __svt, size_type __pos = 0) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->find_first_not_of(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -5439,13 +5610,19 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Find last position of a character not in a string_view.
- * @param __sv A string_view containing characters to avoid.
+ * @param __svt An object convertible to string_view containing
+ * characters to avoid.
* @param __pos Index of character to search back from (default end).
* @return Index of last occurrence.
*/
- size_type
- find_last_not_of(__sv_type __sv, size_type __pos = npos) const noexcept
- { return this->find_last_not_of(__sv.data(), __pos, __sv.size()); }
+ template<typename _Tp>
+ _If_sv<_Tp, size_type>
+ find_last_not_of(const _Tp& __svt, size_type __pos = npos) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return this->find_last_not_of(__sv.data(), __pos, __sv.size());
+ }
#endif // C++17
/**
@@ -5495,46 +5672,57 @@ _GLIBCXX_END_NAMESPACE_CXX11
#if __cplusplus > 201402L
/**
* @brief Compare to a string_view.
- * @param __sv A string_view to compare against.
+ * @param __svt An object convertible to string_view to compare against.
* @return Integer < 0, 0, or > 0.
*/
- int
- compare(__sv_type __sv) const
- {
- const size_type __size = this->size();
- const size_type __osize = __sv.size();
- const size_type __len = std::min(__size, __osize);
-
- int __r = traits_type::compare(_M_data(), __sv.data(), __len);
- if (!__r)
- __r = _S_compare(__size, __osize);
- return __r;
- }
+ template<typename _Tp>
+ _If_sv<_Tp, int>
+ compare(const _Tp& __svt) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ const size_type __size = this->size();
+ const size_type __osize = __sv.size();
+ const size_type __len = std::min(__size, __osize);
+
+ int __r = traits_type::compare(_M_data(), __sv.data(), __len);
+ if (!__r)
+ __r = _S_compare(__size, __osize);
+ return __r;
+ }
/**
* @brief Compare to a string_view.
* @param __pos A position in the string to start comparing from.
* @param __n The number of characters to compare.
- * @param __sv A string_view to compare against.
+ * @param __svt An object convertible to string_view to compare
+ * against.
* @return Integer < 0, 0, or > 0.
*/
- int
- compare(size_type __pos, size_type __n, __sv_type __sv) const
- { return __sv_type(*this).substr(__pos, __n).compare(__sv); }
+ template<typename _Tp>
+ _If_sv<_Tp, int>
+ compare(size_type __pos, size_type __n, const _Tp& __svt) const
+ noexcept(is_same<_Tp, __sv_type>::value)
+ {
+ __sv_type __sv = __svt;
+ return __sv_type(*this).substr(__pos, __n).compare(__sv);
+ }
/**
* @brief Compare to a string_view.
* @param __pos1 A position in the string to start comparing from.
* @param __n1 The number of characters to compare.
- * @param __sv A string_view to compare against.
+ * @param __svt An object convertible to string_view to compare
+ * against.
* @param __pos2 A position in the string_view to start comparing from.
* @param __n2 The number of characters to compare.
* @return Integer < 0, 0, or > 0.
*/
- template <typename _Tp>
+ template<typename _Tp>
_If_sv<_Tp, int>
compare(size_type __pos1, size_type __n1, const _Tp& __svt,
size_type __pos2, size_type __n2 = npos) const
+ noexcept(is_same<_Tp, __sv_type>::value)
{
__sv_type __sv = __svt;
return __sv_type(*this)
diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h
index 75db5b89321..3ecc30e46cb 100644
--- a/libstdc++-v3/include/bits/char_traits.h
+++ b/libstdc++-v3/include/bits/char_traits.h
@@ -40,6 +40,10 @@
#include <bits/postypes.h> // For streampos
#include <cwchar> // For WEOF, wmemmove, wmemset, etc.
+#ifndef _GLIBCXX_ALWAYS_INLINE
+#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__))
+#endif
+
namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -139,7 +143,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return !eq_int_type(__c, eof()) ? __c : to_int_type(char_type()); }
};
-// #define __cpp_lib_constexpr_char_traits 201611
+#define __cpp_lib_constexpr_char_traits 201611
template<typename _CharT>
_GLIBCXX14_CONSTEXPR int
@@ -212,6 +216,42 @@ namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
+#if __cplusplus > 201402
+ /**
+ * @brief Determine whether the characters of a NULL-terminated
+ * string are known at compile time.
+ * @param __s The string.
+ *
+ * Assumes that _CharT is a built-in character type.
+ */
+ template<typename _CharT>
+ static _GLIBCXX_ALWAYS_INLINE constexpr bool
+ __constant_string_p(const _CharT* __s)
+ {
+ while (__builtin_constant_p(*__s) && *__s)
+ __s++;
+ return __builtin_constant_p(*__s);
+ }
+
+ /**
+ * @brief Determine whether the characters of a character array are
+ * known at compile time.
+ * @param __a The character array.
+ * @param __n Number of characters.
+ *
+ * Assumes that _CharT is a built-in character type.
+ */
+ template<typename _CharT>
+ static _GLIBCXX_ALWAYS_INLINE constexpr bool
+ __constant_char_array_p(const _CharT* __a, size_t __n)
+ {
+ size_t __i = 0;
+ while (__builtin_constant_p(__a[__i]) && __i < __n)
+ __i++;
+ return __i == __n;
+ }
+#endif
+
// 21.1
/**
* @brief Basis for explicit traits specializations.
@@ -256,21 +296,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
< static_cast<unsigned char>(__c2));
}
- static /* _GLIBCXX17_CONSTEXPR */ int
+ static _GLIBCXX17_CONSTEXPR int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
{
+#if __cplusplus > 201402
+ if (__builtin_constant_p(__n)
+ && __constant_char_array_p(__s1, __n)
+ && __constant_char_array_p(__s2, __n))
+ return __gnu_cxx::char_traits<char_type>::compare(__s1, __s2, __n);
+#endif
if (__n == 0)
return 0;
return __builtin_memcmp(__s1, __s2, __n);
}
- static /* _GLIBCXX17_CONSTEXPR */ size_t
+ static _GLIBCXX17_CONSTEXPR size_t
length(const char_type* __s)
- { return __builtin_strlen(__s); }
+ {
+#if __cplusplus > 201402
+ if (__constant_string_p(__s))
+ return __gnu_cxx::char_traits<char_type>::length(__s);
+#endif
+ return __builtin_strlen(__s);
+ }
- static /* _GLIBCXX17_CONSTEXPR */ const char_type*
+ static _GLIBCXX17_CONSTEXPR const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
{
+#if __cplusplus > 201402
+ if (__builtin_constant_p(__n)
+ && __builtin_constant_p(__a)
+ && __constant_char_array_p(__s, __n))
+ return __gnu_cxx::char_traits<char_type>::find(__s, __n, __a);
+#endif
if (__n == 0)
return 0;
return static_cast<const char_type*>(__builtin_memchr(__s, __a, __n));
@@ -347,24 +405,45 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
lt(const char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
{ return __c1 < __c2; }
- static /* _GLIBCXX17_CONSTEXPR */ int
+ static _GLIBCXX17_CONSTEXPR int
compare(const char_type* __s1, const char_type* __s2, size_t __n)
{
+#if __cplusplus > 201402
+ if (__builtin_constant_p(__n)
+ && __constant_char_array_p(__s1, __n)
+ && __constant_char_array_p(__s2, __n))
+ return __gnu_cxx::char_traits<char_type>::compare(__s1, __s2, __n);
+#endif
if (__n == 0)
return 0;
- return wmemcmp(__s1, __s2, __n);
+ else
+ return wmemcmp(__s1, __s2, __n);
}
- static /* _GLIBCXX17_CONSTEXPR */ size_t
+ static _GLIBCXX17_CONSTEXPR size_t
length(const char_type* __s)
- { return wcslen(__s); }
+ {
+#if __cplusplus > 201402
+ if (__constant_string_p(__s))
+ return __gnu_cxx::char_traits<char_type>::length(__s);
+ else
+#endif
+ return wcslen(__s);
+ }
- static /* _GLIBCXX17_CONSTEXPR */ const char_type*
+ static _GLIBCXX17_CONSTEXPR const char_type*
find(const char_type* __s, size_t __n, const char_type& __a)
{
+#if __cplusplus > 201402
+ if (__builtin_constant_p(__n)
+ && __builtin_constant_p(__a)
+ && __constant_char_array_p(__s, __n))
+ return __gnu_cxx::char_traits<char_type>::find(__s, __n, __a);
+#endif
if (__n == 0)
return 0;
- return wmemchr(__s, __a, __n);
+ else
+ return wmemchr(__s, __a, __n);
}
static char_type*
diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h
index bc7448bcf13..e0806dc93a1 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -973,17 +973,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_bucket_count = __bkt_count;
}
- __try
- {
- for (; __f != __l; ++__f)
- this->insert(*__f);
- }
- __catch(...)
- {
- clear();
- _M_deallocate_buckets();
- __throw_exception_again;
- }
+ for (; __f != __l; ++__f)
+ this->insert(*__f);
}
template<typename _Key, typename _Value,
diff --git a/libstdc++-v3/include/bits/sstream.tcc b/libstdc++-v3/include/bits/sstream.tcc
index 72e8742b4cf..fc2fcb8992d 100644
--- a/libstdc++-v3/include/bits/sstream.tcc
+++ b/libstdc++-v3/include/bits/sstream.tcc
@@ -88,6 +88,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return traits_type::not_eof(__c);
const __size_type __capacity = _M_string.capacity();
+
+#if _GLIBCXX_USE_CXX11_ABI
+ if ((this->epptr() - this->pbase()) < __capacity)
+ {
+ // There is additional capacity in _M_string that can be used.
+ char_type* __base = const_cast<char_type*>(_M_string.data());
+ _M_pbump(__base, __base + __capacity, this->pptr() - this->pbase());
+ if (_M_mode & ios_base::in)
+ {
+ const __size_type __nget = this->gptr() - this->eback();
+ const __size_type __eget = this->egptr() - this->eback();
+ this->setg(__base, __base + __nget, __base + __eget + 1);
+ }
+ *this->pptr() = traits_type::to_char_type(__c);
+ this->pbump(1);
+ return __c;
+ }
+#endif
+
const __size_type __max_size = _M_string.max_size();
const bool __testput = this->pptr() < this->epptr();
if (__builtin_expect(!__testput && __capacity == __max_size, false))
diff --git a/libstdc++-v3/include/bits/stl_iterator_base_types.h b/libstdc++-v3/include/bits/stl_iterator_base_types.h
index 24ed016b91e..d2c36ed2ac3 100644
--- a/libstdc++-v3/include/bits/stl_iterator_base_types.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_types.h
@@ -200,7 +200,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* sugar for internal library use only.
*/
template<typename _Iter>
- inline typename iterator_traits<_Iter>::iterator_category
+ inline _GLIBCXX_CONSTEXPR
+ typename iterator_traits<_Iter>::iterator_category
__iterator_category(const _Iter&)
{ return typename iterator_traits<_Iter>::iterator_category(); }
diff --git a/libstdc++-v3/include/bits/stl_stack.h b/libstdc++-v3/include/bits/stl_stack.h
index ac59ec715cf..5f2b4ab4486 100644
--- a/libstdc++-v3/include/bits/stl_stack.h
+++ b/libstdc++-v3/include/bits/stl_stack.h
@@ -86,7 +86,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*
* The second template parameter defines the type of the underlying
* sequence/container. It defaults to std::deque, but it can be
- * any type that supports @c back, @c push_back, and @c pop_front,
+ * any type that supports @c back, @c push_back, and @c pop_back,
* such as std::list, std::vector, or an appropriate user-defined
* type.
*
diff --git a/libstdc++-v3/include/bits/string_view.tcc b/libstdc++-v3/include/bits/string_view.tcc
index ffdcc30cae3..accc54e87bb 100644
--- a/libstdc++-v3/include/bits/string_view.tcc
+++ b/libstdc++-v3/include/bits/string_view.tcc
@@ -45,7 +45,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find(const _CharT* __str, size_type __pos, size_type __n) const noexcept
{
@@ -66,7 +66,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find(_CharT __c, size_type __pos) const noexcept
{
@@ -82,7 +82,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept
{
@@ -102,7 +102,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
rfind(_CharT __c, size_type __pos) const noexcept
{
@@ -119,7 +119,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -135,7 +135,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -156,7 +156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -168,7 +168,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_not_of(_CharT __c, size_type __pos) const noexcept
{
@@ -179,7 +179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -200,7 +200,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_not_of(_CharT __c, size_type __pos) const noexcept
{
diff --git a/libstdc++-v3/include/experimental/bits/string_view.tcc b/libstdc++-v3/include/experimental/bits/string_view.tcc
index 03863d0a9df..30968fc6b83 100644
--- a/libstdc++-v3/include/experimental/bits/string_view.tcc
+++ b/libstdc++-v3/include/experimental/bits/string_view.tcc
@@ -49,7 +49,7 @@ inline namespace fundamentals_v1
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find(const _CharT* __str, size_type __pos, size_type __n) const noexcept
{
@@ -70,7 +70,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find(_CharT __c, size_type __pos) const noexcept
{
@@ -86,7 +86,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept
{
@@ -106,7 +106,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
rfind(_CharT __c, size_type __pos) const noexcept
{
@@ -123,7 +123,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -139,7 +139,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -160,7 +160,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -172,7 +172,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_first_not_of(_CharT __c, size_type __pos) const noexcept
{
@@ -183,7 +183,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const
{
@@ -204,7 +204,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _CharT, typename _Traits>
- typename basic_string_view<_CharT, _Traits>::size_type
+ constexpr typename basic_string_view<_CharT, _Traits>::size_type
basic_string_view<_CharT, _Traits>::
find_last_not_of(_CharT __c, size_type __pos) const noexcept
{
diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view
index bd212ac3719..24c17e8cbe8 100644
--- a/libstdc++-v3/include/experimental/string_view
+++ b/libstdc++-v3/include/experimental/string_view
@@ -219,7 +219,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// [string.view.modifiers], modifiers:
- void
+ constexpr void
remove_prefix(size_type __n)
{
__glibcxx_assert(this->_M_len >= __n);
@@ -227,15 +227,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
this->_M_len -= __n;
}
- void
+ constexpr void
remove_suffix(size_type __n)
{ this->_M_len -= __n; }
- void
+ constexpr void
swap(basic_string_view& __sv) noexcept
{
- std::swap(this->_M_len, __sv._M_len);
- std::swap(this->_M_str, __sv._M_str);
+ auto __tmp = *this;
+ *this = __sv;
+ __sv = __tmp;
}
@@ -285,7 +286,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__pos, this->size()), basic_string_view{});
}
- int
+ constexpr int
compare(basic_string_view __str) const noexcept
{
int __ret = traits_type::compare(this->_M_str, __str._M_str,
@@ -295,24 +296,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __ret;
}
- int
+ constexpr int
compare(size_type __pos1, size_type __n1, basic_string_view __str) const
{ return this->substr(__pos1, __n1).compare(__str); }
- int
+ constexpr int
compare(size_type __pos1, size_type __n1,
basic_string_view __str, size_type __pos2, size_type __n2) const
{ return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); }
- int
+ constexpr int
compare(const _CharT* __str) const noexcept
{ return this->compare(basic_string_view{__str}); }
- int
+ constexpr int
compare(size_type __pos1, size_type __n1, const _CharT* __str) const
{ return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
- int
+ constexpr int
compare(size_type __pos1, size_type __n1,
const _CharT* __str, size_type __n2) const
{
@@ -320,97 +321,97 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
.compare(basic_string_view(__str, __n2));
}
- size_type
+ constexpr size_type
find(basic_string_view __str, size_type __pos = 0) const noexcept
{ return this->find(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find(_CharT __c, size_type __pos=0) const noexcept;
- size_type
+ constexpr size_type
find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
- size_type
+ constexpr size_type
find(const _CharT* __str, size_type __pos=0) const noexcept
{ return this->find(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
rfind(basic_string_view __str, size_type __pos = npos) const noexcept
{ return this->rfind(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
rfind(_CharT __c, size_type __pos = npos) const noexcept;
- size_type
+ constexpr size_type
rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
- size_type
+ constexpr size_type
rfind(const _CharT* __str, size_type __pos = npos) const noexcept
{ return this->rfind(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
{ return this->find_first_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_first_of(_CharT __c, size_type __pos = 0) const noexcept
{ return this->find(__c, __pos); }
- size_type
+ constexpr size_type
find_first_of(const _CharT* __str, size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
{ return this->find_first_of(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
find_last_of(basic_string_view __str,
size_type __pos = npos) const noexcept
{ return this->find_last_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_last_of(_CharT __c, size_type __pos=npos) const noexcept
{ return this->rfind(__c, __pos); }
- size_type
+ constexpr size_type
find_last_of(const _CharT* __str, size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
{ return this->find_last_of(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
find_first_not_of(basic_string_view __str,
size_type __pos = 0) const noexcept
{ return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
- size_type
+ constexpr size_type
find_first_not_of(const _CharT* __str,
size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
{
return this->find_first_not_of(__str, __pos,
traits_type::length(__str));
}
- size_type
+ constexpr size_type
find_last_not_of(basic_string_view __str,
size_type __pos = npos) const noexcept
{ return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
- size_type
+ constexpr size_type
find_last_not_of(const _CharT* __str,
size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_last_not_of(const _CharT* __str,
size_type __pos = npos) const noexcept
{
@@ -452,109 +453,109 @@ _GLIBCXX_END_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator!=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator!=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator< (basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator< (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator> (basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator> (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator<=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator<=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator>=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) >= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator>=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) >= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) >= 0; }
diff --git a/libstdc++-v3/include/ext/new_allocator.h b/libstdc++-v3/include/ext/new_allocator.h
index ee64b9c6447..e1e152c4bf0 100644
--- a/libstdc++-v3/include/ext/new_allocator.h
+++ b/libstdc++-v3/include/ext/new_allocator.h
@@ -96,7 +96,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// NB: __n is permitted to be 0. The C++ standard says nothing
// about what the return value is when __n == 0.
pointer
- allocate(size_type __n, const void* = 0)
+ allocate(size_type __n, const void* = static_cast<const void*>(0))
{
if (__n > this->max_size())
std::__throw_bad_alloc();
diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index c3a6ba8f873..cc63d44657b 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -622,7 +622,8 @@ _GLIBCXX_END_NAMESPACE_VERSION
{ }
// conversions
- template<typename _Dur2>
+ template<typename _Dur2,
+ typename = _Require<is_convertible<_Dur2, _Dur>>>
constexpr time_point(const time_point<clock, _Dur2>& __t)
: __d(__t.time_since_epoch())
{ }
diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream
index 2a56d734806..7690252b3e3 100644
--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -302,18 +302,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
__xfer_bufptrs(const basic_stringbuf& __from, basic_stringbuf* __to)
: _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1}
{
- const _CharT* __str = __from._M_string.data();
+ const _CharT* const __str = __from._M_string.data();
+ const _CharT* __end = nullptr;
if (__from.eback())
{
- _M_goff[0] = __from.eback() - __str;
- _M_goff[1] = __from.gptr() - __str;
- _M_goff[2] = __from.egptr() - __str;
+ _M_goff[0] = __from.eback() - __str;
+ _M_goff[1] = __from.gptr() - __str;
+ _M_goff[2] = __from.egptr() - __str;
+ __end = __from.egptr();
}
if (__from.pbase())
{
_M_poff[0] = __from.pbase() - __str;
_M_poff[1] = __from.pptr() - __from.pbase();
_M_poff[2] = __from.epptr() - __str;
+ if (__from.pptr() > __end)
+ __end = __from.pptr();
+ }
+
+ // Set _M_string length to the greater of the get and put areas.
+ if (__end)
+ {
+ // The const_cast avoids changing this constructor's signature,
+ // because it is exported from the dynamic library.
+ auto& __mut_from = const_cast<basic_stringbuf&>(__from);
+ __mut_from._M_string._M_length(__end - __str);
}
}
diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view
index 311d6d725b3..6c7cb035f9a 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -106,7 +106,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_str{__str}
{ }
- basic_string_view&
+ constexpr basic_string_view&
operator=(const basic_string_view&) noexcept = default;
// [string.view.iterators], iterators
@@ -127,19 +127,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
cend() const noexcept
{ return this->_M_str + this->_M_len; }
- const_reverse_iterator
+ constexpr const_reverse_iterator
rbegin() const noexcept
{ return const_reverse_iterator(this->end()); }
- const_reverse_iterator
+ constexpr const_reverse_iterator
rend() const noexcept
{ return const_reverse_iterator(this->begin()); }
- const_reverse_iterator
+ constexpr const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(this->end()); }
- const_reverse_iterator
+ constexpr const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(this->begin()); }
@@ -208,7 +208,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// [string.view.modifiers], modifiers:
- void
+ constexpr void
remove_prefix(size_type __n)
{
__glibcxx_assert(this->_M_len >= __n);
@@ -216,15 +216,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
this->_M_len -= __n;
}
- void
+ constexpr void
remove_suffix(size_type __n)
{ this->_M_len -= __n; }
- void
+ constexpr void
swap(basic_string_view& __sv) noexcept
{
- std::swap(this->_M_len, __sv._M_len);
- std::swap(this->_M_str, __sv._M_str);
+ auto __tmp = *this;
+ *this = __sv;
+ __sv = __tmp;
}
@@ -261,7 +262,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__pos, this->size()), basic_string_view{});
}
- int
+ constexpr int
compare(basic_string_view __str) const noexcept
{
int __ret = traits_type::compare(this->_M_str, __str._M_str,
@@ -271,24 +272,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __ret;
}
- int
+ constexpr int
compare(size_type __pos1, size_type __n1, basic_string_view __str) const
{ return this->substr(__pos1, __n1).compare(__str); }
- int
+ constexpr int
compare(size_type __pos1, size_type __n1,
basic_string_view __str, size_type __pos2, size_type __n2) const
{ return this->substr(__pos1, __n1).compare(__str.substr(__pos2, __n2)); }
- int
+ constexpr int
compare(const _CharT* __str) const noexcept
{ return this->compare(basic_string_view{__str}); }
- int
+ constexpr int
compare(size_type __pos1, size_type __n1, const _CharT* __str) const
{ return this->substr(__pos1, __n1).compare(basic_string_view{__str}); }
- int
+ constexpr int
compare(size_type __pos1, size_type __n1,
const _CharT* __str, size_type __n2) const
{
@@ -296,97 +297,97 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
.compare(basic_string_view(__str, __n2));
}
- size_type
+ constexpr size_type
find(basic_string_view __str, size_type __pos = 0) const noexcept
{ return this->find(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find(_CharT __c, size_type __pos=0) const noexcept;
- size_type
+ constexpr size_type
find(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
- size_type
+ constexpr size_type
find(const _CharT* __str, size_type __pos=0) const noexcept
{ return this->find(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
rfind(basic_string_view __str, size_type __pos = npos) const noexcept
{ return this->rfind(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
rfind(_CharT __c, size_type __pos = npos) const noexcept;
- size_type
+ constexpr size_type
rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept;
- size_type
+ constexpr size_type
rfind(const _CharT* __str, size_type __pos = npos) const noexcept
{ return this->rfind(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
find_first_of(basic_string_view __str, size_type __pos = 0) const noexcept
{ return this->find_first_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_first_of(_CharT __c, size_type __pos = 0) const noexcept
{ return this->find(__c, __pos); }
- size_type
+ constexpr size_type
find_first_of(const _CharT* __str, size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_first_of(const _CharT* __str, size_type __pos = 0) const noexcept
{ return this->find_first_of(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
find_last_of(basic_string_view __str,
size_type __pos = npos) const noexcept
{ return this->find_last_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_last_of(_CharT __c, size_type __pos=npos) const noexcept
{ return this->rfind(__c, __pos); }
- size_type
+ constexpr size_type
find_last_of(const _CharT* __str, size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_last_of(const _CharT* __str, size_type __pos = npos) const noexcept
{ return this->find_last_of(__str, __pos, traits_type::length(__str)); }
- size_type
+ constexpr size_type
find_first_not_of(basic_string_view __str,
size_type __pos = 0) const noexcept
{ return this->find_first_not_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_first_not_of(_CharT __c, size_type __pos = 0) const noexcept;
- size_type
+ constexpr size_type
find_first_not_of(const _CharT* __str,
size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_first_not_of(const _CharT* __str, size_type __pos = 0) const noexcept
{
return this->find_first_not_of(__str, __pos,
traits_type::length(__str));
}
- size_type
+ constexpr size_type
find_last_not_of(basic_string_view __str,
size_type __pos = npos) const noexcept
{ return this->find_last_not_of(__str._M_str, __pos, __str._M_len); }
- size_type
+ constexpr size_type
find_last_not_of(_CharT __c, size_type __pos = npos) const noexcept;
- size_type
+ constexpr size_type
find_last_not_of(const _CharT* __str,
size_type __pos, size_type __n) const;
- size_type
+ constexpr size_type
find_last_not_of(const _CharT* __str,
size_type __pos = npos) const noexcept
{
@@ -394,7 +395,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
traits_type::length(__str));
}
- size_type
+ constexpr size_type
_M_check(size_type __pos, const char* __s) const
{
if (__pos > this->size())
@@ -405,7 +406,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
// NB: _M_limit doesn't check for a bad __pos value.
- size_type
+ constexpr size_type
_M_limit(size_type __pos, size_type __off) const _GLIBCXX_NOEXCEPT
{
const bool __testoff = __off < this->size() - __pos;
@@ -445,109 +446,109 @@ _GLIBCXX_END_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator==(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator==(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.size() == __y.size() && __x.compare(__y) == 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator!=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator!=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator!=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return !(__x == __y); }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator< (basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator< (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) < 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator> (basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator> (basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator> (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) > 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator<=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator<=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator<=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) <= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator>=(basic_string_view<_CharT, _Traits> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) >= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator>=(basic_string_view<_CharT, _Traits> __x,
__detail::__idt<basic_string_view<_CharT, _Traits>> __y) noexcept
{ return __x.compare(__y) >= 0; }
template<typename _CharT, typename _Traits>
- inline bool
+ constexpr bool
operator>=(__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
basic_string_view<_CharT, _Traits> __y) noexcept
{ return __x.compare(__y) >= 0; }
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index aac7cff6cf6..00552d7e250 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -3043,14 +3043,16 @@ template <typename _Base, typename _Derived>
template <typename _From, typename _To>
inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value;
-#ifdef __has_builtin
-# if !__has_builtin(__has_unique_object_representations)
-// Try not to break non-GNU compilers that don't support the built-in:
-# define _GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP 1
+#if __GNUC__ >= 7
+# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
+#elif defined(__is_identifier)
+// For non-GNU compilers:
+# if ! __is_identifier(__has_unique_object_representations)
+# define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1
# endif
#endif
-#ifndef _GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP
+#ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
# define __cpp_lib_has_unique_object_representations 201606
/// has_unique_object_representations
template<typename _Tp>
@@ -3060,13 +3062,13 @@ template <typename _From, typename _To>
)>
{ };
#endif
-#undef _GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP
+#undef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP
#if __GNUC__ >= 7
# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
-#elif defined __has_builtin
+#elif defined(__is_identifier)
// For non-GNU compilers:
-# if __has_builtin(__is_aggregate)
+# if ! __is_identifier(__is_aggregate)
# define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1
# endif
#endif
diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h
index b66d6d194bc..6e6b21ddbde 100644
--- a/libstdc++-v3/libsupc++/cxxabi.h
+++ b/libstdc++-v3/libsupc++/cxxabi.h
@@ -182,7 +182,7 @@ namespace __cxxabiv1
* with GNU extensions. For example, this function is used in
* __gnu_cxx::__verbose_terminate_handler.
*
- * See http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch39.html
+ * See https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_demangling.html
* for other examples of use.
*
* @note The same demangling functionality is available via
diff --git a/libstdc++-v3/testsuite/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc
index c5258615663..1873deb6936 100644
--- a/libstdc++-v3/testsuite/17_intro/names.cc
+++ b/libstdc++-v3/testsuite/17_intro/names.cc
@@ -107,4 +107,9 @@
#undef y
#endif
+#ifdef __hpux__
+#undef d
+#undef r
+#endif
+
#include <bits/stdc++.h>
diff --git a/libstdc++-v3/testsuite/20_util/duration/cons/dr1177.cc b/libstdc++-v3/testsuite/20_util/duration/cons/dr1177.cc
new file mode 100644
index 00000000000..28c881ccc79
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/duration/cons/dr1177.cc
@@ -0,0 +1,41 @@
+// Copyright (C) 2017 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-do compile { target c++11 } }
+
+#include <chrono>
+#include <type_traits>
+
+using namespace std;
+using namespace std::chrono;
+
+// DR 1177
+static_assert(is_constructible<duration<float>, duration<double>>{},
+ "can convert duration with one floating point rep to another");
+static_assert(is_constructible<duration<float>, duration<int>>{},
+ "can convert duration with integral rep to one with floating point rep");
+static_assert(!is_constructible<duration<int>, duration<float>>{},
+ "cannot convert duration with floating point rep to one with integral rep");
+static_assert(is_constructible<duration<int>, duration<long>>{},
+ "can convert duration with one integral rep to another");
+
+static_assert(!is_constructible<duration<int>, duration<int, ratio<2,3>>>{},
+ "cannot convert duration to one with different period");
+static_assert(is_constructible<duration<float>, duration<int, ratio<2,3>>>{},
+ "unless it has a floating-point representation");
+static_assert(is_constructible<duration<float>, duration<int, ratio<1,3>>>{},
+ "or a period that is an integral multiple of the original");
diff --git a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc b/libstdc++-v3/testsuite/20_util/duration/literals/range.cc
index c0d1a6e5885..531b53c42ec 100644
--- a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc
+++ b/libstdc++-v3/testsuite/20_util/duration/literals/range.cc
@@ -26,6 +26,6 @@ test01()
// std::numeric_limits<int64_t>::max() == 9223372036854775807;
auto h = 9223372036854775808h;
- // { dg-error "cannot be represented" "" { target *-*-* } 892 }
+ // { dg-error "cannot be represented" "" { target *-*-* } 893 }
}
// { dg-prune-output "in constexpr expansion" } // needed for -O0
diff --git a/libstdc++-v3/testsuite/20_util/time_point/cons/81468.cc b/libstdc++-v3/testsuite/20_util/time_point/cons/81468.cc
new file mode 100644
index 00000000000..30d1c4a5ac7
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/time_point/cons/81468.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2017 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-do compile { target c++11 } }
+
+#include <chrono>
+#include <type_traits>
+
+using namespace std;
+using namespace std::chrono;
+
+template <class Duration>
+ using sys_time = time_point<system_clock, Duration>;
+
+static_assert(is_constructible<sys_time<milliseconds>, sys_time<seconds>>{},
+ "Can construct time_point from one with lower precision duration");
+
+// PR libstdc++/81468 - DR 1177
+static_assert(!is_constructible<sys_time<seconds>, sys_time<milliseconds>>{},
+ "Cannot construct time_point from one with higher precision duration");
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/79162.cc b/libstdc++-v3/testsuite/21_strings/basic_string/79162.cc
new file mode 100644
index 00000000000..42a046f9e54
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/79162.cc
@@ -0,0 +1,37 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2017 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/>.
+
+#include <string>
+
+template <class DataType>
+class opt : public DataType
+{
+ opt(const opt &) = delete;
+ opt &operator=(const opt &) = delete;
+public:
+ opt() {}
+};
+
+int main()
+{
+ opt<std::string> PGOTestProfileFile;
+ std::string ProfileFileName;
+ ProfileFileName = PGOTestProfileFile;
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc b/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc
new file mode 100644
index 00000000000..fe1f15553fb
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string/lwg2946.cc
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2017 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/>.
+
+#include <string>
+
+int main()
+{
+ std::string s({"abc", 1});
+ s = {"abc", 1};
+ s += {"abc", 1};
+ s.append({"abc", 1});
+ s.assign({"abc", 1});
+ s.insert(0, {"abc", 1});
+ s.replace(0, 1, {"abc", 1});
+ s.replace(s.begin(), s.begin(), {"abc", 1});
+ s.find({"abc", 1});
+ s.rfind({"abc", 1});
+ s.find_first_of({"abc", 1});
+ s.find_last_of({"abc", 1});
+ s.find_first_not_of({"abc", 1});
+ s.find_last_not_of({"abc", 1});
+ s.compare({"abc", 1});
+ s.compare(0, 1, {"abc", 1});
+}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc
index da5558da91f..2ce3824d260 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc
@@ -33,10 +33,29 @@ test01()
VERIFY( str0 == string_view{"pus mons"} );
}
+constexpr bool
+test02()
+{
+ using std::string_view;
+
+ string_view str0{"olympus mons"};
+ string_view::pointer p = str0.data();
+ str0.remove_prefix(4);
+ if ( str0.data() != p + 4)
+ return false;
+ if ( str0.length() != 8 )
+ return false;
+ if ( str0 != string_view{"pus mons"} )
+ return false;
+
+ return true;
+}
+
int
main()
{
test01();
+ static_assert( test02() );
return 0;
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
index db38ab3c616..5c74837dde5 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc
@@ -33,10 +33,29 @@ test01()
VERIFY( str0 == wstring_view{L"pus mons"} );
}
+constexpr bool
+test02()
+{
+ using std::wstring_view;
+
+ wstring_view str0{L"olympus mons"};
+ wstring_view::pointer p = str0.data();
+ str0.remove_prefix(4);
+ if ( str0.data() != p + 4)
+ return false;
+ if ( str0.length() != 8 )
+ return false;
+ if ( str0 != wstring_view{L"pus mons"} )
+ return false;
+
+ return true;
+}
+
int
main()
{
test01();
+ static_assert( test02() );
return 0;
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc
index 042f9bbce6b..4014fc590e2 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc
@@ -33,10 +33,29 @@ test01()
VERIFY( str0 == string_view{"olympus mo"} );
}
+constexpr bool
+test02()
+{
+ using std::string_view;
+
+ string_view str0{"olympus mons"};
+ string_view::pointer p = str0.data();
+ str0.remove_suffix(2);
+ if ( str0.data() != p)
+ return false;
+ if ( str0.length() != 10 )
+ return false;
+ if ( str0 != string_view{"olympus mo"} )
+ return false;
+
+ return true;
+}
+
int
main()
{
test01();
+ static_assert( test02() );
return 0;
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
index 05c90d8c32a..f0423bc01aa 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc
@@ -33,10 +33,29 @@ test01()
VERIFY( str0 == wstring_view{L"olympus mo"} );
}
+constexpr bool
+test02()
+{
+ using std::wstring_view;
+
+ wstring_view str0{L"olympus mons"};
+ wstring_view::pointer p = str0.data();
+ str0.remove_suffix(2);
+ if ( str0.data() != p)
+ return false;
+ if ( str0.length() != 10 )
+ return false;
+ if ( str0 != wstring_view{L"olympus mo"} )
+ return false;
+
+ return true;
+}
+
int
main()
{
test01();
+ static_assert( test02() );
return 0;
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/swap/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/swap/char/1.cc
new file mode 100644
index 00000000000..0cb4c79861b
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/swap/char/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2017 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 "-std=gnu++17" }
+// { dg-do compile { target c++1z } }
+
+#include <string_view>
+
+constexpr bool
+test01()
+{
+ using std::string_view;
+
+ string_view s1{"last"};
+ string_view s2{"first"};
+
+ s1.swap(s2);
+ return s1 == "first" && s2 == "last";
+}
+
+static_assert( test01() );
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t/1.cc
new file mode 100644
index 00000000000..d8322a8b274
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t/1.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2017 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 "-std=gnu++17" }
+// { dg-do compile { target c++1z } }
+
+#include <string_view>
+
+constexpr bool
+test01()
+{
+ using std::wstring_view;
+
+ wstring_view s1{L"last"};
+ wstring_view s2{L"first"};
+
+ s1.swap(s2);
+ return s1 == L"first" && s2 == L"last";
+}
+
+static_assert( test01() );
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/1.cc
index e4e41f70a47..26e51b88a4e 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/1.cc
@@ -62,9 +62,8 @@ test_value(int result, want_value expected)
VERIFY(pass);
return 0;
}
-
-int
+int
test01()
{
using std::string_view;
@@ -74,7 +73,7 @@ test01()
string_view str_2;
//sanity check
- test_value(strcmp("costa marbella", "costa rica"), lt);
+ test_value(strcmp("costa marbella", "costa rica"), lt);
test_value(strcmp("costa rica", "costa rica"), z);
test_value(strcmp(str_1.data(), str_0.data()), lt);
test_value(strcmp(str_0.data(), str_1.data()), gt);
@@ -100,8 +99,8 @@ test01()
test_value(str_1.compare(0, 4, str_2), z);
test_value(str_1.compare(0, 5, str_2), gt);
- // int compare(size_type pos1, size_type n1, const basic_string_view& str,
- // size_type pos2, size_type n2) const;
+ // int compare(size_type pos1, size_type n1, const basic_string_view& str,
+ // size_type pos2, size_type n2) const;
test_value(str_1.compare(0, 6, str_0, 0, 6), z);
test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
@@ -111,21 +110,21 @@ test01()
test_value(str_1.compare("costa rica"), lt);
str_2 = str_0;
test_value(str_2.compare("costa rica"), z);
- test_value(str_2.compare("cost"), gt);
- test_value(str_2.compare("costa ricans"), lt);
+ test_value(str_2.compare("cost"), gt);
+ test_value(str_2.compare("costa ricans"), lt);
// int compare(size_type pos, size_type n1, const charT* str,
// size_type n2 = npos) const;
- test_value(str_1.compare(0, 6, "costa rica", 0, 6), z);
- test_value(str_1.compare(0, 7, "costa rica", 0, 7), lt);
- test_value(str_0.compare(0, 7, "costa marbella", 0, 7), gt);
+ test_value(str_1.compare(0, 6, "costa rica", 0, 6), z);
+ test_value(str_1.compare(0, 7, "costa rica", 0, 7), lt);
+ test_value(str_0.compare(0, 7, "costa marbella", 0, 7), gt);
return 0;
}
-int
-main()
+int
+main()
{
test01();
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/2.cc
new file mode 100644
index 00000000000..8118b97468b
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/2.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 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 "-std=gnu++17" }
+// { dg-do compile { target c++1z } }
+
+#include <string_view>
+
+constexpr char c1[] = "one";
+constexpr char c2[] = "two";
+
+constexpr std::string_view s1{c1};
+constexpr std::string_view s2{c2};
+
+constexpr int n1 = s1.compare(s1);
+constexpr int n2 = s1.compare(s2);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/70483.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/70483.cc
new file mode 100644
index 00000000000..27b6def1b05
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/70483.cc
@@ -0,0 +1,89 @@
+// Copyright (C) 2017 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 "-std=gnu++17" }
+// { dg-do compile { target c++1z } }
+
+#include <string_view>
+
+struct constexpr_char_traits : std::char_traits<char>
+{
+ static constexpr size_t
+ length(const char* val)
+ {
+ size_t res = 0;
+ for (; val[res] != '\0'; ++res)
+ ;
+ return res;
+ }
+
+ static constexpr int
+ compare(const char* lhs, const char* rhs, std::size_t count)
+ {
+ for (size_t pos = 0; pos < count; ++pos)
+ {
+ if (lhs[pos] != rhs[pos])
+ return lhs[pos] - rhs[pos];
+ }
+ return 0;
+ }
+};
+
+using string_view = std::basic_string_view<char, constexpr_char_traits>;
+
+constexpr
+string_view get()
+{
+ string_view res = "x::";
+ string_view start_pattern = "x";
+ res = res.substr(res.find(start_pattern) + start_pattern.size());
+ res = res.substr(0, res.find_first_of(";]"));
+ res = res.substr(res.rfind("::"));
+ return res;
+}
+
+static_assert( get() == get() );
+
+using std::u16string_view;
+
+constexpr
+u16string_view get16()
+{
+ u16string_view res = u"x::";
+ u16string_view start_pattern = u"x";
+ res = res.substr(res.find(start_pattern) + start_pattern.size());
+ res = res.substr(0, res.find_first_of(u";]"));
+ res = res.substr(res.rfind(u"::"));
+ return res;
+}
+
+static_assert( get16() == get16() );
+
+using std::u32string_view;
+
+constexpr
+u32string_view get32()
+{
+ u32string_view res = U"x::";
+ u32string_view start_pattern = U"x";
+ res = res.substr(res.find(start_pattern) + start_pattern.size());
+ res = res.substr(0, res.find_first_of(U";]"));
+ res = res.substr(res.rfind(U"::"));
+ return res;
+}
+
+static_assert( get32() == get32() );
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/wchar_t/1.cc
index 47b36c6cb01..60f5bcf0e36 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/wchar_t/1.cc
@@ -62,9 +62,9 @@ test_value(int result, want_value expected)
VERIFY(pass);
return 0;
}
-
-int
+
+int
test01()
{
using std::wstring_view;
@@ -74,7 +74,7 @@ test01()
wstring_view str_2;
//sanity check
- test_value(wcscmp(L"costa marbella", L"costa rica"), lt);
+ test_value(wcscmp(L"costa marbella", L"costa rica"), lt);
test_value(wcscmp(L"costa rica", L"costa rica"), z);
test_value(wcscmp(str_1.data(), str_0.data()), lt);
test_value(wcscmp(str_0.data(), str_1.data()), gt);
@@ -100,8 +100,8 @@ test01()
test_value(str_1.compare(0, 4, str_2), z);
test_value(str_1.compare(0, 5, str_2), gt);
- // int compare(size_type pos1, size_type n1, const basic_string_view& str,
- // size_type pos2, size_type n2) const;
+ // int compare(size_type pos1, size_type n1, const basic_string_view& str,
+ // size_type pos2, size_type n2) const;
test_value(str_1.compare(0, 6, str_0, 0, 6), z);
test_value(str_1.compare(0, 7, str_0, 0, 7), lt);
test_value(str_0.compare(0, 7, str_1, 0, 7), gt);
@@ -111,21 +111,21 @@ test01()
test_value(str_1.compare(L"costa rica"), lt);
str_2 = str_0;
test_value(str_2.compare(L"costa rica"), z);
- test_value(str_2.compare(L"cost"), gt);
- test_value(str_2.compare(L"costa ricans"), lt);
+ test_value(str_2.compare(L"cost"), gt);
+ test_value(str_2.compare(L"costa ricans"), lt);
// int compare(size_type pos, size_type n1, const charT* str,
// size_type n2 = npos) const;
- test_value(str_1.compare(0, 6, L"costa rica", 0, 6), z);
- test_value(str_1.compare(0, 7, L"costa rica", 0, 7), lt);
- test_value(str_0.compare(0, 7, L"costa marbella", 0, 7), gt);
+ test_value(str_1.compare(0, 6, L"costa rica", 0, 6), z);
+ test_value(str_1.compare(0, 7, L"costa rica", 0, 7), lt);
+ test_value(str_0.compare(0, 7, L"costa marbella", 0, 7), gt);
return 0;
}
-int
-main()
+int
+main()
{
test01();
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/wchar_t/2.cc
new file mode 100644
index 00000000000..0049ae3ca0c
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/wchar_t/2.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2017 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 "-std=gnu++17" }
+// { dg-do compile { target c++1z } }
+
+#include <string_view>
+
+constexpr wchar_t c1[] = L"one";
+constexpr wchar_t c2[] = L"two";
+
+constexpr std::wstring_view s1{c1};
+constexpr std::wstring_view s2{c2};
+
+constexpr int n1 = s1.compare(s1);
+constexpr int n2 = s1.compare(s2);
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/1.cc
index cc56ddba91e..d00bcdf1459 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/1.cc
@@ -61,10 +61,10 @@ test01()
csz01 = str01.find(str04, 5);
VERIFY( csz01 == 5 );
csz01 = str01.find(str04, str01.size());
- VERIFY( csz01 == str01.size() );
+ VERIFY( csz01 == str01.size() );
csz01 = str01.find(str04, str01.size()+1);
- VERIFY( csz01 == npos );
-
+ VERIFY( csz01 == npos );
+
// size_type find(const char* s, size_type pos, size_type n) const;
csz01 = str01.find(str_lit01, 0, 3);
VERIFY( csz01 == 0 );
@@ -85,10 +85,80 @@ test01()
VERIFY( csz01 == npos );
}
+constexpr bool
+test02()
+{
+ typedef std::string_view::size_type csize_type;
+ typedef std::string_view::const_reference cref;
+ typedef std::string_view::reference ref;
+ csize_type npos = std::string_view::npos;
+ csize_type csz01 = 0, csz02 = 0;
+
+ const char str_lit01[] = "mave";
+ const std::string_view str01("mavericks, santa cruz");
+ std::string_view str02(str_lit01);
+ std::string_view str03("s, s");
+ std::string_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find(const string_view&, size_type pos = 0) const;
+ csz01 = str01.find(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str01, 4);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str02, 3);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 12);
+ VERIFY( csz01 == npos );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ csz01 = str01.find(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str04, 5);
+ VERIFY( csz01 == 5 );
+ csz01 = str01.find(str04, str01.size());
+ VERIFY( csz01 == str01.size() );
+ csz01 = str01.find(str04, str01.size()+1);
+ VERIFY( csz01 == npos );
+
+ // size_type find(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3, 0);
+ VERIFY( csz01 == 3 );
+
+ // size_type find(const char* s, size_type pos = 0) const;
+ csz01 = str01.find(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3);
+ VERIFY( csz01 == npos );
+
+ // size_type find(char c, size_type pos = 0) const;
+ csz01 = str01.find('z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ csz01 = str01.find('/');
+ VERIFY( csz01 == npos );
+
+ return true;
+}
+
+
int
main()
-{
+{
test01();
+ static_assert( test02() );
return 0;
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/2.cc
index 2420cb98073..59fa0766a22 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/2.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/2.cc
@@ -59,13 +59,78 @@ test02()
// An empty string_view consists of no characters
// therefore it should be found at every point in a string_view,
// except beyond the end
- // However, str1.find_first_of(str2,pos) finds the first character in
+ // However, str1.find_first_of(str2,pos) finds the first character in
// str1 (starting at pos) that exists in str2, which is none for empty str2
csz01 = str01.find_first_of(str04, 0);
VERIFY( csz01 == npos );
csz01 = str01.find_first_of(str04, 5);
VERIFY( csz01 == npos );
-
+
+ // size_type find_first_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_of(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_of(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3);
+ VERIFY( csz01 == 3 );
+
+ // size_type find_first_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_of('z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+}
+
+constexpr bool
+test03()
+{
+ typedef std::string_view::size_type csize_type;
+ csize_type npos = std::string_view::npos;
+ csize_type csz01 = 0, csz02 = 0;
+
+ const char str_lit01[] = "mave";
+ const std::string_view str01("mavericks, santa cruz");
+ std::string_view str02(str_lit01);
+ std::string_view str03("s, s");
+ std::string_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find_first_of(const string_view&, size_type pos = 0) const;
+ std::string_view str05("xena rulez");
+ csz01 = str01.find_first_of(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str01, 4);
+ VERIFY( csz01 == 4 );
+ csz01 = str01.find_first_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str02, 3);
+ VERIFY( csz01 == 3 );
+ csz01 = str01.find_first_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 12);
+ VERIFY( csz01 == 16 );
+ csz01 = str01.find_first_of(str05, 0);
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_of(str05, 4);
+ VERIFY( csz01 == 4 );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ // However, str1.find_first_of(str2,pos) finds the first character in
+ // str1 (starting at pos) that exists in str2, which is none for empty str2
+ csz01 = str01.find_first_of(str04, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_of(str04, 5);
+ VERIFY( csz01 == npos );
+
// size_type find_first_of(const char* s, size_type pos, size_type n) const;
csz01 = str01.find_first_of(str_lit01, 0, 3);
VERIFY( csz01 == 0 );
@@ -82,12 +147,15 @@ test02()
csz01 = str01.find_first_of('z');
csz02 = str01.size() - 1;
VERIFY( csz01 == csz02 );
+
+ return true;
}
int
main()
-{
+{
test02();
+ static_assert( test03() );
return 0;
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/3.cc
index 9c9a49123f8..edbe8df1c65 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/3.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/3.cc
@@ -84,10 +84,78 @@ test03()
VERIFY( csz01 == npos );
}
+constexpr bool
+test04()
+{
+ typedef std::string_view::size_type csize_type;
+ csize_type npos = std::string_view::npos;
+ csize_type csz01 = 0;
+
+ const std::string_view str01("Bob Rock, per me");
+ const char str_lit01[] = "Bob Rock";
+ std::string_view str02("ovvero Trivi");
+ std::string_view str03(str_lit01);
+ std::string_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str01);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str02, 10);
+ VERIFY( csz01 == 10 );
+ csz01 = str01.find_first_not_of(str02, 12);
+ VERIFY( csz01 == 14 );
+ csz01 = str01.find_first_not_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str03, 15);
+ VERIFY( csz01 == 15 );
+ csz01 = str01.find_first_not_of(str03, 16);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str04, 12);
+ VERIFY( csz01 == 12 );
+ csz01 = str03.find_first_not_of(str01, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str04.find_first_not_of(str02, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_not_of(str_lit01, 0, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str_lit01, 0, 8);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str_lit01, 10, 0);
+ VERIFY( csz01 == 10 );
+
+ // size_type find_first_not_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str_lit01);
+ VERIFY( csz01 == 8 );
+ csz01 = str02.find_first_not_of(str_lit01, 2);
+ VERIFY( csz01 == 2 );
+
+ // size_type find_first_not_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of('B');
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_not_of('o', 1);
+ VERIFY( csz01 == 2 );
+ csz01 = str02.find_first_not_of('z');
+ VERIFY( csz01 == 0 );
+ csz01 = str04.find_first_not_of('S');
+ VERIFY( csz01 == npos );
+
+ return true;
+}
+
int
main()
-{
+{
test03();
+ static_assert( test04() );
return 0;
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/1.cc
index f0affe23639..401ef6fa9ad 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/1.cc
@@ -61,10 +61,76 @@ test01()
csz01 = str01.find(str04, 5);
VERIFY( csz01 == 5 );
csz01 = str01.find(str04, str01.size());
- VERIFY( csz01 == str01.size() );
+ VERIFY( csz01 == str01.size() );
csz01 = str01.find(str04, str01.size()+1);
- VERIFY( csz01 == npos );
-
+ VERIFY( csz01 == npos );
+
+ // size_type find(const wchar_t* s, size_type pos, size_type n) const;
+ csz01 = str01.find(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3, 0);
+ VERIFY( csz01 == 3 );
+
+ // size_type find(const wchar_t* s, size_type pos = 0) const;
+ csz01 = str01.find(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str_lit01, 3);
+ VERIFY( csz01 == npos );
+
+ // size_type find(wchar_t c, size_type pos = 0) const;
+ csz01 = str01.find(L'z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+ csz01 = str01.find(L'/');
+ VERIFY( csz01 == npos );
+}
+
+constexpr bool
+test02()
+{
+ typedef std::wstring_view::size_type csize_type;
+ typedef std::wstring_view::const_reference cref;
+ typedef std::wstring_view::reference ref;
+ csize_type npos = std::wstring_view::npos;
+ csize_type csz01 = 0, csz02 = 0;
+
+ const wchar_t str_lit01[] = L"mave";
+ const std::wstring_view str01(L"mavericks, santa cruz");
+ std::wstring_view str02(str_lit01);
+ std::wstring_view str03(L"s, s");
+ std::wstring_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find(const wstring_view&, size_type pos = 0) const;
+ csz01 = str01.find(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str01, 4);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str02, 3);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find(str03, 12);
+ VERIFY( csz01 == npos );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ csz01 = str01.find(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find(str04, 5);
+ VERIFY( csz01 == 5 );
+ csz01 = str01.find(str04, str01.size());
+ VERIFY( csz01 == str01.size() );
+ csz01 = str01.find(str04, str01.size()+1);
+ VERIFY( csz01 == npos );
+
// size_type find(const wchar_t* s, size_type pos, size_type n) const;
csz01 = str01.find(str_lit01, 0, 3);
VERIFY( csz01 == 0 );
@@ -83,12 +149,15 @@ test01()
VERIFY( csz01 == csz02 );
csz01 = str01.find(L'/');
VERIFY( csz01 == npos );
+
+ return true;
}
int
main()
-{
+{
test01();
+ static_assert( test02() );
return 0;
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/2.cc
index 13434de844e..a74f72f8767 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/2.cc
@@ -59,13 +59,78 @@ test02()
// An empty string_view consists of no characters
// therefore it should be found at every point in a string_view,
// except beyond the end
- // However, str1.find_first_of(str2,pos) finds the first character in
+ // However, str1.find_first_of(str2,pos) finds the first character in
// str1 (starting at pos) that exists in str2, which is none for empty str2
csz01 = str01.find_first_of(str04, 0);
VERIFY( csz01 == npos );
csz01 = str01.find_first_of(str04, 5);
VERIFY( csz01 == npos );
-
+
+ // size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_of(str_lit01, 0, 3);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_of(const wchar_t* s, size_type pos = 0) const;
+ csz01 = str01.find_first_of(str_lit01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str_lit01, 3);
+ VERIFY( csz01 == 3 );
+
+ // size_type find_first_of(wchar_t c, size_type pos = 0) const;
+ csz01 = str01.find_first_of(L'z');
+ csz02 = str01.size() - 1;
+ VERIFY( csz01 == csz02 );
+}
+
+constexpr bool
+test04()
+{
+ typedef std::wstring_view::size_type csize_type;
+ csize_type npos = std::wstring_view::npos;
+ csize_type csz01 = 0, csz02 = 0;
+
+ const wchar_t str_lit01[] = L"mave";
+ const std::wstring_view str01(L"mavericks, santa cruz");
+ std::wstring_view str02(str_lit01);
+ std::wstring_view str03(L"s, s");
+ std::wstring_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find_first_of(const wstring_view&, size_type pos = 0) const;
+ std::wstring_view str05(L"xena rulez");
+ csz01 = str01.find_first_of(str01);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str01, 4);
+ VERIFY( csz01 == 4 );
+ csz01 = str01.find_first_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_of(str02, 3);
+ VERIFY( csz01 == 3 );
+ csz01 = str01.find_first_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 3);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_of(str03, 12);
+ VERIFY( csz01 == 16 );
+ csz01 = str01.find_first_of(str05, 0);
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_of(str05, 4);
+ VERIFY( csz01 == 4 );
+
+ // An empty string_view consists of no characters
+ // therefore it should be found at every point in a string_view,
+ // except beyond the end
+ // However, str1.find_first_of(str2,pos) finds the first character in
+ // str1 (starting at pos) that exists in str2, which is none for empty str2
+ csz01 = str01.find_first_of(str04, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_of(str04, 5);
+ VERIFY( csz01 == npos );
+
// size_type find_first_of(const wchar_t* s, size_type pos, size_type n) const;
csz01 = str01.find_first_of(str_lit01, 0, 3);
VERIFY( csz01 == 0 );
@@ -82,12 +147,15 @@ test02()
csz01 = str01.find_first_of(L'z');
csz02 = str01.size() - 1;
VERIFY( csz01 == csz02 );
+
+ return true;
}
int
main()
-{
+{
test02();
+ static_assert( test04() );
return 0;
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/3.cc
index 8c2c81b27f2..901c780b108 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/3.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/wchar_t/3.cc
@@ -84,10 +84,78 @@ test03()
VERIFY( csz01 == npos );
}
+constexpr bool
+test04()
+{
+ typedef std::wstring_view::size_type csize_type;
+ csize_type npos = std::wstring_view::npos;
+ csize_type csz01 = 0;
+
+ const std::wstring_view str01(L"Bob Rock, per me");
+ const wchar_t str_lit01[] = L"Bob Rock";
+ std::wstring_view str02(L"ovvero Trivi");
+ std::wstring_view str03(str_lit01);
+ std::wstring_view str04;
+
+#undef VERIFY
+#define VERIFY(x) if(!(x)) return false
+
+ // size_type find_first_not_of(const string_view&, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str01);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str02, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str02, 10);
+ VERIFY( csz01 == 10 );
+ csz01 = str01.find_first_not_of(str02, 12);
+ VERIFY( csz01 == 14 );
+ csz01 = str01.find_first_not_of(str03, 0);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str03, 15);
+ VERIFY( csz01 == 15 );
+ csz01 = str01.find_first_not_of(str03, 16);
+ VERIFY( csz01 == npos );
+ csz01 = str01.find_first_not_of(str04, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str04, 12);
+ VERIFY( csz01 == 12 );
+ csz01 = str03.find_first_not_of(str01, 0);
+ VERIFY( csz01 == npos );
+ csz01 = str04.find_first_not_of(str02, 0);
+ VERIFY( csz01 == npos );
+
+ // size_type find_first_not_of(const char* s, size_type pos, size_type n) const;
+ csz01 = str01.find_first_not_of(str_lit01, 0, 0);
+ VERIFY( csz01 == 0 );
+ csz01 = str01.find_first_not_of(str_lit01, 0, 8);
+ VERIFY( csz01 == 8 );
+ csz01 = str01.find_first_not_of(str_lit01, 10, 0);
+ VERIFY( csz01 == 10 );
+
+ // size_type find_first_not_of(const char* s, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(str_lit01);
+ VERIFY( csz01 == 8 );
+ csz01 = str02.find_first_not_of(str_lit01, 2);
+ VERIFY( csz01 == 2 );
+
+ // size_type find_first_not_of(char c, size_type pos = 0) const;
+ csz01 = str01.find_first_not_of(L'B');
+ VERIFY( csz01 == 1 );
+ csz01 = str01.find_first_not_of(L'o', 1);
+ VERIFY( csz01 == 2 );
+ csz01 = str02.find_first_not_of(L'z');
+ VERIFY( csz01 == 0 );
+ csz01 = str04.find_first_not_of(L'S');
+ VERIFY( csz01 == npos );
+
+ return true;
+}
+
int
main()
-{
+{
test03();
+ static_assert( test04() );
return 0;
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operators/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operators/char/2.cc
index 89130b8363b..93533b38875 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operators/char/2.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operators/char/2.cc
@@ -112,7 +112,7 @@ template<class charT, class traits, class Allocator>
#include <string_view>
#include <testsuite_hooks.h>
-int
+void
test01()
{
std::string_view str_0("costa rica");
@@ -120,7 +120,131 @@ test01()
std::string_view str_2("cost");
std::string_view str_3("costa ricans");
std::string_view str_4;
-
+
+ str_4 = str_0;
+ //comparisons between string objects
+ VERIFY( !(str_0 == str_1) );
+ VERIFY( !(str_0 == str_2) );
+ VERIFY( !(str_0 == str_3) );
+ VERIFY( !(str_1 == str_0) );
+ VERIFY( !(str_2 == str_0) );
+ VERIFY( !(str_3 == str_0) );
+ VERIFY( str_4 == str_0 );
+ VERIFY( str_0 == str_4 );
+
+ VERIFY( str_0 != str_1 );
+ VERIFY( str_0 != str_2 );
+ VERIFY( str_0 != str_3 );
+ VERIFY( str_1 != str_0 );
+ VERIFY( str_2 != str_0 );
+ VERIFY( str_3 != str_0 );
+ VERIFY( !(str_0 != str_4) );
+ VERIFY( !(str_4 != str_0) );
+
+ VERIFY( str_0 > str_1 ); //true cuz r>m
+ VERIFY( str_0 > str_2 );
+ VERIFY( !(str_0 > str_3) );
+ VERIFY( !(str_1 > str_0) ); //false cuz m<r
+ VERIFY( !(str_2 > str_0) );
+ VERIFY( str_3 > str_0 );
+ VERIFY( !(str_0 > str_4) );
+ VERIFY( !(str_4 > str_0) );
+
+ VERIFY( !(str_0 < str_1) ); //false cuz r>m
+ VERIFY( !(str_0 < str_2) );
+ VERIFY( str_0 < str_3 );
+ VERIFY( str_1 < str_0 ); //true cuz m<r
+ VERIFY( str_2 < str_0 );
+ VERIFY( !(str_3 < str_0) );
+ VERIFY( !(str_0 < str_4) );
+ VERIFY( !(str_4 < str_0) );
+
+ VERIFY( str_0 >= str_1 ); //true cuz r>m
+ VERIFY( str_0 >= str_2 );
+ VERIFY( !(str_0 >= str_3) );
+ VERIFY( !(str_1 >= str_0) );//false cuz m<r
+ VERIFY( !(str_2 >= str_0) );
+ VERIFY( str_3 >= str_0 );
+ VERIFY( str_0 >= str_4 );
+ VERIFY( str_4 >= str_0 );
+
+ VERIFY( !(str_0 <= str_1) );//false cuz r>m
+ VERIFY( !(str_0 <= str_2) );
+ VERIFY( str_0 <= str_3 );
+ VERIFY( str_1 <= str_0 );//true cuz m<r
+ VERIFY( str_2 <= str_0 );
+ VERIFY( !(str_3 <= str_0) );
+ VERIFY( str_0 <= str_4 );
+ VERIFY( str_4 <= str_0 );
+
+ //comparisons between string object and string literal
+ VERIFY( !(str_0 == "costa marbella") );
+ VERIFY( !(str_0 == "cost") );
+ VERIFY( !(str_0 == "costa ricans") );
+ VERIFY( !("costa marbella" == str_0) );
+ VERIFY( !("cost" == str_0) );
+ VERIFY( !("costa ricans" == str_0) );
+ VERIFY( "costa rica" == str_0 );
+ VERIFY( str_0 == "costa rica" );
+
+ VERIFY( str_0 != "costa marbella" );
+ VERIFY( str_0 != "cost" );
+ VERIFY( str_0 != "costa ricans" );
+ VERIFY( "costa marbella" != str_0 );
+ VERIFY( "cost" != str_0 );
+ VERIFY( "costa ricans" != str_0 );
+ VERIFY( !("costa rica" != str_0) );
+ VERIFY( !(str_0 != "costa rica") );
+
+ VERIFY( str_0 > "costa marbella" ); //true cuz r>m
+ VERIFY( str_0 > "cost" );
+ VERIFY( !(str_0 > "costa ricans") );
+ VERIFY( !("costa marbella" > str_0) );//false cuz m<r
+ VERIFY( !("cost" > str_0) );
+ VERIFY( "costa ricans" > str_0 );
+ VERIFY( !("costa rica" > str_0) );
+ VERIFY( !(str_0 > "costa rica") );
+
+ VERIFY( !(str_0 < "costa marbella") );//false cuz r>m
+ VERIFY( !(str_0 < "cost") );
+ VERIFY( str_0 < "costa ricans" );
+ VERIFY( "costa marbella" < str_0 );//true cuz m<r
+ VERIFY( "cost" < str_0 );
+ VERIFY( !("costa ricans" < str_0) );
+ VERIFY( !("costa rica" < str_0) );
+ VERIFY( !(str_0 < "costa rica") );
+
+ VERIFY( str_0 >= "costa marbella" );//true cuz r>m
+ VERIFY( str_0 >= "cost" );
+ VERIFY( !(str_0 >= "costa ricans") );
+ VERIFY( !("costa marbella" >= str_0) );//false cuz m<r
+ VERIFY( !("cost" >= str_0) );
+ VERIFY( "costa ricans" >= str_0 );
+ VERIFY( "costa rica" >= str_0 );
+ VERIFY( str_0 >= "costa rica" );
+
+ VERIFY( !(str_0 <= "costa marbella") );//false cuz r>m
+ VERIFY( !(str_0 <= "cost") );
+ VERIFY( str_0 <= "costa ricans" );
+ VERIFY( "costa marbella" <= str_0 );//true cuz m<r
+ VERIFY( "cost" <= str_0 );
+ VERIFY( !("costa ricans" <= str_0) );
+ VERIFY( "costa rica" <= str_0 );
+ VERIFY( str_0 <= "costa rica" );
+}
+
+constexpr bool
+test02()
+{
+ std::string_view str_0("costa rica");
+ std::string_view str_1("costa marbella");
+ std::string_view str_2("cost");
+ std::string_view str_3("costa ricans");
+ std::string_view str_4;
+
+#undef VERIFY
+#define VERIFY(x) if (!(x)) return false
+
str_4 = str_0;
//comparisons between string objects
VERIFY( !(str_0 == str_1) );
@@ -140,7 +264,7 @@ test01()
VERIFY( str_3 != str_0 );
VERIFY( !(str_0 != str_4) );
VERIFY( !(str_4 != str_0) );
-
+
VERIFY( str_0 > str_1 ); //true cuz r>m
VERIFY( str_0 > str_2 );
VERIFY( !(str_0 > str_3) );
@@ -232,13 +356,12 @@ test01()
VERIFY( "costa rica" <= str_0 );
VERIFY( str_0 <= "costa rica" );
- return 0;
+ return true;
}
int
-main()
+main()
{
test01();
-
- return 0;
+ static_assert( test02() );
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operators/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operators/wchar_t/2.cc
index dce819469cd..916dce9c9ad 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operators/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operators/wchar_t/2.cc
@@ -45,7 +45,7 @@ template<class charT, class traits, class Allocator>
const basic_string_view<charT,traits,Allocator>& rhs);
template<class charT, class traits, class Allocator>
- bool operator!=(const basic_string_view<charT,traits,Allocator>& lhs,
+ bool operator!=(const basic_string_view<charT,traits,Allocator>& lhs,
const charT* rhs);
*/
@@ -60,7 +60,7 @@ template<class charT, class traits, class Allocator>
const charT* rhs);
template<class charT, class traits, class Allocator>
- bool operator< (const charT* lhs,
+ bool operator< (const charT* lhs,
const basic_string_view<charT,traits,Allocator>& rhs);
*/
@@ -112,7 +112,7 @@ template<class charT, class traits, class Allocator>
#include <string_view>
#include <testsuite_hooks.h>
-int
+void
test01()
{
std::wstring_view str_0(L"costa rica");
@@ -120,7 +120,7 @@ test01()
std::wstring_view str_2(L"cost");
std::wstring_view str_3(L"costa ricans");
std::wstring_view str_4;
-
+
str_4 = str_0;
//comparisons between string_view objects
VERIFY( !(str_0 == str_1) );
@@ -140,7 +140,7 @@ test01()
VERIFY( str_3 != str_0 );
VERIFY( !(str_0 != str_4) );
VERIFY( !(str_4 != str_0) );
-
+
VERIFY( str_0 > str_1 ); //true cuz r>m
VERIFY( str_0 > str_2 );
VERIFY( !(str_0 > str_3) );
@@ -231,14 +231,137 @@ test01()
VERIFY( !(L"costa ricans" <= str_0) );
VERIFY( L"costa rica" <= str_0 );
VERIFY( str_0 <= L"costa rica" );
+}
+
+constexpr bool
+test02()
+{
+ std::wstring_view str_0(L"costa rica");
+ std::wstring_view str_1(L"costa marbella");
+ std::wstring_view str_2(L"cost");
+ std::wstring_view str_3(L"costa ricans");
+ std::wstring_view str_4;
+
+#undef VERIFY
+#define VERIFY(x) if (!(x)) return false
+
+ str_4 = str_0;
+ //comparisons between string_view objects
+ VERIFY( !(str_0 == str_1) );
+ VERIFY( !(str_0 == str_2) );
+ VERIFY( !(str_0 == str_3) );
+ VERIFY( !(str_1 == str_0) );
+ VERIFY( !(str_2 == str_0) );
+ VERIFY( !(str_3 == str_0) );
+ VERIFY( str_4 == str_0 );
+ VERIFY( str_0 == str_4 );
- return 0;
+ VERIFY( str_0 != str_1 );
+ VERIFY( str_0 != str_2 );
+ VERIFY( str_0 != str_3 );
+ VERIFY( str_1 != str_0 );
+ VERIFY( str_2 != str_0 );
+ VERIFY( str_3 != str_0 );
+ VERIFY( !(str_0 != str_4) );
+ VERIFY( !(str_4 != str_0) );
+
+ VERIFY( str_0 > str_1 ); //true cuz r>m
+ VERIFY( str_0 > str_2 );
+ VERIFY( !(str_0 > str_3) );
+ VERIFY( !(str_1 > str_0) ); //false cuz m<r
+ VERIFY( !(str_2 > str_0) );
+ VERIFY( str_3 > str_0 );
+ VERIFY( !(str_0 > str_4) );
+ VERIFY( !(str_4 > str_0) );
+
+ VERIFY( !(str_0 < str_1) ); //false cuz r>m
+ VERIFY( !(str_0 < str_2) );
+ VERIFY( str_0 < str_3 );
+ VERIFY( str_1 < str_0 ); //true cuz m<r
+ VERIFY( str_2 < str_0 );
+ VERIFY( !(str_3 < str_0) );
+ VERIFY( !(str_0 < str_4) );
+ VERIFY( !(str_4 < str_0) );
+
+ VERIFY( str_0 >= str_1 ); //true cuz r>m
+ VERIFY( str_0 >= str_2 );
+ VERIFY( !(str_0 >= str_3) );
+ VERIFY( !(str_1 >= str_0) );//false cuz m<r
+ VERIFY( !(str_2 >= str_0) );
+ VERIFY( str_3 >= str_0 );
+ VERIFY( str_0 >= str_4 );
+ VERIFY( str_4 >= str_0 );
+
+ VERIFY( !(str_0 <= str_1) );//false cuz r>m
+ VERIFY( !(str_0 <= str_2) );
+ VERIFY( str_0 <= str_3 );
+ VERIFY( str_1 <= str_0 );//true cuz m<r
+ VERIFY( str_2 <= str_0 );
+ VERIFY( !(str_3 <= str_0) );
+ VERIFY( str_0 <= str_4 );
+ VERIFY( str_4 <= str_0 );
+
+ //comparisons between string_view object and string_view literal
+ VERIFY( !(str_0 == L"costa marbella") );
+ VERIFY( !(str_0 == L"cost") );
+ VERIFY( !(str_0 == L"costa ricans") );
+ VERIFY( !(L"costa marbella" == str_0) );
+ VERIFY( !(L"cost" == str_0) );
+ VERIFY( !(L"costa ricans" == str_0) );
+ VERIFY( L"costa rica" == str_0 );
+ VERIFY( str_0 == L"costa rica" );
+
+ VERIFY( str_0 != L"costa marbella" );
+ VERIFY( str_0 != L"cost" );
+ VERIFY( str_0 != L"costa ricans" );
+ VERIFY( L"costa marbella" != str_0 );
+ VERIFY( L"cost" != str_0 );
+ VERIFY( L"costa ricans" != str_0 );
+ VERIFY( !(L"costa rica" != str_0) );
+ VERIFY( !(str_0 != L"costa rica") );
+
+ VERIFY( str_0 > L"costa marbella" ); //true cuz r>m
+ VERIFY( str_0 > L"cost" );
+ VERIFY( !(str_0 > L"costa ricans") );
+ VERIFY( !(L"costa marbella" > str_0) );//false cuz m<r
+ VERIFY( !(L"cost" > str_0) );
+ VERIFY( L"costa ricans" > str_0 );
+ VERIFY( !(L"costa rica" > str_0) );
+ VERIFY( !(str_0 > L"costa rica") );
+
+ VERIFY( !(str_0 < L"costa marbella") );//false cuz r>m
+ VERIFY( !(str_0 < L"cost") );
+ VERIFY( str_0 < L"costa ricans" );
+ VERIFY( L"costa marbella" < str_0 );//true cuz m<r
+ VERIFY( L"cost" < str_0 );
+ VERIFY( !(L"costa ricans" < str_0) );
+ VERIFY( !(L"costa rica" < str_0) );
+ VERIFY( !(str_0 < L"costa rica") );
+
+ VERIFY( str_0 >= L"costa marbella" );//true cuz r>m
+ VERIFY( str_0 >= L"cost" );
+ VERIFY( !(str_0 >= L"costa ricans") );
+ VERIFY( !(L"costa marbella" >= str_0) );//false cuz m<r
+ VERIFY( !(L"cost" >= str_0) );
+ VERIFY( L"costa ricans" >= str_0 );
+ VERIFY( L"costa rica" >= str_0 );
+ VERIFY( str_0 >= L"costa rica" );
+
+ VERIFY( !(str_0 <= L"costa marbella") );//false cuz r>m
+ VERIFY( !(str_0 <= L"cost") );
+ VERIFY( str_0 <= L"costa ricans" );
+ VERIFY( L"costa marbella" <= str_0 );//true cuz m<r
+ VERIFY( L"cost" <= str_0 );
+ VERIFY( !(L"costa ricans" <= str_0) );
+ VERIFY( L"costa rica" <= str_0 );
+ VERIFY( str_0 <= L"costa rica" );
+
+ return true;
}
int
-main()
+main()
{
test01();
-
- return 0;
+ static_assert( test02() );
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/char/1.cc
index e46d7eda2ba..5b65aa79dec 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/char/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/char/1.cc
@@ -18,7 +18,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 24.6.5, range access [iterator.range]
+// C++17 27.7, range access [iterator.range]
#include <string_view>
@@ -28,4 +28,20 @@ test01()
std::string_view s("Hello, World!");
std::begin(s);
std::end(s);
+ std::rbegin(s);
+ std::rend(s);
+}
+
+void
+test02()
+{
+ constexpr std::string_view s("Hello, World!");
+ [[maybe_unused]] constexpr auto b = std::begin(s);
+ [[maybe_unused]] constexpr auto e = std::end(s);
+ [[maybe_unused]] constexpr auto cb = std::cbegin(s);
+ [[maybe_unused]] constexpr auto ce = std::cend(s);
+ [[maybe_unused]] constexpr auto rb = std::rbegin(s);
+ [[maybe_unused]] constexpr auto re = std::rend(s);
+ [[maybe_unused]] constexpr auto crb = std::crbegin(s);
+ [[maybe_unused]] constexpr auto cre = std::crend(s);
}
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc
index 9c0370c20b7..84086615bb0 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc
@@ -18,16 +18,30 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 24.6.5, range access [iterator.range]
+// C++17 27.7, range access [iterator.range]
#include <string_view>
void
test01()
{
-#ifdef _GLIBCXX_USE_WCHAR_T
std::wstring_view ws(L"Hello, World!");
std::begin(ws);
std::end(ws);
-#endif
+ std::rbegin(ws);
+ std::rend(ws);
+}
+
+void
+test02()
+{
+ constexpr std::wstring_view ws(L"Hello, World!");
+ [[maybe_unused]] constexpr auto b = std::begin(ws);
+ [[maybe_unused]] constexpr auto e = std::end(ws);
+ [[maybe_unused]] constexpr auto cb = std::cbegin(ws);
+ [[maybe_unused]] constexpr auto ce = std::cend(ws);
+ [[maybe_unused]] constexpr auto rb = std::rbegin(ws);
+ [[maybe_unused]] constexpr auto re = std::rend(ws);
+ [[maybe_unused]] constexpr auto crb = std::crbegin(ws);
+ [[maybe_unused]] constexpr auto cre = std::crend(ws);
}
diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc
index 014caa02313..efd280fea23 100644
--- a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc
+++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc
@@ -74,20 +74,20 @@ template<typename CT>
}
#ifndef __cpp_lib_constexpr_char_traits
-// #error Feature-test macro for constexpr char_traits is missing
+# error Feature-test macro for constexpr char_traits is missing
#elif __cpp_lib_constexpr_char_traits != 201611
-// #error Feature-test macro for constexpr char_traits has the wrong value
+# error Feature-test macro for constexpr char_traits has the wrong value
#endif
static_assert( test_assign<std::char_traits<char>>() );
-// static_assert( test_compare<std::char_traits<char>>() );
-// static_assert( test_length<std::char_traits<char>>() );
-// static_assert( test_find<std::char_traits<char>>() );
+static_assert( test_compare<std::char_traits<char>>() );
+static_assert( test_length<std::char_traits<char>>() );
+static_assert( test_find<std::char_traits<char>>() );
#ifdef _GLIBCXX_USE_WCHAR_T
static_assert( test_assign<std::char_traits<wchar_t>>() );
-// static_assert( test_compare<std::char_traits<wchar_t>>() );
-// static_assert( test_length<std::char_traits<wchar_t>>() );
-// static_assert( test_find<std::char_traits<wchar_t>>() );
+static_assert( test_compare<std::char_traits<wchar_t>>() );
+static_assert( test_length<std::char_traits<wchar_t>>() );
+static_assert( test_find<std::char_traits<wchar_t>>() );
#endif
static_assert( test_assign<std::char_traits<char16_t>>() );
static_assert( test_compare<std::char_traits<char16_t>>() );
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/cons/81891.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/cons/81891.cc
new file mode 100644
index 00000000000..61807c0efd2
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/cons/81891.cc
@@ -0,0 +1,68 @@
+// Copyright (C) 2017 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-do run { target c++11 } }
+
+#include <unordered_map>
+#include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
+
+struct fails_on_copy {
+ fails_on_copy() = default;
+ fails_on_copy(const fails_on_copy&) { throw 0; };
+};
+
+using value_type = std::pair<int, fails_on_copy>;
+
+void
+test01()
+{
+ value_type p;
+ try
+ {
+ std::unordered_map<int, fails_on_copy> umap(&p, &p + 1);
+ }
+ catch(...)
+ { }
+}
+
+void
+test02()
+{
+ using Alloc = __gnu_test::tracker_allocator<value_type>;
+ using std::hash;
+ using std::equal_to;
+
+ value_type p;
+ try
+ {
+ std::unordered_map<int, fails_on_copy, hash<int>, equal_to<int>, Alloc>
+ umap(&p, &p + 1);
+ }
+ catch(...)
+ { }
+
+ using counter = __gnu_test::tracker_allocator_counter;
+ VERIFY(counter::get_allocation_count() == counter::get_deallocation_count());
+}
+
+int
+main()
+{
+ test01();
+ test02();
+}
diff --git a/libstdc++-v3/testsuite/24_iterators/container_access.cc b/libstdc++-v3/testsuite/24_iterators/container_access.cc
index 42ecb410372..e9a32c790df 100644
--- a/libstdc++-v3/testsuite/24_iterators/container_access.cc
+++ b/libstdc++-v3/testsuite/24_iterators/container_access.cc
@@ -1,4 +1,4 @@
-// { dg-do run }
+// { dg-do run { target c++1z } }
// { dg-options "-std=gnu++17" }
// Copyright (C) 2015-2017 Free Software Foundation, Inc.
@@ -62,7 +62,6 @@ test03()
static_assert(s == 3);
constexpr auto e = std::empty(il3);
static_assert(!e);
-
}
void
diff --git a/libstdc++-v3/testsuite/24_iterators/range_access.cc b/libstdc++-v3/testsuite/24_iterators/range_access.cc
index 6ae5499b0d8..5b978b630e1 100644
--- a/libstdc++-v3/testsuite/24_iterators/range_access.cc
+++ b/libstdc++-v3/testsuite/24_iterators/range_access.cc
@@ -17,7 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 24.6.5, range access [iterator.range]
+// C++ 2011 24.6.5, range access [iterator.range]
#include <iterator>
diff --git a/libstdc++-v3/testsuite/24_iterators/range_access_cpp14.cc b/libstdc++-v3/testsuite/24_iterators/range_access_cpp14.cc
index 138b189aaa6..eb75d92a463 100644
--- a/libstdc++-v3/testsuite/24_iterators/range_access_cpp14.cc
+++ b/libstdc++-v3/testsuite/24_iterators/range_access_cpp14.cc
@@ -17,7 +17,7 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// 24.6.5, range access [iterator.range]
+// C++ 2014 24.7, range access [iterator.range]
#include <iterator>
#include <vector>
diff --git a/libstdc++-v3/testsuite/24_iterators/range_access_cpp17.cc b/libstdc++-v3/testsuite/24_iterators/range_access_cpp17.cc
new file mode 100644
index 00000000000..1d5b0739007
--- /dev/null
+++ b/libstdc++-v3/testsuite/24_iterators/range_access_cpp17.cc
@@ -0,0 +1,57 @@
+// { dg-do compile { target c++1z } }
+// { dg-options "-std=gnu++17" }
+
+// Copyright (C) 2017 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/>.
+
+// C++ 2017 27.7, range access [iterator.range]
+
+#include <iterator>
+
+void
+test01()
+{
+ using std::reverse_iterator;
+ static int i[1];
+ static_assert(std::cbegin(i) == i);
+ static_assert(std::cend(i) == i+1);
+ static_assert(std::rbegin(i) == reverse_iterator<int*>(i+1));
+ static_assert(std::rend(i) == reverse_iterator<int*>(i));
+ static_assert(std::crbegin(i) == reverse_iterator<int*>(i+1));
+ static_assert(std::crend(i) == reverse_iterator<int*>(i));
+}
+
+void
+test02()
+{
+ static int i[] = { 1, 2 };
+ static_assert(std::distance(std::begin(i), std::end(i)) == 2);
+ static_assert(std::distance(std::cbegin(i), std::cend(i)) == 2);
+}
+
+void
+test03()
+{
+ using std::reverse_iterator;
+ static std::initializer_list<int> il{1};
+ static_assert(std::cbegin(il) == il.begin());
+ static_assert(std::cend(il) == il.end());
+ static_assert(std::rbegin(il) == reverse_iterator<const int*>(il.end()));
+ static_assert(std::rend(il) == reverse_iterator<const int*>(il.begin()));
+ static_assert(std::crbegin(il) == reverse_iterator<const int*>(il.end()));
+ static_assert(std::crend(il) == reverse_iterator<const int*>(il.begin()));
+}
diff --git a/libstdc++-v3/testsuite/27_io/basic_stringstream/assign/81338.cc b/libstdc++-v3/testsuite/27_io/basic_stringstream/assign/81338.cc
new file mode 100644
index 00000000000..30370c0dd42
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_stringstream/assign/81338.cc
@@ -0,0 +1,40 @@
+// Copyright (C) 2017 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-do run { target c++11 } }
+
+#include <sstream>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ std::stringstream ss;
+ for (int i = 0; i < 100; ++i)
+ {
+ ss << 'a';
+ VERIFY( static_cast<bool>(ss) );
+ VERIFY( ss.str() == "a" );
+ ss = std::stringstream();
+ }
+}
+
+int
+main()
+{
+ test01();
+}
diff --git a/libstdc++-v3/testsuite/experimental/string_view/operations/compare/char/70483.cc b/libstdc++-v3/testsuite/experimental/string_view/operations/compare/char/70483.cc
new file mode 100644
index 00000000000..3bfb59c046b
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/string_view/operations/compare/char/70483.cc
@@ -0,0 +1,68 @@
+// Copyright (C) 2017 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-do compile { target c++14 } }
+
+#include <experimental/string_view>
+
+struct constexpr_char_traits : std::char_traits<char>
+{
+ static constexpr size_t
+ length(const char* val)
+ {
+ size_t res = 0;
+ for (; val[res] != '\0'; ++res)
+ ;
+ return res;
+ }
+
+ static constexpr int
+ compare(const char* lhs, const char* rhs, std::size_t count)
+ {
+ for (size_t pos = 0; pos < count; ++pos)
+ {
+ if (lhs[pos] != rhs[pos])
+ return lhs[pos] - rhs[pos];
+ }
+ return 0;
+ }
+
+ static constexpr const char*
+ find(const char* p, std::size_t n, char c)
+ {
+ for (size_t pos = 0; pos < n; ++pos)
+ if (p[pos] == c)
+ return p + pos;
+ return nullptr;
+ }
+};
+
+using string_view
+ = std::experimental::basic_string_view<char, constexpr_char_traits>;
+
+constexpr
+string_view get()
+{
+ string_view res = "x::";
+ string_view start_pattern = "x";
+ res = res.substr(res.find(start_pattern) + start_pattern.size());
+ res = res.substr(0, res.find_first_of(";]"));
+ res = res.substr(res.rfind("::"));
+ return res;
+}
+
+static_assert( get() == get() );