Commit 4cdc8761 by Benjamin Kosnik

[multiple changes]

2009-10-05  Benjamin Kosnik  <bkoz@redhat.com>
	    Edward Smith-Rowland  <3dw4rd@verizon.net>

	* include/decimal/decimal: Warn if decimal floating point types
	are not available.
	* acinclude.m4 (GLIBCXX_ENABLE_DECIMAL_FLOAT): New.
	* configure.ac: Use it.
	* configure: Regenerate.
	* config.h.in: Regenerate.

2009-10-05  Benjamin Kosnik  <bkoz@redhat.com>

	* include/Makefile.am: Remove stray line break.

	* include/decimal/decimal: Brief class doxygen markup.
	* libsupc++/exception: Whitespace cleanup.

	* testsuite/libstdc++-dg/conformance.exp: Add testsuite directory
	decimal.
	* scripts/create_testsuite_files (dlist): Same.

	* doc/xml/manual/using.xml: One column in table. Move after TR1.

	* testsuite/decimal/bad-cast.cc: Move to...
	* testsuite/decimal/cast_neg.cc: ...here.
	* testsuite/decimal/bad-mixed-mode.cc: Move to...
	* testsuite/decimal/mixed-mode_neg.cc: ...here.
	* testsuite/decimal/bad-operator.cc: Move to...
	* testsuite/decimal/operator_neg.cc: ...here.

	* doc/doxygen/user.cfg.in (INPUT): Add decimal/decimal.

2009-10-05  Janis Johnson  <janis187@us.ibm.com>

	* doc/Makefile.am: Process new file.
	* doc/xml/manual/intro.xml: Ditto.
	* doc/xml/manual/using.xml: Document new header.
	* doc/xml/manual/status_cxxdecimal.xml: New file.
	* include/Makefile.am: Process new headers.
	* include/decimal/decimal: New file.
	* include/decimal/decimal.h: New file.

2009-10-05  Janis Johnson  <janis187@us.ibm.com>

	* testsuite/decimal: New directory.
	* testsuite/decimal/bad-cast.cc: New test.
	* testsuite/decimal/bad-mixed-mode.cc: New test.
	* testsuite/decimal/bad-operator.cc: New test.
	* testsuite/decimal/binary-arith.cc: New test.
	* testsuite/decimal/comparison.cc: New test.
	* testsuite/decimal/compound-assignment.cc: New test.
	* testsuite/decimal/compound-assignment-memfunc.cc: New test.
	* testsuite/decimal/conversion-from-float.cc: New test.
	* testsuite/decimal/conversion-from-integral.cc: New test.
	* testsuite/decimal/conversion-to-generic-float.cc: New test.
	* testsuite/decimal/conversion-to-integral.cc: New test.
	* testsuite/decimal/ctor.cc: New test.
	* testsuite/decimal/incdec.cc: New test.
	* testsuite/decimal/incdec-memfunc.cc: New test.
	* testsuite/decimal/make-decimal.cc: New test.
	* testsuite/decimal/unary-arith.cc: New test.

From-SVN: r152457
parent 8fc7e474
2009-10-05 Benjamin Kosnik <bkoz@redhat.com>
Edward Smith-Rowland <3dw4rd@verizon.net>
* include/decimal/decimal: Warn if decimal floating point types
are not available.
* acinclude.m4 (GLIBCXX_ENABLE_DECIMAL_FLOAT): New.
* configure.ac: Use it.
* configure: Regenerate.
* config.h.in: Regenerate.
2009-10-05 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am: Remove stray line break.
* include/decimal/decimal: Brief class doxygen markup.
* libsupc++/exception: Whitespace cleanup.
* testsuite/libstdc++-dg/conformance.exp: Add testsuite directory
decimal.
* scripts/create_testsuite_files (dlist): Same.
* doc/xml/manual/using.xml: One column in table. Move after TR1.
* testsuite/decimal/bad-cast.cc: Move to...
* testsuite/decimal/cast_neg.cc: ...here.
* testsuite/decimal/bad-mixed-mode.cc: Move to...
* testsuite/decimal/mixed-mode_neg.cc: ...here.
* testsuite/decimal/bad-operator.cc: Move to...
* testsuite/decimal/operator_neg.cc: ...here.
* doc/doxygen/user.cfg.in (INPUT): Add decimal/decimal.
2009-10-05 Janis Johnson <janis187@us.ibm.com>
* doc/Makefile.am: Process new file.
* doc/xml/manual/intro.xml: Ditto.
* doc/xml/manual/using.xml: Document new header.
* doc/xml/manual/status_cxxdecimal.xml: New file.
* include/Makefile.am: Process new headers.
* include/decimal/decimal: New file.
* include/decimal/decimal.h: New file.
2009-10-05 Janis Johnson <janis187@us.ibm.com>
* testsuite/decimal: New directory.
* testsuite/decimal/bad-cast.cc: New test.
* testsuite/decimal/bad-mixed-mode.cc: New test.
* testsuite/decimal/bad-operator.cc: New test.
* testsuite/decimal/binary-arith.cc: New test.
* testsuite/decimal/comparison.cc: New test.
* testsuite/decimal/compound-assignment.cc: New test.
* testsuite/decimal/compound-assignment-memfunc.cc: New test.
* testsuite/decimal/conversion-from-float.cc: New test.
* testsuite/decimal/conversion-from-integral.cc: New test.
* testsuite/decimal/conversion-to-generic-float.cc: New test.
* testsuite/decimal/conversion-to-integral.cc: New test.
* testsuite/decimal/ctor.cc: New test.
* testsuite/decimal/incdec.cc: New test.
* testsuite/decimal/incdec-memfunc.cc: New test.
* testsuite/decimal/make-decimal.cc: New test.
* testsuite/decimal/unary-arith.cc: New test.
2009-10-05 Paolo Carlini <paolo.carlini@oracle.com> 2009-10-05 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_rvalref): Remove. * testsuite/lib/libstdc++.exp (check_v3_target_rvalref): Remove.
......
...@@ -2222,6 +2222,44 @@ AC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [ ...@@ -2222,6 +2222,44 @@ AC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [
dnl dnl
dnl Check for decimal floating point.
dnl See:
dnl http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float
dnl
dnl This checks to see if the host supports decimal floating point types.
dnl
dnl Defines:
dnl _GLIBCXX_USE_DECIMAL_FLOAT
dnl
AC_DEFUN([GLIBCXX_ENABLE_DECIMAL_FLOAT], [
# Fake what AC_TRY_COMPILE does, without linking as this is
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
[#]line __oline__ "configure"
int main()
{
_Decimal32 d1;
_Decimal64 d2;
_Decimal128 d3;
return 0;
}
EOF
AC_MSG_CHECKING([for ISO/IEC TR 24733 ])
if AC_TRY_EVAL(ac_compile); then
AC_DEFINE(_GLIBCXX_USE_DECIMAL_FLOAT, 1,
[Define if ISO/IEC TR 24733 decimal floating point types are supported on this host.])
enable_dfp=yes
else
enable_dfp=no
fi
AC_MSG_RESULT($enable_dfp)
rm -f conftest*
])
dnl
dnl Check for template specializations for the 'wchar_t' type. dnl Check for template specializations for the 'wchar_t' type.
dnl dnl
dnl --enable-wchar_t defines _GLIBCXX_USE_WCHAR_T dnl --enable-wchar_t defines _GLIBCXX_USE_WCHAR_T
......
...@@ -262,9 +262,6 @@ ...@@ -262,9 +262,6 @@
/* Define to 1 if you have the <memory.h> header file. */ /* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H #undef HAVE_MEMORY_H
/* Define to 1 if you have the <execinfo.h> header file. */
#undef HAVE_EXECINFO_H
/* Define to 1 if you have the `modf' function. */ /* Define to 1 if you have the `modf' function. */
#undef HAVE_MODF #undef HAVE_MODF
...@@ -772,6 +769,10 @@ ...@@ -772,6 +769,10 @@
/* Defined if clock_gettime has realtime clock support. */ /* Defined if clock_gettime has realtime clock support. */
#undef _GLIBCXX_USE_CLOCK_REALTIME #undef _GLIBCXX_USE_CLOCK_REALTIME
/* Define if ISO/IEC TR 24733 decimal floating point types are supported on
this host. */
#undef _GLIBCXX_USE_DECIMAL_FLOAT
/* Defined if gettimeofday is available. */ /* Defined if gettimeofday is available. */
#undef _GLIBCXX_USE_GETTIMEOFDAY #undef _GLIBCXX_USE_GETTIMEOFDAY
......
...@@ -7926,7 +7926,7 @@ fi ...@@ -7926,7 +7926,7 @@ fi
# On IRIX 5.3, sys/types and inttypes.h are conflicting. # On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h execinfo.h inttypes.h stdint.h unistd.h
do : do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
...@@ -15358,6 +15358,40 @@ $as_echo "$as_me: WARNING: Performance of certain classes will degrade as a resu ...@@ -15358,6 +15358,40 @@ $as_echo "$as_me: WARNING: Performance of certain classes will degrade as a resu
# Fake what AC_TRY_COMPILE does, without linking as this is
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
#line 15366 "configure"
int main()
{
_Decimal32 d1;
_Decimal64 d2;
_Decimal128 d3;
return 0;
}
EOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ISO/IEC TR 24733 " >&5
$as_echo_n "checking for ISO/IEC TR 24733 ... " >&6; }
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
(eval $ac_compile) 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
$as_echo "#define _GLIBCXX_USE_DECIMAL_FLOAT 1" >>confdefs.h
enable_dfp=yes
else
enable_dfp=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_dfp" >&5
$as_echo "$enable_dfp" >&6; }
rm -f conftest*
# Checks for compiler support that doesn't require linking. # Checks for compiler support that doesn't require linking.
# All these tests are for C++; save the language and the compiler flags. # All these tests are for C++; save the language and the compiler flags.
...@@ -128,6 +128,7 @@ GLIBCXX_ENABLE_SJLJ_EXCEPTIONS ...@@ -128,6 +128,7 @@ GLIBCXX_ENABLE_SJLJ_EXCEPTIONS
GLIBCXX_ENABLE_PCH($is_hosted) GLIBCXX_ENABLE_PCH($is_hosted)
GLIBCXX_ENABLE_THREADS GLIBCXX_ENABLE_THREADS
GLIBCXX_ENABLE_ATOMIC_BUILTINS GLIBCXX_ENABLE_ATOMIC_BUILTINS
GLIBCXX_ENABLE_DECIMAL_FLOAT
# Checks for compiler support that doesn't require linking. # Checks for compiler support that doesn't require linking.
GLIBCXX_CHECK_COMPILER_FEATURES GLIBCXX_CHECK_COMPILER_FEATURES
......
...@@ -107,6 +107,7 @@ xml_sources = \ ...@@ -107,6 +107,7 @@ xml_sources = \
${xml_srcdir}/manual/status_cxx1998.xml \ ${xml_srcdir}/manual/status_cxx1998.xml \
${xml_srcdir}/manual/status_cxx200x.xml \ ${xml_srcdir}/manual/status_cxx200x.xml \
${xml_srcdir}/manual/status_cxxtr1.xml \ ${xml_srcdir}/manual/status_cxxtr1.xml \
${xml_srcdir}/manual/status_cxxtr24733.xml \
${xml_srcdir}/manual/strings.xml \ ${xml_srcdir}/manual/strings.xml \
${xml_srcdir}/manual/support.xml \ ${xml_srcdir}/manual/support.xml \
${xml_srcdir}/manual/test.xml \ ${xml_srcdir}/manual/test.xml \
......
...@@ -319,6 +319,7 @@ xml_sources = \ ...@@ -319,6 +319,7 @@ xml_sources = \
${xml_srcdir}/manual/status_cxx1998.xml \ ${xml_srcdir}/manual/status_cxx1998.xml \
${xml_srcdir}/manual/status_cxx200x.xml \ ${xml_srcdir}/manual/status_cxx200x.xml \
${xml_srcdir}/manual/status_cxxtr1.xml \ ${xml_srcdir}/manual/status_cxxtr1.xml \
${xml_srcdir}/manual/status_cxxtr24733.xml \
${xml_srcdir}/manual/strings.xml \ ${xml_srcdir}/manual/strings.xml \
${xml_srcdir}/manual/support.xml \ ${xml_srcdir}/manual/support.xml \
${xml_srcdir}/manual/test.xml \ ${xml_srcdir}/manual/test.xml \
......
...@@ -727,6 +727,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \ ...@@ -727,6 +727,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \
include/tr1_impl/unordered_set \ include/tr1_impl/unordered_set \
include/tr1_impl/utility \ include/tr1_impl/utility \
include/tr1_impl \ include/tr1_impl \
include/decimal/decimal \
include/ \ include/ \
include/@host_alias@/bits \ include/@host_alias@/bits \
include/backward \ include/backward \
......
...@@ -44,6 +44,11 @@ ...@@ -44,6 +44,11 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
parse="xml" href="status_cxx200x.xml"> parse="xml" href="status_cxx200x.xml">
</xi:include> </xi:include>
<!-- Section 01.4 : Status C++ TR24733 -->
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
parse="xml" href="status_cxxtr24733.xml">
</xi:include>
</sect1> </sect1>
<!-- Section 02 : License --> <!-- Section 02 : License -->
......
<sect2 id="status.iso.tr24733" xreflabel="Status C++ TR24733">
<?dbhtml filename="status_iso_cxxtr24733.html"?>
<sect2info>
<keywordset>
<keyword>
TR 24733
</keyword>
</keywordset>
</sect2info>
<title>C++ TR 24733</title>
<para>
This table is based on the table of contents of
ISO/IEC TR 24733 Date: 2009-08-28
Extension for the programming language C++ to support
decimal floating-point arithmetic
</para>
<para>
This page describes the TR 24733 support in mainline GCC SVN, not in any
particular release.
</para>
<!-- Status is Yes or No, Broken/Partial-->
<!--
Yes
No
<?dbhtml bgcolor="#C8B0B0" ?>
Broken/Partial
<?dbhtml bgcolor="#B0B0B0" ?>
-->
<table frame='all'>
<title>C++ TR 24733 Implementation Status</title>
<tgroup cols='4' align='left' colsep='0' rowsep='1'>
<colspec colname='c1'></colspec>
<colspec colname='c2'></colspec>
<colspec colname='c3'></colspec>
<colspec colname='c4'></colspec>
<thead>
<row>
<entry>Section</entry>
<entry>Description</entry>
<entry>Status</entry>
<entry>Comments</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<emphasis>0</emphasis>
</entry>
<entry namest="c2" nameend="c4" align="left">
<emphasis>Introduction</emphasis>
</entry>
</row>
<row>
<entry>
<emphasis>1</emphasis>
</entry>
<entry namest="c2" nameend="c4" align="left">
<emphasis>Normative references</emphasis>
</entry>
</row>
<row>
<entry>
<emphasis>2</emphasis>
</entry>
<entry namest="c2" nameend="c4" align="left">
<emphasis>Conventions</emphasis>
</entry>
</row>
<row>
<entry>
<emphasis>3</emphasis>
</entry>
<entry namest="c2" nameend="c4" align="left">
<emphasis>Decimal floating-point types</emphasis>
</entry>
</row>
<row>
<entry>3.1</entry>
<entry>Characteristics of decimal floating-point types</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry>3.2</entry>
<entry>Decimal Types</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>3.2.1</entry>
<entry>Class <code>decimal</code> synopsis</entry>
<entry>Partial</entry>
<entry>Missing declarations for formatted input/output; non-conforming extension for functions converting to integral type</entry>
</row>
<row>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>3.2.2</entry>
<entry>Class <code>decimal32</code></entry>
<entry>Partial</entry>
<entry>Missing 3.2.2.5 conversion to integral type; conforming extension for conversion from scalar decimal floating-point</entry>
</row>
<row>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>3.2.3</entry>
<entry>Class <code>decimal64</code></entry>
<entry>Partial</entry>
<entry>Missing 3.2.3.5 conversion to integral type; conforming extension for conversion from scalar decimal floating-point</entry>
</row>
<row>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>3.2.4</entry>
<entry>Class <code>decimal128</code></entry>
<entry>Partial</entry>
<entry>Missing 3.2.4.5 conversion to integral type; conforming extension for conversion from scalar decimal floating-point</entry>
</row>
<row>
<entry>3.2.5</entry>
<entry>Initialization from coefficient and exponent</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.2.6</entry>
<entry>Conversion to generic floating-point type</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.2.7</entry>
<entry>Unary arithmetic operators</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.2.8</entry>
<entry>Binary arithmetic operators</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.2.9</entry>
<entry>Comparison operators</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.2.10</entry>
<entry>Formatted input</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.2.11</entry>
<entry>Formatted output</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.3</entry>
<entry>Additions to header <code>limits</code></entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<entry>3.4</entry>
<entry>Headers <code>cfloat</code> and <code>float.h</code></entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry>3.4.2</entry>
<entry>Additions to header <code>cfloat</code> synopsis</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>3.4.3</entry>
<entry>Additions to header <code>float.h</code> synopsis</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<entry>3.4.4</entry>
<entry>Maximum finite value</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.4.5</entry>
<entry>Epsilon</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.4.6</entry>
<entry>Minimum positive normal value</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.4.7</entry>
<entry>Minimum positive subnormal value</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.4.8</entry>
<entry>Evaluation format</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.5</entry>
<entry>Additions to <code>cfenv</code> and <code>fenv.h</code></entry>
<entry>Outside the scope of GCC</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.6</entry>
<entry>Additions to <code>cmath</code> and <code>math.h</code></entry>
<entry>Outside the scope of GCC</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.7</entry>
<entry>Additions to <code>cstdio</code> and <code>stdio.h</code></entry>
<entry>Outside the scope of GCC</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.8</entry>
<entry>Additions to <code>cstdlib</code> and <code>stdlib.h</code></entry>
<entry>Outside the scope of GCC</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.9</entry>
<entry>Additions to <code>cwchar</code> and <code>wchar.h</code></entry>
<entry>Outside the scope of GCC</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.10</entry>
<entry>Facets</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.11</entry>
<entry>Type traits</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.12</entry>
<entry>Hash functions</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<entry>
<emphasis>4</emphasis>
</entry>
<entry namest="c2" nameend="c4" align="left">
<emphasis>Notes on C compatibility</emphasis>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
...@@ -360,7 +360,7 @@ mode, i.e. <literal>-std=c++0x</literal> or <literal>-std=gnu++0x</literal>. ...@@ -360,7 +360,7 @@ mode, i.e. <literal>-std=c++0x</literal> or <literal>-std=gnu++0x</literal>.
</para> </para>
<table frame='all'> <table frame='all'>
<title>C++ TR1 Library Headers</title> <title>C++ TR 1 Library Headers</title>
<tgroup cols='5' align='left' colsep='1' rowsep='1'> <tgroup cols='5' align='left' colsep='1' rowsep='1'>
<colspec colname='c1'></colspec> <colspec colname='c1'></colspec>
<colspec colname='c2'></colspec> <colspec colname='c2'></colspec>
...@@ -395,7 +395,7 @@ mode, i.e. <literal>-std=c++0x</literal> or <literal>-std=gnu++0x</literal>. ...@@ -395,7 +395,7 @@ mode, i.e. <literal>-std=c++0x</literal> or <literal>-std=gnu++0x</literal>.
<table frame='all'> <table frame='all'>
<title>C++ TR1 Library Headers for C Library Facilities</title> <title>C++ TR 1 Library Headers for C Library Facilities</title>
<tgroup cols='5' align='left' colsep='1' rowsep='1'> <tgroup cols='5' align='left' colsep='1' rowsep='1'>
<colspec colname='c1'></colspec> <colspec colname='c1'></colspec>
<colspec colname='c2'></colspec> <colspec colname='c2'></colspec>
...@@ -430,6 +430,24 @@ mode, i.e. <literal>-std=c++0x</literal> or <literal>-std=gnu++0x</literal>. ...@@ -430,6 +430,24 @@ mode, i.e. <literal>-std=c++0x</literal> or <literal>-std=gnu++0x</literal>.
</tgroup> </tgroup>
</table> </table>
<para>Decimal floating-point arithmetic is available if the C++
compiler supports scalar decimal floating-point types defined via
<code>__attribute__((mode(SD|DD|LD)))</code>.
</para>
<table frame='all'>
<title>C++ TR 24733 Decimal Floating-Point Header</title>
<tgroup cols='1' align='left' colsep='1' rowsep='1'>
<colspec colname='c1'></colspec>
<tbody>
<row>
<entry><filename class="headerfile">decimal/decimal</filename></entry>
</row>
</tbody>
</tgroup>
</table>
<para> <para>
Also included are files for the C++ ABI interface: Also included are files for the C++ ABI interface:
</para> </para>
......
...@@ -618,6 +618,11 @@ tr1_impl_headers = \ ...@@ -618,6 +618,11 @@ tr1_impl_headers = \
${tr1_impl_srcdir}/unordered_set \ ${tr1_impl_srcdir}/unordered_set \
${tr1_impl_srcdir}/utility ${tr1_impl_srcdir}/utility
decimal_srcdir = ${glibcxx_srcdir}/include/decimal
decimal_builddir = ./decimal
decimal_headers = \
${decimal_srcdir}/decimal \
${decimal_srcdir}/decimal.h
# This is the common subset of C++ files that all three "C" header models use. # This is the common subset of C++ files that all three "C" header models use.
c_base_srcdir = $(C_INCLUDE_DIR) c_base_srcdir = $(C_INCLUDE_DIR)
...@@ -896,8 +901,8 @@ endif ...@@ -896,8 +901,8 @@ endif
allstamped = \ allstamped = \
stamp-std stamp-bits stamp-c_base stamp-c_base_extra \ stamp-std stamp-bits stamp-c_base stamp-c_base_extra \
stamp-c_compatibility stamp-backward stamp-ext stamp-pb \ stamp-c_compatibility stamp-backward stamp-ext stamp-pb \
stamp-tr1 stamp-tr1-impl stamp-debug stamp-parallel stamp-host \ stamp-tr1 stamp-tr1-impl stamp-decimal stamp-debug \
stamp-profile stamp-profile-impl stamp-parallel stamp-profile stamp-profile-impl stamp-host
# List of all files that are created by explicit building, editing, or # List of all files that are created by explicit building, editing, or
# catenation. # catenation.
...@@ -1011,6 +1016,11 @@ stamp-tr1-impl: ${tr1_impl_headers} ...@@ -1011,6 +1016,11 @@ stamp-tr1-impl: ${tr1_impl_headers}
@-cd ${tr1_impl_builddir} && $(LN_S) $? . 2>/dev/null @-cd ${tr1_impl_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-tr1-impl @$(STAMP) stamp-tr1-impl
stamp-decimal: ${decimal_headers}
@-mkdir -p ${decimal_builddir}
@-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-decimal
stamp-debug: ${debug_headers} stamp-debug: ${debug_headers}
@-mkdir -p ${debug_builddir} @-mkdir -p ${debug_builddir}
@-cd ${debug_builddir} && $(LN_S) $? . 2>/dev/null @-cd ${debug_builddir} && $(LN_S) $? . 2>/dev/null
...@@ -1239,6 +1249,9 @@ install-headers: ...@@ -1239,6 +1249,9 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}
for file in ${tr1_impl_headers}; do \ for file in ${tr1_impl_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}; done $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${decimal_builddir}
for file in ${decimal_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir}
for file in ${c_base_headers}; do \ for file in ${c_base_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done
...@@ -1283,9 +1296,10 @@ clean-local: ...@@ -1283,9 +1296,10 @@ clean-local:
# directory. (This is more of an example of how this kind of rule can # directory. (This is more of an example of how this kind of rule can
# be made.) # be made.)
.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(tr1_impl_headers) .PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(tr1_impl_headers)
$(ext_headers) $(decimal_headers) $(ext_headers)
$(std_headers): ; @: $(std_headers): ; @:
$(c_base_headers): ; @: $(c_base_headers): ; @:
$(tr1_headers): ; @: $(tr1_headers): ; @:
$(tr1_impl_headers): ; @: $(tr1_impl_headers): ; @:
$(decimal_headers): ; @:
$(ext_headers): ; @: $(ext_headers): ; @:
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
# PARTICULAR PURPOSE. # PARTICULAR PURPOSE.
@SET_MAKE@ @SET_MAKE@
#o# Makefile for the include subdirectory of the GNU C++ Standard library.
VPATH = @srcdir@ VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@
...@@ -856,6 +858,12 @@ tr1_impl_headers = \ ...@@ -856,6 +858,12 @@ tr1_impl_headers = \
${tr1_impl_srcdir}/unordered_set \ ${tr1_impl_srcdir}/unordered_set \
${tr1_impl_srcdir}/utility ${tr1_impl_srcdir}/utility
decimal_srcdir = ${glibcxx_srcdir}/include/decimal
decimal_builddir = ./decimal
decimal_headers = \
${decimal_srcdir}/decimal \
${decimal_srcdir}/decimal.h
# This is the common subset of C++ files that all three "C" header models use. # This is the common subset of C++ files that all three "C" header models use.
c_base_srcdir = $(C_INCLUDE_DIR) c_base_srcdir = $(C_INCLUDE_DIR)
...@@ -1006,20 +1014,21 @@ parallel_builddir = ./parallel ...@@ -1006,20 +1014,21 @@ parallel_builddir = ./parallel
profile_srcdir = ${glibcxx_srcdir}/include/profile profile_srcdir = ${glibcxx_srcdir}/include/profile
profile_builddir = ./profile profile_builddir = ./profile
profile_headers = \ profile_headers = \
${profile_srcdir}/base.h \ ${profile_srcdir}/base.h \
${profile_srcdir}/unordered_map \ ${profile_srcdir}/unordered_map \
${profile_srcdir}/unordered_set \ ${profile_srcdir}/unordered_set \
${profile_srcdir}/vector \ ${profile_srcdir}/vector \
${profile_srcdir}/bitset \ ${profile_srcdir}/bitset \
${profile_srcdir}/deque \ ${profile_srcdir}/deque \
${profile_srcdir}/list \ ${profile_srcdir}/list \
${profile_srcdir}/map \ ${profile_srcdir}/map \
${profile_srcdir}/map.h \ ${profile_srcdir}/map.h \
${profile_srcdir}/multimap.h \ ${profile_srcdir}/multimap.h \
${profile_srcdir}/multiset.h \ ${profile_srcdir}/multiset.h \
${profile_srcdir}/set \ ${profile_srcdir}/set \
${profile_srcdir}/set.h \ ${profile_srcdir}/set.h \
${profile_srcdir}/hashtable.h ${profile_srcdir}/hashtable.h
profile_impl_srcdir = ${glibcxx_srcdir}/include/profile/impl profile_impl_srcdir = ${glibcxx_srcdir}/include/profile/impl
profile_impl_builddir = ./profile/impl profile_impl_builddir = ./profile/impl
profile_impl_headers = \ profile_impl_headers = \
...@@ -1116,8 +1125,8 @@ PCHFLAGS = -x c++-header $(CXXFLAGS) ...@@ -1116,8 +1125,8 @@ PCHFLAGS = -x c++-header $(CXXFLAGS)
allstamped = \ allstamped = \
stamp-std stamp-bits stamp-c_base stamp-c_base_extra \ stamp-std stamp-bits stamp-c_base stamp-c_base_extra \
stamp-c_compatibility stamp-backward stamp-ext stamp-pb \ stamp-c_compatibility stamp-backward stamp-ext stamp-pb \
stamp-tr1 stamp-tr1-impl stamp-debug stamp-parallel stamp-host \ stamp-tr1 stamp-tr1-impl stamp-decimal stamp-debug \
stamp-profile stamp-profile-impl stamp-parallel stamp-profile stamp-profile-impl stamp-host
# List of all files that are created by explicit building, editing, or # List of all files that are created by explicit building, editing, or
...@@ -1424,6 +1433,11 @@ stamp-tr1-impl: ${tr1_impl_headers} ...@@ -1424,6 +1433,11 @@ stamp-tr1-impl: ${tr1_impl_headers}
@-cd ${tr1_impl_builddir} && $(LN_S) $? . 2>/dev/null @-cd ${tr1_impl_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-tr1-impl @$(STAMP) stamp-tr1-impl
stamp-decimal: ${decimal_headers}
@-mkdir -p ${decimal_builddir}
@-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-decimal
stamp-debug: ${debug_headers} stamp-debug: ${debug_headers}
@-mkdir -p ${debug_builddir} @-mkdir -p ${debug_builddir}
@-cd ${debug_builddir} && $(LN_S) $? . 2>/dev/null @-cd ${debug_builddir} && $(LN_S) $? . 2>/dev/null
...@@ -1640,6 +1654,9 @@ install-headers: ...@@ -1640,6 +1654,9 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}
for file in ${tr1_impl_headers}; do \ for file in ${tr1_impl_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}; done $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${decimal_builddir}
for file in ${decimal_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir}
for file in ${c_base_headers}; do \ for file in ${c_base_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done
...@@ -1660,8 +1677,7 @@ install-headers: ...@@ -1660,8 +1677,7 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${parallel_builddir};\ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${parallel_builddir};\
for file in $$parallel_headers_install; do \ for file in $$parallel_headers_install; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${parallel_builddir}; done $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${parallel_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_builddir} \ $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_builddir}
$(DESTDIR)${gxx_include_dir}/${profile_builddir}/impl
for file in ${profile_headers}; do \ for file in ${profile_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${profile_builddir}; done $(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${profile_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_impl_builddir} $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_impl_builddir}
...@@ -1682,11 +1698,12 @@ clean-local: ...@@ -1682,11 +1698,12 @@ clean-local:
# directory. (This is more of an example of how this kind of rule can # directory. (This is more of an example of how this kind of rule can
# be made.) # be made.)
.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(tr1_impl_headers) .PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(tr1_impl_headers)
$(ext_headers) $(decimal_headers) $(ext_headers)
$(std_headers): ; @: $(std_headers): ; @:
$(c_base_headers): ; @: $(c_base_headers): ; @:
$(tr1_headers): ; @: $(tr1_headers): ; @:
$(tr1_impl_headers): ; @: $(tr1_impl_headers): ; @:
$(decimal_headers): ; @:
$(ext_headers): ; @: $(ext_headers): ; @:
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option) // the Free Software Foundation; either version 3, or (at your option)
// any later version. // any later version.
// //
// GCC is distributed in the hope that it will be useful, // GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// Under Section 7 of GPL version 3, you are granted additional // Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version // permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation. // 3.1, as published by the Free Software Foundation.
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
extern "C++" { extern "C++" {
namespace std namespace std
{ {
/** /**
* @defgroup exceptions Exceptions * @defgroup exceptions Exceptions
...@@ -56,7 +56,7 @@ namespace std ...@@ -56,7 +56,7 @@ namespace std
* your own %exception classes, or use a different hierarchy, or to * your own %exception classes, or use a different hierarchy, or to
* throw non-class data (e.g., fundamental types). * throw non-class data (e.g., fundamental types).
*/ */
class exception class exception
{ {
public: public:
exception() throw() { } exception() throw() { }
...@@ -69,7 +69,7 @@ namespace std ...@@ -69,7 +69,7 @@ namespace std
/** If an %exception is thrown which is not listed in a function's /** If an %exception is thrown which is not listed in a function's
* %exception specification, one of these may be thrown. */ * %exception specification, one of these may be thrown. */
class bad_exception : public exception class bad_exception : public exception
{ {
public: public:
bad_exception() throw() { } bad_exception() throw() { }
...@@ -119,10 +119,10 @@ namespace std ...@@ -119,10 +119,10 @@ namespace std
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
/** /**
* @brief A replacement for the standard terminate_handler which * @brief A replacement for the standard terminate_handler which
* prints more information about the terminating exception (if any) * prints more information about the terminating exception (if any)
* on stderr. * on stderr.
* *
* @ingroup exceptions * @ingroup exceptions
* *
...@@ -138,7 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) ...@@ -138,7 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
void __verbose_terminate_handler(); void __verbose_terminate_handler();
_GLIBCXX_END_NAMESPACE _GLIBCXX_END_NAMESPACE
} // extern "C++" } // extern "C++"
#pragma GCC visibility pop #pragma GCC visibility pop
......
...@@ -32,7 +32,7 @@ cd $srcdir ...@@ -32,7 +32,7 @@ cd $srcdir
# This is the ugly version of "everything but the current directory". It's # This is the ugly version of "everything but the current directory". It's
# what has to happen when find(1) doesn't support -mindepth, or -xtype. # what has to happen when find(1) doesn't support -mindepth, or -xtype.
dlist=`echo [0-9][0-9]*` dlist=`echo [0-9][0-9]*`
dlist="$dlist abi backward ext performance tr1" dlist="$dlist abi backward ext performance tr1 decimal"
find $dlist "(" -type f -o -type l ")" -name "*.cc" -print > $tmp.01 find $dlist "(" -type f -o -type l ")" -name "*.cc" -print > $tmp.01
find $dlist "(" -type f -o -type l ")" -name "*.c" -print > $tmp.02 find $dlist "(" -type f -o -type l ")" -name "*.c" -print > $tmp.02
cat $tmp.01 $tmp.02 | sort > $tmp.1 cat $tmp.01 $tmp.02 | sort > $tmp.1
......
...@@ -299,7 +299,7 @@ libgomp_flags = -B${glibcxx_builddir}/../libgomp \ ...@@ -299,7 +299,7 @@ libgomp_flags = -B${glibcxx_builddir}/../libgomp \
atomic_flags = $(ATOMIC_FLAGS) atomic_flags = $(ATOMIC_FLAGS)
parallel_flags = "unix/-D_GLIBCXX_PARALLEL/-fopenmp" parallel_flags = "unix/-D_GLIBCXX_PARALLEL/-fopenmp"
# Runs the testsuite in profile # Runs the testsuite in profile mode.
profile_flags = "unix/-D_GLIBCXX_PROFILE" profile_flags = "unix/-D_GLIBCXX_PROFILE"
# By adding these files here, automake will remove them for 'make clean' # By adding these files here, automake will remove them for 'make clean'
...@@ -652,7 +652,7 @@ check-profile: site.exp ...@@ -652,7 +652,7 @@ check-profile: site.exp
fi; \ fi; \
srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \ srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
EXPECT=$(EXPECT); export EXPECT; \ EXPECT=$(EXPECT); export EXPECT; \
$(MAKE) CXXFLAGS="$(atomic_flags)" RUNTESTFLAGS="$(RUNTESTFLAGS) conformance.exp --outdir $${outputdir} --objdir $${outputdir} --target_board=$(profile_flags)" check-DEJAGNU; ) $(MAKE) CXXFLAGS="$(atomic_flags) " RUNTESTFLAGS="$(RUNTESTFLAGS) conformance.exp --outdir $${outputdir} --objdir $${outputdir} --target_board=$(profile_flags)" check-DEJAGNU; )
.PHONY: baseline_symbols new-abi-baseline \ .PHONY: baseline_symbols new-abi-baseline \
check-abi check-compile check-performance check-parallel check-profile check-abi check-compile check-performance check-parallel check-profile
......
// Copyright (C) 2009 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 }
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 doesn't say explicitly that the conversion from a
// decimal floating-point type to a generic float type is prohibited but
// it implies that in section 4.3 when it says "In C, objects of decimal
// floating-oint type can be converted to generic floating-point type by
// means of an explicit cast. In C++ this is not possible." Check that
// attempt to do a cast are flagged as errors.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
float f;
double d;
long double ld;
decimal32 d32;
decimal64 d64;
decimal128 d128;
void
foo (void)
{
f = d32; // { dg-error "error" }
f = d64; // { dg-error "error" }
f = d128; // { dg-error "error" }
d = d32; // { dg-error "error" }
d = d64; // { dg-error "error" }
d = d128; // { dg-error "error" }
ld = d32; // { dg-error "error" }
ld = d64; // { dg-error "error" }
ld = d128; // { dg-error "error" }
f = (float)d32; // { dg-error "error" }
f = (float)d64; // { dg-error "error" }
f = (float)d128; // { dg-error "error" }
d = (double)d32; // { dg-error "error" }
d = (double)d64; // { dg-error "error" }
d = (double)d128; // { dg-error "error" }
ld = (long double)d32; // { dg-error "error" }
ld = (long double)d64; // { dg-error "error" }
ld = (long double)d128; // { dg-error "error" }
}
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.6 Compound assignment (decimal32).
// ISO/IEC TR 24733 3.2.3.6 Compound assignment (decimal64).
// ISO/IEC TR 24733 3.2.4.6 Compound assignment (decimal128).
// Access member functions directly.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
decimal32 d32 (5);
decimal64 d64 (-10);
decimal128 d128 (25);
int si = -2;
unsigned int ui = 5;
long sl = -10;
unsigned long ul = 20;
long long sll = -25;
unsigned long long ull = 50;
void
compound_assignment_add_32 (void)
{
decimal32 a (1000), b;
b = a; b.operator+=(d32); VERIFY (b == 1005);
b = a; b.operator+=(d64); VERIFY (b == 990);
b = a; b.operator+=(d128); VERIFY (b == 1025);
b = a; b.operator+=(si); VERIFY (b == 998);
b = a; b.operator+=(ui); VERIFY (b == 1005);
b = a; b.operator+=(sl); VERIFY (b == 990);
b = a; b.operator+=(ul); VERIFY (b == 1020);
b = a; b.operator+=(sll); VERIFY (b == 975);
b = a; b.operator+=(ull); VERIFY (b == 1050);
}
void
compound_assignment_subtract_32 (void)
{
decimal32 a (1000), b;
b = a; b.operator-=(d32); VERIFY (b == 995);
b = a; b.operator-=(d64); VERIFY (b == 1010);
b = a; b.operator-=(d128); VERIFY (b == 975);
b = a; b.operator-=(si); VERIFY (b == 1002);
b = a; b.operator-=(ui); VERIFY (b == 995);
b = a; b.operator-=(sl); VERIFY (b == 1010);
b = a; b.operator-=(ul); VERIFY (b == 980);
b = a; b.operator-=(sll); VERIFY (b == 1025);
b = a; b.operator-=(ull); VERIFY (b == 950);
}
void
compound_assignment_multiply_32 (void)
{
decimal32 a (1000), b;
b = a; b.operator*=(d32); VERIFY (b == 5000);
b = a; b.operator*=(d64); VERIFY (b == -10000);
b = a; b.operator*=(d128); VERIFY (b == 25000);
b = a; b.operator*=(si); VERIFY (b == -2000);
b = a; b.operator*=(ui); VERIFY (b == 5000);
b = a; b.operator*=(sl); VERIFY (b == -10000);
b = a; b.operator*=(ul); VERIFY (b == 20000);
b = a; b.operator*=(sll); VERIFY (b == -25000);
b = a; b.operator*=(ull); VERIFY (b == 50000);
}
void
compound_assignment_divide_32 (void)
{
decimal32 a (1000), b;
b = a; b.operator/=(d32); VERIFY (b == 200);
b = a; b.operator/=(d64); VERIFY (b == -100);
b = a; b.operator/=(d128); VERIFY (b == 40);
b = a; b.operator/=(si); VERIFY (b == -500);
b = a; b.operator/=(ui); VERIFY (b == 200);
b = a; b.operator/=(sl); VERIFY (b == -100);
b = a; b.operator/=(ul); VERIFY (b == 50);
b = a; b.operator/=(sll); VERIFY (b == -40);
b = a; b.operator/=(ull); VERIFY (b == 20);
}
void
compound_assignment_add_64 (void)
{
decimal64 a (1000), b;
b = a; b.operator+=(d32); VERIFY (b == 1005);
b = a; b.operator+=(d64); VERIFY (b == 990);
b = a; b.operator+=(d128); VERIFY (b == 1025);
b = a; b.operator+=(si); VERIFY (b == 998);
b = a; b.operator+=(ui); VERIFY (b == 1005);
b = a; b.operator+=(sl); VERIFY (b == 990);
b = a; b.operator+=(ul); VERIFY (b == 1020);
b = a; b.operator+=(sll); VERIFY (b == 975);
b = a; b.operator+=(ull); VERIFY (b == 1050);
}
void
compound_assignment_subtract_64 (void)
{
decimal64 a (1000), b;
b = a; b.operator-=(d32); VERIFY (b == 995);
b = a; b.operator-=(d64); VERIFY (b == 1010);
b = a; b.operator-=(d128); VERIFY (b == 975);
b = a; b.operator-=(si); VERIFY (b == 1002);
b = a; b.operator-=(ui); VERIFY (b == 995);
b = a; b.operator-=(sl); VERIFY (b == 1010);
b = a; b.operator-=(ul); VERIFY (b == 980);
b = a; b.operator-=(sll); VERIFY (b == 1025);
b = a; b.operator-=(ull); VERIFY (b == 950);
}
void
compound_assignment_multiply_64 (void)
{
decimal64 a (1000), b;
b = a; b.operator*=(d32); VERIFY (b == 5000);
b = a; b.operator*=(d64); VERIFY (b == -10000);
b = a; b.operator*=(d128); VERIFY (b == 25000);
b = a; b.operator*=(si); VERIFY (b == -2000);
b = a; b.operator*=(ui); VERIFY (b == 5000);
b = a; b.operator*=(sl); VERIFY (b == -10000);
b = a; b.operator*=(ul); VERIFY (b == 20000);
b = a; b.operator*=(sll); VERIFY (b == -25000);
b = a; b.operator*=(ull); VERIFY (b == 50000);
}
void
compound_assignment_divide_64 (void)
{
decimal64 a (1000), b;
b = a; b.operator/=(d32); VERIFY (b == 200);
b = a; b.operator/=(d64); VERIFY (b == -100);
b = a; b.operator/=(d128); VERIFY (b == 40);
b = a; b.operator/=(si); VERIFY (b == -500);
b = a; b.operator/=(ui); VERIFY (b == 200);
b = a; b.operator/=(sl); VERIFY (b == -100);
b = a; b.operator/=(ul); VERIFY (b == 50);
b = a; b.operator/=(sll); VERIFY (b == -40);
b = a; b.operator/=(ull); VERIFY (b == 20);
}
void
compound_assignment_add_128 (void)
{
decimal128 a (1000), b;
b = a; b.operator+=(d32); VERIFY (b == 1005);
b = a; b.operator+=(d64); VERIFY (b == 990);
b = a; b.operator+=(d128); VERIFY (b == 1025);
b = a; b.operator+=(si); VERIFY (b == 998);
b = a; b.operator+=(ui); VERIFY (b == 1005);
b = a; b.operator+=(sl); VERIFY (b == 990);
b = a; b.operator+=(ul); VERIFY (b == 1020);
b = a; b.operator+=(sll); VERIFY (b == 975);
b = a; b.operator+=(ull); VERIFY (b == 1050);
}
void
compound_assignment_subtract_128 (void)
{
decimal128 a (1000), b;
b = a; b.operator-=(d32); VERIFY (b == 995);
b = a; b.operator-=(d64); VERIFY (b == 1010);
b = a; b.operator-=(d128); VERIFY (b == 975);
b = a; b.operator-=(si); VERIFY (b == 1002);
b = a; b.operator-=(ui); VERIFY (b == 995);
b = a; b.operator-=(sl); VERIFY (b == 1010);
b = a; b.operator-=(ul); VERIFY (b == 980);
b = a; b.operator-=(sll); VERIFY (b == 1025);
b = a; b.operator-=(ull); VERIFY (b == 950);
}
void
compound_assignment_multiply_128 (void)
{
decimal128 a (1000), b;
b = a; b.operator*=(d32); VERIFY (b == 5000);
b = a; b.operator*=(d64); VERIFY (b == -10000);
b = a; b.operator*=(d128); VERIFY (b == 25000);
b = a; b.operator*=(si); VERIFY (b == -2000);
b = a; b.operator*=(ui); VERIFY (b == 5000);
b = a; b.operator*=(sl); VERIFY (b == -10000);
b = a; b.operator*=(ul); VERIFY (b == 20000);
b = a; b.operator*=(sll); VERIFY (b == -25000);
b = a; b.operator*=(ull); VERIFY (b == 50000);
}
void
compound_assignment_divide_128 (void)
{
decimal128 a (1000), b;
b = a; b.operator/=(d32); VERIFY (b == 200);
b = a; b.operator/=(d64); VERIFY (b == -100);
b = a; b.operator/=(d128); VERIFY (b == 40);
b = a; b.operator/=(si); VERIFY (b == -500);
b = a; b.operator/=(ui); VERIFY (b == 200);
b = a; b.operator/=(sl); VERIFY (b == -100);
b = a; b.operator/=(ul); VERIFY (b == 50);
b = a; b.operator/=(sll); VERIFY (b == -40);
b = a; b.operator/=(ull); VERIFY (b == 20);
}
int
main ()
{
compound_assignment_add_32 ();
compound_assignment_subtract_32 ();
compound_assignment_multiply_32 ();
compound_assignment_divide_32 ();
compound_assignment_add_64 ();
compound_assignment_subtract_64 ();
compound_assignment_multiply_64 ();
compound_assignment_divide_64 ();
compound_assignment_add_128 ();
compound_assignment_subtract_128 ();
compound_assignment_multiply_128 ();
compound_assignment_divide_128 ();
}
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.6 Compound assignment (decimal32).
// ISO/IEC TR 24733 3.2.3.6 Compound assignment (decimal64).
// ISO/IEC TR 24733 3.2.4.6 Compound assignment (decimal128).
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
decimal32 d32 (5);
decimal64 d64 (-10);
decimal128 d128 (25);
int si = -2;
unsigned int ui = 5;
long sl = -10;
unsigned long ul = 20;
long long sll = -25;
unsigned long long ull = 50;
void
compound_assignment_add_32 (void)
{
decimal32 a (1000), b;
b = a; b += d32; VERIFY (b == 1005);
b = a; b += d64; VERIFY (b == 990);
b = a; b += d128; VERIFY (b == 1025);
b = a; b += si; VERIFY (b == 998);
b = a; b += ui; VERIFY (b == 1005);
b = a; b += sl; VERIFY (b == 990);
b = a; b += ul; VERIFY (b == 1020);
b = a; b += sll; VERIFY (b == 975);
b = a; b += ull; VERIFY (b == 1050);
}
void
compound_assignment_subtract_32 (void)
{
decimal32 a (1000), b;
b = a; b -= d32; VERIFY (b == 995);
b = a; b -= d64; VERIFY (b == 1010);
b = a; b -= d128; VERIFY (b == 975);
b = a; b -= si; VERIFY (b == 1002);
b = a; b -= ui; VERIFY (b == 995);
b = a; b -= sl; VERIFY (b == 1010);
b = a; b -= ul; VERIFY (b == 980);
b = a; b -= sll; VERIFY (b == 1025);
b = a; b -= ull; VERIFY (b == 950);
}
void
compound_assignment_multiply_32 (void)
{
decimal32 a (1000), b;
b = a; b *= d32; VERIFY (b == 5000);
b = a; b *= d64; VERIFY (b == -10000);
b = a; b *= d128; VERIFY (b == 25000);
b = a; b *= si; VERIFY (b == -2000);
b = a; b *= ui; VERIFY (b == 5000);
b = a; b *= sl; VERIFY (b == -10000);
b = a; b *= ul; VERIFY (b == 20000);
b = a; b *= sll; VERIFY (b == -25000);
b = a; b *= ull; VERIFY (b == 50000);
}
void
compound_assignment_divide_32 (void)
{
decimal32 a (1000), b;
b = a; b /= d32; VERIFY (b == 200);
b = a; b /= d64; VERIFY (b == -100);
b = a; b /= d128; VERIFY (b == 40);
b = a; b /= si; VERIFY (b == -500);
b = a; b /= ui; VERIFY (b == 200);
b = a; b /= sl; VERIFY (b == -100);
b = a; b /= ul; VERIFY (b == 50);
b = a; b /= sll; VERIFY (b == -40);
b = a; b /= ull; VERIFY (b == 20);
}
void
compound_assignment_add_64 (void)
{
decimal64 a (1000), b;
b = a; b += d32; VERIFY (b == 1005);
b = a; b += d64; VERIFY (b == 990);
b = a; b += d128; VERIFY (b == 1025);
b = a; b += si; VERIFY (b == 998);
b = a; b += ui; VERIFY (b == 1005);
b = a; b += sl; VERIFY (b == 990);
b = a; b += ul; VERIFY (b == 1020);
b = a; b += sll; VERIFY (b == 975);
b = a; b += ull; VERIFY (b == 1050);
}
void
compound_assignment_subtract_64 (void)
{
decimal64 a (1000), b;
b = a; b -= d32; VERIFY (b == 995);
b = a; b -= d64; VERIFY (b == 1010);
b = a; b -= d128; VERIFY (b == 975);
b = a; b -= si; VERIFY (b == 1002);
b = a; b -= ui; VERIFY (b == 995);
b = a; b -= sl; VERIFY (b == 1010);
b = a; b -= ul; VERIFY (b == 980);
b = a; b -= sll; VERIFY (b == 1025);
b = a; b -= ull; VERIFY (b == 950);
}
void
compound_assignment_multiply_64 (void)
{
decimal64 a (1000), b;
b = a; b *= d32; VERIFY (b == 5000);
b = a; b *= d64; VERIFY (b == -10000);
b = a; b *= d128; VERIFY (b == 25000);
b = a; b *= si; VERIFY (b == -2000);
b = a; b *= ui; VERIFY (b == 5000);
b = a; b *= sl; VERIFY (b == -10000);
b = a; b *= ul; VERIFY (b == 20000);
b = a; b *= sll; VERIFY (b == -25000);
b = a; b *= ull; VERIFY (b == 50000);
}
void
compound_assignment_divide_64 (void)
{
decimal64 a (1000), b;
b = a; b /= d32; VERIFY (b == 200);
b = a; b /= d64; VERIFY (b == -100);
b = a; b /= d128; VERIFY (b == 40);
b = a; b /= si; VERIFY (b == -500);
b = a; b /= ui; VERIFY (b == 200);
b = a; b /= sl; VERIFY (b == -100);
b = a; b /= ul; VERIFY (b == 50);
b = a; b /= sll; VERIFY (b == -40);
b = a; b /= ull; VERIFY (b == 20);
}
void
compound_assignment_add_128 (void)
{
decimal128 a (1000), b;
b = a; b += d32; VERIFY (b == 1005);
b = a; b += d64; VERIFY (b == 990);
b = a; b += d128; VERIFY (b == 1025);
b = a; b += si; VERIFY (b == 998);
b = a; b += ui; VERIFY (b == 1005);
b = a; b += sl; VERIFY (b == 990);
b = a; b += ul; VERIFY (b == 1020);
b = a; b += sll; VERIFY (b == 975);
b = a; b += ull; VERIFY (b == 1050);
}
void
compound_assignment_subtract_128 (void)
{
decimal128 a (1000), b;
b = a; b -= d32; VERIFY (b == 995);
b = a; b -= d64; VERIFY (b == 1010);
b = a; b -= d128; VERIFY (b == 975);
b = a; b -= si; VERIFY (b == 1002);
b = a; b -= ui; VERIFY (b == 995);
b = a; b -= sl; VERIFY (b == 1010);
b = a; b -= ul; VERIFY (b == 980);
b = a; b -= sll; VERIFY (b == 1025);
b = a; b -= ull; VERIFY (b == 950);
}
void
compound_assignment_multiply_128 (void)
{
decimal128 a (1000), b;
b = a; b *= d32; VERIFY (b == 5000);
b = a; b *= d64; VERIFY (b == -10000);
b = a; b *= d128; VERIFY (b == 25000);
b = a; b *= si; VERIFY (b == -2000);
b = a; b *= ui; VERIFY (b == 5000);
b = a; b *= sl; VERIFY (b == -10000);
b = a; b *= ul; VERIFY (b == 20000);
b = a; b *= sll; VERIFY (b == -25000);
b = a; b *= ull; VERIFY (b == 50000);
}
void
compound_assignment_divide_128 (void)
{
decimal128 a (1000), b;
b = a; b /= d32; VERIFY (b == 200);
b = a; b /= d64; VERIFY (b == -100);
b = a; b /= d128; VERIFY (b == 40);
b = a; b /= si; VERIFY (b == -500);
b = a; b /= ui; VERIFY (b == 200);
b = a; b /= sl; VERIFY (b == -100);
b = a; b /= ul; VERIFY (b == 50);
b = a; b /= sll; VERIFY (b == -40);
b = a; b /= ull; VERIFY (b == 20);
}
int
main ()
{
compound_assignment_add_32 ();
compound_assignment_subtract_32 ();
compound_assignment_multiply_32 ();
compound_assignment_divide_32 ();
compound_assignment_add_64 ();
compound_assignment_subtract_64 ();
compound_assignment_multiply_64 ();
compound_assignment_divide_64 ();
compound_assignment_add_128 ();
compound_assignment_subtract_128 ();
compound_assignment_multiply_128 ();
compound_assignment_divide_128 ();
}
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.2 Conversion from floating-point type (decimal32).
// ISO/IEC TR 24733 3.2.3.2 Conversion from floating-point type (decimal64).
// ISO/IEC TR 24733 3.2.4.2 Conversion from floating-point type (decimal128).
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
void
conversion_from_float_32 ()
{
decimal32 d32(123);
decimal64 d64(234);
decimal128 d128(345);
float f = 456.F;
double d = 567.;
long double ld = 678.L;
d32 = (decimal32) d64;
VERIFY (d32 == make_decimal32 (234LL, 0));
d32 = (decimal32) d128;
VERIFY (d32 == make_decimal32 (345LL, 0));
d32 = (decimal32) f;
VERIFY (d32 == make_decimal32 (456LL, 0));
d32 = (decimal32) d;
VERIFY (d32 == make_decimal32 (567LL, 0));
d32 = (decimal32) ld;
VERIFY (d32 == make_decimal32 (678LL, 0));
}
void
conversion_from_float_64 ()
{
decimal32 d32(123);
decimal64 d64(234);
decimal128 d128(345);
float f = 456.F;
double d = 567.;
long double ld = 678.L;
d64 = d32;
VERIFY (d64 == make_decimal64 (123LL, 0));
d64 = (decimal64) d128;
VERIFY (d64 == make_decimal64 (345LL, 0));
d64 = (decimal64) f;
VERIFY (d64 == make_decimal64 (456LL, 0));
d64 = (decimal64) d;
VERIFY (d64 == make_decimal64 (567LL, 0));
d64 = (decimal64) ld;
VERIFY (d64 == make_decimal64 (678LL, 0));
}
void
conversion_from_float_128 ()
{
decimal32 d32(123);
decimal64 d64(234);
decimal128 d128(345);
float f = 456.F;
double d = 567.;
long double ld = 678.L;
d128 = d32;
VERIFY (d128 == make_decimal128 (123LL, 0));
d128 = d64;
VERIFY (d128 == make_decimal128 (234LL, 0));
d128 = (decimal128) f;
VERIFY (d128 == make_decimal128 (456LL, 0));
d128 = (decimal128) d;
VERIFY (d128 == make_decimal128 (567LL, 0));
d128 = (decimal128) ld;
VERIFY (d128 == make_decimal128 (678LL, 0));
}
int
main ()
{
conversion_from_float_32 ();
conversion_from_float_64 ();
conversion_from_float_128 ();
}
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.3 Conversion from integral type (decimal32).
// ISO/IEC TR 24733 3.2.3.3 Conversion from integral type (decimal64).
// ISO/IEC TR 24733 3.2.4.3 Conversion from integral type (decimal128).
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
void
conversion_from_integral_p32 ()
{
decimal32 d;
decimal32 from_si (1);
decimal32 from_ui (2U);
decimal32 from_sl (3L);
decimal32 from_ul (4UL);
decimal32 from_sll (5LL);
decimal32 from_ull (6ULL);
d++; VERIFY (from_si == d);
d++; VERIFY (from_ui == d);
d++; VERIFY (from_sl == d);
d++; VERIFY (from_ul == d);
d++; VERIFY (from_sll == d);
d++; VERIFY (from_ull == d);
from_si = 7;
d++; VERIFY (from_si == d);
from_ui = 8U;
d++; VERIFY (from_ui == d);
from_sl = 9L;
d++; VERIFY (from_sl == d);
from_ul = 10UL;
d++; VERIFY (from_ul == d);
from_sll = 11LL;
d++; VERIFY (from_sll == d);
from_ull = 12ULL;
d++; VERIFY (from_ull == d);
}
void
conversion_from_integral_m32 ()
{
decimal32 d;
decimal32 from_si (-1);
decimal32 from_sl (-2L);
decimal32 from_sll (-3LL);
d--; VERIFY (from_si == d);
d--; VERIFY (from_sl == d);
d--; VERIFY (from_sll == d);
from_si = -4;
d--; VERIFY (from_si == d);
from_sl = -5L;
d--; VERIFY (from_sl == d);
from_sll = -6LL;
d--; VERIFY (from_sll == d);
}
void
conversion_from_integral_p64 ()
{
decimal64 d;
decimal64 from_si (1);
decimal64 from_ui (2U);
decimal64 from_sl (3L);
decimal64 from_ul (4UL);
decimal64 from_sll (5LL);
decimal64 from_ull (6ULL);
d++; VERIFY (from_si == d);
d++; VERIFY (from_ui == d);
d++; VERIFY (from_sl == d);
d++; VERIFY (from_ul == d);
d++; VERIFY (from_sll == d);
d++; VERIFY (from_ull == d);
from_si = 7;
d++; VERIFY (from_si == d);
from_ui = 8U;
d++; VERIFY (from_ui == d);
from_sl = 9L;
d++; VERIFY (from_sl == d);
from_ul = 10UL;
d++; VERIFY (from_ul == d);
from_sll = 11LL;
d++; VERIFY (from_sll == d);
from_ull = 12ULL;
d++; VERIFY (from_ull == d);
}
void
conversion_from_integral_m64 ()
{
decimal64 d;
decimal64 from_si (-1);
decimal64 from_sl (-2L);
decimal64 from_sll (-3LL);
d--; VERIFY (from_si == d);
d--; VERIFY (from_sl == d);
d--; VERIFY (from_sll == d);
from_si = -4;
d--; VERIFY (from_si == d);
from_sl = -5L;
d--; VERIFY (from_sl == d);
from_sll = -6LL;
d--; VERIFY (from_sll == d);
}
void
conversion_from_integral_p128 ()
{
decimal128 d;
decimal128 from_si (1);
decimal128 from_ui (2U);
decimal128 from_sl (3L);
decimal128 from_ul (4UL);
decimal128 from_sll (5LL);
decimal128 from_ull (6ULL);
d++; VERIFY (from_si == d);
d++; VERIFY (from_ui == d);
d++; VERIFY (from_sl == d);
d++; VERIFY (from_ul == d);
d++; VERIFY (from_sll == d);
d++; VERIFY (from_ull == d);
from_si = 7;
d++; VERIFY (from_si == d);
from_ui = 8U;
d++; VERIFY (from_ui == d);
from_sl = 9L;
d++; VERIFY (from_sl == d);
from_ul = 10UL;
d++; VERIFY (from_ul == d);
from_sll = 11LL;
d++; VERIFY (from_sll == d);
from_ull = 12ULL;
}
void
conversion_from_integral_m128 ()
{
decimal128 d;
decimal128 from_si (-1);
decimal128 from_sl (-2L);
decimal128 from_sll (-3LL);
d--; VERIFY (from_si == d);
d--; VERIFY (from_sl == d);
d--; VERIFY (from_sll == d);
from_si = -4;
d--; VERIFY (from_si == d);
from_sl = -5L;
d--; VERIFY (from_sl == d);
from_sll = -6LL;
d--; VERIFY (from_sll == d);
}
int
main ()
{
conversion_from_integral_p32 ();
conversion_from_integral_m32 ();
conversion_from_integral_p64 ();
conversion_from_integral_m64 ();
conversion_from_integral_p128 ();
conversion_from_integral_m128 ();
}
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.6 Conversion to generic floating-point type.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
void
conversion_to_generic_float_32 ()
{
std::decimal::decimal32 d32(123);
float f;
double d;
long double ld;
f = decimal32_to_float (d32);
VERIFY (f == 123.F);
d = decimal32_to_double (d32);
VERIFY (d == 123.);
ld = decimal32_to_long_double (d32);
VERIFY (ld == 123.L);
d32++;
f = decimal_to_float (d32);
VERIFY (f == 124.F);
d = decimal_to_double (d32);
VERIFY (d == 124.);
ld = decimal_to_long_double (d32);
VERIFY (ld == 124.L);
}
void
conversion_to_generic_float_64 ()
{
std::decimal::decimal64 d64(234);
float f;
double d;
long double ld;
f = decimal64_to_float (d64);
VERIFY (f == 234.F);
d = decimal64_to_double (d64);
VERIFY (d == 234.);
ld = decimal64_to_long_double (d64);
VERIFY (ld == 234.L);
d64++;
f = decimal_to_float (d64);
VERIFY (f == 235.F);
d = decimal_to_double (d64);
VERIFY (d == 235.);
ld = decimal_to_long_double (d64);
VERIFY (ld == 235.L);
}
void
conversion_to_generic_float_128 ()
{
std::decimal::decimal128 d128(345);
float f;
double d;
long double ld;
f = decimal128_to_float (d128);
VERIFY (f == 345.F);
d = decimal128_to_double (d128);
VERIFY (d == 345.);
ld = decimal128_to_long_double (d128);
VERIFY (ld == 345.L);
d128++;
f = decimal_to_float (d128);
VERIFY (f == 346.F);
d = decimal_to_double (d128);
VERIFY (d == 346.);
ld = decimal_to_long_double (d128);
VERIFY (ld == 346.L);
}
int
main ()
{
conversion_to_generic_float_32 ();
conversion_to_generic_float_64 ();
conversion_to_generic_float_128 ();
}
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.4 Conversion to integral type (decimal32).
// ISO/IEC TR 24733 3.2.3.4 Conversion to integral type (decimal64).
// ISO/IEC TR 24733 3.2.4.4 Conversion to integral type (decimal128).
#include <decimal/decimal>
#include <climits>
#include <cstdio>
#include <testsuite_hooks.h>
// Use extension to replace implicit long long conversion with function call.
#define LONGLONG(X) decimal_to_long_long(X)
using namespace std::decimal;
void
conversion_to_integral_32 (void)
{
#undef MAXVAL
#define MAXVAL 999999LL
decimal32 a, b (1), c (-1), d (MAXVAL), e (-MAXVAL);
long long ll;
ll = LONGLONG (a); VERIFY (ll == 0LL);
ll = LONGLONG (b); VERIFY (ll == 1LL);
ll = LONGLONG (c); VERIFY (ll == -1LL);
ll = LONGLONG (d); VERIFY (ll == MAXVAL);
ll = LONGLONG (e); VERIFY (ll == -MAXVAL);
}
void
conversion_to_integral_64 (void)
{
#undef MAXVAL
#define MAXVAL 999999999999999LL
decimal64 a, b (1), c (-1), d (MAXVAL), e (-MAXVAL);
long long ll;
ll = LONGLONG (a); VERIFY (ll == 0LL);
ll = LONGLONG (b); VERIFY (ll == 1LL);
ll = LONGLONG (c); VERIFY (ll == -1LL);
ll = LONGLONG (d); VERIFY (ll == MAXVAL);
ll = LONGLONG (e); VERIFY (ll == -MAXVAL);
}
void
conversion_to_integral_128 (void)
{
#undef MAXVAL
#define MAXVAL LONG_LONG_MAX
decimal128 a, b (1), c (-1), d (MAXVAL), e (-MAXVAL);
long long ll;
ll = LONGLONG (a); VERIFY (ll == 0LL);
ll = LONGLONG (b); VERIFY (ll == 1LL);
ll = LONGLONG (c); VERIFY (ll == -1LL);
ll = LONGLONG (d); VERIFY (ll == MAXVAL);
ll = LONGLONG (e); VERIFY (ll == -MAXVAL);
}
int
main ()
{
conversion_to_integral_32 ();
conversion_to_integral_64 ();
conversion_to_integral_128 ();
}
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.1 Construct/copy/destroy (decimal32).
// ISO/IEC TR 24733 3.2.3.1 Construct/copy/destroy (decimal64).
// ISO/IEC TR 24733 3.2.4.1 Construct/copy/destroy (decimal128).
// Test the default constructor.
#include <decimal/decimal>
#include <cstring>
#include <testsuite_hooks.h>
using namespace std::decimal;
void
ctor_32 (void)
{
decimal32 a;
float b __attribute__((mode(SD))) = 0.e-101DF;
VERIFY (memcmp (&a, &b, 4) == 0);
}
void
ctor_64 (void)
{
decimal64 a;
float b __attribute__((mode(DD))) = 0.e-398DD;
VERIFY (memcmp (&a, &b, 8) == 0);
}
void
ctor_128 (void)
{
decimal128 a;
float b __attribute__((mode(TD))) = 0.e-6176DL;
VERIFY (memcmp (&a, &b, 16) == 0);
}
int
main ()
{
ctor_32 ();
ctor_64 ();
ctor_128 ();
}
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.5 Increment and decrement operators (decimal32).
// ISO/IEC TR 24733 3.2.3.5 Increment and decrement operators (decimal64).
// ISO/IEC TR 24733 3.2.4.5 Increment and decrement operators (decimal128).
// Access member functions directly.
#include <decimal/decimal>
#include <testsuite_hooks.h>
// Use extension to replace implicit long long conversion with function call.
#define LONGLONG(X) decimal_to_long_long(X)
using namespace std::decimal;
void
incdec32 (void)
{
int ival;
std::decimal::decimal32 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
b.operator++();
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator++(1);
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator--();
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b.operator--(1);
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = b.operator++();
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b.operator++(1);
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = b.operator--();
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b.operator--(1);
ival = LONGLONG (c); VERIFY (ival == 11);
}
void
incdec64 (void)
{
int ival;
std::decimal::decimal64 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
b.operator++();
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator++(1);
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator--();
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b.operator--(1);
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = b.operator++();
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b.operator++(1);
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = b.operator--();
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b.operator--(1);
ival = LONGLONG (c); VERIFY (ival == 11);
}
void
incdec128 (void)
{
int ival;
std::decimal::decimal128 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
b.operator++();
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator++(1);
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator--();
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b.operator--(1);
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = b.operator++();
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b.operator++(1);
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = b.operator--();
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b.operator--(1);
ival = LONGLONG (c); VERIFY (ival == 11);
}
int
main ()
{
incdec32 ();
incdec64 ();
incdec128 ();
}
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.5 Increment and decrement operators (decimal32).
// ISO/IEC TR 24733 3.2.3.5 Increment and decrement operators (decimal64).
// ISO/IEC TR 24733 3.2.4.5 Increment and decrement operators (decimal128).
#include <decimal/decimal>
#include <testsuite_hooks.h>
// Use extension to replace implicit long long conversion with function call.
#define LONGLONG(X) decimal_to_long_long(X)
using namespace std::decimal;
void
incdec32 (void)
{
int ival;
std::decimal::decimal32 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
++b;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b++;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
--b;
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b--;
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = ++b;
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b++;
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = --b;
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b--;
ival = LONGLONG (c); VERIFY (ival == 11);
}
void
incdec64 (void)
{
int ival;
std::decimal::decimal64 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
++b;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b++;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
--b;
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b--;
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = ++b;
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b++;
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = --b;
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b--;
ival = LONGLONG (c); VERIFY (ival == 11);
}
void
incdec128 (void)
{
int ival;
std::decimal::decimal128 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
++b;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b++;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
--b;
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b--;
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = ++b;
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b++;
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = --b;
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b--;
ival = LONGLONG (c); VERIFY (ival == 11);
}
int
main ()
{
incdec32 ();
incdec64 ();
incdec128 ();
}
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.5 Initialization from coefficient and exponent.
#include <decimal/decimal>
#include <cstring>
#include <testsuite_hooks.h>
#define PASTE2(A,B) A ## B
#define PASTE(A,B) PASTE2(A,B)
#define TESTVAL_NEG(COEFF,ESIGN,EXP,SUF,NUM,SIZE) \
x = PASTE(PASTE(PASTE(PASTE(PASTE(COEFF,.),E),ESIGN),EXP),SUF); \
sll = PASTE(COEFF,LL); \
i = ESIGN EXP; \
a = PASTE(make_decimal,32) (sll, i); \
b = PASTE(make_decimal,32) (PASTE(COEFF,LL), ESIGN EXP); \
VERIFY ((__builtin_memcmp ((void *)&x, (void *)&a, SIZE) == 0) \
&& (__builtin_memcmp ((void *)&x, (void *)&b,SIZE) == 0));
#define TESTVAL_NONNEG(COEFF,ESIGN,EXP,SUF,NUM,SIZE) \
x = PASTE(PASTE(PASTE(PASTE(PASTE(COEFF,.),E),ESIGN),EXP),SUF); \
sll = PASTE(COEFF,LL); \
ull = PASTE(COEFF,ULL); \
i = ESIGN EXP; \
a = PASTE(make_decimal,32) (sll, i); \
b = PASTE(make_decimal,32) (PASTE(COEFF,LL), ESIGN EXP); \
c = PASTE(make_decimal,32) (ull, i); \
d = PASTE(make_decimal,32) (PASTE(COEFF,ULL), ESIGN EXP); \
VERIFY ((__builtin_memcmp ((void *)&x, (void *)&a, SIZE) == 0) \
&& (__builtin_memcmp ((void *)&x, (void *)&b,SIZE) == 0) \
&& (__builtin_memcmp ((void *)&x, (void *)&c,SIZE) == 0) \
&& (__builtin_memcmp ((void *)&x, (void *)&d,SIZE) == 0));
using namespace std::decimal;
void
make_decimal_32 (void)
{
decimal32 a, b, c, d;
float x __attribute__((mode(SD)));
int i;
unsigned long sz = sizeof (decimal32);
volatile long long sll;
volatile unsigned long long ull;
TESTVAL_NONNEG (0, +, 0, DF, 32, sz);
TESTVAL_NONNEG (5, +, 1, DF, 32, sz);
TESTVAL_NONNEG (50, +, 0, DF, 32, sz);
TESTVAL_NONNEG (500, +, 0, DF, 32, sz);
TESTVAL_NEG (-25, -, 3, DF, 32, sz)
TESTVAL_NEG (-500, +, 0, DF, 32, sz);
TESTVAL_NONNEG (999999, +, 91, DF, 32, sz);
TESTVAL_NONNEG (1, -, 9, DF, 32, sz);
TESTVAL_NONNEG (1, -, 90, DF, 32, sz);
TESTVAL_NONNEG (1, -, 95, DF, 32, sz);
TESTVAL_NONNEG (1, -, 101, DF, 32, sz);
TESTVAL_NEG (-1, -, 101, DF, 32, sz);
}
void
make_decimal_64 (void)
{
decimal64 a, b, c, d;
float x __attribute__((mode(DD)));
int i;
unsigned long sz = sizeof (decimal64);
volatile long long sll;
volatile unsigned long long ull;
TESTVAL_NONNEG (0, +, 0, DF, 64, sz);
TESTVAL_NONNEG (5, +, 1, DF, 64, sz);
TESTVAL_NONNEG (50, +, 0, DF, 64, sz);
TESTVAL_NONNEG (500, +, 0, DF, 64, sz);
TESTVAL_NEG (-25, -, 3, DF, 64, sz)
TESTVAL_NEG (-500, +, 0, DF, 64, sz);
TESTVAL_NONNEG (999999, +, 91, DF, 64, sz);
TESTVAL_NONNEG (1, -, 9, DF, 64, sz);
TESTVAL_NONNEG (1, -, 90, DF, 64, sz);
TESTVAL_NONNEG (1, -, 95, DF, 64, sz);
TESTVAL_NONNEG (1, -, 101, DF, 64, sz);
TESTVAL_NEG (-1, -, 101, DF, 64, sz);
}
void
make_decimal_128 (void)
{
decimal128 a, b, c, d;
float x __attribute__((mode(TD)));
int i;
unsigned long sz = sizeof (decimal128);
volatile long long sll;
volatile unsigned long long ull;
TESTVAL_NONNEG (0, +, 0, DF, 128, sz);
TESTVAL_NONNEG (5, +, 1, DF, 128, sz);
TESTVAL_NONNEG (50, +, 0, DF, 128, sz);
TESTVAL_NONNEG (500, +, 0, DF, 128, sz);
TESTVAL_NEG (-25, -, 3, DF, 128, sz)
TESTVAL_NEG (-500, +, 0, DF, 128, sz);
TESTVAL_NONNEG (999999, +, 91, DF, 128, sz);
TESTVAL_NONNEG (1, -, 9, DF, 128, sz);
TESTVAL_NONNEG (1, -, 90, DF, 128, sz);
TESTVAL_NONNEG (1, -, 95, DF, 128, sz);
TESTVAL_NONNEG (1, -, 101, DF, 128, sz);
TESTVAL_NEG (-1, -, 101, DF, 128, sz);
}
int
main ()
{
make_decimal_32 ();
make_decimal_64 ();
make_decimal_128 ();
}
// Copyright (C) 2009 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 }
// { dg-require-effective-target-dfp }
// Test that binary operators do not accept mixed decimal and generic
// floating-point operands. This isn't explicity prohibited in
// ISO/IEC TR 24733 but it is prohibited in C, and in C++ there should
// not be an implicit conversion from a decimal floating-point type to
// a generic floating-point type.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
decimal32 a32, b32, c32;
decimal64 a64, b64, c64;
decimal128 a128, b128, c128;
float f;
double d;
long double ld;
bool b1, b2, b3, b4, b5, b6;
void
bad_add (void)
{
a32 = b32 + f; // { dg-error "error" }
a32 = ld + b32; // { dg-error "error" }
a64 = b64 + d; // { dg-error "error" }
a64 = ld + b64; // { dg-error "error" }
a128 = b128 + ld; // { dg-error "error" }
a128 = d + b128; // { dg-error "error" }
}
void
bad_subtract (void)
{
a32 = b32 - f; // { dg-error "error" }
a32 = ld - b32; // { dg-error "error" }
a64 = b64 - d; // { dg-error "error" }
a64 = ld - b64; // { dg-error "error" }
a128 = b128 - ld; // { dg-error "error" }
a128 = d - b128; // { dg-error "error" }
}
void
bad_multiply (void)
{
a32 = b32 * f; // { dg-error "error" }
a32 = ld * b32; // { dg-error "error" }
a64 = b64 * d; // { dg-error "error" }
a64 = ld * b64; // { dg-error "error" }
a128 = b128 * ld; // { dg-error "error" }
a128 = d * b128; // { dg-error "error" }
}
void
bad_divide (void)
{
a32 = b32 / f; // { dg-error "error" }
a32 = ld / b32; // { dg-error "error" }
a64 = b64 / d; // { dg-error "error" }
a64 = ld / b64; // { dg-error "error" }
a128 = b128 / ld; // { dg-error "error" }
a128 = d / b128; // { dg-error "error" }
}
void
bad_eq (void)
{
b1 = b32 == f; // { dg-error "error" }
b2 = ld == b32; // { dg-error "error" }
b3 = b64 == d; // { dg-error "error" }
b4 = ld == b64; // { dg-error "error" }
b5 = b128 == ld; // { dg-error "error" }
b6 = d == b128; // { dg-error "error" }
}
void
bad_ne (void)
{
b1 = b32 != f; // { dg-error "error" }
b2 = ld != b32; // { dg-error "error" }
b3 = b64 != d; // { dg-error "error" }
b4 = ld != b64; // { dg-error "error" }
b5 = b128 != ld; // { dg-error "error" }
b6 = d != b128; // { dg-error "error" }
}
void
bad_lt (void)
{
b1 = b32 < f; // { dg-error "error" }
b2 = ld < b32; // { dg-error "error" }
b3 = b64 < d; // { dg-error "error" }
b4 = ld < b64; // { dg-error "error" }
b5 = b128 < ld; // { dg-error "error" }
b6 = d < b128; // { dg-error "error" }
}
void
bad_le (void)
{
b1 = b32 <= f; // { dg-error "error" }
b2 = ld <= b32; // { dg-error "error" }
b3 = b64 <= d; // { dg-error "error" }
b4 = ld <= b64; // { dg-error "error" }
b5 = b128 <= ld; // { dg-error "error" }
b6 = d <= b128; // { dg-error "error" }
}
void
bad_gt (void)
{
b1 = b32 > f; // { dg-error "error" }
b2 = ld > b32; // { dg-error "error" }
b3 = b64 > d; // { dg-error "error" }
b4 = ld > b64; // { dg-error "error" }
b5 = b128 > ld; // { dg-error "error" }
b6 = d > b128; // { dg-error "error" }
}
void
bad_ge (void)
{
b1 = b32 >= f; // { dg-error "error" }
b2 = ld >= b32; // { dg-error "error" }
b3 = b64 >= d; // { dg-error "error" }
b4 = ld >= b64; // { dg-error "error" }
b5 = b128 >= ld; // { dg-error "error" }
b6 = d >= b128; // { dg-error "error" }
}
void
bad_pluseq (void)
{
a32 += f; // { dg-error "error" }
a32 += d; // { dg-error "error" }
a32 += ld; // { dg-error "error" }
a64 += f; // { dg-error "error" }
a64 += d; // { dg-error "error" }
a64 += ld; // { dg-error "error" }
a128 += f; // { dg-error "error" }
a128 += d; // { dg-error "error" }
a128 += ld; // { dg-error "error" }
}
void
bad_minuseq (void)
{
a32 -= f; // { dg-error "error" }
a32 -= d; // { dg-error "error" }
a32 -= ld; // { dg-error "error" }
a64 -= f; // { dg-error "error" }
a64 -= d; // { dg-error "error" }
a64 -= ld; // { dg-error "error" }
a128 -= f; // { dg-error "error" }
a128 -= d; // { dg-error "error" }
a128 -= ld; // { dg-error "error" }
}
void
bad_timeseq (void)
{
a32 *= f; // { dg-error "error" }
a32 *= d; // { dg-error "error" }
a32 *= ld; // { dg-error "error" }
a64 *= f; // { dg-error "error" }
a64 *= d; // { dg-error "error" }
a64 *= ld; // { dg-error "error" }
a128 *= f; // { dg-error "error" }
a128 *= d; // { dg-error "error" }
a128 *= ld; // { dg-error "error" }
}
void
bad_divideeq (void)
{
a32 /= f; // { dg-error "error" }
a32 /= d; // { dg-error "error" }
a32 /= ld; // { dg-error "error" }
a64 /= f; // { dg-error "error" }
a64 /= d; // { dg-error "error" }
a64 /= ld; // { dg-error "error" }
a128 /= f; // { dg-error "error" }
a128 /= d; // { dg-error "error" }
a128 /= ld; // { dg-error "error" }
}
// { dg-excess-errors "notes about candidates" }
// Copyright (C) 2009 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 }
// { dg-require-effective-target-dfp }
// Test that C++ binary operators that are restricted to integer operands
// do not accept decimal float operands.
#include <decimal/decimal>
using namespace std::decimal;
decimal32 a32, b32, c32;
decimal64 a64, b64, c64;
decimal128 a128, b128, c128;
void
modulus (void)
{
a32 = b32 % c32; // { dg-error "error" }
a64 = b64 % c64; // { dg-error "error" }
a128 = b128 % c128; // { dg-error "error" }
a128 = b32 % c128; // { dg-error "error" }
a128 = b64 % c128; // { dg-error "error" }
a32 = 100 % c32; // { dg-error "error" }
a64 = 10 % c64; // { dg-error "error" }
a128 = 1000 % c128; // { dg-error "error" }
a32 = b32 % 7; // { dg-error "error" }
a64 = b64 % 5; // { dg-error "error" }
a128 = b128 % 3; // { dg-error "error" }
}
void
bitwise_right_shift (void)
{
a32 = b32 >> c32; // { dg-error "error" }
a64 = b64 >> c64; // { dg-error "error" }
a128 = b128 >> c128; // { dg-error "error" }
a128 = b32 >> c128; // { dg-error "error" }
a128 = b64 >> c128; // { dg-error "error" }
a32 = 100 >> c32; // { dg-error "error" }
a64 = 10 >> c64; // { dg-error "error" }
a128 = 1000 >> c128; // { dg-error "error" }
a32 = b32 >> 7; // { dg-error "error" }
a64 = b64 >> 5; // { dg-error "error" }
a128 = b128 >> 3; // { dg-error "error" }
}
void
bitwise_left_shift (void)
{
a32 = b32 << c32; // { dg-error "error" }
a64 = b64 << c64; // { dg-error "error" }
a128 = b128 << c128; // { dg-error "error" }
a128 = b32 << c128; // { dg-error "error" }
a128 = b64 << c128; // { dg-error "error" }
a32 = 100 << c32; // { dg-error "error" }
a64 = 10 << c64; // { dg-error "error" }
a128 = 1000 << c128; // { dg-error "error" }
a32 = b32 << 7; // { dg-error "error" }
a64 = b64 << 5; // { dg-error "error" }
a128 = b128 << 3; // { dg-error "error" }
}
void
bitwise_exclusive_or (void)
{
a32 = b32 ^ c32; // { dg-error "error" }
a64 = b64 ^ c64; // { dg-error "error" }
a128 = b128 ^ c128; // { dg-error "error" }
a128 = b32 ^ c128; // { dg-error "error" }
a128 = b64 ^ c128; // { dg-error "error" }
a32 = 100 ^ c32; // { dg-error "error" }
a64 = 10 ^ c64; // { dg-error "error" }
a128 = 1000 ^ c128; // { dg-error "error" }
a32 = b32 ^ 7; // { dg-error "error" }
a64 = b64 ^ 5; // { dg-error "error" }
a128 = b128 ^ 3; // { dg-error "error" }
}
void
bitwise_inclusive_or (void)
{
a32 = b32 | c32; // { dg-error "error" }
a64 = b64 | c64; // { dg-error "error" }
a128 = b128 | c128; // { dg-error "error" }
a128 = b32 | c128; // { dg-error "error" }
a128 = b64 | c128; // { dg-error "error" }
a32 = 100 | c32; // { dg-error "error" }
a64 = 10 | c64; // { dg-error "error" }
a128 = 1000 | c128; // { dg-error "error" }
a32 = b32 | 7; // { dg-error "error" }
a64 = b64 | 5; // { dg-error "error" }
a128 = b128 | 3; // { dg-error "error" }
}
void
logical_and (void)
{
a32 = b32 && c32; // { dg-error "error" }
a64 = b64 && c64; // { dg-error "error" }
a128 = b128 && c128; // { dg-error "error" }
a128 = b32 && c128; // { dg-error "error" }
a128 = b64 && c128; // { dg-error "error" }
a32 = 100 && c32; // { dg-error "error" }
a64 = 10 && c64; // { dg-error "error" }
a128 = 1000 && c128; // { dg-error "error" }
a32 = b32 && 7; // { dg-error "error" }
a64 = b64 && 5; // { dg-error "error" }
a128 = b128 && 3; // { dg-error "error" }
}
void
logical_or (void)
{
a32 = b32 || c32; // { dg-error "error" }
a64 = b64 || c64; // { dg-error "error" }
a128 = b128 || c128; // { dg-error "error" }
a128 = b32 || c128; // { dg-error "error" }
a128 = b64 || c128; // { dg-error "error" }
a32 = 100 || c32; // { dg-error "error" }
a64 = 10 || c64; // { dg-error "error" }
a128 = 1000 || c128; // { dg-error "error" }
a32 = b32 || 7; // { dg-error "error" }
a64 = b64 || 5; // { dg-error "error" }
a128 = b128 || 3; // { dg-error "error" }
}
void
bitwise_complement (void)
{
a32 = ~b32; // { dg-error "error" }
a64 = ~b64; // { dg-error "error" }
a128 = ~b128; // { dg-error "error" }
}
void
logical_not (void)
{
a32 = !b32; // { dg-error "error" }
a64 = !b64; // { dg-error "error" }
a128 = !b128; // { dg-error "error" }
}
// { dg-excess-errors "" { target *-*-* } }
// Copyright (C) 2009 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-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.7 Unary arithmetic operators.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
decimal32 a32 (20), b32 (-20);
decimal64 a64 (124), b64 (-124);
decimal128 a128 (5001), b128 (-5001);
void
unary_plus_32 (void)
{
decimal32 a;
a = +a32; VERIFY (a == a32);
a = +b32; VERIFY (a == b32);
}
void
unary_minus_32 (void)
{
decimal32 a;
a = -a32; VERIFY (a == b32);
a = -b32; VERIFY (a == a32);
}
void
unary_plus_64 (void)
{
decimal64 a;
a = +a64; VERIFY (a == a64);
a = +b64; VERIFY (a == b64);
}
void
unary_minus_64 (void)
{
decimal64 a;
a = -a64; VERIFY (a == b64);
a = -b64; VERIFY (a == a64);
}
void
unary_plus_128 (void)
{
decimal128 a;
a = +a128; VERIFY (a == a128);
a = +b128; VERIFY (a == b128);
}
void
unary_minus_128 (void)
{
decimal128 a;
a = -a128; VERIFY (a == b128);
a = -b128; VERIFY (a == a128);
}
int main ()
{
unary_plus_32 ();
unary_minus_32 ();
unary_plus_64 ();
unary_minus_64 ();
unary_plus_128 ();
unary_minus_128 ();
}
...@@ -58,6 +58,7 @@ if {[info exists tests_file] && [file exists $tests_file]} { ...@@ -58,6 +58,7 @@ if {[info exists tests_file] && [file exists $tests_file]} {
lappend subdirs "$srcdir/ext" lappend subdirs "$srcdir/ext"
lappend subdirs "$srcdir/performance" lappend subdirs "$srcdir/performance"
lappend subdirs "$srcdir/tr1" lappend subdirs "$srcdir/tr1"
lappend subdirs "$srcdir/decimal"
verbose "subdirs are $subdirs" verbose "subdirs are $subdirs"
# Find all the tests. # Find all the tests.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment