From 441ad1f3f396b69075ce2d72dd0efa2cbb5b4d23 Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 23 Oct 2013 11:48:26 +0000 Subject: [PATCH] 2013-10-23 Paolo Carlini PR libstdc++/58815 * include/decimal/decimal (decimal32::operator long long(), decimal64::operator long long(), decimal128::operator long long()): Add in c++11 mode per n3407. * testsuite/decimal/pr58815.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203956 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 8 +++++++ libstdc++-v3/include/decimal/decimal | 21 +++++++++++++------ libstdc++-v3/testsuite/decimal/pr58815.cc | 35 +++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 libstdc++-v3/testsuite/decimal/pr58815.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b287bf1a7cb..48243930d47 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2013-10-23 Paolo Carlini + + PR libstdc++/58815 + * include/decimal/decimal (decimal32::operator long long(), + decimal64::operator long long(), decimal128::operator long long()): + Add in c++11 mode per n3407. + * testsuite/decimal/pr58815.cc: New. + 2013-10-22 Edward Smith-Rowland <3dw4rd@verizon.net> * include/bits/basic_string.h (operator""s): Remove space between quotes diff --git a/libstdc++-v3/include/decimal/decimal b/libstdc++-v3/include/decimal/decimal index a8805378d80..c1601180e75 100644 --- a/libstdc++-v3/include/decimal/decimal +++ b/libstdc++-v3/include/decimal/decimal @@ -250,8 +250,11 @@ namespace decimal /// Conforming extension: Conversion from scalar decimal type. decimal32(__decfloat32 __z) : __val(__z) {} - // 3.2.2.5 Conversion to integral type. (DISABLED) - //operator long long() const { return (long long)__val; } +#if __cplusplus >= 201103L + // 3.2.2.5 Conversion to integral type. + // Note: explicit per n3407. + explicit operator long long() const { return (long long)__val; } +#endif // 3.2.2.6 Increment and decrement operators. decimal32& operator++() @@ -333,8 +336,11 @@ namespace decimal /// Conforming extension: Conversion from scalar decimal type. decimal64(__decfloat64 __z) : __val(__z) {} - // 3.2.3.5 Conversion to integral type. (DISABLED) - //operator long long() const { return (long long)__val; } +#if __cplusplus >= 201103L + // 3.2.3.5 Conversion to integral type. + // Note: explicit per n3407. + explicit operator long long() const { return (long long)__val; } +#endif // 3.2.3.6 Increment and decrement operators. decimal64& operator++() @@ -417,8 +423,11 @@ namespace decimal /// Conforming extension: Conversion from scalar decimal type. decimal128(__decfloat128 __z) : __val(__z) {} - // 3.2.4.5 Conversion to integral type. (DISABLED) - //operator long long() const { return (long long)__val; } +#if __cplusplus >= 201103L + // 3.2.4.5 Conversion to integral type. + // Note: explicit per n3407. + explicit operator long long() const { return (long long)__val; } +#endif // 3.2.4.6 Increment and decrement operators. decimal128& operator++() diff --git a/libstdc++-v3/testsuite/decimal/pr58815.cc b/libstdc++-v3/testsuite/decimal/pr58815.cc new file mode 100644 index 00000000000..b805d75f4eb --- /dev/null +++ b/libstdc++-v3/testsuite/decimal/pr58815.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++11" } +// +// Copyright (C) 2013 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 +// . + +// { dg-do compile } +// { dg-require-effective-target dfp } + +#include + +void +test01 () +{ + std::decimal::decimal32 d32; + std::decimal::decimal64 d64; + std::decimal::decimal128 d128; + + static_cast(d32); + static_cast(d64); + static_cast(d128); +} -- 2.11.4.GIT