From e8e98af7efc36cc9aeef90dc1a6d410e54a99aaf Mon Sep 17 00:00:00 2001 From: redi Date: Sun, 19 Feb 2017 16:04:35 +0000 Subject: [PATCH] C++17 GB50 resolution (P0505R0) 2017-02-19 Dinka Ranns C++17 GB50 resolution * include/std/chrono (duration::operator++()): Add _GLIBCXX17_CONSTEXPR. (duration::operator++(int)): Likewise. (duration::operator--()): Likewise. (duration::operator--(int)): Likewise. (duration::operator+=(const duration&)): Likewise. (duration::operator-=(const duration&)): Likewise. (duration::operator*=(const rep&)): Likewise. (duration::operator/=(const rep&)): Likewise. (duration::operator%=(const rep&)): Likewise. (duration::operator%=(const duration&)): Likewise. (time_point::operator+=(const duration&)): Likewise. (time_point::operator-=(const duration&)): Likewise. * testsuite/20_util/duration/arithmetic/constexpr_c++17.cc: New test. * testsuite/20_util/duration/literals/range.cc: Adjust dg-error. * testsuite/20_util/time_point/arithmetic/constexpr.cc: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245575 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 20 +++++++++++++ libstdc++-v3/include/std/chrono | 22 +++++++------- .../range.cc => arithmetic/constexpr_c++17.cc} | 34 +++++++++++++++------- .../testsuite/20_util/duration/literals/range.cc | 2 +- .../arithmetic/constexpr.cc} | 25 +++++++++------- 5 files changed, 72 insertions(+), 31 deletions(-) copy libstdc++-v3/testsuite/20_util/duration/{literals/range.cc => arithmetic/constexpr_c++17.cc} (65%) copy libstdc++-v3/testsuite/20_util/{duration/literals/range.cc => time_point/arithmetic/constexpr.cc} (65%) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 01efa3ed1a7..0b02dcac602 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,23 @@ +2017-02-19 Dinka Ranns + + C++17 GB50 resolution + * include/std/chrono (duration::operator++()): Add + _GLIBCXX17_CONSTEXPR. + (duration::operator++(int)): Likewise. + (duration::operator--()): Likewise. + (duration::operator--(int)): Likewise. + (duration::operator+=(const duration&)): Likewise. + (duration::operator-=(const duration&)): Likewise. + (duration::operator*=(const rep&)): Likewise. + (duration::operator/=(const rep&)): Likewise. + (duration::operator%=(const rep&)): Likewise. + (duration::operator%=(const duration&)): Likewise. + (time_point::operator+=(const duration&)): Likewise. + (time_point::operator-=(const duration&)): Likewise. + * testsuite/20_util/duration/arithmetic/constexpr_c++17.cc: New test. + * testsuite/20_util/duration/literals/range.cc: Adjust dg-error. + * testsuite/20_util/time_point/arithmetic/constexpr.cc: New test. + 2017-02-19 Gerald Pfeifer * doc/xml/manual/debug.xml: Adjust link to ThreadSanitizer. diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index 2c33be0139c..b3dc430b67a 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -349,50 +349,50 @@ _GLIBCXX_END_NAMESPACE_VERSION operator-() const { return duration(-__r); } - duration& + _GLIBCXX17_CONSTEXPR duration& operator++() { ++__r; return *this; } - duration + _GLIBCXX17_CONSTEXPR duration operator++(int) { return duration(__r++); } - duration& + _GLIBCXX17_CONSTEXPR duration& operator--() { --__r; return *this; } - duration + _GLIBCXX17_CONSTEXPR duration operator--(int) { return duration(__r--); } - duration& + _GLIBCXX17_CONSTEXPR duration& operator+=(const duration& __d) { __r += __d.count(); return *this; } - duration& + _GLIBCXX17_CONSTEXPR duration& operator-=(const duration& __d) { __r -= __d.count(); return *this; } - duration& + _GLIBCXX17_CONSTEXPR duration& operator*=(const rep& __rhs) { __r *= __rhs; return *this; } - duration& + _GLIBCXX17_CONSTEXPR duration& operator/=(const rep& __rhs) { __r /= __rhs; @@ -401,6 +401,7 @@ _GLIBCXX_END_NAMESPACE_VERSION // DR 934. template + _GLIBCXX17_CONSTEXPR typename enable_if::value, duration&>::type operator%=(const rep& __rhs) @@ -410,6 +411,7 @@ _GLIBCXX_END_NAMESPACE_VERSION } template + _GLIBCXX17_CONSTEXPR typename enable_if::value, duration&>::type operator%=(const duration& __d) @@ -631,14 +633,14 @@ _GLIBCXX_END_NAMESPACE_VERSION { return __d; } // arithmetic - time_point& + _GLIBCXX17_CONSTEXPR time_point& operator+=(const duration& __dur) { __d += __dur; return *this; } - time_point& + _GLIBCXX17_CONSTEXPR time_point& operator-=(const duration& __dur) { __d -= __dur; diff --git a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc b/libstdc++-v3/testsuite/20_util/duration/arithmetic/constexpr_c++17.cc similarity index 65% copy from libstdc++-v3/testsuite/20_util/duration/literals/range.cc copy to libstdc++-v3/testsuite/20_util/duration/arithmetic/constexpr_c++17.cc index eafc806ff51..2721765ea75 100644 --- a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc +++ b/libstdc++-v3/testsuite/20_util/duration/arithmetic/constexpr_c++17.cc @@ -1,6 +1,7 @@ -// { dg-do compile { target c++14 } } +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++1z } } -// Copyright (C) 2014-2017 Free Software Foundation, Inc. +// Copyright (C) 2011-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 @@ -18,14 +19,27 @@ // . #include - -void -test01() +#include +constexpr auto test_operators() { - using namespace std::literals::chrono_literals; + std::chrono::nanoseconds d1 { 1 }; + d1++; + ++d1; + d1--; + --d1; + + auto d2(d1); + + d1+=d2; + d1-=d2; - // std::numeric_limits::max() == 9223372036854775807; - auto h = 9223372036854775808h; - // { dg-error "cannot be represented" "" { target *-*-* } 890 } + d1*=1; + d1/=1; + d1%=1; + d1%=d2; + + return d1; } -// { dg-prune-output "in constexpr expansion" } // needed for -O0 + +constexpr auto d4 = test_operators(); + diff --git a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc b/libstdc++-v3/testsuite/20_util/duration/literals/range.cc index eafc806ff51..c0d1a6e5885 100644 --- a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc +++ b/libstdc++-v3/testsuite/20_util/duration/literals/range.cc @@ -26,6 +26,6 @@ test01() // std::numeric_limits::max() == 9223372036854775807; auto h = 9223372036854775808h; - // { dg-error "cannot be represented" "" { target *-*-* } 890 } + // { dg-error "cannot be represented" "" { target *-*-* } 892 } } // { dg-prune-output "in constexpr expansion" } // needed for -O0 diff --git a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc b/libstdc++-v3/testsuite/20_util/time_point/arithmetic/constexpr.cc similarity index 65% copy from libstdc++-v3/testsuite/20_util/duration/literals/range.cc copy to libstdc++-v3/testsuite/20_util/time_point/arithmetic/constexpr.cc index eafc806ff51..2f2acebccf1 100644 --- a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc +++ b/libstdc++-v3/testsuite/20_util/time_point/arithmetic/constexpr.cc @@ -1,6 +1,7 @@ -// { dg-do compile { target c++14 } } +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++1z } } -// Copyright (C) 2014-2017 Free Software Foundation, Inc. +// Copyright (C) 2011-2016 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 @@ -18,14 +19,18 @@ // . #include - -void -test01() +#include +constexpr auto test_operators() { - using namespace std::literals::chrono_literals; + using namespace std::chrono; + nanoseconds d1 { }; + time_point c1 { }; + + c1+=d1; + c1-=d1; - // std::numeric_limits::max() == 9223372036854775807; - auto h = 9223372036854775808h; - // { dg-error "cannot be represented" "" { target *-*-* } 890 } + + return 11; } -// { dg-prune-output "in constexpr expansion" } // needed for -O0 + +constexpr auto a = test_operators(); -- 2.11.4.GIT