diff options
author | Mark Murray <mark.murray@linaro.org> | 2017-10-12 11:44:14 +0100 |
---|---|---|
committer | Mark Murray <mark.murray@arm.com> | 2017-10-12 11:48:16 +0100 |
commit | 50008c2963ce0b77acda184feaf3df841ef9ba33 (patch) | |
tree | 7d6e95fe45613b1a8adcd5b4af78ad55534e6f5d | |
parent | d273604ec799881da2a3875572a70ca0ff584399 (diff) | |
download | gcc-50008c2963ce0b77acda184feaf3df841ef9ba33.tar.gz |
Merge branches/gcc-6-branch rev 253668
Change-Id: I02945f1bb64c8600fc82e0ddc3230ebcad1354eb
98 files changed, 1882 insertions, 289 deletions
diff --git a/contrib/ChangeLog b/contrib/ChangeLog index 552c05c366f..2ca2cddb038 100644 --- a/contrib/ChangeLog +++ b/contrib/ChangeLog @@ -1,3 +1,7 @@ +2017-10-02 Thomas Schwinge <thomas@codesourcery.com> + + * gcc_update (files_and_dependencies): Handle libbacktrace. + 2017-07-04 Release Manager * GCC 6.4.0 released. diff --git a/contrib/gcc_update b/contrib/gcc_update index 2df9da407ef..29329d58075 100755 --- a/contrib/gcc_update +++ b/contrib/gcc_update @@ -173,6 +173,10 @@ liboffloadmic/configure: liboffloadmic/configure.ac liboffloadmic/plugin/aclocal.m4: liboffloadmic/plugin/configure.ac liboffloadmic/plugin/Makefile.in: liboffloadmic/plugin/Makefile.am liboffloadmic/plugin/configure: liboffloadmic/plugin/configure.ac +libbacktrace/aclocal.m4: libbacktrace/configure.ac +libbacktrace/Makefile.in: libbacktrace/Makefile.am libbacktrace/aclocal.m4 +libbacktrace/configure: libbacktrace/configure.ac libbacktrace/aclocal.m4 +libbacktrace/config.h.in: libbacktrace/configure.ac libbacktrace/aclocal.m4 # Top level Makefile.in: Makefile.tpl Makefile.def configure: configure.ac config/acx.m4 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8bbe115c0b3..f67bef557bd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,231 @@ +2017-10-10 Andreas Tobler <andreast@gcc.gnu.org> + + * config.gcc: (armv7*-*-freebsd*): New target. + Define TARGET_FREEBSD_ARMv7 + * config/arm/freebsd.h: Use TARGET_FREEBSD_ARMv7 to define the + default cpu for armv7*-*-freebsd*. + +2017-10-02 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2017-09-30 Jakub Jelinek <jakub@redhat.com> + + * config/i386/i386.c (ix86_split_idivmod): Use mode instead of + always SImode for DIV and MOD in REG_EQUAL notes. + +2017-10-02 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + Backport from mainline + 2017-09-29 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + PR tree-optimization/82337 + * gimple-ssa-strength-reduction.c (find_phi_def): Don't record a + phi definition if the PHI result appears in an abnormal PHI. + (find_basis_for_base_expr): Don't record a basis if the LHS of the + basis appears in an abnormal PHI. + +2017-09-21 Alan Modra <amodra@gmail.com> + + PR target/81996 + * gcc/config/rs6000/rs6000.c (rs6000_return_addr): Use + stack_pointer_rtx for count 0. Update comments. Break up + large rtl expression. + +2017-09-21 Wilco Dijkstra <wdijkstr@arm.com> + + PR target/71951 + * config/aarch64/aarch64.h (LIBGCC2_UNWIND_ATTRIBUTE): Define. + +2017-09-19 Uros Bizjak <ubizjak@gmail.com> + + * config/i386/i386.c (fold_builtin_cpu): Add M_AMDFAM17H + to processor_model and "amdfam17h" to arch_names_table. + * doc/extend.texi (__builtin_cpu_is): Document amdfam17h CPU name. + +2017-09-19 Martin Liska <mliska@suse.cz> + + PR c++/81355 + * config/i386/i386.c (sorted_attr_string): Skip empty strings. + +2017-09-19 Martin Liska <mliska@suse.cz> + + Revert backport: + 2017-08-10 Martin Liska <mliska@suse.cz> + + PR c++/81355 + * c-attribs.c (handle_target_attribute): + Report warning for an empty string argument of target attribute. + +2017-09-18 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-09-04 Richard Biener <rguenther@suse.de> + + PR tree-optimization/82084 + * fold-const.h (can_native_encode_string_p): Declare. + * fold-const.c (can_native_encode_string_p): Factor out from ... + (native_encode_string): ... here. + * tree-vect-stmts.c (vectorizable_store): Call it to avoid + vectorizing stores from constants we later cannot handle. + + 2017-07-25 Richard Biener <rguenther@suse.de> + + PR middle-end/81505 + * fold-const.c (fold_negate_const): TREE_OVERFLOW should be + sticky. + +2017-09-15 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-low.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-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-08 Richard Biener <rguenther@suse.de> + + PR middle-end/81766 + * function.c (thread_prologue_and_epilogue_insns): Restore + behavior of always calling find_many_sub_basic_blocks on + the inserted prologue. + + 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 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-08-02 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/79499 + * function.c (thread_prologue_and_epilogue_insns): Determine blocks + for find_many_sub_basic_blocks bitmap by looking up BLOCK_FOR_INSN + of first NONDEBUG_INSN_P in each of the split_prologue_seq and + prologue_seq sequences - if any. + + 2017-06-30 Jakub Jelinek <jakub@redhat.com> + + PR target/81225 + * config/i386/sse.md (vec_extract_lo_<mode><mask_name>): For + V8FI, V16FI and VI8F_256 iterators, use <store_mask_predicate> instead + of nonimmediate_operand and <store_mask_constraint> instead of m for + the input operand. For V8FI iterator, always split if input is a MEM. + For V16FI and V8SF_256 iterators, don't test if both operands are MEM + if <mask_applied>. For VI4F_256 iterator, use <store_mask_predicate> + instead of register_operand and <store_mask_constraint> instead of v for + the input operand. Make sure both operands aren't MEMs for if not + <mask_applied>. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-11 Martin Liska <mliska@suse.cz> + + PR tree-opt/79987 + * tree-chkp.c (chkp_get_bounds_for_decl_addr): Do not instrument + variables of void type. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-06-28 Martin Liska <mliska@suse.cz> + + PR sanitizer/81224 + * asan.c (instrument_derefs): Bail out inner references + that are hard register variables. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-30 Martin Liska <mliska@suse.cz> + + PR inline-asm/82001 + * ipa-icf-gimple.c (func_checker::compare_tree_list_operand): + Rename to ... + (func_checker::compare_asm_inputs_outputs): ... this function. + (func_checker::compare_gimple_asm): Use the function to compare + also ASM constrains. + * ipa-icf-gimple.h: Rename the function. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-29 Martin Liska <mliska@suse.cz> + + PR other/39851 + * gcc.c (driver_handle_option): Add new argument. + * opts-common.c (handle_option): Pass + target_option_override_hook. + * opts-global.c (lang_handle_option): Add new option. + (set_default_handlers): Add new argument. + (decode_options): Likewise. + * opts.c (target_handle_option): Likewise. + (common_handle_option): Call target_option_override_hook. + * opts.h (struct cl_option_handler_func): Add hook for + target option override. + (struct cl_option_handlers): Likewise. + (set_default_handlers): Add new argument. + (decode_options): Likewise. + (common_handle_option): Likewise. + (target_handle_option): Likewise. + * toplev.c (toplev::main): Pass targetm.target_option.override + hook. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-10 Martin Liska <mliska@suse.cz> + + PR c++/81355 + * c-attribs.c (handle_target_attribute): + Report warning for an empty string argument of target attribute. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-08 Martin Liska <mliska@suse.cz> + + PR tree-opt/81696 + * ipa-icf-gimple.c (func_checker::compare_cst_or_decl): Consider + LABEL_DECLs that can be from a different function. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-06-28 Martin Liska <mliska@suse.cz> + + PR ipa/81128 + * ipa-visibility.c (non_local_p): Handle visibility. + 2017-09-12 Bill Schmidt <wschmidt@linux.vnet.ibm.com> Backport from mainline diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 8afc9469ac6..b7ba2da6873 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20170913 +20171012 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 7b79356b1f8..e41237114c1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-29 Martin Liska <mliska@suse.cz> + + PR other/39851 + * gcc-interface/trans.c (Pragma_to_gnu): Set argument to NULL. + 2017-09-05 Eric Botcazou <ebotcazou@adacore.com> * gcc-interface/utils.c (unchecked_convert): When the result type is a diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 592d005ad89..8a4924c9f28 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -1469,7 +1469,7 @@ Pragma_to_gnu (Node_Id gnat_node) else option_index = 0; - set_default_handlers (&handlers); + set_default_handlers (&handlers, NULL); control_warning_option (option_index, (int) kind, arg, imply, location, lang_mask, &handlers, &global_options, &global_options_set, global_dc); diff --git a/gcc/asan.c b/gcc/asan.c index 9b35104dd43..b80df24acfd 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -1800,6 +1800,9 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, || bitsize != size_in_bytes * BITS_PER_UNIT) return; + if (TREE_CODE (inner) == VAR_DECL && DECL_HARD_REGISTER (inner)) + return; + if (TREE_CODE (inner) == VAR_DECL && offset == NULL_TREE && bitpos >= 0 diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c index 5fb60bde762..4eb68930bec 100644 --- a/gcc/bb-reorder.c +++ b/gcc/bb-reorder.c @@ -2905,7 +2905,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; @@ -2971,7 +2972,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 4025a03680c..8abb86aa56b 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,41 @@ +2017-09-15 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2017-09-12 Jakub Jelinek <jakub@redhat.com> + + PR target/82112 + * c-common.c (sync_resolve_size): Instead of c_dialect_cxx () + assertion check that in the condition. + (get_atomic_generic_size): Likewise. Before testing if parameter + has pointer type, if it has array type, call for C++ + default_conversion to perform array-to-pointer conversion. + + 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-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-29 Martin Liska <mliska@suse.cz> + + PR other/39851 + * c-common.c (parse_optimize_options): Add argument to function + call. + * c-pragma.c (handle_pragma_diagnostic): Likewise. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-06-28 Martin Liska <mliska@suse.cz> + + PR ipa/81128 + * c-attribs.c (handle_alias_ifunc_attribute): Append ifunc alias + to a function declaration. + 2017-09-10 Jonathan Wakely <jwakely@redhat.com> PR c++/81852 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 720c2912b82..e3cee7166fd 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -7990,9 +7990,14 @@ handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args, TREE_STATIC (decl) = 1; if (!is_alias) - /* ifuncs are also aliases, so set that attribute too. */ - DECL_ATTRIBUTES (decl) - = tree_cons (get_identifier ("alias"), args, DECL_ATTRIBUTES (decl)); + { + /* ifuncs are also aliases, so set that attribute too. */ + DECL_ATTRIBUTES (decl) + = tree_cons (get_identifier ("alias"), args, + DECL_ATTRIBUTES (decl)); + DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("ifunc"), + NULL, DECL_ATTRIBUTES (decl)); + } } else { @@ -9584,7 +9589,7 @@ parse_optimize_options (tree args, bool attr_p) &decoded_options_count); decode_options (&global_options, &global_options_set, decoded_options, decoded_options_count, - input_location, global_dc); + input_location, global_dc, NULL); targetm.override_options_after_change(); @@ -10726,10 +10731,9 @@ sync_resolve_size (tree function, vec<tree, va_gc> *params, bool fetch) } argtype = type = TREE_TYPE ((*params)[0]); - if (TREE_CODE (type) == ARRAY_TYPE) + if (TREE_CODE (type) == ARRAY_TYPE && c_dialect_cxx ()) { /* Force array-to-pointer decay for C++. */ - gcc_assert (c_dialect_cxx()); (*params)[0] = default_conversion ((*params)[0]); type = TREE_TYPE ((*params)[0]); } @@ -10891,10 +10895,9 @@ get_atomic_generic_size (location_t loc, tree function, /* Get type of first parameter, and determine its size. */ type_0 = TREE_TYPE ((*params)[0]); - if (TREE_CODE (type_0) == ARRAY_TYPE) + if (TREE_CODE (type_0) == ARRAY_TYPE && c_dialect_cxx ()) { /* Force array-to-pointer decay for C++. */ - gcc_assert (c_dialect_cxx()); (*params)[0] = default_conversion ((*params)[0]); type_0 = TREE_TYPE ((*params)[0]); } @@ -10933,6 +10936,12 @@ get_atomic_generic_size (location_t loc, tree function, /* __atomic_compare_exchange has a bool in the 4th position, skip it. */ if (n_param == 6 && x == 3) continue; + if (TREE_CODE (type) == ARRAY_TYPE && c_dialect_cxx ()) + { + /* Force array-to-pointer decay for C++. */ + (*params)[x] = default_conversion ((*params)[x]); + type = TREE_TYPE ((*params)[x]); + } if (!POINTER_TYPE_P (type)) { error_at (loc, "argument %d of %qE must be a pointer type", x + 1, diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 1691c40f11a..36ad6a783df 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -518,6 +518,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); @@ -592,6 +598,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/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index c73aa822104..660f28673e6 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -813,7 +813,7 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy)) } struct cl_option_handlers handlers; - set_default_handlers (&handlers); + set_default_handlers (&handlers, NULL); const char *arg = NULL; if (cl_options[option_index].flags & CL_JOINED) arg = option_string + 1 + cl_options[option_index].opt_len; diff --git a/gcc/config.gcc b/gcc/config.gcc index ddd5a657c66..f9d7cfb00d3 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1072,6 +1072,10 @@ arm*-*-freebsd*) # ARM FreeBSD EABI tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1" fi ;; + armv7*-*-freebsd*) + tm_defines="${tm_defines} TARGET_FREEBSD_ARMv7=1" + tm_defines="${tm_defines} TARGET_FREEBSD_ARM_HARD_FLOAT=1" + ;; esac with_tls=${with_tls:-gnu} ;; diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 0de52e3ff3c..5f268e2350f 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -957,4 +957,12 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); extern tree aarch64_fp16_type_node; extern tree aarch64_fp16_ptr_type_node; +/* The generic unwind code in libgcc does not initialize the frame pointer. + So in order to unwind a function using a frame pointer, the very first + function that is unwound must save the frame pointer. That way the frame + pointer is restored and its value is now valid - otherwise _Unwind_GetGR + crashes. Libgcc can now be safely built with -fomit-frame-pointer. */ +#define LIBGCC2_UNWIND_ATTRIBUTE \ + __attribute__((optimize ("no-omit-frame-pointer"))) + #endif /* GCC_AARCH64_H */ diff --git a/gcc/config/arm/freebsd.h b/gcc/config/arm/freebsd.h index 0ade4e99be1..f6209b1ca6e 100644 --- a/gcc/config/arm/freebsd.h +++ b/gcc/config/arm/freebsd.h @@ -112,7 +112,10 @@ #undef WCHAR_TYPE_SIZE #define WCHAR_TYPE_SIZE BITS_PER_WORD -#if defined (TARGET_FREEBSD_ARMv6) +#if defined (TARGET_FREEBSD_ARMv7) +#undef SUBTARGET_CPU_DEFAULT +#define SUBTARGET_CPU_DEFAULT TARGET_CPU_genericv7a +#elif defined (TARGET_FREEBSD_ARMv6) #undef SUBTARGET_CPU_DEFAULT #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm1176jzs #else diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index d7ce8ba3341..e6b565db03c 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -19673,13 +19673,13 @@ ix86_split_idivmod (machine_mode mode, rtx operands[], if (signed_p) { - div = gen_rtx_DIV (SImode, operands[2], operands[3]); - mod = gen_rtx_MOD (SImode, operands[2], operands[3]); + div = gen_rtx_DIV (mode, operands[2], operands[3]); + mod = gen_rtx_MOD (mode, operands[2], operands[3]); } else { - div = gen_rtx_UDIV (SImode, operands[2], operands[3]); - mod = gen_rtx_UMOD (SImode, operands[2], operands[3]); + div = gen_rtx_UDIV (mode, operands[2], operands[3]); + mod = gen_rtx_UMOD (mode, operands[2], operands[3]); } /* Extract remainder from AH. */ @@ -36767,6 +36767,9 @@ sorted_attr_string (tree arglist) { const char *str = TREE_STRING_POINTER (TREE_VALUE (arg)); size_t len = strlen (str); + /* Skip empty string. */ + if (len == 0) + continue; str_len_sum += len + 1; if (arg != arglist) argnum++; @@ -36781,11 +36784,21 @@ sorted_attr_string (tree arglist) { const char *str = TREE_STRING_POINTER (TREE_VALUE (arg)); size_t len = strlen (str); + /* Skip empty string. */ + if (len == 0) + continue; memcpy (attr_str + str_len_sum, str, len); attr_str[str_len_sum + len] = TREE_CHAIN (arg) ? ',' : '\0'; str_len_sum += len + 1; } + /* Strip ',' character at the end. */ + if (str_len_sum > 0 && attr_str[str_len_sum - 1] == ',') + { + attr_str[str_len_sum - 1] = '\0'; + str_len_sum--; + } + /* Replace "=,-" with "_". */ for (i = 0; i < strlen (attr_str); i++) if (attr_str[i] == '=' || attr_str[i]== '-') @@ -37402,6 +37415,7 @@ fold_builtin_cpu (tree fndecl, tree *args) M_INTEL_KNL, M_AMD_BTVER1, M_AMD_BTVER2, + M_AMDFAM17H, M_CPU_SUBTYPE_START, M_INTEL_COREI7_NEHALEM, M_INTEL_COREI7_WESTMERE, @@ -37456,6 +37470,7 @@ fold_builtin_cpu (tree fndecl, tree *args) {"bdver3", M_AMDFAM15H_BDVER3}, {"bdver4", M_AMDFAM15H_BDVER4}, {"btver2", M_AMD_BTVER2}, + {"amdfam17h", M_AMDFAM17H}, {"znver1", M_AMDFAM17H_ZNVER1}, }; diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 23c2c969e79..118c058a1b7 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -7230,12 +7230,13 @@ (define_insn "vec_extract_lo_<mode><mask_name>" [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>,v") (vec_select:<ssehalfvecmode> - (match_operand:V8FI 1 "nonimmediate_operand" "v,m") + (match_operand:V8FI 1 "<store_mask_predicate>" "v,<store_mask_constraint>") (parallel [(const_int 0) (const_int 1) (const_int 2) (const_int 3)])))] - "TARGET_AVX512F && !(MEM_P (operands[0]) && MEM_P (operands[1]))" + "TARGET_AVX512F + && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))" { - if (<mask_applied> || !TARGET_AVX512VL) + if (<mask_applied> || (!TARGET_AVX512VL && !MEM_P (operands[1]))) return "vextract<shuffletype>64x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}"; else return "#"; @@ -7374,14 +7375,15 @@ (define_insn "vec_extract_lo_<mode><mask_name>" [(set (match_operand:<ssehalfvecmode> 0 "nonimmediate_operand" "=v,m") (vec_select:<ssehalfvecmode> - (match_operand:V16FI 1 "nonimmediate_operand" "vm,v") + (match_operand:V16FI 1 "<store_mask_predicate>" + "<store_mask_constraint>,v") (parallel [(const_int 0) (const_int 1) (const_int 2) (const_int 3) (const_int 4) (const_int 5) (const_int 6) (const_int 7)])))] "TARGET_AVX512F && <mask_mode512bit_condition> - && !(MEM_P (operands[0]) && MEM_P (operands[1]))" + && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))" { if (<mask_applied>) return "vextract<shuffletype>32x8\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}"; @@ -7413,11 +7415,12 @@ (define_insn "vec_extract_lo_<mode><mask_name>" [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=v,m") (vec_select:<ssehalfvecmode> - (match_operand:VI8F_256 1 "nonimmediate_operand" "vm,v") + (match_operand:VI8F_256 1 "<store_mask_predicate>" + "<store_mask_constraint>,v") (parallel [(const_int 0) (const_int 1)])))] "TARGET_AVX && <mask_avx512vl_condition> && <mask_avx512dq_condition> - && !(MEM_P (operands[0]) && MEM_P (operands[1]))" + && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))" { if (<mask_applied>) return "vextract<shuffletype>64x2\t{$0x0, %1, %0%{%3%}|%0%{%3%}, %1, 0x0}"; @@ -7493,12 +7496,16 @@ (define_insn "vec_extract_lo_<mode><mask_name>" - [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" "=<store_mask_constraint>") + [(set (match_operand:<ssehalfvecmode> 0 "<store_mask_predicate>" + "=<store_mask_constraint>,v") (vec_select:<ssehalfvecmode> - (match_operand:VI4F_256 1 "register_operand" "v") + (match_operand:VI4F_256 1 "<store_mask_predicate>" + "v,<store_mask_constraint>") (parallel [(const_int 0) (const_int 1) (const_int 2) (const_int 3)])))] - "TARGET_AVX && <mask_avx512vl_condition> && <mask_avx512dq_condition>" + "TARGET_AVX + && <mask_avx512vl_condition> && <mask_avx512dq_condition> + && (<mask_applied> || !(MEM_P (operands[0]) && MEM_P (operands[1])))" { if (<mask_applied>) return "vextract<shuffletype>32x4\t{$0x0, %1, %0<mask_operand2>|%0<mask_operand2>, %1, 0x0}"; diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 08c5ea71230..818548b0233 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -25181,24 +25181,23 @@ debug_stack_info (rs6000_stack_t *info) rtx rs6000_return_addr (int count, rtx frame) { - /* Currently we don't optimize very well between prolog and body - code and for PIC code the code can be actually quite bad, so - don't try to be too clever here. */ + /* We can't use get_hard_reg_initial_val for LR when count == 0 if LR + is trashed by the prologue, as it is for PIC on ABI_V4 and Darwin. */ if (count != 0 || ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_DARWIN) && flag_pic)) { cfun->machine->ra_needs_full_frame = 1; - return - gen_rtx_MEM - (Pmode, - memory_address - (Pmode, - plus_constant (Pmode, - copy_to_reg - (gen_rtx_MEM (Pmode, - memory_address (Pmode, frame))), - RETURN_ADDRESS_OFFSET))); + if (count == 0) + /* FRAME is set to frame_pointer_rtx by the generic code, but that + is good for loading 0(r1) only when !FRAME_GROWS_DOWNWARD. */ + frame = stack_pointer_rtx; + rtx prev_frame_addr = memory_address (Pmode, frame); + rtx prev_frame = copy_to_reg (gen_rtx_MEM (Pmode, prev_frame_addr)); + rtx lr_save_off = plus_constant (Pmode, + prev_frame, RETURN_ADDRESS_OFFSET); + rtx lr_save_addr = memory_address (Pmode, lr_save_off); + return gen_rtx_MEM (Pmode, lr_save_addr); } cfun->machine->ra_need_lr = 1; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4140997c61a..807ed460482 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2017-09-15 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2017-09-14 Jakub Jelinek <jakub@redhat.com> + + PR c++/81314 + * cp-gimplify.c (omp_var_to_track): Look through references. + (omp_cxx_notice_variable): Likewise. + 2017-08-14 Paolo Carlini <paolo.carlini@oracle.com> PR c++/71570 diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 23201d3cec5..58037e56e6c 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -853,6 +853,8 @@ omp_var_to_track (tree decl) tree type = TREE_TYPE (decl); if (is_invisiref_parm (decl)) type = TREE_TYPE (type); + else if (TREE_CODE (type) == REFERENCE_TYPE) + type = TREE_TYPE (type); while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); if (type == error_mark_node || !CLASS_TYPE_P (type)) @@ -905,6 +907,8 @@ omp_cxx_notice_variable (struct cp_genericize_omp_taskreg *omp_ctx, tree decl) tree type = TREE_TYPE (decl); if (is_invisiref_parm (decl)) type = TREE_TYPE (type); + else if (TREE_CODE (type) == REFERENCE_TYPE) + type = TREE_TYPE (type); while (TREE_CODE (type) == ARRAY_TYPE) type = TREE_TYPE (type); get_copy_ctor (type, tf_none); diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 552c4afd3d1..83b46988309 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -17801,8 +17801,11 @@ AMD Family 15h Bulldozer version 4. @item btver2 AMD Family 16h CPU. -@item znver1 +@item amdfam17h AMD Family 17h CPU. + +@item znver1 +AMD Family 17h Zen version 1. @end table Here is an example: diff --git a/gcc/fold-const.c b/gcc/fold-const.c index c9aa386b6a0..4403f282706 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7365,15 +7365,10 @@ native_encode_vector (const_tree expr, unsigned char *ptr, int len, int off) static int native_encode_string (const_tree expr, unsigned char *ptr, int len, int off) { - tree type = TREE_TYPE (expr); - HOST_WIDE_INT total_bytes; - - if (TREE_CODE (type) != ARRAY_TYPE - || TREE_CODE (TREE_TYPE (type)) != INTEGER_TYPE - || GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (type))) != BITS_PER_UNIT - || !tree_fits_shwi_p (TYPE_SIZE_UNIT (type))) + if (! can_native_encode_string_p (expr)) return 0; - total_bytes = tree_to_shwi (TYPE_SIZE_UNIT (type)); + + HOST_WIDE_INT total_bytes = tree_to_shwi (TYPE_SIZE_UNIT (TREE_TYPE (expr))); if ((off == -1 && total_bytes > len) || off >= total_bytes) return 0; @@ -7647,6 +7642,22 @@ can_native_interpret_type_p (tree type) } } +/* Return true iff a STRING_CST S is accepted by + native_encode_expr. */ + +bool +can_native_encode_string_p (const_tree expr) +{ + tree type = TREE_TYPE (expr); + + if (TREE_CODE (type) != ARRAY_TYPE + || TREE_CODE (TREE_TYPE (type)) != INTEGER_TYPE + || (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (type))) != BITS_PER_UNIT) + || !tree_fits_shwi_p (TYPE_SIZE_UNIT (type))) + return false; + return true; +} + /* Fold a VIEW_CONVERT_EXPR of a constant expression EXPR to type TYPE at compile-time. If we're unable to perform the conversion return NULL_TREE. */ @@ -13989,8 +14000,8 @@ fold_negate_const (tree arg0, tree type) bool overflow; wide_int val = wi::neg (arg0, &overflow); t = force_fit_type (type, val, 1, - (overflow | TREE_OVERFLOW (arg0)) - && !TYPE_UNSIGNED (type)); + (overflow && ! TYPE_UNSIGNED (type)) + || TREE_OVERFLOW (arg0)); break; } diff --git a/gcc/fold-const.h b/gcc/fold-const.h index 02f42709c4e..6c2c070d5ff 100644 --- a/gcc/fold-const.h +++ b/gcc/fold-const.h @@ -27,6 +27,7 @@ extern int folding_initializer; /* Convert between trees and native memory representation. */ extern int native_encode_expr (const_tree, unsigned char *, int, int off = -1); extern tree native_interpret_expr (tree, const unsigned char *, int); +extern bool can_native_encode_string_p (const_tree); /* Fold constants as much as possible in an expression. Returns the simplified expression. diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0d1f7b66ae2..ac16bc09fc1 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2017-10-06 Thomas Koenig <tkoenig@gcc.gnu.org> + Steven G. Kargl <kargl@gcc.gnu.org> + + Backport from trunk + * expr.c (gfc_get_full_arrayspec_from_expr): If there is + no symtree, set array spec to NULL. + 2017-09-02 Janus Weil <janus@gcc.gnu.org> Backport from trunk diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index b91f906e86c..a30ea2d3d54 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -4102,7 +4102,11 @@ gfc_get_full_arrayspec_from_expr (gfc_expr *expr) if (expr->expr_type == EXPR_VARIABLE || expr->expr_type == EXPR_CONSTANT) { - as = expr->symtree->n.sym->as; + if (expr->symtree) + as = expr->symtree->n.sym->as; + else + as = NULL; + for (ref = expr->ref; ref; ref = ref->next) { switch (ref->type) diff --git a/gcc/function.c b/gcc/function.c index 4f2791254e5..6942a504127 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -6068,13 +6068,19 @@ thread_prologue_and_epilogue_insns (void) try_shrink_wrapping (&entry_edge, &bb_flags, prologue_seq); + rtx_insn *split_prologue_insn = split_prologue_seq; if (split_prologue_seq != NULL_RTX) { + while (split_prologue_insn && !NONDEBUG_INSN_P (split_prologue_insn)) + split_prologue_insn = NEXT_INSN (split_prologue_insn); insert_insn_on_edge (split_prologue_seq, orig_entry_edge); inserted = true; } + rtx_insn *prologue_insn = prologue_seq; if (prologue_seq != NULL_RTX) { + while (prologue_insn && !NONDEBUG_INSN_P (prologue_insn)) + prologue_insn = NEXT_INSN (prologue_insn); insert_insn_on_edge (prologue_seq, entry_edge); inserted = true; } @@ -6215,8 +6221,19 @@ epilogue_done: commit_edge_insertions (); /* Look for basic blocks within the prologue insns. */ + if (split_prologue_insn + && BLOCK_FOR_INSN (split_prologue_insn) == NULL) + split_prologue_insn = NULL; + if (prologue_insn + && BLOCK_FOR_INSN (prologue_insn) == NULL) + prologue_insn = NULL; blocks = sbitmap_alloc (last_basic_block_for_fn (cfun)); bitmap_clear (blocks); + if (split_prologue_insn) + bitmap_set_bit (blocks, + BLOCK_FOR_INSN (split_prologue_insn)->index); + if (prologue_insn) + bitmap_set_bit (blocks, BLOCK_FOR_INSN (prologue_insn)->index); bitmap_set_bit (blocks, entry_edge->dest->index); bitmap_set_bit (blocks, orig_entry_edge->dest->index); find_many_sub_basic_blocks (blocks); diff --git a/gcc/gcc.c b/gcc/gcc.c index 896d9af4acb..85ea19bd3a0 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -3702,7 +3702,8 @@ driver_handle_option (struct gcc_options *opts, unsigned int lang_mask ATTRIBUTE_UNUSED, int kind, location_t loc, const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED, - diagnostic_context *dc) + diagnostic_context *dc, + void (*) (void)) { size_t opt_index = decoded->opt_index; const char *arg = decoded->arg; diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c index f68d6fc7b98..ae2a3b35cd9 100644 --- a/gcc/gimple-ssa-strength-reduction.c +++ b/gcc/gimple-ssa-strength-reduction.c @@ -469,7 +469,8 @@ find_phi_def (tree base) c = base_cand_from_table (base); - if (!c || c->kind != CAND_PHI) + if (!c || c->kind != CAND_PHI + || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_phi_result (c->cand_stmt))) return 0; return c->cand_num; @@ -507,6 +508,11 @@ find_basis_for_base_expr (slsr_cand_t c, tree base_expr) gimple_bb (one_basis->cand_stmt))) continue; + tree lhs = gimple_assign_lhs (one_basis->cand_stmt); + if (lhs && TREE_CODE (lhs) == SSA_NAME + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs)) + continue; + if (!basis || basis->cand_num < one_basis->cand_num) basis = one_basis; } diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index 9e3c862339b..9a9012c6983 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -361,10 +361,14 @@ func_checker::compare_cst_or_decl (tree t1, tree t2) } case LABEL_DECL: { + if (t1 == t2) + return true; + int *bb1 = m_label_bb_map.get (t1); int *bb2 = m_label_bb_map.get (t2); - return return_with_debug (*bb1 == *bb2); + /* Labels can point to another function (non-local GOTOs). */ + return return_with_debug (bb1 != NULL && bb2 != NULL && *bb1 == *bb2); } case PARM_DECL: case RESULT_DECL: @@ -539,11 +543,8 @@ func_checker::compare_operand (tree t1, tree t2) } } -/* Compares two tree list operands T1 and T2 and returns true if these - two trees are semantically equivalent. */ - bool -func_checker::compare_tree_list_operand (tree t1, tree t2) +func_checker::compare_asm_inputs_outputs (tree t1, tree t2) { gcc_assert (TREE_CODE (t1) == TREE_LIST); gcc_assert (TREE_CODE (t2) == TREE_LIST); @@ -556,6 +557,16 @@ func_checker::compare_tree_list_operand (tree t1, tree t2) if (!compare_operand (TREE_VALUE (t1), TREE_VALUE (t2))) return return_false (); + tree p1 = TREE_PURPOSE (t1); + tree p2 = TREE_PURPOSE (t2); + + gcc_assert (TREE_CODE (p1) == TREE_LIST); + gcc_assert (TREE_CODE (p2) == TREE_LIST); + + if (strcmp (TREE_STRING_POINTER (TREE_VALUE (p1)), + TREE_STRING_POINTER (TREE_VALUE (p2))) != 0) + return return_false (); + t2 = TREE_CHAIN (t2); } @@ -1004,7 +1015,7 @@ func_checker::compare_gimple_asm (const gasm *g1, const gasm *g2) tree input1 = gimple_asm_input_op (g1, i); tree input2 = gimple_asm_input_op (g2, i); - if (!compare_tree_list_operand (input1, input2)) + if (!compare_asm_inputs_outputs (input1, input2)) return return_false_with_msg ("ASM input is different"); } @@ -1013,7 +1024,7 @@ func_checker::compare_gimple_asm (const gasm *g1, const gasm *g2) tree output1 = gimple_asm_output_op (g1, i); tree output2 = gimple_asm_output_op (g2, i); - if (!compare_tree_list_operand (output1, output2)) + if (!compare_asm_inputs_outputs (output1, output2)) return return_false_with_msg ("ASM output is different"); } diff --git a/gcc/ipa-icf-gimple.h b/gcc/ipa-icf-gimple.h index 9530a8ed55c..c572a181736 100644 --- a/gcc/ipa-icf-gimple.h +++ b/gcc/ipa-icf-gimple.h @@ -215,9 +215,9 @@ public: is returned. */ bool compare_operand (tree t1, tree t2); - /* Compares two tree list operands T1 and T2 and returns true if these - two trees are semantically equivalent. */ - bool compare_tree_list_operand (tree t1, tree t2); + /* Compares GIMPLE ASM inputs (or outputs) where we iterate tree chain + and compare both TREE_PURPOSEs and TREE_VALUEs. */ + bool compare_asm_inputs_outputs (tree t1, tree t2); /* Verifies that trees T1 and T2, representing function declarations are equivalent from perspective of ICF. */ diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c index adc4426e6be..520c659899e 100644 --- a/gcc/ipa-visibility.c +++ b/gcc/ipa-visibility.c @@ -97,7 +97,8 @@ non_local_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) && !DECL_EXTERNAL (node->decl) && !node->externally_visible && !node->used_from_other_partition - && !node->in_other_partition); + && !node->in_other_partition + && node->get_availability () >= AVAIL_AVAILABLE); } /* Return true when function can be marked local. */ diff --git a/gcc/lra-remat.c b/gcc/lra-remat.c index 79504d4eb1a..60944abfa33 100644 --- a/gcc/lra-remat.c +++ b/gcc/lra-remat.c @@ -753,7 +753,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-low.c b/gcc/omp-low.c index 33faf23e039..22d6ab9ea5f 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1559,6 +1559,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); @@ -10651,24 +10653,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); } } @@ -15175,10 +15181,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)) @@ -18027,7 +18037,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"; } @@ -18446,7 +18456,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/opts-common.c b/gcc/opts-common.c index 900c580019e..0d7f93d5545 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -986,7 +986,8 @@ handle_option (struct gcc_options *opts, { if (!handlers->handlers[i].handler (opts, opts_set, decoded, lang_mask, kind, loc, - handlers, dc)) + handlers, dc, + handlers->target_option_override_hook)) return false; } diff --git a/gcc/opts-global.c b/gcc/opts-global.c index b7e52323a21..23dd7fb5579 100644 --- a/gcc/opts-global.c +++ b/gcc/opts-global.c @@ -167,7 +167,8 @@ lang_handle_option (struct gcc_options *opts, unsigned int lang_mask ATTRIBUTE_UNUSED, int kind, location_t loc, const struct cl_option_handlers *handlers, - diagnostic_context *dc) + diagnostic_context *dc, + void (*) (void)) { gcc_assert (opts == &global_options); gcc_assert (opts_set == &global_options_set); @@ -267,10 +268,12 @@ decode_cmdline_options_to_array_default_mask (unsigned int argc, /* Set *HANDLERS to the default set of option handlers for use in the compilers proper (not the driver). */ void -set_default_handlers (struct cl_option_handlers *handlers) +set_default_handlers (struct cl_option_handlers *handlers, + void (*target_option_override_hook) (void)) { handlers->unknown_option_callback = unknown_option_callback; handlers->wrong_lang_callback = complain_wrong_lang; + handlers->target_option_override_hook = target_option_override_hook; handlers->num_handlers = 3; handlers->handlers[0].handler = lang_handle_option; handlers->handlers[0].mask = initial_lang_mask; @@ -288,7 +291,8 @@ void decode_options (struct gcc_options *opts, struct gcc_options *opts_set, struct cl_decoded_option *decoded_options, unsigned int decoded_options_count, - location_t loc, diagnostic_context *dc) + location_t loc, diagnostic_context *dc, + void (*target_option_override_hook) (void)) { struct cl_option_handlers handlers; @@ -296,7 +300,7 @@ decode_options (struct gcc_options *opts, struct gcc_options *opts_set, lang_mask = initial_lang_mask; - set_default_handlers (&handlers); + set_default_handlers (&handlers, target_option_override_hook); default_options_optimization (opts, opts_set, decoded_options, decoded_options_count, diff --git a/gcc/opts.c b/gcc/opts.c index 0f9431a0b32..8f9862db57c 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -216,7 +216,7 @@ target_handle_option (struct gcc_options *opts, unsigned int lang_mask ATTRIBUTE_UNUSED, int kind, location_t loc, const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED, - diagnostic_context *dc) + diagnostic_context *dc, void (*) (void)) { gcc_assert (dc == global_dc); gcc_assert (kind == DK_UNSPECIFIED); @@ -1543,7 +1543,8 @@ common_handle_option (struct gcc_options *opts, unsigned int lang_mask, int kind ATTRIBUTE_UNUSED, location_t loc, const struct cl_option_handlers *handlers, - diagnostic_context *dc) + diagnostic_context *dc, + void (*target_option_override_hook) (void)) { size_t scode = decoded->opt_index; const char *arg = decoded->arg; @@ -1570,6 +1571,7 @@ common_handle_option (struct gcc_options *opts, undoc_mask = ((opts->x_verbose_flag | opts->x_extra_warnings) ? 0 : CL_UNDOCUMENTED); + target_option_override_hook (); /* First display any single language specific options. */ for (i = 0; i < cl_lang_count; i++) print_specific_help @@ -1589,6 +1591,7 @@ common_handle_option (struct gcc_options *opts, if (lang_mask == CL_DRIVER) break; + target_option_override_hook (); print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0, opts, lang_mask); opts->x_exit_after_options = true; break; @@ -1710,8 +1713,11 @@ common_handle_option (struct gcc_options *opts, } if (include_flags) - print_specific_help (include_flags, exclude_flags, 0, opts, - lang_mask); + { + target_option_override_hook (); + print_specific_help (include_flags, exclude_flags, 0, opts, + lang_mask); + } opts->x_exit_after_options = true; break; } diff --git a/gcc/opts.h b/gcc/opts.h index 25d32c1ad49..52887b6a32c 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -267,7 +267,8 @@ struct cl_option_handler_func const struct cl_decoded_option *decoded, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, - diagnostic_context *dc); + diagnostic_context *dc, + void (*target_option_override_hook) (void)); /* The mask that must have some bit in common with the flags for the option for this particular handler to be used. */ @@ -289,6 +290,9 @@ struct cl_option_handlers void (*wrong_lang_callback) (const struct cl_decoded_option *decoded, unsigned int lang_mask); + /* Target option override hook. */ + void (*target_option_override_hook) (void); + /* The number of individual handlers. */ size_t num_handlers; @@ -333,13 +337,15 @@ extern void decode_cmdline_options_to_array_default_mask (unsigned int argc, const char **argv, struct cl_decoded_option **decoded_options, unsigned int *decoded_options_count); -extern void set_default_handlers (struct cl_option_handlers *handlers); +extern void set_default_handlers (struct cl_option_handlers *handlers, + void (*target_option_override_hook) (void)); extern void decode_options (struct gcc_options *opts, struct gcc_options *opts_set, struct cl_decoded_option *decoded_options, unsigned int decoded_options_count, location_t loc, - diagnostic_context *dc); + diagnostic_context *dc, + void (*target_option_override_hook) (void)); extern int option_enabled (int opt_idx, void *opts); extern bool get_option_state (struct gcc_options *, int, struct cl_option_state *); @@ -384,14 +390,16 @@ extern bool common_handle_option (struct gcc_options *opts, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, - diagnostic_context *dc); + diagnostic_context *dc, + void (*target_option_override_hook) (void)); extern bool target_handle_option (struct gcc_options *opts, struct gcc_options *opts_set, const struct cl_decoded_option *decoded, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, - diagnostic_context *dc); + diagnostic_context *dc, + void (*target_option_override_hook) (void)); extern void finish_options (struct gcc_options *opts, struct gcc_options *opts_set, location_t loc); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c9a10a6e1d4..c53d6b168f8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,167 @@ +2017-10-06 Thomas Koenig <tkoenig@gcc.gnu.org> + Steven G. Kargl <kargl@gcc.gnu.org> + + Backport from trunk + PR fortran/80118 + * gfortran.dg/zero_sized_7.f90: New test. + +2017-10-02 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + Backport from mainline + 2017-09-29 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + PR tree-optimization/82337 + * gcc.c-torture/compile/pr82337.c: New file. + +2017-10-02 Eric Botcazou <ebotcazou@adacore.com> + + * opt55.ad[sb]: Move to... + * gnat.dg/opt55.ad[sb]: ...here. + +2017-09-19 Martin Liska <mliska@suse.cz> + + Revert backport: + 2017-08-10 Martin Liska <mliska@suse.cz> + + PR c++/81355 + * g++.dg/other/pr81355.C: New test. + +2017-09-18 Richard Biener <rguenther@suse.de> + + Backport from mainline + 2017-04-07 Richard Biener <rguenther@suse.de> + + PR middle-end/80341 + * gcc.dg/torture/pr80341.c: New testcase. + + 2017-04-04 Richard Biener <rguenther@suse.de> + + PR middle-end/80281 + * gcc.dg/torture/pr80281.c: New testcase. + +2017-09-18 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-09-04 Richard Biener <rguenther@suse.de> + + PR tree-optimization/82084 + * g++.dg/torture/pr82084.C: New testcase. + + 2017-07-25 Richard Biener <rguenther@suse.de> + + PR middle-end/81505 + * gcc.dg/ubsan/pr81505.c: New testcase. + +2017-09-18 Martin Liska <mliska@suse.cz> + + * gcc.dg/asan/pr81224.c: Remove. + +2017-09-15 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2017-09-12 Jakub Jelinek <jakub@redhat.com> + + PR target/82112 + * gcc.target/powerpc/pr82112.c: New test. + * g++.dg/ext/altivec-18.C: New test. + + PR target/82112 + * c-c++-common/pr82112.c: New test. + * gcc.dg/pr82112.c: New test. + + 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-08-08 Richard Biener <rguenther@suse.de> + + PR middle-end/81766 + * gcc.target/i386/pr81766.c: New testcase. + + 2017-08-03 Jakub Jelinek <jakub@redhat.com> + + PR target/81621 + * gcc.dg/pr81621.c: New test. + + PR middle-end/81052 + * c-c++-common/pr81052.c: New test. + + 2017-08-02 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/79499 + * gcc.dg/pr79499.c: New test. + + 2017-06-30 Jakub Jelinek <jakub@redhat.com> + + PR target/81225 + * gcc.target/i386/pr81225.c: New test. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-11 Martin Liska <mliska@suse.cz> + + PR tree-opt/79987 + * gcc.target/i386/mpx/pr79987.c: New test. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-06-28 Martin Liska <mliska@suse.cz> + + PR sanitizer/81224 + * gcc.dg/asan/pr81224.c: New test. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-30 Martin Liska <mliska@suse.cz> + + PR inline-asm/82001 + * gcc.dg/ipa/pr82001.c: New test. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-10 Martin Liska <mliska@suse.cz> + + PR c++/81355 + * g++.dg/other/pr81355.C: New test. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-08-08 Martin Liska <mliska@suse.cz> + + PR tree-opt/81696 + * gcc.dg/ipa/pr81696.c: New test. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-07-19 Martin Liska <mliska@suse.cz> + + PR sanitizer/63361 + * c-c++-common/ubsan/float-cast-overflow-1.c: Add either + -ffloat-store or -mieee for targets that need it. + +2017-09-15 Martin Liska <mliska@suse.cz> + + Backport from mainline + 2017-06-28 Martin Liska <mliska@suse.cz> + + PR ipa/81128 + * gcc.target/i386/pr81128.c: New test. + 2017-09-12 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/pr82112.c b/gcc/testsuite/c-c++-common/pr82112.c new file mode 100644 index 00000000000..724d74cb33d --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr82112.c @@ -0,0 +1,13 @@ +/* PR target/82112 */ +/* { dg-do compile } */ + +int c[10], d[10], e[10], f[10], g[10], h[10], i[10], j[10], k[10], l[10]; + +void +foo (void) +{ + __atomic_load (c, d, __ATOMIC_ACQUIRE); + __atomic_store (e, f, __ATOMIC_SEQ_CST); + __atomic_exchange (g, h, i, __ATOMIC_RELAXED); + __atomic_compare_exchange (j, k, l, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); +} diff --git a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c index cd6941c9d30..aae88aa3180 100644 --- a/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c +++ b/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-1.c @@ -1,6 +1,7 @@ /* { dg-do run { target { lp64 || ilp32 } } } */ /* { dg-options "-fsanitize=float-cast-overflow" } */ -/* { dg-additional-options "-msse2 -mfpmath=sse" { target { sse2_runtime && ia32 } } } */ +/* { dg-additional-options "-ffloat-store" { target { ia32 } } } */ +/* { dg-additional-options "-mieee" { target { { alpha*-*-* } || { sh*-*-* } } } } */ #include <limits.h> #include "float-cast.h" diff --git a/gcc/testsuite/g++.dg/ext/altivec-18.C b/gcc/testsuite/g++.dg/ext/altivec-18.C new file mode 100644 index 00000000000..5b83028e737 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/altivec-18.C @@ -0,0 +1,14 @@ +// PR target/82112 +// { dg-do compile { target powerpc*-*-* } } +// { dg-require-effective-target powerpc_altivec_ok } +// { dg-options "-maltivec" } + +#include <altivec.h> + +__attribute__((aligned (16))) extern const unsigned char c[16]; + +void +foo (void) +{ + vec_ld (0, c); +} 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/pr82084.C b/gcc/testsuite/g++.dg/torture/pr82084.C new file mode 100644 index 00000000000..416684d2cb8 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr82084.C @@ -0,0 +1,9 @@ +// { dg-do compile } + +#include <string> +int main() +{ + wchar_t strs[4][2]= { L"A", L"B", L"C" , L"D"}; + std::wstring ss(strs[0]); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr82337.c b/gcc/testsuite/gcc.c-torture/compile/pr82337.c new file mode 100644 index 00000000000..f8afa746adb --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr82337.c @@ -0,0 +1,25 @@ +/* PR82337: SLSR needs to prevent abnormal SSA names from + serving as a basis. */ +char *a, *b, *c; + +struct d { + short e; + char f[]; +}; + +extern void j (void); + +void +g() { + struct d *h; + char *i; + int d; + do { + i = h->f + d; + 20 ? j() : 0; + i = c; + if (__builtin_setjmp (h)) + b = h->f + d; + d = (int)(*i); + } while (a); +} 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/pr81696.c b/gcc/testsuite/gcc.dg/ipa/pr81696.c new file mode 100644 index 00000000000..2d3d63ff0bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr81696.c @@ -0,0 +1,26 @@ +/* { dg-options "-O2 -fdump-ipa-icf-details" } */ + +int +main (int argc, char **argv) +{ + __label__ lab4, lab5, lab6; + + void foo (void) { goto lab4; } + void foo2 (void) { goto lab4; } + void bar (void) { goto lab5; } + void baz (void) { goto lab6; } + + if (argc) + foo (); + else + foo2 (); + + lab4:; + bar (); + lab5:; + baz (); + lab6:; + return 0; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/pr82001.c b/gcc/testsuite/gcc.dg/ipa/pr82001.c new file mode 100644 index 00000000000..05e32b10ef5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr82001.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -fdump-ipa-icf-details" } */ + +int +mullo (int a, int b) +{ + asm("mul %%edx # %%1 was %1" + : "+" + "a"(a), + "+d"(b)); + return a; +} + +int +mulhi (int a, int b) +{ + asm("mul %%edx # %%1 was %1" : "+d"(a), "+a"(b)); + return a; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */ diff --git a/gcc/testsuite/gcc.dg/pr79499.c b/gcc/testsuite/gcc.dg/pr79499.c new file mode 100644 index 00000000000..509549ff2fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr79499.c @@ -0,0 +1,13 @@ +/* PR middle-end/79499 */ +/* { dg-do compile { target split_stack } } */ +/* { dg-options "-O2 -fsplit-stack -fno-omit-frame-pointer" } */ + +struct S { struct S *a, *b; }; + +void +foo (struct S *x) +{ + do + x->b = x->a; + while (x = x->a); +} 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/pr82112.c b/gcc/testsuite/gcc.dg/pr82112.c new file mode 100644 index 00000000000..4ca69195acc --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr82112.c @@ -0,0 +1,21 @@ +/* PR target/82112 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90" } */ + +struct S { int a[10]; } bar (void); +int b, c; + +void +foo (void) +{ + __atomic_load (bar ().a, &b, __ATOMIC_ACQUIRE); /* { dg-error "argument 1 of .__atomic_load. must be a non-void pointer type" } */ + __atomic_load (&b, bar ().a, __ATOMIC_ACQUIRE); /* { dg-error "argument 2 of .__atomic_load. must be a pointer type" } */ + __atomic_store (bar ().a, &b, __ATOMIC_SEQ_CST); /* { dg-error "argument 1 of .__atomic_store. must be a non-void pointer type" } */ + __atomic_store (&b, bar ().a, __ATOMIC_SEQ_CST); /* { dg-error "argument 2 of .__atomic_store. must be a pointer type" } */ + __atomic_exchange (bar ().a, &b, &c, __ATOMIC_RELAXED); /* { dg-error "argument 1 of .__atomic_exchange. must be a non-void pointer type" } */ + __atomic_exchange (&b, bar ().a, &c, __ATOMIC_RELAXED); /* { dg-error "argument 2 of .__atomic_exchange. must be a pointer type" } */ + __atomic_exchange (&b, &c, bar ().a, __ATOMIC_RELAXED); /* { dg-error "argument 3 of .__atomic_exchange. must be a pointer type" } */ + __atomic_compare_exchange (bar ().a, &b, &c, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); /* { dg-error "argument 1 of .__atomic_compare_exchange. must be a non-void pointer type" } */ + __atomic_compare_exchange (&b, bar ().a, &c, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); /* { dg-error "argument 2 of .__atomic_compare_exchange. must be a pointer type" } */ + __atomic_compare_exchange (&b, &c, bar ().a, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); /* { dg-error "argument 3 of .__atomic_compare_exchange. must be a pointer type" } */ +} diff --git a/gcc/testsuite/gcc.dg/torture/pr80281.c b/gcc/testsuite/gcc.dg/torture/pr80281.c new file mode 100644 index 00000000000..bff4f6e60a8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr80281.c @@ -0,0 +1,14 @@ +/* { dg-run } */ +/* { dg-require-effective-target int32plus } */ + +int +main () +{ + volatile int a = 0; + long long b = 2147483648LL; + int c = a % 2; + int x = ((int) -b + c) % -2147483647; + if (x != -1) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr80341.c b/gcc/testsuite/gcc.dg/torture/pr80341.c new file mode 100644 index 00000000000..c9e12396d07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr80341.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-additional-options "-Wno-overflow" } */ +/* { dg-require-effective-target int32plus } */ + +const signed char c = -84; +signed char s; + +void +foo () +{ + s = (unsigned short) c / -55; +} + +int +main () +{ + foo (); + if (s != 90) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/ubsan/pr81505.c b/gcc/testsuite/gcc.dg/ubsan/pr81505.c new file mode 100644 index 00000000000..1cebef56172 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ubsan/pr81505.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fsanitize=signed-integer-overflow" } */ + +int a, b, c, h; + +int i[5][5]; + +void +fn1 () +{ + int l = 0; + + for (a = 0; a <= 3; a++) + for (b = 1; b >= 0; b -= 1) + l |= i[0][b]; + c = l; +} diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79987.c b/gcc/testsuite/gcc.target/i386/mpx/pr79987.c new file mode 100644 index 00000000000..b3ebda95694 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/pr79987.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + +extern void foo; +void *bar = &foo; /* { dg-warning "taking address of expression of type .void." } */ diff --git a/gcc/testsuite/gcc.target/i386/pr81128.c b/gcc/testsuite/gcc.target/i386/pr81128.c new file mode 100644 index 00000000000..90a567ad690 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr81128.c @@ -0,0 +1,65 @@ +/* PR ipa/81128 */ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-require-ifunc "" } */ + + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +int resolver_fn = 0; +int resolved_fn = 0; + +static inline void +do_it_right_at_runtime_A () +{ + resolved_fn++; +} + +static inline void +do_it_right_at_runtime_B () +{ + resolved_fn++; +} + +static inline void do_it_right_at_runtime (void); + +void do_it_right_at_runtime (void) + __attribute__ ((ifunc ("resolve_do_it_right_at_runtime"))); + +static void (*resolve_do_it_right_at_runtime (void)) (void) +{ + srand (time (NULL)); + int r = rand (); + resolver_fn++; + + /* Use intermediate variable to get a warning for non-matching + * prototype. */ + typeof(do_it_right_at_runtime) *func; + if (r & 1) + func = do_it_right_at_runtime_A; + else + func = do_it_right_at_runtime_B; + + return (void *) func; +} + +int +main (void) +{ + const unsigned int ITERS = 10; + + for (int i = ITERS; i > 0; i--) + { + do_it_right_at_runtime (); + } + + if (resolver_fn != 1) + __builtin_abort (); + + if (resolved_fn != 10) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/pr81225.c b/gcc/testsuite/gcc.target/i386/pr81225.c new file mode 100644 index 00000000000..db95e941c14 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr81225.c @@ -0,0 +1,14 @@ +/* PR target/81225 */ +/* { dg-do compile } */ +/* { dg-options "-mavx512ifma -O3 -ffloat-store" } */ + +long a[24]; +float b[4], c[24]; +int d; + +void +foo () +{ + for (d = 0; d < 24; d++) + c[d] = (float) d ? : b[a[d]]; +} diff --git a/gcc/testsuite/gcc.target/i386/pr81766.c b/gcc/testsuite/gcc.target/i386/pr81766.c new file mode 100644 index 00000000000..4bcae7f610d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr81766.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -fPIE -mcmodel=large" } */ + +int main() { return 0; } diff --git a/gcc/testsuite/gcc.target/powerpc/pr82112.c b/gcc/testsuite/gcc.target/powerpc/pr82112.c new file mode 100644 index 00000000000..fbb0f9d3d06 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr82112.c @@ -0,0 +1,16 @@ +/* PR target/82112 */ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-maltivec -std=gnu90" } */ + +#include <altivec.h> + +struct __attribute__((aligned (16))) S { unsigned char c[64]; } bar (void); +vector unsigned char v; + +void +foo (void) +{ + vec_ld (0, bar ().c); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */ + vec_st (v, 0, bar ().c); /* { dg-error "invalid parameter combination for AltiVec intrinsic" } */ +} diff --git a/gcc/testsuite/gfortran.dg/zero_sized_7.f90 b/gcc/testsuite/gfortran.dg/zero_sized_7.f90 new file mode 100644 index 00000000000..7908532eaea --- /dev/null +++ b/gcc/testsuite/gfortran.dg/zero_sized_7.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! PR 80118 - this used to ICE +! Original test case by Marco Restelli +module m +implicit none + + integer, parameter :: not_empty(1) = 0 + integer, parameter :: empty1(0) = (/integer :: /) + integer, parameter :: empty2(0) = 0 + +contains + + subroutine sub(v) + integer, allocatable, intent(out) :: v(:) + v = 2*empty2 ! internal compiler error + end subroutine sub + +end module m diff --git a/gcc/testsuite/opt55.adb b/gcc/testsuite/gnat.dg/opt55.adb index 70f486b2ee3..70f486b2ee3 100644 --- a/gcc/testsuite/opt55.adb +++ b/gcc/testsuite/gnat.dg/opt55.adb diff --git a/gcc/testsuite/opt55.ads b/gcc/testsuite/gnat.dg/opt55.ads index fec3c9ae2ef..fec3c9ae2ef 100644 --- a/gcc/testsuite/opt55.ads +++ b/gcc/testsuite/gnat.dg/opt55.ads diff --git a/gcc/toplev.c b/gcc/toplev.c index 3d4137b7c7b..d6f6c74ffbc 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2100,7 +2100,8 @@ toplev::main (int argc, char **argv) enough to default flags appropriately. */ decode_options (&global_options, &global_options_set, save_decoded_options, save_decoded_options_count, - UNKNOWN_LOCATION, global_dc); + UNKNOWN_LOCATION, global_dc, + targetm.target_option.override); handle_common_deferred_options (); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 483fbd90947..380f6898db7 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6527,7 +6527,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) { @@ -6646,6 +6654,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 2901e8b354d..28dac22add6 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -3144,6 +3144,9 @@ chkp_get_bounds_for_decl_addr (tree decl) && !flag_chkp_incomplete_type) return chkp_get_zero_bounds (); + if (VOID_TYPE_P (TREE_TYPE (decl))) + return chkp_get_zero_bounds (); + if (flag_chkp_use_static_bounds && TREE_CODE (decl) == VAR_DECL && (TREE_STATIC (decl) diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 76f3626b4f4..65077ede43c 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -2169,7 +2169,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-stmts.c b/gcc/tree-vect-stmts.c index 4839efb0f40..e29ea54f193 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -5317,6 +5317,12 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, op = gimple_assign_rhs1 (stmt); + /* In the case this is a store from a STRING_CST make sure + native_encode_expr can handle it. */ + if (TREE_CODE (op) == STRING_CST + && ! can_native_encode_string_p (op)) + return false; + if (!vect_is_simple_use (op, vinfo, &def_stmt, &dt, &rhs_vectype)) { if (dump_enabled_p ()) diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 7396f673c0a..a8db5f76834 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,23 @@ +2017-09-15 Jakub Jelinek <jakub@redhat.com> + + Backported from mainline + 2017-09-14 Jakub Jelinek <jakub@redhat.com> + + PR c++/81314 + * testsuite/libgomp.c++/pr81314.C: New test. + + 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-07-04 Release Manager * GCC 6.4.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++/pr81314.C b/libgomp/testsuite/libgomp.c++/pr81314.C new file mode 100644 index 00000000000..afe89438bd3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/pr81314.C @@ -0,0 +1,38 @@ +// PR c++/81314 +// { dg-do link } + +template <int N> +struct S { + S () { s = 0; } + S (const S &x) { s = x.s; } + ~S () {} + int s; +}; + +void +foo (S<2> &x) +{ + #pragma omp taskloop + for (int i = 0; i < 100; ++i) + x.s++; +} + +void +bar (S<3> &x) +{ + #pragma omp task + x.s++; +} + +int +main () +{ + S<2> s; + S<3> t; + #pragma omp parallel + #pragma omp master + { + foo (s); + bar (t); + } +} 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/libquadmath/ChangeLog b/libquadmath/ChangeLog index a514ff15f25..e0354f07a3b 100644 --- a/libquadmath/ChangeLog +++ b/libquadmath/ChangeLog @@ -1,3 +1,8 @@ +2017-09-15 Jakub Jelinek <jakub@redhat.com> + + PR libquadmath/65757 + * math/roundq.c: Cherry-pick upstream glibc 2015-04-28 change. + 2017-07-04 Release Manager * GCC 6.4.0 released. diff --git a/libquadmath/math/roundq.c b/libquadmath/math/roundq.c index 7c9d640e933..adcb94a8faf 100644 --- a/libquadmath/math/roundq.c +++ b/libquadmath/math/roundq.c @@ -1,5 +1,5 @@ /* Round __float128 to integer away from zero. - Copyright (C) 1997, 1999 Free Software Foundation, Inc. + Copyright (C) 1997-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and Jakub Jelinek <jj@ultra.linux.cz>, 1999. @@ -32,7 +32,7 @@ roundq (__float128 x) GET_FLT128_WORDS64 (i0, i1, x); j0 = ((i0 >> 48) & 0x7fff) - 0x3fff; - if (j0 < 31) + if (j0 < 48) { if (j0 < 0) { diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1ba0afa34cc..f803618da6f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,61 @@ +2017-09-20 Jonathan Wakely <jwakely@redhat.com> + + Backport from mainline + 2017-02-16 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/60936 + * src/c++11/snprintf_lite.cc (__concat_size_t): Calculate length + written to buffer, not length remaining in buffer. + + Backport from mainline + 2017-02-08 Gerald Pfeifer <gerald@pfeifer.com> + + * src/c++11/snprintf_lite.cc (__err): Update bug reporting URL. + +2017-09-18 Jonathan Wakely <jwakely@redhat.com> + + Backport from mainline + 2017-02-03 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/60936 + * src/c++11/Makefile.am: Add new files. + * src/c++11/Makefile.in: Regenerate. + * src/c++11/cow-string-inst.cc [!_GLIBCXX_USE_CXX11_ABI] + (operator<<, operator>>, getline): Move explicit instantiations to ... + * src/c++11/cow-string-io-inst.cc: ... new file. + * src/c++11/cow-wstring-inst.cc [!_GLIBCXX_USE_CXX11_ABI] + (operator<<, operator>>, getline): Move explicit instantiations to ... + * src/c++11/cow-wstring-io-inst.cc: ... new file. + * src/c++11/functexcept.cc (__throw_ios_failure, __throw_system_error) + (__throw_future_error, __throw_bad_function_call): + (__throw_regex_error): Move functions for C++11 exceptions to the + files that define the exception types. + * src/c++11/functional.cc (__throw_bad_function_call): Move here. + * src/c++11/future.cc (__throw_future_error): Likewise. + * src/c++11/ios.cc (__throw_ios_failure): Likewise. + * src/c++11/regex.cc (__throw_regex_error): Likewise. + * src/c++11/snprintf_lite.cc (__concat_size_t): Print decimal + representation directly instead of calling __int_to_char. + * src/c++11/sso_string.cc (__sso_string): New file for definition + of __sso_string type. + * src/c++11/string-io-inst.cc [_GLIBCXX_USE_CXX11_ABI]: New file for + explicit instantiations of narrow string I/O functions. + * src/c++11/system_error.cc (__throw_system_error): Move here. + (__sso_string): Move to new file. + * src/c++11/wstring-io-inst.cc [_GLIBCXX_USE_CXX11_ABI]: New file for + explicit instantiations of wide string I/O functions. + * src/c++98/misc-inst.cc [_GLIBCXX_USE_CXX11_ABI] (operator<<) + (operator>>, getline): Remove explicit instantiations from here. + 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 diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index b0a6df9ce8f..b4f5f10a164 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -558,7 +558,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/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am index 5f995f98958..275a8709c6e 100644 --- a/libstdc++-v3/src/c++11/Makefile.am +++ b/libstdc++-v3/src/c++11/Makefile.am @@ -82,9 +82,12 @@ extra_string_inst_sources = \ cow-fstream-inst.cc \ cow-sstream-inst.cc \ cow-string-inst.cc \ + cow-string-io-inst.cc \ cow-wstring-inst.cc \ + cow-wstring-io-inst.cc \ cxx11-locale-inst.cc \ - cxx11-wlocale-inst.cc + cxx11-wlocale-inst.cc \ + sso_string.cc else extra_string_inst_sources = endif @@ -103,8 +106,10 @@ inst_sources = \ sstream-inst.cc \ streambuf-inst.cc \ string-inst.cc \ + string-io-inst.cc \ wlocale-inst.cc \ - wstring-inst.cc + wstring-inst.cc \ + wstring-io-inst.cc else # XTEMPLATE_FLAGS = inst_sources = diff --git a/libstdc++-v3/src/c++11/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in index 5a24cb0a6cb..c8dea4bce6e 100644 --- a/libstdc++-v3/src/c++11/Makefile.in +++ b/libstdc++-v3/src/c++11/Makefile.in @@ -97,15 +97,20 @@ am__objects_3 = chrono.lo codecvt.lo condition_variable.lo \ system_error.lo thread.lo $(am__objects_1) $(am__objects_2) @ENABLE_DUAL_ABI_TRUE@am__objects_4 = cow-fstream-inst.lo \ @ENABLE_DUAL_ABI_TRUE@ cow-sstream-inst.lo cow-string-inst.lo \ -@ENABLE_DUAL_ABI_TRUE@ cow-wstring-inst.lo cxx11-locale-inst.lo \ -@ENABLE_DUAL_ABI_TRUE@ cxx11-wlocale-inst.lo +@ENABLE_DUAL_ABI_TRUE@ cow-string-io-inst.lo \ +@ENABLE_DUAL_ABI_TRUE@ cow-wstring-inst.lo \ +@ENABLE_DUAL_ABI_TRUE@ cow-wstring-io-inst.lo \ +@ENABLE_DUAL_ABI_TRUE@ cxx11-locale-inst.lo \ +@ENABLE_DUAL_ABI_TRUE@ cxx11-wlocale-inst.lo sso_string.lo @ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_5 = $(am__objects_4) \ @ENABLE_EXTERN_TEMPLATE_TRUE@ ext11-inst.lo fstream-inst.lo \ @ENABLE_EXTERN_TEMPLATE_TRUE@ ios-inst.lo iostream-inst.lo \ @ENABLE_EXTERN_TEMPLATE_TRUE@ istream-inst.lo locale-inst.lo \ @ENABLE_EXTERN_TEMPLATE_TRUE@ ostream-inst.lo sstream-inst.lo \ @ENABLE_EXTERN_TEMPLATE_TRUE@ streambuf-inst.lo string-inst.lo \ -@ENABLE_EXTERN_TEMPLATE_TRUE@ wlocale-inst.lo wstring-inst.lo +@ENABLE_EXTERN_TEMPLATE_TRUE@ string-io-inst.lo wlocale-inst.lo \ +@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-inst.lo \ +@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-io-inst.lo am_libc__11convenience_la_OBJECTS = $(am__objects_3) $(am__objects_5) libc__11convenience_la_OBJECTS = $(am_libc__11convenience_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) @@ -395,9 +400,12 @@ sources = \ @ENABLE_DUAL_ABI_TRUE@ cow-fstream-inst.cc \ @ENABLE_DUAL_ABI_TRUE@ cow-sstream-inst.cc \ @ENABLE_DUAL_ABI_TRUE@ cow-string-inst.cc \ +@ENABLE_DUAL_ABI_TRUE@ cow-string-io-inst.cc \ @ENABLE_DUAL_ABI_TRUE@ cow-wstring-inst.cc \ +@ENABLE_DUAL_ABI_TRUE@ cow-wstring-io-inst.cc \ @ENABLE_DUAL_ABI_TRUE@ cxx11-locale-inst.cc \ -@ENABLE_DUAL_ABI_TRUE@ cxx11-wlocale-inst.cc +@ENABLE_DUAL_ABI_TRUE@ cxx11-wlocale-inst.cc \ +@ENABLE_DUAL_ABI_TRUE@ sso_string.cc # XTEMPLATE_FLAGS = @ENABLE_EXTERN_TEMPLATE_FALSE@inst_sources = @@ -415,8 +423,10 @@ sources = \ @ENABLE_EXTERN_TEMPLATE_TRUE@ sstream-inst.cc \ @ENABLE_EXTERN_TEMPLATE_TRUE@ streambuf-inst.cc \ @ENABLE_EXTERN_TEMPLATE_TRUE@ string-inst.cc \ +@ENABLE_EXTERN_TEMPLATE_TRUE@ string-io-inst.cc \ @ENABLE_EXTERN_TEMPLATE_TRUE@ wlocale-inst.cc \ -@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-inst.cc +@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-inst.cc \ +@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-io-inst.cc libc__11convenience_la_SOURCES = $(sources) $(inst_sources) diff --git a/libstdc++-v3/src/c++11/cow-string-inst.cc b/libstdc++-v3/src/c++11/cow-string-inst.cc index 50d9f85e961..4f84ef8e125 100644 --- a/libstdc++-v3/src/c++11/cow-string-inst.cc +++ b/libstdc++-v3/src/c++11/cow-string-inst.cc @@ -29,35 +29,10 @@ #define _GLIBCXX_USE_CXX11_ABI 0 #include "string-inst.cc" -#include <istream> -#include <ostream> - #if ! _GLIBCXX_USE_DUAL_ABI # error This file should not be compiled for this configuration. #endif -namespace std _GLIBCXX_VISIBILITY(default) -{ -_GLIBCXX_BEGIN_NAMESPACE_VERSION - - // These came from c++98/misc-inst.cc, repeat them for COW string - // string related to iostreams. - template - basic_istream<char>& - operator>>(basic_istream<char>&, string&); - template - basic_ostream<char>& - operator<<(basic_ostream<char>&, const string&); - template - basic_istream<char>& - getline(basic_istream<char>&, string&, char); - template - basic_istream<char>& - getline(basic_istream<char>&, string&); - -_GLIBCXX_END_NAMESPACE_VERSION -} // namespace - #ifdef _GLIBCXX_USE_C99_STDINT_TR1 #include <random> #if defined __i386__ || defined __x86_64__ diff --git a/libstdc++-v3/src/c++11/cow-string-io-inst.cc b/libstdc++-v3/src/c++11/cow-string-io-inst.cc new file mode 100644 index 00000000000..caafd2eec83 --- /dev/null +++ b/libstdc++-v3/src/c++11/cow-string-io-inst.cc @@ -0,0 +1,59 @@ +// Reference-counted COW string instantiations for I/O -*- C++ -*- + +// Copyright (C) 2014-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. + +// 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/>. + +// +// ISO C++ 14882: 21 Strings library +// + +#define _GLIBCXX_USE_CXX11_ABI 0 +#include <istream> +#include <ostream> + +#if ! _GLIBCXX_USE_DUAL_ABI +# error This file should not be compiled for this configuration. +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // The equivalent SSO string instantiations are in c++98/misc-inst.cc, + // repeat them for COW string + + // string related to iostreams. + template + basic_istream<char>& + operator>>(basic_istream<char>&, string&); + template + basic_ostream<char>& + operator<<(basic_ostream<char>&, const string&); + template + basic_istream<char>& + getline(basic_istream<char>&, string&, char); + template + basic_istream<char>& + getline(basic_istream<char>&, string&); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/src/c++11/cow-wstring-inst.cc b/libstdc++-v3/src/c++11/cow-wstring-inst.cc index 41e8759fd8c..a830a1f5542 100644 --- a/libstdc++-v3/src/c++11/cow-wstring-inst.cc +++ b/libstdc++-v3/src/c++11/cow-wstring-inst.cc @@ -33,32 +33,8 @@ #define C wchar_t #include "string-inst.cc" -#include <ostream> -#include <istream> - #if ! _GLIBCXX_USE_DUAL_ABI # error This file should not be compiled for this configuration. #endif -namespace std _GLIBCXX_VISIBILITY(default) -{ -_GLIBCXX_BEGIN_NAMESPACE_VERSION - - // XXX these came from c++98/misc-inst.cc, repeat them for COW string - // string related to iostreams - template - basic_istream<wchar_t>& - operator>>(basic_istream<wchar_t>&, wstring&); - template - basic_ostream<wchar_t>& - operator<<(basic_ostream<wchar_t>&, const wstring&); - template - basic_istream<wchar_t>& - getline(basic_istream<wchar_t>&, wstring&, wchar_t); - template - basic_istream<wchar_t>& - getline(basic_istream<wchar_t>&, wstring&); - -_GLIBCXX_END_NAMESPACE_VERSION -} // namespace #endif diff --git a/libstdc++-v3/src/c++11/cow-wstring-io-inst.cc b/libstdc++-v3/src/c++11/cow-wstring-io-inst.cc new file mode 100644 index 00000000000..b174d20ad86 --- /dev/null +++ b/libstdc++-v3/src/c++11/cow-wstring-io-inst.cc @@ -0,0 +1,63 @@ +// Reference-counted COW wide string instantiations for I/O -*- C++ -*- + +// Copyright (C) 2014-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. + +// 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/>. + +// +// ISO C++ 14882: 21 Strings library +// + +#define _GLIBCXX_USE_CXX11_ABI 0 +#include <bits/c++config.h> + +#ifdef _GLIBCXX_USE_WCHAR_T +#include <ostream> +#include <istream> + +#if ! _GLIBCXX_USE_DUAL_ABI +# error This file should not be compiled for this configuration. +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // The equivalent SSO wstring instantiations are in c++98/misc-inst.cc, + // repeat them for COW wstring + + // string related to iostreams + template + basic_istream<wchar_t>& + operator>>(basic_istream<wchar_t>&, wstring&); + template + basic_ostream<wchar_t>& + operator<<(basic_ostream<wchar_t>&, const wstring&); + template + basic_istream<wchar_t>& + getline(basic_istream<wchar_t>&, wstring&, wchar_t); + template + basic_istream<wchar_t>& + getline(basic_istream<wchar_t>&, wstring&); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif diff --git a/libstdc++-v3/src/c++11/functexcept.cc b/libstdc++-v3/src/c++11/functexcept.cc index 83a8d9ad132..ae741418130 100644 --- a/libstdc++-v3/src/c++11/functexcept.cc +++ b/libstdc++-v3/src/c++11/functexcept.cc @@ -20,20 +20,12 @@ // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. -// We don't want to change the type thrown by __throw_ios_failure (yet?) -#define _GLIBCXX_USE_CXX11_ABI 0 - #include <bits/functexcept.h> #include <cstdlib> #include <exception> #include <stdexcept> #include <new> #include <typeinfo> -#include <ios> -#include <system_error> -#include <future> -#include <functional> -#include <bits/regex_error.h> #include <stdarg.h> #ifdef _GLIBCXX_USE_NLS @@ -121,27 +113,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __throw_underflow_error(const char* __s __attribute__((unused))) { _GLIBCXX_THROW_OR_ABORT(underflow_error(_(__s))); } - void - __throw_ios_failure(const char* __s __attribute__((unused))) - { _GLIBCXX_THROW_OR_ABORT(ios_base::failure(_(__s))); } - - void - __throw_system_error(int __i __attribute__((unused))) - { _GLIBCXX_THROW_OR_ABORT(system_error(error_code(__i, - generic_category()))); } - - void - __throw_future_error(int __i __attribute__((unused))) - { _GLIBCXX_THROW_OR_ABORT(future_error(make_error_code(future_errc(__i)))); } - - void - __throw_bad_function_call() - { _GLIBCXX_THROW_OR_ABORT(bad_function_call()); } - - void - __throw_regex_error(regex_constants::error_type __ecode - __attribute__((unused))) - { _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode)); } - _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/src/c++11/functional.cc b/libstdc++-v3/src/c++11/functional.cc index 26f183fad34..d9f25e8966f 100644 --- a/libstdc++-v3/src/c++11/functional.cc +++ b/libstdc++-v3/src/c++11/functional.cc @@ -23,11 +23,16 @@ // <http://www.gnu.org/licenses/>. #include <functional> +#include <bits/functexcept.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + __throw_bad_function_call() + { _GLIBCXX_THROW_OR_ABORT(bad_function_call()); } + bad_function_call::~bad_function_call() noexcept = default; const char* diff --git a/libstdc++-v3/src/c++11/future.cc b/libstdc++-v3/src/c++11/future.cc index 7809a371db4..8b28a9c662f 100644 --- a/libstdc++-v3/src/c++11/future.cc +++ b/libstdc++-v3/src/c++11/future.cc @@ -23,6 +23,7 @@ // <http://www.gnu.org/licenses/>. #include <future> +#include <bits/functexcept.h> namespace { @@ -70,6 +71,10 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + __throw_future_error(int __i __attribute__((unused))) + { _GLIBCXX_THROW_OR_ABORT(future_error(make_error_code(future_errc(__i)))); } + const error_category& future_category() noexcept { return __future_category_instance(); } diff --git a/libstdc++-v3/src/c++11/ios.cc b/libstdc++-v3/src/c++11/ios.cc index e0c14ecf8e1..f65f7e35a50 100644 --- a/libstdc++-v3/src/c++11/ios.cc +++ b/libstdc++-v3/src/c++11/ios.cc @@ -26,13 +26,29 @@ // ISO C++ 14882: 27.4 Iostreams base classes // +// Determines the version of ios_base::failure thrown by __throw_ios_failure. +// If !_GLIBCXX_USE_DUAL_ABI this will get undefined automatically. +#define _GLIBCXX_USE_CXX11_ABI 0 + #include <ios> #include <limits> +#include <bits/functexcept.h> + +#ifdef _GLIBCXX_USE_NLS +# include <libintl.h> +# define _(msgid) gettext (msgid) +#else +# define _(msgid) (msgid) +#endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + __throw_ios_failure(const char* __s __attribute__((unused))) + { _GLIBCXX_THROW_OR_ABORT(ios_base::failure(_(__s))); } + // Definitions for static const members of ios_base. const ios_base::fmtflags ios_base::boolalpha; const ios_base::fmtflags ios_base::dec; diff --git a/libstdc++-v3/src/c++11/regex.cc b/libstdc++-v3/src/c++11/regex.cc index 0abc728109c..d3a090eca4d 100644 --- a/libstdc++-v3/src/c++11/regex.cc +++ b/libstdc++-v3/src/c++11/regex.cc @@ -24,11 +24,17 @@ #include <stdexcept> #include <bits/regex_error.h> +#include <bits/functexcept.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + __throw_regex_error(regex_constants::error_type __ecode + __attribute__((unused))) + { _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode)); } + regex_error::regex_error(regex_constants::error_type __ecode) : std::runtime_error("regex_error"), _M_code(__ecode) { } diff --git a/libstdc++-v3/src/c++11/snprintf_lite.cc b/libstdc++-v3/src/c++11/snprintf_lite.cc index d92fe45db22..2ddcdf353ac 100644 --- a/libstdc++-v3/src/c++11/snprintf_lite.cc +++ b/libstdc++-v3/src/c++11/snprintf_lite.cc @@ -52,7 +52,7 @@ namespace __gnu_cxx { const size_t __len = __bufend - __buf + 1; const char __err[] = "not enough space for format expansion " - "(Please submit full bug report at http://gcc.gnu.org/bugs.html):\n "; + "(Please submit full bug report at https://gcc.gnu.org/bugs/):\n "; const size_t __errlen = sizeof(__err) - 1; char *const __e @@ -71,19 +71,17 @@ namespace __gnu_cxx { // Returns number of characters appended, or -1 if BUFSIZE is too small. int __concat_size_t(char *__buf, size_t __bufsize, size_t __val) { - // __int_to_char is explicitly instantiated and available only for - // some, but not all, types. See locale-inst.cc. -#ifdef _GLIBCXX_USE_LONG_LONG - unsigned long long __val2 = __val; -#else - unsigned long __val2 = __val; -#endif // Long enough for decimal representation. - int __ilen = 3 * sizeof(__val2); + int __ilen = 3 * sizeof(__val); char *__cs = static_cast<char*>(__builtin_alloca(__ilen)); - size_t __len = std::__int_to_char(__cs + __ilen, __val2, - std::__num_base::_S_atoms_out, - std::ios_base::dec, true); + char* __out = __cs + __ilen; + do + { + *--__out = "0123456789"[__val % 10]; + __val /= 10; + } + while (__val != 0); + size_t __len = __cs + __ilen - __out; if (__bufsize < __len) return -1; diff --git a/libstdc++-v3/src/c++11/sso_string.cc b/libstdc++-v3/src/c++11/sso_string.cc new file mode 100644 index 00000000000..a59db1aac3f --- /dev/null +++ b/libstdc++-v3/src/c++11/sso_string.cc @@ -0,0 +1,107 @@ +// Helper for accessing __cxx11::string from the ABI -*- C++ -*- + +// Copyright (C) 2014-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. + +// 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/>. + + +#define _GLIBCXX_USE_CXX11_ABI 1 +#define __sso_string __sso_stringxxx +#include <string> +#include <stdexcept> +#undef __sso_string + +#if ! _GLIBCXX_USE_DUAL_ABI +# error This file should not be compiled for this configuration. +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wabi-tag" + // Redefine __sso_string so that we can define and export its members + // in terms of the SSO std::string. + struct __sso_string + { + struct __str + { + const char* _M_p; + size_t _M_string_length; + char _M_local_buf[16]; + }; + + union { + __str _M_s; + char _M_bytes[sizeof(_M_s)]; + std::string _M_str; + }; + + __sso_string(); + __sso_string(const std::string& s); + __sso_string(const char*, size_t n); + __sso_string(const __sso_string&) noexcept; + __sso_string& operator=(const __sso_string&) noexcept; + ~__sso_string(); + __sso_string(__sso_string&&) noexcept; + __sso_string& operator=(__sso_string&&) noexcept; + }; +#pragma GCC diagnostic pop + + __sso_string::__sso_string() : _M_str() { } + +#if _GLIBCXX_USE_CXX11_ABI + static_assert(sizeof(__sso_string) == sizeof(std::string), + "sizeof(std::string) has changed"); + static_assert(alignof(__sso_string) == alignof(std::string), + "alignof(std::string) has changed"); + + // This constructor is defined in src/c++11/cow-stdexcept.cc for COW strings + __sso_string::__sso_string(const std::string& s) : _M_str(s) { } +#endif + + __sso_string::__sso_string(const char* s, size_t n) : _M_str(s, n) { } + + __sso_string::__sso_string(const __sso_string& s) noexcept + : _M_str(s._M_str) { } + + __sso_string& + __sso_string::operator=(const __sso_string& s) noexcept + { + _M_str = s._M_str; + return *this; + } + + __sso_string::~__sso_string() { _M_str.~basic_string(); } + + __sso_string::__sso_string(__sso_string&& s) noexcept + : _M_str(std::move(s._M_str)) { } + + __sso_string& + __sso_string::operator=(__sso_string&& s) noexcept + { + _M_str = std::move(s._M_str); + return *this; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/src/c++11/string-io-inst.cc b/libstdc++-v3/src/c++11/string-io-inst.cc new file mode 100644 index 00000000000..7c063d46a6d --- /dev/null +++ b/libstdc++-v3/src/c++11/string-io-inst.cc @@ -0,0 +1,53 @@ +// SSO string instantiations for I/O -*- C++ -*- + +// Copyright (C) 1997-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. + +// 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/>. + +// +// ISO C++ 14882: +// + +#define _GLIBCXX_USE_CXX11_ABI 1 +#include <string> +#include <istream> +#include <ostream> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // string related to iostreams + template + basic_istream<char>& + operator>>(basic_istream<char>&, string&); + template + basic_ostream<char>& + operator<<(basic_ostream<char>&, const string&); + template + basic_istream<char>& + getline(basic_istream<char>&, string&, char); + template + basic_istream<char>& + getline(basic_istream<char>&, string&); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/src/c++11/system_error.cc b/libstdc++-v3/src/c++11/system_error.cc index 6a092dfc4b6..41726e483ac 100644 --- a/libstdc++-v3/src/c++11/system_error.cc +++ b/libstdc++-v3/src/c++11/system_error.cc @@ -75,6 +75,12 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + __throw_system_error(int __i __attribute__((unused))) + { + _GLIBCXX_THROW_OR_ABORT(system_error(error_code(__i, generic_category()))); + } + error_category::~error_category() noexcept = default; const error_category& @@ -112,73 +118,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif -#if _GLIBCXX_USE_DUAL_ABI -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wabi-tag" - // Redefine __sso_string so that we can define and export its members - // in terms of the SSO std::string. - struct __sso_string - { - struct __str - { - const char* _M_p; - size_t _M_string_length; - char _M_local_buf[16]; - }; - - union { - __str _M_s; - char _M_bytes[sizeof(_M_s)]; - std::string _M_str; - }; - - __sso_string(); - __sso_string(const std::string& s); - __sso_string(const char*, size_t n); - __sso_string(const __sso_string&) noexcept; - __sso_string& operator=(const __sso_string&) noexcept; - ~__sso_string(); - __sso_string(__sso_string&&) noexcept; - __sso_string& operator=(__sso_string&&) noexcept; - }; -#pragma GCC diagnostic pop - - __sso_string::__sso_string() : _M_str() { } - -#if _GLIBCXX_USE_CXX11_ABI - static_assert(sizeof(__sso_string) == sizeof(std::string), - "sizeof(std::string) has changed"); - static_assert(alignof(__sso_string) == alignof(std::string), - "alignof(std::string) has changed"); - - // This constructor is defined in src/c++11/cow-stdexcept.cc for COW strings - __sso_string::__sso_string(const std::string& s) : _M_str(s) { } -#endif - - __sso_string::__sso_string(const char* s, size_t n) : _M_str(s, n) { } - - __sso_string::__sso_string(const __sso_string& s) noexcept - : _M_str(s._M_str) { } - - __sso_string& - __sso_string::operator=(const __sso_string& s) noexcept - { - _M_str = s._M_str; - return *this; - } - - __sso_string::~__sso_string() { _M_str.~basic_string(); } - - __sso_string::__sso_string(__sso_string&& s) noexcept - : _M_str(std::move(s._M_str)) { } - - __sso_string& - __sso_string::operator=(__sso_string&& s) noexcept - { - _M_str = std::move(s._M_str); - return *this; - } -#endif // _GLIBCXX_USE_DUAL_ABI - _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/src/c++11/wstring-io-inst.cc b/libstdc++-v3/src/c++11/wstring-io-inst.cc new file mode 100644 index 00000000000..0fae8210d9a --- /dev/null +++ b/libstdc++-v3/src/c++11/wstring-io-inst.cc @@ -0,0 +1,55 @@ +// SSO string instantiations for I/O -*- C++ -*- + +// Copyright (C) 1997-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. + +// 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/>. + +// +// ISO C++ 14882: +// + +#define _GLIBCXX_USE_CXX11_ABI 1 +#include <string> +#include <istream> +#include <ostream> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // string related to iostreams +#ifdef _GLIBCXX_USE_WCHAR_T + template + basic_istream<wchar_t>& + operator>>(basic_istream<wchar_t>&, wstring&); + template + basic_ostream<wchar_t>& + operator<<(basic_ostream<wchar_t>&, const wstring&); + template + basic_istream<wchar_t>& + getline(basic_istream<wchar_t>&, wstring&, wchar_t); + template + basic_istream<wchar_t>& + getline(basic_istream<wchar_t>&, wstring&); +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/src/c++98/misc-inst.cc b/libstdc++-v3/src/c++98/misc-inst.cc index f4be0387145..052165bda8b 100644 --- a/libstdc++-v3/src/c++98/misc-inst.cc +++ b/libstdc++-v3/src/c++98/misc-inst.cc @@ -36,34 +36,6 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - // string related to iostreams - template - basic_istream<char>& - operator>>(basic_istream<char>&, string&); - template - basic_ostream<char>& - operator<<(basic_ostream<char>&, const string&); - template - basic_istream<char>& - getline(basic_istream<char>&, string&, char); - template - basic_istream<char>& - getline(basic_istream<char>&, string&); -#ifdef _GLIBCXX_USE_WCHAR_T - template - basic_istream<wchar_t>& - operator>>(basic_istream<wchar_t>&, wstring&); - template - basic_ostream<wchar_t>& - operator<<(basic_ostream<wchar_t>&, const wstring&); - template - basic_istream<wchar_t>& - getline(basic_istream<wchar_t>&, wstring&, wchar_t); - template - basic_istream<wchar_t>& - getline(basic_istream<wchar_t>&, wstring&); -#endif - #if _GLIBCXX_USE_CXX11_ABI // C++98 members that are not instantiated by src/c++11/string-inst.cc // because they changed in C++11 to take const_iterator parameters. 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 807b291f8d2..acbfab00992 100644 --- a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc +++ b/libstdc++-v3/testsuite/20_util/duration/literals/range.cc @@ -27,5 +27,5 @@ test01() // std::numeric_limits<int64_t>::max() == 9223372036854775807; auto h = 9223372036854775808h; - // { dg-error "cannot be represented" "" { target *-*-* } 797 } + // { dg-error "cannot be represented" "" { target *-*-* } 798 } } 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"); |