Commit 27a2694f by Janis Johnson Committed by Ben Elliston

nodfp-1.c: New test.

	* gcc.dg/nodfp-1.c: New test.
	* gcc.dg/compat/scalar-return-dfp_x.c: Likewise.
	* gcc.dg/compat/scalar-return-dfp_x.c: Likewise.
	* gcc.dg/compat/scalar-return-dfp_main.c: Likewise.
	* gcc.dg/compat/scalar-by-value-dfp_main.c: Likewise.
	* gcc.dg/compat/scalar-by-value-dfp_x.c: Likewise.
	* gcc.dg/compat/scalar-return-dfp_y.c: Likewise.
	* gcc.dg/compat/scalar-by-value-dfp_y.c: Likewise.
	* gcc.dg/debug/dwarf2/dwarf-float.c: Likewise.
	* gcc.dg/debug/dwarf2/dwarf-dfp.c: Likewise.
	* gcc.dg/format/dfp-scanf-1.c: Likewise.
	* gcc.dg/format/dfp-printf-1.c: Likewise.
	* gcc.dg/compat/struct-layout-1.exp: Use c-compat.exp.
	(compat_setup_dfp): New.
	* gcc.dg/compat/compat.exp: Use it.
	(compat-use-alt-compiler, compat-use-tst-compiler): Move to new file.
	Make some variables global, prepend "compat_" to their names.
	* gcc.dg/compat/struct-layout-1.h: Conditional DFP support.
	* gcc.dg/compat/struct-layout-1_generate.c: Ditto.
	* gcc.misc-tests/dectest.exp: New test driver for decTest.
	* lib/compat.exp (compat_skip_list): Make global, rename.
	* lib/c-compat.exp: New file.
	* lib/target-supports.exp (check_effective_target_dfp): New.

	* gcc.dg/dfp/dec-eval-method.c, gcc.dg/dfp/func-array.c,
	gcc.dg/dfp/convert-dfp-fold.c, gcc.dg/dfp/struct-union.c,
	gcc.dg/dfp/compare-rel.h, gcc.dg/dfp/convert-dfp-round.c,
	gcc.dg/dfp/func-struct.c, gcc.dg/dfp/constants-c99.c,
	gcc.dg/dfp/compare-eq-d32.c, gcc.dg/dfp/func-vararg-mixed.c,
	gcc.dg/dfp/compare-rel-d128.c, gcc.dg/dfp/operator-comma.c,
	gcc.dg/dfp/decfloat-constants.c, gcc.dg/dfp/operator-bitwise.c,
	gcc.dg/dfp/func-mixed.c, gcc.dg/dfp/compare-eq-dfp.c,
	gcc.dg/dfp/operator-assignment.c, gcc.dg/dfp/dfp-round.h,
	gcc.dg/dfp/modes.c, gcc.dg/dfp/keywords-c99.c, gcc.dg/dfp/nan-1.c,
	gcc.dg/dfp/loop-index.c, gcc.dg/dfp/compare-eq-d64.c,
	gcc.dg/dfp/convert-bfp.c, gcc.dg/dfp/usual-arith-conv-const.c,
	gcc.dg/dfp/convert-dfp.c, gcc.dg/dfp/compare-rel-const.c,
	gcc.dg/dfp/convert-int-fold.c, gcc.dg/dfp/keywords-pedantic.c,
	gcc.dg/dfp/compare-rel-d32.c, gcc.dg/dfp/call-by-value.c,
	gcc.dg/dfp/constants-hex.c, gcc.dg/dfp/func-scalar.c,
	gcc.dg/dfp/keywords-ignored-c99.c, gcc.dg/dfp/snan.c,
	gcc.dg/dfp/usual-arith-conv.c, gcc.dg/dfp/constants-pedantic.c,
	gcc.dg/dfp/operator-logical.c, gcc.dg/dfp/compare-eq-d128.c,
	gcc.dg/dfp/convert-bfp-fold.c, gcc.dg/dfp/ctypes.c,
	gcc.dg/dfp/convert-int.c, gcc.dg/dfp/keywords-c89.c,
	gcc.dg/dfp/constants.c, gcc.dg/dfp/compare-rel-dfp.c,
	gcc.dg/dfp/compare-eq-const.c, gcc.dg/dfp/cast-bad.c,
	gcc.dg/dfp/operator-arith-fold.c, gcc.dg/dfp/union-init.c,
	gcc.dg/dfp/struct-layout-1.c,
	gcc.dg/dfp/compare-eq.hgcc.dg/dfp/convert-int-saturate.c,
	gcc.dg/dfp/compare-rel-d64.c, gcc.dg/dfp/func-vararg-size0.c,
	gcc.dg/dfp/Wconversion-2.c, gcc.dg/dfp/nan-2.c,
	gcc.dg/dfp/operator-cond.c, gcc.dg/dfp/composite-type.c,
	gcc.dg/dfp/func-vararg-dfp.c,
	gcc.dg/dfp/dfp.expgcc.dg/dfp/keywords-reserved.c,
	gcc.dg/dfp/convert-complex.c, gcc.dg/dfp/Wbad-function-cast-1.c,
	gcc.dg/dfp/operator-unary.c, gcc.dg/dfp/altivec-types.c,
	gcc.dg/dfp/cast.c, gcc.dg/dfp/typespec.c,
	gcc.dg/dfp/wtr-conversion-1.c: New tests.

Co-Authored-By: Ben Elliston <bje@au.ibm.com>
Co-Authored-By: Jon Grimm <jgrimm2@us.ibm.com>
Co-Authored-By: Yao Qi <qiyaoltc@cn.ibm.com>

From-SVN: r109604
parent fcfd0ebb
2006-01-12 Janis Johnson <janis187@us.ibm.com>
Yao Qi <qiyaoltc@cn.ibm.com>
Ben Elliston <bje@au.ibm.com>
Jon Grimm <jgrimm2@us.ibm.com>
* gcc.dg/nodfp-1.c: New test.
* gcc.dg/compat/scalar-return-dfp_x.c: Likewise.
* gcc.dg/compat/scalar-return-dfp_x.c: Likewise.
* gcc.dg/compat/scalar-return-dfp_main.c: Likewise.
* gcc.dg/compat/scalar-by-value-dfp_main.c: Likewise.
* gcc.dg/compat/scalar-by-value-dfp_x.c: Likewise.
* gcc.dg/compat/scalar-return-dfp_y.c: Likewise.
* gcc.dg/compat/scalar-by-value-dfp_y.c: Likewise.
* gcc.dg/debug/dwarf2/dwarf-float.c: Likewise.
* gcc.dg/debug/dwarf2/dwarf-dfp.c: Likewise.
* gcc.dg/format/dfp-scanf-1.c: Likewise.
* gcc.dg/format/dfp-printf-1.c: Likewise.
* gcc.dg/compat/struct-layout-1.exp: Use c-compat.exp.
(compat_setup_dfp): New.
* gcc.dg/compat/compat.exp: Use it.
(compat-use-alt-compiler, compat-use-tst-compiler): Move to new file.
Make some variables global, prepend "compat_" to their names.
* gcc.dg/compat/struct-layout-1.h: Conditional DFP support.
* gcc.dg/compat/struct-layout-1_generate.c: Ditto.
* gcc.misc-tests/dectest.exp: New test driver for decTest.
* lib/compat.exp (compat_skip_list): Make global, rename.
* lib/c-compat.exp: New file.
* lib/target-supports.exp (check_effective_target_dfp): New.
* gcc.dg/dfp/dec-eval-method.c, gcc.dg/dfp/func-array.c,
gcc.dg/dfp/convert-dfp-fold.c, gcc.dg/dfp/struct-union.c,
gcc.dg/dfp/compare-rel.h, gcc.dg/dfp/convert-dfp-round.c,
gcc.dg/dfp/func-struct.c, gcc.dg/dfp/constants-c99.c,
gcc.dg/dfp/compare-eq-d32.c, gcc.dg/dfp/func-vararg-mixed.c,
gcc.dg/dfp/compare-rel-d128.c, gcc.dg/dfp/operator-comma.c,
gcc.dg/dfp/decfloat-constants.c, gcc.dg/dfp/operator-bitwise.c,
gcc.dg/dfp/func-mixed.c, gcc.dg/dfp/compare-eq-dfp.c,
gcc.dg/dfp/operator-assignment.c, gcc.dg/dfp/dfp-round.h,
gcc.dg/dfp/modes.c, gcc.dg/dfp/keywords-c99.c, gcc.dg/dfp/nan-1.c,
gcc.dg/dfp/loop-index.c, gcc.dg/dfp/compare-eq-d64.c,
gcc.dg/dfp/convert-bfp.c, gcc.dg/dfp/usual-arith-conv-const.c,
gcc.dg/dfp/convert-dfp.c, gcc.dg/dfp/compare-rel-const.c,
gcc.dg/dfp/convert-int-fold.c, gcc.dg/dfp/keywords-pedantic.c,
gcc.dg/dfp/compare-rel-d32.c, gcc.dg/dfp/call-by-value.c,
gcc.dg/dfp/constants-hex.c, gcc.dg/dfp/func-scalar.c,
gcc.dg/dfp/keywords-ignored-c99.c, gcc.dg/dfp/snan.c,
gcc.dg/dfp/usual-arith-conv.c, gcc.dg/dfp/constants-pedantic.c,
gcc.dg/dfp/operator-logical.c, gcc.dg/dfp/compare-eq-d128.c,
gcc.dg/dfp/convert-bfp-fold.c, gcc.dg/dfp/ctypes.c,
gcc.dg/dfp/convert-int.c, gcc.dg/dfp/keywords-c89.c,
gcc.dg/dfp/constants.c, gcc.dg/dfp/compare-rel-dfp.c,
gcc.dg/dfp/compare-eq-const.c, gcc.dg/dfp/cast-bad.c,
gcc.dg/dfp/operator-arith-fold.c, gcc.dg/dfp/union-init.c,
gcc.dg/dfp/struct-layout-1.c,
gcc.dg/dfp/compare-eq.hgcc.dg/dfp/convert-int-saturate.c,
gcc.dg/dfp/compare-rel-d64.c, gcc.dg/dfp/func-vararg-size0.c,
gcc.dg/dfp/Wconversion-2.c, gcc.dg/dfp/nan-2.c,
gcc.dg/dfp/operator-cond.c, gcc.dg/dfp/composite-type.c,
gcc.dg/dfp/func-vararg-dfp.c,
gcc.dg/dfp/dfp.expgcc.dg/dfp/keywords-reserved.c,
gcc.dg/dfp/convert-complex.c, gcc.dg/dfp/Wbad-function-cast-1.c,
gcc.dg/dfp/operator-unary.c, gcc.dg/dfp/altivec-types.c,
gcc.dg/dfp/cast.c, gcc.dg/dfp/typespec.c,
gcc.dg/dfp/wtr-conversion-1.c: New tests.
2006-01-11 Richard Guenther <rguenther@suse.de> 2006-01-11 Richard Guenther <rguenther@suse.de>
PR tree-optimization/25734 PR tree-optimization/25734
...@@ -30,49 +30,27 @@ if $tracelevel then { ...@@ -30,49 +30,27 @@ if $tracelevel then {
} }
global GCC_UNDER_TEST global GCC_UNDER_TEST
global ALT_CC_UNDER_TEST
global compat_save_gcc_under_test
global compat_use_alt
global compat_same_alt
global compat_have_dfp
# Load procedures from common libraries. # Load procedures from common libraries.
load_lib standard.exp load_lib standard.exp
load_lib gcc.exp load_lib gcc.exp
# # Load the language-dependent compatibility support procedures.
# compat-use-alt-compiler -- make the alternate compiler the default load_lib c-compat.exp
#
proc compat-use-alt-compiler { } {
global GCC_UNDER_TEST ALT_CC_UNDER_TEST
global same_alt
# We don't need to do this if the alternate compiler is actually
# the same as the compiler under test.
if { $same_alt == 0 } then {
set GCC_UNDER_TEST $ALT_CC_UNDER_TEST
}
}
#
# compat-use-tst-compiler -- make compiler under test the default
#
proc compat-use-tst-compiler { } {
global GCC_UNDER_TEST save_gcc_under_test
global same_alt
# We don't need to do this if the alternate compiler is actually
# the same as the compiler under test.
if { $same_alt == 0 } then {
set GCC_UNDER_TEST $save_gcc_under_test
}
}
# Load the language-independent compabibility support procedures. # Load the language-independent compabibility support procedures.
# This must be done after the compat-use-*-compiler definitions.
load_lib compat.exp load_lib compat.exp
gcc_init gcc_init
# Save variables for the C compiler under test, which each test will # Save variables for the C compiler under test, which each test will
# change a couple of times. This must be done after calling gcc-init. # change a couple of times. This must be done after calling gcc-init.
set save_gcc_under_test $GCC_UNDER_TEST set compat_save_gcc_under_test $GCC_UNDER_TEST
# Define an identifier for use with this suite to avoid name conflicts # Define an identifier for use with this suite to avoid name conflicts
# with other compat tests running at the same time. # with other compat tests running at the same time.
...@@ -82,15 +60,18 @@ set sid "c_compat" ...@@ -82,15 +60,18 @@ set sid "c_compat"
# variable is defined but is set to "same", that means we use the same # variable is defined but is set to "same", that means we use the same
# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS # compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS
# are different. # are different.
set use_alt 0 set compat_use_alt 0
set same_alt 0 set compat_same_alt 0
if [info exists ALT_CC_UNDER_TEST] then { if [info exists ALT_CC_UNDER_TEST] then {
set use_alt 1 set compat_use_alt 1
if [string match "same" $ALT_CC_UNDER_TEST] then { if [string match "same" $ALT_CC_UNDER_TEST] then {
set same_alt 1 set compat_same_alt 1
} }
} }
compat_setup_dfp
# Main loop. # Main loop.
foreach src [lsort [find $srcdir/$subdir *_main.c]] { foreach src [lsort [find $srcdir/$subdir *_main.c]] {
# If we're only testing specific files and this isn't one of them, skip it. # If we're only testing specific files and this isn't one of them, skip it.
...@@ -98,7 +79,7 @@ foreach src [lsort [find $srcdir/$subdir *_main.c]] { ...@@ -98,7 +79,7 @@ foreach src [lsort [find $srcdir/$subdir *_main.c]] {
continue continue
} }
compat-execute $src $sid $use_alt compat-execute $src $sid $compat_use_alt
} }
# Restore the original compiler under test. # Restore the original compiler under test.
......
/* Test passing scalars by value. This test includes scalar types that
are supported by va_arg. */
/* { dg-require-compat-dfp "" } */
extern void scalar_by_value_dfp_x (void);
extern void exit (int);
int fails;
int
main ()
{
scalar_by_value_dfp_x ();
exit (0);
}
#include "compat-common.h"
#define T(NAME, TYPE, INITVAL) \
TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \
TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \
TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \
TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \
\
extern void init##NAME (TYPE *p, TYPE v); \
extern void checkg##NAME (void); \
extern void \
test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \
TYPE x05, TYPE x06, TYPE x07, TYPE x08, \
TYPE x09, TYPE x10, TYPE x11, TYPE x12, \
TYPE x13, TYPE x14, TYPE x15, TYPE x16); \
extern void testva##NAME (int n, ...); \
\
void \
check##NAME (TYPE x, TYPE v) \
{ \
if (x != v + INITVAL) \
DEBUG_CHECK \
} \
\
void \
test2_##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \
TYPE x05, TYPE x06, TYPE x07, TYPE x08) \
{ \
test##NAME (x01, g02##NAME, x02, g04##NAME, \
x03, g06##NAME, x04, g08##NAME, \
x05, g10##NAME, x06, g12##NAME, \
x07, g14##NAME, x08, g16##NAME); \
} \
\
void \
testit##NAME (void) \
{ \
DEBUG_FPUTS (#NAME); \
DEBUG_FPUTS (" init: "); \
init##NAME (&g01##NAME, 1); \
init##NAME (&g02##NAME, 2); \
init##NAME (&g03##NAME, 3); \
init##NAME (&g04##NAME, 4); \
init##NAME (&g05##NAME, 5); \
init##NAME (&g06##NAME, 6); \
init##NAME (&g07##NAME, 7); \
init##NAME (&g08##NAME, 8); \
init##NAME (&g09##NAME, 9); \
init##NAME (&g10##NAME, 10); \
init##NAME (&g11##NAME, 11); \
init##NAME (&g12##NAME, 12); \
init##NAME (&g13##NAME, 13); \
init##NAME (&g14##NAME, 14); \
init##NAME (&g15##NAME, 15); \
init##NAME (&g16##NAME, 16); \
checkg##NAME (); \
DEBUG_NL; \
DEBUG_FPUTS (#NAME); \
DEBUG_FPUTS (" test: "); \
test##NAME (g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
g09##NAME, g10##NAME, g11##NAME, g12##NAME, \
g13##NAME, g14##NAME, g15##NAME, g16##NAME); \
DEBUG_NL; \
DEBUG_FPUTS (#NAME); \
DEBUG_FPUTS (" testva:"); \
DEBUG_NL; \
testva##NAME (1, \
g01##NAME); \
DEBUG_NL; \
testva##NAME (2, \
g01##NAME, g02##NAME); \
DEBUG_NL; \
testva##NAME (3, \
g01##NAME, g02##NAME, g03##NAME); \
DEBUG_NL; \
testva##NAME (4, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME); \
DEBUG_NL; \
testva##NAME (5, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME); \
DEBUG_NL; \
testva##NAME (6, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME); \
DEBUG_NL; \
testva##NAME (7, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME); \
DEBUG_NL; \
testva##NAME (8, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME, g08##NAME); \
DEBUG_NL; \
testva##NAME (9, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
g09##NAME); \
DEBUG_NL; \
testva##NAME (10, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
g09##NAME, g10##NAME); \
DEBUG_NL; \
testva##NAME (11, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
g09##NAME, g10##NAME, g11##NAME); \
DEBUG_NL; \
testva##NAME (12, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
g09##NAME, g10##NAME, g11##NAME, g12##NAME); \
DEBUG_NL; \
testva##NAME (13, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
g09##NAME, g10##NAME, g11##NAME, g12##NAME, \
g13##NAME); \
DEBUG_NL; \
testva##NAME (14, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
g09##NAME, g10##NAME, g11##NAME, g12##NAME, \
g13##NAME, g14##NAME); \
DEBUG_NL; \
testva##NAME (15, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
g09##NAME, g10##NAME, g11##NAME, g12##NAME, \
g13##NAME, g14##NAME, g15##NAME); \
DEBUG_NL; \
testva##NAME (16, \
g01##NAME, g02##NAME, g03##NAME, g04##NAME, \
g05##NAME, g06##NAME, g07##NAME, g08##NAME, \
g09##NAME, g10##NAME, g11##NAME, g12##NAME, \
g13##NAME, g14##NAME, g15##NAME, g16##NAME); \
DEBUG_NL; \
DEBUG_FPUTS (#NAME); \
DEBUG_FPUTS (" test2: "); \
test2_##NAME (g01##NAME, g03##NAME, g05##NAME, g07##NAME, \
g09##NAME, g11##NAME, g13##NAME, g15##NAME); \
DEBUG_NL; \
}
T(d32, _Decimal32, 1.2df)
T(d64, _Decimal64, 12.34dd)
T(d128, _Decimal128, 123.456dl)
#undef T
void
scalar_by_value_dfp_x ()
{
DEBUG_INIT
#define T(NAME) testit##NAME ();
T(d32)
T(d64)
T(d128)
DEBUG_FINI
if (fails != 0)
abort ();
#undef T
}
#include <stdarg.h>
#include "compat-common.h"
#ifdef SKIP_VA
const int test_va = 0;
#else
const int test_va = 1;
#endif
#define T(NAME, TYPE, INITVAL) \
extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \
extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \
extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \
extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \
\
extern void check##NAME (TYPE x, TYPE v); \
\
void \
init##NAME (TYPE *p, TYPE v) \
{ \
*p = v + INITVAL; \
} \
\
void \
checkg##NAME (void) \
{ \
check##NAME (g01##NAME, 1); \
check##NAME (g02##NAME, 2); \
check##NAME (g03##NAME, 3); \
check##NAME (g04##NAME, 4); \
check##NAME (g05##NAME, 5); \
check##NAME (g06##NAME, 6); \
check##NAME (g07##NAME, 7); \
check##NAME (g08##NAME, 8); \
check##NAME (g09##NAME, 9); \
check##NAME (g10##NAME, 10); \
check##NAME (g11##NAME, 11); \
check##NAME (g12##NAME, 12); \
check##NAME (g13##NAME, 13); \
check##NAME (g14##NAME, 14); \
check##NAME (g15##NAME, 15); \
check##NAME (g16##NAME, 16); \
} \
\
void \
test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \
TYPE x05, TYPE x06, TYPE x07, TYPE x08, \
TYPE x09, TYPE x10, TYPE x11, TYPE x12, \
TYPE x13, TYPE x14, TYPE x15, TYPE x16) \
{ \
check##NAME (x01, 1); \
check##NAME (x02, 2); \
check##NAME (x03, 3); \
check##NAME (x04, 4); \
check##NAME (x05, 5); \
check##NAME (x06, 6); \
check##NAME (x07, 7); \
check##NAME (x08, 8); \
check##NAME (x09, 9); \
check##NAME (x10, 10); \
check##NAME (x11, 11); \
check##NAME (x12, 12); \
check##NAME (x13, 13); \
check##NAME (x14, 14); \
check##NAME (x15, 15); \
check##NAME (x16, 16); \
} \
\
void \
testva##NAME (int n, ...) \
{ \
int i; \
va_list ap; \
if (test_va) \
{ \
va_start (ap, n); \
for (i = 0; i < n; i++) \
{ \
TYPE t = va_arg (ap, TYPE); \
check##NAME (t, i+1); \
} \
va_end (ap); \
} \
}
T(d32, _Decimal32, 1.2df)
T(d64, _Decimal64, 12.34dd)
T(d128, _Decimal128, 123.456dl)
/* Test function return values. This test includes scalar types that
are supported by va_arg. */
/* { dg-require-compat-dfp "" } */
extern void scalar_return_dfp_x(void);
extern void exit (int);
int fails;
int
main ()
{
scalar_return_dfp_x ();
exit (0);
}
#include "compat-common.h"
#ifdef SKIP_VA
const int test_va = 0;
#else
const int test_va = 1;
#endif
#define T(NAME, TYPE, INITVAL) \
TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \
TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \
TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \
TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \
\
extern void init##NAME (TYPE *p, TYPE v); \
extern void checkg##NAME (void); \
extern TYPE test0##NAME (void); \
extern TYPE test1##NAME (TYPE); \
extern TYPE testva##NAME (int n, ...); \
\
void \
check##NAME (TYPE x, TYPE v) \
{ \
if (x != v) \
DEBUG_CHECK \
} \
\
void \
testit##NAME (void) \
{ \
TYPE rslt; \
DEBUG_FPUTS (#NAME); \
DEBUG_FPUTS (" init: "); \
init##NAME (&g01##NAME, 1); \
init##NAME (&g02##NAME, 2); \
init##NAME (&g03##NAME, 3); \
init##NAME (&g04##NAME, 4); \
init##NAME (&g05##NAME, 5); \
init##NAME (&g06##NAME, 6); \
init##NAME (&g07##NAME, 7); \
init##NAME (&g08##NAME, 8); \
init##NAME (&g09##NAME, 9); \
init##NAME (&g10##NAME, 10); \
init##NAME (&g11##NAME, 11); \
init##NAME (&g12##NAME, 12); \
init##NAME (&g13##NAME, 13); \
init##NAME (&g14##NAME, 14); \
init##NAME (&g15##NAME, 15); \
init##NAME (&g16##NAME, 16); \
checkg##NAME (); \
DEBUG_NL; \
DEBUG_FPUTS (#NAME); \
DEBUG_FPUTS (" test0: "); \
rslt = test0##NAME (); \
check##NAME (rslt, g01##NAME); \
DEBUG_NL; \
DEBUG_FPUTS (#NAME); \
DEBUG_FPUTS (" test1: "); \
rslt = test1##NAME (g01##NAME); \
check##NAME (rslt, g01##NAME); \
if (test_va) \
{ \
DEBUG_NL; \
DEBUG_FPUTS (#NAME); \
DEBUG_FPUTS (" testva:"); \
rslt = testva##NAME (1, g01##NAME); \
check##NAME (rslt, g01##NAME); \
rslt = testva##NAME (5, g01##NAME, g02##NAME, g03##NAME, \
g04##NAME, g05##NAME); \
check##NAME (rslt, g05##NAME); \
rslt = testva##NAME (9, g01##NAME, g02##NAME, g03##NAME, \
g04##NAME, g05##NAME, g06##NAME, \
g07##NAME, g08##NAME, g09##NAME); \
check##NAME (rslt, g09##NAME); \
rslt = testva##NAME (16, g01##NAME, g02##NAME, g03##NAME, \
g04##NAME, g05##NAME, g06##NAME, \
g07##NAME, g08##NAME, g09##NAME, \
g10##NAME, g11##NAME, g12##NAME, \
g13##NAME, g14##NAME, g15##NAME, \
g16##NAME); \
check##NAME (rslt, g16##NAME); \
} \
DEBUG_NL; \
}
T(d32, _Decimal32, 1.2df)
T(d64, _Decimal64, 12.34dd)
T(d128, _Decimal128, 123.456dl)
#undef T
void
scalar_return_dfp_x ()
{
DEBUG_INIT
#define T(NAME) testit##NAME ();
T(d32)
T(d64)
T(d128)
DEBUG_FINI
if (fails != 0)
abort ();
#undef T
}
#include <stdarg.h>
#include "compat-common.h"
#define T(NAME, TYPE, INITVAL) \
extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \
extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \
extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \
extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \
\
extern void check##NAME (TYPE x, TYPE v); \
\
void \
init##NAME (TYPE *p, TYPE v) \
{ \
*p = v + INITVAL; \
} \
\
void \
checkg##NAME (void) \
{ \
check##NAME (g01##NAME, 1+INITVAL); \
check##NAME (g02##NAME, 2+INITVAL); \
check##NAME (g03##NAME, 3+INITVAL); \
check##NAME (g04##NAME, 4+INITVAL); \
check##NAME (g05##NAME, 5+INITVAL); \
check##NAME (g06##NAME, 6+INITVAL); \
check##NAME (g07##NAME, 7+INITVAL); \
check##NAME (g08##NAME, 8+INITVAL); \
check##NAME (g09##NAME, 9+INITVAL); \
check##NAME (g10##NAME, 10+INITVAL); \
check##NAME (g11##NAME, 11+INITVAL); \
check##NAME (g12##NAME, 12+INITVAL); \
check##NAME (g13##NAME, 13+INITVAL); \
check##NAME (g14##NAME, 14+INITVAL); \
check##NAME (g15##NAME, 15+INITVAL); \
check##NAME (g16##NAME, 16+INITVAL); \
} \
\
TYPE \
test0##NAME (void) \
{ \
return g01##NAME; \
} \
\
TYPE \
test1##NAME (TYPE x01) \
{ \
return x01; \
} \
\
TYPE \
testva##NAME (int n, ...) \
{ \
int i; \
TYPE rslt; \
va_list ap; \
va_start (ap, n); \
for (i = 0; i < n; i++) \
rslt = va_arg (ap, TYPE); \
va_end (ap); \
return rslt; \
}
T(d32, _Decimal32, 1.2df)
T(d64, _Decimal64, 12.34dd)
T(d128, _Decimal128, 123.456dl)
...@@ -35,49 +35,26 @@ if $tracelevel then { ...@@ -35,49 +35,26 @@ if $tracelevel then {
} }
global GCC_UNDER_TEST global GCC_UNDER_TEST
global compat_save_gcc_under_test
global compat_use_alt
global compat_same_alt
global compat_have_dfp
# Load procedures from common libraries. # Load procedures from common libraries.
load_lib standard.exp load_lib standard.exp
load_lib gcc.exp load_lib gcc.exp
# # Load the language-dependent compabibility support procedures.
# compat-use-alt-compiler -- make the alternate compiler the default load_lib c-compat.exp
#
proc compat-use-alt-compiler { } {
global GCC_UNDER_TEST ALT_CC_UNDER_TEST
global same_alt
# We don't need to do this if the alternate compiler is actually
# the same as the compiler under test.
if { $same_alt == 0 } then {
set GCC_UNDER_TEST $ALT_CC_UNDER_TEST
}
}
#
# compat-use-tst-compiler -- make compiler under test the default
#
proc compat-use-tst-compiler { } {
global GCC_UNDER_TEST save_gcc_under_test
global same_alt
# We don't need to do this if the alternate compiler is actually
# the same as the compiler under test.
if { $same_alt == 0 } then {
set GCC_UNDER_TEST $save_gcc_under_test
}
}
# Load the language-independent compabibility support procedures. # Load the language-independent compabibility support procedures.
# This must be done after the compat-use-*-compiler definitions.
load_lib compat.exp load_lib compat.exp
gcc_init gcc_init
# Save variables for the C compiler under test, which each test will # Save variables for the C compiler under test, which each test will
# change a couple of times. This must be done after calling gcc-init. # change a couple of times. This must be done after calling gcc-init.
set save_gcc_under_test $GCC_UNDER_TEST set compat_save_gcc_under_test $GCC_UNDER_TEST
# Define an identifier for use with this suite to avoid name conflicts # Define an identifier for use with this suite to avoid name conflicts
# with other compat tests running at the same time. # with other compat tests running at the same time.
...@@ -87,22 +64,31 @@ set sid "c_compat" ...@@ -87,22 +64,31 @@ set sid "c_compat"
# variable is defined but is set to "same", that means we use the same # variable is defined but is set to "same", that means we use the same
# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS # compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS
# are different. # are different.
set use_alt 0 set compat_use_alt 0
set same_alt 0 set compat_same_alt 0
if [info exists ALT_CC_UNDER_TEST] then { if [info exists ALT_CC_UNDER_TEST] then {
set use_alt 1 set compat_use_alt 1
if [string match "same" $ALT_CC_UNDER_TEST] then { if [string match "same" $ALT_CC_UNDER_TEST] then {
set same_alt 1 set compat_same_alt 1
} }
} }
compat_setup_dfp
if { $compat_have_dfp == 0 } {
set skip_dfp "-DSKIP_DECIMAL_FLOAT"
} else {
set skip_dfp ""
}
set tstobjdir "$tmpdir/gcc.dg-struct-layout-1" set tstobjdir "$tmpdir/gcc.dg-struct-layout-1"
set generator "$tmpdir/gcc.dg-struct-layout-1_generate" set generator "$tmpdir/gcc.dg-struct-layout-1_generate"
set generator_src "$srcdir/$subdir/struct-layout-1_generate.c" set generator_src "$srcdir/$subdir/struct-layout-1_generate.c"
set generator_src "$generator_src $srcdir/$subdir/generate-random.c" set generator_src "$generator_src $srcdir/$subdir/generate-random.c"
set generator_src "$generator_src $srcdir/$subdir/generate-random_r.c" set generator_src "$generator_src $srcdir/$subdir/generate-random_r.c"
set generator_cmd "-o $generator $generator_src" set generator_cmd "-o $generator $skip_dfp $generator_src"
set status [remote_exec host "$HOSTCC $HOSTCFLAGS $generator_cmd"] set status [remote_exec host "$HOSTCC $HOSTCFLAGS $generator_cmd"]
set status [lindex $status 0] set status [lindex $status 0]
...@@ -123,7 +109,7 @@ if { $status == 0 } then { ...@@ -123,7 +109,7 @@ if { $status == 0 } then {
continue continue
} }
compat-execute $src $sid $use_alt compat-execute $src $sid $compat_use_alt
} }
} else { } else {
warning "Could not execute gcc.dg/compat/struct-layout-1 generator" warning "Could not execute gcc.dg/compat/struct-layout-1 generator"
......
...@@ -204,6 +204,11 @@ typedef _Complex unsigned long long int Tcullong; ...@@ -204,6 +204,11 @@ typedef _Complex unsigned long long int Tcullong;
typedef float Tfloat; typedef float Tfloat;
typedef double Tdouble; typedef double Tdouble;
typedef long double Tldouble; typedef long double Tldouble;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 TDecimal32;
typedef _Decimal64 TDecimal64;
typedef _Decimal128 TDecimal128;
#endif
typedef _Complex float Tcfloat; typedef _Complex float Tcfloat;
typedef _Complex double Tcdouble; typedef _Complex double Tcdouble;
typedef _Complex long double Tcldouble; typedef _Complex long double Tcldouble;
...@@ -248,6 +253,11 @@ typedef _Complex unsigned long long int Talcullong atal; ...@@ -248,6 +253,11 @@ typedef _Complex unsigned long long int Talcullong atal;
typedef float Talfloat atal; typedef float Talfloat atal;
typedef double Taldouble atal; typedef double Taldouble atal;
typedef long double Talldouble atal; typedef long double Talldouble atal;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 TalDecimal32 atal;
typedef _Decimal64 TalDecimal64 atal;
typedef _Decimal128 TalDecimal128 atal;
#endif
typedef _Complex float Talcfloat atal; typedef _Complex float Talcfloat atal;
typedef _Complex double Talcdouble atal; typedef _Complex double Talcdouble atal;
typedef _Complex long double Talcldouble atal; typedef _Complex long double Talcldouble atal;
...@@ -292,6 +302,11 @@ typedef _Complex unsigned long long int Tal1cullong atal1; ...@@ -292,6 +302,11 @@ typedef _Complex unsigned long long int Tal1cullong atal1;
typedef float Tal1float atal1; typedef float Tal1float atal1;
typedef double Tal1double atal1; typedef double Tal1double atal1;
typedef long double Tal1ldouble atal1; typedef long double Tal1ldouble atal1;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 Tal1Decimal32 atal1;
typedef _Decimal64 Tal1Decimal64 atal1;
typedef _Decimal128 Tal1Decimal128 atal1;
#endif
typedef _Complex float Tal1cfloat atal1; typedef _Complex float Tal1cfloat atal1;
typedef _Complex double Tal1cdouble atal1; typedef _Complex double Tal1cdouble atal1;
typedef _Complex long double Tal1cldouble atal1; typedef _Complex long double Tal1cldouble atal1;
...@@ -336,6 +351,11 @@ typedef _Complex unsigned long long int Tal2cullong atal2; ...@@ -336,6 +351,11 @@ typedef _Complex unsigned long long int Tal2cullong atal2;
typedef float Tal2float atal2; typedef float Tal2float atal2;
typedef double Tal2double atal2; typedef double Tal2double atal2;
typedef long double Tal2ldouble atal2; typedef long double Tal2ldouble atal2;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 Tal2Decimal32 atal2;
typedef _Decimal64 Tal2Decimal64 atal2;
typedef _Decimal128 Tal2Decimal128 atal2;
#endif
typedef _Complex float Tal2cfloat atal2; typedef _Complex float Tal2cfloat atal2;
typedef _Complex double Tal2cdouble atal2; typedef _Complex double Tal2cdouble atal2;
typedef _Complex long double Tal2cldouble atal2; typedef _Complex long double Tal2cldouble atal2;
...@@ -380,6 +400,11 @@ typedef _Complex unsigned long long int Tal4cullong atal4; ...@@ -380,6 +400,11 @@ typedef _Complex unsigned long long int Tal4cullong atal4;
typedef float Tal4float atal4; typedef float Tal4float atal4;
typedef double Tal4double atal4; typedef double Tal4double atal4;
typedef long double Tal4ldouble atal4; typedef long double Tal4ldouble atal4;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 Tal4Decimal32 atal4;
typedef _Decimal64 Tal4Decimal64 atal4;
typedef _Decimal128 Tal4Decimal128 atal4;
#endif
typedef _Complex float Tal4cfloat atal4; typedef _Complex float Tal4cfloat atal4;
typedef _Complex double Tal4cdouble atal4; typedef _Complex double Tal4cdouble atal4;
typedef _Complex long double Tal4cldouble atal4; typedef _Complex long double Tal4cldouble atal4;
...@@ -424,6 +449,11 @@ typedef _Complex unsigned long long int Tal8cullong atal8; ...@@ -424,6 +449,11 @@ typedef _Complex unsigned long long int Tal8cullong atal8;
typedef float Tal8float atal8; typedef float Tal8float atal8;
typedef double Tal8double atal8; typedef double Tal8double atal8;
typedef long double Tal8ldouble atal8; typedef long double Tal8ldouble atal8;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 Tal8Decimal32 atal8;
typedef _Decimal64 Tal8Decimal64 atal8;
typedef _Decimal128 Tal8Decimal128 atal8;
#endif
typedef _Complex float Tal8cfloat atal8; typedef _Complex float Tal8cfloat atal8;
typedef _Complex double Tal8cdouble atal8; typedef _Complex double Tal8cdouble atal8;
typedef _Complex long double Tal8cldouble atal8; typedef _Complex long double Tal8cldouble atal8;
...@@ -468,6 +498,11 @@ typedef _Complex unsigned long long int Tal16cullong atal16; ...@@ -468,6 +498,11 @@ typedef _Complex unsigned long long int Tal16cullong atal16;
typedef float Tal16float atal16; typedef float Tal16float atal16;
typedef double Tal16double atal16; typedef double Tal16double atal16;
typedef long double Tal16ldouble atal16; typedef long double Tal16ldouble atal16;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 Tal16Decimal32 atal16;
typedef _Decimal64 Tal16Decimal64 atal16;
typedef _Decimal128 Tal16Decimal128 atal16;
#endif
typedef _Complex float Tal16cfloat atal16; typedef _Complex float Tal16cfloat atal16;
typedef _Complex double Tal16cdouble atal16; typedef _Complex double Tal16cdouble atal16;
typedef _Complex long double Tal16cldouble atal16; typedef _Complex long double Tal16cldouble atal16;
...@@ -512,6 +547,11 @@ typedef _Complex unsigned long long int Talx1cullong atalx1; ...@@ -512,6 +547,11 @@ typedef _Complex unsigned long long int Talx1cullong atalx1;
typedef float Talx1float atalx1; typedef float Talx1float atalx1;
typedef double Talx1double atalx1; typedef double Talx1double atalx1;
typedef long double Talx1ldouble atalx1; typedef long double Talx1ldouble atalx1;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 Talx1Decimal32 atalx1;
typedef _Decimal64 Talx1Decimal64 atalx1;
typedef _Decimal128 Talx1Decimal128 atalx1;
#endif
typedef _Complex float Talx1cfloat atalx1; typedef _Complex float Talx1cfloat atalx1;
typedef _Complex double Talx1cdouble atalx1; typedef _Complex double Talx1cdouble atalx1;
typedef _Complex long double Talx1cldouble atalx1; typedef _Complex long double Talx1cldouble atalx1;
...@@ -553,6 +593,11 @@ typedef _Complex unsigned long long int Talx2cullong atalx2; ...@@ -553,6 +593,11 @@ typedef _Complex unsigned long long int Talx2cullong atalx2;
typedef float Talx2float atalx2; typedef float Talx2float atalx2;
typedef double Talx2double atalx2; typedef double Talx2double atalx2;
typedef long double Talx2ldouble atalx2; typedef long double Talx2ldouble atalx2;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 Talx2Decimal32 atalx2;
typedef _Decimal64 Talx2Decimal64 atalx2;
typedef _Decimal128 Talx2Decimal128 atalx2;
#endif
typedef _Complex float Talx2cfloat atalx2; typedef _Complex float Talx2cfloat atalx2;
typedef _Complex double Talx2cdouble atalx2; typedef _Complex double Talx2cdouble atalx2;
typedef _Complex long double Talx2cldouble atalx2; typedef _Complex long double Talx2cldouble atalx2;
...@@ -588,6 +633,11 @@ typedef _Complex unsigned long long int Talx4cullong atalx4; ...@@ -588,6 +633,11 @@ typedef _Complex unsigned long long int Talx4cullong atalx4;
typedef float Talx4float atalx4; typedef float Talx4float atalx4;
typedef double Talx4double atalx4; typedef double Talx4double atalx4;
typedef long double Talx4ldouble atalx4; typedef long double Talx4ldouble atalx4;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 Talx4Decimal32 atalx4;
typedef _Decimal64 Talx4Decimal64 atalx4;
typedef _Decimal128 Talx4Decimal128 atalx4;
#endif
typedef _Complex float Talx4cfloat atalx4; typedef _Complex float Talx4cfloat atalx4;
typedef _Complex double Talx4cdouble atalx4; typedef _Complex double Talx4cdouble atalx4;
typedef _Complex long double Talx4cldouble atalx4; typedef _Complex long double Talx4cldouble atalx4;
...@@ -618,6 +668,10 @@ typedef _Complex unsigned long long int Talx8cullong atalx8; ...@@ -618,6 +668,10 @@ typedef _Complex unsigned long long int Talx8cullong atalx8;
#endif #endif
typedef double Talx8double atalx8; typedef double Talx8double atalx8;
typedef long double Talx8ldouble atalx8; typedef long double Talx8ldouble atalx8;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal64 Talx8Decimal64 atalx8;
typedef _Decimal128 Talx8Decimal128 atalx8;
#endif
typedef _Complex float Talx8cfloat atalx8; typedef _Complex float Talx8cfloat atalx8;
typedef _Complex double Talx8cdouble atalx8; typedef _Complex double Talx8cdouble atalx8;
typedef _Complex long double Talx8cldouble atalx8; typedef _Complex long double Talx8cldouble atalx8;
......
...@@ -46,6 +46,7 @@ enum TYPE ...@@ -46,6 +46,7 @@ enum TYPE
TYPE_CUINT, TYPE_CUINT,
TYPE_FLOAT, TYPE_FLOAT,
TYPE_CFLOAT, TYPE_CFLOAT,
TYPE_DEC_FLOAT,
TYPE_SENUM, TYPE_SENUM,
TYPE_UENUM, TYPE_UENUM,
TYPE_PTR, TYPE_PTR,
...@@ -82,7 +83,14 @@ struct types base_types[] = { ...@@ -82,7 +83,14 @@ struct types base_types[] = {
{ "float", TYPE_FLOAT, 0, 0 }, { "float", TYPE_FLOAT, 0, 0 },
{ "double", TYPE_FLOAT, 0, 0 }, { "double", TYPE_FLOAT, 0, 0 },
{ "long double", TYPE_FLOAT, 0, 0 }, { "long double", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "_Decimal32", TYPE_DEC_FLOAT, 0, 0 },
{ "_Decimal64", TYPE_DEC_FLOAT, 0, 0 },
{ "_Decimal128", TYPE_DEC_FLOAT, 0, 0 },
#define NTYPES1 21
#else
#define NTYPES1 18 #define NTYPES1 18
#endif
{ "Tchar", TYPE_UINT, 127, 'C' }, { "Tchar", TYPE_UINT, 127, 'C' },
{ "Tschar", TYPE_INT, 127, 'C' }, { "Tschar", TYPE_INT, 127, 'C' },
{ "Tuchar", TYPE_UINT, 255, 'C' }, { "Tuchar", TYPE_UINT, 255, 'C' },
...@@ -103,6 +111,11 @@ struct types base_types[] = { ...@@ -103,6 +111,11 @@ struct types base_types[] = {
{ "Tfloat", TYPE_FLOAT, 0, 0 }, { "Tfloat", TYPE_FLOAT, 0, 0 },
{ "Tdouble", TYPE_FLOAT, 0, 0 }, { "Tdouble", TYPE_FLOAT, 0, 0 },
{ "Tldouble", TYPE_FLOAT, 0, 0 }, { "Tldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "TDecimal32", TYPE_DEC_FLOAT, 0, 0 },
{ "TDecimal64", TYPE_DEC_FLOAT, 0, 0 },
{ "TDecimal128", TYPE_DEC_FLOAT, 0, 0 },
#endif
{ "enum E0", TYPE_UENUM, 0, ' ' }, { "enum E0", TYPE_UENUM, 0, ' ' },
{ "enum E1", TYPE_UENUM, 1, ' ' }, { "enum E1", TYPE_UENUM, 1, ' ' },
{ "enum E2", TYPE_SENUM, 3, ' ' }, { "enum E2", TYPE_SENUM, 3, ' ' },
...@@ -214,6 +227,11 @@ struct types attrib_types[] = { ...@@ -214,6 +227,11 @@ struct types attrib_types[] = {
{ "Talfloat", TYPE_FLOAT, 0, 0 }, { "Talfloat", TYPE_FLOAT, 0, 0 },
{ "Taldouble", TYPE_FLOAT, 0, 0 }, { "Taldouble", TYPE_FLOAT, 0, 0 },
{ "Talldouble", TYPE_FLOAT, 0, 0 }, { "Talldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "TalDecimal32", TYPE_DEC_FLOAT, 0, 0 },
{ "TalDecimal64", TYPE_DEC_FLOAT, 0, 0 },
{ "TalDecimal128", TYPE_DEC_FLOAT, 0, 0 },
#endif
{ "TalE0", TYPE_UENUM, 0, ' ' }, { "TalE0", TYPE_UENUM, 0, ' ' },
{ "TalE1", TYPE_UENUM, 1, ' ' }, { "TalE1", TYPE_UENUM, 1, ' ' },
{ "TalE2", TYPE_SENUM, 3, ' ' }, { "TalE2", TYPE_SENUM, 3, ' ' },
...@@ -242,6 +260,11 @@ struct types attrib_types[] = { ...@@ -242,6 +260,11 @@ struct types attrib_types[] = {
{ "Tal1float", TYPE_FLOAT, 0, 0 }, { "Tal1float", TYPE_FLOAT, 0, 0 },
{ "Tal1double", TYPE_FLOAT, 0, 0 }, { "Tal1double", TYPE_FLOAT, 0, 0 },
{ "Tal1ldouble", TYPE_FLOAT, 0, 0 }, { "Tal1ldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "Tal1Decimal32", TYPE_DEC_FLOAT, 0, 0},
{ "Tal1Decimal64", TYPE_DEC_FLOAT, 0, 0},
{ "Tal1Decimal128", TYPE_DEC_FLOAT, 0, 0},
#endif
{ "Tal1E0", TYPE_UENUM, 0, ' ' }, { "Tal1E0", TYPE_UENUM, 0, ' ' },
{ "Tal1E1", TYPE_UENUM, 1, ' ' }, { "Tal1E1", TYPE_UENUM, 1, ' ' },
{ "Tal1E2", TYPE_SENUM, 3, ' ' }, { "Tal1E2", TYPE_SENUM, 3, ' ' },
...@@ -270,6 +293,11 @@ struct types attrib_types[] = { ...@@ -270,6 +293,11 @@ struct types attrib_types[] = {
{ "Tal2float", TYPE_FLOAT, 0, 0 }, { "Tal2float", TYPE_FLOAT, 0, 0 },
{ "Tal2double", TYPE_FLOAT, 0, 0 }, { "Tal2double", TYPE_FLOAT, 0, 0 },
{ "Tal2ldouble", TYPE_FLOAT, 0, 0 }, { "Tal2ldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "Tal2Decimal32", TYPE_DEC_FLOAT, 0, 0 },
{ "Tal2Decimal64", TYPE_DEC_FLOAT, 0, 0 },
{ "Tal2Decimal128", TYPE_DEC_FLOAT, 0, 0 },
#endif
{ "Tal2E0", TYPE_UENUM, 0, ' ' }, { "Tal2E0", TYPE_UENUM, 0, ' ' },
{ "Tal2E1", TYPE_UENUM, 1, ' ' }, { "Tal2E1", TYPE_UENUM, 1, ' ' },
{ "Tal2E2", TYPE_SENUM, 3, ' ' }, { "Tal2E2", TYPE_SENUM, 3, ' ' },
...@@ -298,6 +326,11 @@ struct types attrib_types[] = { ...@@ -298,6 +326,11 @@ struct types attrib_types[] = {
{ "Tal4float", TYPE_FLOAT, 0, 0 }, { "Tal4float", TYPE_FLOAT, 0, 0 },
{ "Tal4double", TYPE_FLOAT, 0, 0 }, { "Tal4double", TYPE_FLOAT, 0, 0 },
{ "Tal4ldouble", TYPE_FLOAT, 0, 0 }, { "Tal4ldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "Tal4Decimal32", TYPE_DEC_FLOAT, 0, 0 },
{ "Tal4Decimal64", TYPE_DEC_FLOAT, 0, 0 },
{ "Tal4Decimal128", TYPE_DEC_FLOAT, 0, 0 },
#endif
{ "Tal4E0", TYPE_UENUM, 0, ' ' }, { "Tal4E0", TYPE_UENUM, 0, ' ' },
{ "Tal4E1", TYPE_UENUM, 1, ' ' }, { "Tal4E1", TYPE_UENUM, 1, ' ' },
{ "Tal4E2", TYPE_SENUM, 3, ' ' }, { "Tal4E2", TYPE_SENUM, 3, ' ' },
...@@ -326,6 +359,11 @@ struct types attrib_types[] = { ...@@ -326,6 +359,11 @@ struct types attrib_types[] = {
{ "Tal8float", TYPE_FLOAT, 0, 0 }, { "Tal8float", TYPE_FLOAT, 0, 0 },
{ "Tal8double", TYPE_FLOAT, 0, 0 }, { "Tal8double", TYPE_FLOAT, 0, 0 },
{ "Tal8ldouble", TYPE_FLOAT, 0, 0 }, { "Tal8ldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "Tal8Decimal32", TYPE_DEC_FLOAT, 0, 0 },
{ "Tal8Decimal64", TYPE_DEC_FLOAT, 0, 0 },
{ "Tal8Decimal128", TYPE_DEC_FLOAT, 0, 0 },
#endif
{ "Tal8E0", TYPE_UENUM, 0, ' ' }, { "Tal8E0", TYPE_UENUM, 0, ' ' },
{ "Tal8E1", TYPE_UENUM, 1, ' ' }, { "Tal8E1", TYPE_UENUM, 1, ' ' },
{ "Tal8E2", TYPE_SENUM, 3, ' ' }, { "Tal8E2", TYPE_SENUM, 3, ' ' },
...@@ -354,6 +392,11 @@ struct types attrib_types[] = { ...@@ -354,6 +392,11 @@ struct types attrib_types[] = {
{ "Tal16float", TYPE_FLOAT, 0, 0 }, { "Tal16float", TYPE_FLOAT, 0, 0 },
{ "Tal16double", TYPE_FLOAT, 0, 0 }, { "Tal16double", TYPE_FLOAT, 0, 0 },
{ "Tal16ldouble", TYPE_FLOAT, 0, 0 }, { "Tal16ldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "Tal16Decimal32", TYPE_DEC_FLOAT, 0, 0 },
{ "Tal16Decimal64", TYPE_DEC_FLOAT, 0, 0 },
{ "Tal16Decimal128", TYPE_DEC_FLOAT, 0, 0 },
#endif
{ "Tal16E0", TYPE_UENUM, 0, ' ' }, { "Tal16E0", TYPE_UENUM, 0, ' ' },
{ "Tal16E1", TYPE_UENUM, 1, ' ' }, { "Tal16E1", TYPE_UENUM, 1, ' ' },
{ "Tal16E2", TYPE_SENUM, 3, ' ' }, { "Tal16E2", TYPE_SENUM, 3, ' ' },
...@@ -472,6 +515,11 @@ struct types attrib_array_types[] = { ...@@ -472,6 +515,11 @@ struct types attrib_array_types[] = {
{ "Talx1float", TYPE_FLOAT, 0, 0 }, { "Talx1float", TYPE_FLOAT, 0, 0 },
{ "Talx1double", TYPE_FLOAT, 0, 0 }, { "Talx1double", TYPE_FLOAT, 0, 0 },
{ "Talx1ldouble", TYPE_FLOAT, 0, 0 }, { "Talx1ldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "Talx1Decimal32", TYPE_DEC_FLOAT, 0 ,0 },
{ "Talx1Decimal64", TYPE_DEC_FLOAT, 0 ,0 },
{ "Talx1Decimal128", TYPE_DEC_FLOAT, 0 ,0 },
#endif
{ "Talx1E0", TYPE_UENUM, 0, ' ' }, { "Talx1E0", TYPE_UENUM, 0, ' ' },
{ "Talx1E1", TYPE_UENUM, 1, ' ' }, { "Talx1E1", TYPE_UENUM, 1, ' ' },
{ "Talx1E2", TYPE_SENUM, 3, ' ' }, { "Talx1E2", TYPE_SENUM, 3, ' ' },
...@@ -496,6 +544,11 @@ struct types attrib_array_types[] = { ...@@ -496,6 +544,11 @@ struct types attrib_array_types[] = {
{ "Talx2float", TYPE_FLOAT, 0, 0 }, { "Talx2float", TYPE_FLOAT, 0, 0 },
{ "Talx2double", TYPE_FLOAT, 0, 0 }, { "Talx2double", TYPE_FLOAT, 0, 0 },
{ "Talx2ldouble", TYPE_FLOAT, 0, 0 }, { "Talx2ldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "Talx2Decimal32", TYPE_DEC_FLOAT, 0 , 0 },
{ "Talx2Decimal64", TYPE_DEC_FLOAT, 0 , 0 },
{ "Talx2Decimal128", TYPE_DEC_FLOAT, 0 , 0 },
#endif
{ "Talx2E0", TYPE_UENUM, 0, ' ' }, { "Talx2E0", TYPE_UENUM, 0, ' ' },
{ "Talx2E1", TYPE_UENUM, 1, ' ' }, { "Talx2E1", TYPE_UENUM, 1, ' ' },
{ "Talx2E2", TYPE_SENUM, 3, ' ' }, { "Talx2E2", TYPE_SENUM, 3, ' ' },
...@@ -518,6 +571,11 @@ struct types attrib_array_types[] = { ...@@ -518,6 +571,11 @@ struct types attrib_array_types[] = {
{ "Talx4float", TYPE_FLOAT, 0, 0 }, { "Talx4float", TYPE_FLOAT, 0, 0 },
{ "Talx4double", TYPE_FLOAT, 0, 0 }, { "Talx4double", TYPE_FLOAT, 0, 0 },
{ "Talx4ldouble", TYPE_FLOAT, 0, 0 }, { "Talx4ldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "Talx4Decimal32", TYPE_DEC_FLOAT, 0 , 0 },
{ "Talx4Decimal64", TYPE_DEC_FLOAT, 0 , 0 },
{ "Talx4Decimal128", TYPE_DEC_FLOAT, 0 , 0 },
#endif
{ "Talx4E0", TYPE_UENUM, 0, ' ' }, { "Talx4E0", TYPE_UENUM, 0, ' ' },
{ "Talx4E1", TYPE_UENUM, 1, ' ' }, { "Talx4E1", TYPE_UENUM, 1, ' ' },
{ "Talx4E2", TYPE_SENUM, 3, ' ' }, { "Talx4E2", TYPE_SENUM, 3, ' ' },
...@@ -536,7 +594,11 @@ struct types attrib_array_types[] = { ...@@ -536,7 +594,11 @@ struct types attrib_array_types[] = {
{ "Taly8cptr", TYPE_PTR, 0, 0 }, { "Taly8cptr", TYPE_PTR, 0, 0 },
{ "Taly8iptr", TYPE_PTR, 0, 0 }, { "Taly8iptr", TYPE_PTR, 0, 0 },
{ "Talx8double", TYPE_FLOAT, 0, 0 }, { "Talx8double", TYPE_FLOAT, 0, 0 },
{ "Talx8ldouble", TYPE_FLOAT, 0, 0 } { "Talx8ldouble", TYPE_FLOAT, 0, 0 },
#ifndef SKIP_DECIMAL_FLOAT
{ "Talx8Decimal64", TYPE_DEC_FLOAT, 0, 0 },
{ "Talx8Decimal128", TYPE_DEC_FLOAT, 0, 0 }
#endif
#define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0])) #define NAATYPES2 (sizeof (attrib_array_types) / sizeof (attrib_array_types[0]))
}; };
struct types complex_attrib_array_types[] = { struct types complex_attrib_array_types[] = {
...@@ -950,6 +1012,11 @@ output_FNB (char mode, struct entry *e) ...@@ -950,6 +1012,11 @@ output_FNB (char mode, struct entry *e)
{ {
unsigned long long int l1, l2, m; unsigned long long int l1, l2, m;
int signs = 0; int signs = 0;
#ifndef SKIP_DECIMAL_FLOAT
int suffix = 0;
char DEC_SUFFIX[3][3]={"DF","DD","DL"};
#endif
const char *p, *q; const char *p, *q;
if (e->type->type == TYPE_OTHER) if (e->type->type == TYPE_OTHER)
...@@ -991,6 +1058,29 @@ output_FNB (char mode, struct entry *e) ...@@ -991,6 +1058,29 @@ output_FNB (char mode, struct entry *e)
fprintf (outfile, "%s%f,%s%f", (signs & 1) ? "-" : "", fprintf (outfile, "%s%f,%s%f", (signs & 1) ? "-" : "",
((double) l1) / 64, (signs & 2) ? "-" : "", ((double) l2) / 64); ((double) l1) / 64, (signs & 2) ? "-" : "", ((double) l2) / 64);
break; break;
#ifndef SKIP_DECIMAL_FLOAT
case TYPE_DEC_FLOAT:
l1 &= 0xffffff;
l2 &= 0xffffff;
signs = generate_random () & 3;
/* Get the suffix of Decimal Floting Points per
e->type->name. Distinguish these three DFP types by
e->type->name. */
if (strstr(e->type->name, "Decimal32")) suffix=0;
else if (strstr(e->type->name, "Decimal64")) suffix=1;
else if (strstr(e->type->name, "Decimal128")) suffix=2;
else
abort ();
/* Formatted input/output specifiers for DFP types have not been
implemented in GLIBC. %f here used in fprintf is just to
dump the numbers to outfile. */
fprintf (outfile, "%s%f%s,%s%f%s",
(signs & 1) ? "-" : "", ((double) l1) / 64, DEC_SUFFIX[suffix],
(signs & 2) ? "-" : "", ((double) l2) / 64, DEC_SUFFIX[suffix]);
break;
#endif
case TYPE_CINT: case TYPE_CINT:
signs = generate_random () & 3; signs = generate_random () & 3;
l1 &= e->type->maxval; l1 &= e->type->maxval;
......
/* Verify the DWARF encoding of C99 decimal floating point types. */
/* { dg-do compile */
/* { dg-require-effective-target dfp } */
/* { dg-options "-O0 -gdwarf-2 -dA" } */
/* { dg-final { scan-assembler "0x10.*DW_AT_encoding" } } */
/* { dg-final { scan-assembler "0x4.*DW_AT_byte_size" } } */
/* { dg-final { scan-assembler "0x8.*DW_AT_byte_size" } } */
/* { dg-final { scan-assembler "0x10.*DW_AT_byte_size" } } */
void foo ()
{
_Decimal32 f = 1.5df;
_Decimal64 d = 1.5dd;
_Decimal128 l = 1.5dl;
}
/* Verify the DWARF encoding of C99 floating point types. */
/* { dg-do compile */
/* { dg-options "-O0 -gdwarf-2 -dA" } */
/* { dg-final { scan-assembler "0x4.*DW_AT_encoding" } } */
/* { dg-final { scan-assembler "0x4.*DW_AT_byte_size" } } */
/* { dg-final { scan-assembler "0x8.*DW_AT_byte_size" } } */
/* { dg-final { scan-assembler "0x10.*DW_AT_byte_size" } } */
void foo ()
{
float f = 1.5f;
double d = 1.5;
long double l = 1.5l;
}
/* Test operation of -Wbad-function-cast. */
/* Based on gcc.dg/Wbad-function-cast-1.c. */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wbad-function-cast" } */
int if1(void);
char if2(void);
long if3(void);
float rf1(void);
double rf2(void);
_Decimal32 rf3(void);
_Decimal64 rf4(void);
_Decimal128 rf5(void);
_Complex double cf(void);
void
foo(void)
{
/* Casts to void types are always OK. */
(void)rf3();
(void)rf4();
(void)rf5();
(const void)rf3();
/* Casts to the same type or similar types are OK. */
(_Decimal32)rf1();
(_Decimal64)rf2();
(_Decimal128)rf3();
(_Decimal128)rf4();
(_Decimal128)rf5();
(float)rf3();
(double)rf4();
(long double)rf5();
/* Casts to types with different TREE_CODE (which is how this
warning has been defined) are not OK, except for casts to void
types. */
(_Decimal32)if1(); /* { dg-warning "cast from function call of type 'int' to non-matching type '_Decimal32'" } */
(_Decimal64)if2(); /* { dg-warning "cast from function call of type 'char' to non-matching type '_Decimal64'" } */
(_Decimal128)if3(); /* { dg-warning "cast from function call of type 'long int' to non-matching type '_Decimal128'" } */
(int)rf3(); /* { dg-warning "cast from function call of type '_Decimal32' to non-matching type 'int'" } */
(long)rf4(); /* { dg-warning "cast from function call of type '_Decimal64' to non-matching type 'long int'" } */
(long int)rf5(); /* { dg-warning "cast from function call of type '_Decimal128' to non-matching type 'long int'" } */
(_Decimal32)cf(); /* { dg-warning "cast from function call of type 'complex double' to non-matching type '_Decimal32'" } */
}
/* Test messages for -Wconversion (based on gcc.dg/Wconversion-2.c). */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wconversion" } */
void fsi(signed int);
void fd32(_Decimal32);
void fd64(_Decimal64);
void fd128(_Decimal128);
struct s {
void (*fsi)(signed int);
void (*fd32)(_Decimal32);
void (*fd64)(_Decimal64);
void (*fd128)(_Decimal128);
} x;
signed int si;
unsigned int ui;
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
void
g (void)
{
fsi(d32); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */
x.fsi(d32); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */
fsi(d64); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */
x.fsi(d64); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */
fsi(d128); /* { dg-warning "warning: passing argument 1 of 'fsi' as integer rather than floating due to prototype" } */
x.fsi(d128); /* { dg-warning "warning: passing argument 1 of 'x.fsi' as integer rather than floating due to prototype" } */
fd32(si); /* { dg-warning "warning: passing argument 1 of 'fd32' as floating rather than integer due to prototype" } */
x.fd32(si); /* { dg-warning "warning: passing argument 1 of 'x.fd32' as floating rather than integer due to prototype" } */
fd64(ui); /* { dg-warning "warning: passing argument 1 of 'fd64' as floating rather than integer due to prototype" } */
x.fd64(ui); /* { dg-warning "warning: passing argument 1 of 'x.fd64' as floating rather than integer due to prototype" } */
fd128(si); /* { dg-warning "warning: passing argument 1 of 'fd128' as floating rather than integer due to prototype" } */
x.fd128(ui); /* { dg-warning "warning: passing argument 1 of 'x.fd128' as floating rather than integer due to prototype" } */
fd32(1.0); /* { dg-warning "warning: passing argument 1 of 'fd32' as '_Decimal32' rather than 'double' due to prototype" } */
x.fd32(1.0); /* { dg-warning "warning: passing argument 1 of 'x.fd32' as '_Decimal32' rather than 'double' due to prototype" } */
fd64(1.0); /* { dg-warning "warning: passing argument 1 of 'fd64' as '_Decimal64' rather than 'double' due to prototype" } */
x.fd64(1.0); /* { dg-warning "warning: passing argument 1 of 'x.fd64' as '_Decimal64' rather than 'double' due to prototype" } */
fd128(1.0); /* { dg-warning "warning: passing argument 1 of 'fd128' as '_Decimal128' rather than 'double' due to prototype" } */
x.fd128(1.0); /* { dg-warning "warning: passing argument 1 of 'x.fd128' as '_Decimal128' rather than 'double' due to prototype" } */
}
/* { dg-do compile { target { powerpc*-*-linux* } } } */
/* { dg-options "-maltivec" } */
/* GNU extension: PowerPC AltiVec Built-in Functions.
These should be rejected as invalid AltiVec types. */
__vector _Decimal32 vd32; /* { dg-error "AltiVec types" "" } */
__vector _Decimal64 vd64; /* { dg-error "AltiVec types" "" } */
__vector _Decimal128 vd128; /* { dg-error "AltiVec types" "" } */
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.9.1(9) Function definitions; parameter has automatic storage.
Test that actual parameters are passed by value and that modifications
made within functions are lost on function return. */
extern void abort (void);
int foo32 (_Decimal32 z)
{
z = z + 1.0df;
}
int foo64 (_Decimal64 z)
{
z = z + 1.0dd;
}
int foo128 (_Decimal128 z)
{
z = z + 1.0dl;
}
int
main ()
{
_Decimal32 d32 = 1.1df;
_Decimal64 d64 = 1.2dd;
_Decimal128 d128 = 1.3dl;
foo32 (d32);
if (d32 != 1.1df)
abort ();
foo64 (d64);
if (d64 != 1.2dd)
abort ();
foo128 (d128);
if (d128 != 1.3dl)
abort ();
return 0;
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.4 Cast operators.
Test invalid casts involving decimal float. */
struct s { _Decimal32 d32; } sv;
union u { _Decimal32 d32; } uv;
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
_Decimal32* d32p;
_Decimal64* d64p;
_Decimal128* d128p;
void
f (void)
{
(_Decimal32 []) d32p; /* { dg-error "cast specifies array type" } */
(_Decimal32 ()) d32p; /* { dg-error "cast specifies function type" } */
(_Decimal64 []) d64p; /* { dg-error "cast specifies array type" } */
(_Decimal64 ()) d64p; /* { dg-error "cast specifies function type" } */
(_Decimal128 []) d128p; /* { dg-error "cast specifies array type" } */
(_Decimal128 ()) d128p; /* { dg-error "cast specifies function type" } */
(struct s) d32; /* { dg-error "conversion to non-scalar type requested" } */
(union u) d32;
(struct s) d64; /* { dg-error "conversion to non-scalar type requested" } */
(union u) d64; /* { dg-error "cast to union type from type not present in union" } */
(struct s) d128; /* { dg-error "conversion to non-scalar type requested" } */
(union u) d128; /* { dg-error "cast to union type from type not present in union" } */
(_Decimal32) sv; /* { dg-error "aggregate value used where a float was expected" } */
(_Decimal32) uv; /* { dg-error "aggregate value used where a float was expected" } */
(_Decimal64) sv; /* { dg-error "aggregate value used where a float was expected" } */
(_Decimal64) uv; /* { dg-error "aggregate value used where a float was expected" } */
(_Decimal128) sv; /* { dg-error "aggregate value used where a float was expected" } */
(_Decimal128) uv; /* { dg-error "aggregate value used where a float was expected" } */
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.4 Cast operators.
Test valid casts involving decimal float. */
extern void abort (void);
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
static float f = 2.f;
static double d = 2.l;
int
main (void)
{
/* Casts between DFP types. */
d32 = 1.2df;
d64 = 1.2dd;
d128 = 1.2dl;
if (d32 != (_Decimal32) d64)
abort ();
if (d32 != (_Decimal32) d128)
abort ();
if (d64 != (_Decimal64) d32)
abort ();
if (d64 != (_Decimal64) d128)
abort ();
if (d128 != (_Decimal128) d32)
abort ();
if (d128 != (_Decimal128) d64)
abort ();
/* Casts between generic and decimal floating point types. Use a
value that we can assume can be represented exactly in all
representations. */
d32 = 2.0df;
d64 = 2.0dd;
d128 = 2.0dl;
/* To generic floating types. */
if ((float) d32 != 2.0f)
abort ();
if ((double) d32 != 2.0l)
abort ();
if ((float) d64 != 2.0f)
abort ();
if ((double) d64 != 2.0l)
abort ();
if ((float) d128 != 2.0f)
abort ();
if ((double) d128 != 2.0l)
abort ();
/* float to decimal floating types. */
if (d32 != (_Decimal32) f)
abort ();
if (d64 != (_Decimal64) f)
abort ();
if (d128 != (_Decimal128) f)
abort ();
/* double to decimal floating types. */
if (d32 != (_Decimal32) d)
abort ();
if (d64 != (_Decimal64) d)
abort ();
if (d128 != (_Decimal128) d)
abort ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.9 Equality operators.
Compare decimal float constants against each other. */
extern void link_error (void);
int
main ()
{
/* Compare like-typed positive constants. */
if (2.0df != 2.0df)
link_error ();
/* Compare decimal float constants of different types. */
if (500e-2dl != 0.05e2df)
link_error ();
/* Binary floating point introduces errors to decimal values. */
if (1.4 + 1.4 + 1.4 == 4.2)
link_error ();
/* But, this looks more like what one would expect. */
if (1.4dd + 1.4dd + 1.4dd != 4.2dd)
link_error ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* C99 6.5.9 Equality operators.
Compare decimal float values against each other at runtime. */
#define WIDTH 128
#include "compare-eq.h"
int main ()
{
test_compares ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* C99 6.5.9 Equality operators.
Compare decimal float values against each other at runtime. */
#define WIDTH 32
#include "compare-eq.h"
int main ()
{
test_compares ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* C99 6.5.9 Equality operators.
Compare decimal float values against each other at runtime. */
#define WIDTH 64
#include "compare-eq.h"
int main ()
{
test_compares ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* C99 6.5.9 Equality operators.
Compare decimal float values against variables of different types. */
extern void abort (void);
static int failcnt;
/* Support compiling the test to report individual failures; default is
to abort as soon as a check fails. */
#ifdef DBG
#include <stdio.h>
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
#else
#define FAILURE abort ();
#endif
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
/* Use some typedefs of decimal float types, too. */
typedef _Decimal32 SDtype;
typedef _Decimal64 DDtype;
typedef _Decimal128 TDtype;
SDtype d32b;
DDtype d64b;
TDtype d128b;
void
inits (void)
{
d32 = 1.0df;
d64 = 3.0dd;
d128 = 5.0dl;
d32b = -1.0df;
d64b = -4.0dd;
d128b = -6.0dl;
}
void
compare_dfp (void)
{
if ((d32 == d64) != 0) FAILURE
if ((d32 != d128b) != 1) FAILURE
if ((d64 != d32) != 1) FAILURE
if ((d64 == d128) != 0) FAILURE
if ((d128 != d32) != 1) FAILURE
if ((d128 == d64) != 0) FAILURE
}
int
main ()
{
inits ();
compare_dfp ();
if (failcnt)
abort ();
return 0;
}
/* Basic test of runtime equality comparisons using simple values that
are not affected by rounding. */
#include <stdlib.h>
static int failcnt;
#define PASTE2(A,B) A ## B
#define PASTE(A,B) PASTE2(A,B)
#ifdef DBG
#include <stdio.h>
#define FAILURE(OP,KIND) \
{ printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \
failcnt++; }
#else
#define FAILURE(OP,KIND) abort ();
#endif
#ifndef WIDTH
#error define WIDTH as decimal float size in bytes
#endif
#if WIDTH == 32
#define DTYPE _Decimal32
#define SUFFIX DF
#elif WIDTH == 64
#define DTYPE _Decimal64
#define SUFFIX DD
#elif WIDTH == 128
#define DTYPE _Decimal128
#define SUFFIX DL
#elif WIDTH == 0
/* This is for testing the test using a type known to work. */
#define DTYPE double
#define SUFFIX
#else
#error invalid width for decimal float type
#endif
DTYPE m_two = PASTE(-2.0, SUFFIX);
DTYPE m_one = PASTE(-1.0, SUFFIX);
DTYPE zero = PASTE(0.0, SUFFIX);
DTYPE one = PASTE(1.0, SUFFIX);
DTYPE two = PASTE(2.0, SUFFIX);
void
test_compares (void)
{
DTYPE x = one;
DTYPE y = zero;
DTYPE z = m_one;
/* Equal to: comparisons against equal values. */
if (! (x == one)) FAILURE ("==", "equal")
if (! (y == zero)) FAILURE ("==", "equal")
if (! (z == m_one)) FAILURE ("==", "equal")
/* Equal to: comparisons against lesser values. */
if (x == m_one) FAILURE ("==", "lesser")
if (x == zero) FAILURE ("==", "lesser")
if (y == m_one) FAILURE ("==", "lesser")
if (z == m_two) FAILURE ("==", "lesser")
/* Equal to: comparisons against greater values. */
if (x == two) FAILURE ("==", "greater")
if (y == one) FAILURE ("==", "greater")
if (z == zero) FAILURE ("==", "greater")
if (z == one) FAILURE ("==", "greater")
/* Not equal to: comparisons against equal values. */
if (x != one) FAILURE ("!=", "equal")
if (y != zero) FAILURE ("!=", "equal")
if (z != m_one) FAILURE ("!=", "equal")
/* Not equal to: comparisons against lesser values. */
if (! (x != m_one)) FAILURE ("!=", "lesser")
if (! (x != zero)) FAILURE ("!=", "lesser")
if (! (y != m_one)) FAILURE ("!=", "lesser")
if (! (z != m_two)) FAILURE ("!=", "lesser")
/* Not equal to: comparisons against greater values. */
if (! (x != m_one)) FAILURE ("!=", "greater")
if (! (x != zero)) FAILURE ("!=", "greater")
if (! (y != m_one)) FAILURE ("!=", "greater")
if (! (z != m_two)) FAILURE ("!=", "greater")
if (failcnt)
abort ();
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.8 Relational operators.
Compare decimal float constants against each other. */
extern void link_error (void);
int
main ()
{
/* Compare like-typed negative constants. */
if (-2.0dl < -2.0dl)
link_error ();
/* Compare like-typed constants. */
if (-2.0dl >= .01dl)
link_error ();
/* Compare like-typed constants. */
if (0.2dd > 0.02e1dd)
link_error ();
/* Compare decimal float constants of different types. */
if (-.000005dd >= -.0000049DL)
link_error();
/* Test use gcc builtins for comparisons. */
if (__builtin_isless(-2.0dl,-2.0dl))
link_error();
if (__builtin_isgreaterequal(-2.0dl,.01dl))
link_error();
if (!(__builtin_islessequal(-2.0dl, -2.0dd)))
link_error();
if (!(__builtin_isgreater(2.0dl, -2.0dd)))
link_error();
if (__builtin_islessequal(2.0df, __builtin_nand64("")))
link_error();
if (__builtin_islessgreater(2.0dd, __builtin_nand64("")))
link_error();
if (!__builtin_islessgreater(2.0dd, -2.0dd))
link_error();
if (!__builtin_islessgreater(-3.0dd, 2.0dd))
link_error();
if (__builtin_isunordered(1.1df, 0.003dd))
link_error();
if (!__builtin_isunordered(-3.1df, __builtin_nand32("")))
link_error();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* C99 6.5.8 Relational operators.
Compare decimal float values against each other at runtime. */
#define WIDTH 128
#include "compare-rel.h"
int
main ()
{
test_compares ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* C99 6.5.8 Relational operators.
Compare decimal float values against each other at runtime. */
#define WIDTH 32
#include "compare-rel.h"
int
main ()
{
test_compares ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* C99 6.5.8 Relational operators.
Compare decimal float values against each other at runtime. */
#define WIDTH 64
#include "compare-rel.h"
int
main ()
{
test_compares ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* C99 6.5.8 Relational operators.
Compare decimal float values against variables of different types. */
extern void abort (void);
static int failcnt;
/* Support compiling the test to report individual failures; default is
to abort as soon as a check fails. */
#ifdef DBG
#include <stdio.h>
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
#else
#define FAILURE abort ();
#endif
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
/* Use some typedefs of decimal float types, too. */
typedef _Decimal32 SDtype;
typedef _Decimal64 DDtype;
typedef _Decimal128 TDtype;
SDtype d32b;
DDtype d64b;
TDtype d128b;
void
inits (void)
{
d32 = 1.0df;
d64 = 3.0dd;
d128 = 5.0dl;
d32b = -1.0df;
d64b = -4.0dd;
d128b = -6.0dl;
}
void
compare_dfp (void)
{
if ((d32 > d64) != 0) FAILURE
if ((d32 >= d128b) != 1) FAILURE
if ((d64 < d32) != 0) FAILURE
if ((d64 <= d128) != 1) FAILURE
if ((d128 > d32) != 1) FAILURE
if ((d128 >= d64) != 1) FAILURE
}
int
main ()
{
inits ();
compare_dfp ();
if (failcnt)
abort ();
return 0;
}
/* Basic test of runtime relational comparisons using simple values that
are not affected by rounding. */
#include <stdlib.h>
static int failcnt;
#define PASTE2(A,B) A ## B
#define PASTE(A,B) PASTE2(A,B)
#ifdef DBG
#include <stdio.h>
#define FAILURE(OP,KIND) \
{ printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \
failcnt++; }
#else
#define FAILURE(OP,KIND) abort ();
#endif
#ifndef WIDTH
#error define WIDTH as decimal float size in bytes
#endif
#if WIDTH == 32
#define DTYPE _Decimal32
#define SUFFIX DF
#elif WIDTH == 64
#define DTYPE _Decimal64
#define SUFFIX DD
#elif WIDTH == 128
#define DTYPE _Decimal128
#define SUFFIX DL
#elif WIDTH == 0
/* This is for testing the test using a type known to work. */
#define DTYPE double
#define SUFFIX
#else
#error invalid width for decimal float type
#endif
DTYPE m_two = PASTE(-2.0, SUFFIX);
DTYPE m_one = PASTE(-1.0, SUFFIX);
DTYPE zero = PASTE(0.0, SUFFIX);
DTYPE one = PASTE(1.0, SUFFIX);
DTYPE two = PASTE(2.0, SUFFIX);
void
test_compares (void)
{
DTYPE x = one;
DTYPE y = zero;
DTYPE z = m_one;
/* Less than or equal to: comparisons against equal values. */
if (! (x <= one)) FAILURE ("<=", "equal")
if (! (y <= zero)) FAILURE ("<=", "equal")
if (! (z <= m_one)) FAILURE ("<=", "equal")
/* Less than or equal to: comparisons against lesser values. */
if (x <= m_one) FAILURE ("<=", "lesser")
if (x <= zero) FAILURE ("<=", "lesser")
if (y <= m_one) FAILURE ("<=", "lesser")
if (z <= m_two) FAILURE ("<=", "lesser")
/* Less than or equal to: comparisons against greater values. */
if (! (x <= two)) FAILURE ("<=", "greater")
if (! (y <= one)) FAILURE ("<=", "greater")
if (! (z <= zero)) FAILURE ("<=", "greater")
if (! (z <= one)) FAILURE ("<=", "greater")
/* Less than: comparisons against equal values. */
if (x < one) FAILURE ("<", "equal")
if (y < zero) FAILURE ("<", "equal")
if (z < m_one) FAILURE ("<", "equal")
/* Less than: comparisons against lesser values. */
if (x < m_one) FAILURE ("<", "lesser")
if (x < zero) FAILURE ("<", "lesser")
if (y < m_one) FAILURE ("<", "lesser")
if (z < m_two) FAILURE ("<", "lesser")
/* Less than: comparisons against greater values. */
if (! (x < two)) FAILURE ("<", "greater")
if (! (y < one)) FAILURE ("<", "greater")
if (! (z < zero)) FAILURE ("<", "greater")
if (! (z < one)) FAILURE ("<", "greater")
/* Greater than or equal to: comparisons against equal values. */
if (! (x >= one)) FAILURE (">=", "equal")
if (! (y >= zero)) FAILURE (">=", "equal")
if (! (z >= m_one)) FAILURE (">=", "equal")
/* Greater than or equal to: comparisons against lesser values. */
if (! (x >= m_one)) FAILURE (">=", "lesser")
if (! (x >= zero)) FAILURE (">=", "lesser")
if (! (y >= m_one)) FAILURE (">=", "lesser")
if (! (z >= m_two)) FAILURE (">=", "lesser")
/* Greater than or equal to: comparisons against greater values. */
if (x >= two) FAILURE (">=", "greater")
if (y >= one) FAILURE (">=", "greater")
if (z >= zero) FAILURE (">=", "greater")
if (z >= one) FAILURE (">=", "greater")
/* Greater than: comparisons against equal values. */
if (x > one) FAILURE (">", "equal")
if (y > zero) FAILURE (">", "equal")
if (z > m_one) FAILURE (">", "equal")
/* Greater than: comparisons against lesser values. */
if (! (x > m_one)) FAILURE (">", "lesser")
if (! (x > zero)) FAILURE (">", "lesser")
if (! (y > m_one)) FAILURE (">", "lesser")
if (! (z > m_two)) FAILURE (">", "lesser")
/* Greater than: comparisons against greater values. */
if (x > two) FAILURE (">", "greater")
if (y > one) FAILURE (">", "greater")
if (z > zero) FAILURE (">", "greater")
if (z > one) FAILURE (">", "greater")
if (failcnt)
abort ();
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -O -Wall" } */
/* C99 6.2.7: Compatible type and composite type. */
#define DECIMAL_COMPOSITE_DECL(TYPE) \
_Decimal##TYPE g1_##TYPE(); \
_Decimal##TYPE g2_##TYPE(); \
_Decimal##TYPE (*h1_##TYPE)[2]; \
_Decimal##TYPE (*h2_##TYPE)[3]; \
_Decimal##TYPE (*h3_##TYPE)[4]; \
_Decimal##TYPE f1_##TYPE(_Decimal##TYPE(*)()); \
_Decimal##TYPE f1_##TYPE(_Decimal##TYPE(*)(_Decimal##TYPE*)); \
_Decimal##TYPE f1_##TYPE (_Decimal##TYPE(*g)(_Decimal##TYPE*)) \
{ \
_Decimal##TYPE d##TYPE; \
d##TYPE = ((_Decimal##TYPE (*) (_Decimal##TYPE*)) g)(&d##TYPE); \
d##TYPE = ((_Decimal##TYPE (*) ()) g); \
return d##TYPE; \
} \
_Decimal##TYPE f2_##TYPE(_Decimal##TYPE(*)[]); \
_Decimal##TYPE f2_##TYPE(_Decimal##TYPE(*)[3]);
#define DECIMAL_COMPOSITE_TEST(TYPE) \
do \
{ \
_Decimal##TYPE d##TYPE; \
d##TYPE = f1_##TYPE(g1_##TYPE); \
d##TYPE = f1_##TYPE(g2_##TYPE); \
d##TYPE = f2_##TYPE(h1_##TYPE); \
d##TYPE = f2_##TYPE(h2_##TYPE); \
d##TYPE = f2_##TYPE(h3_##TYPE); \
} while(0)
DECIMAL_COMPOSITE_DECL(32); /* { dg-error "incompatible types in assignment" } */
DECIMAL_COMPOSITE_DECL(64); /* { dg-error "incompatible types in assignment" } */
DECIMAL_COMPOSITE_DECL(128); /* { dg-error "incompatible types in assignment" } */
int main()
{
DECIMAL_COMPOSITE_TEST(32); /* { dg-warning "incompatible pointer type" } */
DECIMAL_COMPOSITE_TEST(64); /* { dg-warning "incompatible pointer type" } */
DECIMAL_COMPOSITE_TEST(128); /* { dg-warning "incompatible pointer type" } */
return 0;
}
/* { dg-do compile } */
/* { dg-options "-std=c99" } */
/* N1150 6: Constants.
C99 6.4.4.2: Floating constants. */
_Decimal32 a = 1.1df; /* { dg-error "error" } */
_Decimal32 b = -.003DF; /* { dg-error "error" } */
_Decimal64 c = 11e-1dl; /* { dg-error "error" } */
_Decimal64 d = -.3DL; /* { dg-error "error" } */
_Decimal128 e = 000.3e0dl; /* { dg-error "error" } */
_Decimal128 f = 3000300030003e0DL; /* { dg-error "error" } */
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
/* N1150 6: Constants.
C99 6.4.4.2: Floating constants.
The df, dd, dl, DF, DD and DL suffixes shall not be used in a
hexadecimal-floating-constant. */
_Decimal32 bad1 = 0x1.0p1df; /* { dg-error "invalid suffix" "hexadecimal floating constant" } */
_Decimal32 bad2 = 0x1.0p1DF; /* { dg-error "invalid suffix" "hexadecimal floating constant" } */
_Decimal64 bad3 = 0x2.0p-2dd; /* { dg-error "invalid suffix" "hexadecimal floating constant" } */
_Decimal64 bad4 = 0x2.0p2DD; /* { dg-error "invalid suffix" "hexadecimal floating constant" } */
_Decimal128 bad5 = 0x3.0p3dl; /* { dg-error "invalid suffix" "hexadecimal floating constant" } */
_Decimal128 bad6 = 0x3.0p3DL; /* { dg-error "invalid suffix" "hexadecimal floating constant" } */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -pedantic" } */
/* N1150 6: Constants.
C99 6.4.4.2: Floating constants. */
_Decimal32 a = 1.1df; /* { dg-warning "GCC extension|ISO C" } */
_Decimal32 b = -.003DF; /* { dg-warning "GCC extension|ISO C" } */
_Decimal64 c = 11e-1dl; /* { dg-warning "GCC extension|ISO C" } */
_Decimal64 d = -.3DL; /* { dg-warning "GCC extension|ISO C" } */
_Decimal128 e = 000.3e0dl; /* { dg-warning "GCC extension|ISO C" } */
_Decimal128 f = 3000300030003e0DL; /* { dg-warning "GCC extension|ISO C" } */
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
/* N1150 6: Constants.
C99 6.4.4.2: Floating constants. */
_Decimal32 a = 1.1df;
_Decimal32 b = -.003DF;
_Decimal64 c = 11e-1dl;
_Decimal64 d = -.3DL;
_Decimal128 e = 000.3e0dl;
_Decimal128 f = 3000300030003e0DL;
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -O" } */
/* N1150 5.2 Conversions among decimal floating types and between
decimal floating types and generic floating types.
C99 6.3.1.5(4) Conversions, arithmetic operands, real floating types. */
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
float sf;
double df;
long double tf;
extern void link_error (void);
int
main ()
{
/* Conversions from decimal float to binary float. */
/* Conversions from _Decimal32. */
d32 = 2.0df;
sf = d32;
if (sf != 2.0f)
link_error ();
df = d32;
if (df != 2.0)
link_error ();
tf = d32;
if (tf != 2.0l)
link_error ();
/* Conversions from _Decimal64. */
d64 = -7.0dd;
sf = d64;
if (sf != -7.0f)
link_error ();
df = d64;
if (df != -7.0)
link_error ();
tf = d64;
if (tf != -7.0l)
link_error ();
/* Conversions from _Decimal128. */
d128 = 30.0dl;
sf = d128;
if (sf != 30.0f)
link_error ();
df = d128;
if (df != 30.0)
link_error ();
df = d128;
if (df != 30.0l)
link_error ();
/* Conversions from binary float to decimal float. */
sf = 30.0f;
d32 = sf;
if (d32 != 30.0df)
link_error ();
d64 = sf;
if (d64 != 30.0dd)
link_error ();
df = -2.0;
d32 = df;
if (d32 != -2.0df)
link_error ();
d64 = df;
if (d64 != -2.0dd)
link_error ();
d128 = df;
if (d128 != -2.0dl)
link_error ();
sf = 30.0f;
d128 = sf;
if (d128 != 30.0dl)
link_error ();
tf = -22.0l;
d32 = tf;
if (d32 != -22.0df)
link_error ();
d64 = tf;
if (d64 != -22.0dd)
link_error ();
d128 = tf;
if (d128 != -22.0dl)
link_error ();
/* 2**(-11) = 0.00048828125. */
d128 = 0.000488281251dl;
sf = d128;
if (sf != 0.00048828125f)
link_error ();
/* 2**(-25) = 0.298023223876953125E-7. */
d128 = 2.98023223876953125E-8dl;
df = d128;
if (df < (2.9802322387695312e-08 - 0.00000000001)
|| df > (2.9802322387695312e-08 + 0.00000000001))
link_error ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* N1150 5.2 Conversions among decimal floating types and between
decimal floating types and generic floating types.
C99 6.3.1.5(4) Conversions, arithmetic operands, real floating types. */
volatile _Decimal32 d32;
volatile _Decimal64 d64;
volatile _Decimal128 d128;
volatile float sf;
volatile double df;
volatile long double tf;
extern void abort (void);
int
main ()
{
/* Conversions from decimal float to binary float. */
/* Conversions from _Decimal32. */
d32 = 2.0df;
sf = d32;
if (sf != 2.0f)
abort ();
df = d32;
if (df != 2.0)
abort ();
tf = d32;
if (tf != 2.0l)
abort ();
/* Conversions from _Decimal64. */
d64 = -7.0dd;
sf = d64;
if (sf != -7.0f)
abort ();
df = d64;
if (df != -7.0)
abort ();
tf = d64;
if (tf != -7.0l)
abort ();
/* Conversions from _Decimal128. */
d128 = 30.0dl;
sf = d128;
if (sf != 30.0f)
abort ();
df = d128;
if (df != 30.0)
abort ();
df = d128;
if (df != 30.0l)
abort ();
/* Conversions from binary float to decimal float. */
sf = 30.0f;
d32 = sf;
if (d32 != 30.0df)
abort ();
d64 = sf;
if (d64 != 30.0dd)
abort ();
df = -2.0;
d32 = df;
if (d32 != -2.0df)
abort ();
d64 = df;
if (d64 != -2.0dd)
abort ();
d128 = df;
if (d128 != -2.0dl)
abort ();
sf = 30.0f;
d128 = sf;
if (d128 != 30.0dl)
abort ();
tf = -22.0l;
d32 = tf;
if (d32 != -22.0df)
abort ();
d64 = tf;
if (d64 != -22.0dd)
abort ();
d128 = tf;
if (d128 != -22.0dl)
abort ();
/* 2**(-11) = 0.00048828125. */
d128 = 0.000488281251dl;
sf = d128;
if (sf != 0.00048828125f)
abort ();
/* 2**(-25) = 0.298023223876953125E-7. */
d128 = 2.98023223876953125E-8dl;
df = d128;
if (df < (2.9802322387695312e-08 - 0.00000000001)
|| df > (2.9802322387695312e-08 + 0.00000000001))
abort ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-O3" } */
/* N1150 5.3 Conversions between decimal floating and complex.
C99 6.3.1.7 Conversions, arithmetic operands, real and complex. */
extern void abort(void);
static int failcnt;
/* Support compiling the test to report individual failures; default is
to abort as soon as a check fails. */
#ifdef DBG
#include <stdio.h>
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
#else
#define FAILURE abort ();
#endif
int
main ()
{
_Complex float cf;
_Complex double cd;
_Complex long double cld;
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
cf = 2.0f * __extension__ 1i + 3.0f;
cd = 2.0 * __extension__ 1i + 3.0;
cld = 2.0l * __extension__ 1i + 3.0l;
/* Convert complex to decimal floating. */
d32 = cf;
d64 = cd;
d128 = cld;
if (d32 != 3.0DF)
FAILURE
if (d64 != 3.0dd)
FAILURE
if (d128 != 3.0dl)
FAILURE
/* Convert decimal floating to complex. */
d32 = 2.5DF;
d64 = 1.5DD;
d128 = 2.5DL;
cf = d32;
cd = d64;
cld = d128;
/* N1107 5.3 Conversions between decimal floating and complex.
When a value of decimal floating type converted to a complex
type, the real part of the complex result value is undermined
by the rules of conversions in N1107 5.2 and the imaginary part
of the complex result value is zero. */
if (__real__ cf != 2.5f)
FAILURE
if (__real__ cd !=1.5)
FAILURE
if (__real__ cld != 2.5)
FAILURE
if (__imag__ cf != 0.0f)
FAILURE
if (__imag__ cd != 0.0)
FAILURE
if (__imag__ cld != 0.0l)
FAILURE
/* Verify that the conversions from DFP types to complex is
determined by the rules of conversion to the real part. */
/* Convert _Decimal64 to _Complex float. */
d64 = 0.125dl;
cf = d64;
if (__real__ cf != 0.125f)
FAILURE
/* Convert _Decimal128 to _Complex double. */
d128 = 1.25E-7dl;
cd = d128;
if (__real__ cd != 1.25E-7)
FAILURE
/* Verify that conversion from complex to decimal floating types
results in the value of the real part converted to the result
type according to the rules of conversion between those types. */
/* Convert _Complex float to decimal float types. */
cf = 2.0f * __extension__ 1i + 2.25f;
d32 = cf;
d64 = cf;
d128 = cf;
if (d32 != 2.25DF)
FAILURE
if (d64 != 2.25DD)
FAILURE
if (d128 != 2.25DL)
FAILURE
/* Convert _Complex double to decimal float types. */
cd = 2.0 * __extension__ 1i + 1.25;
d32 = cd;
d64 = cd;
d128 = cd;
if (d32 != 1.25DF)
FAILURE
if (d64 != 1.25DD)
FAILURE
if (d128 != 1.25DL)
FAILURE
/* Convert _Complex long double to decimal float types. */
cld = 2.0l * __extension__ 1i + 0.0625l;
d32 = cld;
d64 = cld;
d128 = cld;
if (d32 != 0.0625DF)
FAILURE
if (d64 != 0.0625DD)
FAILURE
if (d128 != 0.0625DL)
FAILURE
return 0;
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -O" } */
/* N1150 5.2 Conversions among decimal floating types and between
decimal floating types and generic floating types.
C99 6.3.1.5(3) New. */
extern void link_error ();
int
main ()
{
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
/* Conversions to larger types. */
d32 = 123.4df;
d64 = d32;
if (d64 != 123.4dd)
link_error ();
d128 = d32;
if (d128 != 123.4dl)
link_error ();
d64 = 345.678dd;
d128 = d64;
if (d128 != 345.678dl)
link_error ();
/* Conversions to smaller types for which the value fits. */
d64 = 3456.789dd;
d32 = d64;
if (d32 != 3456.789df)
link_error ();
d128 = 123.4567dl;
d32 = d128;
if (d32 != 123.4567dl)
link_error ();
d128 = 1234567890.123456dl;
d64 = d128;
if (d64 != 1234567890.123456dd)
link_error ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-O0 -std=gnu99" } */
/* N1150 5.2: Conversions among decimal floating types and between
decimal floating types and generic floating types.
C99 6.3.1.5(3) New.
Perform conversions between DFP types in which the assigned value
cannot be represented exactly in the result and must be rounded
correctly according to the current rounding mode.
Normally this would not be part of compiler testing, but conversions
are currently handled in libgcc via decNumber. */
#include "dfp-round.h"
extern void abort (void);
static int failcnt = 0;
/* Support compiling the test to report individual failures; default is
to abort as soon as a check fails. */
#ifdef DBG
#include <stdio.h>
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
#else
#define FAILURE abort ();
#endif
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
_Decimal32 d64_to_d32 (_Decimal64 d) { return d; }
_Decimal64 d128_to_d64 (_Decimal128 d) { return d; }
_Decimal32 d128_to_d32 (_Decimal128 d) { return d; }
int
do_d64_to_d32 (_Decimal64 orig, _Decimal32 exp)
{
d64 = orig;
d32 = d64_to_d32 (d64);
return (d32 == exp);
}
int
do_d128_to_d32 (_Decimal128 orig, _Decimal32 exp)
{
d128 = orig;
d32 = d128_to_d32 (d128);
return (d32 == exp);
}
int
do_d128_to_d64 (_Decimal128 orig, _Decimal64 exp)
{
d128 = orig;
d64 = d128_to_d64 (d128);
return (d64 == exp);
}
int
main ()
{
DFP_SETROUND (FE_DEC_DOWNWARD);
if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE
if (!do_d64_to_d32 (1.1111135dd, 1.111113df)) FAILURE
if (!do_d64_to_d32 (-1.1111125dd, -1.111113df)) FAILURE
if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE
if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE
if (!do_d128_to_d32 (1.1111135dl, 1.111113df)) FAILURE
if (!do_d128_to_d32 (-1.1111125dl, -1.111113df)) FAILURE
if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE
if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE
if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111113dd)) FAILURE
if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111113dd)) FAILURE
if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE
DFP_SETROUND (FE_DEC_TONEAREST);
if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE
if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE
if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE
if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE
if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE
if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE
if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE
if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE
if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE
if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE
if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE
if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE
DFP_SETROUND (FE_DEC_TONEARESTFROMZERO);
if (!do_d64_to_d32 (1.1111125dd, 1.111113df)) FAILURE
if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE
if (!do_d64_to_d32 (-1.1111125dd, -1.111113df)) FAILURE
if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE
if (!do_d128_to_d32 (1.1111125dl, 1.111113df)) FAILURE
if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE
if (!do_d128_to_d32 (-1.1111125dl, -1.111113df)) FAILURE
if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE
if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111113dd)) FAILURE
if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE
if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111113dd)) FAILURE
if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE
DFP_SETROUND (FE_DEC_TOWARDZERO);
if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE
if (!do_d64_to_d32 (1.1111135dd, 1.111113df)) FAILURE
if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE
if (!do_d64_to_d32 (-1.1111135dd, -1.111113df)) FAILURE
if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE
if (!do_d128_to_d32 (1.1111135dl, 1.111113df)) FAILURE
if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE
if (!do_d128_to_d32 (-1.1111135dl, -1.111113df)) FAILURE
if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE
if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111113dd)) FAILURE
if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE
if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111113dd)) FAILURE
DFP_SETROUND (FE_DEC_UPWARD);
if (!do_d64_to_d32 (1.1111125dd, 1.111113df)) FAILURE
if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE
if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE
if (!do_d64_to_d32 (-1.1111135dd, -1.111113df)) FAILURE
if (!do_d128_to_d32 (1.1111125dl, 1.111113df)) FAILURE
if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE
if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE
if (!do_d128_to_d32 (-1.1111135dl, -1.111113df)) FAILURE
if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111113dd)) FAILURE
if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE
if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE
if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111113dd)) FAILURE
if (failcnt)
abort ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* N1150 5.2 Conversions among decimal floating types and between
decimal floating types and generic floating types.
C99 6.3.1.5(3) New.
Test various conversions involving decimal floating types. */
#include <decfloat.h>
extern void abort (void);
volatile _Decimal32 d32;
volatile _Decimal64 d64;
volatile _Decimal128 d128;
int
main ()
{
/* Conversions to larger types. */
d32 = 123.4df;
d64 = d32;
if (d64 != 123.4dd)
abort ();
d128 = d32;
if (d128 != 123.4dl)
abort ();
d64 = 345.678dd;
d128 = d64;
if (d128 != 345.678dl)
abort ();
/* Conversions to smaller types for which the value fits. */
d64 = 3456.789dd;
d32 = d64;
if (d32 != 3456.789df)
abort ();
d128 = 123.4567dl;
d32 = d128;
if (d32 != 123.4567dl)
abort ();
d128 = 1234567890.123456dl;
d64 = d128;
if (d64 != 1234567890.123456dd)
abort ();
/* Test demotion to non-representable decimal floating type. */
/* Assumes a default rounding mode of 'near'. This uses the rules
describe in the 27 July 2005 draft of IEEE 754r, which are much
more clear that what's described in draft 5 of N1107. */
/* Rounds to what _Decimal32 can handle. */
d64 = 9.99999949E96DD;
d32 = d64;
if (d32 != DEC32_MAX)
abort();
/* Rounds to more than _Decimal32 can handle. */
d64 = 9.9999995E96DD;
d32 = d64;
if (d32 != __builtin_infd32())
abort();
/* Rounds to what _Decimal32 can handle. */
d128 = 9.99999949E96DD;
d32 = d128;
if (d32 != DEC32_MAX)
abort();
/* Rounds to more than _Decimal32 can handle. */
d128= 9.9999995E96DD;
d32 = d128;
if (d32 != __builtin_infd32())
abort();
/* Rounds to what _Decimal64 can handle. */
d128 = 9.99999999999999949E384DL;
d64 = d128;
if (d64 != DEC64_MAX)
abort();
/* Rounds to more than _Decimal64 can handle. */
d128 = 9.9999999999999995E384DL;
d64 = d128;
if (d64 != __builtin_infd64())
abort();
return 0;
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -O" } */
/* N1150 5.1 Conversion between decimal floating integer.
C99 6.3.1.4(1a) New.
These should all be folded at compile time. */
extern void link_error (void);
int
main ()
{
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
unsigned int ui;
unsigned long ul;
unsigned long long ull;
int si;
long sl;
long long sll;
_Bool b;
/* C99 Section 6.7.2 Type specifiers. Type _Bool is
mentioned in this section. Conversions between
_Bool and DFP types. */
/* Decimal float to unsigned integer. */
d32 = 456.789df;
d64 = 23.456789dd;
d128 = 1234.5678dl;
ui = d32;
if (ui != 456U)
link_error ();
ul = d32;
if (ul != 456UL)
link_error ();
ull = d32;
if (ull != 456ULL)
link_error ();
ui = d64;
if (ui != 23U)
link_error ();
ul = d64;
if (ul != 23UL)
link_error ();
ull = d64;
if (ull != 23ULL)
link_error ();
ui = d128;
if (ui != 1234U)
link_error ();
ul = d128;
if (ul != 1234UL)
link_error ();
ull = d128;
if (ull != 1234ULL)
link_error ();
/* Decimal float to signed integer. */
/* Decimal float to _Bool. */
d32 = 1.23df;
d64 = -3.4dd;
d128 = 0.00003dl;
b = d32;
if (!b)
link_error ();
b = d64;
if (!b)
link_error ();
b = d128;
if (!b)
link_error ();
/* Unsigned integer to decimal float. */
ui = 987U;
ul = 345678UL;
ull = 1234567ULL;
d32 = ui;
if (d32 != 987.0df)
link_error ();
d32 = ul;
if (d32 != 345678.0df)
link_error ();
d32 = ull;
if (d32 != 1234567.df)
link_error ();
d64 = ui;
if (d64 != 987.0dd)
link_error ();
d64 = ul;
if (d64 != 345678.0dd)
link_error ();
d64 = ull;
if (d64 != 1234567.dd)
link_error ();
d128 = ui;
if (d128 != 987.0dl)
link_error ();
d128 = ul;
if (d128 != 345678.0dl)
link_error ();
d128 = ull;
if (d128 != 1234567.dl)
link_error ();
/* Signed integer to decimal float. */
si = -987;
sl = -345678;
sll = -1234567;
d32 = si;
if (d32 != -987.0df)
link_error ();
d32 = sl;
if (d32 != -345678.0df)
link_error ();
d32 = sll;
if (d32 != -1234567.df)
link_error ();
d64 = si;
if (d64 != -987.0dd)
link_error ();
d64 = sl;
if (d64 != -345678.0dd)
link_error ();
d64 = sll;
if (d64 != -1234567.dd)
link_error ();
d128 = si;
if (d128 != -987.0dl)
link_error ();
d128 = sl;
if (d128 != -345678.0dl)
link_error ();
d128 = sll;
if (d128 != -1234567.dl)
link_error ();
/* _Bool to decimal float. */
d32 = 0.0DF;
d64 = 0.0DD;
d128 = 0.0DL;
b = d32;
if (b)
link_error ();
b = d64;
if (b)
link_error ();
b = d128;
if (b)
link_error ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* N1150 5.1 Conversion between decimal floating integer.
C99 6.3.1.4(1a) New.
Test integer saturation. */
#include <decfloat.h>
#include <limits.h>
extern void abort (void);
volatile _Decimal32 d32;
volatile _Decimal64 d64;
volatile _Decimal128 d128;
volatile signed int si;
volatile unsigned int usi;
volatile unsigned long long udi;
int
main ()
{
/* Unsigned. */
usi = DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
if (usi != UINT_MAX)
abort ();
usi = DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
if (usi != UINT_MAX)
abort ();
usi = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
if (usi != UINT_MAX)
abort ();
/* Signed. */
si = DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
if (si != INT_MAX)
abort ();
si = DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
if (si != INT_MAX)
abort ();
si = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
if (si != INT_MAX)
abort ();
si = - DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
if (si != INT_MIN)
abort ();
si = - DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
if (si != INT_MIN)
abort ();
si = - DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
if (si != INT_MIN)
abort ();
return 0;
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -O0" } */
/* N1150 5.1 Conversion between decimal floating integer.
C99 6.3.1.4(1a) New. */
extern void abort (void);
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
unsigned int ui;
unsigned long ul;
unsigned long long ull;
int si;
long sl;
long long sll;
_Bool b;
void
init_dfp_1 (void)
{
d32 = 456.789df;
d64 = 23.456789dd;
d128 = 1234.5678dl;
}
void
init_dfp_2 (void)
{
d32 = 1.23df;
d64 = -3.4dd;
d128 = 0.00003dl;
}
void
init_dfp_3 (void)
{
d32 = 0.0DF;
d64 = 0.0DD;
d128 = 0.0DL;
}
void
init_unsigned_int (void)
{
ui = 987U;
ul = 345678UL;
ull = 1234567ULL;
}
void
init_signed_int (void)
{
si = -987;
sl = -345678;
sll = -1234567;
}
int
main ()
{
/* C99 Section 6.7.2 Type specifiers. Type _Bool is
mentioned in this section. Conversions between
_Bool and DFP types. */
/* Decimal float to unsigned integer. */
init_dfp_1 ();
ui = d32;
if (ui != 456U)
abort ();
ul = d32;
if (ul != 456UL)
abort ();
ull = d32;
if (ull != 456ULL)
abort ();
ui = d64;
if (ui != 23U)
abort ();
ul = d64;
if (ul != 23UL)
abort ();
ull = d64;
if (ull != 23ULL)
abort ();
ui = d128;
if (ui != 1234U)
abort ();
ul = d128;
if (ul != 1234UL)
abort ();
ull = d128;
if (ull != 1234ULL)
abort ();
/* Decimal float to signed integer. */
/* Decimal float to _Bool. */
init_dfp_2 ();
b = d32;
if (!b)
abort ();
b = d64;
if (!b)
abort ();
b = d128;
if (!b)
abort ();
/* Unsigned integer to decimal float. */
init_unsigned_int ();
d32 = ui;
if (d32 != 987.0df)
abort ();
d32 = ul;
if (d32 != 345678.0df)
abort ();
d32 = ull;
if (d32 != 1234567.df)
abort ();
d64 = ui;
if (d64 != 987.0dd)
abort ();
d64 = ul;
if (d64 != 345678.0dd)
abort ();
d64 = ull;
if (d64 != 1234567.dd)
abort ();
d128 = ui;
if (d128 != 987.0dl)
abort ();
d128 = ul;
if (d128 != 345678.0dl)
abort ();
d128 = ull;
if (d128 != 1234567.dl)
abort ();
/* Signed integer to decimal float. */
init_signed_int ();
d32 = si;
if (d32 != -987.0df)
abort ();
d32 = sl;
if (d32 != -345678.0df)
abort ();
d32 = sll;
if (d32 != -1234567.df)
abort ();
d64 = si;
if (d64 != -987.0dd)
abort ();
d64 = sl;
if (d64 != -345678.0dd)
abort ();
d64 = sll;
if (d64 != -1234567.dd)
abort ();
d128 = si;
if (d128 != -987.0dl)
abort ();
d128 = sl;
if (d128 != -345678.0dl)
abort ();
d128 = sll;
if (d128 != -1234567.dl)
abort ();
/* _Bool to decimal float. */
init_dfp_3 ();
b = d32;
if (b)
abort ();
b = d64;
if (b)
abort ();
b = d128;
if (b)
abort ();
return 0;
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
/* N1150 3: Decimal floating types.
C99 6.7.2: Type specifiers */
/* Test for the existence of the types. */
_Decimal32 sd1;
_Decimal64 dd2;
_Decimal128 td3;
#define ARRAY_SIZE 7
static _Decimal32 d32[ARRAY_SIZE];
static _Decimal64 d64[ARRAY_SIZE];
static _Decimal128 d128[ARRAY_SIZE];
extern _Decimal32 ext_d32[ARRAY_SIZE];
extern _Decimal64 ext_d64[ARRAY_SIZE];
extern _Decimal128 ext_d128[ARRAY_SIZE];
/* Test sizes for these types. */
int ssize[sizeof (_Decimal32) == 4 ? 1 : -1];
int dsize[sizeof (_Decimal64) == 8 ? 1 : -1];
int tsize[sizeof (_Decimal128) == 16 ? 1 : -1];
int salign = __alignof (_Decimal32);
int dalign = __alignof (_Decimal64);
int talign = __alignof (_Decimal128);
/* sizeof operator applied on an array of DFP types is n times the
size of a single variable of this type. */
int d32_array_size [sizeof(d32) == ARRAY_SIZE * sizeof(sd1) ? 1 : -1];
int d64_array_size [sizeof(d64) == ARRAY_SIZE * sizeof(dd2) ? 1 : -1];
int d128_array_size [sizeof(d128) == ARRAY_SIZE * sizeof(td3)? 1 : -1];
/* Likewise for extern qualified arrays. */
int ext_d32_array_size [sizeof(ext_d32) == ARRAY_SIZE * sizeof(sd1) ? 1 : -1];
int ext_d64_array_size [sizeof(ext_d64) == ARRAY_SIZE * sizeof(dd2) ? 1 : -1];
int ext_d128_array_size [sizeof(ext_d128) == ARRAY_SIZE * sizeof(td3)? 1 : -1];
void f()
{
_Decimal32 d32[ARRAY_SIZE];
_Decimal64 d64[ARRAY_SIZE];
_Decimal128 d128[ARRAY_SIZE];
int d32_array_size [sizeof(d32) == ARRAY_SIZE * sizeof(_Decimal32) ? 1 : -1];
int d64_array_size [sizeof(d64) == ARRAY_SIZE * sizeof(_Decimal64) ? 1 : -1];
int d128_array_size [sizeof(d128) == ARRAY_SIZE * sizeof(_Decimal128)? 1 : -1];
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
/* N1107 4: Characteristics of decimal floating types <decfloat.h>.
C99 5.2.4.2.2a[2] (New).
Verify that __DEC_EVAL_METHOD__ is defined; it will be used to define
DEC_EVAL_METHOD in <decfloat.h>. */
int i;
#ifndef __DEC_EVAL_METHOD__
#error __DEC_EVAL_METHOD__ is not defined
#endif
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
/* N1150 4: Characteristics of decimal floating types <decfloat.h>.
C99 5.2.4.2.2a[3]: New.
Verify constants about range of decimal float and three components of
decimal float defined in decfloat.h. */
/* Make sure we are exporting the right values to decfloat.h. */
#include <decfloat.h>
extern void abort (void);
int main ()
{
if (DEC32_MANT_DIG != 7) abort();
if (DEC64_MANT_DIG != 16) abort();
if (DEC128_MANT_DIG != 34) abort();
if (DEC32_MIN_EXP != -95) abort();
if (DEC64_MIN_EXP != -383) abort();
if (DEC128_MIN_EXP != -6143) abort();
if (DEC32_MAX_EXP != 96) abort();
if (DEC64_MAX_EXP != 384) abort();
if (DEC128_MAX_EXP != 6144) abort();
if (DEC32_MAX != 9.999999E96DF) abort();
if (DEC64_MAX != 9.999999999999999E384DD) abort();
if (DEC128_MAX != 9.999999999999999999999999999999999E6144DL) abort();
if (DEC32_EPSILON != 1E-6DF) abort();
if (DEC64_EPSILON != 1E-15DD) abort();
if (DEC128_EPSILON != 1E-33DL) abort();
if (DEC32_MIN != 1E-95DF) abort();
if (DEC32_MIN != 1E-383DD) abort();
if (DEC128_MIN != 1E-6143DL) abort();
if (DEC32_DEN != 0.000001E-95DF) abort();
if (DEC64_DEN != 0.000000000000001E-383DD) abort();
if (DEC128_DEN != 0.000000000000000000000000000000001E-6143DL) abort();
return 0;
}
/* This is very temporary; right now it gets functions in libgcc that
pass on the rounding mode to decNumber, but later it can be replaced
with Official Stuff. */
#define FE_DEC_DOWNWARD 0
#define FE_DEC_TONEAREST 1
#define FE_DEC_TONEARESTFROMZERO 2
#define FE_DEC_TOWARDZERO 3
#define FE_DEC_UPWARD 4
extern void __dfp_set_round (int);
#define DFP_SETROUND(M) __dfp_set_round(M)
extern int __dfp_get_round (void);
#define DFP_GETROUND __dfp_get_round()
# Copyright (C) 2005 Free Software Foundation, Inc.
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# GCC testsuite that uses the `dg.exp' driver.
# Load support procs.
load_lib gcc-dg.exp
# Skip these tests for targets that don't support this extension.
if { ![check_effective_target_dfp] } {
return;
}
# If a testcase doesn't have special options, use these.
global DEFAULT_CFLAGS
if ![info exists DEFAULT_CFLAGS] then {
set DEFAULT_CFLAGS " -ansi -pedantic-errors"
}
# Initialize `dg'.
dg-init
# Main loop.
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
"" $DEFAULT_CFLAGS
# All done.
dg-finish
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.2.2 Function calls.
Test passing array elements involving decimal floating point types. */
extern void abort (void);
/* A handful of functions that return the Nth _Decimal32 argument of
an incoming array. */
_Decimal32
arg0_32 (_Decimal32 args[])
{
return args[0];
}
_Decimal32
arg1_32 (_Decimal32 args[])
{
return args[1];
}
_Decimal32
arg2_32 (_Decimal32 args[])
{
return args[2];
}
_Decimal32
arg3_32 (_Decimal32 args[])
{
return args[3];
}
_Decimal32
arg4_32 (_Decimal32 args[])
{
return args[4];
}
_Decimal32
arg5_32 (_Decimal32 args[])
{
return args[5];
}
/* A handful of functions that return the Nth _Decimal64 argument of
an incoming array. */
_Decimal64
arg0_64 (_Decimal64 args[])
{
return args[0];
}
_Decimal64
arg1_64 (_Decimal64 args[])
{
return args[1];
}
_Decimal64
arg2_64 (_Decimal64 args[])
{
return args[2];
}
_Decimal64
arg3_64 (_Decimal64 args[])
{
return args[3];
}
_Decimal64
arg4_64 (_Decimal64 args[])
{
return args[4];
}
_Decimal64
arg5_64 (_Decimal64 args[])
{
return args[5];
}
/* A handful of functions that return the Nth _Decimal128 argument of
an incoming array. */
_Decimal128
arg0_128 (_Decimal128 args[])
{
return args[0];
}
_Decimal128
arg1_128 (_Decimal128 args[])
{
return args[1];
}
_Decimal128
arg2_128 (_Decimal128 args[])
{
return args[2];
}
_Decimal128
arg3_128 (_Decimal128 args[])
{
return args[3];
}
_Decimal128
arg4_128 (_Decimal128 args[])
{
return args[4];
}
_Decimal128
arg5_128 (_Decimal128 args[])
{
return args[5];
}
int main()
{
_Decimal32 d32[] = { 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df };
_Decimal64 d64[] = { 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd };
_Decimal128 d128[] = { 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl };
/* _Decimal32 variants. */
if (arg0_32 (d32) != 0.0df) abort ();
if (arg1_32 (d32) != 1.0df) abort ();
if (arg2_32 (d32) != 2.0df) abort ();
if (arg3_32 (d32) != 3.0df) abort ();
if (arg4_32 (d32) != 4.0df) abort ();
if (arg5_32 (d32) != 5.0df) abort ();
/* _Decimal64 variants. */
if (arg0_64 (d64) != 0.0dd) abort ();
if (arg1_64 (d64) != 1.0dd) abort ();
if (arg2_64 (d64) != 2.0dd) abort ();
if (arg3_64 (d64) != 3.0dd) abort ();
if (arg4_64 (d64) != 4.0dd) abort ();
if (arg5_64 (d64) != 5.0dd) abort ();
/* _Decimal128 variants. */
if (arg0_128 (d128) != 0.0dl) abort ();
if (arg1_128 (d128) != 1.0dl) abort ();
if (arg2_128 (d128) != 2.0dl) abort ();
if (arg3_128 (d128) != 3.0dl) abort ();
if (arg4_128 (d128) != 4.0dl) abort ();
if (arg5_128 (d128) != 5.0dl) abort ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -Wall" } */
/* C99 6.5.2.2 Function calls.
Test scalar passing and return values involving decimal floating
point types. */
extern void abort (void);
/* A handful of functions that return their Nth _Decimal32
argument with mixed types in parameter list. */
_Decimal32
arg0_32 (_Decimal32 arg0, int arg1, unsigned int arg2,
float arg3, double arg4, long double arg5)
{
return arg0;
}
_Decimal32
arg1_32 (int arg0, _Decimal32 arg1, unsigned int arg2,
float arg3, double arg4, long double arg5)
{
return arg1;
}
_Decimal32
arg2_32 (int arg0, unsigned int arg1, _Decimal32 arg2,
float arg3, double arg4, long double arg5)
{
return arg2;
}
_Decimal32
arg3_32 (int arg0, unsigned int arg1, float arg2,
_Decimal32 arg3, double arg4, long double arg5)
{
return arg3;
}
_Decimal32
arg4_32 (int arg0, unsigned int arg1, float arg2,
double arg3, _Decimal32 arg4, long double arg5)
{
return arg4;
}
_Decimal32
arg5_32 (int arg0, unsigned int arg1, float arg2,
double arg3, long double arg4, _Decimal32 arg5)
{
return arg5;
}
/* A handful of functions that return their Nth _Decimal64
argument with mixed types in parameter list. */
_Decimal64
arg0_64 (_Decimal64 arg0, int arg1, unsigned int arg2,
float arg3, double arg4, long double arg5)
{
return arg0;
}
_Decimal64
arg1_64 (int arg0, _Decimal64 arg1, unsigned int arg2,
float arg3, double arg4, long double arg5)
{
return arg1;
}
_Decimal64
arg2_64 (int arg0, unsigned int arg1, _Decimal64 arg2,
float arg3, double arg4, long double arg5)
{
return arg2;
}
_Decimal64
arg3_64 (int arg0, unsigned int arg1, float arg2,
_Decimal64 arg3, double arg4, long double arg5)
{
return arg3;
}
_Decimal64
arg4_64 (int arg0, unsigned int arg1, float arg2,
float arg3, _Decimal64 arg4, long double arg5)
{
return arg4;
}
_Decimal64
arg5_64 (int arg0, unsigned int arg1, float arg2,
double arg3, long double arg4, _Decimal64 arg5)
{
return arg5;
}
/* A handful of functions that return their Nth _Decimal128
argument with mixed types in parameter list. */
_Decimal128
arg0_128 (_Decimal128 arg0, int arg1, unsigned int arg2,
float arg3, double arg4, long double arg5)
{
return arg0;
}
_Decimal32
arg1_128 (int arg0, _Decimal128 arg1, unsigned int arg2,
float arg3, double arg4, long double arg5)
{
return arg1;
}
_Decimal128
arg2_128 (int arg0, unsigned int arg1, _Decimal128 arg2,
float arg3, double arg4, long double arg5)
{
return arg2;
}
_Decimal128
arg3_128 (int arg0, unsigned int arg1, float arg2,
_Decimal128 arg3, double arg4, long double arg5)
{
return arg3;
}
_Decimal128
arg4_128 (int arg0, unsigned int arg1, float arg2,
float arg3, _Decimal32 arg4, long double arg5)
{
return arg4;
}
_Decimal128
arg5_128 (int arg0, unsigned int arg1, float arg2,
double arg3, long double arg4, _Decimal128 arg5)
{
return arg5;
}
int
main ()
{
/* _Decimal32 variants. */
if (arg0_32 (0.0df, -1, 2, 3.0f, 4.0, 5.0ld) != 0.0df) abort ();
if (arg1_32 (0, 1.0df, 2, 3.0f, 4.0, 5.0ld) != 1.0df) abort ();
if (arg2_32 (0, -1, 2.0df, 3.0f, 4.0, 5.0ld) != 2.0df) abort ();
if (arg3_32 (0, -1, 2.0f, 3.0df, 4.0, 5.0ld) != 3.0df) abort ();
if (arg4_32 (0, -1, 2.0f, 3.0, 4.0df, 5.0ld) != 4.0df) abort ();
if (arg5_32 (0, -1, 2.0f, 3.0, 4.0ld, 5.0df) != 5.0df) abort ();
/* _Decimal64 variants. */
if (arg0_64 (0.0dd, -1, 2, 3.0f, 4.0, 5.0ld) != 0.0dd) abort ();
if (arg1_64 (0, 1.0dd, 2, 3.0f, 4.0, 5.0ld) != 1.0dd) abort ();
if (arg2_64 (0, -1, 2.0dd, 3.0f, 4.0, 5.0ld) != 2.0dd) abort ();
if (arg3_64 (0, -1, 2.0f, 3.0dd, 4.0, 5.0ld) != 3.0dd) abort ();
if (arg4_64 (0, -1, 2.0f, 3.0, 4.0dd, 5.0ld) != 4.0dd) abort ();
if (arg5_64 (0, -1, 2.0f, 3.0, 4.0ld, 5.0dd) != 5.0dd) abort ();
/* _Decimal128 variants. */
if (arg0_128 (0.0dl, -1, 2, 3.0f, 4.0, 5.0ld) != 0.0dl) abort ();
if (arg1_128 (0, 1.0dl, 2, 3.0f, 4.0, 5.0ld) != 1.0dl) abort ();
if (arg2_128 (0, -1, 2.0dl, 3.0f, 4.0, 5.0ld) != 2.0dl) abort ();
if (arg3_128 (0, -1, 2.0f, 3.0dl, 4.0, 5.0ld) != 3.0dl) abort ();
if (arg4_128 (0, -1, 2.0f, 3.0, 4.0dl, 5.0ld) != 4.0dl) abort ();
if (arg5_128 (0, -1, 2.0f, 3.0, 4.0ld, 5.0dl) != 5.0dl) abort ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.2.2 Function calls.
Test scalar passing and return values involving decimal floating
point types. */
extern void abort (void);
/* A handful of functions that return their Nth _Decimal32
argument. */
_Decimal32
arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
_Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
{
return arg0;
}
_Decimal32
arg1_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
_Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
{
return arg1;
}
_Decimal32
arg2_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
_Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
{
return arg2;
}
_Decimal32
arg3_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
_Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
{
return arg3;
}
_Decimal32
arg4_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
_Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
{
return arg4;
}
_Decimal32
arg5_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2,
_Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5)
{
return arg5;
}
/* A handful of functions that return their Nth _Decimal64
argument. */
_Decimal64
arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
_Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
{
return arg0;
}
_Decimal64
arg1_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
_Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
{
return arg1;
}
_Decimal64
arg2_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
_Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
{
return arg2;
}
_Decimal64
arg3_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
_Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
{
return arg3;
}
_Decimal64
arg4_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
_Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
{
return arg4;
}
_Decimal64
arg5_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2,
_Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5)
{
return arg5;
}
/* A handful of functions that return their Nth _Decimal128
argument. */
_Decimal128
arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
_Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
{
return arg0;
}
_Decimal128
arg1_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
_Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
{
return arg1;
}
_Decimal128
arg2_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
_Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
{
return arg2;
}
_Decimal128
arg3_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
_Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
{
return arg3;
}
_Decimal128
arg4_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
_Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
{
return arg4;
}
_Decimal128
arg5_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2,
_Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5)
{
return arg5;
}
int
main ()
{
/* _Decimal32 variants. */
if (arg0_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 0.0df)
abort ();
if (arg1_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 1.0df)
abort ();
if (arg2_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 2.0df)
abort ();
if (arg3_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 3.0df)
abort ();
if (arg4_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 4.0df)
abort ();
if (arg5_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 5.0df)
abort ();
/* _Decimal64 variants. */
if (arg0_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 0.0dd)
abort ();
if (arg1_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 1.0dd)
abort ();
if (arg2_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 2.0dd)
abort ();
if (arg3_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 3.0dd)
abort ();
if (arg4_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 4.0dd)
abort ();
if (arg5_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 5.0dd)
abort ();
/* _Decimal128 variants. */
if (arg0_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 0.0dl)
abort ();
if (arg1_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 1.0dl)
abort ();
if (arg2_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 2.0dl)
abort ();
if (arg3_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 3.0dl)
abort ();
if (arg4_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 4.0dl)
abort ();
if (arg5_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 5.0dl)
abort ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.2.2 Function calls.
Test structure passing and return values involving decimal floating
point types. */
extern void abort (void);
struct example
{
_Decimal128 d128;
char dummy1;
_Decimal64 d64;
char dummy2;
_Decimal32 d32;
} nums = { 1.0dl, 'a', 2.0dd, 'b', 3.0df };
_Decimal32
d32_field (struct example s)
{
return s.d32;
}
_Decimal64
d64_field (struct example s)
{
return s.d64;
}
_Decimal128
d128_field (struct example s)
{
return s.d128;
}
char
dummy1_field (struct example s)
{
return s.dummy1;
}
char
dummy2_field (struct example s)
{
return s.dummy2;
}
_Decimal32
ptr_d32_field (struct example *s)
{
return s->d32;
}
_Decimal64
ptr_d64_field (struct example *s)
{
return s->d64;
}
_Decimal128
ptr_d128_field (struct example *s)
{
return s->d128;
}
char
ptr_dummy1_field (struct example *s)
{
return s->dummy1;
}
char
ptr_dummy2_field (struct example *s)
{
return s->dummy2;
}
int
main ()
{
if (d32_field (nums) != 3.0df) abort ();
if (d64_field (nums) != 2.0dd) abort ();
if (d128_field (nums) != 1.0dl) abort ();
if (dummy1_field (nums) != 'a') abort ();
if (dummy2_field (nums) != 'b') abort ();
if (ptr_d32_field (&nums) != 3.0df) abort ();
if (ptr_d64_field (&nums) != 2.0dd) abort ();
if (ptr_d128_field (&nums) != 1.0dl) abort ();
if (ptr_dummy1_field (&nums) != 'a') abort ();
if (ptr_dummy2_field (&nums) != 'b') abort ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.2.2 Function calls.
Test passing varargs of the decimal float types. */
#include <stdarg.h>
extern void abort (void);
static _Decimal32
vararg32 (unsigned arg, ...)
{
int i;
va_list ap;
_Decimal32 result;
va_start (ap, arg);
for (i = 0; i <= arg; i++)
result = va_arg (ap, _Decimal32);
va_end (ap);
return result;
}
static _Decimal64
vararg64 (unsigned arg, ...)
{
int i;
va_list ap;
_Decimal64 result;
va_start (ap, arg);
for (i = 0; i <= arg; i++)
result = va_arg (ap, _Decimal64);
va_end (ap);
return result;
}
static _Decimal128
vararg128 (unsigned arg, ...)
{
int i;
va_list ap;
_Decimal128 result;
va_start (ap, arg);
for (i = 0; i <= arg; i++)
result = va_arg (ap, _Decimal128);
va_end (ap);
return result;
}
int main()
{
/* _Decimal32 variants. */
if (vararg32 (0, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 0.0df)
abort ();
if (vararg32 (1, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 1.0df)
abort ();
if (vararg32 (2, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 2.0df)
abort ();
if (vararg32 (3, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 3.0df)
abort ();
if (vararg32 (4, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 4.0df)
abort ();
if (vararg32 (5, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 5.0df)
abort ();
/* _Decimal64 variants. */
if (vararg64 (0, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 0.0dd)
abort ();
if (vararg64 (1, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 1.0dd)
abort ();
if (vararg64 (2, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 2.0dd)
abort ();
if (vararg64 (3, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 3.0dd)
abort ();
if (vararg64 (4, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 4.0dd)
abort ();
if (vararg64 (5, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 5.0dd)
abort ();
/* _Decimal128 variants. */
if (vararg128 (0, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 0.0dl)
abort ();
if (vararg128 (1, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 1.0dl)
abort ();
if (vararg128 (2, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 2.0dl)
abort ();
if (vararg128 (3, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 3.0dl)
abort ();
if (vararg128 (4, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 4.0dl)
abort ();
if (vararg128 (5, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 5.0dl)
abort ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.2.2 Function calls.
Test passing varargs of the combination of decimal float types and
other types. */
#include <stdarg.h>
extern void abort (void);
/* Supposing the list of varying number of arguments is:
unsigned int, _Decimal128, double, _Decimal32, _Decimal64. */
static _Decimal32
vararg_d32 (unsigned arg, ...)
{
va_list ap;
_Decimal32 result;
va_start (ap, arg);
va_arg (ap, unsigned int);
va_arg (ap, _Decimal128);
va_arg (ap, double);
result = va_arg (ap, _Decimal32);
va_end (ap);
return result;
}
static _Decimal32
vararg_d64 (unsigned arg, ...)
{
va_list ap;
_Decimal64 result;
va_start (ap, arg);
va_arg (ap, unsigned int);
va_arg (ap, _Decimal128);
va_arg (ap, double);
va_arg (ap, _Decimal32);
result = va_arg (ap, _Decimal64);
va_end (ap);
return result;
}
static _Decimal128
vararg_d128 (unsigned arg, ...)
{
va_list ap;
_Decimal128 result;
va_start (ap, arg);
va_arg (ap, unsigned int);
result = va_arg (ap, _Decimal128);
va_end (ap);
return result;
}
static unsigned int
vararg_int (unsigned arg, ...)
{
va_list ap;
unsigned int result;
va_start (ap, arg);
result = va_arg (ap, unsigned int);
va_end (ap);
return result;
}
static double
vararg_double (unsigned arg, ...)
{
va_list ap;
float result;
va_start (ap, arg);
va_arg (ap, unsigned int);
va_arg (ap, _Decimal128);
result = va_arg (ap, double);
va_end (ap);
return result;
}
int
main ()
{
if (vararg_d32 (3, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 3.0df) abort ();
if (vararg_d64 (4, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 4.0dd) abort ();
if (vararg_d128 (1, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 1.0dl) abort ();
if (vararg_int (0, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 0) abort ();
if (vararg_double (2, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 2.0) abort ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.2.2 Function calls. */
#include <stdarg.h>
extern void abort (void);
struct S1
{
struct
{
_Decimal64 e;
} b[0];
};
/* Test handling vararg parameters whose size is 0. */
int check_var(int z,...)
{
double d;
struct S1 s1;
long long result;
va_list ap;
va_start (ap, z);
d = va_arg (ap, double);
s1 = va_arg (ap, struct S1);
result = va_arg (ap, long long);
va_end (ap);
return (result == 2LL);
}
int
main ()
{
struct S1 s1;
struct S1 a1[5];
if (check_var(5, 1.0, s1, 2LL, a1[2], a1[2]) == 0)
abort ();
return 0;
}
/* { dg-do compile } */
/* { dg-options "-std=c89" } */
/* Decimal float keywords are not recognized in C89 mode. */
_Decimal32 x; /* { dg-error "error" } */
_Decimal64 y; /* { dg-error "error" } */
_Decimal128 z; /* { dg-error "error" } */
/* { dg-do compile } */
/* { dg-options "-std=c99" } */
/* Decimal float keywords are not recognized in C99 mode. */
_Decimal32 x; /* { dg-error "error" } */
_Decimal64 y; /* { dg-error "error" } */
_Decimal128 z; /* { dg-error "error" } */
/* { dg-do compile } */
/* { dg-options "-std=c99" } */
/* Decimal float keywords are not reserved for c99. */
int _Decimal32 (void)
{
return 0;
}
int foo (int i)
{
int _Decimal64 = i * 2;
return _Decimal64;
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -pedantic" } */
/* Decimal float is a GCC extension. */
_Decimal32 x; /* { dg-warning "GCC extension|ISO C" } */
_Decimal64 y; /* { dg-warning "GCC extension|ISO C" } */
_Decimal128 z; /* { dg-warning "GCC extension|ISO C" } */
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
/* N1150 3: Decimal floating types.
C99 6.4.1(2): Keywords.
Decimal float keywords cannot be used in other contexts. */
int _Decimal32 (void) /* { dg-error "error" } */
{
return 0;
}
int foo (int i)
{
int _Decimal64 = i * 2; /* { dg-error "error" } */
return _Decimal64; /* { dg-error "error" } */
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.8.5.2: The for statement. */
#include <stdio.h>
#include <stdlib.h>
void
f32 (void)
{
_Decimal32 d;
int i;
for (d = 1.1df, i=0; d <= 1.5df; d += 0.1df)
i++;
if (i != 5)
abort();
}
void
f64 (void)
{
_Decimal64 d;
int i;
for (d = 1.1dd, i=0; d <= 1.5dd; d += 0.1dd)
i++;
if (i != 5)
abort();
}
void
f128 (void)
{
_Decimal128 d;
int i;
for (d = 1.1dl, i=0; d <= 1.5dl; d += 0.1dl)
i++;
if (i != 5)
abort();
}
int
main ()
{
int i;
f32 ();
f64 ();
f128 ();
return (0);
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
typedef float decimal32 __attribute__ ((mode (SD)));
typedef float decimal64 __attribute__ ((mode (DD)));
typedef float decimal128 __attribute__ ((mode (TD)));
int ssize[sizeof (decimal32) == 4 ? 1 : -1];
int dsize[sizeof (decimal64) == 8 ? 1 : -1];
int tsize[sizeof (decimal128) == 16 ? 1 : -1];
int salign = __alignof (decimal32);
int dalign = __alignof (decimal64);
int talign = __alignof (decimal128);
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* N1150 4: Characteristics of decimal floating types (not explicit)
C99 5.2.4.2.2: Characteristics of floating types.
A few simple checks on arithmetic operations. */
extern void abort (void);
int main()
{
/* Some possibly non-obvious tests, but most logical
operations on NaN return false, including NaN == NaN. */
if (__builtin_nand32("") == __builtin_nand32(""))
abort();
if (__builtin_nand64("") == __builtin_nand64(""))
abort();
if (__builtin_nand128("") == __builtin_nand128(""))
abort();
if (!(__builtin_nand32("") != __builtin_nand32("")))
abort();
if (!(__builtin_nand64("") != __builtin_nand64("")))
abort();
if (!(__builtin_nand128("") != __builtin_nand128("")))
abort();
if (__builtin_nand32("") > __builtin_nand32(""))
abort();
if (__builtin_nand64("") >= __builtin_nand64(""))
abort();
if (__builtin_nand128("") < __builtin_nand128(""))
abort();
if (-__builtin_nand128("") < +__builtin_nand128(""))
abort();
/* 0.0/0.0 => NaN, but NaN != NaN. */
if (0.0df/0.0dl == __builtin_nand32(""))
abort();
/* 0.0 * INF => NaN. */
if (!__builtin_isnand32 (0.0df * __builtin_infd32()))
abort ();
if (!__builtin_isnand64 (0.0dd * __builtin_infd64()))
abort ();
if (!__builtin_isnand128 (0.0dd * __builtin_infd128()))
abort ();
/* INF - INF => NaN. */
if (!__builtin_isnand32 (__builtin_infd32() - __builtin_infd32()))
abort ();
if (!__builtin_isnand64 (__builtin_infd64() - __builtin_infd64()))
abort ();
if (!__builtin_isnand128 (__builtin_infd128() - __builtin_infd128()))
abort ();
/* INF/INF => NaN. */
if (!__builtin_isnand32 (__builtin_infd32()/__builtin_infd32()) )
abort ();
if (!__builtin_isnand64 (__builtin_infd64()/__builtin_infd64()) )
abort ();
if (!__builtin_isnand128 (__builtin_infd128()/__builtin_infd128()) )
abort ();
/* 0.0/0.0 => NaN, but NaN != NaN. */
if ((0.0dd/0.0df) == (0.0dd/0.0df))
abort();
if (__builtin_nand32("") < __builtin_infd32())
abort();
if (__builtin_nand32("") >= __builtin_infd32())
abort();
/* Fixme: Add sqrtdf(-x.df) test when sqrt is supported. */
if (!__builtin_isnand32(__builtin_nand32("")))
abort();
if (!__builtin_isnand64(__builtin_nand64("")))
abort();
if (!__builtin_isnand128(__builtin_nand128("")))
abort();
if (!__builtin_isnand128(8.0df * __builtin_nand128("")))
abort();
if (!__builtin_isnand32(8.1dl - __builtin_nand32("")))
abort();
if (!__builtin_isnand128(__builtin_nand64("") + __builtin_nand128("")))
abort();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* N1150 4: Characteristics of decimal floating types (not explicit)
C99 5.2.4.2.2: Characteristics of floating types.
A few simple checks on arithmetic operations. Based on nan-1.c with
the consideration of negative zero. */
extern void abort (void);
int main()
{
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
/* Verify that division by negative zero produces a negative infinity
result. */
d32 = 123.45f;
if (d32/-0.0df != -__builtin_infd32())
abort();
if (123.45df/-0.0df != -__builtin_infd32())
abort();
d64 = 123.45f;
if (d64/-0.0dd != -__builtin_infd64())
abort();
if (123.45dd/-0.0dd != -__builtin_infd64())
abort();
d128 = 123.45f;
if (d128/-0.0dl != -__builtin_infd64())
abort();
if (123.45dl/-0.0dl != -__builtin_infd128())
abort();
d32 = 0.0df;
if (!__builtin_isnand32(-(d32/-0.0df)))
abort();
if (!__builtin_isnand32(-(0.0df/-0.0df)))
abort();
d64 = 0.0dd;
if (!__builtin_isnand64(-(d64/-0.0dd)))
abort();
if (!__builtin_isnand64(-(0.0dd/-0.0dd)))
abort();
d128 = 0.0dl;
if (!__builtin_isnand128(-(d128/-0.0dl)))
abort();
if (!__builtin_isnand128(-(0.0dl/-0.0dl)))
abort();
return 0;
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -O" } */
/* C99 6.5.5: Multiplicative operators.
C99 6.5.6: Additive operators. */
extern void link_error (void);
int
main ()
{
_Decimal32 d32_1, d32_2;
/* Compare like-typed positive constants. */
if (2.99df + 5.1df != 8.09df)
link_error ();
if (5.77df - 2.22dd != 3.55df)
link_error ();
if (2.0dl * 3.7dd * -2 != -14.8df)
link_error ();
if (.18df / -.2df + 1 != 1.e-1dd)
link_error ();
d32_1 = 3.0df;
d32_2 = 1.0df;
if (!__builtin_constant_p (d32_1 + 0.2df))
link_error ();
if (!__builtin_constant_p (1.0df / 3.0df))
link_error ();
if (!__builtin_constant_p (d32_2 / d32_1))
link_error ();
d32_2 = 2.0df;
if (!__builtin_constant_p (d32_2 / d32_1))
link_error ();
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.16 Assignment operators.
Verify the compound assignment operator for decimal float types,
using it with other decimal float types, integers, and other binary
float types cast to decimal float types. */
extern void abort (void);
#define OPERATE(OPRD1,OPRT,OPRD2,RLT) \
if (( OPRD1 OPRT OPRD2 )!= RLT) \
abort ();
#define DECIMAL_COMPOUND_ASSIGNMENT(TYPE, OPRD) \
{ \
_Decimal##TYPE d = OPRD; \
OPERATE(d,+=,1,(OPRD + 1)); \
d = OPRD; \
OPERATE(d,+=,0,OPRD); \
d = OPRD; \
OPERATE(d,+=,(-1),(OPRD - 1)); \
d = OPRD; \
OPERATE(d,+=,d32a,(OPRD + d32a)); \
d = OPRD; \
OPERATE(d,+=,d64a,(OPRD + d64a)); \
d = OPRD; \
OPERATE(d,+=,d128a,(OPRD + d128a)); \
d = OPRD; \
OPERATE(d,+=,(_Decimal##TYPE)1.1,(OPRD + (_Decimal##TYPE)1.1)); \
d = OPRD; \
OPERATE(d,+=,(_Decimal##TYPE)2.2f,(OPRD + (_Decimal##TYPE)2.2f)); \
d = OPRD; \
OPERATE(d,-=,1,(OPRD - 1)); \
d = OPRD; \
OPERATE(d,-=,0,OPRD); \
d = OPRD; \
OPERATE(d,-=,(-1),(OPRD + 1)); \
d = OPRD; \
OPERATE(d,-=,d32a,OPRD-d32a); \
d = OPRD; \
OPERATE(d,-=,d64a,OPRD-d64a); \
d = OPRD; \
OPERATE(d,-=,d128a,OPRD-d128a); \
}
int
main ()
{
_Decimal32 d32 = 1.23456fd, d32a = 1.2df;
_Decimal64 d64 = 23.456789dd, d64a = 2.8dd;
_Decimal128 d128 = 345.67890123456789ld, d128a = 4.7dl;
DECIMAL_COMPOUND_ASSIGNMENT(32, d32);
DECIMAL_COMPOUND_ASSIGNMENT(64, d64);
DECIMAL_COMPOUND_ASSIGNMENT(128, d128);
return 0;
}
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.10: Bitwise AND operator.
C99 6.5.11: Bitwise exclusive OR operator.
C99 6.5.12: Bitwise inclusive OR operator.
Test that these operators do not accept decimal float operands. */
extern void abort (void);
#define OPERATE(OPRD1,OPRT,OPRD2) \
do \
{ \
OPRD1 OPRT OPRD2; \
} while (0)
#define DECIMAL_BITWISE_OPERATOR(OPRT,OPRD) \
do \
{ \
OPERATE(OPRD,OPRT,1); \
OPERATE(OPRD,OPRT,0); \
OPERATE(OPRD,OPRT,0x15); \
OPERATE(0,OPRT,OPRD); \
OPERATE(1,OPRT,OPRD); \
OPERATE(0x15,OPRT,OPRD); \
} while (0)
void operator_notfor_decimal()
{
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
/* C99 Section 6.5.7 Bitwise shift operators. Operands must have
integer type (which the decimal float types are not). */
d32 << 1; /* { dg-error "invalid operands to binary" } */
d32 >> 1; /* { dg-error "invalid operands to binary" } */
d64 << 1; /* { dg-error "invalid operands to binary" } */
d64 >> 1; /* { dg-error "invalid operands to binary" } */
d128 << 1; /* { dg-error "invalid operands to binary" } */
d128 >> 1; /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(&,d32); /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(&,d64); /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(&,d128); /* { dg-error "invalid operands to binary" } */
/* C99 Section 6.5.{10,11,12} Bitwise operator. Constraints: Each of
the operands shall have integer type. DFP type is reject by compiler
when bitwise operation is performed. */
DECIMAL_BITWISE_OPERATOR(&,d32); /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(&,d64); /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(&,d128); /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(|,d32); /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(|,d64); /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(|,d128); /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(^,d32); /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(^,d64); /* { dg-error "invalid operands to binary" } */
DECIMAL_BITWISE_OPERATOR(^,d128); /* { dg-error "invalid operands to binary" } */
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* C99 6.5.17: Comma operator.
Test with decimal float operands. */
extern void abort (void);
static int failcnt = 0;
/* Support compiling the test to report individual failures; default is
to abort as soon as a check fails. */
#ifdef DBG
#include <stdio.h>
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
#else
#define FAILURE abort ();
#endif
volatile _Decimal32 d32a, d32b, d32c;
volatile _Decimal64 d64a, d64b, d64c;
volatile _Decimal128 d128a, d128b, d128c;
void
init ()
{
d32b = 123.456e94df;
d64b = 12.3456789012345e383dd;
d128b = 12345.6789012345678901e4000dl;
d32c = 1.3df;
d64c = 1.2dd;
d128c = 1.1dl;
}
int
main ()
{
d32a = (d32b, d32c);
if (d32a != d32c)
FAILURE
d64a = (d64b, 7.89dd, d64c);
if (d64a != d64c)
FAILURE
d128a = (45678.987654dl, d128c, d128b);
if (d128a != d128b)
FAILURE
d128a = (d32b, d64b, d128b);
if (d128a != d128b)
FAILURE
d32a = (d32b, 12, d64c);
if (d32a != d64c)
FAILURE;
d64a = (d64b, d32b, 12);
if (d64a != 12.0dd)
FAILURE;
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* C99 6.5.15 Conditional operator.
Test with decimal float operands. */
extern void abort (void);
static int failcnt = 0;
/* Support compiling the test to report individual failures; default is
to abort as soon as a check fails. */
#ifdef DBG
#include <stdio.h>
#define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
#else
#define FAILURE abort ();
#endif
volatile _Decimal32 d32a, d32b, d32c;
volatile _Decimal64 d64a, d64b, d64c;
volatile _Decimal128 d128a, d128b, d128c;
volatile int i, yes, no;
void
init ()
{
d32b = 123.456e94df;
d64b = 12.3456789012345e383dd;
d128b = 12345.6789012345678901e4000dl;
d32c = 1.3df;
d64c = 1.2dd;
d128c = 1.1dl;
i = 2;
yes = 1;
no = 0;
}
int
main ()
{
/* Operands and the result are all the same decimal float type. */
d32a = yes ? d32b : d32c;
if (d32a != d32b)
FAILURE
d64a = no ? d64b : d64c;
if (d64a != d64b)
FAILURE
d128a = yes ? d128b : d128c;
if (d128a != d128b)
FAILURE
/* Operand types are different. */
d128a = yes ? d32b : d64b;
if (d128a != d32b)
FAILURE
d128a = yes ? d128b : d64b;
if (d128a != d128b)
FAILURE
d128a = no ? d32b : d128b;
if (d128a != d128b)
FAILURE
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 Logical AND operator.
C99 Logical OR operator.
Test with decimal float operands. */
extern void abort (void);
#define OPERATE(OPRD1,OPRT,OPRD2,RLT) \
do \
{ \
if (( (OPRD1) OPRT (OPRD2) )!= RLT) \
abort (); \
} while (0)
#define DECIMAL_LOGICAL_OR(OPRD) \
do \
{ \
OPRD = 1.0; \
OPERATE(1,||,OPRD,1); \
OPERATE(0,||,OPRD,1); \
OPERATE(OPRD,||,1,1); \
OPERATE(OPRD,||,0,1); \
OPRD = 0.0; \
OPERATE(1,||,OPRD,1); \
OPERATE(0,||,OPRD,0); \
OPERATE(OPRD,||,1,1); \
OPERATE(OPRD,||,0,0); \
} while (0)
#define DECIMAL_LOGICAL_AND(OPRD) \
do \
{ \
OPRD = 1.0; \
OPERATE(1,&&,OPRD,1); \
OPERATE(0,&&,OPRD,0); \
OPERATE(OPRD,&&,1,1); \
OPERATE(OPRD,&&,0,0); \
OPRD = 0.0; \
OPERATE(1,&&,OPRD,0); \
OPERATE(0,&&,OPRD,0); \
OPERATE(OPRD,&&,1,0); \
OPERATE(OPRD,&&,0,0); \
} while (0)
int
main ()
{
_Decimal32 d32;
_Decimal64 d64;
_Decimal128 d128;
/* C99 Section 6.5.{13,14} Logical operator. Constraints Each of the
operands shall have scalar type. DFP types would obey this. */
DECIMAL_LOGICAL_OR (d32);
DECIMAL_LOGICAL_AND (d32);
DECIMAL_LOGICAL_OR (d64);
DECIMAL_LOGICAL_AND (d64);
DECIMAL_LOGICAL_OR (d128);
DECIMAL_LOGICAL_AND (d128);
return 0;
}
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* C99 6.5.3 Unary operators. */
extern void abort (void);
#define AUTO_INCREASE_DECREASE(TYPE,SUFFIX) \
do \
{ \
_Decimal##TYPE in_de_d##TYPE = 0.0##SUFFIX; \
if (in_de_d##TYPE++) abort (); \
if (--in_de_d##TYPE) abort (); \
if (++in_de_d##TYPE == 0.0##SUFFIX) abort (); \
if (in_de_d##TYPE-- == 0.0##SUFFIX) abort (); \
} while(0)
#define UNARY_OPERATOR(TYPE,SUFFIX) \
do \
{ \
_Decimal##TYPE unary_d##TYPE = 1.0##SUFFIX; \
_Decimal##TYPE* unary_dp##TYPE; \
/* & operator. */ \
unary_dp##TYPE = &(unary_d##TYPE); \
/* * operator. */ \
unary_d##TYPE = *(unary_dp##TYPE); \
/* - operator. */ \
unary_d##TYPE = -unary_d##TYPE; \
if (unary_d##TYPE != -1.0##SUFFIX) abort (); \
/* + operator. */ \
unary_d##TYPE = +unary_d##TYPE; \
if (unary_d##TYPE != -1.0##SUFFIX) abort (); \
if (!unary_d##TYPE) abort (); /*! operator. */ \
} while (0)
int
main ()
{
/* C99 6.5.3.1 Prefix increment and decrement operators. */
AUTO_INCREASE_DECREASE(32, DF);
AUTO_INCREASE_DECREASE(64, DD);
AUTO_INCREASE_DECREASE(128, DL);
/* C99 6.5.3 Unary operators. */
UNARY_OPERATOR(32, DF);
UNARY_OPERATOR(64, DD);
UNARY_OPERATOR(128, DL);
/* C99 6.5.3 Unary operators for zero values. */
if (- +0.df != -0.df) abort ();
if (+ -0.df != -0.df) abort ();
if (- -0.df != +0.df) abort ();
return 0;
}
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