aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDinka Ranns <dinka.ranns@googlemail.com>2017-02-19 16:04:35 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2017-02-19 16:04:35 +0000
commit1dee318ad864c606879b7807f768f9be0d0baa1d (patch)
treef0e7d06abeba92b2e38c00b72b66b62038ef1078
parent7dfa657b5bae61a458721d079320fb82401ed58b (diff)
downloadgcc-1dee318ad864c606879b7807f768f9be0d0baa1d.zip
gcc-1dee318ad864c606879b7807f768f9be0d0baa1d.tar.gz
gcc-1dee318ad864c606879b7807f768f9be0d0baa1d.tar.bz2
C++17 GB50 resolution (P0505R0)
2017-02-19 Dinka Ranns <dinka.ranns@googlemail.com> 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. From-SVN: r245575
-rw-r--r--libstdc++-v3/ChangeLog20
-rw-r--r--libstdc++-v3/include/std/chrono22
-rw-r--r--libstdc++-v3/testsuite/20_util/duration/arithmetic/constexpr_c++17.cc45
-rw-r--r--libstdc++-v3/testsuite/20_util/duration/literals/range.cc2
-rw-r--r--libstdc++-v3/testsuite/20_util/time_point/arithmetic/constexpr.cc36
5 files changed, 114 insertions, 11 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 01efa3e..0b02dca 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,23 @@
+2017-02-19 Dinka Ranns <dinka.ranns@googlemail.com>
+
+ 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 <gerald@pfeifer.com>
* doc/xml/manual/debug.xml: Adjust link to ThreadSanitizer.
diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index 2c33be0..b3dc430 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<typename _Rep2 = rep>
+ _GLIBCXX17_CONSTEXPR
typename enable_if<!treat_as_floating_point<_Rep2>::value,
duration&>::type
operator%=(const rep& __rhs)
@@ -410,6 +411,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
}
template<typename _Rep2 = rep>
+ _GLIBCXX17_CONSTEXPR
typename enable_if<!treat_as_floating_point<_Rep2>::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/arithmetic/constexpr_c++17.cc b/libstdc++-v3/testsuite/20_util/duration/arithmetic/constexpr_c++17.cc
new file mode 100644
index 0000000..2721765
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/duration/arithmetic/constexpr_c++17.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++1z } }
+
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <chrono>
+#include <testsuite_common_types.h>
+constexpr auto test_operators()
+{
+ std::chrono::nanoseconds d1 { 1 };
+ d1++;
+ ++d1;
+ d1--;
+ --d1;
+
+ auto d2(d1);
+
+ d1+=d2;
+ d1-=d2;
+
+ d1*=1;
+ d1/=1;
+ d1%=1;
+ d1%=d2;
+
+ return d1;
+}
+
+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 eafc806..c0d1a6e 100644
--- a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc
+++ b/libstdc++-v3/testsuite/20_util/duration/literals/range.cc
@@ -26,6 +26,6 @@ test01()
// std::numeric_limits<int64_t>::max() == 9223372036854775807;
auto h = 9223372036854775808h;
- // { dg-error "cannot be represented" "" { target *-*-* } 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/time_point/arithmetic/constexpr.cc b/libstdc++-v3/testsuite/20_util/time_point/arithmetic/constexpr.cc
new file mode 100644
index 0000000..2f2aceb
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/time_point/arithmetic/constexpr.cc
@@ -0,0 +1,36 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile { target c++1z } }
+
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <chrono>
+#include <testsuite_common_types.h>
+constexpr auto test_operators()
+{
+ using namespace std::chrono;
+ nanoseconds d1 { };
+ time_point<system_clock> c1 { };
+
+ c1+=d1;
+ c1-=d1;
+
+
+ return 11;
+}
+
+constexpr auto a = test_operators();