diff options
author | Martin Liska <mliska@suse.cz> | 2022-10-17 10:19:50 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-10-17 10:19:50 +0200 |
commit | 6c22519f33270a689fc8730ceff9212b376ed40d (patch) | |
tree | ac49e01b1cca30f8ae20e7089840c34593cf76a7 | |
parent | 2c92cfe87d2bb8aa0eb78f3932fca16699cb35c9 (diff) | |
parent | f10b9f64133cbfb5ba06f4deb23766f92629bdd9 (diff) | |
download | gcc-6c22519f33270a689fc8730ceff9212b376ed40d.zip gcc-6c22519f33270a689fc8730ceff9212b376ed40d.tar.gz gcc-6c22519f33270a689fc8730ceff9212b376ed40d.tar.bz2 |
Merge branch 'master' into devel/sphinx
-rw-r--r-- | gcc/ChangeLog | 19 | ||||
-rw-r--r-- | gcc/DATESTAMP | 2 | ||||
-rw-r--r-- | gcc/common/config/i386/cpuinfo.h | 6 | ||||
-rw-r--r-- | gcc/common/config/i386/i386-common.cc | 4 | ||||
-rw-r--r-- | gcc/config.gcc | 5 | ||||
-rw-r--r-- | gcc/config/h8300/constraints.md | 27 | ||||
-rw-r--r-- | gcc/config/h8300/h8300.cc | 2 | ||||
-rw-r--r-- | gcc/config/h8300/h8300.h | 12 | ||||
-rw-r--r-- | gcc/config/h8300/movepush.md | 8 | ||||
-rw-r--r-- | libstdc++-v3/ChangeLog | 31 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/charconv.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_map.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_pair.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/uses_allocator_args.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/std/charconv | 41 | ||||
-rw-r--r-- | libstdc++-v3/include/std/version | 1 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/debug.cc | 16 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/from_chars/constexpr.cc | 57 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/to_chars/constexpr.cc | 172 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/to_chars/version.cc | 16 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc | 52 |
21 files changed, 446 insertions, 36 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c1fc2ec..a687dc5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,22 @@ +2022-10-16 Jeff Law <jeffreyalaw@gmail.com> + + * config/h8300/constraints.md (Z0..Z7): New register + constraints. + * config/h8300/h8300.h (reg_class): Add new classes. + (REG_CLASS_NAMES): Similarly. + (REG_CLASS_CONTENTS): Similarly. + +2022-10-16 Jeff Law <jeffreyalaw@gmail.com> + + * config/h8300/constraints.md (Zz constraint): Renamed + from "z". + * config/h8300/movepush.md (movqi_h8sx, movhi_h8sx): Adjust + constraint to use Zz instead of Z. + +2022-10-16 Jeff Law <jeffreyalaw@gmail.com> + + * config/h8300/h8300.cc (h8300_register_move_cost): Fix typo. + 2022-10-14 Aldy Hernandez <aldyh@redhat.com> * value-range.cc (frange::set): Implement distinction between diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 88e8f3f..856b00b 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20221015 +20221017 diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h index bbced8a..b5c1b21 100644 --- a/gcc/common/config/i386/cpuinfo.h +++ b/gcc/common/config/i386/cpuinfo.h @@ -496,6 +496,12 @@ get_intel_cpu (struct __processor_model *cpu_model, case 0x9a: case 0xbf: /* Alder Lake. */ + case 0xb7: + /* Raptor Lake. */ + case 0xb5: + case 0xaa: + case 0xac: + /* Meteor Lake. */ cpu = "alderlake"; CHECK___builtin_cpu_is ("corei7"); CHECK___builtin_cpu_is ("alderlake"); diff --git a/gcc/common/config/i386/i386-common.cc b/gcc/common/config/i386/i386-common.cc index c0c2ad7..d6a68dc 100644 --- a/gcc/common/config/i386/i386-common.cc +++ b/gcc/common/config/i386/i386-common.cc @@ -1929,6 +1929,10 @@ const pta processor_alias_table[] = M_CPU_SUBTYPE (INTEL_COREI7_SAPPHIRERAPIDS), P_PROC_AVX512F}, {"alderlake", PROCESSOR_ALDERLAKE, CPU_HASWELL, PTA_ALDERLAKE, M_CPU_SUBTYPE (INTEL_COREI7_ALDERLAKE), P_PROC_AVX2}, + {"raptorlake", PROCESSOR_ALDERLAKE, CPU_HASWELL, PTA_ALDERLAKE, + M_CPU_SUBTYPE (INTEL_COREI7_ALDERLAKE), P_PROC_AVX2}, + {"meteorlake", PROCESSOR_ALDERLAKE, CPU_HASWELL, PTA_ALDERLAKE, + M_CPU_SUBTYPE (INTEL_COREI7_ALDERLAKE), P_PROC_AVX2}, {"bonnell", PROCESSOR_BONNELL, CPU_ATOM, PTA_BONNELL, M_CPU_TYPE (INTEL_BONNELL), P_PROC_SSSE3}, {"atom", PROCESSOR_BONNELL, CPU_ATOM, PTA_BONNELL, diff --git a/gcc/config.gcc b/gcc/config.gcc index 8d5972f..2af30b4 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1082,6 +1082,11 @@ case ${target} in # Assume that newlib is being used and so __cxa_atexit is provided. default_use_cxa_atexit=yes use_gcc_stdint=wrap + + case "${with_newlib}-${with_headers}" in + no-no) use_gcc_stdint=provide ;; + *) ;; + esac ;; esac diff --git a/gcc/config/h8300/constraints.md b/gcc/config/h8300/constraints.md index 2836232..6eaffc1 100644 --- a/gcc/config/h8300/constraints.md +++ b/gcc/config/h8300/constraints.md @@ -211,8 +211,33 @@ (and (match_code "const_int") (match_test "exact_log2 (ival & 0xff) != -1"))) -(define_constraint "Z" +(define_constraint "Zz" "@internal" (and (match_test "TARGET_H8300SX") (match_code "mem") (match_test "CONSTANT_P (XEXP (op, 0))"))) + +(define_register_constraint "Z0" "NOT_R0_REGS" + "@internal") + +(define_register_constraint "Z1" "NOT_R1_REGS" + "@internal") + +(define_register_constraint "Z2" "NOT_R2_REGS" + "@internal") + +(define_register_constraint "Z3" "NOT_R3_REGS" + "@internal") + +(define_register_constraint "Z4" "NOT_R4_REGS" + "@internal") + +(define_register_constraint "Z5" "NOT_R5_REGS" + "@internal") + +(define_register_constraint "Z6" "NOT_R6_REGS" + "@internal") + +(define_register_constraint "Z7" "NOT_SP_REGS" + "@internal") + diff --git a/gcc/config/h8300/h8300.cc b/gcc/config/h8300/h8300.cc index 78cf15f..be3e385 100644 --- a/gcc/config/h8300/h8300.cc +++ b/gcc/config/h8300/h8300.cc @@ -1140,7 +1140,7 @@ static int h8300_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED, reg_class_t from, reg_class_t to) { - if (from == MAC_REGS || to == MAC_REG) + if (from == MAC_REGS || to == MAC_REGS) return 6; else return 3; diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h index 9a6c78c..45cc4fc 100644 --- a/gcc/config/h8300/h8300.h +++ b/gcc/config/h8300/h8300.h @@ -282,6 +282,8 @@ extern const char * const *h8_reg_names; enum reg_class { NO_REGS, COUNTER_REGS, SOURCE_REGS, DESTINATION_REGS, + NOT_R0_REGS, NOT_R1_REGS, NOT_R2_REGS, NOT_R3_REGS, + NOT_R4_REGS, NOT_R5_REGS, NOT_R6_REGS, NOT_SP_REGS, GENERAL_REGS, MAC_REGS, ALL_REGS, LIM_REG_CLASSES }; @@ -291,6 +293,8 @@ enum reg_class { #define REG_CLASS_NAMES \ { "NO_REGS", "COUNTER_REGS", "SOURCE_REGS", "DESTINATION_REGS", \ + "NOT_R0_REGS", "NOT_R1_REGS", "NOT_R2_REGS", "NOT_R3_REGS", \ + "NOT_R4_REGS", "NOT_R5_REGS", "NOT_R6_REGS", "NOT_SP_REGS", \ "GENERAL_REGS", "MAC_REGS", "ALL_REGS", "LIM_REGS" } /* Define which registers fit in which classes. @@ -302,6 +306,14 @@ enum reg_class { {0x010}, /* COUNTER_REGS */ \ {0x020}, /* SOURCE_REGS */ \ {0x040}, /* DESTINATION_REGS */ \ + {0x0fe}, /* NOT_R0_REGS */ \ + {0x0fd}, /* NOT_R1_REGS */ \ + {0x0fb}, /* NOT_R2_REGS */ \ + {0x0f7}, /* NOT_R3_REGS */ \ + {0x0ef}, /* NOT_R4_REGS */ \ + {0x0df}, /* NOT_R5_REGS */ \ + {0x0bf}, /* NOT_R6_REGS */ \ + {0x07f}, /* NOT_SP_REGS */ \ {0xeff}, /* GENERAL_REGS */ \ {0x100}, /* MAC_REGS */ \ {0xfff}, /* ALL_REGS */ \ diff --git a/gcc/config/h8300/movepush.md b/gcc/config/h8300/movepush.md index ada4ddd..e895de8 100644 --- a/gcc/config/h8300/movepush.md +++ b/gcc/config/h8300/movepush.md @@ -28,7 +28,7 @@ [(set (attr "length") (symbol_ref "compute_mov_length (operands)"))]) (define_insn_and_split "*movqi_h8sx" - [(set (match_operand:QI 0 "general_operand_dst" "=Z,rQ") + [(set (match_operand:QI 0 "general_operand_dst" "=Zz,rQ") (match_operand:QI 1 "general_operand_src" "P4>X,rQi"))] "TARGET_H8300SX" "#" @@ -37,7 +37,7 @@ (clobber (reg:CC CC_REG))])]) (define_insn "*movqi_h8sx<cczn>" - [(set (match_operand:QI 0 "general_operand_dst" "=Z,rQ") + [(set (match_operand:QI 0 "general_operand_dst" "=Zz,rQ") (match_operand:QI 1 "general_operand_src" "P4>X,rQi")) (clobber (reg:CC CC_REG))] "TARGET_H8300SX" @@ -113,7 +113,7 @@ [(set (attr "length") (symbol_ref "compute_mov_length (operands)"))]) (define_insn_and_split "*movhi_h8sx" - [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Z,Q,rQ") + [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Zz,Q,rQ") (match_operand:HI 1 "general_operand_src" "I,P3>X,P4>X,IP8>X,rQi"))] "TARGET_H8300SX" "#" @@ -122,7 +122,7 @@ (clobber (reg:CC CC_REG))])]) (define_insn "*movhi_h8sx<cczn>" - [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Z,Q,rQ") + [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Zz,Q,rQ") (match_operand:HI 1 "general_operand_src" "I,P3>X,P4>X,IP8>X,rQi")) (clobber (reg:CC CC_REG))] "TARGET_H8300SX" diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8166bc9..9ff3e3f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,34 @@ +2022-10-15 Jonathan Wakely <jwakely@redhat.com> + + * src/c++11/debug.cc (print_raw): Move inside #if block. + +2022-10-15 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/charconv.h (__to_chars_10_impl): Add constexpr + for C++23. Remove 'static' from array. + * include/std/charconv (__cpp_lib_constexpr_charconv): Define. + (__to_chars, __to_chars_16): Remove 'static' from array, add + constexpr. + (__to_chars_10, __to_chars_8, __to_chars_2, __to_chars_i) + (to_chars, __raise_and_add, __from_chars_pow2_base) + (__from_chars_alnum, from_chars): Add constexpr. + (__from_chars_alnum_to_val): Avoid local static during constant + evaluation. Add constexpr. + * include/std/version (__cpp_lib_constexpr_charconv): Define. + * testsuite/20_util/from_chars/constexpr.cc: New test. + * testsuite/20_util/to_chars/constexpr.cc: New test. + * testsuite/20_util/to_chars/version.cc: New test. + +2022-10-15 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/stl_map.h (map::insert(Pair&&)): Use + remove_const_t on argument to __is_pair. + * include/bits/stl_pair.h (__is_pair<const pair<T,U>>): Remove + partial specialization. + * include/bits/uses_allocator_args.h (_Std_pair): Use + remove_cv_t as per LWG 3677. + * testsuite/20_util/uses_allocator/lwg3677.cc: New test. + 2022-10-14 Jonathan Wakely <jwakely@redhat.com> * libsupc++/eh_alloc.cc [USE_POOL]: New macro. diff --git a/libstdc++-v3/include/bits/charconv.h b/libstdc++-v3/include/bits/charconv.h index 4cae10a..d04aab7 100644 --- a/libstdc++-v3/include/bits/charconv.h +++ b/libstdc++-v3/include/bits/charconv.h @@ -68,13 +68,13 @@ namespace __detail // The caller is required to provide a buffer of exactly the right size // (which can be determined by the __to_chars_len function). template<typename _Tp> - void + _GLIBCXX23_CONSTEXPR void __to_chars_10_impl(char* __first, unsigned __len, _Tp __val) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); static_assert(is_unsigned<_Tp>::value, "implementation bug"); - static constexpr char __digits[201] = + constexpr char __digits[201] = "0001020304050607080910111213141516171819" "2021222324252627282930313233343536373839" "4041424344454647484950515253545556575859" diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index 9c2b074..83c579a 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -847,7 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { #if __cplusplus >= 201703L using _P2 = remove_reference_t<_Pair>; - if constexpr (__is_pair<_P2>) + if constexpr (__is_pair<remove_const_t<_P2>>) if constexpr (is_same_v<allocator_type, allocator<value_type>>) if constexpr (__usable_key<typename _P2::first_type>) { diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index d0f07b0..1951670 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -889,9 +889,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp, typename _Up> inline constexpr bool __is_pair<pair<_Tp, _Up>> = true; - - template<typename _Tp, typename _Up> - inline constexpr bool __is_pair<const pair<_Tp, _Up>> = true; #endif /// @cond undocumented diff --git a/libstdc++-v3/include/bits/uses_allocator_args.h b/libstdc++-v3/include/bits/uses_allocator_args.h index ef5c4ff..77e4860 100644 --- a/libstdc++-v3/include/bits/uses_allocator_args.h +++ b/libstdc++-v3/include/bits/uses_allocator_args.h @@ -44,7 +44,7 @@ namespace std _GLIBCXX_VISIBILITY(default) _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> - concept _Std_pair = __is_pair<_Tp>; + concept _Std_pair = __is_pair<remove_cv_t<_Tp>>; /** @addtogroup allocators * @{ diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv index 64d0584..4b6cc83 100644 --- a/libstdc++-v3/include/std/charconv +++ b/libstdc++-v3/include/std/charconv @@ -50,6 +50,10 @@ # define __cpp_lib_to_chars 201611L #endif +#if __cplusplus > 202002L +# define __cpp_lib_constexpr_charconv 202202L +#endif + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -119,7 +123,7 @@ namespace __detail // Generic implementation for arbitrary bases. template<typename _Tp> - to_chars_result + constexpr to_chars_result __to_chars(char* __first, char* __last, _Tp __val, int __base) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); @@ -138,7 +142,7 @@ namespace __detail unsigned __pos = __len - 1; - static constexpr char __digits[] = { + constexpr char __digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', @@ -160,7 +164,7 @@ namespace __detail } template<typename _Tp> - __integer_to_chars_result_type<_Tp> + constexpr __integer_to_chars_result_type<_Tp> __to_chars_16(char* __first, char* __last, _Tp __val) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); @@ -177,7 +181,7 @@ namespace __detail return __res; } - static constexpr char __digits[] = { + constexpr char __digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; @@ -207,7 +211,7 @@ namespace __detail } template<typename _Tp> - inline __integer_to_chars_result_type<_Tp> + constexpr __integer_to_chars_result_type<_Tp> __to_chars_10(char* __first, char* __last, _Tp __val) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); @@ -231,7 +235,7 @@ namespace __detail } template<typename _Tp> - __integer_to_chars_result_type<_Tp> + constexpr __integer_to_chars_result_type<_Tp> __to_chars_8(char* __first, char* __last, _Tp __val) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); @@ -285,7 +289,7 @@ namespace __detail } template<typename _Tp> - __integer_to_chars_result_type<_Tp> + constexpr __integer_to_chars_result_type<_Tp> __to_chars_2(char* __first, char* __last, _Tp __val) noexcept { static_assert(is_integral<_Tp>::value, "implementation bug"); @@ -322,7 +326,7 @@ namespace __detail } // namespace __detail template<typename _Tp> - __detail::__integer_to_chars_result_type<_Tp> + constexpr __detail::__integer_to_chars_result_type<_Tp> __to_chars_i(char* __first, char* __last, _Tp __value, int __base = 10) { __glibcxx_assert(2 <= __base && __base <= 36); @@ -361,7 +365,7 @@ namespace __detail } #define _GLIBCXX_TO_CHARS(T) \ - inline to_chars_result \ + _GLIBCXX23_CONSTEXPR inline to_chars_result \ to_chars(char* __first, char* __last, T __value, int __base = 10) \ { return std::__to_chars_i<T>(__first, __last, __value, __base); } _GLIBCXX_TO_CHARS(char) @@ -400,7 +404,7 @@ _GLIBCXX_TO_CHARS(unsigned __GLIBCXX_TYPE_INT_N_3) namespace __detail { template<typename _Tp> - bool + constexpr bool __raise_and_add(_Tp& __val, int __base, unsigned char __c) { if (__builtin_mul_overflow(__val, __base, &__val) @@ -429,18 +433,27 @@ namespace __detail return __table; } +#if __cpp_lib_constexpr_charconv + template<bool _DecOnly> + inline constexpr auto __table = __from_chars_alnum_to_val_table(); +#endif + // If _DecOnly is true: if the character is a decimal digit, then // return its corresponding base-10 value, otherwise return a value >= 127. // If _DecOnly is false: if the character is an alphanumeric digit, then // return its corresponding base-36 value, otherwise return a value >= 127. template<bool _DecOnly = false> - unsigned char + _GLIBCXX23_CONSTEXPR unsigned char __from_chars_alnum_to_val(unsigned char __c) { if _GLIBCXX17_CONSTEXPR (_DecOnly) return static_cast<unsigned char>(__c - '0'); else { +#if __cpp_lib_constexpr_charconv + if (std::__is_constant_evaluated()) + return __table<_DecOnly>.__data[__c]; +#endif // This initializer is deliberately made dependent in order to work // around modules bug PR105322. static constexpr auto __table = (_DecOnly, __from_chars_alnum_to_val_table()); @@ -451,7 +464,7 @@ namespace __detail /// std::from_chars implementation for integers in a power-of-two base. /// If _DecOnly is true, then we may assume __base is at most 8. template<bool _DecOnly, typename _Tp> - bool + _GLIBCXX23_CONSTEXPR bool __from_chars_pow2_base(const char*& __first, const char* __last, _Tp& __val, int __base) { @@ -508,7 +521,7 @@ namespace __detail /// std::from_chars implementation for integers in any base. /// If _DecOnly is true, then we may assume __base is at most 10. template<bool _DecOnly, typename _Tp> - bool + constexpr bool __from_chars_alnum(const char*& __first, const char* __last, _Tp& __val, int __base) { @@ -548,7 +561,7 @@ namespace __detail /// std::from_chars for integral types. template<typename _Tp> - __detail::__integer_from_chars_result_type<_Tp> + _GLIBCXX23_CONSTEXPR __detail::__integer_from_chars_result_type<_Tp> from_chars(const char* __first, const char* __last, _Tp& __value, int __base = 10) { diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index 397a4aa..bec9e7a 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -302,6 +302,7 @@ #if __cplusplus > 202002L // c++23 #define __cpp_lib_byteswap 202110L +#define __cpp_lib_constexpr_charconv 202202L #define __cpp_lib_constexpr_typeinfo 202106L #if __cpp_concepts >= 202002L # define __cpp_lib_expected 202202L diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc index f2b25fb..9eda380 100644 --- a/libstdc++-v3/src/c++11/debug.cc +++ b/libstdc++-v3/src/c++11/debug.cc @@ -610,14 +610,6 @@ namespace { print_word(ctx, word, Length - 1); } void - print_raw(PrintContext& ctx, const char* str, ptrdiff_t nbc) - { - if (nbc == -1) - nbc = INT_MAX; - ctx._M_column += fprintf(stderr, "%.*s", (int)nbc, str); - } - - void print_word(PrintContext& ctx, const char* word, ptrdiff_t nbc = -1) { size_t length = nbc >= 0 ? nbc : __builtin_strlen(word); @@ -1092,6 +1084,14 @@ namespace { print_string(ctx, str, nbc, nullptr, 0); } #if _GLIBCXX_HAVE_STACKTRACE + void + print_raw(PrintContext& ctx, const char* str, ptrdiff_t nbc) + { + if (nbc == -1) + nbc = INT_MAX; + ctx._M_column += fprintf(stderr, "%.*s", (int)nbc, str); + } + int print_backtrace(void* data, __UINTPTR_TYPE__ pc, const char* filename, int lineno, const char* function) diff --git a/libstdc++-v3/testsuite/20_util/from_chars/constexpr.cc b/libstdc++-v3/testsuite/20_util/from_chars/constexpr.cc new file mode 100644 index 0000000..6e14694 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/from_chars/constexpr.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++23" } +// { dg-do compile { target c++23 } } + +#include <charconv> +#include <testsuite_hooks.h> + +constexpr bool +test() +{ + const char str[] = "-01234afz###"; + const char* end = str + sizeof(str); + + std::from_chars_result res; + int ival = 99; + unsigned uval = 99; + + res = std::from_chars(str, str+1, ival, 10); + VERIFY( res.ptr == str ); + VERIFY( res.ec == std::errc::invalid_argument ); + VERIFY( ival == 99 ); + res = std::from_chars(str, str+4, ival, 10); + VERIFY( res.ptr == str+4 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( ival == -12 ); + res = std::from_chars(str, end, ival, 10); + VERIFY( res.ptr == str+6 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( ival == -1234 ); + + res = std::from_chars(str, end, uval, 10); + VERIFY( res.ptr == str ); + VERIFY( res.ec == std::errc::invalid_argument ); + VERIFY( uval == 99 ); + res = std::from_chars(str+1, end, uval, 10); + VERIFY( res.ptr == str+6 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( uval == 1234 ); + + res = std::from_chars(str, end, ival, 3); + VERIFY( res.ptr == str+4 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( ival == -5 ); + + res = std::from_chars(str, end, ival, 16); + VERIFY( res.ptr == str+8 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( ival == -1193135 ); + + res = std::from_chars(str+1, end, uval, 36); + VERIFY( res.ptr == str+1+8 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( uval == 2302953695 ); + + return true; +} + +static_assert( test() ); diff --git a/libstdc++-v3/testsuite/20_util/to_chars/constexpr.cc b/libstdc++-v3/testsuite/20_util/to_chars/constexpr.cc new file mode 100644 index 0000000..30c5916 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/to_chars/constexpr.cc @@ -0,0 +1,172 @@ +// { dg-options "-std=gnu++23" } +// { dg-do compile { target c++23 } } + +#include <charconv> + +#ifndef __cpp_lib_constexpr_charconv +# error "Feature-test macro for constexpr charconv missing in <charconv>" +#elif __cpp_lib_constexpr_charconv != 202202L +# error "Feature-test macro for constexpr charconv has wrong value in <charconv>" +#endif + +#include <testsuite_hooks.h> + +constexpr bool +test_base10() +{ + std::to_chars_result res; + char buf[10] = "XXXXXXXXX"; + res = std::to_chars(buf, buf+3, 1234); + VERIFY( res.ptr == buf+3 ); + VERIFY( res.ec == std::errc::value_too_large ); + res = std::to_chars(buf, buf+4, -1234); + VERIFY( res.ptr == buf+4 ); + VERIFY( res.ec == std::errc::value_too_large ); + res = std::to_chars(buf, buf+4, 1234); + VERIFY( res.ptr == buf+4 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( buf[0] == '1' ); + VERIFY( buf[1] == '2' ); + VERIFY( buf[2] == '3' ); + VERIFY( buf[3] == '4' ); + VERIFY( buf[4] == 'X' ); + res = std::to_chars(buf, buf+10, -567, 10); + VERIFY( res.ptr == buf+4 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( buf[0] == '-' ); + VERIFY( buf[1] == '5' ); + VERIFY( buf[2] == '6' ); + VERIFY( buf[3] == '7' ); + VERIFY( buf[4] == 'X' ); + return true; +} + +static_assert( test_base10() ); + +constexpr bool +test_base16() +{ + std::to_chars_result res; + char buf[10] = "XXXXXXXXX"; + res = std::to_chars(buf, buf+3, 0x1234, 16); + VERIFY( res.ptr == buf+3 ); + VERIFY( res.ec == std::errc::value_too_large ); + res = std::to_chars(buf, buf+4, -0x1234, 16); + VERIFY( res.ptr == buf+4 ); + VERIFY( res.ec == std::errc::value_too_large ); + res = std::to_chars(buf, buf+4, 0x1234, 16); + VERIFY( res.ptr == buf+4 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( buf[0] == '1' ); + VERIFY( buf[1] == '2' ); + VERIFY( buf[2] == '3' ); + VERIFY( buf[3] == '4' ); + VERIFY( buf[4] == 'X' ); + res = std::to_chars(buf, buf+10, -0x567, 16); + VERIFY( res.ptr == buf+4 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( buf[0] == '-' ); + VERIFY( buf[1] == '5' ); + VERIFY( buf[2] == '6' ); + VERIFY( buf[3] == '7' ); + VERIFY( buf[5] == 'X' ); + return true; +} + +static_assert( test_base16() ); + +constexpr bool +test_base8() +{ + std::to_chars_result res; + char buf[10] = "XXXXXXXXX"; + res = std::to_chars(buf, buf+2, 01234, 8); + VERIFY( res.ptr == buf+2 ); + VERIFY( res.ec == std::errc::value_too_large ); + res = std::to_chars(buf, buf+3, -01234, 8); + VERIFY( res.ptr == buf+3 ); + VERIFY( res.ec == std::errc::value_too_large ); + res = std::to_chars(buf, buf+4, 01234, 8); + VERIFY( res.ptr == buf+4 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( buf[0] == '1' ); + VERIFY( buf[1] == '2' ); + VERIFY( buf[2] == '3' ); + VERIFY( buf[3] == '4' ); + VERIFY( buf[4] == 'X' ); + res = std::to_chars(buf, buf+10, -0567, 8); + VERIFY( res.ptr == buf+4 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( buf[0] == '-' ); + VERIFY( buf[1] == '5' ); + VERIFY( buf[2] == '6' ); + VERIFY( buf[3] == '7' ); + VERIFY( buf[4] == 'X' ); + return true; +} + +static_assert( test_base8() ); + +constexpr bool +test_base2() +{ + std::to_chars_result res; + char buf[10] = "XXXXXXXXX"; + res = std::to_chars(buf, buf+4, 0b10001, 2); + VERIFY( res.ptr == buf+4 ); + VERIFY( res.ec == std::errc::value_too_large ); + res = std::to_chars(buf, buf+5, -0b10001, 2); + VERIFY( res.ptr == buf+5 ); + VERIFY( res.ec == std::errc::value_too_large ); + res = std::to_chars(buf, buf+5, 0b10001, 2); + VERIFY( res.ptr == buf+5 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( buf[0] == '1' ); + VERIFY( buf[1] == '0' ); + VERIFY( buf[2] == '0' ); + VERIFY( buf[3] == '0' ); + VERIFY( buf[4] == '1' ); + VERIFY( buf[5] == 'X' ); + res = std::to_chars(buf, buf+10, -0b11011, 2); + VERIFY( res.ptr == buf+6 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( buf[0] == '-' ); + VERIFY( buf[1] == '1' ); + VERIFY( buf[2] == '1' ); + VERIFY( buf[3] == '0' ); + VERIFY( buf[4] == '1' ); + VERIFY( buf[5] == '1' ); + VERIFY( buf[6] == 'X' ); + return true; +} + +static_assert( test_base2() ); + +constexpr bool +test_base36() +{ + std::to_chars_result res; + char buf[10] = "XXXXXXXXX"; + res = std::to_chars(buf, buf+1, 1234, 36); + VERIFY( res.ptr == buf+1 ); + VERIFY( res.ec == std::errc::value_too_large ); + res = std::to_chars(buf, buf+2, -1234, 36); + VERIFY( res.ptr == buf+2 ); + VERIFY( res.ec == std::errc::value_too_large ); + res = std::to_chars(buf, buf+3, 1234, 36); + VERIFY( res.ptr == buf+2 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( buf[0] == 'y' ); + VERIFY( buf[1] == 'a' ); + VERIFY( buf[3] == 'X' ); + res = std::to_chars(buf, buf+10, -567, 36); + VERIFY( res.ptr == buf+3 ); + VERIFY( res.ec == std::errc{} ); + VERIFY( buf[0] == '-' ); + VERIFY( buf[1] == 'f' ); + VERIFY( buf[2] == 'r' ); + VERIFY( buf[4] == 'X' ); + return true; +} + +static_assert( test_base36() ); diff --git a/libstdc++-v3/testsuite/20_util/to_chars/version.cc b/libstdc++-v3/testsuite/20_util/to_chars/version.cc new file mode 100644 index 0000000..af06e1b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/to_chars/version.cc @@ -0,0 +1,16 @@ +// { dg-options "-std=gnu++23" } +// { dg-do preprocess { target c++23 } } + +#include <version> + +#ifndef __cpp_lib_to_chars +# error "Feature-test macro for to_chars missing in <version>" +#elif __cpp_lib_to_chars != 201611L +# error "Feature-test macro for to_chars has wrong value in <version>" +#endif + +#ifndef __cpp_lib_constexpr_charconv +# error "Feature-test macro for constexpr charconv missing in <version>" +#elif __cpp_lib_constexpr_charconv != 202202L +# error "Feature-test macro for constexpr charconv has wrong value in <version>" +#endif diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc new file mode 100644 index 0000000..649b98d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3677.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++23" } +// { dg-do run { target c++20 } } + +#include <memory> +#include <testsuite_hooks.h> + +struct UsesAlloc +{ + using allocator_type = std::allocator<int>; + + bool passed_alloc; + + UsesAlloc(int) : passed_alloc(false) { } + + UsesAlloc(int, std::allocator<int>) : passed_alloc(true) { } +}; + +using Pair = std::pair<UsesAlloc, int>; + +void +test_const() +{ + std::allocator<int> a; + int i = 0; + auto p = std::make_obj_using_allocator<const Pair>(a, i, i); + VERIFY( p.first.passed_alloc ); +} + +void +test_volatile() +{ + std::allocator<int> a; + int i = 0; + auto p = std::make_obj_using_allocator<volatile Pair>(a, i, i); + VERIFY( p.first.passed_alloc ); +} + +void +test_const_volatile() +{ + std::allocator<int> a; + int i = 0; + auto p = std::make_obj_using_allocator<volatile Pair>(a, i, i); + VERIFY( p.first.passed_alloc ); +} + +int main() +{ + test_const(); + test_volatile(); + test_const_volatile(); +} |