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
This commit is contained in:
Janis Johnson 2006-01-11 21:29:59 +00:00 committed by Ben Elliston
parent fcfd0ebb14
commit 27a2694fb9
88 changed files with 6131 additions and 76 deletions

View File

@ -1,3 +1,68 @@
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>
PR tree-optimization/25734

View File

@ -30,49 +30,27 @@ if $tracelevel then {
}
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_lib standard.exp
load_lib gcc.exp
#
# compat-use-alt-compiler -- make the alternate compiler the default
#
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-dependent compatibility support procedures.
load_lib c-compat.exp
# Load the language-independent compabibility support procedures.
# This must be done after the compat-use-*-compiler definitions.
load_lib compat.exp
gcc_init
# 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.
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
# with other compat tests running at the same time.
@ -82,15 +60,18 @@ set sid "c_compat"
# 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
# are different.
set use_alt 0
set same_alt 0
set compat_use_alt 0
set compat_same_alt 0
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 {
set same_alt 1
set compat_same_alt 1
}
}
compat_setup_dfp
# Main loop.
foreach src [lsort [find $srcdir/$subdir *_main.c]] {
# 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]] {
continue
}
compat-execute $src $sid $use_alt
compat-execute $src $sid $compat_use_alt
}
# Restore the original compiler under test.

View File

@ -0,0 +1,15 @@
/* 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);
}

View File

@ -0,0 +1,170 @@
#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
}

View File

@ -0,0 +1,89 @@
#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)

View File

@ -0,0 +1,15 @@
/* 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);
}

View File

@ -0,0 +1,109 @@
#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
}

View File

@ -0,0 +1,67 @@
#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)

View File

@ -35,49 +35,26 @@ if $tracelevel then {
}
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_lib standard.exp
load_lib gcc.exp
#
# compat-use-alt-compiler -- make the alternate compiler the default
#
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-dependent compabibility support procedures.
load_lib c-compat.exp
# Load the language-independent compabibility support procedures.
# This must be done after the compat-use-*-compiler definitions.
load_lib compat.exp
gcc_init
# 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.
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
# with other compat tests running at the same time.
@ -87,22 +64,31 @@ set sid "c_compat"
# 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
# are different.
set use_alt 0
set same_alt 0
set compat_use_alt 0
set compat_same_alt 0
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 {
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 generator "$tmpdir/gcc.dg-struct-layout-1_generate"
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_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 [lindex $status 0]
@ -123,7 +109,7 @@ if { $status == 0 } then {
continue
}
compat-execute $src $sid $use_alt
compat-execute $src $sid $compat_use_alt
}
} else {
warning "Could not execute gcc.dg/compat/struct-layout-1 generator"

View File

@ -204,6 +204,11 @@ typedef _Complex unsigned long long int Tcullong;
typedef float Tfloat;
typedef double Tdouble;
typedef long double Tldouble;
#ifndef SKIP_DECIMAL_FLOAT
typedef _Decimal32 TDecimal32;
typedef _Decimal64 TDecimal64;
typedef _Decimal128 TDecimal128;
#endif
typedef _Complex float Tcfloat;
typedef _Complex double Tcdouble;
typedef _Complex long double Tcldouble;
@ -248,6 +253,11 @@ typedef _Complex unsigned long long int Talcullong atal;
typedef float Talfloat atal;
typedef double Taldouble 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 double Talcdouble atal;
typedef _Complex long double Talcldouble atal;
@ -292,6 +302,11 @@ typedef _Complex unsigned long long int Tal1cullong atal1;
typedef float Tal1float atal1;
typedef double Tal1double 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 double Tal1cdouble atal1;
typedef _Complex long double Tal1cldouble atal1;
@ -336,6 +351,11 @@ typedef _Complex unsigned long long int Tal2cullong atal2;
typedef float Tal2float atal2;
typedef double Tal2double 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 double Tal2cdouble atal2;
typedef _Complex long double Tal2cldouble atal2;
@ -380,6 +400,11 @@ typedef _Complex unsigned long long int Tal4cullong atal4;
typedef float Tal4float atal4;
typedef double Tal4double 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 double Tal4cdouble atal4;
typedef _Complex long double Tal4cldouble atal4;
@ -424,6 +449,11 @@ typedef _Complex unsigned long long int Tal8cullong atal8;
typedef float Tal8float atal8;
typedef double Tal8double 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 double Tal8cdouble atal8;
typedef _Complex long double Tal8cldouble atal8;
@ -468,6 +498,11 @@ typedef _Complex unsigned long long int Tal16cullong atal16;
typedef float Tal16float atal16;
typedef double Tal16double 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 double Tal16cdouble atal16;
typedef _Complex long double Tal16cldouble atal16;
@ -512,6 +547,11 @@ typedef _Complex unsigned long long int Talx1cullong atalx1;
typedef float Talx1float atalx1;
typedef double Talx1double 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 double Talx1cdouble atalx1;
typedef _Complex long double Talx1cldouble atalx1;
@ -553,6 +593,11 @@ typedef _Complex unsigned long long int Talx2cullong atalx2;
typedef float Talx2float atalx2;
typedef double Talx2double 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 double Talx2cdouble atalx2;
typedef _Complex long double Talx2cldouble atalx2;
@ -588,6 +633,11 @@ typedef _Complex unsigned long long int Talx4cullong atalx4;
typedef float Talx4float atalx4;
typedef double Talx4double 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 double Talx4cdouble atalx4;
typedef _Complex long double Talx4cldouble atalx4;
@ -618,6 +668,10 @@ typedef _Complex unsigned long long int Talx8cullong atalx8;
#endif
typedef double Talx8double 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 double Talx8cdouble atalx8;
typedef _Complex long double Talx8cldouble atalx8;

View File

@ -46,6 +46,7 @@ enum TYPE
TYPE_CUINT,
TYPE_FLOAT,
TYPE_CFLOAT,
TYPE_DEC_FLOAT,
TYPE_SENUM,
TYPE_UENUM,
TYPE_PTR,
@ -82,7 +83,14 @@ struct types base_types[] = {
{ "float", TYPE_FLOAT, 0, 0 },
{ "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
#endif
{ "Tchar", TYPE_UINT, 127, 'C' },
{ "Tschar", TYPE_INT, 127, 'C' },
{ "Tuchar", TYPE_UINT, 255, 'C' },
@ -103,6 +111,11 @@ struct types base_types[] = {
{ "Tfloat", TYPE_FLOAT, 0, 0 },
{ "Tdouble", 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 E1", TYPE_UENUM, 1, ' ' },
{ "enum E2", TYPE_SENUM, 3, ' ' },
@ -214,6 +227,11 @@ struct types attrib_types[] = {
{ "Talfloat", TYPE_FLOAT, 0, 0 },
{ "Taldouble", 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, ' ' },
{ "TalE1", TYPE_UENUM, 1, ' ' },
{ "TalE2", TYPE_SENUM, 3, ' ' },
@ -242,6 +260,11 @@ struct types attrib_types[] = {
{ "Tal1float", TYPE_FLOAT, 0, 0 },
{ "Tal1double", 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, ' ' },
{ "Tal1E1", TYPE_UENUM, 1, ' ' },
{ "Tal1E2", TYPE_SENUM, 3, ' ' },
@ -270,6 +293,11 @@ struct types attrib_types[] = {
{ "Tal2float", TYPE_FLOAT, 0, 0 },
{ "Tal2double", 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, ' ' },
{ "Tal2E1", TYPE_UENUM, 1, ' ' },
{ "Tal2E2", TYPE_SENUM, 3, ' ' },
@ -298,6 +326,11 @@ struct types attrib_types[] = {
{ "Tal4float", TYPE_FLOAT, 0, 0 },
{ "Tal4double", 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, ' ' },
{ "Tal4E1", TYPE_UENUM, 1, ' ' },
{ "Tal4E2", TYPE_SENUM, 3, ' ' },
@ -326,6 +359,11 @@ struct types attrib_types[] = {
{ "Tal8float", TYPE_FLOAT, 0, 0 },
{ "Tal8double", 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, ' ' },
{ "Tal8E1", TYPE_UENUM, 1, ' ' },
{ "Tal8E2", TYPE_SENUM, 3, ' ' },
@ -354,6 +392,11 @@ struct types attrib_types[] = {
{ "Tal16float", TYPE_FLOAT, 0, 0 },
{ "Tal16double", 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, ' ' },
{ "Tal16E1", TYPE_UENUM, 1, ' ' },
{ "Tal16E2", TYPE_SENUM, 3, ' ' },
@ -472,6 +515,11 @@ struct types attrib_array_types[] = {
{ "Talx1float", TYPE_FLOAT, 0, 0 },
{ "Talx1double", 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, ' ' },
{ "Talx1E1", TYPE_UENUM, 1, ' ' },
{ "Talx1E2", TYPE_SENUM, 3, ' ' },
@ -496,6 +544,11 @@ struct types attrib_array_types[] = {
{ "Talx2float", TYPE_FLOAT, 0, 0 },
{ "Talx2double", 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, ' ' },
{ "Talx2E1", TYPE_UENUM, 1, ' ' },
{ "Talx2E2", TYPE_SENUM, 3, ' ' },
@ -518,6 +571,11 @@ struct types attrib_array_types[] = {
{ "Talx4float", TYPE_FLOAT, 0, 0 },
{ "Talx4double", 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, ' ' },
{ "Talx4E1", TYPE_UENUM, 1, ' ' },
{ "Talx4E2", TYPE_SENUM, 3, ' ' },
@ -536,7 +594,11 @@ struct types attrib_array_types[] = {
{ "Taly8cptr", TYPE_PTR, 0, 0 },
{ "Taly8iptr", TYPE_PTR, 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]))
};
struct types complex_attrib_array_types[] = {
@ -950,6 +1012,11 @@ output_FNB (char mode, struct entry *e)
{
unsigned long long int l1, l2, m;
int signs = 0;
#ifndef SKIP_DECIMAL_FLOAT
int suffix = 0;
char DEC_SUFFIX[3][3]={"DF","DD","DL"};
#endif
const char *p, *q;
if (e->type->type == TYPE_OTHER)
@ -991,6 +1058,29 @@ output_FNB (char mode, struct entry *e)
fprintf (outfile, "%s%f,%s%f", (signs & 1) ? "-" : "",
((double) l1) / 64, (signs & 2) ? "-" : "", ((double) l2) / 64);
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:
signs = generate_random () & 3;
l1 &= e->type->maxval;

View File

@ -0,0 +1,16 @@
/* 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;
}

View File

@ -0,0 +1,15 @@
/* 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;
}

View File

@ -0,0 +1,44 @@
/* 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'" } */
}

View File

@ -0,0 +1,44 @@
/* 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" } */
}

View File

@ -0,0 +1,9 @@
/* { 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" "" } */

View File

@ -0,0 +1,46 @@
/* { 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;
}

View File

@ -0,0 +1,41 @@
/* { 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" } */
}

View File

@ -0,0 +1,78 @@
/* { 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;
}

View File

@ -0,0 +1,29 @@
/* { 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;
}

View File

@ -0,0 +1,14 @@
/* { 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;
}

View File

@ -0,0 +1,14 @@
/* { 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;
}

View File

@ -0,0 +1,14 @@
/* { 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;
}

View File

@ -0,0 +1,66 @@
/* { 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;
}

View File

@ -0,0 +1,96 @@
/* 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 ();
}

View File

@ -0,0 +1,60 @@
/* { 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;
}

View File

@ -0,0 +1,15 @@
/* { 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;
}

View File

@ -0,0 +1,15 @@
/* { 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;
}

View File

@ -0,0 +1,15 @@
/* { 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;
}

View File

@ -0,0 +1,66 @@
/* { 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;
}

View File

@ -0,0 +1,136 @@
/* 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 ();
}

View File

@ -0,0 +1,46 @@
/* { 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;
}

View File

@ -0,0 +1,12 @@
/* { 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" } */

View File

@ -0,0 +1,15 @@
/* { 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" } */

View File

@ -0,0 +1,12 @@
/* { 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" } */

View File

@ -0,0 +1,12 @@
/* { 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;

View File

@ -0,0 +1,118 @@
/* { 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;
}

View File

@ -0,0 +1,118 @@
/* { 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;
}

View File

@ -0,0 +1,129 @@
/* { 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;
}

View File

@ -0,0 +1,46 @@
/* { 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;
}

View File

@ -0,0 +1,137 @@
/* { 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;
}

View File

@ -0,0 +1,92 @@
/* { 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;
}

View File

@ -0,0 +1,166 @@
/* { 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;
}

View File

@ -0,0 +1,64 @@
/* { 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;
}

View File

@ -0,0 +1,194 @@
/* { 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;
}

View File

@ -0,0 +1,53 @@
/* { 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];
}

View File

@ -0,0 +1,13 @@
/* { 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

View File

@ -0,0 +1,46 @@
/* { 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;
}

View File

@ -0,0 +1,14 @@
/* 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()

View File

@ -0,0 +1,41 @@
# 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

View File

@ -0,0 +1,160 @@
/* { 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;
}

View File

@ -0,0 +1,175 @@
/* { 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;
}

View File

@ -0,0 +1,195 @@
/* { 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;
}

View File

@ -0,0 +1,96 @@
/* { 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;
}

View File

@ -0,0 +1,99 @@
/* { 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;
}

View File

@ -0,0 +1,106 @@
/* { 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;
}

View File

@ -0,0 +1,45 @@
/* { 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;
}

View File

@ -0,0 +1,8 @@
/* { 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" } */

View File

@ -0,0 +1,8 @@
/* { 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" } */

View File

@ -0,0 +1,15 @@
/* { 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;
}

View File

@ -0,0 +1,8 @@
/* { 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" } */

View File

@ -0,0 +1,17 @@
/* { 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" } */
}

View File

@ -0,0 +1,58 @@
/* { 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);
}

View File

@ -0,0 +1,15 @@
/* { 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);

View File

@ -0,0 +1,109 @@
/* { 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;
}

View File

@ -0,0 +1,56 @@
/* { 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;
}

View File

@ -0,0 +1,44 @@
/* { 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;
}

View File

@ -0,0 +1,59 @@
/* { 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;
}

View File

@ -0,0 +1,66 @@
/* { 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" } */
}

View File

@ -0,0 +1,58 @@
/* { 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;
}

View File

@ -0,0 +1,66 @@
/* { 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;
}

View File

@ -0,0 +1,66 @@
/* { 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;
}

View File

@ -0,0 +1,55 @@
/* { 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;
}

View File

@ -0,0 +1,29 @@
/* { dg-do run } */
/* { dg-options "" } */
/* FIXME: this test needs to be conditional to systems with POSIX signals. */
#include <signal.h>
extern void exit(int status);
extern void abort(void);
void go_quietly (int arg)
{
exit (0);
}
int main()
{
_Decimal32 d = 1.5df;
/* Enable signaling NaNs using a scaffolding libgcc function. */
__dfp_enable_traps ();
signal (SIGFPE, go_quietly);
d = d / 0.0df;
/* Never reached. */
abort ();
return 0;
}

View File

@ -0,0 +1,92 @@
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
#include <stdarg.h>
extern void abort (void);
struct S1
{
_Decimal64 a[0];
};
struct S2
{
struct
{
_Decimal64 e;
} b[0];
};
struct S3
{
union
{
_Decimal64 c;
} a[0];
};
struct S4
{
int a[0];
_Decimal64 b[0];
};
struct S5
{
union
{
_Decimal64 c[0];
} a;
};
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 do \
{ printf ("failed at line %d\n", __LINE__); \
failcnt++; \
}while(0)
#else
#define FAILURE abort ()
#endif
int check_var (int z, ...)
{
long long result;
va_list ap;
va_start (ap, z);
va_arg (ap, struct S1);
result = va_arg (ap, long long);
va_end (ap);
return (result == 2LL);
}
int main ()
{
struct S1 s1;
struct S2 s2;
struct S3 s3;
struct S4 s4;
struct S5 s5;
if (check_var (2, s1, 2LL) == 0)
FAILURE;
if (check_var (2, s2, 2LL) == 0)
FAILURE;
if (check_var (2, s3, 2LL) == 0)
FAILURE;
if (check_var (2, s4, 2LL) == 0)
FAILURE;
if (check_var (2, s5, 2LL) == 0)
FAILURE;
if (failcnt)
abort ();
return 0;
}

View File

@ -0,0 +1,62 @@
/* { dg-do compile } */
/* { dg-options "-O -Wall" } */
/* C99 6.5.2.3 Structure and union members.
If the first expression has qualified type, the result has the so-qualified
version of the type of the designated member. */
struct s {_Decimal32 d32; const _Decimal64 d64;};
struct sv { volatile _Decimal32 d32; volatile _Decimal64 d64; };
union u
{
const _Decimal64 d64;
_Decimal32 d32;
const struct s cs;
};
struct s s;
struct sv sv;
const struct s cs;
union u u;
const union u cu;
struct s g (struct s s)
{
return s;
}
union u h (union u u)
{
return u;
}
void f()
{
cs.d32 = 1.23dd; /* { dg-error "assignment of read-only variable" } */
cs.d64 = 1.23df; /* { dg-error "assignment of read-only variable" } */
s.d64 = 1.23df; /* { dg-error "assignment of read-only member" } */
s.d32 = 1.23dd;
u.d32 = 1.23dd;
u.d64 = 1.23df; /* { dg-error "assignment of read-only member" } */
u.cs.d32 = 1.23dd; /* { dg-error "assignment of read-only member" } */
u.cs.d64 = 1.23df; /* { dg-error "assignment of read-only member" } */
cu.d32 = 1.23dd; /* { dg-error "assignment of read-only variable" } */
cu.d64 = 1.23df; /* { dg-error "assignment of read-only variable" } */
cu.cs.d32 = 1.23dd; /* { dg-error "assignment of read-only variable" } */
cu.cs.d64 = 1.23df; /* { dg-error "assignment of read-only variable" } */
/* f().x is a valid postfix expression but is not an lvalue if
function f() returning a structure or union. */
g(s).d32 = 1.23dd; /* { dg-error "lvalue required" } */
h(u).d64 = 1.23df; /* { dg-error "lvalue required" } */
/* Test assignment to volatile structure members. */
sv.d32 = 1.1df;
sv.d64 = 1.1dd;
}

View File

@ -0,0 +1,303 @@
/* Test for valid and invalid combinations of type specifiers.
Based off gcc.dg/test-spec-1.c */
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
typedef char type;
void _Decimal32 *x0; /* { dg-error "error" "void _Decimal32" } */
void _Decimal64 *x1; /* { dg-error "error" "void _Decimal64" } */
void _Decimal128 *x2; /* { dg-error "error" "void _Decimal128" } */
char _Decimal32 *x3; /* { dg-error "error" "char _Decimal32" } */
char _Decimal64 *x4; /* { dg-error "error" "char _Decimal64" } */
char _Decimal128 *x5; /* { dg-error "error" "char _Decimal128" } */
short _Decimal32 *x6; /* { dg-error "error" "short _Decimal32" } */
short _Decimal64 *x7; /* { dg-error "error" "short _Decimal64" } */
short _Decimal128 *x8; /* { dg-error "error" "short _Decimal128" } */
int _Decimal32 *x9; /* { dg-error "error" "int _Decimal32" } */
int _Decimal64 *x10; /* { dg-error "error" "int _Decimal64" } */
int _Decimal128 *x11; /* { dg-error "error" "int _Decimal128" } */
long _Decimal32 *x12; /* { dg-error "error" "long _Decimal32" } */
long _Decimal64 *x13; /* { dg-error "error" "long _Decimal64" } */
long _Decimal128 *x14; /* { dg-error "error" "long _Decimal128" } */
float _Decimal32 *x15; /* { dg-error "error" "float _Decimal32" } */
float _Decimal64 *x16; /* { dg-error "error" "float _Decimal64" } */
float _Decimal128 *x17; /* { dg-error "error" "float _Decimal128" } */
double _Decimal32 *x18; /* { dg-error "error" "double _Decimal32" } */
double _Decimal64 *x19; /* { dg-error "error" "double _Decimal64" } */
double _Decimal128 *x20; /* { dg-error "error" "double _Decimal128" } */
signed _Decimal32 *x21; /* { dg-error "error" "signed _Decimal32" } */
signed _Decimal64 *x22; /* { dg-error "error" "signed _Decimal64" } */
signed _Decimal128 *x23; /* { dg-error "error" "signed _Decimal128" } */
_Bool _Decimal32 *x24; /* { dg-error "error" "_Bool _Decimal32" } */
_Bool _Decimal64 *x25; /* { dg-error "error" "_Bool _Decimal64" } */
_Bool _Decimal128 *x26; /* { dg-error "error" "_Bool _Decimal128" } */
int _Decimal32 *x27; /* { dg-error "error" "int _Decimal32" } */
int _Decimal64 *x28; /* { dg-error "error" "int _Decimal64" } */
int _Decimal128 *x29; /* { dg-error "error" "int _Decimal128" } */
type _Decimal32 *x30; /* { dg-error "error" "type _Decimal32" } */
type _Decimal64 *x31; /* { dg-error "error" "type _Decimal64" } */
type _Decimal128 *x32; /* { dg-error "error" "type _Decimal128" } */
char signed _Decimal32 *x33; /* { dg-error "error" "char signed _Decimal32" } */
char signed _Decimal64 *x34; /* { dg-error "error" "char signed _Decimal64" } */
char signed _Decimal128 *x35; /* { dg-error "error" "char signed _Decimal128" } */
char unsigned _Decimal32 *x36; /* { dg-error "error" "char unsigned _Decimal32" } */
char unsigned _Decimal64 *x37; /* { dg-error "error" "char unsigned _Decimal64" } */
char unsigned _Decimal128 *x38; /* { dg-error "error" "char unsigned _Decimal128" } */
short _Decimal32 *x39; /* { dg-error "error" "short _Decimal32" } */
short _Decimal64 *x40; /* { dg-error "error" "short _Decimal64" } */
short _Decimal128 *x41; /* { dg-error "error" "short _Decimal128" } */
short signed _Decimal32 *x42; /* { dg-error "error" "short signed _Decimal32" } */
short signed _Decimal64 *x43; /* { dg-error "error" "short signed _Decimal64" } */
short signed _Decimal128 *x44; /* { dg-error "error" "short signed _Decimal128" } */
short unsigned _Decimal32 *x45; /* { dg-error "error" "short unsigned _Decimal32" } */
short unsigned _Decimal64 *x46; /* { dg-error "error" "short unsigned _Decimal64" } */
short unsigned _Decimal128 *x47; /* { dg-error "error" "short unsigned _Decimal128" } */
_Decimal32 short*x48; /* { dg-error "error" "_Decimal32 short" } */
_Decimal64 short*x49; /* { dg-error "error" "_Decimal64 short" } */
_Decimal128 short*x50; /* { dg-error "error" "_Decimal128 short" } */
_Decimal32 short signed*x51; /* { dg-error "error" "_Decimal32 short signed" } */
_Decimal64 short signed*x52; /* { dg-error "error" "_Decimal64 short signed" } */
_Decimal128 short signed*x53; /* { dg-error "error" "_Decimal128 short signed" } */
_Decimal32 short unsigned*x54; /* { dg-error "error" "_Decimal32 short unsigned" } */
_Decimal64 short unsigned*x55; /* { dg-error "error" "_Decimal64 short unsigned" } */
_Decimal128 short unsigned*x56; /* { dg-error "error" "_Decimal128 short unsigned" } */
_Decimal32 long*x57; /* { dg-error "error" "_Decimal32 long" } */
_Decimal64 long*x58; /* { dg-error "error" "_Decimal64 long" } */
_Decimal128 long*x59; /* { dg-error "error" "_Decimal128 long" } */
_Decimal32 long signed*x60; /* { dg-error "error" "_Decimal32 long signed" } */
_Decimal64 long signed*x61; /* { dg-error "error" "_Decimal64 long signed" } */
_Decimal128 long signed*x62; /* { dg-error "error" "_Decimal128 long signed" } */
_Decimal32 long unsigned*x63; /* { dg-error "error" "_Decimal32 long unsigned" } */
_Decimal64 long unsigned*x64; /* { dg-error "error" "_Decimal64 long unsigned" } */
_Decimal128 long unsigned*x65; /* { dg-error "error" "_Decimal128 long unsigned" } */
_Decimal32 signed long*x66; /* { dg-error "error" "_Decimal32 signed long" } */
_Decimal64 signed long*x67; /* { dg-error "error" "_Decimal64 signed long" } */
_Decimal128 signed long*x68; /* { dg-error "error" "_Decimal128 signed long" } */
_Decimal32 signed short*x69; /* { dg-error "error" "_Decimal32 signed short" } */
_Decimal64 signed short*x70; /* { dg-error "error" "_Decimal64 signed short" } */
_Decimal128 signed short*x71; /* { dg-error "error" "_Decimal128 signed short" } */
int signed _Decimal32 *x72; /* { dg-error "error" "int signed _Decimal32" } */
int signed _Decimal64 *x73; /* { dg-error "error" "int signed _Decimal64" } */
int signed _Decimal128 *x74; /* { dg-error "error" "int signed _Decimal128" } */
int unsigned _Decimal32 *x75; /* { dg-error "error" "int unsigned _Decimal32" } */
int unsigned _Decimal64 *x76; /* { dg-error "error" "int unsigned _Decimal64" } */
int unsigned _Decimal128 *x77; /* { dg-error "error" "int unsigned _Decimal128" } */
long int _Decimal32 *x78; /* { dg-error "error" "long int _Decimal32" } */
long int _Decimal64 *x79; /* { dg-error "error" "long int _Decimal64" } */
long int _Decimal128 *x80; /* { dg-error "error" "long int _Decimal128" } */
long long _Decimal32 *x81; /* { dg-error "error" "long long _Decimal32" } */
long long _Decimal64 *x82; /* { dg-error "error" "long long _Decimal64" } */
long long _Decimal128 *x83; /* { dg-error "error" "long long _Decimal128" } */
long double _Decimal32 *x84; /* { dg-error "error" "long double _Decimal32" } */
long double _Decimal64 *x85; /* { dg-error "error" "long double _Decimal64" } */
long double _Decimal128 *x86; /* { dg-error "error" "long double _Decimal128" } */
long signed _Decimal32 *x87; /* { dg-error "error" "long signed _Decimal32" } */
long signed _Decimal64 *x88; /* { dg-error "error" "long signed _Decimal64" } */
long signed _Decimal128 *x89; /* { dg-error "error" "long signed _Decimal128" } */
long unsigned _Decimal32 *x90; /* { dg-error "error" "long unsigned _Decimal32" } */
long unsigned _Decimal64 *x91; /* { dg-error "error" "long unsigned _Decimal64" } */
long unsigned _Decimal128 *x92; /* { dg-error "error" "long unsigned _Decimal128" } */
double long _Decimal32 *x93; /* { dg-error "error" "double long _Decimal32" } */
double long _Decimal64 *x94; /* { dg-error "error" "double long _Decimal64" } */
double long _Decimal128 *x95; /* { dg-error "error" "double long _Decimal128" } */
signed char _Decimal32 *x96; /* { dg-error "error" "signed char _Decimal32" } */
signed char _Decimal64 *x97; /* { dg-error "error" "signed char _Decimal64" } */
signed char _Decimal128 *x98; /* { dg-error "error" "signed char _Decimal128" } */
signed short _Decimal32 *x99; /* { dg-error "error" "signed short _Decimal32" } */
signed short _Decimal64 *x100; /* { dg-error "error" "signed short _Decimal64" } */
signed short _Decimal128 *x101; /* { dg-error "error" "signed short _Decimal128" } */
signed int _Decimal32 *x102; /* { dg-error "error" "signed int _Decimal32" } */
signed int _Decimal64 *x103; /* { dg-error "error" "signed int _Decimal64" } */
signed int _Decimal128 *x104; /* { dg-error "error" "signed int _Decimal128" } */
signed long _Decimal32 *105x; /* { dg-error "error" "signed long _Decimal32" } */
signed long _Decimal64 *x107; /* { dg-error "error" "signed long _Decimal64" } \*/
signed long _Decimal128 *x107; /* { dg-error "error" "signed long _Decimal128" } \*/
unsigned char _Decimal32 *x108; /* { dg-error "error" "unsigned char _Decimal32" } */
unsigned char _Decimal64 *x109; /* { dg-error "error" "unsigned char _Decimal64" } */
unsigned char _Decimal128 *x110; /* { dg-error "error" "unsigned char _Decimal128" } */
unsigned short _Decimal32 *x111; /* { dg-error "error" "unsigned short _Decimal32" } */
unsigned short _Decimal64 *x112; /* { dg-error "error" "unsigned short _Decimal64" } */
unsigned short _Decimal128 *x113; /* { dg-error "error" "unsigned short _Decimal128" } */
unsigned int _Decimal32 *x114; /* { dg-error "error" "unsigned int _Decimal32" } */
unsigned int _Decimal64 *x115; /* { dg-error "error" "unsigned int _Decimal64" } */
unsigned int _Decimal128 *x116; /* { dg-error "error" "unsigned int _Decimal128" } */
unsigned long _Decimal32 *x117; /* { dg-error "error" "unsigned long _Decimal32" } */
unsigned long _Decimal64 *x118; /* { dg-error "error" "unsigned long _Decimal64" } */
unsigned long _Decimal128 *x119; /* { dg-error "error" "unsigned long _Decimal128" } */
short int signed _Decimal32 *x120; /* { dg-error "error" "short int signed _Decimal32" } */
short int signed _Decimal64 *x121; /* { dg-error "error" "short int signed _Decimal64" } */
short int signed _Decimal128 *x122; /* { dg-error "error" "short int signed _Decimal128" } */
short int unsigned _Decimal32 *x123; /* { dg-error "error" "short int unsigned _Decimal32" } */
short int unsigned _Decimal64 *x124; /* { dg-error "error" "short int unsigned _Decimal64" } */
short int unsigned _Decimal128 *x125; /* { dg-error "error" "short int unsigned _Decimal128" } */
short signed int _Decimal32 *x126; /* { dg-error "error" "short signed int _Decimal32" } */
short signed int _Decimal64 *x127; /* { dg-error "error" "short signed int _Decimal64" } */
short signed int _Decimal128 *x128; /* { dg-error "error" "short signed int _Decimal128" } */
short unsigned int _Decimal32 *x129; /* { dg-error "error" "short unsigned int _Decimal32" } */
short unsigned int _Decimal64 *x130; /* { dg-error "error" "short unsigned int _Decimal64" } */
short unsigned int _Decimal128 *x131; /* { dg-error "error" "short unsigned int _Decimal128" } */
int short signed _Decimal32 *x132; /* { dg-error "error" "int short signed _Decimal32" } */
int short signed _Decimal64 *x133; /* { dg-error "error" "int short signed _Decimal64" } */
int short signed _Decimal128 *x134; /* { dg-error "error" "int short signed _Decimal128" } */
int short unsigned _Decimal32 *x135; /* { dg-error "error" "int short unsigned _Decimal32" } */
int short unsigned _Decimal64 *x136; /* { dg-error "error" "int short unsigned _Decimal64" } */
int short unsigned _Decimal128 *x137; /* { dg-error "error" "int short unsigned _Decimal128" } */
int long long _Decimal32 *x138; /* { dg-error "error" "int long long _Decimal32" } */
int long long _Decimal64 *x139; /* { dg-error "error" "int long long _Decimal64" } */
int long long _Decimal128 *x140; /* { dg-error "error" "int long long _Decimal128" } */
int long signed _Decimal32 *x141; /* { dg-error "error" "int long signed _Decimal32" } */
int long signed _Decimal64 *x142; /* { dg-error "error" "int long signed _Decimal64" } */
int long signed _Decimal128 *x143; /* { dg-error "error" "int long signed _Decimal128" } */
int long unsigned _Decimal32 *x144; /* { dg-error "error" "int long unsigned _Decimal32" } */
int long unsigned _Decimal64 *x145; /* { dg-error "error" "int long unsigned _Decimal64" } */
int long unsigned _Decimal128 *x146; /* { dg-error "error" "int long unsigned _Decimal128" } */
int signed short _Decimal32 *x147; /* { dg-error "error" "int signed short _Decimal32" } */
int signed short _Decimal64 *x148; /* { dg-error "error" "int signed short _Decimal64" } */
int signed short _Decimal128 *x149; /* { dg-error "error" "int signed short _Decimal128" } */
int signed long _Decimal32 *x150; /* { dg-error "error" "int signed long _Decimal32" } */
int signed long _Decimal64 *x151; /* { dg-error "error" "int signed long _Decimal64" } */
int signed long _Decimal128 *x152; /* { dg-error "error" "int signed long _Decimal128" } */
int unsigned short _Decimal32 *x153; /* { dg-error "error" "int unsigned short _Decimal32" } */
int unsigned short _Decimal64 *x154; /* { dg-error "error" "int unsigned short _Decimal64" } */
int unsigned short _Decimal128 *x155; /* { dg-error "error" "int unsigned short _Decimal128" } */
int unsigned long _Decimal32 *x156; /* { dg-error "error" "int unsigned long _Decimal32" } */
int unsigned long _Decimal64 *x157; /* { dg-error "error" "int unsigned long _Decimal64" } */
int unsigned long _Decimal128 *x158; /* { dg-error "error" "int unsigned long _Decimal128" } */
long int long _Decimal32 *x159; /* { dg-error "error" "long int long _Decimal32" } */
long int long _Decimal64 *x160; /* { dg-error "error" "long int long _Decimal64" } */
long int long _Decimal128 *x161; /* { dg-error "error" "long int long _Decimal128" } */
long int signed _Decimal32 *x162; /* { dg-error "error" "long int signed _Decimal32" } */
long int signed _Decimal64 *x163; /* { dg-error "error" "long int signed _Decimal64" } */
long int signed _Decimal128 *x164; /* { dg-error "error" "long int signed _Decimal128" } */
long int unsigned _Decimal32 *x165; /* { dg-error "error" "long int unsigned _Decimal32" } */
long int unsigned _Decimal64 *x166; /* { dg-error "error" "long int unsigned _Decimal64" } */
long int unsigned _Decimal128 *x167; /* { dg-error "error" "long int unsigned _Decimal128" } */
long long int _Decimal32 *x168; /* { dg-error "error" "long long int _Decimal32" } */
long long int _Decimal64 *x169; /* { dg-error "error" "long long int _Decimal64" } */
long long int _Decimal128 *x170; /* { dg-error "error" "long long int _Decimal128" } */
long long signed _Decimal32 *x171; /* { dg-error "error" "long long signed _Decimal32" } */
long long signed _Decimal64 *x172; /* { dg-error "error" "long long signed _Decimal64" } */
long long signed _Decimal128 *x172; /* { dg-error "error" "long long signed _Decimal128" } */
long long unsigned _Decimal32 *x175; /* { dg-error "error" "long long unsigned _Decimal32" } */
long long unsigned _Decimal64 *x176; /* { dg-error "error" "long long unsigned _Decimal64" } */
long long unsigned _Decimal128 *x177; /* { dg-error "error" "long long unsigned _Decimal128" } */
long signed int _Decimal32 *x178; /* { dg-error "error" "long signed int _Decimal32" } */
long signed int _Decimal64 *x179; /* { dg-error "error" "long signed int _Decimal64" } */
long signed int _Decimal128 *x180; /* { dg-error "error" "long signed int _Decimal128" } */
long unsigned int _Decimal32 *x181; /* { dg-error "error" "long unsigned int _Decimal32" } */
long unsigned int _Decimal64 *x182; /* { dg-error "error" "long unsigned int _Decimal64" } */
long unsigned int _Decimal128 *x183; /* { dg-error "error" "long unsigned int _Decimal128" } */
long unsigned long _Decimal32 *x184; /* { dg-error "error" "long unsigned long _Decimal32" } */
long unsigned long _Decimal64 *x185; /* { dg-error "error" "long unsigned long _Decimal64" } */
long unsigned long _Decimal128 *x186; /* { dg-error "error" "long unsigned long _Decimal128" } */
signed short int _Decimal32 *x187; /* { dg-error "error" "signed short int _Decimal32" } */
signed short int _Decimal64 *x188; /* { dg-error "error" "signed short int _Decimal64" } */
signed short int _Decimal128 *x189; /* { dg-error "error" "signed short int _Decimal128" } */
signed int short _Decimal32 *x190; /* { dg-error "error" "signed int short _Decimal32" } */
signed int short _Decimal64 *x191; /* { dg-error "error" "signed int short _Decimal64" } */
signed int short _Decimal128 *x191; /* { dg-error "error" "signed int short _Decimal128" } */
signed int long _Decimal32 *x192; /* { dg-error "error" "signed int long _Decimal32" } */
signed int long _Decimal64 *x193; /* { dg-error "error" "signed int long _Decimal64" } */
signed int long _Decimal128 *x194; /* { dg-error "error" "signed int long _Decimal128" } */
signed long int _Decimal32 *x195; /* { dg-error "error" "signed long int _Decimal32" } */
signed long int _Decimal64 *x196; /* { dg-error "error" "signed long int _Decimal64" } */
signed long int _Decimal128 *x197; /* { dg-error "error" "signed long int _Decimal128" } */
signed long long _Decimal32 *x198; /* { dg-error "error" "signed long long _Decimal32" } */
signed long long _Decimal64 *x199; /* { dg-error "error" "signed long long _Decimal64" } */
signed long long _Decimal128 *x200; /* { dg-error "error" "signed long long _Decimal128" } */
unsigned short int _Decimal32 *x201; /* { dg-error "error" "unsigned short int _Decimal32" } */
unsigned short int _Decimal64 *x202; /* { dg-error "error" "unsigned short int _Decimal64" } */
unsigned short int _Decimal128 *x203; /* { dg-error "error" "unsigned short int _Decimal128" } */
unsigned int short _Decimal32 *x204; /* { dg-error "error" "unsigned int short _Decimal32" } */
unsigned int short _Decimal64 *x205; /* { dg-error "error" "unsigned int short _Decimal64" } */
unsigned int short _Decimal128 *x206; /* { dg-error "error" "unsigned int short _Decimal128" } */
unsigned int long _Decimal32 *x207; /* { dg-error "error" "unsigned int long _Decimal32" } */
unsigned int long _Decimal64 *x208; /* { dg-error "error" "unsigned int long _Decimal64" } */
unsigned int long _Decimal128 *x209; /* { dg-error "error" "unsigned int long _Decimal128" } */
unsigned long int _Decimal32 *x210; /* { dg-error "error" "unsigned long int _Decimal32" } */
unsigned long int _Decimal64 *x211; /* { dg-error "error" "unsigned long int _Decimal64" } */
unsigned long int _Decimal128 *x212; /* { dg-error "error" "unsigned long int _Decimal128" } */
unsigned long long _Decimal32 *x213; /* { dg-error "error" "unsigned long long _Decimal32" } */
unsigned long long _Decimal64 *x214; /* { dg-error "error" "unsigned long long _Decimal64" } */
unsigned long long _Decimal128 *x215; /* { dg-error "error" "unsigned long long _Decimal128" } */
int long long signed _Decimal32 *x216; /* { dg-error "error" "int long long signed _Decimal32" } */
int long long signed _Decimal64 *x217; /* { dg-error "error" "int long long signed _Decimal64" } */
int long long signed _Decimal128 *x218; /* { dg-error "error" "int long long signed _Decimal128" } */
int long long unsigned _Decimal32 *x219; /* { dg-error "error" "int long long unsigned _Decimal32" } */
int long long unsigned _Decimal64 *x220; /* { dg-error "error" "int long long unsigned _Decimal64" } */
int long long unsigned _Decimal128 *x221; /* { dg-error "error" "int long long unsigned _Decimal128" } */
int long signed long _Decimal32 *x222; /* { dg-error "error" "int long signed long _Decimal32" } */
int long signed long _Decimal64 *x223; /* { dg-error "error" "int long signed long _Decimal64" } */
int long signed long _Decimal128 *x224; /* { dg-error "error" "int long signed long _Decimal128" } */
int long unsigned long _Decimal32 *x226; /* { dg-error "error" "int long unsigned long _Decimal32" } */
int long unsigned long _Decimal64 *x227; /* { dg-error "error" "int long unsigned long _Decimal64" } */
int long unsigned long _Decimal128 *x228; /* { dg-error "error" "int long unsigned long _Decimal128" } */
int signed long long _Decimal32 *x229; /* { dg-error "error" "int signed long long _Decimal32" } */
int signed long long _Decimal64 *x230; /* { dg-error "error" "int signed long long _Decimal64" } */
int signed long long _Decimal128 *x231; /* { dg-error "error" "int signed long long _Decimal128" } */
int unsigned long long _Decimal32 *x232; /* { dg-error "error" "int unsigned long long _Decimal32" } */
int unsigned long long _Decimal64 *x233; /* { dg-error "error" "int unsigned long long _Decimal64" } */
int unsigned long long _Decimal128 *x234; /* { dg-error "error" "int unsigned long long _Decimal128" } */
long int long signed _Decimal32 *x235; /* { dg-error "error" "long int long signed _Decimal32" } */
long int long signed _Decimal64 *x236; /* { dg-error "error" "long int long signed _Decimal64" } */
long int long signed _Decimal128 *x237; /* { dg-error "error" "long int long signed _Decimal128" } */
long int long unsigned _Decimal32 *x238; /* { dg-error "error" "long int long unsigned _Decimal32" } */
long int long unsigned _Decimal64 *x239; /* { dg-error "error" "long int long unsigned _Decimal64" } */
long int long unsigned _Decimal128 *x240; /* { dg-error "error" "long int long unsigned _Decimal128" } */
long int signed long _Decimal32 *x241; /* { dg-error "error" "long int signed long _Decimal32" } */
long int signed long _Decimal64 *x242; /* { dg-error "error" "long int signed long _Decimal64" } */
long int signed long _Decimal128 *x243; /* { dg-error "error" "long int signed long _Decimal128" } */
long int unsigned long _Decimal32 *x244; /* { dg-error "error" "long int unsigned long _Decimal32" } */
long int unsigned long _Decimal64 *x245; /* { dg-error "error" "long int unsigned long _Decimal64" } */
long int unsigned long _Decimal128 *x246; /* { dg-error "error" "long int unsigned long _Decimal128" } */
long long int signed _Decimal32 *x247; /* { dg-error "error" "long long int signed _Decimal32" } */
long long int signed _Decimal64 *x248; /* { dg-error "error" "long long int signed _Decimal64" } */
long long int signed _Decimal128 *x249; /* { dg-error "error" "long long int signed _Decimal128" } */
long long int unsigned _Decimal32 *x250; /* { dg-error "error" "long long int unsigned _Decimal32" } */
long long int unsigned _Decimal64 *x251; /* { dg-error "error" "long long int unsigned _Decimal64" } */
long long int unsigned _Decimal128 *x252; /* { dg-error "error" "long long int unsigned _Decimal128" } */
long long signed int _Decimal32 *x253; /* { dg-error "error" "long long signed int _Decimal32" } */
long long signed int _Decimal64 *x254; /* { dg-error "error" "long long signed int _Decimal64" } */
long long signed int _Decimal128 *x255; /* { dg-error "error" "long long signed int _Decimal128" } */
long long unsigned int _Decimal32 *x256; /* { dg-error "error" "long long unsigned int _Decimal32" } */
long long unsigned int _Decimal64 *x257; /* { dg-error "error" "long long unsigned int _Decimal64" } */
long long unsigned int _Decimal128 *x258; /* { dg-error "error" "long long unsigned int _Decimal128" } */
long signed int long _Decimal32 *x259; /* { dg-error "error" "long signed int long _Decimal32" } */
long signed int long _Decimal64 *x260; /* { dg-error "error" "long signed int long _Decimal64" } */
long signed int long _Decimal128 *x261; /* { dg-error "error" "long signed int long _Decimal128" } */
long signed long int _Decimal32 *x262; /* { dg-error "error" "long signed long int _Decimal32" } */
long signed long int _Decimal64 *x263; /* { dg-error "error" "long signed long int _Decimal64" } */
long signed long int _Decimal128 *x264; /* { dg-error "error" "long signed long int _Decimal128" } */
long unsigned int long _Decimal32 *x265; /* { dg-error "error" "long unsigned int long _Decimal32" } */
long unsigned int long _Decimal64 *x266; /* { dg-error "error" "long unsigned int long _Decimal64" } */
long unsigned int long _Decimal128 *x267; /* { dg-error "error" "long unsigned int long _Decimal128" } */
long unsigned long int _Decimal32 *x268; /* { dg-error "error" "long unsigned long int _Decimal32" } */
long unsigned long int _Decimal64 *x269; /* { dg-error "error" "long unsigned long int _Decimal64" } */
long unsigned long int _Decimal128 *x270; /* { dg-error "error" "long unsigned long int _Decimal128" } */
signed long long int _Decimal32 *x271; /* { dg-error "error" "signed long long int _Decimal32" } */
signed long long int _Decimal64 *x272; /* { dg-error "error" "signed long long int _Decimal64" } */
signed long long int _Decimal128 *x273; /* { dg-error "error" "signed long long int _Decimal128" } */
unsigned int long long _Decimal32 *x274; /* { dg-error "error" "unsigned int long long _Decimal32" } */
unsigned int long long _Decimal64 *x275; /* { dg-error "error" "unsigned int long long _Decimal64" } */
unsigned int long long _Decimal128 *x276; /* { dg-error "error" "unsigned int long long _Decimal128" } */
unsigned long int long _Decimal32 *x277; /* { dg-error "error" "unsigned long int long _Decimal32" } */
unsigned long int long _Decimal64 *x278; /* { dg-error "error" "unsigned long int long _Decimal64" } */
unsigned long int long _Decimal128 *x279; /* { dg-error "error" "unsigned long int long _Decimal128" } */
unsigned long long int _Decimal32 *x280; /* { dg-error "error" "unsigned long long int _Decimal32" } */
unsigned long long int _Decimal64 *x281; /* { dg-error "error" "unsigned long long int _Decimal64" } */
unsigned long long int _Decimal128 *x282; /* { dg-error "error" "unsigned long long int _Decimal128" } */
_Complex _Decimal32 *x283; /* { dg-error "error" "_Complex _Decimal32" } */
_Complex _Decimal64 *x284; /* { dg-error "error" "_Complex _Decimal64" } */
_Complex _Decimal128 *x285; /* { dg-error "error" "_Complex _Decimal128" } */
_Decimal32 _Complex *x286; /* { dg-error "error" "_Decimal32 _Complex" } */
_Decimal64 _Complex *x287; /* { dg-error "error" "_Decimal64 _Complex" } */
_Decimal128 _Complex *x288; /* { dg-error "error" "_Decimal128 _Complex" } */
unsigned _Decimal32 *x289; /* { dg-error "error" "unsigned _Decimal32" } */
unsigned _Decimal64 *x290; /* { dg-error "error" "unsigned _Decimal64" } */
unsigned _Decimal128 *x291; /* { dg-error "error" "unsigned _Decimal128" } */
signed _Decimal32 *x292; /* { dg-error "error" "signed _Decimal32" } */
signed _Decimal64 *x293; /* { dg-error "error" "signed _Decimal64" } */
signed _Decimal128 *x294; /* { dg-error "error" "signed _Decimal128" } */

View File

@ -0,0 +1,61 @@
/* { dg-do run } */
/* { dg-options "-std=gnu99" } */
/* Cast to union is a GNU C extension. */
extern void abort (void);
union u
{
_Decimal128 d128;
double d;
};
union n
{
double d;
_Decimal64 d64;
};
int main ()
{
static union u u1 = { 0.0dl };
static union u u2 = { 4.2dl };
static union u u4 = { 0.0 };
static union n n1 = { 2.2dd };
static union n n2 = { 3.25 };
_Decimal128 d128;
_Decimal64 d64;
double d;
if (u1.d128 != 0.0dl)
abort ();
if (u2.d128 != 4.2dl)
abort ();
/* cast decimal floating point to union type. */
d128 = 1.23dl;
d64 = 4.56dd;
d = 3.25;
u4 = (union u) d128;
if (u4.d128 != 1.23dl)
abort ();
u4 = (union u) d;
if (u4.d != 3.25)
abort ();
n1 = (union n) d64;
if (n1.d64 != 4.56dd)
abort ();
n1 = (union n)d;
if (n1.d != 3.25)
abort ();
return 0;
}

View File

@ -0,0 +1,31 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99" } */
/* Test various conversions involving decimal floating types. */
/* Assertion that constant C is of type T. */
#define ASSERT_CONST_TYPE(C, T) \
do { \
typedef T type; \
typedef type **typepp; \
typedef __typeof__((C)) ctype; \
typedef ctype **ctypepp; \
typepp x = 0; \
ctypepp y = 0; \
x = y; \
y = x; \
} while (0)
int
main ()
{
ASSERT_CONST_TYPE (3 + 2.1df, _Decimal32); /* { dg-bogus "assignment from incompatible pointer type" } */
ASSERT_CONST_TYPE (1.3df + 2, _Decimal32); /* { dg-bogus "assignment from incompatible pointer type" } */
ASSERT_CONST_TYPE (56U - 55.0dd, _Decimal64); /* { dg-bogus "assignment from incompatible pointer type" } */
ASSERT_CONST_TYPE (5 * .2DL, _Decimal128); /* { dg-bogus "assignment from incompatible pointer type" } */
ASSERT_CONST_TYPE (.88dl / 2L, _Decimal128); /* { dg-bogus "assignment from incompatible pointer type" } */
ASSERT_CONST_TYPE (.114df - 1.6dd, _Decimal64); /* { dg-bogus "assignment from incompatible pointer type" } */
ASSERT_CONST_TYPE (3L - 1 + .55df, _Decimal32); /* { dg-bogus "assignment from incompatible pointer type" } */
return 0;
}

View File

@ -0,0 +1,128 @@
/* { dg-do run } */
/* { dg-options "-std=gnu99 -O0" } */
/* N1150 5.4: Usual arithmetic conversions.
C99 6.3.1.8[1] (New).
Test arithmetic operators with different decimal float types, and
between decimal float types and integer types. */
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;
void
init ()
{
d32b = 123.456e94df;
d64b = 12.3456789012345e383dd;
d128b = 12345.6789012345678901e4000dl;
d32c = 1.3df;
d64c = 1.2dd;
d128c = 1.1dl;
i = 2;
}
int
main ()
{
init ();
/* Usual arithmetic conversions between decimal float types; addition. */
d128a = d128b + d32b;
if (d128a < d128b)
FAILURE
d128a = d32b + d128b;
if (d128a < d128b)
FAILURE
d128a = d128b + d64b;
if (d128a < d128b)
FAILURE
d128a = d64b + d128b;
if (d128a < d128b)
FAILURE
d64a = d64b + d32b;
if (d64a < d64b)
FAILURE
d64a = d32b + d64b;
if (d64a < d64b)
FAILURE
/* Usual arithmetic conversions between decimal float types;
multiplication. */
d128a = d128b * d32c;
if (d128a < d128b)
FAILURE
d128a = d32c * d128b;
if (d128a < d128b)
FAILURE
d128a = d128b * d64c;
if (d128a < d128b)
FAILURE
d128a = d64c * d128b;
if (d128a < d128b)
FAILURE
d64a = d64b * d32c;
if (d64a < d64b)
FAILURE
d64a = d32c * d64b;
if (d64a < d64b)
FAILURE
/* Usual arithmetic conversions between decimal float and integer types. */
d32a = d32c + i;
if (d32a != d32c + 2.0df)
FAILURE
d32a = d32c - i;
if (d32a != d32c - 2.0df)
FAILURE
d32a = i * d32c;
if (d32a != d32c + d32c)
FAILURE
d32a = d32c / i;
if (d32a != d32c / 2.0df)
FAILURE
d64a = i + d64c;
if (d64a != d64c + 2.0dd)
FAILURE
d64a = d64c - i;
if (d64a != d64c - 2.0dd)
FAILURE
d64a = d64c * i;
if (d64a != d64c + d64c)
FAILURE
d64a = d64c / i;
if (d64a != d64c / 2.0dd)
FAILURE
d128a = d128c + i;
if (d128a != d128c + 2.0dl)
FAILURE
d128a = d128c - i;
if (d128a != d128c - 2.0dl)
FAILURE
d128a = i * d128c;
if (d128a != d128c + d128c)
FAILURE
d128a = d128c / i;
if (d128a != d128c / 2.0dl)
FAILURE
return 0;
}

View File

@ -0,0 +1,75 @@
/* Test for -Wtraditional warnings on conversions by prototypes.
Note, gcc should omit these warnings in system header files.
Based on gcc.dg/wtr-conversion-1.c */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wtraditional" } */
extern void foo_i (int);
extern void foo_f (float);
extern void foo_ld (long double);
extern void foo_d32 (_Decimal32);
extern void foo_d64 (_Decimal64);
extern void foo_d128 (_Decimal128);
extern int i;
extern float f;
extern long double ld;
extern _Decimal32 d32;
extern _Decimal64 d64;
extern _Decimal128 d128;
void
testfunc1 ()
{
foo_i (i);
foo_i (d32); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */
foo_i (d64); /* { dg-warning "as integer rather than floating" "prototype convDersion warning" } */
foo_i (d128); /* { dg-warning "as integer rather than floating" "prototype conversion warning" } */
foo_d32 (i); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */
foo_d32 (f); /* { dg-warning "as '_Decimal32' rather than 'float'" "prototype conversion warning" } */
foo_d32 (ld); /* { dg-warning "as '_Decimal32' rather than 'long double'" "prototype conversion warning" } */
foo_d32 (d64); /* { dg-warning "as '_Decimal32' rather than '_Decimal64'" "prototype conversion warning" } */
foo_d32 (d128); /* { dg-warning "as '_Decimal32' rather than '_Decimal128'" "prototype conversion warning" } */
foo_d64 (i); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */
foo_d64 (f); /* { dg-warning "as '_Decimal64' rather than 'float'" "prototype conversion warning" } */
foo_d64 (ld); /* { dg-warning "as '_Decimal64' rather than 'long double'" "prototype conversion warning" } */
foo_d64 (d32); /* { dg-bogus "as '_Decimal64' rather than '_Decimal32'" "prototype conversion warning" } */
foo_d64 (d128); /* { dg-warning "as '_Decimal64' rather than '_Decimal128'" "prototype conversion warning" } */
foo_d128 (i); /* { dg-warning "as floating rather than integer" "prototype conversion warning" } */
foo_d128 (f); /* { dg-warning "as '_Decimal128' rather than 'float'" "prototype conversion warning" } */
foo_d128 (ld); /* { dg-warning "as '_Decimal128' rather than 'long double'" "prototype conversion warning" } */
foo_d128 (d32); /* { dg-bogus "as '_Decimal128' rather than '_Decimal32'" "prototype conversion warning" } */
foo_d128 (d64); /* { dg-bogus "as '_Decimal128' rather than '_Decimal64'" "prototype conversion warning" } */
foo_d128 (d128); /* { dg-bogus "as '_Decimal128' rather than '_Decimal'" "prototype conversion warning" } */
}
# 54 "sys-header.h" 3
/* We are in system headers now, no -Wtraditional warnings should issue. */
void
testfunc2 ()
{
foo_i (i);
foo_i (d32);
foo_i (d64);
foo_i (d128);
foo_d32 (i);
foo_d32 (f);
foo_d32 (ld);
foo_d32 (d32);
foo_d32 (d64);
foo_d32 (d128);
foo_d64 (i);
foo_d64 (f);
foo_d64 (ld);
foo_d64 (d32);
foo_d64 (d64);
foo_d64 (d128);
foo_d128 (i);
foo_d128 (f);
foo_d128 (ld);
foo_d128 (d32);
foo_d128 (d64);
foo_d128 (d128);
}

View File

@ -0,0 +1,122 @@
/* Test for printf formats for Decimal Floating Point types. */
/* { dg-do compile } */
/* { dg-require-effective-target dfp } */
/* { dg-options "-Wformat" } */
extern int printf (const char *restrict, ...);
void
foo (_Decimal32 x, _Decimal64 y, _Decimal128 z, int i, unsigned int j,
double d, char *p)
{
/* See ISO/IEC DTR 24732 subclause 9.3 (currently Working Draft 5 from
2005-03-06). */
/* Formatted input/output specifiers. */
/* Check lack of warnings for valid usage. */
printf ("%Hf\n", x);
printf ("%HF\n", x);
printf ("%He\n", x);
printf ("%HE\n", x);
printf ("%Hg\n", x);
printf ("%HG\n", x);
printf ("%Df\n", y);
printf ("%DF\n", y);
printf ("%De\n", y);
printf ("%DE\n", y);
printf ("%Dg\n", y);
printf ("%DG\n", y);
printf ("%DDf\n", z);
printf ("%DDF\n", z);
printf ("%DDe\n", z);
printf ("%DDE\n", z);
printf ("%DDg\n", z);
printf ("%DDG\n", z);
printf ("%DG%DDE%HF%DDe%He%HE%DF%DDF%De%DDG%HG%Df%Hg%DE%DDf%Dg%DDg%Hf\n",
y, z, x, z, x, x, y, z, y, z, x, y, x, y, z, y, z, x);
/* Check warnings for type mismatches. */
printf ("%Hf\n", y); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%HF\n", y); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%He\n", y); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%HE\n", y); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%Hg\n", y); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%HG\n", y); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%Hf\n", z); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%HF\n", z); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%He\n", z); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%HE\n", z); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%Hg\n", z); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%HG\n", z); /* { dg-warning "expects type" "bad use of %H" } */
printf ("%Df\n", x); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%DF\n", x); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%De\n", x); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%DE\n", x); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%Dg\n", x); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%DG\n", x); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%Df\n", z); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%DF\n", z); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%De\n", z); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%DE\n", z); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%Dg\n", z); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%DG\n", z); /* { dg-warning "expects type" "bad use of %D" } */
printf ("%DDf\n", x); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDF\n", x); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDe\n", x); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDE\n", x); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDg\n", x); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDG\n", x); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDf\n", y); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDF\n", y); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDe\n", y); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDE\n", y); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDg\n", y); /* { dg-warning "expects type" "bad use of %DD" } */
printf ("%DDG\n", y); /* { dg-warning "expects type" "bad use of %DD" } */
/* Check for warnings for bad use of H, D, and DD length specifiers. */
printf ("%Hd\n", i); /* { dg-warning "length" "bad use of %H" } */
printf ("%Hi\n", i); /* { dg-warning "length" "bad use of %H" } */
printf ("%Ho\n", j); /* { dg-warning "length" "bad use of %H" } */
printf ("%Hu\n", j); /* { dg-warning "length" "bad use of %H" } */
printf ("%Hx\n", j); /* { dg-warning "length" "bad use of %H" } */
printf ("%HX\n", j); /* { dg-warning "length" "bad use of %H" } */
printf ("%Ha\n", d); /* { dg-warning "length" "bad use of %H" } */
printf ("%HA\n", d); /* { dg-warning "length" "bad use of %H" } */
printf ("%Hc\n", i); /* { dg-warning "length" "bad use of %H" } */
printf ("%Hs\n", p); /* { dg-warning "length" "bad use of %H" } */
printf ("%Hp\n", p); /* { dg-warning "length" "bad use of %H" } */
printf ("%Hn\n", p); /* { dg-warning "length" "bad use of %H" } */
/* Sanity checks for flags, field width, and precision in formats for
DFP types. */
printf ("%-Hf\n", x);
printf ("%+HF\n", x);
printf ("% He\n", x);
printf ("%#HE\n", x);
printf ("%0Hg\n", x);
printf ("%#0HG\n", x);
printf ("%0#Df\n", y);
printf ("%0DF\n", y);
printf ("%#De\n", y);
printf ("%-#DE\n", y);
printf ("%-#0Dg\n", y); /* { dg-warning "flag ignored" "ignore flag" } */
printf ("%0+ DG\n", y); /* { dg-warning "flag ignored" "ignore flag" } */
printf ("%DDf\n", z);
printf ("%0DDF\n", z);
printf ("%#0DDe\n", z);
printf ("%+DDE\n", z);
printf ("%0-#DDg\n", z); /* { dg-warning "flag ignored" "ignore flag" } */
printf ("% DDG\n", z);
}

View File

@ -0,0 +1,99 @@
/* Test for scanf formats for Decimal Floating Point types. */
/* { dg-do compile } */
/* { dg-require-effective-target dfp } */
/* { dg-options "-Wformat" } */
#include "format.h"
void
voo (_Decimal32 *x, _Decimal64 *y, _Decimal128 *z, int *i, unsigned int *j,
double *d, char **p)
{
/* See ISO/IEC DTR 24732 subclause 9.3 (currently Working Draft 5 from
2005-03-06). */
/* Formatted input/output specifiers. */
/* Check lack of warnings for valid usage. */
scanf ("%Hf", x);
scanf ("%HF", x);
scanf ("%He", x);
scanf ("%HE", x);
scanf ("%Hg", x);
scanf ("%HG", x);
scanf ("%Df", y);
scanf ("%DF", y);
scanf ("%De", y);
scanf ("%DE", y);
scanf ("%Dg", y);
scanf ("%DG", y);
scanf ("%DDf", z);
scanf ("%DDF", z);
scanf ("%DDe", z);
scanf ("%DDE", z);
scanf ("%DDg", z);
scanf ("%DDG", z);
scanf ("%DG%DDE%HF%DDe%He%HE%DF%DDF%De%DDG%HG%Df%Hg%DE%DDf%Dg%DDg%Hf\n",
y, z, x, z, x, x, y, z, y, z, x, y, x, y, z, y, z, x);
/* Check warnings for type mismatches. */
scanf ("%Hf", y); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%HF", y); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%He", y); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%HE", y); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%Hg", y); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%HG", y); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%Hf", z); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%HF", z); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%He", z); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%HE", z); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%Hg", z); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%HG", z); /* { dg-warning "expects type" "bad use of %H" } */
scanf ("%Df", x); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%DF", x); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%De", x); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%DE", x); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%Dg", x); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%DG", x); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%Df", z); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%DF", z); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%De", z); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%DE", z); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%Dg", z); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%DG", z); /* { dg-warning "expects type" "bad use of %D" } */
scanf ("%DDf", x); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDF", x); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDe", x); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDE", x); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDg", x); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDG", x); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDf", y); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDF", y); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDe", y); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDE", y); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDg", y); /* { dg-warning "expects type" "bad use of %DD" } */
scanf ("%DDG", y); /* { dg-warning "expects type" "bad use of %DD" } */
/* Check for warnings for bad use of H, D, and DD length specifiers. */
scanf ("%Hd\n", i); /* { dg-warning "length" "bad use of %H" } */
scanf ("%Hi\n", i); /* { dg-warning "length" "bad use of %H" } */
scanf ("%Ho\n", j); /* { dg-warning "length" "bad use of %H" } */
scanf ("%Hu\n", j); /* { dg-warning "length" "bad use of %H" } */
scanf ("%Hx\n", j); /* { dg-warning "length" "bad use of %H" } */
scanf ("%HX\n", j); /* { dg-warning "length" "bad use of %H" } */
scanf ("%Ha\n", d); /* { dg-warning "length" "bad use of %H" } */
scanf ("%HA\n", d); /* { dg-warning "length" "bad use of %H" } */
scanf ("%Hc\n", i); /* { dg-warning "length" "bad use of %H" } */
scanf ("%Hs\n", p); /* { dg-warning "length" "bad use of %H" } */
scanf ("%Hp\n", p); /* { dg-warning "length" "bad use of %H" } */
scanf ("%Hn\n", p); /* { dg-warning "length" "bad use of %H" } */
}

View File

@ -0,0 +1,6 @@
/* { dg-do compile { target {! dfp} } } */
/* { dg-options "-std=gnu99" } */
_Decimal32 x; /* { dg-error "not supported" "reject decimal float" } */
_Decimal64 y; /* { dg-error "not supported" "reject decimal float" } */
_Decimal128 z; /* { dg-error "not supported" "reject decimal float" } */

View File

@ -0,0 +1,531 @@
# Copyright 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.
# DejaGnu test driver around Mike Cowlishaw's testsuite for decimal
# decimal arithmetic ("dectest"). See:
# <http://www2.hursley.ibm.com/decimal/dectest.html>.
#
# Contributed by Ben Elliston <bje@au.ibm.com>.
set TORTURE_OPTIONS [list {} -O1 -O2 -O3 -msoft-float]
# On x86 and x86-64 systems, -Os makes the stack alignment too small,
# leading to segmentation faults when executing SSE instructions.
# Force the alignment of the stack to 2^4 (16) bytes.
if {[istarget i?86-*-linux-gnu] || [istarget x86_64-*-linux-gnu]} {
lappend TORTURE_OPTIONS {-Os -mpreferred-stack-boundary=4}
} else {
lappend TORTURE_OPTIONS {-Os}
}
proc target-specific-flags {} {
set result "-frounding-math "
return $result
}
# Load support procs (borrow these from c-torture).
load_lib c-torture.exp
load_lib target-supports.exp
# Skip these tests for targets that don't support this extension.
if { ![check_effective_target_dfp] } {
return
}
# The list format is [coefficient, max-exponent, min-exponent].
set properties(_Decimal32) [list 7 96 -95]
set properties(_Decimal64) [list 16 384 -383]
set properties(_Decimal128) [list 34 6144 -6143]
# Operations implemented by the compiler.
set operators(add) {+}
set operators(compare) {==}
set operators(divide) {/}
set operators(multiply) {*}
set operators(subtract) {-}
set operators(minus) {-}
set operators(plus) {+}
set operators(apply) {}
# Operations imlemented by the library.
set libfuncs(abs) fabsl
set libfuncs(squareroot) sqrtl
set libfuncs(max) fmaxl
set libfuncs(min) fminl
set libfuncs(quantize) quantize
set libfuncs(samequantum) samequantum
set libfuncs(power) powl
set libfuncs(toSci) unknown
set libfuncs(tosci) unknown
set libfuncs(toEng) unknown
set libfuncs(toeng) unknown
set libfuncs(divideint) unknown
set libfuncs(rescale) unknown
set libfuncs(remainder) unknown
set libfuncs(remaindernear) unknown
set libfuncs(normalize) unknown
set libfuncs(tointegral) unknown
set libfuncs(trim) unknown
# Run all of the tests listed in TESTCASES by invoking df-run-test on
# each. Skip tests that not included by the user invoking runtest
# with the foo.exp=test.c syntax.
proc dfp-run-tests { testcases } {
global runtests
foreach test $testcases {
# If we're only testing specific files and this isn't one of
# them, skip it.
if ![runtest_file_p $runtests $test] continue
dfp-run-test $test
}
}
# Run a single test case named by TESTCASE.
# Called for each test by dfp-run-tests.
proc dfp-run-test { testcase } {
set fd [open $testcase r]
while {[gets $fd line] != -1} {
switch -regexp -- $line {
{^[ \t]*--.*$} {
# Ignore comments.
}
{^[ \t]*$} {
# Ignore blank lines.
}
{^[ \t]*[^:]*:[^:]*} {
regsub -- {[ \t]*--.*$} $line {} line
process-directive $line
}
default {
process-test-case $testcase $line
}
}
}
close $fd
}
# Return the appropriate constant from <fenv.h> for MODE.
proc c-rounding-mode { mode } {
switch [string tolower $mode] {
"floor" { return 0 } # FE_DEC_DOWNWARD
"half_even" { return 1 } # FE_DEC_TONEARESTFROMZERO
"half_up" { return 2 } # FE_DEC_TONEAREST
"down" { return 3 } # FE_DEC_TOWARDZERO
"ceiling" { return 4 } # FE_DEC_UPWARD
}
error "unsupported rounding mode ($mode)"
}
# Return a string of C code that forms the preamble to perform the
# test named ID.
proc c-test-preamble { id } {
append result "/* Machine generated test case for $id */\n"
append result "\n"
append result "\#include <assert.h>\n"
append result "\#include <fenv.h>\n"
append result "\#include <math.h>\n"
append result "\n"
append result "int main ()\n"
append result "\{"
return $result
}
# Return a string of C code that forms the postable to the test named ID.
proc c-test-postamble { id } {
return "\}"
}
# Generate a C unary expression that applies OPERATION to OP.
proc c-unary-expression {operation op} {
global operators
global libfuncs
if [catch {set result "$operators($operation) $op"}] {
# If operation isn't in the operators or libfuncs arrays,
# we'll throw an error. That's what we want.
# FIXME: append d32, etc. here.
set result "$libfuncs($operation) ($op)"
}
return $result
}
# Generate a C binary expression that applies OPERATION to OP1 and OP2.
proc c-binary-expression {operation op1 op2} {
global operators
global libfuncs
if [catch {set result "$op1 $operators($operation) $op2"}] {
# If operation isn't in the operators or libfuncs arrays,
# we'll throw an error. That's what we want.
set result "$libfuncs($operation) ($op1, $op2)"
}
return $result
}
# Return the most appropriate C type (_Decimal32, etc) for this test.
proc c-decimal-type { } {
global directives
if [catch {set precision $directives(precision)}] {
set precision "_Decimal128"
}
if { $precision == 7 } {
set result "_Decimal32"
} elseif {$precision == 16} {
set result "_Decimal64"
} elseif {$precision == 34} {
set result "_Decimal128"
} else {
error "Unsupported precision"
}
return $result
}
# Return the size of the most appropriate C type, in bytes.
proc c-sizeof-decimal-type { } {
switch [c-decimal-type] {
"_Decimal32" { return 4 }
"_Decimal64" { return 8 }
"_Decimal128" { return 16 }
}
error "Unsupported precision"
}
# Return the right literal suffix for CTYPE.
proc c-type-suffix { ctype } {
switch $ctype {
"_Decimal32" { return "df" }
"_Decimal64" { return "dd" }
"_Decimal128" { return "dl" }
"float" { return "f" }
"long double" { return "l" }
}
return ""
}
proc nan-p { operand } {
if {[string match "NaN*" $operand] || [string match "-NaN*" $operand]} {
return 1
} else {
return 0
}
}
proc infinity-p { operand } {
if {[string match "Inf*" $operand] || [string match "-Inf*" $operand]} {
return 1
} else {
return 0
}
}
proc isnan-builtin-name { } {
set bits [expr [c-sizeof-decimal-type] * 8]
return "__builtin_isnand$bits"
}
proc isinf-builtin-name { } {
set bits [expr [c-sizeof-decimal-type] * 8]
return "__builtin_isinfd$bits"
}
# Return a string that declares a C union containing the decimal type
# and an unsigned char array of the right size.
proc c-union-decl { } {
append result " union {\n"
append result " [c-decimal-type] d;\n"
append result " unsigned char bytes\[[c-sizeof-decimal-type]\];\n"
append result " } u;"
return $result
}
proc transform-hex-constant {value} {
regsub \# $value {} value
regsub -all (\.\.) $value {0x\1, } bytes
return [list $bytes]
}
# Create a C program file (named using ID) containing a test for a
# binary OPERATION on OP1 and OP2 that expects RESULT and CONDITIONS.
proc make-c-test {testcase id operation result conditions op1 {op2 "NONE"}} {
global directives
set filename ${id}.c
set outfd [open $filename w]
puts $outfd [c-test-preamble $id]
puts $outfd [c-union-decl]
if {[string compare $result ?] != 0} {
if {[string index $result 0] == "\#"} {
puts $outfd " static unsigned char compare\[[c-sizeof-decimal-type]\] = [transform-hex-constant $result];"
}
}
if {[string compare $op2 NONE] == 0} {
if {[string index $op1 0] == "\#"} {
puts $outfd " static unsigned char fill\[[c-sizeof-decimal-type]\] = [transform-hex-constant $op1];"
}
}
puts $outfd ""
puts $outfd " /* FIXME: Set rounding mode with fesetround() once in libc. */"
puts $outfd " __dfp_set_round ([c-rounding-mode $directives(rounding)]);"
puts $outfd ""
# Build the expression to be tested.
if {[string compare $op2 NONE] == 0} {
if {[string index $op1 0] == "\#"} {
puts $outfd " memcpy (u.bytes, fill, [c-sizeof-decimal-type]);"
} else {
puts $outfd " u.d = [c-unary-expression $operation [c-operand $op1]];"
}
} else {
puts $outfd " u.d = [c-binary-expression $operation [c-operand $op1] [c-operand $op2]];"
}
# Test the result.
if {[string compare $result ?] != 0} {
# Not an undefined result ..
if {[string index $result 0] == "\#"} {
# Handle hex comparisons.
puts $outfd " return memcmp (u.bytes, compare, [c-sizeof-decimal-type]);"
} elseif {[nan-p $result]} {
puts $outfd " return ![isnan-builtin-name] (u.d);"
} elseif {[infinity-p $result]} {
puts $outfd " return ![isinf-builtin-name] (u.d);"
} else {
# Ordinary values.
puts $outfd " return !(u.d == [c-operand $result]);"
}
} else {
puts $outfd " return 0;"
}
puts $outfd [c-test-postamble $id]
close $outfd
return $filename
}
# Is the test supported for this target?
proc supported-p { id op } {
global directives
global libfuncs
# Ops that are unsupported. Many of these tests fail because they
# do not tolerate the C front-end rounding the value of floating
# point literals to suit the type of the constant. Otherwise, by
# treating the `apply' operator like C assignment, some of them do
# pass.
switch -- $op {
apply { return 0 }
}
# Ditto for the following miscellaneous tests.
switch $id {
addx1130 { return 0 }
addx1131 { return 0 }
addx1132 { return 0 }
addx1133 { return 0 }
addx1134 { return 0 }
addx1135 { return 0 }
addx1136 { return 0 }
addx1138 { return 0 }
addx1139 { return 0 }
addx1140 { return 0 }
addx1141 { return 0 }
addx1142 { return 0 }
addx1151 { return 0 }
addx1152 { return 0 }
addx1153 { return 0 }
addx1154 { return 0 }
addx1160 { return 0 }
addx690 { return 0 }
mulx263 { return 0 }
subx947 { return 0 }
}
if [info exist libfuncs($op)] {
# No library support for now.
return 0
}
if [catch {c-rounding-mode $directives(rounding)}] {
# Unsupported rounding mode.
return 0
}
if [catch {c-decimal-type}] {
# Unsupported precision.
return 0
}
return 1
}
# Break LINE into a list of tokens. Be sensitive to quoting.
# There has to be a better way to do this :-|
proc tokenize { line } {
set quoting 0
set tokens [list]
foreach char [split $line {}] {
if {!$quoting} {
if { [info exists token] && $char == " " } {
if {[string compare "$token" "--"] == 0} {
# Only comments remain.
return $tokens
}
lappend tokens $token
unset token
} else {
if {![info exists token] && $char == "'" } {
set quoting 1
} else {
if { $char != " " } {
append token $char
}
}
}
} else {
# Quoting.
if { $char == "'" } {
set quoting 0
if [info exists token] {
lappend tokens $token
unset token
} else {
lappend tokens {}
}
} else {
append token $char
}
}
}
# Flush any residual token.
if {[info exists token] && [string compare $token "--"]} {
lappend tokens $token
}
return $tokens
}
# Process a directive in LINE.
proc process-directive { line } {
global directives
set keyword [string tolower [string trim [lindex [split $line :] 0]]]
set value [string tolower [string trim [lindex [split $line :] 1]]]
set directives($keyword) $value
}
# Produce a C99-valid floating point literal.
proc c-operand {operand} {
set bits [expr 8 * [c-sizeof-decimal-type]]
switch -glob -- $operand {
"Inf*" { return "__builtin_infd${bits} ()" }
"-Inf*" { return "- __builtin_infd${bits} ()" }
"NaN*" { return "__builtin_nand${bits} (\"\")" }
"-NaN*" { return "- __builtin_nand${bits} (\"\")" }
"sNaN*" { return "__builtin_nand${bits} (\"\")" }
"-sNaN*" { return "- __builtin_nand${bits} (\"\")" }
}
if {[string first . $operand] < 0 && \
[string first E $operand] < 0 && \
[string first e $operand] < 0} {
append operand .
}
set suffix [c-type-suffix [c-decimal-type]]
return [append operand $suffix]
}
# Process an arithmetic test in LINE from TESTCASE.
proc process-test-case { testcase line } {
set testfile [file tail $testcase]
# Compress multiple spaces down to one.
regsub -all { *} $line { } line
set args [tokenize $line]
if {[llength $args] < 5} {
error "Skipping invalid test: $line"
return
}
set id [string trim [lindex $args 0]]
set operation [string trim [lindex $args 1]]
set operand1 [string trim [lindex $args 2]]
if { [string compare [lindex $args 3] -> ] == 0 } {
# Unary operation.
set operand2 NONE
set result_index 4
set cond_index 5
} else {
# Binary operation.
set operand2 [string trim [lindex $args 3]]
if { [string compare [lindex $args 4] -> ] != 0 } {
warning "Skipping invalid test: $line"
return
}
set result_index 5
set cond_index 6
}
set result [string trim [lindex $args $result_index]]
set conditions [list]
for { set i $cond_index } { $i < [llength $args] } { incr i } {
lappend conditions [string tolower [lindex $args $i]]
}
# If this test is unsupported, say so.
if ![supported-p $id $operation] {
unsupported "$testfile ($id)"
return
}
if {[string compare $operand1 \#] == 0 || \
[string compare $operand2 \#] == 0} {
unsupported "$testfile ($id), null reference"
return
}
# Construct a C program and then compile/execute it on the target.
# Grab some stuff from the c-torture.exp test driver for this.
set cprog [make-c-test $testfile $id $operation $result $conditions $operand1 $operand2]
c-torture-execute $cprog [target-specific-flags]
}
### Script mainline:
if [catch {set testdir $env(DECTEST)}] {
# If $DECTEST is unset, skip this test driver altogether.
return
}
note "Using tests in $testdir"
dfp-run-tests [lsort [glob -nocomplain $testdir/*.decTest]]
unset testdir

View File

@ -0,0 +1,110 @@
# Copyright (C) 2002, 2003, 2005, 02005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Please email any bugs, comments, and/or additions to this file to:
# gcc-patches@gcc.gnu.org
# Globals.
global compat_use_alt
global compat_same_alt
global compat_have_dfp
global compat_skip_list
# This file defines procs for determining features supported by both C
# compilers for compatibility tests.
load_lib target-supports.exp
#
# compat-use-alt-compiler -- make the alternate compiler the default
#
proc compat-use-alt-compiler { } {
global GCC_UNDER_TEST ALT_CC_UNDER_TEST
global compat_same_alt
# We don't need to do this if the alternate compiler is actually
# the same as the compiler under test.
if { $compat_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 compat_save_gcc_under_test
global compat_same_alt
# We don't need to do this if the alternate compiler is actually
# the same as the compiler under test.
if { $compat_same_alt == 0 } then {
set GCC_UNDER_TEST $compat_save_gcc_under_test
}
}
# Find out whether both compilers support decimal float types.
proc compat_setup_dfp { } {
global compat_use_alt
global compat_same_alt
global compat_have_dfp
verbose "compat_setup_dfp: $compat_use_alt $compat_same_alt" 2
set compat_have_dfp 1
# If there is an alternate compiler, does it support decimal float types?
if { $compat_use_alt == 1 && $compat_same_alt == 0 } {
compat-use-alt-compiler
set compat_have_dfp [check_dfp]
compat-use-tst-compiler
verbose "compat_have_dfp for alt compiler: $compat_have_dfp" 2
}
# Does the compiler under test support it?
if { $compat_have_dfp == 1 } {
set compat_have_dfp [check_dfp]
verbose "compat_have_dfp for tst compiler: $compat_have_dfp" 2
}
# If decimal float is not supported, add it to the skip list, which
# affects code in the header files.
if { $compat_have_dfp == 0 } {
global compat_skip_list
lappend compat_skip_list "DECIMAL_FLOAT"
}
}
# Return 1 if the compiler supports decimal float types, 0 otherwise.
#
# Don't use check_effective_target since this will differ depending
# on the compiler, not the target.
#
proc check_dfp { } {
set result [string match "" [get_compiler_messages dfp2 object {
_Decimal32 x; _Decimal64 y; _Decimal128 z;
}]]
return $result
}
# If either compiler does not support decimal float types, skip this test.
proc dg-require-compat-dfp { args } {
global compat_have_dfp
if { $compat_have_dfp == 0 } {
upvar dg-do-what dg-do-what
set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
}
}

View File

@ -1,4 +1,4 @@
# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
# Copyright (C) 2002, 2003, 2004, 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
@ -62,7 +62,8 @@ if ![info exists COMPAT_SKIPS] {
set COMPAT_SKIPS [list {}]
}
set skip_list $COMPAT_SKIPS
global compat_skip_list
set compat_skip_list $COMPAT_SKIPS
load_lib dg.exp
load_lib gcc-dg.exp
@ -81,10 +82,10 @@ proc compat-obj { source dest optall optfile optstr xfaildata } {
global testcase
global tool
global compiler_conditional_xfail_data
global skip_list
global compat_skip_list
# Add the skip specifiers.
foreach skip $skip_list {
foreach skip $compat_skip_list {
if { ![string match $skip ""] } {
lappend optall "-DSKIP_$skip"
}

View File

@ -1055,6 +1055,25 @@ proc check_effective_target_lp64 { } {
return $et_lp64_saved
}
# Return 1 if the target supports Decimal Floating Point, 0 otherwise.
#
# This won't change for different subtargets so cache the result.
proc check_effective_target_dfp { } {
global et_dfp_saved
if [info exists et_dfp_saved] {
verbose "check_effective_target_dfp: using cached result" 2
} else {
verbose "check_effective_target_dfp: compiling source" 2
set et_dfp_saved [string match "" [get_compiler_messages dfp object {
_Decimal32 x; _Decimal64 y; _Decimal128 z;
}]]
}
verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
return $et_dfp_saved
}
# Return 1 if the target needs a command line argument to enable a SIMD
# instruction set.
#