OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/gnu-dev/or1k-gcc/gcc/testsuite/c-c++-common
    from Rev 685 to Rev 686
    Reverse comparison

Rev 685 → Rev 686

/cpp/warning-directive-1.c
0,0 → 1,4
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option" { target c } }
// { dg-options "-fdiagnostics-show-option" { target c++ } }
#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." }
/cpp/warning-directive-2.c
0,0 → 1,5
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror=cpp" { target c } }
// { dg-options "-fdiagnostics-show-option -Werror=cpp" { target c++ } }
/* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */
#warning "Printed" // { dg-error "\"Printed\" .-Werror=cpp." }
/cpp/normalize-3.c
0,0 → 1,35
/* { dg-do preprocess } */
/* { dg-options "-std=c99 -fextended-identifiers -Wnormalized=id" { target c } } */
/* { dg-options "-fextended-identifiers -Wnormalized=id" { target c++ } } */
 
\u00AA
\u00B7
\u0F43 /* { dg-warning "not in NFC" } */
a\u05B8\u05B9\u05B9\u05BBb
a\u05BB\u05B9\u05B8\u05B9b /* { dg-warning "not in NFC" } */
\u09CB
\u09C7\u09BE /* { dg-warning "not in NFC" } */
\u0B4B
\u0B47\u0B3E /* { dg-warning "not in NFC" } */
\u0BCA
\u0BC6\u0BBE /* { dg-warning "not in NFC" } */
\u0BCB
\u0BC7\u0BBE /* { dg-warning "not in NFC" } */
\u0CCA
\u0CC6\u0CC2 /* { dg-warning "not in NFC" } */
\u0D4A
\u0D46\u0D3E /* { dg-warning "not in NFC" } */
\u0D4B
\u0D47\u0D3E /* { dg-warning "not in NFC" } */
 
K
\u212A
 
\u03AC
\u1F71 /* { dg-warning "not in NFC" } */
 
\uAC00
\u1100\u1161
\uAC01
\u1100\u1161\u11A8
\uAC00\u11A8
/cpp/warning-directive-3.c
0,0 → 1,4
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Werror -Wno-error=cpp" { target c } }
// { dg-options "-fdiagnostics-show-option -Werror -Wno-error=cpp" { target c++ } }
#warning "Printed" // { dg-warning "\"Printed\" .-Wcpp." }
/cpp/warning-directive-4.c
0,0 → 1,4
// { dg-do preprocess }
// { dg-options "-std=gnu99 -fdiagnostics-show-option -Wno-cpp" { target c } }
// { dg-options "-fdiagnostics-show-option -Wno-cpp" { target c++ } }
#warning "Not printed" // { dg-bogus "." }
/cpp/pr45457.c
0,0 → 1,18
/* PR preprocessor/45457 */
/* { dg-do compile } */
 
const char *a =
#ifdef __DBL_DENORM_MIN__
"a"
#endif
#if defined(__DBL_EPSILON__)
"b"
#endif
#ifndef __DBL_MAX__
"c"
#endif
#if !defined(__DBL_MIN__)
"d"
#endif
;
double b = __DBL_DENORM_MIN__ + __DBL_EPSILON__ + __DBL_MAX__ + __DBL_MIN__;
/fmax-errors.c
0,0 → 1,11
/* PR c/44782 */
/* { dg-do compile } */
/* { dg-options "-fmax-errors=3" } */
 
void foo (unsigned int i, unsigned int j)
{
(i) (); /* { dg-error "" } */
(j) (); /* { dg-error "" } */
(i+j) (); /* { dg-error "" } */
(i*j) (); /* no error here due to -fmax-errors */
} /* { dg-prune-output "compilation terminated" } */
/Wint-to-pointer-cast-1.c
0,0 → 1,12
/* Test -Wint-to-pointer-cast - on by default. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "" } */
 
char c;
 
void *
f (void)
{
return (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */
}
/uninit-G-O0.c
0,0 → 1,9
/* Test we do not warn about initializing variable with address of self in the initialization. */
/* { dg-do compile } */
/* { dg-options "-Wuninitialized" } */
 
void *f()
{
void *i = &i;
return i;
}
/Wint-to-pointer-cast-3.c
0,0 → 1,22
/* Test -Wno-int-to-pointer-cast. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wno-int-to-pointer-cast" } */
 
char c;
 
void *
f (void)
{
return (void *) c;
}
 
void *p;
 
char
g (void)
{
return (char) p;
/* { dg-warning "cast from pointer to integer of different size" "" { target c } 19 } */
/* { dg-error "cast from 'void\\*' to 'char' loses precision" "" { target c++ } 19 } */
}
/asmgoto-2.c
0,0 → 1,20
/* { dg-do compile } */
/* { dg-options "" } */
 
void
foo (void)
{
__label__ lab;
int i = 0;
asm goto ("" : : : : lab);
asm goto ("" : "=r" (i) : : : lab); /* { dg-error "expected" } */
asm goto ("" : : : : ); /* { dg-error "expected" } */
asm goto ("" : : : "memory"); /* { dg-error "expected" } */
asm goto ("" : : : ); /* { dg-error "expected" } */
asm goto ("" : : "r" (i)); /* { dg-error "expected" } */
asm goto ("" : : ); /* { dg-error "expected" } */
asm goto ("" : "=r" (i)); /* { dg-error "expected" } */
asm goto ("" : ); /* { dg-error "expected" } */
asm goto (""); /* { dg-error "expected" } */
lab:;
}
/asmgoto-4.c
0,0 → 1,44
/* PR middle-end/44071 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
 
static inline int
f1 (void)
{
asm goto ("" : : : : l1, l2);
__builtin_unreachable ();
l1:
return 1;
l2:
return 0;
}
 
int
b1 (int x)
{
if (f1 () || x == 6)
x = 1;
else
x = 2;
return x;
}
 
static inline int
f2 (void)
{
asm goto ("" : : : : l1, l2);
l1:
return 1;
l2:
return 0;
}
 
int
b2 (int x)
{
if (f2 () || x == 6)
x = 1;
else
x = 2;
return x;
}
/raw-string-11.c
0,0 → 1,13
// PR preprocessor/48740
// { dg-options "-std=gnu99 -trigraphs -save-temps" { target c } }
// { dg-options "-std=c++0x -save-temps" { target c++ } }
// { dg-do run }
 
int main ()
{
return __builtin_memcmp (R"raw(foo%sbar%sfred%sbob?????)raw",
"foo%sbar%sfred%sbob?""?""?""?""?",
sizeof ("foo%sbar%sfred%sbob?""?""?""?""?"));
}
 
// { dg-final { cleanup-saved-temps } }
/builtin-offsetof.c
0,0 → 1,29
// Contributed by Dodji Seketeli <dodji@redhat.com>
// Origin PR c++/38699
// { dg-options "-Warray-bounds" }
// { dg-do compile }
 
struct A
{
const char *p;
};
 
struct B
{
char p[10];
struct A a;
};
 
void
f0 ()
{
__builtin_offsetof(struct A, p); // OK
__builtin_offsetof(struct A, p[0]); // { dg-error "non constant address" }
__builtin_offsetof(struct B, p[0]); // OK
__builtin_offsetof(struct B, p[9]); // OK
__builtin_offsetof(struct B, p[10]); // OK
__builtin_offsetof(struct B, p[11]); // { dg-warning "greater than size" }
__builtin_offsetof(struct B, a.p); // OK
__builtin_offsetof(struct B, p[0]); // OK
__builtin_offsetof(struct B, a.p[0]); // { dg-error "non constant address" }
}
/Wunused-var-2.c
0,0 → 1,20
/* { dg-do compile } */
/* { dg-options "-Wunused" } */
 
int
f1 (void)
{
int c = ({
int a;
a = 1;
a; });
return c;
}
 
void
f2 (void)
{
int f;
f = 0;
__asm__ __volatile__ ("" : "+r" (f));
}
/vla-1.c
0,0 → 1,21
/* Test that changes to a variable are reflected in a VLA later in the
expression. */
/* { dg-options "" } */
 
#ifdef __cplusplus
extern "C"
#endif
void abort();
 
int i = 4;
int f()
{
return i;
}
 
int main()
{
if (i+=2, sizeof(*(int(*)[f()])0) != 6*sizeof(int))
abort();
return 0;
}
/Wunused-var-4.c
0,0 → 1,29
/* { dg-do compile } */
/* { dg-options "-Wunused -W" } */
 
int
f1 (unsigned int x)
{
int c = ({ union { unsigned int a; int b; } u; u.a = x; u.b; });
return c;
}
 
void
f2 (void)
{
struct S { int i; } a;
int b[1];
a.i = 1;
a.i; /* { dg-warning "no effect" } */
b[0] = 1;
b[0]; /* { dg-warning "no effect" } */
}
 
void
f3 (void)
{
struct S { int i; } a; /* { dg-warning "set but not used" } */
int b[1]; /* { dg-warning "set but not used" } */
a.i = 1;
b[0] = 1;
}
/Wunused-var-6.c
0,0 → 1,15
/* PR c/43981 */
/* { dg-do compile } */
/* { dg-options "-Wunused" } */
 
void g (char *);
 
char
f (int a)
{
int len = a * 3;
char t[len];
 
g (t);
return t[0];
}
/pr36513.c
0,0 → 1,15
/* PR 36513: -Wlogical-op warns about strchr */
/* { dg-do compile } */
/* { dg-options "-Wlogical-op" } */
 
extern void *__rawmemchr (const void *__s, int __c);
int main1 ()
{
char *s, t;
(__extension__ (__builtin_constant_p (t)
&& !__builtin_constant_p (s)
&& (t) == '\0'
? (char *) __rawmemchr (s, t)
: __builtin_strchr (s, t)));
}
 
/int128-2.c
0,0 → 1,157
/* { dg-do run { target int128 } } */
/* { dg-options "-std=gnu99" { target c } } */
/* { dg-options "" { target c++ } } */
 
#ifndef __cplusplus
extern void abort (void);
#else
extern "C" void abort (void);
#endif
 
#define MK_CONST128(A,B,C,D) \
( (((unsigned __int128) (unsigned int) A) << 96) \
| (((unsigned __int128) (unsigned int) B) << 64) \
| (((unsigned __int128) (unsigned int) C) << 32) \
| ((unsigned __int128) (unsigned int) D) )
 
#define MK_CONST128_SIGNED(A,B,C,D) \
((__int128) MK_CONST128(A, B, C, D))
 
#define MINUS_2 MK_CONST128_SIGNED (0xffffffffu, 0xffffffffu, 0xffffffffu, \
0xfffffffeu)
#define MINUS_3 MK_CONST128_SIGNED (0xffffffffu, 0xffffffffu, 0xffffffffu, \
0xfffffffdu)
#define MINUS_6 MK_CONST128_SIGNED (0xffffffffu, 0xffffffffu, 0xffffffffu, \
0xfffffffau)
#define PLUS_1 MK_CONST128_SIGNED (0, 0, 0, 1)
#define PLUS_2 MK_CONST128_SIGNED (0, 0, 0, 2)
#define PLUS_3 MK_CONST128_SIGNED (0, 0, 0, 3)
#define PLUS_6 MK_CONST128_SIGNED (0, 0, 0, 6)
#define PLUS_10 MK_CONST128_SIGNED (0, 0, 0, 10)
 
#define U_8 MK_CONST128 (0, 0, 0, 8)
#define U_MAX MK_CONST128 (0xffffffff,0xffffffff,0xffffffff,0xffffffff)
#define U_CST1 MK_CONST128 (0xbeeffeed, 0xdeafcafe, 0xaffefade, 0x12345678)
#define U_CST2 MK_CONST128 (0x41100112, 0x21503501, 0x50010521, 0xedcba987)
 
signed __int128 foo_neg (signed __int128 v)
{
return -v;
}
 
unsigned __int128 foo_xor (unsigned __int128 x, unsigned __int128 y)
{
return x ^ y;
}
 
unsigned __int128 foo_inv (unsigned __int128 v)
{
return ~v;
}
 
unsigned __int128 foo_rotate_left (unsigned __int128 v)
{
unsigned __int128 c;
int i;
for (i = 0; i < 128; i++)
{
c = v >> 127;
v <<= 1;
v |= c;
}
return v;
}
 
unsigned __int128 foo_rotate_right (unsigned __int128 v)
{
unsigned __int128 c;
int i;
for (i = 0; i < 128; i++)
{
c = (v & ((unsigned __int128) 1)) << 127;
v >>= 1;
v |= c;
}
return v;
}
 
void foo_swap (unsigned __int128 *x, unsigned __int128 *y)
{
unsigned __int128 x1 = x[0];
unsigned __int128 y1 = y[0];
x1 ^= y1 ^= x1 ^= y1;
x[0] = x1;
y[0] = y1;
}
 
__int128 foo_add (signed __int128 a, unsigned __int128 b)
{
return (__int128) (a + (__int128) b);
}
 
__int128 foo_sub (unsigned __int128 a, signed __int128 b)
{
return (__int128) ((__int128) a - b);
}
 
__int128 foo_mul (signed __int128 a, signed __int128 b)
{
return a * b;
}
 
__int128 foo_div (signed __int128 a, signed __int128 b)
{
return a / b;
}
 
__int128 foo_shl (signed __int128 a, int shift)
{
return a << (shift & 127);
}
 
__int128 foo_shr (signed __int128 a, int shift)
{
return a >> (shift & 127);
}
 
int main(void)
{
__int128 rslt;
unsigned __int128 u1, u2;
 
rslt = foo_add (MINUS_2, U_8);
if (rslt != PLUS_6)
abort ();
rslt = foo_sub (U_8, MINUS_2);
if (rslt != PLUS_10)
abort ();
rslt = foo_sub ((unsigned __int128) foo_mul (MINUS_2, MINUS_2), MINUS_2);
if (rslt != PLUS_6)
abort ();
if (rslt != foo_shl (PLUS_3, 1))
abort ();
rslt = foo_shl (MINUS_3, 1);
if (rslt != MINUS_6)
abort ();
if (foo_shr (MINUS_6, 1) != MINUS_3)
abort ();
if (foo_div (MINUS_6, MINUS_3) != PLUS_2)
abort ();
if (foo_rotate_left (U_CST1) != U_CST1)
abort ();
if (foo_rotate_right (U_CST1) != U_CST1)
abort ();
u1 = U_CST1;
u2 = U_8;
foo_swap (&u1, &u2);
if (u1 != U_8 || u2 != U_CST1)
abort ();
 
if (foo_inv (U_CST2) != U_CST1)
abort ();
if (foo_neg (PLUS_2) != MINUS_2)
abort ();
if (foo_neg ((signed __int128) U_CST1) != foo_add (PLUS_1, foo_xor (U_CST1, U_MAX)))
abort ();
return 0;
}
/Wunused-var-8.c
0,0 → 1,19
/* Origin: PR c++/44108 */
/* { dg-options "-Wunused" } */
/* { dg-do compile } */
 
int
foo ()
{
unsigned int M = 2;
const unsigned int M_CONST = 2;
static unsigned int M_STATIC = 2;
static const unsigned int M_STATIC_CONST = 2;
 
char n1[M];
char n2[M_CONST];
char n3[M_STATIC];
char n4[M_STATIC_CONST];
 
return sizeof (n1) + sizeof (n2) + sizeof (n3) + sizeof (n4);
}
/pr44832.c
0,0 → 1,162
/* PR debug/44832 */
/* { dg-do compile } */
/* { dg-options "-O2 -fcompare-debug" } */
/* { dg-options "-O2 -fcompare-debug -fno-short-enums" {target short_enums} } */
/* { dg-require-effective-target int32plus } */
 
struct rtx_def;
typedef struct rtx_def *rtx;
typedef const struct rtx_def *const_rtx;
struct rtvec_def;
typedef struct rtvec_def *rtvec;
extern int ix86_isa_flags;
 
enum machine_mode
{
VOIDmode,
V8HImode,
V16QImode,
V4SImode,
V2DImode,
V32QImode,
MAX_MACHINE_MODE,
 
NUM_MACHINE_MODES = MAX_MACHINE_MODE
};
extern unsigned char mode_size[NUM_MACHINE_MODES];
extern const unsigned char mode_inner[NUM_MACHINE_MODES];
extern const unsigned char mode_nunits[NUM_MACHINE_MODES];
enum rtx_code {
 
CONST_INT ,
 
CONST_FIXED ,
 
CONST_DOUBLE
 
};
union rtunion_def
{
rtvec rt_rtvec;
};
typedef union rtunion_def rtunion;
struct rtx_def {
 
__extension__ enum rtx_code code: 16;
 
__extension__ enum machine_mode mode : 8;
 
union u {
rtunion fld[1];
} u;
};
struct rtvec_def {
rtx elem[1];
};
extern int rtx_equal_p (const_rtx, const_rtx);
extern rtx gen_reg_rtx (enum machine_mode);
 
extern void
ix86_expand_vector_init_concat (enum machine_mode mode,
rtx target, rtx *ops, int n);
 
static void
ix86_expand_vector_init_general (unsigned char mmx_ok, enum machine_mode mode,
rtx target, rtx vals)
{
rtx ops[32], op0, op1;
enum machine_mode half_mode = VOIDmode;
int n, i;
 
switch (mode)
{
case V4SImode:
case V2DImode:
n = mode_nunits[mode];
ix86_expand_vector_init_concat (mode, target, ops, n);
return;
 
case V32QImode:
goto half;
half:
{
typedef int eger;
if (mode != V4SImode)
ops[0] = 0;
}
n = mode_nunits[mode];
for (i = 0; i < n; i++)
ops[i] = (((((vals)->u.fld[0]).rt_rtvec))->elem[i]);
op0 = gen_reg_rtx (VOIDmode);
return;
 
case V16QImode:
if (!((ix86_isa_flags & (1 << 19)) != 0))
break;
 
case V8HImode:
if (!((ix86_isa_flags & (1 << 17)) != 0))
break;
 
n = mode_nunits[mode];
for (i = 0; i < n; i++)
ops[i] = (((((vals)->u.fld[0]).rt_rtvec))->elem[i]);
return;
 
default:
;
}
 
{
int n_words;
 
n_words = ((unsigned short) mode_size[mode]) / 4;
 
if (n_words == 4)
ix86_expand_vector_init_general (0, V4SImode, 0, 0);
}
}
 
 
void
ix86_expand_vector_init (unsigned char mmx_ok, rtx target, rtx vals)
{
enum machine_mode mode = ((enum machine_mode) (target)->mode);
enum machine_mode inner_mode = ((enum machine_mode) mode_inner[mode]);
int n_elts = mode_nunits[mode];
int n_var = 0, one_var = -1;
unsigned char all_same = 1, all_const_zero = 1;
int i;
rtx x;
 
for (i = 0; i < n_elts; ++i)
{
x = (((((vals)->u.fld[0]).rt_rtvec))->elem[i]);
if (!((((enum rtx_code) (x)->code) == CONST_INT)
|| ((enum rtx_code) (x)->code) == CONST_DOUBLE
|| ((enum rtx_code) (x)->code) == CONST_FIXED))
n_var++, one_var = i;
else
all_const_zero = 0;
if (i > 0 && !rtx_equal_p (x, (((((vals)->u.fld[0]).rt_rtvec))->elem[0])))
all_same = 0;
}
 
 
if (n_var == 0)
{
return;
}
 
if (all_same)
return;
 
if (n_var == 1)
{
if (all_const_zero)
return;
 
}
 
ix86_expand_vector_init_general (mmx_ok, mode, target, vals);
}
/uninit-E.c
0,0 → 1,9
/* Test we do warn about initializing variable with self when -Winit-self is supplied. */
/* { dg-do compile } */
/* { dg-options "-O -Wuninitialized -Winit-self" } */
 
int f()
{
int i = i; /* { dg-warning "i" "uninitialized variable warning" } */
return i;
}
/uninit-G.c
0,0 → 1,9
/* Test we do not warn about initializing variable with address of self in the initialization. */
/* { dg-do compile } */
/* { dg-options "-O -Wuninitialized" } */
 
void *f()
{
void *i = &i;
return i;
}
/uninit-17.c
0,0 → 1,25
/* { dg-do compile } */
/* { dg-options "-O2 -Wuninitialized -fno-ivopts" } */
 
inline int foo(int x)
{
return x;
}
static void bar(int a, int *ptr)
{
do
{
int b; /* { dg-message "declared" } */
if (b < 40) {
ptr[0] = b;
}
b += 1; /* { dg-warning "may be used uninitialized" } */
ptr++;
}
while (--a != 0);
}
void foobar(int a, int *ptr)
{
bar(foo(a), ptr);
}
 
/raw-string-1.c
0,0 → 1,141
// { dg-do run }
// { dg-require-effective-target wchar }
// { dg-options "-std=gnu99 -Wno-c++-compat -trigraphs" { target c } }
// { dg-options "-std=c++0x" { target c++ } }
 
#ifndef __cplusplus
#include <wchar.h>
 
typedef __CHAR16_TYPE__ char16_t;
typedef __CHAR32_TYPE__ char32_t;
#endif
 
const char s0[] = R"(a\
\u010d\U0000010D\\\'\"\?\a\b\f\n\r\t\v\0\00\000\xa\xabb
c)";
const char s1[] = "a\\\n\\u010d\\U0000010D\\\\\\'\\\"\\?\\a\\b\\f\\n\\r\\t\\v\\0\\00\\000\\xa\\xabb\nc";
const char s2[] = R"*|*(a\
b
c)"
c)*|"
c)*|*";
const char s3[] = "a\\\nb\nc)\"\nc)*|\"\nc";
// The ) in ??) below is part of the raw string suffix )".
const char s4[] = R"(??/
??/
??(??<??=??'??!??-??>??)";
const char s5[] = "?\?/\n?\?/\n?\?(?\?<?\?=?\?'?\?!?\?-?\?>?\?";
 
const char t0[] = u8R"(a\
\u010d\U0000010D\\\'\"\?\a\b\f\n\r\t\v\0\00\000\xa\xabb
c)";
const char t1[] = u8"a\\\n\\u010d\\U0000010D\\\\\\'\\\"\\?\\a\\b\\f\\n\\r\\t\\v\\0\\00\\000\\xa\\xabb\nc";
const char t2[] = u8R"*|*(a\
b
c)"
c)*|"
c)*|*";
const char t3[] = u8"a\\\nb\nc)\"\nc)*|\"\nc";
const char t4[] = u8R"(??/
??/
??(??<??=??'??!??-??>??)";
const char t5[] = u8"?\?/\n?\?/\n?\?(?\?<?\?=?\?'?\?!?\?-?\?>?\?";
 
const char16_t u0[] = uR"(a\
\u010d\U0000010D\\\'\"\?\a\b\f\n\r\t\v\0\00\000\xa\xabb
c)";
const char16_t u1[] = u"a\\\n\\u010d\\U0000010D\\\\\\'\\\"\\?\\a\\b\\f\\n\\r\\t\\v\\0\\00\\000\\xa\\xabb\nc";
const char16_t u2[] = uR"*|*(a\
b
c)"
c)*|"
c)*|*";
const char16_t u3[] = u"a\\\nb\nc)\"\nc)*|\"\nc";
const char16_t u4[] = uR"(??/
??/
??(??<??=??'??!??-??>??)";
const char16_t u5[] = u"?\?/\n?\?/\n?\?(?\?<?\?=?\?'?\?!?\?-?\?>?\?";
 
const char32_t U0[] = UR"(a\
\u010d\U0000010D\\\'\"\?\a\b\f\n\r\t\v\0\00\000\xa\xabb
c)";
const char32_t U1[] = U"a\\\n\\u010d\\U0000010D\\\\\\'\\\"\\?\\a\\b\\f\\n\\r\\t\\v\\0\\00\\000\\xa\\xabb\nc";
const char32_t U2[] = UR"*|*(a\
b
c)"
c)*|"
c)*|*";
const char32_t U3[] = U"a\\\nb\nc)\"\nc)*|\"\nc";
const char32_t U4[] = UR"(??/
??/
??(??<??=??'??!??-??>??)";
const char32_t U5[] = U"?\?/\n?\?/\n?\?(?\?<?\?=?\?'?\?!?\?-?\?>?\?";
 
const wchar_t L0[] = LR"(a\
\u010d\U0000010D\\\'\"\?\a\b\f\n\r\t\v\0\00\000\xa\xabb
c)";
const wchar_t L1[] = L"a\\\n\\u010d\\U0000010D\\\\\\'\\\"\\?\\a\\b\\f\\n\\r\\t\\v\\0\\00\\000\\xa\\xabb\nc";
const wchar_t L2[] = LR"*|*(a\
b
c)"
c)*|"
c)*|*";
const wchar_t L3[] = L"a\\\nb\nc)\"\nc)*|\"\nc";
const wchar_t L4[] = LR"(??/
??/
??(??<??=??'??!??-??>??)";
const wchar_t L5[] = L"?\?/\n?\?/\n?\?(?\?<?\?=?\?'?\?!?\?-?\?>?\?";
 
int
main (void)
{
if (sizeof (s0) != sizeof (s1)
|| __builtin_memcmp (s0, s1, sizeof (s0)) != 0)
__builtin_abort ();
if (sizeof (s2) != sizeof (s3)
|| __builtin_memcmp (s2, s3, sizeof (s2)) != 0)
__builtin_abort ();
if (sizeof (s4) != sizeof (s5)
|| __builtin_memcmp (s4, s5, sizeof (s4)) != 0)
__builtin_abort ();
if (sizeof (t0) != sizeof (t1)
|| __builtin_memcmp (t0, t1, sizeof (t0)) != 0)
__builtin_abort ();
if (sizeof (t2) != sizeof (t3)
|| __builtin_memcmp (t2, t3, sizeof (t2)) != 0)
__builtin_abort ();
if (sizeof (t4) != sizeof (t5)
|| __builtin_memcmp (t4, t5, sizeof (t4)) != 0)
__builtin_abort ();
if (sizeof (u0) != sizeof (u1)
|| __builtin_memcmp (u0, u1, sizeof (u0)) != 0)
__builtin_abort ();
if (sizeof (u2) != sizeof (u3)
|| __builtin_memcmp (u2, u3, sizeof (u2)) != 0)
__builtin_abort ();
if (sizeof (u4) != sizeof (u5)
|| __builtin_memcmp (u4, u5, sizeof (u4)) != 0)
__builtin_abort ();
if (sizeof (U0) != sizeof (U1)
|| __builtin_memcmp (U0, U1, sizeof (U0)) != 0)
__builtin_abort ();
if (sizeof (U2) != sizeof (U3)
|| __builtin_memcmp (U2, U3, sizeof (U2)) != 0)
__builtin_abort ();
if (sizeof (U4) != sizeof (U5)
|| __builtin_memcmp (U4, U5, sizeof (U4)) != 0)
__builtin_abort ();
if (sizeof (L0) != sizeof (L1)
|| __builtin_memcmp (L0, L1, sizeof (L0)) != 0)
__builtin_abort ();
if (sizeof (L2) != sizeof (L3)
|| __builtin_memcmp (L2, L3, sizeof (L2)) != 0)
__builtin_abort ();
if (sizeof (L4) != sizeof (L5)
|| __builtin_memcmp (L4, L5, sizeof (L4)) != 0)
__builtin_abort ();
if (sizeof (R"*()*") != 1
|| __builtin_memcmp (R"*()*", "", 1) != 0)
__builtin_abort ();
return 0;
}
/pr51768.c
0,0 → 1,25
/* PR middle-end/51768 */
/* { dg-do compile } */
/* { dg-options "" } */
 
void
foo (void)
{
asm goto ("" : : : : lab, lab, lab2, lab); /* { dg-error "duplicate asm operand name" } */
lab:;
lab2:;
}
 
void
bar (void)
{
asm goto ("" : : [lab] "i" (0) : : lab); /* { dg-error "duplicate asm operand name" } */
lab:;
}
 
void
baz (void)
{
int x;
asm ("" : [lab] "=r" (x) : [lab] "r" (x)); /* { dg-error "duplicate asm operand name" } */
}
/guality/pr43141.c
0,0 → 1,16
/* { dg-do run } */
/* { dg-options "-g" } */
 
int i;
static int f(int) __attribute ((noinline));
static int f(int x)
{
return i;
}
 
int main()
{
return f(42);
}
 
/* { dg-final { gdb-test 8 "sizeof (x)" "sizeof (int)" } } */
/raw-string-3.c
0,0 → 1,59
// If not c++0x/gnu99, the {,u,u8,U,L}R prefix should be parsed as separate
// token.
// { dg-do compile }
// { dg-options "" { target c } }
// { dg-options "-std=c++98" { target c++ } }
 
const void *s0 = R"(a)"; // { dg-error "was not declared|undeclared" }
// { dg-error "expected ',' or ';'" "" { target *-*-* } 7 }
const void *s1 = uR"(a)"; // { dg-error "was not declared|undeclared" }
// { dg-error "expected ',' or ';'" "" { target *-*-* } 9 }
const void *s2 = UR"(a)"; // { dg-error "was not declared|undeclared" }
// { dg-error "expected ',' or ';'" "" { target *-*-* } 11 }
const void *s3 = u8R"(a)"; // { dg-error "was not declared|undeclared" }
// { dg-error "expected ',' or ';'" "" { target *-*-* } 13 }
const void *s4 = LR"(a)"; // { dg-error "was not declared|undeclared" }
// { dg-error "expected ',' or ';'" "" { target *-*-* } 15 }
 
const int i0 = R'a'; // { dg-error "expected ',' or ';'" }
// { dg-error "was not declared" "" { target c++ } 18 }
const int i1 = uR'a'; // { dg-error "expected ',' or ';'" }
// { dg-error "was not declared" "" { target c++ } 20 }
const int i2 = UR'a'; // { dg-error "expected ',' or ';'" }
// { dg-error "was not declared" "" { target c++ } 22 }
const int i3 = u8R'a'; // { dg-error "expected ',' or ';'" }
// { dg-error "was not declared" "" { target c++ } 24 }
const int i4 = LR'a'; // { dg-error "expected ',' or ';'" }
// { dg-error "was not declared" "" { target c++ } 26 }
 
#define R "a"
#define uR "b"
#define UR "c"
#define u8R "d"
#define LR "e"
 
const void *s5 = R"(a)";
const void *s6 = uR"(a)";
const void *s7 = UR"(a)";
const void *s8 = u8R"(a)";
const void *s9 = LR"(a)";
 
#undef R
#undef uR
#undef UR
#undef u8R
#undef LR
 
#define R 1 +
#define uR 2 +
#define UR 3 +
#define u8R 4 +
#define LR 5 +
 
const int i5 = R'a';
const int i6 = uR'a';
const int i7 = UR'a';
const int i8 = u8R'a';
const int i9 = LR'a';
 
int main () {}
/raw-string-5.c
0,0 → 1,27
// { dg-do compile }
// { dg-options "-std=gnu99" { target c } }
// { dg-options "-std=c++0x" { target c++ } }
 
const void *s0 = R"0123456789abcdefg()0123456789abcdefg";
// { dg-error "raw string delimiter longer" "" { target *-*-* } 5 }
// { dg-error "stray" "" { target *-*-* } 5 }
const void *s1 = R" () ";
// { dg-error "invalid character" "" { target *-*-* } 8 }
// { dg-error "stray" "" { target *-*-* } 8 }
const void *s2 = R" () ";
// { dg-error "invalid character" "" { target *-*-* } 11 }
// { dg-error "stray" "" { target *-*-* } 11 }
const void *s3 = R")())";
// { dg-error "invalid character" "" { target *-*-* } 14 }
// { dg-error "stray" "" { target *-*-* } 14 }
const void *s4 = R"@()@";
// { dg-error "invalid character" "" { target *-*-* } 17 }
// { dg-error "stray" "" { target *-*-* } 17 }
const void *s5 = R"$()$";
// { dg-error "invalid character" "" { target *-*-* } 20 }
// { dg-error "stray" "" { target *-*-* } 20 }
const void *s6 = R"\u0040()\u0040";
// { dg-error "invalid character" "" { target *-*-* } 23 }
// { dg-error "stray" "" { target *-*-* } 23 }
 
int main () {}
/Wunused-var-11.c
0,0 → 1,12
/* PR c++/44443 */
/* { dg-options "-Wunused" } */
/* { dg-do compile } */
 
int i;
 
void
f1 ()
{
const int * __attribute__((unused)) a = &i;
const int *b __attribute__((unused)) = &i;
}
/Wunused-var-13.c
0,0 → 1,27
/* PR c/46015 */
/* { dg-options "-Wunused" } */
/* { dg-do compile } */
 
int
f1 (int i)
{
static void *labs[2] = { &&lab1, &&lab2 };
goto *(labs[i & 1]);
 
lab1:
return 1;
lab2:
return 2;
}
 
int
f2 (int i)
{
void *labs[2] = { &&lab1, &&lab2 };
goto *labs[i & 1];
 
lab1:
return 1;
lab2:
return 2;
}
/raw-string-7.c
0,0 → 1,24
// The trailing whitespace after \ and before newline extension
// breaks full compliance for raw strings.
// { dg-do run { xfail *-*-* } }
// { dg-options "-std=gnu99" { target c } }
// { dg-options "-std=c++0x" { target c++ } }
 
// Note, there is a single space after \ on the following line.
const char *s0 = R"(\
)";
// { dg-bogus "backslash and newline separated by space" "" { xfail *-*-* } 8 }
 
// Note, there is a single tab after \ on the following line.
const char *s1 = R"(\
)";
// { dg-bogus "backslash and newline separated by space" "" { xfail *-*-* } 13 }
 
int
main (void)
{
if (__builtin_strcmp (s0, "\\ \n") != 0
|| __builtin_strcmp (s1, "\\\t\n") != 0)
__builtin_abort ();
return 0;
}
/uninit-D-O0.c
0,0 → 1,9
/* Test we do not warn about initializing variable with self. */
/* { dg-do compile } */
/* { dg-options "-Wuninitialized" } */
 
int f()
{
int i = i;
return i;
}
/raw-string-9.c
0,0 → 1,19
// Make sure that we properly handle trigraphs in raw strings when
// trigraphs are disabled, too.
// { dg-options "-std=gnu99" { target c } }
// { dg-options "-std=gnu++0x" { target c++ } }
// { dg-do run }
 
const char b[] = "??>"; // { dg-message "-trigraphs" }
const char a[] = R"(??>??)??/
??)";
 
#define TEST(str, val) \
if (sizeof (str) != sizeof (val) \
|| __builtin_memcmp (str, val, sizeof (str)) != 0) \
__builtin_abort ()
 
int main()
{
TEST (a, "?\?>?\?)?\?/\n?\?");
}
/Wunused-local-typedefs.c
0,0 → 1,44
/* Origin PR c++/33255
{ dg-options "-Wunused-local-typedefs" }
{ dg-do compile }
*/
 
void
test_warn ()
{
typedef int foo; // { dg-warning "locally defined but not used" }
}
 
void
test0 ()
{
typedef int foo;
foo var __attribute__((unused));
}
 
void
test1 ()
{
typedef int foo;
const foo *var = 0;
}
 
void
test2 ()
{
typedef int foo;
void func(foo);
}
 
void
test7 (void)
{
typedef int foo;
int vec[1] = {sizeof (foo)};
}
 
void
test8 (void)
{
typedef int foo __attribute__((used));
}
/attr-used-2.c
0,0 → 1,11
/* { dg-do compile } */
/* { dg-options "-Wall -O2" } */
 
static int xyzzy __attribute__((__used__)) = 1;
 
void foo()
{
int x __attribute__((__used__)); /* { dg-warning "attribute ignored|unused variable" } */
}
 
/* { dg-final { scan-assembler "xyzzy" } } */
/simulate-thread/bitfields-1.c
0,0 → 1,71
/* { dg-do link } */
/* { dg-options "--param allow-store-data-races=0" } */
/* { dg-final { simulate-thread } } */
 
#include <stdio.h>
#include "../../gcc.dg/simulate-thread/simulate-thread.h"
 
/* Test that we don't store past VAR.A. */
 
struct S
{
volatile unsigned int a : 4;
unsigned char b;
unsigned int c : 6;
} var = { 1, 2, 3 };
 
static int global = 0;
 
/* Called before each instruction, simulating another thread
executing. */
void simulate_thread_other_threads()
{
global++;
var.b = global;
/* Don't go past the 6 bits var.c can hold. */
var.c = global % 64;
}
 
/* Called after each instruction. Returns 1 if any inconsistency is
found, 0 otherwise. */
int simulate_thread_step_verify()
{
int ret = 0;
if (var.b != global)
{
printf("FAIL: invalid intermediate value for <b>.\n");
ret = 1;
}
if (var.c != global % 64)
{
printf("FAIL: invalid intermediate value for <c>.\n");
ret = 1;
}
return ret;
}
 
/* Called at the end of the program (simulate_thread_fini == 1). Verifies
the state of the program and returns 1 if any inconsistency is
found, 0 otherwise. */
int simulate_thread_final_verify()
{
if (var.a != 12)
{
printf("FAIL: invalid final result for <a>.\n");
return 1;
}
return 0;
}
 
__attribute__((noinline))
void simulate_thread_main()
{
var.a = 12;
}
 
int main()
{
simulate_thread_main();
simulate_thread_done();
return 0;
}
/simulate-thread/bitfields-2.c
0,0 → 1,59
/* { dg-do link } */
/* { dg-options "--param allow-store-data-races=0" } */
/* { dg-final { simulate-thread } } */
 
#include <stdio.h>
#include "../../gcc.dg/simulate-thread/simulate-thread.h"
 
/* Test that we don't store past VAR.K. */
 
struct S
{
volatile int i;
volatile int j: 32;
volatile int k: 15;
volatile unsigned char c[2];
} var;
 
static int global = 0;
 
void simulate_thread_other_threads()
{
global++;
var.c[0] = global % 256;
var.c[1] = global % 256;
}
 
int simulate_thread_step_verify()
{
if (var.c[0] != global % 256
|| var.c[1] != global % 256)
{
printf("FAIL: invalid intermediate result for <var.c[]>.\n");
return 1;
}
return 0;
}
 
int simulate_thread_final_verify()
{
if (var.k != 13)
{
printf("FAIL: invalid final result\n");
return 1;
}
return 0;
}
 
__attribute__((noinline))
void simulate_thread_main()
{
var.k = 13;
}
 
int main()
{
simulate_thread_main();
simulate_thread_done();
return 0;
}
/simulate-thread/bitfields-3.c
0,0 → 1,63
/* { dg-do link } */
/* { dg-options "--param allow-store-data-races=0" } */
/* { dg-final { simulate-thread } } */
 
#include <stdio.h>
#include "../../gcc.dg/simulate-thread/simulate-thread.h"
 
/* Store into <c> should not clobber <d>. */
 
struct bits
{
char a;
int b:7;
int c:9;
unsigned char d;
} var;
 
static int global = 0;
 
void simulate_thread_other_threads()
{
global++;
var.d = global;
}
 
int simulate_thread_step_verify()
{
if (var.d != global)
{
printf("FAIL: invalid intermediate result\n");
return 1;
}
return 0;
}
 
int simulate_thread_final_verify()
{
if (var.c != 5)
{
printf("FAIL: invalid final result\n");
return 1;
}
return 0;
}
 
__attribute__((noinline))
void update_c(struct bits *p, int val)
{
p -> c = val;
}
 
__attribute__((noinline))
void simulate_thread_main()
{
update_c(&var, 5);
}
 
int main()
{
simulate_thread_main();
simulate_thread_done();
return 0;
}
/simulate-thread/bitfields-4.c
0,0 → 1,60
/* { dg-do link } */
/* { dg-options "--param allow-store-data-races=0" } */
/* { dg-final { simulate-thread } } */
 
#include <stdio.h>
#include <stdlib.h>
#include "../../gcc.dg/simulate-thread/simulate-thread.h"
 
struct bits
{
char a;
int b:7;
int c:9;
unsigned char d;
} *p;
 
static int global = 0;
 
void simulate_thread_other_threads()
{
global++;
p->d = global % 256;
}
 
int simulate_thread_step_verify()
{
if (p->d != global % 256)
{
printf("FAIL: invalid intermediate result\n");
return 1;
}
return 0;
}
 
int simulate_thread_final_verify()
{
if (p->c != 55)
{
printf("FAIL: invalid final result\n");
return 1;
}
return 0;
}
 
/* Store into <c> should not clobber <d>. */
/* We should not use a 32-bit move to store into p->, but a smaller move. */
__attribute__((noinline))
void simulate_thread_main()
{
p -> c = 55;
}
 
int main()
{
p = (struct bits *) calloc (1, sizeof (struct bits));
simulate_thread_main();
simulate_thread_done();
return 0;
}
/attr-used.c
0,0 → 1,13
/* { dg-do compile } */
/* { dg-options "-O3" } */
 
static void function_declaration_before(void) __attribute__((__used__));
 
static void function_declaration_before(void) {}
 
static void function_declaration_after(void) {}
 
static void function_declaration_after(void) __attribute__((__used__));
 
/* { dg-final { scan-assembler "function_declaration_before" } } */
/* { dg-final { scan-assembler "function_declaration_after" } } */
/abi-bf.c
0,0 → 1,3
/* { dg-warning "incompatible" } */
/* { dg-do compile } */
/* { dg-options "-fstrict-volatile-bitfields -fabi-version=1" } */
/gomp/atomic-14.c
0,0 → 1,43
/* PR middle-end/45423 */
/* { dg-do compile } */
/* { dg-options "-fopenmp" } */
 
#ifdef __cplusplus
bool *baz ();
#else
_Bool *baz ();
#endif
int *bar ();
 
int
foo (void)
{
#pragma omp barrier
#pragma omp atomic
(*bar ())++;
#pragma omp barrier
#pragma omp atomic
++(*bar ());
#pragma omp barrier
#pragma omp atomic
(*bar ())--;
#pragma omp barrier
#pragma omp atomic
--(*bar ());
#pragma omp barrier
#pragma omp atomic
(*baz ())++;
#pragma omp barrier
#pragma omp atomic
++(*baz ());
#ifndef __cplusplus
#pragma omp barrier
#pragma omp atomic
(*baz ())--;
#pragma omp barrier
#pragma omp atomic
--(*baz ());
#pragma omp barrier
#endif
return 0;
}
/gomp/atomic-15.c
0,0 → 1,46
/* { dg-do compile } */
/* { dg-options "-fopenmp" } */
 
int x = 6;
 
int
main ()
{
int v;
#pragma omp atomic
x = x * 7 + 6; /* { dg-error "expected" } */
#pragma omp atomic
x = x * 7 ^ 6; /* { dg-error "expected" } */
#pragma omp atomic update
x = x - 8 + 6; /* { dg-error "expected" } */
#pragma omp atomic
x = x ^ 7 | 2; /* { dg-error "expected" } */
#pragma omp atomic
x = x / 7 * 2; /* { dg-error "expected" } */
#pragma omp atomic
x = x / 7 / 2; /* { dg-error "expected" } */
#pragma omp atomic capture
v = x = x | 6; /* { dg-error "invalid operator" } */
#pragma omp atomic capture
{ v = x; x = x * 7 + 6; } /* { dg-error "expected" } */
#pragma omp atomic capture
{ v = x; x = x * 7 ^ 6; } /* { dg-error "expected" } */
#pragma omp atomic capture
{ v = x; x = x - 8 + 6; } /* { dg-error "expected" } */
#pragma omp atomic capture
{ v = x; x = x ^ 7 | 2; } /* { dg-error "expected" } */
#pragma omp atomic capture
{ v = x; x = x / 7 * 2; } /* { dg-error "expected" } */
#pragma omp atomic capture
{ v = x; x = x / 7 / 2; } /* { dg-error "expected" } */
#pragma omp atomic capture
{ x = x * 7 + 6; v = x; } /* { dg-error "expected" } */
#pragma omp atomic capture
{ x = x * 7 ^ 6; v = x; } /* { dg-error "expected" } */
#pragma omp atomic capture
{ x = x - 8 + 6; v = x; } /* { dg-error "expected" } */
#pragma omp atomic capture
{ x = x ^ 7 | 2; v = x; } /* { dg-error "expected" } */
(void) v;
return 0;
}
/gomp/pr51360.c
0,0 → 1,27
/* PR c/51360 */
/* { dg-do compile } */
/* { dg-options "-Wunused -W -fopenmp" } */
 
void
foo (int a, int b, int c, int d)
{
int m, n, o, p, i;
m = 6;
n = 1;
o = 5;
p = 1;
a = 6;
b = 1;
c = 5;
d = 1;
#pragma omp parallel for num_threads (m) if (n) schedule (static, o)
for (i = 0; i < 10; i++)
;
#pragma omp parallel for num_threads (a) if (b) schedule (static, c)
for (i = 0; i < 10; i++)
;
#pragma omp task final (p)
;
#pragma omp task final (d)
;
}
/gomp/atomic-7.c
0,0 → 1,23
/* { dg-do compile } */
 
double x, y;
 
void f2(void)
{
#pragma omp atomic
y++;
#pragma omp atomic
y--;
#pragma omp atomic
++y;
#pragma omp atomic
--y;
#pragma omp atomic
y += 1;
#pragma omp atomic
y -= x;
#pragma omp atomic
y *= 3;
#pragma omp atomic
y /= 3;
}
/gomp/atomic-8.c
0,0 → 1,21
/* { dg-do compile } */
 
long double z;
 
void f3(void)
{
#pragma omp atomic
z++;
#pragma omp atomic
z--;
#pragma omp atomic
++z;
#pragma omp atomic
--z;
#pragma omp atomic
z += 1;
#pragma omp atomic
z *= 3;
#pragma omp atomic
z /= 3;
}
/gomp/atomic-9.c
0,0 → 1,14
/* { dg-do compile } */
/* { dg-options "-fopenmp -fdump-tree-ompexp" } */
/* { dg-require-effective-target cas_int } */
 
volatile int *bar(void);
 
void f1(void)
{
#pragma omp atomic
*bar() += 1;
}
 
/* { dg-final { scan-tree-dump-times "__atomic_fetch_add" 1 "ompexp" } } */
/* { dg-final { cleanup-tree-dump "ompexp" } } */
/gomp/atomic-1.c
0,0 → 1,99
/* { dg-do compile } */
 
int x;
volatile int y;
volatile unsigned char z;
 
void f1(void)
{
#pragma omp atomic
x++;
#pragma omp atomic
x--;
#pragma omp atomic
++x;
#pragma omp atomic
--x;
#pragma omp atomic
x += 1;
#pragma omp atomic
x -= y;
#pragma omp atomic
x |= 1;
#pragma omp atomic
x &= 1;
#pragma omp atomic
x ^= 1;
#pragma omp atomic
x *= 3;
#pragma omp atomic
x /= 3;
#pragma omp atomic
x /= 3;
#pragma omp atomic
x <<= 3;
#pragma omp atomic
x >>= 3;
}
 
void f2(void)
{
#pragma omp atomic
y++;
#pragma omp atomic
y--;
#pragma omp atomic
++y;
#pragma omp atomic
--y;
#pragma omp atomic
y += 1;
#pragma omp atomic
y -= x;
#pragma omp atomic
y |= 1;
#pragma omp atomic
y &= 1;
#pragma omp atomic
y ^= 1;
#pragma omp atomic
y *= 3;
#pragma omp atomic
y /= 3;
#pragma omp atomic
y /= 3;
#pragma omp atomic
y <<= 3;
#pragma omp atomic
y >>= 3;
}
 
void f3(void)
{
#pragma omp atomic
z++;
#pragma omp atomic
z--;
#pragma omp atomic
++z;
#pragma omp atomic
--z;
#pragma omp atomic
z += 1;
#pragma omp atomic
z |= 1;
#pragma omp atomic
z &= 1;
#pragma omp atomic
z ^= 1;
#pragma omp atomic
z *= 3;
#pragma omp atomic
z /= 3;
#pragma omp atomic
z /= 3;
#pragma omp atomic
z <<= 3;
#pragma omp atomic
z >>= 3;
}
/gomp/atomic-10.c
0,0 → 1,25
/* PR middle-end/28046 */
/* { dg-do compile } */
/* { dg-options "-fopenmp -fdump-tree-ompexp" } */
/* { dg-require-effective-target cas_int } */
 
int a[3], b;
struct C { int x; int y; } c;
 
int bar (void), *baz (void);
 
void
foo (void)
{
#pragma omp atomic
a[2] += bar ();
#pragma omp atomic
b += bar ();
#pragma omp atomic
c.y += bar ();
#pragma omp atomic
*baz () += bar ();
}
 
/* { dg-final { scan-tree-dump-times "__atomic_fetch_add" 4 "ompexp" } } */
/* { dg-final { cleanup-tree-dump "ompexp" } } */
/gomp/atomic-2.c
0,0 → 1,23
/* { dg-do compile } */
 
float x, y;
 
void f1(void)
{
#pragma omp atomic
x++;
#pragma omp atomic
x--;
#pragma omp atomic
++x;
#pragma omp atomic
--x;
#pragma omp atomic
x += 1;
#pragma omp atomic
x -= y;
#pragma omp atomic
x *= 3;
#pragma omp atomic
x /= 3;
}
/gomp/atomic-12.c
0,0 → 1,306
/* PR middle-end/45423 */
/* { dg-do compile } */
/* { dg-options "-fopenmp -fdump-tree-gimple -g0" } */
/* atomicvar should never be referenced in between the barrier and
following #pragma omp atomic_load. */
/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */
/* { dg-final { cleanup-tree-dump "gimple" } } */
 
#ifdef __cplusplus
bool atomicvar, c;
#else
_Bool atomicvar, c;
#endif
int i, atomicvar2, c2;
 
int
foo (void)
{
#pragma omp barrier
#pragma omp atomic
atomicvar |= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar |= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar |= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar |= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar |= c;
#pragma omp barrier
#pragma omp atomic
atomicvar ^= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar ^= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar ^= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar ^= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar ^= c;
#pragma omp barrier
#pragma omp atomic
atomicvar &= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar &= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar &= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar &= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar &= c;
#pragma omp barrier
#pragma omp atomic
atomicvar += -1;
#pragma omp barrier
#pragma omp atomic
atomicvar += 0;
#pragma omp barrier
#pragma omp atomic
atomicvar += 1;
#pragma omp barrier
#pragma omp atomic
atomicvar += 2;
#pragma omp barrier
#pragma omp atomic
atomicvar += c;
#pragma omp barrier
#pragma omp atomic
atomicvar -= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar -= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar -= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar -= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar -= c;
#pragma omp barrier
#pragma omp atomic
atomicvar *= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar *= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar *= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar *= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar *= c;
#pragma omp barrier
#pragma omp atomic
atomicvar /= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar /= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar /= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar /= c;
#pragma omp barrier
#pragma omp atomic
atomicvar <<= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar <<= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar <<= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar <<= i;
#pragma omp barrier
#pragma omp atomic
atomicvar >>= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar >>= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar >>= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar >>= i;
#pragma omp barrier
#pragma omp atomic
atomicvar++;
#pragma omp barrier
#pragma omp atomic
++atomicvar;
#pragma omp barrier
#ifndef __cplusplus
#pragma omp atomic
atomicvar--;
#pragma omp barrier
#pragma omp atomic
--atomicvar;
#pragma omp barrier
#endif
return 0;
}
 
int
bar (void)
{
#pragma omp barrier
#pragma omp atomic
atomicvar2 |= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 |= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar2 |= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 |= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 |= c2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 ^= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 ^= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar2 ^= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 ^= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 ^= c2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 &= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 &= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar2 &= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 &= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 &= c2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 += -1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 += 0;
#pragma omp barrier
#pragma omp atomic
atomicvar2 += 1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 += 2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 += c2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 -= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 -= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar2 -= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 -= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 -= c2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 *= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 *= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar2 *= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 *= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 *= c2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 /= -1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 /= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 /= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 /= c2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 <<= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar2 <<= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 <<= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 <<= i;
#pragma omp barrier
#pragma omp atomic
atomicvar2 >>= 0;
#pragma omp barrier
#pragma omp atomic
atomicvar2 >>= 1;
#pragma omp barrier
#pragma omp atomic
atomicvar2 >>= 2;
#pragma omp barrier
#pragma omp atomic
atomicvar2 >>= i;
#pragma omp barrier
#pragma omp atomic
atomicvar2++;
#pragma omp barrier
#pragma omp atomic
++atomicvar2;
#pragma omp barrier
#pragma omp atomic
atomicvar2--;
#pragma omp barrier
#pragma omp atomic
--atomicvar2;
#pragma omp barrier
return 0;
}
/gomp/atomic-3.c
0,0 → 1,14
/* { dg-do compile } */
/* { dg-options "-fopenmp -fdump-tree-ompexp" } */
/* { dg-require-effective-target cas_int } */
 
int *xyzzy;
 
void f1(void)
{
#pragma omp atomic
xyzzy++;
}
 
/* { dg-final { scan-tree-dump-times "xyzzy, 4" 1 "ompexp" } } */
/* { dg-final { cleanup-tree-dump "ompexp" } } */
/gomp/atomic-13.c
0,0 → 1,9
/* PR middle-end/45423 */
/* { dg-do compile } */
/* { dg-options "-fopenmp -fdump-tree-gimple -g0 -O2" } */
/* atomicvar should never be referenced in between the barrier and
following #pragma omp atomic_load. */
/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */
/* { dg-final { cleanup-tree-dump "gimple" } } */
 
#include "atomic-12.c"
/gomp/atomic-4.c
0,0 → 1,24
/* { dg-do compile } */
 
int a[4];
int *p;
struct S { int x; int y[4]; } s;
int *bar(void);
 
void f1(void)
{
#pragma omp atomic
a[4] += 1;
#pragma omp atomic
*p += 1;
#pragma omp atomic
s.x += 1;
#pragma omp atomic
s.y[*p] += 1;
#pragma omp atomic
s.y[*p] *= 42;
#pragma omp atomic
*bar() += 1;
#pragma omp atomic
*bar() *= 42;
}
/pr52181.c
0,0 → 1,13
/* PR c/52181 */
/* { dg-do compile } */
 
extern const int v1[];
const int __attribute__((aligned(16))) v1[] = { 1 };
extern const int __attribute__((aligned(16))) v2[];
const int v2[] = { 1 };
extern const int __attribute__((aligned(16))) v3[];
const int __attribute__((aligned(16))) v3[] = { 1 };
const int __attribute__((aligned(16))) v4[] = { 1 };
int test[(__alignof__ (v4) != __alignof__ (v1) /* { dg-bogus "is negative" } */
|| __alignof__ (v4) != __alignof__ (v2)
|| __alignof__ (v4) != __alignof__ (v3)) ? -1 : 0];
/pr33193.c
0,0 → 1,19
/* PR c/33193 */
/* { dg-do compile } */
 
struct a {float x, y; };
 
float f(struct a b)
{
/* The error messages here are different between C and C++, so just
make sure we get an error. */
float x = __real b; /* { dg-error "" } */
float y = __imag b; /* { dg-error "" } */
return x / y;
}
int f1(int *b)
{
float x = __imag b; /* { dg-error "wrong type argument" } */
float y = __real b; /* { dg-error "wrong type argument" } */
return x - y;
}
/fold-bitand-4.c
0,0 → 1,45
/* { dg-do compile } */
/* { dg-options "-fdump-tree-original" } */
/* { dg-additional-options "-fno-common" { target hppa*-*-hpux* } } */
 
typedef char char4[4] __attribute__ ((aligned (4)));
char4 c4[4] __attribute__ ((aligned (16)));
 
typedef char char16[16] __attribute__ ((aligned (16)));
char16 c16[4] __attribute__ ((aligned (4)));
 
int f1 (void)
{
/* 12 */
return 15 & (__SIZE_TYPE__)&c4[3];
}
 
int f2 (int i)
{
/* Indeterminate */
return 15 & (__SIZE_TYPE__)&c4[i];
}
 
int f3 (int i)
{
/* 0 */
return 3 & (__SIZE_TYPE__)&c4[i];
}
 
int f4 (int i)
{
/* Indeterminate */
return 7 & (__SIZE_TYPE__)&c16[i];
}
 
int f5 (int i)
{
/* 0 */
return 3 & (__SIZE_TYPE__)&c16[i];
}
 
/* { dg-final { scan-tree-dump-times "return \[^\n0-9\]*12;" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "\& 15" 1 "original" } } */
/* { dg-final { scan-tree-dump-times "return \[^\n0-9\]*0;" 2 "original" } } */
/* { dg-final { scan-tree-dump-times "\& 7" 1 "original" } } */
/* { dg-final { cleanup-tree-dump "original" } } */
/pr43690.c
0,0 → 1,13
/* PR middle-end/43690 */
/* { dg-do compile } */
/* { dg-options "-O2" } */
 
void
foo (char *x)
{
asm ("" : : "m" (x++)); /* { dg-error "is not directly addressable" } */
asm ("" : : "m" (++x)); /* { dg-error "is not directly addressable" } */
asm ("" : : "m" (x--)); /* { dg-error "is not directly addressable" } */
asm ("" : : "m" (--x)); /* { dg-error "is not directly addressable" } */
asm ("" : : "m" (x + 1)); /* { dg-error "is not directly addressable" } */
}
/cxxbitfields-6.c
0,0 → 1,17
/* PR middle-end/50141 */
/* { dg-do compile } */
/* { dg-options "-O2 --param allow-store-data-races=0" } */
 
struct S
{
int i:8;
};
 
void bar (struct S, int);
 
void
foo (struct S s, int i)
{
s.i = i;
bar (s, i);
}
/Wconversion-real.c
0,0 → 1,85
/* Test for diagnostics for Wconversion for floating-point. */
 
/* { dg-do compile } */
/* { dg-skip-if "doubles are floats" { "avr-*-*" } { "*" } { "" } } */
/* { dg-options "-std=c99 -Wconversion" { target c } } */
/* { dg-options "-Wconversion" { target c++ } } */
/* { dg-require-effective-target large_double } */
 
float vfloat;
double vdouble;
long double vlongdouble;
 
void ffloat (float f);
void fdouble (double d);
void flongdouble (long double ld);
 
void h (void)
{
float f = 0;
double d = 0;
long double ld = 0;
 
ffloat (3.1); /* { dg-warning "conversion" } */
vfloat = 3.1; /* { dg-warning "conversion" } */
ffloat (3.1L); /* { dg-warning "conversion" } */
vfloat = 3.1L; /* { dg-warning "conversion" } */
fdouble (3.1L); /* { dg-warning "conversion" "" { target large_long_double } } */
vdouble = 3.1L; /* { dg-warning "conversion" "" { target large_long_double } } */
ffloat (vdouble); /* { dg-warning "conversion" } */
vfloat = vdouble; /* { dg-warning "conversion" } */
ffloat (vlongdouble); /* { dg-warning "conversion" } */
vfloat = vlongdouble; /* { dg-warning "conversion" } */
fdouble (vlongdouble); /* { dg-warning "conversion" "" { target large_long_double } } */
vdouble = vlongdouble; /* { dg-warning "conversion" "" { target large_long_double } } */
 
 
ffloat ((float) 3.1);
vfloat = (float) 3.1;
ffloat ((float) 3.1L);
vfloat = (float) 3.1L;
fdouble ((double) 3.1L);
vdouble = (double) 3.1L;
ffloat ((float) vdouble);
vfloat = (float) vdouble;
ffloat ((float) vlongdouble);
vfloat = (float) vlongdouble;
fdouble ((double) vlongdouble);
vdouble = (double) vlongdouble;
 
 
ffloat (3.0);
vfloat = 3.0;
ffloat (3.1f);
vfloat = 3.1f;
ffloat (0.25L);
vfloat = 0.25L;
 
 
fdouble (3.0);
vdouble = 3.0;
fdouble (3.1f);
vdouble = 3.1f;
fdouble (0.25L);
vdouble = 0.25L;
 
flongdouble (3.0);
vlongdouble = 3.0;
flongdouble (3.1f);
vlongdouble = 3.1f;
flongdouble (0.25L);
vlongdouble = 0.25L;
 
ffloat (f);
vfloat = f;
fdouble (f);
vdouble = f;
fdouble (d);
vdouble = d;
flongdouble (f);
vlongdouble = f;
flongdouble (d);
vlongdouble = d;
flongdouble (ld);
vlongdouble = ld;
}
/restrict-2.c
0,0 → 1,14
/* { dg-do compile } */
/* { dg-options "-O -fno-strict-aliasing -fdump-tree-lim1-details" } */
 
void foo (float * __restrict__ a, float * __restrict__ b, int n, int j)
{
int i;
for(i = 0; i < n; ++i)
a[i] = (b[j+50] + b[j-50]) * 0.5f;
}
 
/* We should move the RHS of the store out of the loop. */
 
/* { dg-final { scan-tree-dump-times "Moving statement" 11 "lim1" } } */
/* { dg-final { cleanup-tree-dump "lim1" } } */
/restrict-4.c
0,0 → 1,19
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-lim1-details" } */
 
struct Foo
{
int n;
int * __restrict__ p;
};
void bar(struct Foo f, int * __restrict__ q)
{
int i;
for (i = 0; i < f.n; ++i)
{
*q += f.p[i];
}
}
 
/* { dg-final { scan-tree-dump "Executing store motion" "lim1" } } */
/* { dg-final { cleanup-tree-dump "lim1" } } */
/uninit-E-O0.c
0,0 → 1,9
/* Test we do warn about initializing variable with self when -Winit-self is supplied. */
/* { dg-do compile } */
/* { dg-options "-Wuninitialized -Winit-self" } */
 
int f()
{
int i = i; /* { dg-warning "i" "uninitialized variable warning" } */
return i;
}
/Wint-to-pointer-cast-2.c
0,0 → 1,12
/* Test -Wint-to-pointer-cast. */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-Wint-to-pointer-cast" } */
 
char c;
 
void *
f (void)
{
return (void *) c; /* { dg-warning "cast to pointer from integer of different size" } */
}
/asmgoto-1.c
0,0 → 1,15
/* { dg-do compile } */
/* { dg-options "" } */
 
void
foo (void)
{
int i = 0;
asm ("" : : : "memory");
asm ("" : : : );
asm ("" : : "r" (i));
asm ("" : : );
asm ("" : "=r" (i));
asm ("" : );
asm ("");
}
/warn-ommitted-condop.c
0,0 → 1,29
/* { dg-options "-Wparentheses" } */
 
extern void f2 (int);
 
void bar (int x, int y, int z)
{
#define T(op) f2 (x op y ? : 1)
#define T2(op) f2 (x op y ? 2 : 1)
 
T(<); /* { dg-warning "omitted middle operand" } */
T(>); /* { dg-warning "omitted middle operand" } */
T(<=); /* { dg-warning "omitted middle operand" } */
T(>=); /* { dg-warning "omitted middle operand" } */
T(==); /* { dg-warning "omitted middle operand" } */
T(!=); /* { dg-warning "omitted middle operand" } */
T(||); /* { dg-warning "omitted middle operand" } */
T(&&); /* { dg-warning "omitted middle operand" } */
f2 (!x ? : 1); /* { dg-warning "omitted middle operand" } */
T2(<); /* { dg-bogus "omitted middle operand" } */
T2(>); /* { dg-bogus "omitted middle operand" } */
T2(==); /* { dg-bogus "omitted middle operand" } */
T2(||); /* { dg-bogus "omitted middle operand" } */
T2(&&); /* { dg-bogus "omitted middle operand" } */
T(+); /* { dg-bogus "omitted middle operand" } */
T(-); /* { dg-bogus "omitted middle operand" } */
T(*); /* { dg-bogus "omitted middle operand" } */
T(/); /* { dg-bogus "omitted middle operand" } */
T(^); /* { dg-bogus "omitted middle operand" } */
}
/asmgoto-3.c
0,0 → 1,10
/* { dg-do compile } */
/* { dg-options "-Wunused" } */
 
int foo ()
{
asm goto ("" : : : : label);
return 1;
label:
return 0;
}
/raw-string-10.c
0,0 → 1,20
// Test that we don't revert trigraphs and line splicing when a raw string
// literal is formed by token pasting.
// { dg-options "-std=gnu99 -trigraphs" { target c } }
// { dg-options "-std=c++0x" { target c++ } }
// { dg-do run }
 
#define PASTE(X,Y) X##Y
 
const char a[] = PASTE(R,"(??>\
)");
 
#define TEST(str, val) \
if (sizeof (str) != sizeof (val) \
|| __builtin_memcmp (str, val, sizeof (str)) != 0) \
__builtin_abort ()
 
int main()
{
TEST (a, "}");
}
/raw-string-12.c Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
raw-string-12.c Property changes : Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Index: Wunused-var-1.c =================================================================== --- Wunused-var-1.c (nonexistent) +++ Wunused-var-1.c (revision 686) @@ -0,0 +1,179 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +void +f1 (void) +{ + int a; /* { dg-warning "set but not used" } */ + int b; + int c; + c = 1; + a = b = c; +} + +void +f2 (int x) +{ + int a; /* { dg-warning "set but not used" } */ + int b; + int c; /* { dg-warning "set but not used" } */ + c = (a = x, b = x); +} + +int +f3 (int x) +{ + int a; + return a = x; +} + +int +f4 (int x) +{ + int a; + a = x; + return a; +} + +void +f5 (int x) +{ + int a[2]; /* { dg-warning "set but not used" } */ + int b; + int *c, d[2]; + c = d; + b = x; + a[b] = 1; + c[b] = 1; +} + +int +f6 (int x) +{ + int a[2]; + int b; + b = x; + a[b] = 1; + return a[b]; +} + +void +f7 (int x, int *p) +{ + int *a[2]; + a[x] = p; + a[x][x] = x; +} + +struct S { int i; }; + +void +f8 (void) +{ + struct S s; /* { dg-warning "set but not used" } */ + s.i = 6; +} + +int +f9 (void) +{ + struct S s; + s.i = 6; + return s.i; +} + +struct S +f10 (void) +{ + struct S s; + s.i = 6; + return s; +} + +extern int foo11 (int *); + +void +f11 (void) +{ + int a[2]; + foo11 (a); +} + +void +f12 (void) +{ + int a; + a = 1; + a; /* { dg-warning "no effect" } */ +} + +void +f13 (void (*x) (void)) +{ + void (*a) (void); + a = x; + a (); +} + +void +f14 (void (*x) (void)) +{ + void (*a) (void); /* { dg-warning "set but not used" } */ + a = x; +} + +extern void foo15 (int *); + +void +f15 (void) +{ + int a[10]; + int *b = a + 2; + foo15 (b); +} + +extern void foo16 (int **); + +void +f16 (void) +{ + int a[10]; + int *b[] = { a, a + 2 }; + foo16 (b); +} + +void +f17 (int x) +{ + long a; /* { dg-warning "set but not used" } */ + int b; + a = b = x; +} + +void +f18 (int x) +{ + int a; /* { dg-warning "set but not used" } */ + int b; + a = (char) (b = x); +} + +int +f19 (int x, int y, int z) +{ + int a; + int b; + a = x; + b = y; + return z ? a : b; +} + +int * +f20 (int x) +{ + static int a[] = { 3, 4, 5, 6 }; + static int b[] = { 4, 5, 6, 7 }; + static int c[] = { 5, 6, 7, 8 }; /* { dg-warning "set but not used" } */ + c[1] = 1; + return x ? a : b; +} Index: Wunused-var-3.c =================================================================== --- Wunused-var-3.c (nonexistent) +++ Wunused-var-3.c (revision 686) @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +void +f1 (void) +{ + _Complex int a; /* { dg-warning "set but not used" } */ + _Complex double b; /* { dg-warning "set but not used" } */ + __real__ a = 1; + __imag__ a = 2; + __real__ b = 3.0; + __imag__ b = 4.0; +} + +int +f2 (void) +{ + _Complex int a; + _Complex double b; + __real__ a = 1; + __imag__ a = 2; + __real__ b = 3.0; + __imag__ b = 4.0; + return __real__ a + __imag__ b; +} + +_Complex double +f3 (void) +{ + _Complex int a; + _Complex double b; + __real__ a = 1; + __imag__ a = 2; + __real__ b = 3.0; + __imag__ b = 4.0; + return a + b; +} Index: Wunused-var-5.c =================================================================== --- Wunused-var-5.c (nonexistent) +++ Wunused-var-5.c (revision 686) @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +void +f1 (void) +{ + extern int extvari; + extvari = 1; +} + +int extvarj; + +void +f2 (void) +{ + extern int extvarj; + extvarj = 1; +} + +static int extvark; + +void +f3 (void) +{ + extern int extvark; + extvark = 1; +} + +int +f4 (void) +{ + return extvark; +} Index: pr36513-2.c =================================================================== --- pr36513-2.c (nonexistent) +++ pr36513-2.c (revision 686) @@ -0,0 +1,13 @@ +/* PR 36513: -Wlogical-op warns about strchr */ +/* { dg-do compile } */ +/* { dg-options "-Wlogical-op" } */ +#ifdef __cplusplus +#include +#else +#include +#endif +int main2 () +{ + char *s, t; + strchr (s, t); +} Index: int128-1.c =================================================================== --- int128-1.c (nonexistent) +++ int128-1.c (revision 686) @@ -0,0 +1,41 @@ +/* { dg-do run { target int128 } } */ +/* { dg-options "-std=gnu99" { target c } } */ +/* { dg-options "" { target c++ } } */ + +#include + +#ifndef __cplusplus +extern void abort (void); +#else +extern "C" void abort (void); +#endif + +#define MK_CONST128(A,B,C,D) \ + ( (((unsigned __int128) (unsigned int) A) << 96) \ + | (((unsigned __int128) (unsigned int) B) << 64) \ + | (((unsigned __int128) (unsigned int) C) << 32) \ + | ((unsigned __int128) (unsigned int) D) ) + +#define MK_CONST128_SIGNED(A,B,C,D) \ + ((__int128) MK_CONST128(A, B, C, D)) + +void foo(int i, ...) +{ + __int128 q; + va_list va; + + va_start(va, i); + q = va_arg(va, __int128); + va_end(va); + + if (q != MK_CONST128_SIGNED (0xfeffffffU, 2U, 3U, 4U)) + abort(); +} + +int main(void) +{ + __int128 q = MK_CONST128_SIGNED (0xfeffffffU, 2U, 3U, 4U); + + foo(1, q); + return 0; +} Index: Wunused-var-7.c =================================================================== --- Wunused-var-7.c (nonexistent) +++ Wunused-var-7.c (revision 686) @@ -0,0 +1,48 @@ +/* PR c++/44062 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ + +void +foo (void) +{ + int a, b, c, d, e, f, g; + a = 1; + b = 2; + c = 3; + d = 4; + e = 5; + f = 6; + g = 7; + a; /* { dg-warning "no effect" } */ + b, 1; /* { dg-warning "no effect" } */ + (void) c; + (void) d, 1; /* { dg-warning "no effect" } */ + e, f, 1; /* { dg-warning "no effect" } */ + (void) g, f, 1; /* { dg-warning "no effect" } */ +} + +void +bar (void) +{ + int a; + int b; + int c; /* { dg-warning "set but not used" } */ + a = 1; + b = 2; + c = 3; + c = ({ a++, b; }); +} + +void +baz (void) +{ + int a; + int b; + int c; + int d; + a = 1; + b = 2; + c = 3; + d = 4; + d, ( a++, b ), c; /* { dg-warning "no effect" } */ +} Index: int128-types-1.c =================================================================== --- int128-types-1.c (nonexistent) +++ int128-types-1.c (revision 686) @@ -0,0 +1,666 @@ +/* Test for valid and invalid combinations of type specifiers using __int128. + */ +/* Origin: Kai Tietz */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-std=gnu99" { target c } } */ +/* { dg-options "" { target c++ } } */ + +typedef char type; +__int128 *x0; +void __int128 *x1; /* { dg-error "" } */ +char __int128 *x2; /* { dg-error "" } */ +short __int128 *x3; /* { dg-error "" } */ +int __int128 *x4; /* { dg-error "" } */ +__int128 void *x5; /* { dg-error "" } */ +__int128 char *x6; /* { dg-error "" } */ +__int128 short *x7; /* { dg-error "" } */ +__int128 int *x8; /* { dg-error "" } */ +__int128 __int128 *x9; /* { dg-error "" } */ +__int128 long *x10; /* { dg-error "" } */ +__int128 float *x11; /* { dg-error "" } */ +__int128 double *x12; /* { dg-error "" } */ +__int128 signed *x13; +__int128 unsigned *x14; +__int128 _Bool *x15; /* { dg-error "" } */ +__int128 _Complex *x16; +long __int128 *x17; /* { dg-error "" } */ +float __int128 *x18; /* { dg-error "" } */ +double __int128 *x19; /* { dg-error "" } */ +signed __int128 *x20; +unsigned __int128 *x21; +_Bool __int128 *x22; /* { dg-error "" } */ +_Complex __int128 *x23; +type __int128 *x24; /* { dg-error "" } */ +char signed __int128 *x25; /* { dg-error "" } */ +char unsigned __int128 *x26; /* { dg-error "" } */ +char _Complex __int128 *x27; /* { dg-error "" } */ +short int __int128 *x28; /* { dg-error "" } */ +short signed __int128 *x29; /* { dg-error "" } */ +short unsigned __int128 *x30; /* { dg-error "" } */ +short _Complex __int128 *x31; /* { dg-error "" } */ +int short __int128 *x32; /* { dg-error "" } */ +int long __int128 *x33; /* { dg-error "" } */ +int signed __int128 *x34; /* { dg-error "" } */ +int unsigned __int128 *x35; /* { dg-error "" } */ +int _Complex __int128 *x36; /* { dg-error "" } */ +__int128 signed void *x37; /* { dg-error "" } */ +__int128 signed char *x38; /* { dg-error "" } */ +__int128 signed short *x39; /* { dg-error "" } */ +__int128 signed int *x40; /* { dg-error "" } */ +__int128 signed __int128 *x41; /* { dg-error "" } */ +__int128 signed long *x42; /* { dg-error "" } */ +__int128 signed float *x43; /* { dg-error "" } */ +__int128 signed double *x44; /* { dg-error "" } */ +__int128 signed signed *x45; /* { dg-error "" } */ +__int128 signed unsigned *x46; /* { dg-error "" } */ +__int128 signed _Bool *x47; /* { dg-error "" } */ +__int128 signed _Complex *x48; +__int128 unsigned void *x49; /* { dg-error "" } */ +__int128 unsigned char *x50; /* { dg-error "" } */ +__int128 unsigned short *x51; /* { dg-error "" } */ +__int128 unsigned int *x52; /* { dg-error "" } */ +__int128 unsigned __int128 *x53; /* { dg-error "" } */ +__int128 unsigned long *x54; /* { dg-error "" } */ +__int128 unsigned float *x55; /* { dg-error "" } */ +__int128 unsigned double *x56; /* { dg-error "" } */ +__int128 unsigned signed *x57; /* { dg-error "" } */ +__int128 unsigned unsigned *x58; /* { dg-error "" } */ +__int128 unsigned _Bool *x59; /* { dg-error "" } */ +__int128 unsigned _Complex *x60; +__int128 _Complex void *x61; /* { dg-error "" } */ +__int128 _Complex char *x62; /* { dg-error "" } */ +__int128 _Complex short *x63; /* { dg-error "" } */ +__int128 _Complex int *x64; /* { dg-error "" } */ +__int128 _Complex __int128 *x65; /* { dg-error "" } */ +__int128 _Complex long *x66; /* { dg-error "" } */ +__int128 _Complex float *x67; /* { dg-error "" } */ +__int128 _Complex double *x68; /* { dg-error "" } */ +__int128 _Complex signed *x69; +__int128 _Complex unsigned *x70; +__int128 _Complex _Bool *x71; /* { dg-error "" } */ +__int128 _Complex _Complex *x72; /* { dg-error "" } */ +long int __int128 *x73; /* { dg-error "" } */ +long long __int128 *x74; /* { dg-error "" } */ +long double __int128 *x75; /* { dg-error "" } */ +long signed __int128 *x76; /* { dg-error "" } */ +long unsigned __int128 *x77; /* { dg-error "" } */ +long _Complex __int128 *x78; /* { dg-error "" } */ +float _Complex __int128 *x79; /* { dg-error "" } */ +double long __int128 *x80; /* { dg-error "" } */ +double _Complex __int128 *x81; /* { dg-error "" } */ +signed char __int128 *x82; /* { dg-error "" } */ +signed short __int128 *x83; /* { dg-error "" } */ +signed int __int128 *x84; /* { dg-error "" } */ +signed __int128 void *x85; /* { dg-error "" } */ +signed __int128 char *x86; /* { dg-error "" } */ +signed __int128 short *x87; /* { dg-error "" } */ +signed __int128 int *x88; /* { dg-error "" } */ +signed __int128 __int128 *x89; /* { dg-error "" } */ +signed __int128 long *x90; /* { dg-error "" } */ +signed __int128 float *x91; /* { dg-error "" } */ +signed __int128 double *x92; /* { dg-error "" } */ +signed __int128 signed *x93; /* { dg-error "" } */ +signed __int128 unsigned *x94; /* { dg-error "" } */ +signed __int128 _Bool *x95; /* { dg-error "" } */ +signed __int128 _Complex *x96; +signed long __int128 *x97; /* { dg-error "" } */ +signed _Complex __int128 *x98; +unsigned char __int128 *x99; /* { dg-error "" } */ +unsigned short __int128 *x100; /* { dg-error "" } */ +unsigned int __int128 *x101; /* { dg-error "" } */ +unsigned __int128 void *x102; /* { dg-error "" } */ +unsigned __int128 char *x103; /* { dg-error "" } */ +unsigned __int128 short *x104; /* { dg-error "" } */ +unsigned __int128 int *x105; /* { dg-error "" } */ +unsigned __int128 __int128 *x106; /* { dg-error "" } */ +unsigned __int128 long *x107; /* { dg-error "" } */ +unsigned __int128 float *x108; /* { dg-error "" } */ +unsigned __int128 double *x109; /* { dg-error "" } */ +unsigned __int128 signed *x110; /* { dg-error "" } */ +unsigned __int128 unsigned *x111; /* { dg-error "" } */ +unsigned __int128 _Bool *x112; /* { dg-error "" } */ +unsigned __int128 _Complex *x113; +unsigned long __int128 *x114; /* { dg-error "" } */ +unsigned _Complex __int128 *x115; +_Complex char __int128 *x116; /* { dg-error "" } */ +_Complex short __int128 *x117; /* { dg-error "" } */ +_Complex int __int128 *x118; /* { dg-error "" } */ +_Complex __int128 void *x119; /* { dg-error "" } */ +_Complex __int128 char *x120; /* { dg-error "" } */ +_Complex __int128 short *x121; /* { dg-error "" } */ +_Complex __int128 int *x122; /* { dg-error "" } */ +_Complex __int128 __int128 *x123; /* { dg-error "" } */ +_Complex __int128 long *x124; /* { dg-error "" } */ +_Complex __int128 float *x125; /* { dg-error "" } */ +_Complex __int128 double *x126; /* { dg-error "" } */ +_Complex __int128 signed *x127; +_Complex __int128 unsigned *x128; +_Complex __int128 _Bool *x129; /* { dg-error "" } */ +_Complex __int128 _Complex *x130; /* { dg-error "" } */ +_Complex long __int128 *x131; /* { dg-error "" } */ +_Complex float __int128 *x132; /* { dg-error "" } */ +_Complex double __int128 *x133; /* { dg-error "" } */ +_Complex signed __int128 *x134; +_Complex unsigned __int128 *x135; +char signed _Complex __int128 *x136; /* { dg-error "" } */ +char unsigned _Complex __int128 *x137; /* { dg-error "" } */ +char _Complex signed __int128 *x138; /* { dg-error "" } */ +char _Complex unsigned __int128 *x139; /* { dg-error "" } */ +short int signed __int128 *x140; /* { dg-error "" } */ +short int unsigned __int128 *x141; /* { dg-error "" } */ +short int _Complex __int128 *x142; /* { dg-error "" } */ +short signed int __int128 *x143; /* { dg-error "" } */ +short signed _Complex __int128 *x144; /* { dg-error "" } */ +short unsigned int __int128 *x145; /* { dg-error "" } */ +short unsigned _Complex __int128 *x146; /* { dg-error "" } */ +short _Complex int __int128 *x147; /* { dg-error "" } */ +short _Complex signed __int128 *x148; /* { dg-error "" } */ +short _Complex unsigned __int128 *x149; /* { dg-error "" } */ +int short signed __int128 *x150; /* { dg-error "" } */ +int short unsigned __int128 *x151; /* { dg-error "" } */ +int short _Complex __int128 *x152; /* { dg-error "" } */ +int long long __int128 *x153; /* { dg-error "" } */ +int long signed __int128 *x154; /* { dg-error "" } */ +int long unsigned __int128 *x155; /* { dg-error "" } */ +int long _Complex __int128 *x156; /* { dg-error "" } */ +int signed short __int128 *x157; /* { dg-error "" } */ +int signed long __int128 *x158; /* { dg-error "" } */ +int signed _Complex __int128 *x159; /* { dg-error "" } */ +int unsigned short __int128 *x160; /* { dg-error "" } */ +int unsigned long __int128 *x161; /* { dg-error "" } */ +int unsigned _Complex __int128 *x162; /* { dg-error "" } */ +int _Complex short __int128 *x163; /* { dg-error "" } */ +int _Complex long __int128 *x164; /* { dg-error "" } */ +int _Complex signed __int128 *x165; /* { dg-error "" } */ +int _Complex unsigned __int128 *x166; /* { dg-error "" } */ +__int128 signed _Complex void *x167; /* { dg-error "" } */ +__int128 signed _Complex char *x168; /* { dg-error "" } */ +__int128 signed _Complex short *x169; /* { dg-error "" } */ +__int128 signed _Complex int *x170; /* { dg-error "" } */ +__int128 signed _Complex __int128 *x171; /* { dg-error "" } */ +__int128 signed _Complex long *x172; /* { dg-error "" } */ +__int128 signed _Complex float *x173; /* { dg-error "" } */ +__int128 signed _Complex double *x174; /* { dg-error "" } */ +__int128 signed _Complex signed *x175; /* { dg-error "" } */ +__int128 signed _Complex unsigned *x176; /* { dg-error "" } */ +__int128 signed _Complex _Bool *x177; /* { dg-error "" } */ +__int128 signed _Complex _Complex *x178; /* { dg-error "" } */ +__int128 unsigned _Complex void *x179; /* { dg-error "" } */ +__int128 unsigned _Complex char *x180; /* { dg-error "" } */ +__int128 unsigned _Complex short *x181; /* { dg-error "" } */ +__int128 unsigned _Complex int *x182; /* { dg-error "" } */ +__int128 unsigned _Complex __int128 *x183; /* { dg-error "" } */ +__int128 unsigned _Complex long *x184; /* { dg-error "" } */ +__int128 unsigned _Complex float *x185; /* { dg-error "" } */ +__int128 unsigned _Complex double *x186; /* { dg-error "" } */ +__int128 unsigned _Complex signed *x187; /* { dg-error "" } */ +__int128 unsigned _Complex unsigned *x188; /* { dg-error "" } */ +__int128 unsigned _Complex _Bool *x189; /* { dg-error "" } */ +__int128 unsigned _Complex _Complex *x190; /* { dg-error "" } */ +__int128 _Complex signed void *x191; /* { dg-error "" } */ +__int128 _Complex signed char *x192; /* { dg-error "" } */ +__int128 _Complex signed short *x193; /* { dg-error "" } */ +__int128 _Complex signed int *x194; /* { dg-error "" } */ +__int128 _Complex signed __int128 *x195; /* { dg-error "" } */ +__int128 _Complex signed long *x196; /* { dg-error "" } */ +__int128 _Complex signed float *x197; /* { dg-error "" } */ +__int128 _Complex signed double *x198; /* { dg-error "" } */ +__int128 _Complex signed signed *x199; /* { dg-error "" } */ +__int128 _Complex signed unsigned *x200; /* { dg-error "" } */ +__int128 _Complex signed _Bool *x201; /* { dg-error "" } */ +__int128 _Complex signed _Complex *x202; /* { dg-error "" } */ +__int128 _Complex unsigned void *x203; /* { dg-error "" } */ +__int128 _Complex unsigned char *x204; /* { dg-error "" } */ +__int128 _Complex unsigned short *x205; /* { dg-error "" } */ +__int128 _Complex unsigned int *x206; /* { dg-error "" } */ +__int128 _Complex unsigned __int128 *x207; /* { dg-error "" } */ +__int128 _Complex unsigned long *x208; /* { dg-error "" } */ +__int128 _Complex unsigned float *x209; /* { dg-error "" } */ +__int128 _Complex unsigned double *x210; /* { dg-error "" } */ +__int128 _Complex unsigned signed *x211; /* { dg-error "" } */ +__int128 _Complex unsigned unsigned *x212; /* { dg-error "" } */ +__int128 _Complex unsigned _Bool *x213; /* { dg-error "" } */ +__int128 _Complex unsigned _Complex *x214; /* { dg-error "" } */ +long int long __int128 *x215; /* { dg-error "" } */ +long int signed __int128 *x216; /* { dg-error "" } */ +long int unsigned __int128 *x217; /* { dg-error "" } */ +long int _Complex __int128 *x218; /* { dg-error "" } */ +long long int __int128 *x219; /* { dg-error "" } */ +long long signed __int128 *x220; /* { dg-error "" } */ +long long unsigned __int128 *x221; /* { dg-error "" } */ +long long _Complex __int128 *x222; /* { dg-error "" } */ +long double _Complex __int128 *x223; /* { dg-error "" } */ +long signed int __int128 *x224; /* { dg-error "" } */ +long signed long __int128 *x225; /* { dg-error "" } */ +long signed _Complex __int128 *x226; /* { dg-error "" } */ +long unsigned int __int128 *x227; /* { dg-error "" } */ +long unsigned long __int128 *x228; /* { dg-error "" } */ +long unsigned _Complex __int128 *x229; /* { dg-error "" } */ +long _Complex int __int128 *x230; /* { dg-error "" } */ +long _Complex long __int128 *x231; /* { dg-error "" } */ +long _Complex double __int128 *x232; /* { dg-error "" } */ +long _Complex signed __int128 *x233; /* { dg-error "" } */ +long _Complex unsigned __int128 *x234; /* { dg-error "" } */ +double long _Complex __int128 *x235; /* { dg-error "" } */ +double _Complex long __int128 *x236; /* { dg-error "" } */ +signed char _Complex __int128 *x237; /* { dg-error "" } */ +signed short int __int128 *x238; /* { dg-error "" } */ +signed short _Complex __int128 *x239; /* { dg-error "" } */ +signed int short __int128 *x240; /* { dg-error "" } */ +signed int long __int128 *x241; /* { dg-error "" } */ +signed int _Complex __int128 *x242; /* { dg-error "" } */ +signed __int128 _Complex void *x243; /* { dg-error "" } */ +signed __int128 _Complex char *x244; /* { dg-error "" } */ +signed __int128 _Complex short *x245; /* { dg-error "" } */ +signed __int128 _Complex int *x246; /* { dg-error "" } */ +signed __int128 _Complex __int128 *x247; /* { dg-error "" } */ +signed __int128 _Complex long *x248; /* { dg-error "" } */ +signed __int128 _Complex float *x249; /* { dg-error "" } */ +signed __int128 _Complex double *x250; /* { dg-error "" } */ +signed __int128 _Complex signed *x251; /* { dg-error "" } */ +signed __int128 _Complex unsigned *x252; /* { dg-error "" } */ +signed __int128 _Complex _Bool *x253; /* { dg-error "" } */ +signed __int128 _Complex _Complex *x254; /* { dg-error "" } */ +signed long int __int128 *x255; /* { dg-error "" } */ +signed long long __int128 *x256; /* { dg-error "" } */ +signed long _Complex __int128 *x257; /* { dg-error "" } */ +signed _Complex char __int128 *x258; /* { dg-error "" } */ +signed _Complex short __int128 *x259; /* { dg-error "" } */ +signed _Complex int __int128 *x260; /* { dg-error "" } */ +signed _Complex __int128 void *x261; /* { dg-error "" } */ +signed _Complex __int128 char *x262; /* { dg-error "" } */ +signed _Complex __int128 short *x263; /* { dg-error "" } */ +signed _Complex __int128 int *x264; /* { dg-error "" } */ +signed _Complex __int128 __int128 *x265; /* { dg-error "" } */ +signed _Complex __int128 long *x266; /* { dg-error "" } */ +signed _Complex __int128 float *x267; /* { dg-error "" } */ +signed _Complex __int128 double *x268; /* { dg-error "" } */ +signed _Complex __int128 signed *x269; /* { dg-error "" } */ +signed _Complex __int128 unsigned *x270; /* { dg-error "" } */ +signed _Complex __int128 _Bool *x271; /* { dg-error "" } */ +signed _Complex __int128 _Complex *x272; /* { dg-error "" } */ +signed _Complex long __int128 *x273; /* { dg-error "" } */ +unsigned char _Complex __int128 *x274; /* { dg-error "" } */ +unsigned short int __int128 *x275; /* { dg-error "" } */ +unsigned short _Complex __int128 *x276; /* { dg-error "" } */ +unsigned int short __int128 *x277; /* { dg-error "" } */ +unsigned int long __int128 *x278; /* { dg-error "" } */ +unsigned int _Complex __int128 *x279; /* { dg-error "" } */ +unsigned __int128 _Complex void *x280; /* { dg-error "" } */ +unsigned __int128 _Complex char *x281; /* { dg-error "" } */ +unsigned __int128 _Complex short *x282; /* { dg-error "" } */ +unsigned __int128 _Complex int *x283; /* { dg-error "" } */ +unsigned __int128 _Complex __int128 *x284; /* { dg-error "" } */ +unsigned __int128 _Complex long *x285; /* { dg-error "" } */ +unsigned __int128 _Complex float *x286; /* { dg-error "" } */ +unsigned __int128 _Complex double *x287; /* { dg-error "" } */ +unsigned __int128 _Complex signed *x288; /* { dg-error "" } */ +unsigned __int128 _Complex unsigned *x289; /* { dg-error "" } */ +unsigned __int128 _Complex _Bool *x290; /* { dg-error "" } */ +unsigned __int128 _Complex _Complex *x291; /* { dg-error "" } */ +unsigned long int __int128 *x292; /* { dg-error "" } */ +unsigned long long __int128 *x293; /* { dg-error "" } */ +unsigned long _Complex __int128 *x294; /* { dg-error "" } */ +unsigned _Complex char __int128 *x295; /* { dg-error "" } */ +unsigned _Complex short __int128 *x296; /* { dg-error "" } */ +unsigned _Complex int __int128 *x297; /* { dg-error "" } */ +unsigned _Complex __int128 void *x298; /* { dg-error "" } */ +unsigned _Complex __int128 char *x299; /* { dg-error "" } */ +unsigned _Complex __int128 short *x300; /* { dg-error "" } */ +unsigned _Complex __int128 int *x301; /* { dg-error "" } */ +unsigned _Complex __int128 __int128 *x302; /* { dg-error "" } */ +unsigned _Complex __int128 long *x303; /* { dg-error "" } */ +unsigned _Complex __int128 float *x304; /* { dg-error "" } */ +unsigned _Complex __int128 double *x305; /* { dg-error "" } */ +unsigned _Complex __int128 signed *x306; /* { dg-error "" } */ +unsigned _Complex __int128 unsigned *x307; /* { dg-error "" } */ +unsigned _Complex __int128 _Bool *x308; /* { dg-error "" } */ +unsigned _Complex __int128 _Complex *x309; /* { dg-error "" } */ +unsigned _Complex long __int128 *x310; /* { dg-error "" } */ +_Complex char signed __int128 *x311; /* { dg-error "" } */ +_Complex char unsigned __int128 *x312; /* { dg-error "" } */ +_Complex short int __int128 *x313; /* { dg-error "" } */ +_Complex short signed __int128 *x314; /* { dg-error "" } */ +_Complex short unsigned __int128 *x315; /* { dg-error "" } */ +_Complex int short __int128 *x316; /* { dg-error "" } */ +_Complex int long __int128 *x317; /* { dg-error "" } */ +_Complex int signed __int128 *x318; /* { dg-error "" } */ +_Complex int unsigned __int128 *x319; /* { dg-error "" } */ +_Complex __int128 signed void *x320; /* { dg-error "" } */ +_Complex __int128 signed char *x321; /* { dg-error "" } */ +_Complex __int128 signed short *x322; /* { dg-error "" } */ +_Complex __int128 signed int *x323; /* { dg-error "" } */ +_Complex __int128 signed __int128 *x324; /* { dg-error "" } */ +_Complex __int128 signed long *x325; /* { dg-error "" } */ +_Complex __int128 signed float *x326; /* { dg-error "" } */ +_Complex __int128 signed double *x327; /* { dg-error "" } */ +_Complex __int128 signed signed *x328; /* { dg-error "" } */ +_Complex __int128 signed unsigned *x329; /* { dg-error "" } */ +_Complex __int128 signed _Bool *x330; /* { dg-error "" } */ +_Complex __int128 signed _Complex *x331; /* { dg-error "" } */ +_Complex __int128 unsigned void *x332; /* { dg-error "" } */ +_Complex __int128 unsigned char *x333; /* { dg-error "" } */ +_Complex __int128 unsigned short *x334; /* { dg-error "" } */ +_Complex __int128 unsigned int *x335; /* { dg-error "" } */ +_Complex __int128 unsigned __int128 *x336; /* { dg-error "" } */ +_Complex __int128 unsigned long *x337; /* { dg-error "" } */ +_Complex __int128 unsigned float *x338; /* { dg-error "" } */ +_Complex __int128 unsigned double *x339; /* { dg-error "" } */ +_Complex __int128 unsigned signed *x340; /* { dg-error "" } */ +_Complex __int128 unsigned unsigned *x341; /* { dg-error "" } */ +_Complex __int128 unsigned _Bool *x342; /* { dg-error "" } */ +_Complex __int128 unsigned _Complex *x343; /* { dg-error "" } */ +_Complex long int __int128 *x344; /* { dg-error "" } */ +_Complex long long __int128 *x345; /* { dg-error "" } */ +_Complex long double __int128 *x346; /* { dg-error "" } */ +_Complex long signed __int128 *x347; /* { dg-error "" } */ +_Complex long unsigned __int128 *x348; /* { dg-error "" } */ +_Complex double long __int128 *x349; /* { dg-error "" } */ +_Complex signed char __int128 *x350; /* { dg-error "" } */ +_Complex signed short __int128 *x351; /* { dg-error "" } */ +_Complex signed int __int128 *x352; /* { dg-error "" } */ +_Complex signed __int128 void *x353; /* { dg-error "" } */ +_Complex signed __int128 char *x354; /* { dg-error "" } */ +_Complex signed __int128 short *x355; /* { dg-error "" } */ +_Complex signed __int128 int *x356; /* { dg-error "" } */ +_Complex signed __int128 __int128 *x357; /* { dg-error "" } */ +_Complex signed __int128 long *x358; /* { dg-error "" } */ +_Complex signed __int128 float *x359; /* { dg-error "" } */ +_Complex signed __int128 double *x360; /* { dg-error "" } */ +_Complex signed __int128 signed *x361; /* { dg-error "" } */ +_Complex signed __int128 unsigned *x362; /* { dg-error "" } */ +_Complex signed __int128 _Bool *x363; /* { dg-error "" } */ +_Complex signed __int128 _Complex *x364; /* { dg-error "" } */ +_Complex signed long __int128 *x365; /* { dg-error "" } */ +_Complex unsigned char __int128 *x366; /* { dg-error "" } */ +_Complex unsigned short __int128 *x367; /* { dg-error "" } */ +_Complex unsigned int __int128 *x368; /* { dg-error "" } */ +_Complex unsigned __int128 void *x369; /* { dg-error "" } */ +_Complex unsigned __int128 char *x370; /* { dg-error "" } */ +_Complex unsigned __int128 short *x371; /* { dg-error "" } */ +_Complex unsigned __int128 int *x372; /* { dg-error "" } */ +_Complex unsigned __int128 __int128 *x373; /* { dg-error "" } */ +_Complex unsigned __int128 long *x374; /* { dg-error "" } */ +_Complex unsigned __int128 float *x375; /* { dg-error "" } */ +_Complex unsigned __int128 double *x376; /* { dg-error "" } */ +_Complex unsigned __int128 signed *x377; /* { dg-error "" } */ +_Complex unsigned __int128 unsigned *x378; /* { dg-error "" } */ +_Complex unsigned __int128 _Bool *x379; /* { dg-error "" } */ +_Complex unsigned __int128 _Complex *x380; /* { dg-error "" } */ +_Complex unsigned long __int128 *x381; /* { dg-error "" } */ +short int signed _Complex __int128 *x382; /* { dg-error "" } */ +short int unsigned _Complex __int128 *x383; /* { dg-error "" } */ +short int _Complex signed __int128 *x384; /* { dg-error "" } */ +short int _Complex unsigned __int128 *x385; /* { dg-error "" } */ +short signed int _Complex __int128 *x386; /* { dg-error "" } */ +short signed _Complex int __int128 *x387; /* { dg-error "" } */ +short unsigned int _Complex __int128 *x388; /* { dg-error "" } */ +short unsigned _Complex int __int128 *x389; /* { dg-error "" } */ +short _Complex int signed __int128 *x390; /* { dg-error "" } */ +short _Complex int unsigned __int128 *x391; /* { dg-error "" } */ +short _Complex signed int __int128 *x392; /* { dg-error "" } */ +short _Complex unsigned int __int128 *x393; /* { dg-error "" } */ +int short signed _Complex __int128 *x394; /* { dg-error "" } */ +int short unsigned _Complex __int128 *x395; /* { dg-error "" } */ +int short _Complex signed __int128 *x396; /* { dg-error "" } */ +int short _Complex unsigned __int128 *x397; /* { dg-error "" } */ +int long long signed __int128 *x398; /* { dg-error "" } */ +int long long unsigned __int128 *x399; /* { dg-error "" } */ +int long long _Complex __int128 *x400; /* { dg-error "" } */ +int long signed long __int128 *x401; /* { dg-error "" } */ +int long signed _Complex __int128 *x402; /* { dg-error "" } */ +int long unsigned long __int128 *x403; /* { dg-error "" } */ +int long unsigned _Complex __int128 *x404; /* { dg-error "" } */ +int long _Complex long __int128 *x405; /* { dg-error "" } */ +int long _Complex signed __int128 *x406; /* { dg-error "" } */ +int long _Complex unsigned __int128 *x407; /* { dg-error "" } */ +int signed short _Complex __int128 *x408; /* { dg-error "" } */ +int signed long long __int128 *x409; /* { dg-error "" } */ +int signed long _Complex __int128 *x410; /* { dg-error "" } */ +int signed _Complex short __int128 *x411; /* { dg-error "" } */ +int signed _Complex long __int128 *x412; /* { dg-error "" } */ +int unsigned short _Complex __int128 *x413; /* { dg-error "" } */ +int unsigned long long __int128 *x414; /* { dg-error "" } */ +int unsigned long _Complex __int128 *x415; /* { dg-error "" } */ +int unsigned _Complex short __int128 *x416; /* { dg-error "" } */ +int unsigned _Complex long __int128 *x417; /* { dg-error "" } */ +int _Complex short signed __int128 *x418; /* { dg-error "" } */ +int _Complex short unsigned __int128 *x419; /* { dg-error "" } */ +int _Complex long long __int128 *x420; /* { dg-error "" } */ +int _Complex long signed __int128 *x421; /* { dg-error "" } */ +int _Complex long unsigned __int128 *x422; /* { dg-error "" } */ +int _Complex signed short __int128 *x423; /* { dg-error "" } */ +int _Complex signed long __int128 *x424; /* { dg-error "" } */ +int _Complex unsigned short __int128 *x425; /* { dg-error "" } */ +int _Complex unsigned long __int128 *x426; /* { dg-error "" } */ +long int long signed __int128 *x427; /* { dg-error "" } */ +long int long unsigned __int128 *x428; /* { dg-error "" } */ +long int long _Complex __int128 *x429; /* { dg-error "" } */ +long int signed long __int128 *x430; /* { dg-error "" } */ +long int signed _Complex __int128 *x431; /* { dg-error "" } */ +long int unsigned long __int128 *x432; /* { dg-error "" } */ +long int unsigned _Complex __int128 *x433; /* { dg-error "" } */ +long int _Complex long __int128 *x434; /* { dg-error "" } */ +long int _Complex signed __int128 *x435; /* { dg-error "" } */ +long int _Complex unsigned __int128 *x436; /* { dg-error "" } */ +long long int signed __int128 *x437; /* { dg-error "" } */ +long long int unsigned __int128 *x438; /* { dg-error "" } */ +long long int _Complex __int128 *x439; /* { dg-error "" } */ +long long signed int __int128 *x440; /* { dg-error "" } */ +long long signed _Complex __int128 *x441; /* { dg-error "" } */ +long long unsigned int __int128 *x442; /* { dg-error "" } */ +long long unsigned _Complex __int128 *x443; /* { dg-error "" } */ +long long _Complex int __int128 *x444; /* { dg-error "" } */ +long long _Complex signed __int128 *x445; /* { dg-error "" } */ +long long _Complex unsigned __int128 *x446; /* { dg-error "" } */ +long signed int long __int128 *x447; /* { dg-error "" } */ +long signed int _Complex __int128 *x448; /* { dg-error "" } */ +long signed long int __int128 *x449; /* { dg-error "" } */ +long signed long _Complex __int128 *x450; /* { dg-error "" } */ +long signed _Complex int __int128 *x451; /* { dg-error "" } */ +long signed _Complex long __int128 *x452; /* { dg-error "" } */ +long unsigned int long __int128 *x453; /* { dg-error "" } */ +long unsigned int _Complex __int128 *x454; /* { dg-error "" } */ +long unsigned long int __int128 *x455; /* { dg-error "" } */ +long unsigned long _Complex __int128 *x456; /* { dg-error "" } */ +long unsigned _Complex int __int128 *x457; /* { dg-error "" } */ +long unsigned _Complex long __int128 *x458; /* { dg-error "" } */ +long _Complex int long __int128 *x459; /* { dg-error "" } */ +long _Complex int signed __int128 *x460; /* { dg-error "" } */ +long _Complex int unsigned __int128 *x461; /* { dg-error "" } */ +long _Complex long int __int128 *x462; /* { dg-error "" } */ +long _Complex long signed __int128 *x463; /* { dg-error "" } */ +long _Complex long unsigned __int128 *x464; /* { dg-error "" } */ +long _Complex signed int __int128 *x465; /* { dg-error "" } */ +long _Complex signed long __int128 *x466; /* { dg-error "" } */ +long _Complex unsigned int __int128 *x467; /* { dg-error "" } */ +long _Complex unsigned long __int128 *x468; /* { dg-error "" } */ +signed short int _Complex __int128 *x469; /* { dg-error "" } */ +signed short _Complex int __int128 *x470; /* { dg-error "" } */ +signed int short _Complex __int128 *x471; /* { dg-error "" } */ +signed int long long __int128 *x472; /* { dg-error "" } */ +signed int long _Complex __int128 *x473; /* { dg-error "" } */ +signed int _Complex short __int128 *x474; /* { dg-error "" } */ +signed int _Complex long __int128 *x475; /* { dg-error "" } */ +signed long int long __int128 *x476; /* { dg-error "" } */ +signed long int _Complex __int128 *x477; /* { dg-error "" } */ +signed long long int __int128 *x478; /* { dg-error "" } */ +signed long long _Complex __int128 *x479; /* { dg-error "" } */ +signed long _Complex int __int128 *x480; /* { dg-error "" } */ +signed long _Complex long __int128 *x481; /* { dg-error "" } */ +signed _Complex short int __int128 *x482; /* { dg-error "" } */ +signed _Complex int short __int128 *x483; /* { dg-error "" } */ +signed _Complex int long __int128 *x484; /* { dg-error "" } */ +signed _Complex long int __int128 *x485; /* { dg-error "" } */ +signed _Complex long long __int128 *x486; /* { dg-error "" } */ +unsigned short int _Complex __int128 *x487; /* { dg-error "" } */ +unsigned short _Complex int __int128 *x488; /* { dg-error "" } */ +unsigned int short _Complex __int128 *x489; /* { dg-error "" } */ +unsigned int long long __int128 *x490; /* { dg-error "" } */ +unsigned int long _Complex __int128 *x491; /* { dg-error "" } */ +unsigned int _Complex short __int128 *x492; /* { dg-error "" } */ +unsigned int _Complex long __int128 *x493; /* { dg-error "" } */ +unsigned long int long __int128 *x494; /* { dg-error "" } */ +unsigned long int _Complex __int128 *x495; /* { dg-error "" } */ +unsigned long long int __int128 *x496; /* { dg-error "" } */ +unsigned long long _Complex __int128 *x497; /* { dg-error "" } */ +unsigned long _Complex int __int128 *x498; /* { dg-error "" } */ +unsigned long _Complex long __int128 *x499; /* { dg-error "" } */ +unsigned _Complex short int __int128 *x500; /* { dg-error "" } */ +unsigned _Complex int short __int128 *x501; /* { dg-error "" } */ +unsigned _Complex int long __int128 *x502; /* { dg-error "" } */ +unsigned _Complex long int __int128 *x503; /* { dg-error "" } */ +unsigned _Complex long long __int128 *x504; /* { dg-error "" } */ +_Complex short int signed __int128 *x505; /* { dg-error "" } */ +_Complex short int unsigned __int128 *x506; /* { dg-error "" } */ +_Complex short signed int __int128 *x507; /* { dg-error "" } */ +_Complex short unsigned int __int128 *x508; /* { dg-error "" } */ +_Complex int short signed __int128 *x509; /* { dg-error "" } */ +_Complex int short unsigned __int128 *x510; /* { dg-error "" } */ +_Complex int long long __int128 *x511; /* { dg-error "" } */ +_Complex int long signed __int128 *x512; /* { dg-error "" } */ +_Complex int long unsigned __int128 *x513; /* { dg-error "" } */ +_Complex int signed short __int128 *x514; /* { dg-error "" } */ +_Complex int signed long __int128 *x515; /* { dg-error "" } */ +_Complex int unsigned short __int128 *x516; /* { dg-error "" } */ +_Complex int unsigned long __int128 *x517; /* { dg-error "" } */ +_Complex long int long __int128 *x518; /* { dg-error "" } */ +_Complex long int signed __int128 *x519; /* { dg-error "" } */ +_Complex long int unsigned __int128 *x520; /* { dg-error "" } */ +_Complex long long int __int128 *x521; /* { dg-error "" } */ +_Complex long long signed __int128 *x522; /* { dg-error "" } */ +_Complex long long unsigned __int128 *x523; /* { dg-error "" } */ +_Complex long signed int __int128 *x524; /* { dg-error "" } */ +_Complex long signed long __int128 *x525; /* { dg-error "" } */ +_Complex long unsigned int __int128 *x526; /* { dg-error "" } */ +_Complex long unsigned long __int128 *x527; /* { dg-error "" } */ +_Complex signed short int __int128 *x528; /* { dg-error "" } */ +_Complex signed int short __int128 *x529; /* { dg-error "" } */ +_Complex signed int long __int128 *x530; /* { dg-error "" } */ +_Complex signed long int __int128 *x531; /* { dg-error "" } */ +_Complex signed long long __int128 *x532; /* { dg-error "" } */ +_Complex unsigned short int __int128 *x533; /* { dg-error "" } */ +_Complex unsigned int short __int128 *x534; /* { dg-error "" } */ +_Complex unsigned int long __int128 *x535; /* { dg-error "" } */ +_Complex unsigned long int __int128 *x536; /* { dg-error "" } */ +_Complex unsigned long long __int128 *x537; /* { dg-error "" } */ +int long long signed _Complex __int128 *x538; /* { dg-error "" } */ +int long long unsigned _Complex __int128 *x539; /* { dg-error "" } */ +int long long _Complex signed __int128 *x540; /* { dg-error "" } */ +int long long _Complex unsigned __int128 *x541; /* { dg-error "" } */ +int long signed long _Complex __int128 *x542; /* { dg-error "" } */ +int long signed _Complex long __int128 *x543; /* { dg-error "" } */ +int long unsigned long _Complex __int128 *x544; /* { dg-error "" } */ +int long unsigned _Complex long __int128 *x545; /* { dg-error "" } */ +int long _Complex long signed __int128 *x546; /* { dg-error "" } */ +int long _Complex long unsigned __int128 *x547; /* { dg-error "" } */ +int long _Complex signed long __int128 *x548; /* { dg-error "" } */ +int long _Complex unsigned long __int128 *x549; /* { dg-error "" } */ +int signed long long _Complex __int128 *x550; /* { dg-error "" } */ +int signed long _Complex long __int128 *x551; /* { dg-error "" } */ +int signed _Complex long long __int128 *x552; /* { dg-error "" } */ +int unsigned long long _Complex __int128 *x553; /* { dg-error "" } */ +int unsigned long _Complex long __int128 *x554; /* { dg-error "" } */ +int unsigned _Complex long long __int128 *x555; /* { dg-error "" } */ +int _Complex long long signed __int128 *x556; /* { dg-error "" } */ +int _Complex long long unsigned __int128 *x557; /* { dg-error "" } */ +int _Complex long signed long __int128 *x558; /* { dg-error "" } */ +int _Complex long unsigned long __int128 *x559; /* { dg-error "" } */ +int _Complex signed long long __int128 *x560; /* { dg-error "" } */ +int _Complex unsigned long long __int128 *x561; /* { dg-error "" } */ +long int long signed _Complex __int128 *x562; /* { dg-error "" } */ +long int long unsigned _Complex __int128 *x563; /* { dg-error "" } */ +long int long _Complex signed __int128 *x564; /* { dg-error "" } */ +long int long _Complex unsigned __int128 *x565; /* { dg-error "" } */ +long int signed long _Complex __int128 *x566; /* { dg-error "" } */ +long int signed _Complex long __int128 *x567; /* { dg-error "" } */ +long int unsigned long _Complex __int128 *x568; /* { dg-error "" } */ +long int unsigned _Complex long __int128 *x569; /* { dg-error "" } */ +long int _Complex long signed __int128 *x570; /* { dg-error "" } */ +long int _Complex long unsigned __int128 *x571; /* { dg-error "" } */ +long int _Complex signed long __int128 *x572; /* { dg-error "" } */ +long int _Complex unsigned long __int128 *x573; /* { dg-error "" } */ +long long int signed _Complex __int128 *x574; /* { dg-error "" } */ +long long int unsigned _Complex __int128 *x575; /* { dg-error "" } */ +long long int _Complex signed __int128 *x576; /* { dg-error "" } */ +long long int _Complex unsigned __int128 *x577; /* { dg-error "" } */ +long long signed int _Complex __int128 *x578; /* { dg-error "" } */ +long long signed _Complex int __int128 *x579; /* { dg-error "" } */ +long long unsigned int _Complex __int128 *x580; /* { dg-error "" } */ +long long unsigned _Complex int __int128 *x581; /* { dg-error "" } */ +long long _Complex int signed __int128 *x582; /* { dg-error "" } */ +long long _Complex int unsigned __int128 *x583; /* { dg-error "" } */ +long long _Complex signed int __int128 *x584; /* { dg-error "" } */ +long long _Complex unsigned int __int128 *x585; /* { dg-error "" } */ +long signed int long _Complex __int128 *x586; /* { dg-error "" } */ +long signed int _Complex long __int128 *x587; /* { dg-error "" } */ +long signed long int _Complex __int128 *x588; /* { dg-error "" } */ +long signed long _Complex int __int128 *x589; /* { dg-error "" } */ +long signed _Complex int long __int128 *x590; /* { dg-error "" } */ +long signed _Complex long int __int128 *x591; /* { dg-error "" } */ +long unsigned int long _Complex __int128 *x592; /* { dg-error "" } */ +long unsigned int _Complex long __int128 *x593; /* { dg-error "" } */ +long unsigned long int _Complex __int128 *x594; /* { dg-error "" } */ +long unsigned long _Complex int __int128 *x595; /* { dg-error "" } */ +long unsigned _Complex int long __int128 *x596; /* { dg-error "" } */ +long unsigned _Complex long int __int128 *x597; /* { dg-error "" } */ +long _Complex int long signed __int128 *x598; /* { dg-error "" } */ +long _Complex int long unsigned __int128 *x599; /* { dg-error "" } */ +long _Complex int signed long __int128 *x600; /* { dg-error "" } */ +long _Complex int unsigned long __int128 *x601; /* { dg-error "" } */ +long _Complex long int signed __int128 *x602; /* { dg-error "" } */ +long _Complex long int unsigned __int128 *x603; /* { dg-error "" } */ +long _Complex long signed int __int128 *x604; /* { dg-error "" } */ +long _Complex long unsigned int __int128 *x605; /* { dg-error "" } */ +long _Complex signed int long __int128 *x606; /* { dg-error "" } */ +long _Complex signed long int __int128 *x607; /* { dg-error "" } */ +long _Complex unsigned int long __int128 *x608; /* { dg-error "" } */ +long _Complex unsigned long int __int128 *x609; /* { dg-error "" } */ +signed int long long _Complex __int128 *x610; /* { dg-error "" } */ +signed int long _Complex long __int128 *x611; /* { dg-error "" } */ +signed int _Complex long long __int128 *x612; /* { dg-error "" } */ +signed long int long _Complex __int128 *x613; /* { dg-error "" } */ +signed long int _Complex long __int128 *x614; /* { dg-error "" } */ +signed long long int _Complex __int128 *x615; /* { dg-error "" } */ +signed long long _Complex int __int128 *x616; /* { dg-error "" } */ +signed long _Complex int long __int128 *x617; /* { dg-error "" } */ +signed long _Complex long int __int128 *x618; /* { dg-error "" } */ +signed _Complex int long long __int128 *x619; /* { dg-error "" } */ +signed _Complex long int long __int128 *x620; /* { dg-error "" } */ +signed _Complex long long int __int128 *x621; /* { dg-error "" } */ +unsigned int long long _Complex __int128 *x622; /* { dg-error "" } */ +unsigned int long _Complex long __int128 *x623; /* { dg-error "" } */ +unsigned int _Complex long long __int128 *x624; /* { dg-error "" } */ +unsigned long int long _Complex __int128 *x625; /* { dg-error "" } */ +unsigned long int _Complex long __int128 *x626; /* { dg-error "" } */ +unsigned long long int _Complex __int128 *x627; /* { dg-error "" } */ +unsigned long long _Complex int __int128 *x628; /* { dg-error "" } */ +unsigned long _Complex int long __int128 *x629; /* { dg-error "" } */ +unsigned long _Complex long int __int128 *x630; /* { dg-error "" } */ +unsigned _Complex int long long __int128 *x631; /* { dg-error "" } */ +unsigned _Complex long int long __int128 *x632; /* { dg-error "" } */ +unsigned _Complex long long int __int128 *x633; /* { dg-error "" } */ +_Complex int long long signed __int128 *x634; /* { dg-error "" } */ +_Complex int long long unsigned __int128 *x635; /* { dg-error "" } */ +_Complex int long signed long __int128 *x636; /* { dg-error "" } */ +_Complex int long unsigned long __int128 *x637; /* { dg-error "" } */ +_Complex int signed long long __int128 *x638; /* { dg-error "" } */ +_Complex int unsigned long long __int128 *x639; /* { dg-error "" } */ +_Complex long int long signed __int128 *x640; /* { dg-error "" } */ +_Complex long int long unsigned __int128 *x641; /* { dg-error "" } */ +_Complex long int signed long __int128 *x642; /* { dg-error "" } */ +_Complex long int unsigned long __int128 *x643; /* { dg-error "" } */ +_Complex long long int signed __int128 *x644; /* { dg-error "" } */ +_Complex long long int unsigned __int128 *x645; /* { dg-error "" } */ +_Complex long long signed int __int128 *x646; /* { dg-error "" } */ +_Complex long long unsigned int __int128 *x647; /* { dg-error "" } */ +_Complex long signed int long __int128 *x648; /* { dg-error "" } */ +_Complex long signed long int __int128 *x649; /* { dg-error "" } */ +_Complex long unsigned int long __int128 *x650; /* { dg-error "" } */ +_Complex long unsigned long int __int128 *x651; /* { dg-error "" } */ +_Complex signed int long long __int128 *x652; /* { dg-error "" } */ +_Complex signed long int long __int128 *x653; /* { dg-error "" } */ +_Complex signed long long int __int128 *x654; /* { dg-error "" } */ +_Complex unsigned int long long __int128 *x655; /* { dg-error "" } */ +_Complex unsigned long int long __int128 *x656; /* { dg-error "" } */ +_Complex unsigned long long int __int128 *x657; /* { dg-error "" } */ Index: transparent-union-1.c =================================================================== --- transparent-union-1.c (nonexistent) +++ transparent-union-1.c (revision 686) @@ -0,0 +1,5 @@ +/* PR c++/51228 */ + +typedef union {} U __attribute__((transparent_union)); /* { dg-warning "ignored" } */ + +void foo(U u) {} Index: Wunused-var-9.c =================================================================== --- Wunused-var-9.c (nonexistent) +++ Wunused-var-9.c (revision 686) @@ -0,0 +1,80 @@ +/* { dg-options "-Wunused" } */ +/* { dg-do compile } */ + +int f1 (int *, int); +int f2 (int *); +int f3 (int *); + +int +f4 (int x) +{ + int a, n = 0; + int b; + for (a = f1 (&b, x); f2 (&b); (void) (a = f3 (&b))) + n++; + return n; +} + +void +f5 (int x) +{ + int a; + a = x; + (void) (a = x); +} + +void +f6 (int x) +{ + int a; /* { dg-warning "set but not used" } */ + a = x; +} + +void +f7 (int x) +{ + int a; + ({ a = x; }); +} + +int +f8 (int x) +{ + int a; + int b = ({ a = x; }); + return b; +} + +int v; + +void +f9 (int x) +{ + int a; + ({ v++, a = x; }); +} + +int +f10 (int x) +{ + int a; + int b = ({ v++, a = x; }); + return b; +} + +void +f11 (int x) +{ + int a; + a = x; + ({ v++, a; }); +} + +int +f12 (int x) +{ + int a; + a = x; + int b = ({ v++, a; }); + return b; +} Index: uninit-D.c =================================================================== --- uninit-D.c (nonexistent) +++ uninit-D.c (revision 686) @@ -0,0 +1,9 @@ +/* Test we do not warn about initializing variable with self. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +int f() +{ + int i = i; + return i; +} Index: pr52177.c =================================================================== --- pr52177.c (nonexistent) +++ pr52177.c (revision 686) @@ -0,0 +1,23 @@ +/* PR middle-end/52177 */ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-ccp" } */ + +int *s; + +static inline int +foo () +{ + return sizeof (int); +} + +int +bar () +{ + return __atomic_always_lock_free (foo (), s); +} + +int +baz () +{ + return __atomic_is_lock_free (foo (), s); +} Index: pr43942.c =================================================================== --- pr43942.c (nonexistent) +++ pr43942.c (revision 686) @@ -0,0 +1,33 @@ +/* PR debug/43942 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fcompare-debug" } */ + +extern int f1 (int); + +int +f2 (int x) +{ + extern int v; + return f1 (x); +} + +void +f3 (void) +{ + f2 (0); +} + +static inline int +f4 (int x) +{ + extern int w; + if (w) + return f1 (x); + return 0; +} + +void +f5 (void) +{ + f4 (0); +} Index: pr42674.c =================================================================== --- pr42674.c (nonexistent) +++ pr42674.c (revision 686) @@ -0,0 +1,13 @@ +/* PR middle-end/42674 */ +/* { dg-do compile } */ +/* { dg-options "-Wreturn-type" } */ + +extern void bar (void); +static int foo (void) __attribute__ ((__noreturn__, __used__)); + +static int +foo (void) +{ + while (1) + bar (); +} Index: uninit-F.c =================================================================== --- uninit-F.c (nonexistent) +++ uninit-F.c (revision 686) @@ -0,0 +1,9 @@ +/* Test we do warn about initializing variable with self in the initialization. */ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +int f() +{ + int i = i + 1; /* { dg-warning "i" "uninitialized variable warning" } */ + return i; +} Index: raw-string-2.c =================================================================== --- raw-string-2.c (nonexistent) +++ raw-string-2.c (revision 686) @@ -0,0 +1,125 @@ +// { dg-do run } +// { dg-require-effective-target wchar } +// { dg-options "-std=gnu99 -Wno-c++-compat -trigraphs" { target c } } +// { dg-options "-std=c++0x" { target c++ } } + +#ifndef __cplusplus +#include + +typedef __CHAR16_TYPE__ char16_t; +typedef __CHAR32_TYPE__ char32_t; +#endif + +#define R +#define u +#define uR +#define U +#define UR +#define u8 +#define u8R +#define L +#define LR + +const char s00[] = R"(a)" "(b)"; +const char s01[] = "(a)" R"*(b)*"; +const char s02[] = R"(a)" R"(b)"; +const char s03[] = R"-(a)-" u8"(b)"; +const char s04[] = "(a)" u8R"MNOPQRSTUVWXYZ(b)MNOPQRSTUVWXYZ"; +const char s05[] = R"(a)" u8R"wxyzABCDEFGHIJKL(b)wxyzABCDEFGHIJKL"; +const char s06[] = u8R";[(a);[" "(b)"; +const char s07[] = u8"(a)" R"(b)"; +const char s08[] = u8R"(a)" R"_{}#[]<>%:;.?*+-(b)_{}#[]<>%:;.?*+-"; +const char s09[] = u8R"/^&|~!=,"'(a)/^&|~!=,"'" u8"(b)"; +const char s10[] = u8"(a)" u8R"0123456789abcdef(b)0123456789abcdef"; +const char s11[] = u8R"ghijklmnopqrstuv(a)ghijklmnopqrstuv" u8R"w(b)w"; +const char s12[] = R"??=??(????)??'??!??-\ +(a)#[{}]^|~"; + +const char16_t u03[] = R"-(a)-" u"(b)"; +const char16_t u04[] = "(a)" uR"MNOPQRSTUVWXYZ(b)MNOPQRSTUVWXYZ"; +const char16_t u05[] = R"(a)" uR"wxyzABCDEFGHIJKL(b)wxyzABCDEFGHIJKL"; +const char16_t u06[] = uR";[(a);[" "(b)"; +const char16_t u07[] = u"(a)" R"(b)"; +const char16_t u08[] = uR"(a)" R"_{}#[]<>%:;.?*+-(b)_{}#[]<>%:;.?*+-"; +const char16_t u09[] = uR"/^&|~!=,"'(a)/^&|~!=,"'" u"(b)"; +const char16_t u10[] = u"(a)" uR"0123456789abcdef(b)0123456789abcdef"; +const char16_t u11[] = uR"ghijklmnopqrstuv(a)ghijklmnopqrstuv" uR"w(b)w"; +const char16_t u12[] = uR"??=??(????)??'??!??-\ +(a)#[{}]^|~"; + +const char32_t U03[] = R"-(a)-" U"(b)"; +const char32_t U04[] = "(a)" UR"MNOPQRSTUVWXYZ(b)MNOPQRSTUVWXYZ"; +const char32_t U05[] = R"(a)" UR"wxyzABCDEFGHIJKL(b)wxyzABCDEFGHIJKL"; +const char32_t U06[] = UR";[(a);[" "(b)"; +const char32_t U07[] = U"(a)" R"(b)"; +const char32_t U08[] = UR"(a)" R"_{}#[]<>%:;.?*+-(b)_{}#[]<>%:;.?*+-"; +const char32_t U09[] = UR"/^&|~!=,"'(a)/^&|~!=,"'" U"(b)"; +const char32_t U10[] = U"(a)" UR"0123456789abcdef(b)0123456789abcdef"; +const char32_t U11[] = UR"ghijklmnopqrstuv(a)ghijklmnopqrstuv" UR"w(b)w"; +const char32_t U12[] = UR"??=??(????)??'??!??-\ +(a)#[{}]^|~"; + +const wchar_t L03[] = R"-(a)-" L"(b)"; +const wchar_t L04[] = "(a)" LR"MNOPQRSTUVWXYZ(b)MNOPQRSTUVWXYZ"; +const wchar_t L05[] = R"(a)" LR"wxyzABCDEFGHIJKL(b)wxyzABCDEFGHIJKL"; +const wchar_t L06[] = LR";[(a);[" "(b)"; +const wchar_t L07[] = L"(a)" R"(b)"; +const wchar_t L08[] = LR"(a)" R"_{}#[]<>%:;.?*+-(b)_{}#[]<>%:;.?*+-"; +const wchar_t L09[] = LR"/^&|~!=,"'(a)/^&|~!=,"'" L"(b)"; +const wchar_t L10[] = L"(a)" LR"0123456789abcdef(b)0123456789abcdef"; +const wchar_t L11[] = LR"ghijklmnopqrstuv(a)ghijklmnopqrstuv" LR"w(b)w"; +const wchar_t L12[] = LR"??=??(????)??'??!??-\ +(a)#[{}]^|~"; + +int +main (void) +{ +#define TEST(str, val) \ + if (sizeof (str) != sizeof (val) \ + || __builtin_memcmp (str, val, sizeof (str)) != 0) \ + __builtin_abort () + TEST (s00, "a(b)"); + TEST (s01, "(a)b"); + TEST (s02, "ab"); + TEST (s03, "a(b)"); + TEST (s04, "(a)b"); + TEST (s05, "ab"); + TEST (s06, "a(b)"); + TEST (s07, "(a)b"); + TEST (s08, "ab"); + TEST (s09, "a(b)"); + TEST (s10, "(a)b"); + TEST (s11, "ab"); + TEST (s12, "a"); + TEST (u03, u"a(b)"); + TEST (u04, u"(a)b"); + TEST (u05, u"ab"); + TEST (u06, u"a(b)"); + TEST (u07, u"(a)b"); + TEST (u08, u"ab"); + TEST (u09, u"a(b)"); + TEST (u10, u"(a)b"); + TEST (u11, u"ab"); + TEST (u12, u"a"); + TEST (U03, U"a(b)"); + TEST (U04, U"(a)b"); + TEST (U05, U"ab"); + TEST (U06, U"a(b)"); + TEST (U07, U"(a)b"); + TEST (U08, U"ab"); + TEST (U09, U"a(b)"); + TEST (U10, U"(a)b"); + TEST (U11, U"ab"); + TEST (U12, U"a"); + TEST (L03, L"a(b)"); + TEST (L04, L"(a)b"); + TEST (L05, L"ab"); + TEST (L06, L"a(b)"); + TEST (L07, L"(a)b"); + TEST (L08, L"ab"); + TEST (L09, L"a(b)"); + TEST (L10, L"(a)b"); + TEST (L11, L"ab"); + TEST (L12, L"a"); + return 0; +} Index: raw-string-4.c =================================================================== --- raw-string-4.c (nonexistent) +++ raw-string-4.c (revision 686) @@ -0,0 +1,29 @@ +// R is not applicable for character literals. +// { dg-do compile } +// { dg-options "-std=gnu99" { target c } } +// { dg-options "-std=c++0x" { target c++ } } + +const int i0 = R'a'; // { dg-error "was not declared|undeclared" } + // { dg-error "expected ',' or ';'" "" { target *-*-* } 6 } +const int i1 = uR'a'; // { dg-error "was not declared|undeclared" } + // { dg-error "expected ',' or ';'" "" { target *-*-* } 8 } +const int i2 = UR'a'; // { dg-error "was not declared|undeclared" } + // { dg-error "expected ',' or ';'" "" { target *-*-* } 10 } +const int i3 = u8R'a'; // { dg-error "was not declared|undeclared" } + // { dg-error "expected ',' or ';'" "" { target *-*-* } 12 } +const int i4 = LR'a'; // { dg-error "was not declared|undeclared" } + // { dg-error "expected ',' or ';'" "" { target *-*-* } 14 } + +#define R 1 + +#define uR 2 + +#define UR 3 + +#define u8R 4 + +#define LR 5 + + +const int i5 = R'a'; +const int i6 = uR'a'; +const int i7 = UR'a'; +const int i8 = u8R'a'; +const int i9 = LR'a'; + +int main () {} Index: Wunused-var-10.c =================================================================== --- Wunused-var-10.c (nonexistent) +++ Wunused-var-10.c (revision 686) @@ -0,0 +1,68 @@ +/* PR c++/44362 */ +/* { dg-options "-Wunused" } */ +/* { dg-do compile } */ + +int +f1 (int u, int v) +{ + int a, b, c, d, e, f, g, h, i; + a = u; + b = v; + c = u; + d = v; + e = u; + f = v; + g = u == 6 ? a : b; + h = 0 ? c : d; + i = 1 ? e : f; + return g + h + i; +} + +int +f2 (int u, int v) +{ + int a, b, c, d, e, f, g, h, i; + a = u; + b = v; + c = u; + d = v; + e = u; + f = v; + g = u == 6 ? a + 1 : b; + h = 0 ? c + 1 : d; + i = 1 ? e + 1 : f; + return g + h + i; +} + +int +f3 (int u, int v) +{ + int a, b, c, d, e, f, g, h, i; + a = u; + b = v; + c = u; + d = v; + e = u; + f = v; + g = u == 6 ? a : b + 1; + h = 0 ? c : d + 1; + i = 1 ? e : f + 1; + return g + h + i; +} + +int +f4 (int u, int v) +{ + int a, c, e, g, h, i; + long b, d, f; + a = u; + b = v; + c = u; + d = v; + e = u; + f = v; + g = u == 6 ? a : b; + h = 0 ? c : d; + i = 1 ? e : f; + return g + h + i; +} Index: tm/abort-1.c =================================================================== --- tm/abort-1.c (nonexistent) +++ tm/abort-1.c (revision 686) @@ -0,0 +1,6 @@ +/* { dg-do compile } */ + +void f(void) +{ + __transaction_cancel; /* { dg-error "without transactional" } */ +} Index: tm/abort-2.c =================================================================== --- tm/abort-2.c (nonexistent) +++ tm/abort-2.c (revision 686) @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +int g; +void f(void) +{ + __transaction_atomic { + if (g == 0) + __transaction_cancel; + } +} Index: tm/trxn-expr-2.c =================================================================== --- tm/trxn-expr-2.c (nonexistent) +++ tm/trxn-expr-2.c (revision 686) @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* Make sure that we don't just crash without -fgnu-tm enabled. */ +/* { dg-options "" } */ + +int x; + +int foo(void) +{ + return __transaction_atomic (x + 1); /* { dg-error "" } */ +} + +int bar(void) +{ + return __transaction_relaxed (x + 1); /* { dg-error "" } */ +} Index: tm/ipa-1.c =================================================================== --- tm/ipa-1.c (nonexistent) +++ tm/ipa-1.c (revision 686) @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O -fdump-ipa-tmipa" } */ + +int val, george; + +extern void func(); + +int set_remove(void) +{ + int result = 8; + __transaction_atomic { + result = george; + if (val) + goto out; + } + out: + func(); + return result; +} + + +/* { dg-final { scan-ipa-dump-not "getTMCloneOrIrrevocable" "tmipa" } } */ +/* { dg-final { cleanup-ipa-dump "tmipa" } } */ Index: tm/abort-3.c =================================================================== --- tm/abort-3.c (nonexistent) +++ tm/abort-3.c (revision 686) @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +void f(void) +{ + __transaction_atomic { /* { dg-error "__transaction_atomic. without trans" } */ + __transaction_cancel; /* { dg-error "_cancel. without trans" } */ + } +} Index: tm/malloc.c =================================================================== --- tm/malloc.c (nonexistent) +++ tm/malloc.c (revision 686) @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -fdump-tree-tmmark" } */ + +#include + +char *z; + +void foobar(void) +{ + char *p, *q; + __transaction_atomic { + p = (char *)malloc(123); + q = (char *)calloc(555,1); + free(q); + free(p); + } + z = (char *)malloc (666); +} + +/* { dg-final { scan-tree-dump-times " malloc .666" 1 "tmmark" { target { ! { *-*-solaris2* && c++ } } } } } */ +/* Solaris 2 headers are C++-aware and declare std::malloc. */ +/* { dg-final { scan-tree-dump-times " std::malloc .666" 1 "tmmark" { target { *-*-solaris2* && c++ } } } } */ +/* { dg-final { scan-tree-dump-times "__builtin__ITM_malloc" 1 "tmmark" } } */ +/* { dg-final { scan-tree-dump-times "__builtin__ITM_calloc" 1 "tmmark" } } */ +/* { dg-final { scan-tree-dump-times "__builtin__ITM_free" 2 "tmmark" } } */ +/* { dg-final { cleanup-tree-dump "tmmark" } } */ Index: tm/wrap-1.c =================================================================== --- tm/wrap-1.c (nonexistent) +++ tm/wrap-1.c (revision 686) @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -fdump-tree-optimized" } */ + +void orig(void); +void xyzzy(void) __attribute__((transaction_wrap (orig))); + +void foo() { __transaction_relaxed { orig (); } } + +/* { dg-final { scan-tree-dump-times "xyzzy" 1 "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ Index: tm/trxn-expr-3.c =================================================================== --- tm/trxn-expr-3.c (nonexistent) +++ tm/trxn-expr-3.c (revision 686) @@ -0,0 +1,14 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm -O -fdump-tree-tmmark" } + +int global; + +int f2() +{ + return __transaction_atomic (global + 3) + + __transaction_atomic (global + 4); +} + +/* { dg-final { scan-tree-dump-times "ITM_RU" 2 "tmmark" } } */ +/* { dg-final { scan-tree-dump-times "ITM_commitTransaction" 2 "tmmark" } } */ +/* { dg-final { cleanup-tree-dump "tmmark" } } */ Index: tm/trxn-expr.c =================================================================== --- tm/trxn-expr.c (nonexistent) +++ tm/trxn-expr.c (revision 686) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -fdump-tree-tmmark" } */ + +int y, x, york; + +void foobar(void) +{ + x = y + __transaction_atomic (york); +} + +/* { dg-final { scan-tree-dump-times "_ITM_RU.*york" 1 "tmmark" } } */ +/* { dg-final { scan-tree-dump-times "_ITM_RU" 1 "tmmark" } } */ +/* { dg-final { cleanup-tree-dump "tmmark" } } */ Index: tm/atomic-1.c =================================================================== --- tm/atomic-1.c (nonexistent) +++ tm/atomic-1.c (revision 686) @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +int g; +void f(void) +{ + __transaction_atomic { /* { dg-error "without transactional memory" } */ + g++; + } +} Index: tm/atomic-2.c =================================================================== --- tm/atomic-2.c (nonexistent) +++ tm/atomic-2.c (revision 686) @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +int g; +void f(void) +{ + __transaction_atomic { + g++; + } +} Index: tm/safe-1.c =================================================================== --- tm/safe-1.c (nonexistent) +++ tm/safe-1.c (revision 686) @@ -0,0 +1,69 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +void ts(void) __attribute__((transaction_safe)); +void tp(void) __attribute__((transaction_pure)); +void tc(void) __attribute__((transaction_callable)); +void ti(void) __attribute__((transaction_unsafe)); +void tm(void) __attribute__((transaction_may_cancel_outer)); +void tu(void); +int fc(int) __attribute__((const)); + +typedef void (*Fs) (void) __attribute__((transaction_safe)); +typedef void (*Fc) (void) __attribute__((transaction_callable)); +typedef void (*Fi) (void) __attribute__((transaction_unsafe)); +typedef void (*Fm) (void) __attribute__((transaction_may_cancel_outer)); +extern Fs ps; +extern Fc pc; +extern Fi pi; +extern Fm pm; +extern void (*pu)(void); + +int __attribute__((transaction_safe)) +foo(void) +{ + int i; + + ts(); + tp(); + tc(); /* { dg-error "unsafe function call" } */ + ti(); /* { dg-error "unsafe function call" } */ + + /* ??? Direct function calls without markups are handled later + than pass_diagnose_tm_blocks, which means we'll exit with + errors before getting there. This test moved to safe-3.c. */ + /* tu(); */ + + (*ps)(); + (*pc)(); /* { dg-error "unsafe function call" } */ + (*pi)(); /* { dg-error "unsafe function call" } */ + (*pu)(); /* { dg-error "unsafe function call" } */ + + asm(""); /* { dg-error "asm not allowed" } */ + asm("" : "=g"(i)); /* { dg-error "asm not allowed" } */ + + return fc(i); +} + +int __attribute__((transaction_may_cancel_outer)) +bar(void) +{ + int i; + + ts(); + tp(); + tc(); /* { dg-error "unsafe function call" } */ + ti(); /* { dg-error "unsafe function call" } */ + tm(); + + (*ps)(); + (*pc)(); /* { dg-error "unsafe function call" } */ + (*pi)(); /* { dg-error "unsafe function call" } */ + (*pm)(); + (*pu)(); /* { dg-error "unsafe function call" } */ + + asm(""); /* { dg-error "asm not allowed" } */ + asm("" : "=g"(i)); /* { dg-error "asm not allowed" } */ + + return fc(i); +} Index: tm/safe-2.c =================================================================== --- tm/safe-2.c (nonexistent) +++ tm/safe-2.c (revision 686) @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +void mco(void) __attribute__((transaction_may_cancel_outer)); + +void +f(void) +{ + mco(); /* { dg-error "" } */ + __transaction_atomic { + mco(); /* { dg-error "" } */ + } + __transaction_relaxed { + mco(); /* { dg-error "" } */ + } + __transaction_atomic [[outer]] { + mco(); + } + __transaction_atomic [[outer]] { + __transaction_atomic { + __transaction_atomic { + __transaction_atomic { + mco(); + } + } + } + } +} + +void __attribute__((transaction_may_cancel_outer)) +g(void) +{ + mco(); + __transaction_atomic { + __transaction_atomic { + __transaction_atomic { + __transaction_atomic { + mco(); + } + } + } + } +} Index: tm/safe-3.c =================================================================== --- tm/safe-3.c (nonexistent) +++ tm/safe-3.c (revision 686) @@ -0,0 +1,48 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +void f_extern (void); +void f_first (void); +void f_later (void); + +extern int x; + +void f_first (void) { x++; } + +void __attribute__((transaction_safe)) +test_safe (void) +{ + f_extern (); /* { dg-error "unsafe function call" } */ + f_first (); + f_later (); +} + +void __attribute__((transaction_may_cancel_outer)) +test_mco (void) +{ + f_extern (); /* { dg-error "unsafe function call" } */ + f_first (); + f_later (); +} + +void +test_atomic (void) +{ + __transaction_atomic { + f_extern (); /* { dg-error "unsafe function call" } */ + f_first (); + f_later (); + } + __transaction_relaxed { + f_extern (); + f_first (); + f_later (); + } + __transaction_atomic [[outer]] { + f_extern (); /* { dg-error "unsafe function call" } */ + f_first (); + f_later (); + } +} + +void f_later () { f_first(); test_safe(); } Index: tm/cancel-1.c =================================================================== --- tm/cancel-1.c (nonexistent) +++ tm/cancel-1.c (revision 686) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +void unsafe(void) __attribute__((transaction_unsafe)); + +void +f(void) +{ + int a; + __transaction_atomic { + a = 1; + __transaction_atomic { + __transaction_cancel; + } + } + unsafe(); +} Index: tm/attrib-1.c =================================================================== --- tm/attrib-1.c (nonexistent) +++ tm/attrib-1.c (revision 686) @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +#define TC __attribute__((transaction_callable)) +#define TU __attribute__((transaction_unsafe)) +#define TP __attribute__((transaction_pure)) +#define TS __attribute__((transaction_safe)) +extern void f1(void) TC; +extern void f2(void) TU; +extern void f3(void) TP; +extern void f4(void) TS; + +extern void g1(void) TC TS; /* { dg-error "previously declared" } */ + +extern int v1 TP; /* { dg-warning "ignored" } */ + +typedef void t1(void) TC; +typedef void (*t2)(void) TC; +typedef int t3 TC; /* { dg-warning "ignored" } */ + +typedef void u0(void); +typedef u0 u1 TC; +typedef u1 u2 TP; /* { dg-error "previously declared" } */ +typedef u0 *u3 TS; +typedef u3 u4 TU; /* { dg-error "previously declared" } */ Index: tm/memcpy-1.c =================================================================== --- tm/memcpy-1.c (nonexistent) +++ tm/memcpy-1.c (revision 686) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ +typedef __SIZE_TYPE__ size_t; +#ifdef __cplusplus +extern "C" +#endif +void *memcpy (void *__restrict, const void *__restrict, size_t); + +__attribute__((transaction_safe)) +void *wmemcpy(void *dest, const void *src, size_t n) +{ + return memcpy(dest, src, n); +} Index: tm/omp.c =================================================================== --- tm/omp.c (nonexistent) +++ tm/omp.c (revision 686) @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -fopenmp" } */ +/* { dg-require-effective-target pthread } */ + +__attribute__ ((transaction_pure)) +unsigned long rdtsc(); + +typedef struct ENTER_EXIT_TIMES +{ + unsigned long enter; +} times_t; + +void ParClassify() +{ + void * Parent; +#pragma omp parallel private(Parent) + { + times_t inside; + __transaction_atomic { + inside.enter = rdtsc(); + } + } +} Index: tm/inline-asm-2.c =================================================================== --- tm/inline-asm-2.c (nonexistent) +++ tm/inline-asm-2.c (revision 686) @@ -0,0 +1,8 @@ +// { dg-do compile } +// { dg-options "-fgnu-tm" } + +__attribute__((transaction_callable)) +void func() +{ + __asm__ (""); +} Index: tm/20111206.c =================================================================== --- tm/20111206.c (nonexistent) +++ tm/20111206.c (revision 686) @@ -0,0 +1,53 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O2" } */ +/* This test case triggered block sharing between the two transactions. */ + +void func1 (void) __attribute__ ((transaction_callable, used)); +long func2 (void) __attribute__ ((transaction_callable, used)); +unsigned long rand (void); + +void client_run (void) +{ + long types[100]; + long i; + + for (i = 0; i < 100; i++) + { + long action = rand (); + + switch (action) + { + case 0: + { + __transaction_relaxed + { + long bill = func2 (); + if (bill >= 0) + { + func1 (); + } + } + break; + } + + case 1: + { + long n; + __transaction_relaxed + { + for (n = 0; n < 100; n++) + { + long t = types[n]; + switch (t) + { + case 0: + func1 (); + break; + } + } + } + break; + } + } + } +} Index: tm/inline-asm.c =================================================================== --- tm/inline-asm.c (nonexistent) +++ tm/inline-asm.c (revision 686) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O1" } */ + +static inline void +inline_death () +{ + __asm__ (""); /* { dg-error "asm not allowed" } */ +} + +void +tranfunction () +{ + __transaction_atomic + { + inline_death (); + } +} Index: tm/outer-1.c =================================================================== --- tm/outer-1.c (nonexistent) +++ tm/outer-1.c (revision 686) @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm" } */ + +void mco(void) __attribute__((transaction_may_cancel_outer)); + +void +f(void) +{ + mco(); /* { dg-error "" } */ + __transaction_atomic { + mco(); /* { dg-error "" } */ + } + __transaction_relaxed { + mco(); /* { dg-error "" } */ + } + __transaction_atomic [[outer]] { + mco(); + } +} + +void __attribute__((transaction_may_cancel_outer)) +g(void) +{ + mco(); + __transaction_atomic { + mco(); + } + __transaction_atomic [[outer]] { /* { dg-error "" } */ + mco(); + } +} Index: tm/20100127.c =================================================================== --- tm/20100127.c (nonexistent) +++ tm/20100127.c (revision 686) @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O -fdump-tree-tmmark" } */ + +/* Test that `nontrxn' doesn't end up inside the transaction. */ + +typedef struct node { + int * val; + struct node *next; +} node_t; + +node_t *next; +int nontrxn1, nontrxn; + +static int set_remove(int * val) +{ + int result; + int * v; + __transaction_relaxed { + v = next->val; + result = (v == val); + if (result) + result = 2; + } + return result; +} + +void test(void *data) +{ + extern void bark(void); + if (set_remove(0)) + bark(); + nontrxn = 99; /* Should be outside transaction. */ +} + +/* { dg-final { scan-tree-dump-times "_ITM_W.*nontrxn" 0 "tmmark" } } */ +/* { dg-final { cleanup-tree-dump "tmmark" } } */ Index: tm/freq.c =================================================================== --- tm/freq.c (nonexistent) +++ tm/freq.c (revision 686) @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O" } */ + +extern __attribute__((transaction_safe)) void TMreleaseNode (); + +int global; + +__attribute__((transaction_safe)) +void +TMrbtree_insert () +{ + if (global) + TMreleaseNode(); +} Index: Wunused-var-12.c =================================================================== --- Wunused-var-12.c (nonexistent) +++ Wunused-var-12.c (revision 686) @@ -0,0 +1,26 @@ +/* PR c++/44780 */ +/* { dg-do compile } */ +/* { dg-options "-Wunused" } */ +/* { dg-additional-options "-fno-common" { target { { hppa*-*-hpux* } && { ! lp64 } } } } */ + +typedef double vec __attribute__ ((__vector_size__ (16))); +vec c, d; + +void +foo (void) +{ + vec a; + vec b; + a = c; + b = a; + d = b; +} + +void +bar (void) +{ + vec a; + vec b; /* { dg-warning "set but not used" } */ + a = c; + b = a; +} Index: raw-string-6.c =================================================================== --- raw-string-6.c (nonexistent) +++ raw-string-6.c (revision 686) @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-std=gnu99" { target c } } +// { dg-options "-std=c++0x" { target c++ } } + +const void *s0 = R"ouch()ouCh"; // { dg-error "at end of input" } + // { dg-error "unterminated raw string" "" { target *-*-* } 5 } Index: raw-string-8.c =================================================================== --- raw-string-8.c (nonexistent) +++ raw-string-8.c (revision 686) @@ -0,0 +1,10 @@ +// Test that we track line numbers properly across newlines +// both escaped and not in raw strings. +// { dg-options "-std=gnu99" { target c } } +// { dg-options "-std=c++0x" { target c++ } } + +const char a[] = R"(\ + +)"; + +T t; // { dg-error "" } Index: Wunused-var-14.c =================================================================== --- Wunused-var-14.c (nonexistent) +++ Wunused-var-14.c (revision 686) @@ -0,0 +1,13 @@ +/* PR c/50179 */ +/* { dg-options "-Wunused" } */ +/* { dg-do compile } */ + +void bar (int, ...); + +char * +foo (void) +{ + bar (1, (__extension__ ({ static char b[2]; b[0] = 1; b; }))); + bar (1, ({ static char c[2]; c[0] = 1; c; })); + return ({ static char d[2]; d[0] = 1; d; }); +} Index: pr20000.c =================================================================== --- pr20000.c (nonexistent) +++ pr20000.c (revision 686) @@ -0,0 +1,32 @@ +/* PR c/20000 We only want to warn if the function returns + explicitly. We do not care about the return type. */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +int g(void) __attribute__((noreturn)); +int g2(void) __attribute__((noreturn)); /* { dg-bogus ".noreturn. function returns non-void value" } */ +void h(void) __attribute__((noreturn)); + + +int g(void) { + return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" } */ +} /* { dg-warning "'noreturn' function does return" "" { target *-*-* } 12 } */ + +int g2(void) { + h(); +} + +typedef int ft(void); +volatile ft vg; +volatile ft vg2; + +int vg(void); +int vg2(void); /* { dg-bogus ".noreturn. function returns non-void value" } */ + +int vg(void) { + return 1; /* { dg-warning "function declared 'noreturn' has a 'return' statement" "" { target c } 27 } */ +} /* { dg-warning "'noreturn' function does return" "" { target c } 27 } */ + +int vg2(void) { + h(); +} Index: dwarf2/pr43190.c =================================================================== --- dwarf2/pr43190.c (nonexistent) +++ dwarf2/pr43190.c (revision 686) @@ -0,0 +1,13 @@ +/* PR debug/43190 */ +/* { dg-options "-gdwarf-2 -dA" } */ +/* { dg-final { scan-assembler "DW_TAG_structure_type\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"S\[^\\r\\n\]*DW_AT_name" } } */ +/* { dg-final { scan-assembler "DW_TAG_typedef\[^\\r\\n\]*\[\\r\\n\]+\[^\\r\\n\]*\"T\[^\\r\\n\]*DW_AT_name" } } */ + +typedef struct S { int i; } *T; +#define M(p) ((T) (p)) + +void +foo (void *p) +{ + M (p)->i++; +} Index: dwarf2/vla1.c =================================================================== --- dwarf2/vla1.c (nonexistent) +++ dwarf2/vla1.c (revision 686) @@ -0,0 +1,11 @@ +// PR debug/42800 +// { dg-options "-gdwarf-2 -dA" } +// { dg-final { scan-assembler "DW_AT_upper_bound" } } + +int +f (int i) +{ + char a[i]; + + return a[0]; +} Index: uninit-F-O0.c =================================================================== --- uninit-F-O0.c (nonexistent) +++ uninit-F-O0.c (revision 686) @@ -0,0 +1,9 @@ +/* Test we do warn about initializing variable with self in the initialization. */ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +int f() +{ + int i = i + 1; /* { dg-warning "i" "uninitialized variable warning" } */ + return i; +} Index: uninit-pr51010.c =================================================================== --- uninit-pr51010.c (nonexistent) +++ uninit-pr51010.c (revision 686) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +int f (int j) +{ + int a [10]; + return a [j]; /* { dg-warning "a\\\[j\\\]. is used uninitialized" } */ +} +int g (int j) +{ + int a [10]; + return a [j+1]; /* { dg-warning "a\\\[\\\]. is used uninitialized" } */ +} Index: Wcast-qual-1.c =================================================================== --- Wcast-qual-1.c (nonexistent) +++ Wcast-qual-1.c (revision 686) @@ -0,0 +1,162 @@ +/* { dg-do compile } */ +/* { dg-options "-Wcast-qual" } */ + +void +f1 (void *bar) +{ + const void *p1 = (const void *) bar; + const char *p2 = (const char *) bar; + const void **p3 = (const void **) bar; + const char **p4 = (const char **) bar; + const void * const *p5 = (const void * const *) bar; + const char * const *p6 = (const char * const *) bar; + void * const *p7 = (void * const *) bar; + char * const *p8 = (char * const *) bar; + const void ***p9 = (const void ***) bar; + const char ***p10 = (const char ***) bar; + void * const **p11 = (void * const **) bar; + char * const **p12 = (char * const **) bar; + void ** const *p13 = (void ** const *) bar; + char ** const *p14 = (char ** const *) bar; + const void * const **p15 = (const void * const **) bar; + const char * const **p16 = (const char * const **) bar; + const void ** const *p17 = (const void ** const *) bar; + const char ** const *p18 = (const char ** const *) bar; + void * const * const * p19 = (void * const * const *) bar; + char * const * const * p20 = (char * const * const *) bar; + const void * const * const *p21 = (const void * const * const *) bar; + const char * const * const *p22 = (const char * const * const *) bar; +} + +void +f2 (void **bar) +{ + const void *p1 = (const void *) bar; + const char *p2 = (const char *) bar; + const void **p3 = (const void **) bar; /* { dg-warning "cast" } */ + const char **p4 = (const char **) bar; + const void * const *p5 = (const void * const *) bar; + const char * const *p6 = (const char * const *) bar; + void * const *p7 = (void * const *) bar; + char * const *p8 = (char * const *) bar; + const void ***p9 = (const void ***) bar; + const char ***p10 = (const char ***) bar; + void * const **p11 = (void * const **) bar; + char * const **p12 = (char * const **) bar; + void ** const *p13 = (void ** const *) bar; + char ** const *p14 = (char ** const *) bar; + const void * const **p15 = (const void * const **) bar; + const char * const **p16 = (const char * const **) bar; + const void ** const *p17 = (const void ** const *) bar; + const char ** const *p18 = (const char ** const *) bar; + void * const * const * p19 = (void * const * const *) bar; + char * const * const * p20 = (char * const * const *) bar; + const void * const * const *p21 = (const void * const * const *) bar; + const char * const * const *p22 = (const char * const * const *) bar; +} + +void +f3 (void ***bar) +{ + const void *p1 = (const void *) bar; + const char *p2 = (const char *) bar; + const void **p3 = (const void **) bar; + const char **p4 = (const char **) bar; + const void * const *p5 = (const void * const *) bar; + const char * const *p6 = (const char * const *) bar; + void * const *p7 = (void * const *) bar; + char * const *p8 = (char * const *) bar; + const void ***p9 = (const void ***) bar; /* { dg-warning "cast" } */ + const char ***p10 = (const char ***) bar; + void * const **p11 = (void * const **) bar; /* { dg-warning "cast" } */ + char * const **p12 = (char * const **) bar; + void ** const *p13 = (void ** const *) bar; + char ** const *p14 = (char ** const *) bar; + const void * const **p15 = (const void * const **) bar; /* { dg-warning "cast" } */ + const char * const **p16 = (const char * const **) bar; + const void ** const *p17 = (const void ** const *) bar; /* { dg-warning "cast" } */ + const char ** const *p18 = (const char ** const *) bar; + void * const * const * p19 = (void * const * const *) bar; + char * const * const * p20 = (char * const * const *) bar; + const void * const * const *p21 = (const void * const * const *) bar; + const char * const * const *p22 = (const char * const * const *) bar; +} + +void +f4 (void * const **bar) +{ + const void ***p9 = (const void ***) bar; /* { dg-warning "cast" } */ + void * const **p11 = (void * const **) bar; + void ** const *p13 = (void ** const *) bar; /* { dg-warning "cast" } */ + const void * const **p15 = (const void * const **) bar; /* { dg-warning "cast" } */ + const void ** const *p17 = (const void ** const *) bar; /* { dg-warning "cast" } */ + void * const * const * p19 = (void * const * const *) bar; + const void * const * const *p21 = (const void * const * const *) bar; +} + +void +f5 (char ***bar) +{ + volatile const char ***p9 = (volatile const char ***) bar; /* { dg-warning "cast" } */ + volatile char * const **p11 = (volatile char * const **) bar; /* { dg-warning "cast" } */ + volatile char ** const *p13 = (volatile char ** const *) bar; /* { dg-warning "cast" } */ + volatile const char * const **p15 = (volatile const char * const **) bar; /* { dg-warning "cast" } */ + volatile const char ** const *p17 = (volatile const char ** const *) bar; /* { dg-warning "cast" } */ + volatile char * const * const * p19 = (volatile char * const * const *) bar; + volatile const char * const * const *p21 = (volatile const char * const * const *) bar; +} + +void +f6 (char ***bar) +{ + const char * volatile **p9 = (const char * volatile **) bar; /* { dg-warning "cast" } */ + char * volatile const **p11 = (char * volatile const **) bar; /* { dg-warning "cast" } */ + char * volatile * const *p13 = (char * volatile * const *) bar; + const char * volatile const **p15 = (const char * volatile const **) bar; /* { dg-warning "cast" } */ + const char * volatile * const *p17 = (const char * volatile * const *) bar; /* { dg-warning "cast" } */ + char * volatile const * const * p19 = (char * volatile const * const *) bar; + const char * volatile const * const *p21 = (const char * volatile const * const *) bar; +} + +void +f7 (char ***bar) +{ + const char ** volatile *p9 = (const char ** volatile *) bar; /* { dg-warning "cast" } */ + char * const * volatile *p11 = (char * const * volatile *) bar; /* { dg-warning "cast" } */ + char ** volatile const *p13 = (char ** volatile const *) bar; + const char * const * volatile *p15 = (const char * const * volatile *) bar; /* { dg-warning "cast" } */ + const char ** volatile const *p17 = (const char ** volatile const *) bar; /* { dg-warning "cast" } */ + char * const * volatile const * p19 = (char * const * volatile const *) bar; + const char * const * volatile const *p21 = (const char * const * volatile const *) bar; +} + +typedef int (intfn) (int); +typedef intfn *pintfn; +typedef const intfn *constfn; + +void +f8 (constfn ***bar) +{ + const constfn *p1 = (const constfn *) bar; + const pintfn *p2 = (const pintfn *) bar; + const constfn **p3 = (const constfn **) bar; + const pintfn **p4 = (const pintfn **) bar; + const constfn * const *p5 = (const constfn * const *) bar; + const pintfn * const *p6 = (const pintfn * const *) bar; + constfn * const *p7 = (constfn * const *) bar; + pintfn * const *p8 = (pintfn * const *) bar; + const constfn ***p9 = (const constfn ***) bar; /* { dg-warning "cast" } */ + const pintfn ***p10 = (const pintfn ***) bar; /* { dg-warning "cast" } */ + constfn * const **p11 = (constfn * const **) bar; /* { dg-warning "cast" } */ + pintfn * const **p12 = (pintfn * const **) bar; /* { dg-warning "cast" } */ + constfn ** const *p13 = (constfn ** const *) bar; + pintfn ** const *p14 = (pintfn ** const *) bar; + const constfn * const **p15 = (const constfn * const **) bar; /* { dg-warning "cast" } */ + const pintfn * const **p16 = (const pintfn * const **) bar; /* { dg-warning "cast" } */ + const constfn ** const *p17 = (const constfn ** const *) bar; /* { dg-warning "cast" } */ + const pintfn ** const *p18 = (const pintfn ** const *) bar; /* { dg-warning "cast" } */ + constfn * const * const * p19 = (constfn * const * const *) bar; + pintfn * const * const * p20 = (pintfn * const * const *) bar; + const constfn * const * const *p21 = (const constfn * const * const *) bar; + const pintfn * const * const *p22 = (const pintfn * const * const *) bar; +} Index: torture/complex-sign-mixed-add.c =================================================================== --- torture/complex-sign-mixed-add.c (nonexistent) +++ torture/complex-sign-mixed-add.c (revision 686) @@ -0,0 +1,55 @@ +/* Test complex arithmetic with signed zeros. Mixed real/complex + addition. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" { target c } } */ + +#include "complex-sign.h" + +#define CHECK_ADD(TYPE, COPY, ZERO, ZEROI) \ + do { \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, +, +, +, +, +); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, +, +, -, +, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, +, -, +, +, +); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, +, -, -, +, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, -, +, +, +, +); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, -, +, -, +, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, -, -, +, -, +); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, +, -, -, -, -, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, +, +, +, ZERO, +, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, +, +, -, ZERO, +, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, +, -, +, ZERO, +, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, +, -, -, ZERO, +, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, -, +, +, ZERO, +, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, -, +, -, ZERO, -, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, -, -, +, ZERO, +, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, +, -, -, -, ZERO, -, -); \ + } while (0) + +void +check_add_float (void) +{ +#ifndef __SPU__ + CHECK_ADD (float, __builtin_copysignf, 0.0f, 0.0if); +#endif +} + +void +check_add_double (void) +{ + CHECK_ADD (double, __builtin_copysign, 0.0, 0.0i); +} + +void +check_add_long_double (void) +{ + CHECK_ADD (long double, __builtin_copysignl, 0.0l, 0.0il); +} + +int +main (void) +{ + check_add_float (); + check_add_double (); + check_add_long_double (); + exit (0); +} Index: torture/complex-sign-mul-one.c =================================================================== --- torture/complex-sign-mul-one.c (nonexistent) +++ torture/complex-sign-mul-one.c (revision 686) @@ -0,0 +1,63 @@ +/* Test complex arithmetic with signed zeros. Pure complex + multiplication with 1.0 + 0.0i. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" { target c } } */ + +#include "complex-sign.h" + +#define CHECK_MUL_INT(TYPE, COPY, ZERO, ZEROI, ONE, S1, S2, SR, SI) \ + do { \ + _Complex TYPE a1, b1, c1; \ + volatile _Complex TYPE a2, b2, c2; \ + a1 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a1, COPY, S1, S2); \ + b1 = ONE + ZEROI; \ + c1 = a1 * b1; \ + CHECK_RES (c1, COPY, SR, SI); \ + c1 = a1 * (ONE + ZEROI); \ + CHECK_RES (c1, COPY, SR, SI); \ + a2 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a2, COPY, S1, S2); \ + b2 = ONE + ZEROI; \ + c2 = a2 * b2; \ + CHECK_RES (c2, COPY, SR, SI); \ + c2 = a2 * (ONE + ZEROI); \ + CHECK_RES (c2, COPY, SR, SI); \ + } while (0) + +#define CHECK_MUL(TYPE, COPY, ZERO, ZEROI, ONE) \ + do { \ + CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, +, +, +, +); \ + CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, +, -, +, +); \ + CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, -, +, -, +); \ + CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, -, -, +, -); \ + } while (0) + +void +check_mul_float (void) +{ +#ifndef __SPU__ + CHECK_MUL (float, __builtin_copysignf, 0.0f, 0.0if, 1.0f); +#endif +} + +void +check_mul_double (void) +{ + CHECK_MUL (double, __builtin_copysign, 0.0, 0.0i, 1.0); +} + +void +check_mul_long_double (void) +{ + CHECK_MUL (long double, __builtin_copysignl, 0.0l, 0.0il, 1.0l); +} + +int +main (void) +{ + check_mul_float (); + check_mul_double (); + check_mul_long_double (); + exit (0); +} Index: torture/complex-sign-mixed-sub.c =================================================================== --- torture/complex-sign-mixed-sub.c (nonexistent) +++ torture/complex-sign-mixed-sub.c (revision 686) @@ -0,0 +1,55 @@ +/* Test complex arithmetic with signed zeros. Mixed real/complex + subtraction. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" { target c } } */ + +#include "complex-sign.h" + +#define CHECK_SUB(TYPE, COPY, ZERO, ZEROI) \ + do { \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, +, +, +, +, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, +, +, -, +, +); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, +, -, +, +, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, +, -, -, +, +); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, -, +, +, -, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, -, +, -, -, +); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, -, -, +, +, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, -, -, -, -, +, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, +, +, +, ZERO, +, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, +, +, -, ZERO, +, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, +, -, +, ZERO, +, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, +, -, -, ZERO, +, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, -, +, +, ZERO, -, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, -, +, -, ZERO, +, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, -, -, +, ZERO, -, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, -, -, -, -, ZERO, +, -); \ + } while (0) + +void +check_sub_float (void) +{ +#ifndef __SPU__ + CHECK_SUB (float, __builtin_copysignf, 0.0f, 0.0if); +#endif +} + +void +check_sub_double (void) +{ + CHECK_SUB (double, __builtin_copysign, 0.0, 0.0i); +} + +void +check_sub_long_double (void) +{ + CHECK_SUB (long double, __builtin_copysignl, 0.0l, 0.0il); +} + +int +main (void) +{ + check_sub_float (); + check_sub_double (); + check_sub_long_double (); + exit (0); +} Index: torture/complex-sign-mul.c =================================================================== --- torture/complex-sign-mul.c (nonexistent) +++ torture/complex-sign-mul.c (revision 686) @@ -0,0 +1,55 @@ +/* Test complex arithmetic with signed zeros. Pure complex + multiplication. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" { target c } } */ + +#include "complex-sign.h" + +#define CHECK_MUL(TYPE, COPY, ZERO, ZEROI) \ + do { \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, +, +, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, +, +, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, +, -, +, -, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, +, -, -, +, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, -, +, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, -, +, -, +, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, -, -, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, +, -, -, -, -, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, +, +, +, -, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, +, +, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, +, -, +, +, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, +, -, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, -, +, +, +, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, -, +, -, -, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, -, -, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, *, -, -, -, -, +, +); \ + } while (0) + +void +check_mul_float (void) +{ +#ifndef __SPU__ + CHECK_MUL (float, __builtin_copysignf, 0.0f, 0.0if); +#endif +} + +void +check_mul_double (void) +{ + CHECK_MUL (double, __builtin_copysign, 0.0, 0.0i); +} + +void +check_mul_long_double (void) +{ + CHECK_MUL (long double, __builtin_copysignl, 0.0l, 0.0il); +} + +int +main (void) +{ + check_mul_float (); + check_mul_double (); + check_mul_long_double (); + exit (0); +} Index: torture/complex-sign-mixed-mul.c =================================================================== --- torture/complex-sign-mixed-mul.c (nonexistent) +++ torture/complex-sign-mixed-mul.c (revision 686) @@ -0,0 +1,55 @@ +/* Test complex arithmetic with signed zeros. Mixed real/complex + multiplication. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" { target c } } */ + +#include "complex-sign.h" + +#define CHECK_MUL(TYPE, COPY, ZERO, ZEROI) \ + do { \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, +, +, +, +, +); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, +, +, -, +, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, +, -, +, -, +); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, +, -, -, -, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, -, +, +, -, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, -, +, -, -, +); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, -, -, +, +, -); \ + CHECK_ARITH_RC (TYPE, COPY, ZERO, ZEROI, *, -, -, -, +, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, +, +, +, ZERO, +, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, +, +, -, ZERO, -, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, +, -, +, ZERO, +, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, +, -, -, ZERO, -, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, -, +, +, ZERO, -, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, -, +, -, ZERO, +, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, -, -, +, ZERO, -, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, *, -, -, -, ZERO, +, +); \ + } while (0) + +void +check_mul_float (void) +{ +#ifndef __SPU__ + CHECK_MUL (float, __builtin_copysignf, 0.0f, 0.0if); +#endif +} + +void +check_mul_double (void) +{ + CHECK_MUL (double, __builtin_copysign, 0.0, 0.0i); +} + +void +check_mul_long_double (void) +{ + CHECK_MUL (long double, __builtin_copysignl, 0.0l, 0.0il); +} + +int +main (void) +{ + check_mul_float (); + check_mul_double (); + check_mul_long_double (); + exit (0); +} Index: torture/pr42834.c =================================================================== --- torture/pr42834.c (nonexistent) +++ torture/pr42834.c (revision 686) @@ -0,0 +1,23 @@ +/* { dg-do run } */ + +void __attribute__((noinline,noclone)) +foo(int *p, float *q) { __asm__ volatile ("" : : : "memory"); } + +int main() +{ + if (sizeof (int) == sizeof (float)) + { + int i; + float f; + int *p; + /* Prevent i and f from being rewritten into SSA form. */ + foo (&i, &f); + i = 0; + f = 1.0; + p = (int *)&f; + __builtin_memcpy (&i, p, 4); + if (*(float *)&i != 1.0) + __builtin_abort (); + } + return 0; +} Index: torture/pr46137.c =================================================================== --- torture/pr46137.c (nonexistent) +++ torture/pr46137.c (revision 686) @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +struct X { }; + +static inline void * +bar (void *dst, void *src) +{ + return __builtin___memcpy_chk (dst, src, sizeof (struct X), + __builtin_object_size (dst, 0)); +} + +struct X +foo (struct X *x) +{ + struct X any; + bar (&any, x); + return any; +} Index: torture/complex-sign-mul-minus-one.c =================================================================== --- torture/complex-sign-mul-minus-one.c (nonexistent) +++ torture/complex-sign-mul-minus-one.c (revision 686) @@ -0,0 +1,63 @@ +/* Test complex arithmetic with signed zeros. Pure complex + multiplication with -1.0 + 0.0i. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" { target c } } */ + +#include "complex-sign.h" + +#define CHECK_MUL_INT(TYPE, COPY, ZERO, ZEROI, ONE, S1, S2, SR, SI) \ + do { \ + _Complex TYPE a1, b1, c1; \ + volatile _Complex TYPE a2, b2, c2; \ + a1 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a1, COPY, S1, S2); \ + b1 = -ONE + ZEROI; \ + c1 = a1 * b1; \ + CHECK_RES (c1, COPY, SR, SI); \ + c1 = a1 * (-ONE + ZEROI); \ + CHECK_RES (c1, COPY, SR, SI); \ + a2 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a2, COPY, S1, S2); \ + b2 = -ONE + ZEROI; \ + c2 = a2 * b2; \ + CHECK_RES (c2, COPY, SR, SI); \ + c2 = a2 * (-ONE + ZEROI); \ + CHECK_RES (c2, COPY, SR, SI); \ + } while (0) + +#define CHECK_MUL(TYPE, COPY, ZERO, ZEROI, ONE) \ + do { \ + CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, +, +, -, +); \ + CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, +, -, +, +); \ + CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, -, +, +, -); \ + CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, -, -, +, +); \ + } while (0) + +void +check_mul_float (void) +{ +#ifndef __SPU__ + CHECK_MUL (float, __builtin_copysignf, 0.0f, 0.0if, 1.0f); +#endif +} + +void +check_mul_double (void) +{ + CHECK_MUL (double, __builtin_copysign, 0.0, 0.0i, 1.0); +} + +void +check_mul_long_double (void) +{ + CHECK_MUL (long double, __builtin_copysignl, 0.0l, 0.0il, 1.0l); +} + +int +main (void) +{ + check_mul_float (); + check_mul_double (); + check_mul_long_double (); + exit (0); +} Index: torture/complex-sign-mixed-div.c =================================================================== --- torture/complex-sign-mixed-div.c (nonexistent) +++ torture/complex-sign-mixed-div.c (revision 686) @@ -0,0 +1,47 @@ +/* Test complex arithmetic with signed zeros. Mixed real/complex + division. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" { target c } } */ + +#include "complex-sign.h" + +#define CHECK_DIV(TYPE, COPY, ZERO, ZEROI, ONE) \ + do { \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, +, +, +, ONE, +, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, +, +, -, ONE, -, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, +, -, +, ONE, +, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, +, -, -, ONE, -, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, -, +, +, ONE, -, +); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, -, +, -, ONE, +, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, -, -, +, ONE, -, -); \ + CHECK_ARITH_CR (TYPE, COPY, ZERO, ZEROI, /, -, -, -, ONE, +, +); \ + } while (0) + +void +check_div_float (void) +{ +#ifndef __SPU__ + CHECK_DIV (float, __builtin_copysignf, 0.0f, 0.0if, 1.0f); +#endif +} + +void +check_div_double (void) +{ + CHECK_DIV (double, __builtin_copysign, 0.0, 0.0i, 1.0); +} + +void +check_div_long_double (void) +{ + CHECK_DIV (long double, __builtin_copysignl, 0.0l, 0.0il, 1.0l); +} + +int +main (void) +{ + check_div_float (); + check_div_double (); + check_div_long_double (); + exit (0); +} Index: torture/complex-sign.h =================================================================== --- torture/complex-sign.h (nonexistent) +++ torture/complex-sign.h (revision 686) @@ -0,0 +1,80 @@ +/* Common header for complex arithmetic sign tests. */ + +#ifdef __cplusplus +extern "C" { +#endif +extern void abort (void); +extern void exit (int); +#ifdef __cplusplus +} +#endif + +#define CHECK_RES(VALUE, COPY, SIGN_REAL, SIGN_IMAG) \ + do { \ + if ((VALUE) != 0 \ + || COPY (1.0, __real__ (VALUE)) != SIGN_REAL 1.0 \ + || COPY (1.0, __imag__ (VALUE)) != SIGN_IMAG 1.0) \ + abort (); \ + } while (0) + +/* This definition is intended to work with or without imaginary + types, as long as mixed real/complex arithmetic is handled + correctly. */ +#define ENCODE(ZERO, ZEROI, SA, SB) \ + (SA 1 == 1 \ + ? SB 1 == 1 ? ZERO + ZEROI : ZERO - ZEROI \ + : SB 1 == 1 ? -(ZERO - ZEROI) : -(ZERO + ZEROI)) + +#define CHECK_ARITH(TYPE, COPY, ZERO, ZEROI, OP, S1, S2, S3, S4, SR, SI) \ + do { \ + _Complex TYPE a1, b1, c1; \ + volatile _Complex TYPE a2, b2, c2; \ + a1 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a1, COPY, S1, S2); \ + b1 = ENCODE(ZERO, ZEROI, S3, S4); \ + CHECK_RES (b1, COPY, S3, S4); \ + c1 = a1 OP b1; \ + CHECK_RES (c1, COPY, SR, SI); \ + a2 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a2, COPY, S1, S2); \ + b2 = ENCODE(ZERO, ZEROI, S3, S4); \ + CHECK_RES (b2, COPY, S3, S4); \ + c2 = a2 OP b2; \ + CHECK_RES (c2, COPY, SR, SI); \ + } while (0) + +#define CHECK_ARITH_RC(TYPE, COPY, ZERO, ZEROI, OP, S1, S3, S4, SR, SI) \ + do { \ + TYPE a1; \ + _Complex TYPE b1, c1; \ + volatile TYPE a2; \ + volatile _Complex TYPE b2, c2; \ + a1 = S1 ZERO; \ + b1 = ENCODE(ZERO, ZEROI, S3, S4); \ + CHECK_RES (b1, COPY, S3, S4); \ + c1 = a1 OP b1; \ + CHECK_RES (c1, COPY, SR, SI); \ + a2 = S1 ZERO; \ + b2 = ENCODE(ZERO, ZEROI, S3, S4); \ + CHECK_RES (b2, COPY, S3, S4); \ + c2 = a2 OP b2; \ + CHECK_RES (c2, COPY, SR, SI); \ + } while (0) + +#define CHECK_ARITH_CR(TYPE, COPY, ZERO, ZEROI, OP, S1, S2, S3, V3, SR, SI) \ + do { \ + _Complex TYPE a1, c1; \ + TYPE b1; \ + volatile _Complex TYPE a2, c2; \ + volatile TYPE b2; \ + a1 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a1, COPY, S1, S2); \ + b1 = S3 V3; \ + c1 = a1 OP b1; \ + CHECK_RES (c1, COPY, SR, SI); \ + a2 = ENCODE(ZERO, ZEROI, S1, S2); \ + CHECK_RES (a2, COPY, S1, S2); \ + b2 = S3 V3; \ + c2 = a2 OP b2; \ + CHECK_RES (c2, COPY, SR, SI); \ + } while (0) Index: torture/complex-sign-add.c =================================================================== --- torture/complex-sign-add.c (nonexistent) +++ torture/complex-sign-add.c (revision 686) @@ -0,0 +1,55 @@ +/* Test complex arithmetic with signed zeros. Pure complex + addition. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" { target c } } */ + +#include "complex-sign.h" + +#define CHECK_ADD(TYPE, COPY, ZERO, ZEROI) \ + do { \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, +, +, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, +, +, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, +, -, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, +, -, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, -, +, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, -, +, -, +, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, -, -, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, +, -, -, -, +, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, +, +, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, +, +, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, +, -, +, -, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, +, -, -, -, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, -, +, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, -, +, -, +, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, -, -, +, -, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, +, -, -, -, -, -, -); \ + } while (0) + +void +check_add_float (void) +{ +#ifndef __SPU__ + CHECK_ADD (float, __builtin_copysignf, 0.0f, 0.0if); +#endif +} + +void +check_add_double (void) +{ + CHECK_ADD (double, __builtin_copysign, 0.0, 0.0i); +} + +void +check_add_long_double (void) +{ + CHECK_ADD (long double, __builtin_copysignl, 0.0l, 0.0il); +} + +int +main (void) +{ + check_add_float (); + check_add_double (); + check_add_long_double (); + exit (0); +} Index: torture/complex-alias-1.c =================================================================== --- torture/complex-alias-1.c (nonexistent) +++ torture/complex-alias-1.c (revision 686) @@ -0,0 +1,35 @@ +/* Accesses to complex numbers were sometimes marked as scalar and + sometimes as struct accesses. */ +/* { dg-do run } */ +/* { dg-options "-std=c99" { target c } } */ + +#ifdef __cplusplus +extern "C" { +#endif +extern void abort (void); +#ifdef __cplusplus +} +#endif +static double _Complex *fp_cxd(double _Complex *cx) { + return cx; +} + +int main( ) { + double _Complex cx = 4.0 + 3.0*(__extension__ 1.0iF); + double _Complex cx43 = 4.0 + 3.0*(__extension__ 1.0iF); + double _Complex cx11 = 1.0 + 1.0*(__extension__ 1.0iF); + + *fp_cxd(&cx) *= cx11; + *fp_cxd(&cx) /= cx11; + + double r_cx = __real__(cx); + double i_cx = __imag__(cx); + double r_cx43 = __real__(cx43); + double i_cx43 = __imag__(cx43); + + if( (r_cx == r_cx43) && (i_cx == i_cx43) ) { + return 0; + } else { + abort (); + } +} Index: torture/complex-sign-sub.c =================================================================== --- torture/complex-sign-sub.c (nonexistent) +++ torture/complex-sign-sub.c (revision 686) @@ -0,0 +1,55 @@ +/* Test complex arithmetic with signed zeros. Pure complex + subtraction. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu99" { target c } } */ + +#include "complex-sign.h" + +#define CHECK_SUB(TYPE, COPY, ZERO, ZEROI) \ + do { \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, +, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, +, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, -, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, -, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, +, +, +, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, +, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, -, +, +, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, -, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, +, +, -, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, +, -, -, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, -, +, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, -, -, +, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, +, +, -, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, +, -, -, +); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, -, +, +, -); \ + CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, -, -, +, +); \ + } while (0) + +void +check_sub_float (void) +{ +#ifndef __SPU__ + CHECK_SUB (float, __builtin_copysignf, 0.0f, 0.0if); +#endif +} + +void +check_sub_double (void) +{ + CHECK_SUB (double, __builtin_copysign, 0.0, 0.0i); +} + +void +check_sub_long_double (void) +{ + CHECK_SUB (long double, __builtin_copysignl, 0.0l, 0.0il); +} + +int +main (void) +{ + check_sub_float (); + check_sub_double (); + check_sub_long_double (); + exit (0); +} Index: pr41935.c =================================================================== --- pr41935.c (nonexistent) +++ pr41935.c (revision 686) @@ -0,0 +1,70 @@ +/* { dg-options "-Warray-bounds" } */ +/* { dg-do compile } */ + +struct A +{ + int i; + char p[1]; +}; + +struct B +{ + struct A a; + int i; +}; + +struct C +{ + int i; + struct A a; +}; + +union D +{ + char p[1]; + struct A a; + struct B b; + struct C c; +}; + +struct E +{ + int i; + union D d; +}; + +struct F +{ + union D d; + int i; +}; + +union G +{ + int i; + union D d; +}; + +void +f0 () +{ + __builtin_offsetof (struct A, p[4]); /* OK */ + __builtin_offsetof (struct B, a.p[4]); /* { dg-warning "greater than size" } */ + __builtin_offsetof (struct C, a.p[4]); /* OK */ + __builtin_offsetof (union D, p[4]); /* OK */ + __builtin_offsetof (union D, a.p[4]); /* OK */ + __builtin_offsetof (union D, b.a.p[4]); /* { dg-warning "greater than size" } */ + __builtin_offsetof (union D, c.a.p[4]); /* OK */ + __builtin_offsetof (struct E, d.p[4]); /* OK */ + __builtin_offsetof (struct E, d.a.p[4]); /* OK */ + __builtin_offsetof (struct E, d.b.a.p[4]); /* { dg-warning "greater than size" } */ + __builtin_offsetof (struct E, d.c.a.p[4]); /* OK */ + __builtin_offsetof (struct F, d.p[4]); /* { dg-warning "greater than size" } */ + __builtin_offsetof (struct F, d.a.p[4]); /* { dg-warning "greater than size" } */ + __builtin_offsetof (struct F, d.b.a.p[4]); /* { dg-warning "greater than size" } */ + __builtin_offsetof (struct F, d.c.a.p[4]); /* { dg-warning "greater than size" } */ + __builtin_offsetof (union G, d.p[4]); /* OK */ + __builtin_offsetof (union G, d.a.p[4]); /* OK */ + __builtin_offsetof (union G, d.b.a.p[4]); /* { dg-warning "greater than size" } */ + __builtin_offsetof (union G, d.c.a.p[4]); /* OK */ +} Index: pr46562-2.c =================================================================== --- pr46562-2.c (nonexistent) +++ pr46562-2.c (revision 686) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fno-tree-ccp -fno-tree-forwprop -fdump-tree-fre1" } */ + +static const int a[4] = {}; +int foo(void) +{ + int i = 1; + const int *p = &a[i]; + return *p; +} + +/* { dg-final { scan-tree-dump "= 0;" "fre1" } } */ +/* { dg-final { cleanup-tree-dump "fre1" } } */ Index: cxxbitfields-3.c =================================================================== --- cxxbitfields-3.c (nonexistent) +++ cxxbitfields-3.c (revision 686) @@ -0,0 +1,22 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 --param allow-store-data-races=0" } */ + +/* Make sure we don't narrow down to a QI or HI to store into VAR.J, + but instead use an SI. */ + +struct S +{ + volatile int i: 4; + volatile int j: 4; + volatile int k: 8; + volatile int l: 8; + volatile int m: 8; +} var; + +void setit() +{ + var.j = 5; +} + +/* { dg-final { scan-assembler "movl.*, _?var" { target nonpic } } } */ +/* { dg-final { scan-assembler "movl.*, (_?var|\\(%)" { target { ! nonpic } } } } */ Index: dfp/func-array.c =================================================================== --- dfp/func-array.c (nonexistent) +++ dfp/func-array.c (revision 686) @@ -0,0 +1,157 @@ +/* C99 6.5.2.2 Function calls. + Test passing array elements involving decimal floating point types. */ + +#include "dfp-dbg.h" + +/* 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) FAILURE + if (arg1_32 (d32) != 1.0df) FAILURE + if (arg2_32 (d32) != 2.0df) FAILURE + if (arg3_32 (d32) != 3.0df) FAILURE + if (arg4_32 (d32) != 4.0df) FAILURE + if (arg5_32 (d32) != 5.0df) FAILURE + + /* _Decimal64 variants. */ + if (arg0_64 (d64) != 0.0dd) FAILURE + if (arg1_64 (d64) != 1.0dd) FAILURE + if (arg2_64 (d64) != 2.0dd) FAILURE + if (arg3_64 (d64) != 3.0dd) FAILURE + if (arg4_64 (d64) != 4.0dd) FAILURE + if (arg5_64 (d64) != 5.0dd) FAILURE + + /* _Decimal128 variants. */ + if (arg0_128 (d128) != 0.0dl) FAILURE + if (arg1_128 (d128) != 1.0dl) FAILURE + if (arg2_128 (d128) != 2.0dl) FAILURE + if (arg3_128 (d128) != 3.0dl) FAILURE + if (arg4_128 (d128) != 4.0dl) FAILURE + if (arg5_128 (d128) != 5.0dl) FAILURE + + FINISH +} Index: dfp/func-pointer.c =================================================================== --- dfp/func-pointer.c (nonexistent) +++ dfp/func-pointer.c (revision 686) @@ -0,0 +1,205 @@ +/* C99 6.5.2.2 Function calls. + Test pointer argument passing and return values involving decimal floating + point types. */ + +#include "dfp-dbg.h" + +/* A handful of functions that return their Nth pointer to 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 pointer to _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; +} + + + +_Decimal32 df0 = 0.0df, df1 = 1.0df, df2 = 2.0df, + df3 = 3.0df, df4 = 4.0df, df5 = 5.0df; +_Decimal32 *pdf0 = &df0, *pdf1 = &df1, *pdf2 = &df2, + *pdf3 = &df3, *pdf4 = &df4, *pdf5 = &df5; +_Decimal64 dd0 = 0.0dd, dd1 = 1.0dd, dd2 = 2.0dd, + dd3 = 3.0dd, dd4 = 4.0dd, dd5 = 5.0dd; +_Decimal64 *pdd0 = &dd0, *pdd1 = &dd1, *pdd2 = &dd2, + *pdd3 = &dd3, *pdd4 = &dd4, *pdd5 = &dd5; +_Decimal128 dl0 = 0.0dl, dl1 = 1.0dl, dl2 = 2.0dl, + dl3 = 3.0dl, dl4 = 4.0dl, dl5 = 5.0dl; +_Decimal128 *pdl0 = &dl0, *pdl1 = &dl1, *pdl2 = &dl2, + *pdl3 = &dl3, *pdl4 = &dl4, *pdl5 = &dl5; + +int +main () +{ + /* _Decimal32 variants. */ + if (*arg0_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 0.0df) + FAILURE + if (*arg1_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 1.0df) + FAILURE + if (*arg2_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 2.0df) + FAILURE + if (*arg3_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 3.0df) + FAILURE + if (*arg4_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 4.0df) + FAILURE + if (*arg5_32 (pdf0, pdf1, pdf2, pdf3, pdf4, pdf5) != 5.0df) + FAILURE + + /* _Decimal64 variants. */ + if (*arg0_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 0.0dd) + FAILURE + if (*arg1_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 1.0dd) + FAILURE + if (*arg2_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 2.0dd) + FAILURE + if (*arg3_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 3.0dd) + FAILURE + if (*arg4_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 4.0dd) + FAILURE + if (*arg5_64 (pdd0, pdd1, pdd2, pdd3, pdd4, pdd5) != 5.0dd) + FAILURE + + /* _Decimal128 variants. */ + if (*arg0_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 0.0dl) + FAILURE + if (*arg1_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 1.0dl) + FAILURE + if (*arg2_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 2.0dl) + FAILURE + if (*arg3_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 3.0dl) + FAILURE + if (*arg4_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 4.0dl) + FAILURE + if (*arg5_128 (pdl0, pdl1, pdl2, pdl3, pdl4, pdl5) != 5.0dl) + FAILURE + + FINISH +} Index: dfp/convert-dfp-fold.c =================================================================== --- dfp/convert-dfp-fold.c (nonexistent) +++ dfp/convert-dfp-fold.c (revision 686) @@ -0,0 +1,47 @@ +/* { dg-options "-O2" } */ + +/* N1150 5.2 Conversions among decimal floating types and between + decimal floating types and generic floating types. + C99 6.3.1.5(3) New. */ + +#include "dfp-dbg.h" + +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; +} Index: dfp/inf-1.c =================================================================== --- dfp/inf-1.c (nonexistent) +++ dfp/inf-1.c (revision 686) @@ -0,0 +1,61 @@ +/* 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. */ + +#include "dfp-dbg.h" + +int main() +{ + /* Assumes rounding mode. */ + if (9999999.E90DF + 1.E90df != __builtin_infd32 ()) + FAILURE + + if (!__builtin_isinfd32 (9999999.E90DF + 1.E90df)) + FAILURE + + if (9.999999999999999E384dd + .000000000000001e384dd + != __builtin_infd32 ()) + FAILURE + + if (-9999999.E90DF - 1.E90df != -__builtin_infd32 ()) + FAILURE + + if (!__builtin_isinfd32 (9.999999999999999E384dd + .000000000000001e384dd)) + FAILURE + + if (7.999999999999999999999999999999999E6144dl + 3.0E6144dl + != __builtin_infd32 ()) + FAILURE + + if (__builtin_infd32 () * __builtin_infd32 () != __builtin_infd32 ()) + FAILURE + + if (__builtin_infd32 () * 2 != __builtin_infd32 ()) + FAILURE + + if (__builtin_infd64 () * -5 != -__builtin_infd32 ()) + FAILURE + + if (!__builtin_isinfd128 (__builtin_infd32 () / 4)) + FAILURE + + if (__builtin_infd64 () != __builtin_infd128 ()) + FAILURE + + if (!__builtin_isinfd64 (__builtin_infd128 ())) + FAILURE + + if (__builtin_finited64 (__builtin_infd32 () * 4)) + FAILURE + + if (!__builtin_finited128 (9.999999E90DL - 1.E90dd)) + FAILURE + + if (__builtin_finited128 (__builtin_infd32 () *__builtin_infd128 ())) + FAILURE + + if (__builtin_finited32 (__builtin_nand32 (""))) + FAILURE + + FINISH +} Index: dfp/compare-rel.h =================================================================== --- dfp/compare-rel.h (nonexistent) +++ dfp/compare-rel.h (revision 686) @@ -0,0 +1,132 @@ +/* Basic test of runtime relational comparisons using simple values that + are not affected by rounding. */ + +#include +#include "dfp-dbg.h" + +#undef FAILURE +#ifdef DBG +#define FAILURE(OP,KIND) \ + { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \ + failures++; } +#else +#define FAILURE(OP,KIND) __builtin_abort (); +#endif + +#define PASTE2(A,B) A ## B +#define PASTE(A,B) PASTE2(A,B) + +#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") +} Index: dfp/func-struct.c =================================================================== --- dfp/func-struct.c (nonexistent) +++ dfp/func-struct.c (revision 686) @@ -0,0 +1,93 @@ +/* C99 6.5.2.2 Function calls. + Test structure passing and return values involving decimal floating + point types. */ + +#include "dfp-dbg.h" + +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) FAILURE + if (d64_field (nums) != 2.0dd) FAILURE + if (d128_field (nums) != 1.0dl) FAILURE + if (dummy1_field (nums) != 'a') FAILURE + if (dummy2_field (nums) != 'b') FAILURE + + if (ptr_d32_field (&nums) != 3.0df) FAILURE + if (ptr_d64_field (&nums) != 2.0dd) FAILURE + if (ptr_d128_field (&nums) != 1.0dl) FAILURE + if (ptr_dummy1_field (&nums) != 'a') FAILURE + if (ptr_dummy2_field (&nums) != 'b') FAILURE + + FINISH +} Index: dfp/convert-int-max-fold.c =================================================================== --- dfp/convert-int-max-fold.c (nonexistent) +++ dfp/convert-int-max-fold.c (revision 686) @@ -0,0 +1,148 @@ +/* { dg-options "-O2 -w" } */ + +/* N1150 5.1 Conversions from decimal float to integer. */ + +/* Test decimal float to integer conversions for values at the limit of + what will fit into the destination type. This assumes 32-bit int and + 64-bit long long (there's a check for that below). This version tests + conversions during compilation. */ + +#include "dfp-dbg.h" + +extern void link_error (void); + +void +doit () +{ + _Decimal32 d32; + _Decimal64 d64; + _Decimal128 d128; + int si; + unsigned int ui; + long long sll; + unsigned long long ull; + + /* _Decimal32 to int. */ + + d32 = 2147483.E3DF; + si = d32; + if (si != 2147483000) + link_error (); + + d32 = -2147483.E3DF; + si = d32; + if (si != -2147483000) + link_error (); + + /* _Decimal32 to unsigned int. */ + + d32 = 4.294967E9DF; + ui = d32; + if (ui != 4294967000U) + link_error (); + + /* _Decimal32 to long long. */ + + d32 = 922.3372E16DF; + sll = d32; + if (sll != 9223372000000000000LL) + link_error (); + + d32 = -92233.72E14DF; + sll = d32; + if (sll != -9223372000000000000LL) + link_error (); + + /* _Decimal32 to unsigned long long. */ + + d32 = 0.1844674E20DF; + ull = d32; + if (ull != 18446740000000000000ULL) + link_error (); + + /* _Decimal64 to int. */ + + d64 = 2.147483647E9DD; + si = d64; + if (si != 2147483647) + link_error (); + + d64 = -2147483648.DD; + si = d64; + if (si != -2147483648) + link_error (); + + /* _Decimal64 to unsigned int. */ + + d64 = 42949.67295E5DD; + ui = d64; + if (ui != 4294967295) + link_error (); + + /* _Decimal64 to long long. */ + + d64 = 9.223372036854775E18DD; + sll = d64; + if (sll != 9223372036854775000LL) + link_error (); + + d64 = -92233720.36854775E11DD; + sll = d64; + if (sll != -9223372036854775000LL) + link_error (); + + /* _Decimal64 to unsigned long long. */ + d64 = 1844674407370955.E4DD; + ull = d64; + if (ull != 18446744073709550000ULL) + link_error (); + + /* _Decimal128 to int. */ + + d128 = 2.147483647E9DL; + si = d128; + if (si != 2147483647) + link_error (); + + d128 = -2147483648.DL; + si = d128; + if (si != -2147483648) + link_error (); + + /* _Decimal128 to unsigned int. */ + + d128 = 4294.967295E6DL; + ui = d128; + if (ui != 4294967295) + link_error (); + + /* _Decimal128 to long long. */ + + d128 = 9223372036854775807.DL; + sll = d128; + if (sll != 9223372036854775807LL) + link_error (); + + d128 = -9.223372036854775808E19DL; + sll = d128; + if (sll != -9223372036854775807LL - 1LL) + link_error (); + + /* _Decimal128 to unsigned long long. */ + d128 = 18446744073709551615.DL; + ull = d128; + if (ull != 18446744073709551615ULL) + link_error (); +} + +int +main () +{ + /* This test assumes 32-bit int and 64-bit long long. */ + + if (sizeof (int) != 4 || sizeof (long long) != 8) + return 0; + + doit (); + return 0; +} Index: dfp/compare-eq-d32.c =================================================================== --- dfp/compare-eq-d32.c (nonexistent) +++ dfp/compare-eq-d32.c (revision 686) @@ -0,0 +1,14 @@ +/* { dg-options "-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 (); + + FINISH +} Index: dfp/func-vararg-mixed.c =================================================================== --- dfp/func-vararg-mixed.c (nonexistent) +++ dfp/func-vararg-mixed.c (revision 686) @@ -0,0 +1,102 @@ +/* C99 6.5.2.2 Function calls. + Test passing varargs of the combination of decimal float types and + other types. */ + +#include +#include "dfp-dbg.h" + +/* 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) FAILURE + if (vararg_d64 (4, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 4.0dd) FAILURE + if (vararg_d128 (1, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 1.0dl) FAILURE + if (vararg_int (0, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 0) FAILURE + if (vararg_double (2, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 2.0) FAILURE + + FINISH +} Index: dfp/compare-special-d128.c =================================================================== --- dfp/compare-special-d128.c (nonexistent) +++ dfp/compare-special-d128.c (revision 686) @@ -0,0 +1,15 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + C99 6.5.9 Equality operators. + Compare decimal float special values at runtime. */ + +#define WIDTH 128 +#include "compare-special.h" + +int +main () +{ + test_compares (); + FINISH +} Index: dfp/pr35620.c =================================================================== --- dfp/pr35620.c (nonexistent) +++ dfp/pr35620.c (revision 686) @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#ifdef __cplusplus +typedef float _Decimal32 __attribute__((mode(SD))); +#endif + +extern void foo (_Decimal32); +_Decimal32 *p; + +extern int i; +union U { _Decimal32 a; int b; } u; + +void +blatz (void) +{ + _Decimal32 d; + u.b = i; + d = u.a; + foo (d); +} + +void +bar (void) +{ + foo (*p); +} Index: dfp/compare-rel-d128.c =================================================================== --- dfp/compare-rel-d128.c (nonexistent) +++ dfp/compare-rel-d128.c (revision 686) @@ -0,0 +1,14 @@ +/* { dg-options "-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 (); + FINISH +} Index: dfp/pr31385.c =================================================================== --- dfp/pr31385.c (nonexistent) +++ dfp/pr31385.c (revision 686) @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef float fp_t __attribute__((mode(SD))); + +extern fp_t g(fp_t); + +fp_t +bug(fp_t x) +{ + fp_t result; + int n; + fp_t f, f3, y, z; + + n = 0; + y = 1.DF; + f = g(x); + + if (f < 0.DF) + f = -f; + + f3 = 2.DF; + + z = (y + y + f / (y * y)); + y = (z + z) / (9.DF) + f3 / (z * z); + + result = y; + + return (result); +} Index: dfp/operator-comma.c =================================================================== --- dfp/operator-comma.c (nonexistent) +++ dfp/operator-comma.c (revision 686) @@ -0,0 +1,47 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.17: Comma operator. + Test with decimal float operands. */ + +#include "dfp-dbg.h" + +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; + + FINISH +} Index: dfp/func-vararg-alternate.h =================================================================== --- dfp/func-vararg-alternate.h (nonexistent) +++ dfp/func-vararg-alternate.h (revision 686) @@ -0,0 +1,143 @@ +/* Simple test of vararg passing for problematic types with and without + double values passed between them. */ + +#include "dfp-dbg.h" +#include + +DTYPE a[10]; +double b[10]; + +union U { + DTYPE d; + unsigned int i[INTS]; +}; + +void +compare (double r, double s, unsigned int *p, unsigned int *q, int n, int line) +{ + int i; + + for (i = 0; i < n; i++) + if (r != s || p[i] != q[i]) +#ifdef DBG + { + int j; + + failures++; + printf ("line %-3d", line); + for (j = 0; j < n; j++) + printf (" %08x", p[j]); + printf (" %10.2g\n ", r); + for (j = 0; j < n; j++) + printf (" %08x", q[j]); + printf (" %10.2g\n\n", s); + + return; + } +#else + __builtin_abort (); +#endif +} + +void +bar0 (int n, ...) +{ + union U u; + int j; + va_list ap; + + va_start (ap, n); + for (j = 0; j < n; j++) + a[j] = va_arg (ap, DTYPE); + va_end (ap); +} + +void +bar1 (int n, ...) +{ + union U u; + int j; + va_list ap; + + va_start (ap, n); + for (j = 0; j < n; j++) + { + a[j] = va_arg (ap, DTYPE); + b[j] = va_arg (ap, double); + } + va_end (ap); +} + +void +bar2 (int n, ...) +{ + union U u; + int j; + va_list ap; + + va_start (ap, n); + for (j = 0; j < n; j++) + { + b[j] = va_arg (ap, double); + a[j] = va_arg (ap, DTYPE); + } + va_end (ap); +} + +void +doit () +{ + DTYPE x, y, z; + union U u1, u2; + + /* Sanity check that test setup is right, especially for long double + which can be changed by command line option. */ + if (INTS * 4 != sizeof (DTYPE)) + { +#ifdef DBG + printf ("test error: INTS = %d, sizeof (DTYPE) = %d\n", + INTS, sizeof (DTYPE)); +#endif + __builtin_abort (); + } + + x = ONE / THREE; + y = ONE / SEVEN; + z = ONE / ELEVEN; + + bar0 (1, x); + u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + + bar0 (2, x, y); + u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + + bar0 (3, x, y, z); + u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + u1.d = z; u2.d = a[2]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__); + + bar1 (1, x, 1.5); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + + bar1 (2, x, 1.5, y, 2.5); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); + + bar1 (3, x, 1.5, y, 2.5, z, 3.5); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); + u1.d = z; u2.d = a[2]; compare (3.5, b[2], u1.i, u2.i, INTS, __LINE__); + + bar2 (1, 1.5, x); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + + bar2 (2, 1.5, x, 2.5, y); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); + + bar2 (3, 1.5, x, 2.5, y, 3.5, z); + u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__); + u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__); + u1.d = z; u2.d = a[2]; compare (3.5, b[2], u1.i, u2.i, INTS, __LINE__); +} Index: dfp/compare-special-d64.c =================================================================== --- dfp/compare-special-d64.c (nonexistent) +++ dfp/compare-special-d64.c (revision 686) @@ -0,0 +1,15 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + C99 6.5.9 Equality operators. + Compare decimal float special values at runtime. */ + +#define WIDTH 64 +#include "compare-special.h" + +int +main () +{ + test_compares (); + FINISH +} Index: dfp/func-mixed.c =================================================================== --- dfp/func-mixed.c (nonexistent) +++ dfp/func-mixed.c (revision 686) @@ -0,0 +1,174 @@ +/* { dg-options "-Wall" } */ + +/* C99 6.5.2.2 Function calls. + Test scalar passing and return values involving decimal floating + point types. */ + +#include "dfp-dbg.h" + +/* 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; +} +_Decimal128 +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.0l) != 0.0df) FAILURE + if (arg1_32 (0, 1.0df, 2, 3.0f, 4.0, 5.0l) != 1.0df) FAILURE + if (arg2_32 (0, -1, 2.0df, 3.0f, 4.0, 5.0l) != 2.0df) FAILURE + if (arg3_32 (0, -1, 2.0f, 3.0df, 4.0, 5.0l) != 3.0df) FAILURE + if (arg4_32 (0, -1, 2.0f, 3.0, 4.0df, 5.0l) != 4.0df) FAILURE + if (arg5_32 (0, -1, 2.0f, 3.0, 4.0l, 5.0df) != 5.0df) FAILURE + + /* _Decimal64 variants. */ + if (arg0_64 (0.0dd, -1, 2, 3.0f, 4.0, 5.0l) != 0.0dd) FAILURE + if (arg1_64 (0, 1.0dd, 2, 3.0f, 4.0, 5.0l) != 1.0dd) FAILURE + if (arg2_64 (0, -1, 2.0dd, 3.0f, 4.0, 5.0l) != 2.0dd) FAILURE + if (arg3_64 (0, -1, 2.0f, 3.0dd, 4.0, 5.0l) != 3.0dd) FAILURE + if (arg4_64 (0, -1, 2.0f, 3.0, 4.0dd, 5.0l) != 4.0dd) FAILURE + if (arg5_64 (0, -1, 2.0f, 3.0, 4.0l, 5.0dd) != 5.0dd) FAILURE + + /* _Decimal128 variants. */ + if (arg0_128 (0.0dl, -1, 2, 3.0f, 4.0, 5.0l) != 0.0dl) FAILURE + if (arg1_128 (0, 1.0dl, 2, 3.0f, 4.0, 5.0l) != 1.0dl) FAILURE + if (arg2_128 (0, -1, 2.0dl, 3.0f, 4.0, 5.0l) != 2.0dl) FAILURE + if (arg3_128 (0, -1, 2.0f, 3.0dl, 4.0, 5.0l) != 3.0dl) FAILURE + if (arg4_128 (0, -1, 2.0f, 3.0, 4.0dl, 5.0l) != 4.0dl) FAILURE + if (arg5_128 (0, -1, 2.0f, 3.0, 4.0l, 5.0dl) != 5.0dl) FAILURE + + FINISH +} Index: dfp/compare-eq-dfp.c =================================================================== --- dfp/compare-eq-dfp.c (nonexistent) +++ dfp/compare-eq-dfp.c (revision 686) @@ -0,0 +1,53 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.9 Equality operators. + Compare decimal float values against variables of different types. */ + +#include "dfp-dbg.h" + +_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 (); + + FINISH +} Index: dfp/operator-assignment.c =================================================================== --- dfp/operator-assignment.c (nonexistent) +++ dfp/operator-assignment.c (revision 686) @@ -0,0 +1,56 @@ +/* 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. */ + +#include "dfp-dbg.h" + +#define OPERATE(OPRD1,OPRT,OPRD2,RLT) \ + if (( OPRD1 OPRT OPRD2 )!= RLT) \ + FAILURE + +#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.23456df, d32a = 1.2df; + _Decimal64 d64 = 23.456789dd, d64a = 2.8dd; + _Decimal128 d128 = 345.67890123456789dl, d128a = 4.7dl; + + DECIMAL_COMPOUND_ASSIGNMENT(32, d32); + DECIMAL_COMPOUND_ASSIGNMENT(64, d64); + DECIMAL_COMPOUND_ASSIGNMENT(128, d128); + + FINISH +} Index: dfp/convert-bfp-11.c =================================================================== --- dfp/convert-bfp-11.c (nonexistent) +++ dfp/convert-bfp-11.c (revision 686) @@ -0,0 +1,58 @@ +/* { dg-skip-if "" { ! "powerpc*-*-linux*" } { "*" } { "" } } */ + +/* Test decimal float conversions to and from IBM 128-bit long double. + Checks are skipped at runtime if long double is not 128 bits. + Don't force 128-bit long doubles because runtime support depends + on glibc. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; + +/* A value slightly less than DEC32_MAX can be converted in both directions. */ +CONVERT_VALID (101, sd, tf, 9.999998e96df, 9.999998e96L, 1.e+81L) +CONVERT_VALID (102, tf, sd, 9.999998e96L, 9.999998e96df, 0.df) + +/* A value slightly less than DBL_MAX can be converted in both directions. */ +CONVERT_VALID (201, tf, dd, 1.79768e+308l, 1.79768e+308dd, 0.dd) +CONVERT_VALID (202, dd, tf, 1.79768e+308dd, 1.79768e+308l, 2.e292l) +CONVERT_VALID (203, tf, td, 1.79768e+308l, 1.79768e+308dl, 1.e292dl) +CONVERT_VALID (204, td, tf, 1.79768e+308dl, 1.79768e+308l, 2.e292l) + +/* Check values that are too large for the result type. */ +CONVERT_TO_PINF (301, dd, tf, 1.8e+308dd, l) +CONVERT_TO_PINF (302, dd, tf, 9.9e+384dd, l) +CONVERT_TO_PINF (303, td, tf, 1.8e+308dl, l) +CONVERT_TO_PINF (304, td, tf, 9.9e+384dl, l) + +CONVERT_TO_PINF (311, tf, sd, 1.0e+97L, d32) +CONVERT_TO_PINF (312, tf, sd, 1.6e+308L, d32) + +int +main () +{ + if (sizeof (long double) != 16) + return 0; + + convert_101 (); + convert_102 (); + + convert_201 (); + convert_202 (); + convert_203 (); + convert_204 (); + + convert_301 (); + convert_302 (); + convert_303 (); + convert_304 (); + convert_311 (); + convert_312 (); + + FINISH +} Index: dfp/convert-bfp-13.c =================================================================== --- dfp/convert-bfp-13.c (nonexistent) +++ dfp/convert-bfp-13.c (revision 686) @@ -0,0 +1,18 @@ +/* Test for bug where fold changed binary operation to decimal + depending on typedefs. */ + +#include "dfp-dbg.h" + +volatile double d = 1.2345675; + +typedef const volatile _Decimal32 d32; + +int +main (void) +{ + _Decimal32 a = (d * d); + d32 b = (d * d); + if (a != b) + FAILURE + FINISH +} Index: dfp/modes.c =================================================================== --- dfp/modes.c (nonexistent) +++ dfp/modes.c (revision 686) @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +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); + Index: dfp/nan-1.c =================================================================== --- dfp/nan-1.c (nonexistent) +++ dfp/nan-1.c (revision 686) @@ -0,0 +1,106 @@ +/* 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. */ + +#include "dfp-dbg.h" + +int main() +{ + /* Some possibly non-obvious tests, but most logical + operations on NaN return false, including NaN == NaN. */ + if (__builtin_nand32("") == __builtin_nand32("")) + FAILURE + + if (__builtin_nand64("") == __builtin_nand64("")) + FAILURE + + if (__builtin_nand128("") == __builtin_nand128("")) + FAILURE + + if (!(__builtin_nand32("") != __builtin_nand32(""))) + FAILURE + + if (!(__builtin_nand64("") != __builtin_nand64(""))) + FAILURE + + if (!(__builtin_nand128("") != __builtin_nand128(""))) + FAILURE + + if (__builtin_nand32("") > __builtin_nand32("")) + FAILURE + + if (__builtin_nand64("") >= __builtin_nand64("")) + FAILURE + + if (__builtin_nand128("") < __builtin_nand128("")) + FAILURE + + if (-__builtin_nand128("") < +__builtin_nand128("")) + FAILURE + + /* 0.0/0.0 => NaN, but NaN != NaN. */ + if (0.0df/0.0dl == __builtin_nand32("")) + FAILURE + + /* 0.0 * INF => NaN. */ + if (!__builtin_isnand32 (0.0df * __builtin_infd32())) + FAILURE + + if (!__builtin_isnand64 (0.0dd * __builtin_infd64())) + FAILURE + + if (!__builtin_isnand128 (0.0dd * __builtin_infd128())) + FAILURE + + /* INF - INF => NaN. */ + if (!__builtin_isnand32 (__builtin_infd32() - __builtin_infd32())) + FAILURE + + if (!__builtin_isnand64 (__builtin_infd64() - __builtin_infd64())) + FAILURE + + if (!__builtin_isnand128 (__builtin_infd128() - __builtin_infd128())) + FAILURE + + /* INF/INF => NaN. */ + if (!__builtin_isnand32 (__builtin_infd32()/__builtin_infd32()) ) + FAILURE + + if (!__builtin_isnand64 (__builtin_infd64()/__builtin_infd64()) ) + FAILURE + + if (!__builtin_isnand128 (__builtin_infd128()/__builtin_infd128()) ) + FAILURE + + /* 0.0/0.0 => NaN, but NaN != NaN. */ + if ((0.0dd/0.0df) == (0.0dd/0.0df)) + FAILURE + + if (__builtin_nand32("") < __builtin_infd32()) + FAILURE + + if (__builtin_nand32("") >= __builtin_infd32()) + FAILURE + + /* Fixme: Add sqrtdf(-x.df) test when sqrt is supported. */ + + if (!__builtin_isnand32(__builtin_nand32(""))) + FAILURE + + if (!__builtin_isnand64(__builtin_nand64(""))) + FAILURE + + if (!__builtin_isnand128(__builtin_nand128(""))) + FAILURE + + if (!__builtin_isnand128(8.0df * __builtin_nand128(""))) + FAILURE + + if (!__builtin_isnand32(8.1dl - __builtin_nand32(""))) + FAILURE + + if (!__builtin_isnand128(__builtin_nand64("") + __builtin_nand128(""))) + FAILURE + + FINISH +} Index: dfp/loop-index.c =================================================================== --- dfp/loop-index.c (nonexistent) +++ dfp/loop-index.c (revision 686) @@ -0,0 +1,57 @@ +/* C99 6.8.5.2: The for statement. */ + +#include +#include +#include "dfp-dbg.h" + +void +f32 (void) +{ + _Decimal32 d; + int i; + + for (d = 1.1df, i=0; d <= 1.5df; d += 0.1df) + i++; + + if (i != 5) + FAILURE +} + +void +f64 (void) +{ + _Decimal64 d; + int i; + + for (d = 1.1dd, i=0; d <= 1.5dd; d += 0.1dd) + i++; + + if (i != 5) + FAILURE +} + +void +f128 (void) +{ + _Decimal128 d; + int i; + + for (d = 1.1dl, i=0; d <= 1.5dl; d += 0.1dl) + i++; + + if (i != 5) + FAILURE +} + +int +main () +{ + int i; + + f32 (); + f64 (); + f128 (); + + FINISH + return (0); +} Index: dfp/compare-eq-d64.c =================================================================== --- dfp/compare-eq-d64.c (nonexistent) +++ dfp/compare-eq-d64.c (revision 686) @@ -0,0 +1,14 @@ +/* { dg-options "-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 (); + + FINISH +} Index: dfp/usual-arith-conv-const.c =================================================================== --- dfp/usual-arith-conv-const.c (nonexistent) +++ dfp/usual-arith-conv-const.c (revision 686) @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +/* Test various conversions involving decimal floating types. */ + +#include "dfp-dbg.h" + +/* 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; +} Index: dfp/convert-bfp-3.c =================================================================== --- dfp/convert-bfp-3.c (nonexistent) +++ dfp/convert-bfp-3.c (revision 686) @@ -0,0 +1,21 @@ +/* This test assumes IEEE float and double. It also tests long double + but makes no assumption about its size or range of values. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; /* might actually be df or xf, doesn't matter */ + +CONVERT_ZEROES_ALL (t); + +int +main () +{ + CALL_ZEROES_ALL (t) + + FINISH +} Index: dfp/convert-bfp.c =================================================================== --- dfp/convert-bfp.c (nonexistent) +++ dfp/convert-bfp.c (revision 686) @@ -0,0 +1,131 @@ +/* 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. */ + +/* Long double isn't supported yet at runtime, so disable those checks. */ + +#include "dfp-dbg.h" + +static int skip_long_double; + +volatile _Decimal32 d32; +volatile _Decimal64 d64; +volatile _Decimal128 d128; +volatile float sf; +volatile double df; +volatile long double tf; + +int +main () +{ + /* Conversions from decimal float to binary float. */ + + if (sizeof (long double) == sizeof (double)) + skip_long_double = 1; + + /* Conversions from _Decimal32. */ + d32 = 2.0df; + sf = d32; + if (sf != 2.0f) + FAILURE + + df = d32; + if (df != 2.0) + FAILURE + + if (skip_long_double == 0) + { + tf = d32; + if (tf != 2.0l) + FAILURE + } + + /* Conversions from _Decimal64. */ + d64 = -7.0dd; + sf = d64; + if (sf != -7.0f) + FAILURE + + df = d64; + if (df != -7.0) + FAILURE + + if (skip_long_double == 0) + { + tf = d64; + if (tf != -7.0l) + FAILURE + } + + /* Conversions from _Decimal128. */ + d128 = 30.0dl; + sf = d128; + if (sf != 30.0f) + FAILURE + + df = d128; + if (df != 30.0) + FAILURE + + df = d128; + if (df != 30.0l) + FAILURE + + /* Conversions from binary float to decimal float. */ + sf = 30.0f; + d32 = sf; + if (d32 != 30.0df) + FAILURE + + d64 = sf; + if (d64 != 30.0dd) + FAILURE + + df = -2.0; + d32 = df; + if (d32 != -2.0df) + FAILURE + + d64 = df; + if (d64 != -2.0dd) + FAILURE + + d128 = df; + if (d128 != -2.0dl) + FAILURE + + sf = 30.0f; + d128 = sf; + if (d128 != 30.0dl) + FAILURE + + if (skip_long_double == 0) + { + tf = -22.0l; + d32 = tf; + if (d32 != -22.0df) + FAILURE + + d64 = tf; + if (d64 != -22.0dd) + FAILURE + + d128 = tf; + if (d128 != -22.0dl) + FAILURE + } + + /* 2**(-11) = 0.00048828125. */ + d128 = 0.000488281251dl; + sf = d128; + if (sf != 0.00048828125f) + FAILURE + /* 2**(-25) = 0.298023223876953125E-7. */ + d128 = 2.98023223876953125E-8dl; + df = d128; + if (df < (2.9802322387695312e-08 - 0.00000000001) + || df > (2.9802322387695312e-08 + 0.00000000001)) + FAILURE + + FINISH +} Index: dfp/pr39035.c =================================================================== --- dfp/pr39035.c (nonexistent) +++ dfp/pr39035.c (revision 686) @@ -0,0 +1,71 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +/* DFP TR 24732 == WG14 / N1176, N1312 */ +/* Based on a test from Fred Tydeman. */ + +#include "dfp-dbg.h" + +/* Test runtime computations. */ + +void +runtime32 (void) +{ + volatile _Decimal32 d; + d = 0.0DF; + if (d) + FAILURE +} + +void +runtime64 (void) +{ + volatile _Decimal64 d; + d = 0.0DD; + if (d) + FAILURE +} + +void +runtime128 (void) +{ + volatile _Decimal128 d; + d = 0.0DL; + if (d) + FAILURE +} + +void +fold32 (void) +{ + if (0.0DF) + FAILURE +} + +void +fold64 (void) +{ + if (0.0DD) + FAILURE +} + +void +fold128 (void) +{ + if (0.0DL) + FAILURE +} + +int +main(void) +{ + runtime32 (); + runtime64 (); + runtime128 (); + + fold32 (); + fold64 (); + fold128 (); + + FINISH +} Index: dfp/convert-bfp-5.c =================================================================== --- dfp/convert-bfp-5.c (nonexistent) +++ dfp/convert-bfp-5.c (revision 686) @@ -0,0 +1,21 @@ +/* This test assumes IEEE float and double. It also tests long double + but makes no assumption about its size or range of values. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; /* might actually be df or xf, doesn't matter */ + +CONVERT_NAN_ALL (t); + +int +main () +{ + CALL_NAN_ALL (t) + + FINISH +} Index: dfp/convert-dfp.c =================================================================== --- dfp/convert-dfp.c (nonexistent) +++ dfp/convert-dfp.c (revision 686) @@ -0,0 +1,94 @@ +/* { dg-options "-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. */ + +#ifndef __STDC_WANT_DEC_FP__ +#define __STDC_WANT_DEC_FP__ 1 +#endif + +#include "dfp-dbg.h" +#include + +volatile _Decimal32 d32; +volatile _Decimal64 d64; +volatile _Decimal128 d128; + +int +main () +{ + /* Conversions to larger types. */ + d32 = 123.4df; + d64 = d32; + if (d64 != 123.4dd) + FAILURE + d128 = d32; + if (d128 != 123.4dl) + FAILURE + d64 = 345.678dd; + d128 = d64; + if (d128 != 345.678dl) + FAILURE + + /* Conversions to smaller types for which the value fits. */ + d64 = 3456.789dd; + d32 = d64; + if (d32 != 3456.789df) + FAILURE + d128 = 123.4567dl; + d32 = d128; + if (d32 != 123.4567df) + FAILURE + + d128 = 1234567890.123456dl; + d64 = d128; + if (d64 != 1234567890.123456dd) + FAILURE + + /* 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) + FAILURE + + /* Rounds to more than _Decimal32 can handle. */ + d64 = 9.9999995E96DD; + d32 = d64; + if (d32 != __builtin_infd32()) + FAILURE + + /* Rounds to what _Decimal32 can handle. */ + d128 = 9.99999949E96DD; + d32 = d128; + if (d32 != DEC32_MAX) + FAILURE + + /* Rounds to more than _Decimal32 can handle. */ + d128= 9.9999995E96DD; + d32 = d128; + if (d32 != __builtin_infd32()) + FAILURE + + /* Rounds to what _Decimal64 can handle. */ + d128 = 9.99999999999999949E384DL; + d64 = d128; + if (d64 != DEC64_MAX) + FAILURE + + /* Rounds to more than _Decimal64 can handle. */ + d128 = 9.9999999999999995E384DL; + d64 = d128; + if (d64 != __builtin_infd64()) + FAILURE + + FINISH +} Index: dfp/convert-bfp-7.c =================================================================== --- dfp/convert-bfp-7.c (nonexistent) +++ dfp/convert-bfp-7.c (revision 686) @@ -0,0 +1,83 @@ +/* { dg-options "-w" } */ + +/* This test assumes IEEE float and double. */ + +#define __STDC_WANT_DEC_FP__ +#include + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; + +/* Check values that are too large for the result type. */ +CONVERT_TO_PINF (301, sd, sf, 4.e+38df, f) +CONVERT_TO_PINF (303, dd, sf, 4.e+38dd, f) +CONVERT_TO_PINF (302, sd, sf, 9.9e+384df, f) +CONVERT_TO_PINF (304, dd, sf, 9.9e+384dd, f) +CONVERT_TO_PINF (305, td, sf, 4.e+38dl, f) +CONVERT_TO_PINF (306, td, sf, 1.e+39dl, f) +CONVERT_TO_MINF (311, sd, sf, -4.e+38df, f) +CONVERT_TO_MINF (312, dd, sf, -4.e+38dd, f) +CONVERT_TO_MINF (313, sd, sf, -9.9e+384df, f) +CONVERT_TO_MINF (314, dd, sf, -9.9e+384dd, f) +CONVERT_TO_MINF (315, td, sf, -4.e+38dl, f) +CONVERT_TO_MINF (316, td, sf, -1.e+39dl, f) + +CONVERT_TO_PINF (321, dd, df, 1.8e+308dd,) +CONVERT_TO_PINF (322, dd, df, 9.9e+384dd,) +CONVERT_TO_PINF (323, td, df, 1.8e+308dl,) +CONVERT_TO_PINF (324, td, df, 9.9e+384dl,) +CONVERT_TO_PINF (325, dd, df, 1.e309dd,) +CONVERT_TO_PINF (326, td, df, 1.e309dl,) +CONVERT_TO_MINF (331, dd, df, -1.8e+308dd,) +CONVERT_TO_MINF (332, dd, df, -9.9e+384dd,) +CONVERT_TO_MINF (333, td, df, -1.8e+308dl,) +CONVERT_TO_MINF (334, td, df, -9.9e+384dl,) +CONVERT_TO_MINF (335, dd, df, -1.e309dd,) +CONVERT_TO_MINF (336, td, df, -1.e309dl,) + +CONVERT_TO_PINF (341, df, sd, 1.0e+97, d32) +CONVERT_TO_PINF (342, df, sd, 1.6e+308, d32) +CONVERT_TO_MINF (351, df, sd, -1.0e+97, d32) +CONVERT_TO_MINF (352, df, sd, -1.6e+308, d32) + +int +main () +{ + convert_301 (); + convert_302 (); + convert_303 (); + convert_304 (); + convert_305 (); + convert_306 (); + convert_311 (); + convert_312 (); + convert_313 (); + convert_314 (); + convert_315 (); + convert_316 (); + + convert_321 (); + convert_322 (); + convert_323 (); + convert_324 (); + convert_325 (); + convert_326 (); + convert_331 (); + convert_332 (); + convert_333 (); + convert_334 (); + convert_335 (); + convert_336 (); + + convert_341 (); + convert_342 (); + convert_351 (); + convert_352 (); + + FINISH +} Index: dfp/compare-rel-const.c =================================================================== --- dfp/compare-rel-const.c (nonexistent) +++ dfp/compare-rel-const.c (revision 686) @@ -0,0 +1,57 @@ +/* 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; +} Index: dfp/convert-int-fold.c =================================================================== --- dfp/convert-int-fold.c (nonexistent) +++ dfp/convert-int-fold.c (revision 686) @@ -0,0 +1,173 @@ +/* { dg-options "-O2" } */ + +/* N1150 5.1 Conversion between decimal floating integer. + C99 6.3.1.4(1a) New. + These should all be folded at compile time. */ + +#include "dfp-dbg.h" + +#ifdef __cplusplus +#define BOOL bool +#else +#define BOOL _Bool +#endif + +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; +} Index: dfp/convert-int-max.c =================================================================== --- dfp/convert-int-max.c (nonexistent) +++ dfp/convert-int-max.c (revision 686) @@ -0,0 +1,146 @@ +/* { dg-options "-O0 -w" } */ + +/* N1150 5.1 Conversions from decimal float to integer. */ + +/* Test decimal float to integer conversions for values at the limit of + what will fit into the destination type. This assumes 32-bit int and + 64-bit long long (there's a check for that below). */ + +#include "dfp-dbg.h" + +volatile _Decimal32 d32; +volatile _Decimal64 d64; +volatile _Decimal128 d128; +volatile int si; +volatile unsigned int ui; +volatile long long sll; +volatile unsigned long long ull; + +void +doit () +{ + /* _Decimal32 to int. */ + + d32 = 2147483.E3DF; + si = d32; + if (si != 2147483000) + FAILURE + + d32 = -2147483.E3DF; + si = d32; + if (si != -2147483000) + FAILURE + + /* _Decimal32 to unsigned int. */ + + d32 = 4.294967E9DF; + ui = d32; + if (ui != 4294967000U) + FAILURE + + /* _Decimal32 to long long. */ + + d32 = 922.3372E16DF; + sll = d32; + if (sll != 9223372000000000000LL) + FAILURE + + d32 = -92233.72E14DF; + sll = d32; + if (sll != -9223372000000000000LL) + FAILURE + + /* _Decimal32 to unsigned long long. */ + + d32 = .1844674E20DF; + ull = d32; + if (ull != 18446740000000000000ULL) + FAILURE + + /* _Decimal64 to int. */ + + d64 = 2.147483647E9DD; + si = d64; + if (si != 2147483647) + FAILURE + + d64 = -2147483648.DD; + si = d64; + if (si != -2147483648) + FAILURE + + /* _Decimal64 to unsigned int. */ + + d64 = 42949.67295E5DD; + ui = d64; + if (ui != 4294967295) + FAILURE + + /* _Decimal64 to long long. */ + + d64 = 9.223372036854775E18DD; + sll = d64; + if (sll != 9223372036854775000LL) + FAILURE + + d64 = -92233720.36854775E11DD; + sll = d64; + if (sll != -9223372036854775000LL) + FAILURE + + /* _Decimal64 to unsigned long long. */ + d64 = 1844674407370955.E4DD; + ull = d64; + if (ull != 18446744073709550000ULL) + FAILURE + + /* _Decimal128 to int. */ + + d128 = 2.147483647E9DL; + si = d128; + if (si != 2147483647) + FAILURE + + d128 = -2147483648.DL; + si = d128; + if (si != -2147483648) + FAILURE + + /* _Decimal128 to unsigned int. */ + + d128 = 4294.967295E6DL; + ui = d128; + if (ui != 4294967295) + FAILURE + + /* _Decimal128 to long long. */ + + d128 = 9223372036854775807.DL; + sll = d128; + if (sll != 9223372036854775807LL) + FAILURE + + d128 = -9.223372036854775808E19DL; + sll = d128; + if (sll != -9223372036854775807LL - 1LL) + FAILURE + + /* _Decimal128 to unsigned long long. */ + d128 = 18446744073709551615.DL; + ull = d128; + if (ull != 18446744073709551615ULL) + FAILURE +} + +int +main () +{ + /* This test assumes 32-bit int and 64-bit long long. */ + + if (sizeof (int) != 4 || sizeof (long long) != 8) + return 0; + + doit (); + + FINISH +} Index: dfp/convert-bfp-9.c =================================================================== --- dfp/convert-bfp-9.c (nonexistent) +++ dfp/convert-bfp-9.c (revision 686) @@ -0,0 +1,192 @@ +/* { dg-xfail-run-if "" { lax_strtofp } "*" "" } */ +/* { dg-options "-w" } */ + +/* This test assumes IEEE float and double. */ + +#define __STDC_WANT_DEC_FP__ +#include + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; + +/* Exponent values that might cause problems with a particular + implementation. */ + +CONVERT_VALID (101, dd, df, 1.e309dd, 1.e309, 0.) +CONVERT_VALID (102, dd, df, 1.e308dd, 1.e308, 0.) +CONVERT_VALID (103, dd, df, 1.e307dd, 1.e307, 0.) +CONVERT_VALID (104, dd, df, 1.e306dd, 1.e306, 0.) +CONVERT_VALID (105, dd, df, 1.e305dd, 1.e305, 0.) +CONVERT_VALID (106, dd, df, 1.e304dd, 1.e304, 0.) +CONVERT_VALID (107, dd, df, 1.e303dd, 1.e303, 0.) +CONVERT_VALID (108, dd, df, 1.e302dd, 1.e302, 0.) +CONVERT_VALID (109, dd, df, 1.e301dd, 1.e301, 0.) +CONVERT_VALID (110, dd, df, 1.e300dd, 1.e300, 0.) +CONVERT_VALID (111, dd, df, 1.e299dd, 1.e299, 0.) +CONVERT_VALID (112, dd, df, 1.e298dd, 1.e298, 0.) +CONVERT_VALID (113, dd, df, 1.e297dd, 1.e297, 0.) +CONVERT_VALID (114, dd, df, 1.e296dd, 1.e296, 0.) +CONVERT_VALID (115, dd, df, 1.e295dd, 1.e295, 0.) +CONVERT_VALID (116, dd, df, 1.e294dd, 1.e294, 0.) +CONVERT_VALID (117, dd, df, 1.e293dd, 1.e293, 0.) +CONVERT_VALID (118, dd, df, 1.e292dd, 1.e292, 0.) +CONVERT_VALID (119, dd, df, 1.e291dd, 1.e291, 0.) +CONVERT_VALID (120, dd, df, 1.e290dd, 1.e290, 0.) + +CONVERT_VALID (201, dd, df, 1.e-309dd, 1.e-309, 0.) +CONVERT_VALID (202, dd, df, 1.e-308dd, 1.e-308, 0.) +CONVERT_VALID (203, dd, df, 1.e-307dd, 1.e-307, 0.) +CONVERT_VALID (204, dd, df, 1.e-306dd, 1.e-306, 0.) +CONVERT_VALID (205, dd, df, 1.e-305dd, 1.e-305, 0.) +CONVERT_VALID (206, dd, df, 1.e-304dd, 1.e-304, 0.) +CONVERT_VALID (207, dd, df, 1.e-303dd, 1.e-303, 0.) +CONVERT_VALID (208, dd, df, 1.e-302dd, 1.e-302, 0.) +CONVERT_VALID (209, dd, df, 1.e-301dd, 1.e-301, 0.) +CONVERT_VALID (210, dd, df, 1.e-300dd, 1.e-300, 0.) +CONVERT_VALID (211, dd, df, 1.e-299dd, 1.e-299, 0.) +CONVERT_VALID (212, dd, df, 1.e-298dd, 1.e-298, 0.) +CONVERT_VALID (213, dd, df, 1.e-297dd, 1.e-297, 0.) +CONVERT_VALID (214, dd, df, 1.e-296dd, 1.e-296, 0.) +CONVERT_VALID (215, dd, df, 1.e-295dd, 1.e-295, 0.) +CONVERT_VALID (216, dd, df, 1.e-294dd, 1.e-294, 0.) +CONVERT_VALID (217, dd, df, 1.e-293dd, 1.e-293, 0.) +CONVERT_VALID (218, dd, df, 1.e-292dd, 1.e-292, 0.) +CONVERT_VALID (219, dd, df, 1.e-291dd, 1.e-291, 0.) +CONVERT_VALID (220, dd, df, 1.e-290dd, 1.e-290, 0.) + +CONVERT_VALID (301, td, df, 1.e309dl, 1.e309, 0.) +CONVERT_VALID (302, td, df, 1.e308dl, 1.e308, 0.) +CONVERT_VALID (303, td, df, 1.e307dl, 1.e307, 0.) +CONVERT_VALID (304, td, df, 1.e306dl, 1.e306, 0.) +CONVERT_VALID (305, td, df, 1.e305dl, 1.e305, 0.) +CONVERT_VALID (306, td, df, 1.e304dl, 1.e304, 0.) +CONVERT_VALID (307, td, df, 1.e303dl, 1.e303, 0.) +CONVERT_VALID (308, td, df, 1.e302dl, 1.e302, 0.) +CONVERT_VALID (309, td, df, 1.e301dl, 1.e301, 0.) +CONVERT_VALID (310, td, df, 1.e300dl, 1.e300, 0.) +CONVERT_VALID (311, td, df, 1.e299dl, 1.e299, 0.) +CONVERT_VALID (312, td, df, 1.e298dl, 1.e298, 0.) +CONVERT_VALID (313, td, df, 1.e297dl, 1.e297, 0.) +CONVERT_VALID (314, td, df, 1.e296dl, 1.e296, 0.) +CONVERT_VALID (315, td, df, 1.e295dl, 1.e295, 0.) +CONVERT_VALID (316, td, df, 1.e294dl, 1.e294, 0.) +CONVERT_VALID (317, td, df, 1.e293dl, 1.e293, 0.) +CONVERT_VALID (318, td, df, 1.e292dl, 1.e292, 0.) +CONVERT_VALID (319, td, df, 1.e291dl, 1.e291, 0.) +CONVERT_VALID (320, td, df, 1.e290dl, 1.e290, 0.) + +CONVERT_VALID (401, td, df, 1.e-309dl, 1.e-309, 0.) +CONVERT_VALID (402, td, df, 1.e-308dl, 1.e-308, 0.) +CONVERT_VALID (403, td, df, 1.e-307dl, 1.e-307, 0.) +CONVERT_VALID (404, td, df, 1.e-306dl, 1.e-306, 0.) +CONVERT_VALID (405, td, df, 1.e-305dl, 1.e-305, 0.) +CONVERT_VALID (406, td, df, 1.e-304dl, 1.e-304, 0.) +CONVERT_VALID (407, td, df, 1.e-303dl, 1.e-303, 0.) +CONVERT_VALID (408, td, df, 1.e-302dl, 1.e-302, 0.) +CONVERT_VALID (409, td, df, 1.e-301dl, 1.e-301, 0.) +CONVERT_VALID (410, td, df, 1.e-300dl, 1.e-300, 0.) +CONVERT_VALID (411, td, df, 1.e-299dl, 1.e-299, 0.) +CONVERT_VALID (412, td, df, 1.e-298dl, 1.e-298, 0.) +CONVERT_VALID (413, td, df, 1.e-297dl, 1.e-297, 0.) +CONVERT_VALID (414, td, df, 1.e-296dl, 1.e-296, 0.) +CONVERT_VALID (415, td, df, 1.e-295dl, 1.e-295, 0.) +CONVERT_VALID (416, td, df, 1.e-294dl, 1.e-294, 0.) +CONVERT_VALID (417, td, df, 1.e-293dl, 1.e-293, 0.) +CONVERT_VALID (418, td, df, 1.e-292dl, 1.e-292, 0.) +CONVERT_VALID (419, td, df, 1.e-291dl, 1.e-291, 0.) +CONVERT_VALID (420, td, df, 1.e-290dl, 1.e-290, 0.) + +int +main () +{ + convert_101 (); + convert_102 (); + convert_103 (); + convert_104 (); + convert_105 (); + convert_106 (); + convert_107 (); + convert_108 (); + convert_109 (); + convert_110 (); + convert_111 (); + convert_112 (); + convert_113 (); + convert_114 (); + convert_115 (); + convert_116 (); + convert_117 (); + convert_118 (); + convert_119 (); + convert_120 (); + + convert_201 (); + convert_202 (); + convert_203 (); + convert_204 (); + convert_205 (); + convert_206 (); + convert_207 (); + convert_208 (); + convert_209 (); + convert_210 (); + convert_211 (); + convert_212 (); + convert_213 (); + convert_214 (); + convert_215 (); + convert_216 (); + convert_217 (); + convert_218 (); + convert_219 (); + convert_220 (); + + convert_301 (); + convert_302 (); + convert_303 (); + convert_304 (); + convert_305 (); + convert_306 (); + convert_307 (); + convert_308 (); + convert_309 (); + convert_310 (); + convert_311 (); + convert_312 (); + convert_313 (); + convert_314 (); + convert_315 (); + convert_316 (); + convert_317 (); + convert_318 (); + convert_319 (); + convert_320 (); + + convert_401 (); + convert_402 (); + convert_403 (); + convert_404 (); + convert_405 (); + convert_406 (); + convert_407 (); + convert_408 (); + convert_409 (); + convert_410 (); + convert_411 (); + convert_412 (); + convert_413 (); + convert_414 (); + convert_415 (); + convert_416 (); + convert_417 (); + convert_418 (); + convert_419 (); + convert_420 (); + + FINISH +} Index: dfp/compare-rel-d32.c =================================================================== --- dfp/compare-rel-d32.c (nonexistent) +++ dfp/compare-rel-d32.c (revision 686) @@ -0,0 +1,14 @@ +/* { dg-options "-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 (); + FINISH +} Index: dfp/call-by-value.c =================================================================== --- dfp/call-by-value.c (nonexistent) +++ dfp/call-by-value.c (revision 686) @@ -0,0 +1,43 @@ +/* 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. */ + +#include "dfp-dbg.h" + +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) + FAILURE + + foo64 (d64); + if (d64 != 1.2dd) + FAILURE + + foo128 (d128); + if (d128 != 1.3dl) + FAILURE + + FINISH +} Index: dfp/func-scalar.c =================================================================== --- dfp/func-scalar.c (nonexistent) +++ dfp/func-scalar.c (revision 686) @@ -0,0 +1,192 @@ +/* C99 6.5.2.2 Function calls. + Test scalar passing and return values involving decimal floating + point types. */ + +#include "dfp-dbg.h" + +/* 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) + FAILURE + if (arg1_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 1.0df) + FAILURE + if (arg2_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 2.0df) + FAILURE + if (arg3_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 3.0df) + FAILURE + if (arg4_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 4.0df) + FAILURE + if (arg5_32 (0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 5.0df) + FAILURE + + /* _Decimal64 variants. */ + if (arg0_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 0.0dd) + FAILURE + if (arg1_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 1.0dd) + FAILURE + if (arg2_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 2.0dd) + FAILURE + if (arg3_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 3.0dd) + FAILURE + if (arg4_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 4.0dd) + FAILURE + if (arg5_64 (0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 5.0dd) + FAILURE + + /* _Decimal128 variants. */ + if (arg0_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 0.0dl) + FAILURE + if (arg1_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 1.0dl) + FAILURE + if (arg2_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 2.0dl) + FAILURE + if (arg3_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 3.0dl) + FAILURE + if (arg4_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 4.0dl) + FAILURE + if (arg5_128 (0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 5.0dl) + FAILURE + + FINISH +} Index: dfp/signbit-2.c =================================================================== --- dfp/signbit-2.c (nonexistent) +++ dfp/signbit-2.c (revision 686) @@ -0,0 +1,36 @@ +/* { dg-options "-O1" } */ + +/* Check that the compiler uses builtins for signbit; if not the link + will fail because library functions are in libm. */ +/* See PR51867. + Since GCC uses library call when optimizing for "-O0", this test + case requires at least "-O1" level optimization now. */ + +#include "dfp-dbg.h" + +volatile _Decimal32 sd = 2.3df; +volatile _Decimal64 dd = -4.5dd; +volatile _Decimal128 tf = 5.3dl; +volatile float f = 1.2f; +volatile double d = -7.8; +volatile long double ld = 3.4L; + +EXTERN int signbitf (float); +EXTERN int signbit (double); +EXTERN int signbitl (long double); +EXTERN int signbitd32 (_Decimal32); +EXTERN int signbitd64 (_Decimal64); +EXTERN int signbitd128 (_Decimal128); + +int +main () +{ + if (signbitf (f) != 0) FAILURE + if (signbit (d) == 0) FAILURE + if (signbitl (ld) != 0) FAILURE + if (signbitd32 (sd) != 0) FAILURE + if (signbitd64 (dd) == 0) FAILURE + if (signbitd128 (tf) != 0) FAILURE + + FINISH +} Index: dfp/usual-arith-conv.c =================================================================== --- dfp/usual-arith-conv.c (nonexistent) +++ dfp/usual-arith-conv.c (revision 686) @@ -0,0 +1,117 @@ +/* { dg-options "-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. */ + +#include "dfp-dbg.h" + +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 + + FINISH +} Index: dfp/operator-logical.c =================================================================== --- dfp/operator-logical.c (nonexistent) +++ dfp/operator-logical.c (revision 686) @@ -0,0 +1,63 @@ +/* C99 Logical AND operator. + C99 Logical OR operator. + Test with decimal float operands. */ + +#include "dfp-dbg.h" + +#define OPERATE(OPRD1,OPRT,OPRD2,RLT) \ +do \ +{ \ + if (( (OPRD1) OPRT (OPRD2) )!= RLT) \ + __builtin_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; +} Index: dfp/compare-eq-d128.c =================================================================== --- dfp/compare-eq-d128.c (nonexistent) +++ dfp/compare-eq-d128.c (revision 686) @@ -0,0 +1,14 @@ +/* { dg-options "-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 (); + + FINISH +} Index: dfp/convert-bfp-fold.c =================================================================== --- dfp/convert-bfp-fold.c (nonexistent) +++ dfp/convert-bfp-fold.c (revision 686) @@ -0,0 +1,118 @@ +/* { dg-options "-O2" } */ + +/* 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. */ + +#include "dfp-dbg.h" + +_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; + d128 = sf; + if (d128 != 30.0dl) + link_error (); + + d64 = sf; + if (d64 != 30.0dd) + link_error (); + + d32 = sf; + if (d32 != 30.0df) + link_error (); + + df = -2.0; + d128 = df; + if (d128 != -2.0dl) + link_error (); + + d64 = df; + if (d64 != -2.0dd) + link_error (); + + d32 = df; + if (d32 != -2.0df) + link_error (); + + tf = -22.0l; + d128 = tf; + if (d128 != -22.0dl) + link_error (); + + d64 = tf; + if (d64 != -22.0dd) + link_error (); + + d32 = tf; + if (d32 != -22.0df) + 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; +} Index: dfp/convert-int.c =================================================================== --- dfp/convert-int.c (nonexistent) +++ dfp/convert-int.c (revision 686) @@ -0,0 +1,199 @@ +/* { dg-options "-O0" } */ + +/* N1150 5.1 Conversion between decimal floating types and integer. + C99 6.3.1.4(1a) New. */ + +#include "dfp-dbg.h" + +#ifdef __cplusplus +#define BOOL bool +#else +#define BOOL _Bool +#endif + +_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) + FAILURE + ul = d32; + if (ul != 456UL) + FAILURE + ull = d32; + if (ull != 456ULL) + FAILURE + + ui = d64; + if (ui != 23U) + FAILURE + ul = d64; + if (ul != 23UL) + FAILURE + ull = d64; + if (ull != 23ULL) + FAILURE + + ui = d128; + if (ui != 1234U) + FAILURE + ul = d128; + if (ul != 1234UL) + FAILURE + ull = d128; + if (ull != 1234ULL) + FAILURE + + /* Decimal float to signed integer. */ + + /* Decimal float to BOOL. */ + init_dfp_2 (); + + b = d32; + if (!b) + FAILURE + b = d64; + if (!b) + FAILURE + b = d128; + if (!b) + FAILURE + + /* Unsigned integer to decimal float. */ + init_unsigned_int (); + + d32 = ui; + if (d32 != 987.0df) + FAILURE + d32 = ul; + if (d32 != 345678.0df) + FAILURE + d32 = ull; + if (d32 != 1234567.df) + FAILURE + + d64 = ui; + if (d64 != 987.0dd) + FAILURE + d64 = ul; + if (d64 != 345678.0dd) + FAILURE + d64 = ull; + if (d64 != 1234567.dd) + FAILURE + + d128 = ui; + if (d128 != 987.0dl) + FAILURE + d128 = ul; + if (d128 != 345678.0dl) + FAILURE + d128 = ull; + if (d128 != 1234567.dl) + FAILURE + + /* Signed integer to decimal float. */ + init_signed_int (); + + d32 = si; + if (d32 != -987.0df) + FAILURE + d32 = sl; + if (d32 != -345678.0df) + FAILURE + d32 = sll; + if (d32 != -1234567.df) + FAILURE + + d64 = si; + if (d64 != -987.0dd) + FAILURE + d64 = sl; + if (d64 != -345678.0dd) + FAILURE + d64 = sll; + if (d64 != -1234567.dd) + FAILURE + + d128 = si; + if (d128 != -987.0dl) + FAILURE + d128 = sl; + if (d128 != -345678.0dl) + FAILURE + d128 = sll; + if (d128 != -1234567.dl) + FAILURE + + /* BOOL to decimal float. */ + init_dfp_3 (); + + b = d32; + if (b) + FAILURE + b = d64; + if (b) + FAILURE + b = d128; + if (b) + FAILURE + + FINISH +} Index: dfp/dfp-dbg.h =================================================================== --- dfp/dfp-dbg.h (nonexistent) +++ dfp/dfp-dbg.h (revision 686) @@ -0,0 +1,20 @@ +#ifdef __cplusplus +typedef float _Decimal32 __attribute__((mode(SD))); +typedef float _Decimal64 __attribute__((mode(DD))); +typedef float _Decimal128 __attribute__((mode(TD))); + +#define EXTERN extern "C" +#else +#define EXTERN extern +#endif + +int failures; + +#ifdef DBG +extern int printf (const char *, ...); +#define FAILURE { printf ("failed at line %d\n", __LINE__); failures++; } +#define FINISH if (failures != 0) __builtin_abort (); return 0; +#else +#define FAILURE __builtin_abort (); +#define FINISH return 0; +#endif Index: dfp/convert-dfp-fold-2.c =================================================================== --- dfp/convert-dfp-fold-2.c (nonexistent) +++ dfp/convert-dfp-fold-2.c (revision 686) @@ -0,0 +1,15 @@ +/* Test for bug where fold narrowed decimal floating-point + operations. */ + +#include "dfp-dbg.h" + +volatile _Decimal32 f = 1.23456DF; +volatile _Decimal64 d = 1.23456DD; + +int +main (void) +{ + if ((_Decimal128)((_Decimal64)f * (_Decimal64)f) != (_Decimal128)(d * d)) + FAILURE + FINISH +} Index: dfp/compare-special.h =================================================================== --- dfp/compare-special.h (nonexistent) +++ dfp/compare-special.h (revision 686) @@ -0,0 +1,284 @@ +/* Basic test of runtime relational comparisons using NaNs and infinities. */ + +#include +#include "dfp-dbg.h" + +#define PASTE2(A,B) A ## B +#define PASTE(A,B) PASTE2(A,B) + +/* Override FAILURE from dfp-dbg.h with one that provides additional info. */ +#undef FAILURE +#ifdef DBG +#define FAILURE(OP,KIND) \ + { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \ + failures++; } +#else +#define FAILURE(OP,KIND) __builtin_abort (); +#endif + +#ifndef WIDTH +#error define WIDTH as decimal float size in bytes +#endif + +#if WIDTH == 32 +#define DTYPE _Decimal32 +#define SUFFIX DF +#define SUFFIX2 d32 +#elif WIDTH == 64 +#define DTYPE _Decimal64 +#define SUFFIX DD +#define SUFFIX2 d64 +#elif WIDTH == 128 +#define DTYPE _Decimal128 +#define SUFFIX DL +#define SUFFIX2 d128 +#elif WIDTH == 0 +/* This is for testing the test using a type known to work. */ +#define DTYPE double +#define SUFFIX +#define SUFFIX2 +#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); + +volatile DTYPE x, y, z, _nan, inf, m_inf; + +void +test_compares (void) +{ + _nan = PASTE(__builtin_nan, SUFFIX2) (""); + inf = PASTE(__builtin_inf, SUFFIX2) (); + m_inf = - PASTE(__builtin_inf, SUFFIX2) (); + + x = PASTE(__builtin_nan, SUFFIX2) (""); + y = PASTE(__builtin_inf, SUFFIX2) (); + z = - PASTE(__builtin_inf, SUFFIX2) (); + + /* Less than or equal to with NaN. */ + + if (x <= two) FAILURE ("<=", "NaN") + if (x <= zero) FAILURE ("<=", "NaN") + if (x <= m_one) FAILURE ("<=", "NaN") + if (x <= _nan) FAILURE ("<=", "NaN") + if (x <= inf) FAILURE ("<=", "NaN") + if (x <= m_inf) FAILURE ("<=", "NaN") + + if (two <= x) FAILURE ("<=", "NaN") + if (zero <= x) FAILURE ("<=", "NaN") + if (m_one <= x) FAILURE ("<=", "NaN") + if (_nan <= x) FAILURE ("<=", "NaN") + if (inf <= x) FAILURE ("<=", "NaN") + if (m_inf <= x) FAILURE ("<=", "NaN") + + /* Less than or equal to with infinities, no NaNs. */ + + if (y <= two) FAILURE ("<=", "inf") + if (y <= zero) FAILURE ("<=", "inf") + if (y <= m_one) FAILURE ("<=", "inf") + if (!(two <= y)) FAILURE ("<=", "inf") + if (!(zero <= y)) FAILURE ("<=", "inf") + if (!(m_one <= y)) FAILURE ("<=", "inf") + + if (!(z <= two)) FAILURE ("<=", "-inf") + if (!(z <= zero)) FAILURE ("<=", "-inf") + if (!(z <= m_one)) FAILURE ("<=", "-inf") + if (two <= z) FAILURE ("<=", "-inf") + if (zero <= z) FAILURE ("<=", "-inf") + if (m_one <= z) FAILURE ("<=", "-inf") + + if (!(y <= inf)) FAILURE ("<=", "inf") + if (y <= m_inf) FAILURE ("<=", "inf") + if (!(z <= inf)) FAILURE ("<=", "inf") + if (!(z <= m_inf)) FAILURE ("<=", "inf") + + /* Less than with NaN. */ + + if (x < two) FAILURE ("<", "NaN") + if (x < zero) FAILURE ("<", "NaN") + if (x < m_one) FAILURE ("<", "NaN") + if (x < _nan) FAILURE ("<", "NaN") + if (x < inf) FAILURE ("<", "NaN") + if (x < m_inf) FAILURE ("<", "NaN") + + if (two < x) FAILURE ("<", "NaN") + if (zero < x) FAILURE ("<", "NaN") + if (m_one < x) FAILURE ("<", "NaN") + if (_nan < x) FAILURE ("<", "NaN") + if (inf < x) FAILURE ("<", "NaN") + if (m_inf < x) FAILURE ("<", "NaN") + + /* Less than with infinities, no NaNs. */ + + if (y < two) FAILURE ("<", "inf") + if (y < zero) FAILURE ("<", "inf") + if (y < m_one) FAILURE ("<", "inf") + if (!(two < y)) FAILURE ("<", "inf") + if (!(zero < y)) FAILURE ("<", "inf") + if (!(m_one < y)) FAILURE ("<", "inf") + + if (!(z < two)) FAILURE ("<", "-inf") + if (!(z < zero)) FAILURE ("<", "-inf") + if (!(z < m_one)) FAILURE ("<", "-inf") + if (two < z) FAILURE ("<", "-inf") + if (zero < z) FAILURE ("<", "-inf") + if (m_one < z) FAILURE ("<", "-inf") + + if (y < inf) FAILURE ("<=", "inf") + if (y < m_inf) FAILURE ("<=", "inf") + if (!(z < inf)) FAILURE ("<=", "inf") + if (z < m_inf) FAILURE ("<=", "inf") + + /* Greater than or equal to with NaN. */ + + if (x >= two) FAILURE (">=", "NaN") + if (x >= zero) FAILURE (">=", "NaN") + if (x >= m_one) FAILURE (">=", "NaN") + if (x >= _nan) FAILURE (">=", "NaN") + if (x >= inf) FAILURE (">=", "NaN") + if (x >= m_inf) FAILURE (">=", "NaN") + + if (two >= x) FAILURE (">=", "NaN") + if (zero >= x) FAILURE (">=", "NaN") + if (m_one >= x) FAILURE (">=", "NaN") + if (_nan >= x) FAILURE (">=", "NaN") + if (inf >= x) FAILURE (">=", "NaN") + if (m_inf >= x) FAILURE (">=", "NaN") + + /* Greater than or equal to with infinities, no NaNs. */ + + if (!(y >= two)) FAILURE (">=", "inf") + if (!(y >= zero)) FAILURE (">=", "inf") + if (!(y >= m_one)) FAILURE (">=", "inf") + if (two >= y) FAILURE (">=", "inf") + if (zero >= y) FAILURE (">=", "inf") + if (m_one >= y) FAILURE (">=", "inf") + + if (z >= two) FAILURE (">=", "-inf") + if (z >= zero) FAILURE (">=", "-inf") + if (z >= m_one) FAILURE (">=", "-inf") + if (!(two >= z)) FAILURE (">=", "-inf") + if (!(zero >= z)) FAILURE (">=", "-inf") + if (!(m_one >= z)) FAILURE (">=", "-inf") + + if (!(y >= inf)) FAILURE ("<=", "inf") + if (!(y >= m_inf)) FAILURE ("<=", "inf") + if (z >= inf) FAILURE ("<=", "inf") + if (!(z >= m_inf)) FAILURE ("<=", "inf") + + /* Greater than with NaN. */ + + if (x > two) FAILURE (">", "NaN") + if (x > zero) FAILURE (">", "NaN") + if (x > m_one) FAILURE (">", "NaN") + if (x > _nan) FAILURE (">", "NaN") + if (x > inf) FAILURE (">", "NaN") + if (x > m_inf) FAILURE (">", "NaN") + + if (two > x) FAILURE (">", "NaN") + if (zero > x) FAILURE (">", "NaN") + if (m_one > x) FAILURE (">", "NaN") + if (_nan > x) FAILURE (">", "NaN") + if (inf > x) FAILURE (">", "NaN") + if (m_inf > x) FAILURE (">", "NaN") + + /* Greater than with infinities, no NaNs. */ + + if (!(y > two)) FAILURE (">", "inf") + if (!(y > zero)) FAILURE (">", "inf") + if (!(y > m_one)) FAILURE (">", "inf") + if (two > y) FAILURE (">", "inf") + if (zero > y) FAILURE (">", "inf") + if (m_one > y) FAILURE (">", "inf") + + if (z > two) FAILURE (">", "-inf") + if (z > zero) FAILURE (">", "-inf") + if (z > m_one) FAILURE (">", "-inf") + if (!(two > z)) FAILURE (">", "-inf") + if (!(zero > z)) FAILURE (">", "-inf") + if (!(m_one > z)) FAILURE (">", "-inf") + + if (y > inf) FAILURE (">", "inf") + if (!(y > m_inf)) FAILURE (">", "inf") + if (z > inf) FAILURE (">", "inf") + if (z > m_inf) FAILURE (">", "inf") + + /* Equal with NaN. */ + + if (x == two) FAILURE ("==", "NaN") + if (x == zero) FAILURE ("==", "NaN") + if (x == m_one) FAILURE ("==", "NaN") + if (x == _nan) FAILURE ("==", "NaN") + if (x == inf) FAILURE ("==", "NaN") + if (x == m_inf) FAILURE ("==", "NaN") + + if (two == x) FAILURE ("==", "NaN") + if (zero == x) FAILURE ("==", "NaN") + if (m_one == x) FAILURE ("==", "NaN") + if (_nan == x) FAILURE ("==", "NaN") + if (inf == x) FAILURE ("==", "NaN") + if (m_inf == x) FAILURE ("==", "NaN") + + /* Equal with infinities, no NaNs. */ + + if (y == two) FAILURE ("==", "inf") + if (y == zero) FAILURE ("==", "inf") + if (y == m_one) FAILURE ("==", "inf") + if (two == y) FAILURE ("==", "inf") + if (zero == y) FAILURE ("==", "inf") + if (m_one == y) FAILURE ("==", "inf") + + if (z == two) FAILURE ("==", "-inf") + if (z == zero) FAILURE ("==", "-inf") + if (z == m_one) FAILURE ("==", "-inf") + if (two == z) FAILURE ("==", "-inf") + if (zero == z) FAILURE ("==", "-inf") + if (m_one == z) FAILURE ("==", "-inf") + + if (!(y == inf)) FAILURE ("==", "inf") + if (y == m_inf) FAILURE ("==", "inf") + if (z == inf) FAILURE ("==", "inf") + if (!(z == m_inf)) FAILURE ("==", "inf") + + /* Not equal with NaN. */ + + if (!(x != two)) FAILURE ("!=", "NaN") + if (!(x != zero)) FAILURE ("!=", "NaN") + if (!(x != m_one)) FAILURE ("!=", "NaN") + if (!(x != _nan)) FAILURE ("!=", "NaN") + if (!(x != inf)) FAILURE ("!=", "NaN") + if (!(x != m_inf)) FAILURE ("!=", "NaN") + + if (!(two != x)) FAILURE ("!=", "NaN") + if (!(zero != x)) FAILURE ("!=", "NaN") + if (!(m_one != x)) FAILURE ("!=", "NaN") + if (!(_nan != x)) FAILURE ("!=", "NaN") + if (!(inf != x)) FAILURE ("!=", "NaN") + if (!(m_inf != x)) FAILURE ("!=", "NaN") + + /* Not equal with infinities, no NaNs. */ + + if (!(y != two)) FAILURE ("!=", "inf") + if (!(y != zero)) FAILURE ("!=", "inf") + if (!(y != m_one)) FAILURE ("!=", "inf") + if (!(two != y)) FAILURE ("!=", "inf") + if (!(zero != y)) FAILURE ("!=", "inf") + if (!(m_one != y)) FAILURE ("!=", "inf") + + if (!(z != two)) FAILURE ("!=", "-inf") + if (!(z != zero)) FAILURE ("!=", "-inf") + if (!(z != m_one)) FAILURE ("!=", "-inf") + if (!(two != z)) FAILURE ("!=", "-inf") + if (!(zero != z)) FAILURE ("!=", "-inf") + if (!(m_one != z)) FAILURE ("!=", "-inf") + + if (y != inf) FAILURE ("!=", "inf") + if (!(y != m_inf)) FAILURE ("!=", "inf") + if (!(z != inf)) FAILURE ("!=", "inf") + if (z != m_inf) FAILURE ("!=", "inf") +} Index: dfp/compare-rel-dfp.c =================================================================== --- dfp/compare-rel-dfp.c (nonexistent) +++ dfp/compare-rel-dfp.c (revision 686) @@ -0,0 +1,53 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + Compare decimal float values against variables of different types. */ + +#include "dfp-dbg.h" + +_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 (); + + FINISH +} Index: dfp/compare-eq-const.c =================================================================== --- dfp/compare-eq-const.c (nonexistent) +++ dfp/compare-eq-const.c (revision 686) @@ -0,0 +1,28 @@ +/* C99 6.5.9 Equality operators. + Compare decimal float constants against each other. */ + +#include "dfp-dbg.h" + +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 (); + + FINISH +} Index: dfp/func-deref.c =================================================================== --- dfp/func-deref.c (nonexistent) +++ dfp/func-deref.c (revision 686) @@ -0,0 +1,205 @@ +/* C99 6.5.2.2 Function calls. + Test scalar passing and return values involving decimal floating + point types and dereferenced pointers. */ + +#include "dfp-dbg.h" + +/* A handful of functions that return their Nth _Decimal32 + argument. */ + +_Decimal32 __attribute__((noinline)) +arg0_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg0; +} + +_Decimal32 __attribute__((noinline)) +arg1_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg1; +} + +_Decimal32 __attribute__((noinline)) +arg2_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg2; +} + +_Decimal32 __attribute__((noinline)) +arg3_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg3; +} + +_Decimal32 __attribute__((noinline)) +arg4_32 (_Decimal32 arg0, _Decimal32 arg1, _Decimal32 arg2, + _Decimal32 arg3, _Decimal32 arg4, _Decimal32 arg5) +{ + return arg4; +} + +_Decimal32 __attribute__((noinline)) +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 __attribute__((noinline)) +arg0_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg0; +} + +_Decimal64 __attribute__((noinline)) +arg1_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg1; +} + +_Decimal64 __attribute__((noinline)) +arg2_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg2; +} + +_Decimal64 __attribute__((noinline)) +arg3_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg3; +} + +_Decimal64 __attribute__((noinline)) +arg4_64 (_Decimal64 arg0, _Decimal64 arg1, _Decimal64 arg2, + _Decimal64 arg3, _Decimal64 arg4, _Decimal64 arg5) +{ + return arg4; +} + +_Decimal64 __attribute__((noinline)) +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 __attribute__((noinline)) +arg0_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg0; +} + +_Decimal128 __attribute__((noinline)) +arg1_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg1; +} + +_Decimal128 __attribute__((noinline)) +arg2_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg2; +} + +_Decimal128 __attribute__((noinline)) +arg3_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg3; +} + +_Decimal128 __attribute__((noinline)) +arg4_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg4; +} + +_Decimal128 __attribute__((noinline)) +arg5_128 (_Decimal128 arg0, _Decimal128 arg1, _Decimal128 arg2, + _Decimal128 arg3, _Decimal128 arg4, _Decimal128 arg5) +{ + return arg5; +} + + + +_Decimal32 df0 = 0.0df, df1 = 1.0df, df2 = 2.0df, + df3 = 3.0df, df4 = 4.0df, df5 = 5.0df; +_Decimal32 *pdf0 = &df0, *pdf1 = &df1, *pdf2 = &df2, + *pdf3 = &df3, *pdf4 = &df4, *pdf5 = &df5; +_Decimal64 dd0 = 0.0dd, dd1 = 1.0dd, dd2 = 2.0dd, + dd3 = 3.0dd, dd4 = 4.0dd, dd5 = 5.0dd; +_Decimal64 *pdd0 = &dd0, *pdd1 = &dd1, *pdd2 = &dd2, + *pdd3 = &dd3, *pdd4 = &dd4, *pdd5 = &dd5; +_Decimal128 dl0 = 0.0dl, dl1 = 1.0dl, dl2 = 2.0dl, + dl3 = 3.0dl, dl4 = 4.0dl, dl5 = 5.0dl; +_Decimal128 *pdl0 = &dl0, *pdl1 = &dl1, *pdl2 = &dl2, + *pdl3 = &dl3, *pdl4 = &dl4, *pdl5 = &dl5; + +int +main () +{ + /* _Decimal32 variants. */ + if (arg0_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 0.0df) + FAILURE + if (arg1_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 1.0df) + FAILURE + if (arg2_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 2.0df) + FAILURE + if (arg3_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 3.0df) + FAILURE + if (arg4_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 4.0df) + FAILURE + if (arg5_32 (*pdf0, *pdf1, *pdf2, *pdf3, *pdf4, *pdf5) != 5.0df) + FAILURE + + /* _Decimal64 variants. */ + if (arg0_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 0.0dd) + FAILURE + if (arg1_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 1.0dd) + FAILURE + if (arg2_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 2.0dd) + FAILURE + if (arg3_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 3.0dd) + FAILURE + if (arg4_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 4.0dd) + FAILURE + if (arg5_64 (*pdd0, *pdd1, *pdd2, *pdd3, *pdd4, *pdd5) != 5.0dd) + FAILURE + + /* _Decimal128 variants. */ + if (arg0_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 0.0dl) + FAILURE + if (arg1_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 1.0dl) + FAILURE + if (arg2_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 2.0dl) + FAILURE + if (arg3_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 3.0dl) + FAILURE + if (arg4_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 4.0dl) + FAILURE + if (arg5_128 (*pdl0, *pdl1, *pdl2, *pdl3, *pdl4, *pdl5) != 5.0dl) + FAILURE + + FINISH +} Index: dfp/func-vararg-alternate-d32.c =================================================================== --- dfp/func-vararg-alternate-d32.c (nonexistent) +++ dfp/func-vararg-alternate-d32.c (revision 686) @@ -0,0 +1,19 @@ +/* Simple test of vararg passing for problematic types with and without + double values passed between them. */ + +#define DTYPE _Decimal32 +#define ONE 1.0df +#define THREE 3.0df +#define SEVEN 7.0df +#define ELEVEN 11.0df +#define INTS 1 + +#include "func-vararg-alternate.h" + +int +main () +{ + doit (); + + FINISH +} Index: dfp/func-vararg-mixed-2.c =================================================================== --- dfp/func-vararg-mixed-2.c (nonexistent) +++ dfp/func-vararg-mixed-2.c (revision 686) @@ -0,0 +1,105 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-mpreferred-stack-boundary=2" } */ + +/* C99 6.5.2.2 Function calls. + Test passing varargs of the combination of decimal float types and + other types. */ + +#include +#include "dfp-dbg.h" + +/* 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) FAILURE + if (vararg_d64 (4, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 4.0dd) FAILURE + if (vararg_d128 (1, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 1.0dl) FAILURE + if (vararg_int (0, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 0) FAILURE + if (vararg_double (2, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 2.0) FAILURE + + FINISH +} Index: dfp/operator-arith-fold.c =================================================================== --- dfp/operator-arith-fold.c (nonexistent) +++ dfp/operator-arith-fold.c (revision 686) @@ -0,0 +1,45 @@ +/* { dg-options "-O2" } */ + +/* C99 6.5.5: Multiplicative operators. + C99 6.5.6: Additive operators. */ + +#include "dfp-dbg.h" + +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; +} Index: dfp/pr33466.c =================================================================== --- dfp/pr33466.c (nonexistent) +++ dfp/pr33466.c (revision 686) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ + +/* The suffix for a decimal float constant must use a single case. + + These are invalid for all targets, not just those that support + decimal float. */ + +long double dF = 4.5dF; /* { dg-error "invalid suffix|literal operator" } */ +long double Df = 4.5Df; /* { dg-error "invalid suffix|literal operator" } */ +long double dD = 4.5dD; /* { dg-error "invalid suffix|literal operator" } */ +long double Dd = 4.5Dd; /* { dg-error "invalid suffix|literal operator" } */ +long double dL = 4.5dL; /* { dg-error "invalid suffix|literal operator" } */ +long double Dl = 4.5Dl; /* { dg-error "invalid suffix|literal operator" } */ Index: dfp/pr39902.c =================================================================== --- dfp/pr39902.c (nonexistent) +++ dfp/pr39902.c (revision 686) @@ -0,0 +1,226 @@ +/* Check that optimizations like (x * 1) to x, or (x * -1) to -x, + do not apply to decimal float computations where trailing zeroes + are significant. */ + +#include "dfp-dbg.h" + +#define COMPARE32(A,B) \ + A.i == B.i + +#define COMPARE64(A,B) \ + A.i[0] == B.i[0] && A.i[1] == B.i[1] + +#define COMPARE128(A,B) \ + A.i[0] == B.i[0] && A.i[1] == B.i[1] && A.i[2] == B.i[2] && A.i[3] == B.i[3] + +typedef union { + _Decimal32 d; + unsigned int i; +} u32; + +typedef union { + _Decimal64 d; + unsigned int i[2]; +} u64; + +typedef union { + _Decimal128 d; + unsigned int i[4]; +} u128; + +volatile u32 p32_1; +volatile u32 p32_1_0; +volatile u32 p32_2_0; +volatile u32 m32_1; +volatile u32 m32_1_0; +volatile u32 m32_2_0; +volatile u32 a32; + +volatile u64 p64_1; +volatile u64 p64_1_0; +volatile u64 p64_2_0; +volatile u64 m64_1; +volatile u64 m64_1_0; +volatile u64 m64_2_0; +volatile u64 a64; + +volatile u128 p128_1; +volatile u128 p128_1_0; +volatile u128 p128_2_0; +volatile u128 m128_1; +volatile u128 m128_1_0; +volatile u128 m128_2_0; +volatile u128 a128; + +void +init32 (void) +{ + p32_1.d = 1.DF; + p32_1_0.d = 1.0DF; + p32_2_0.d = 2.0DF; + m32_1.d = -1.DF; + m32_1_0.d = -1.0DF; + m32_2_0.d = -2.0DF; +} + +void +init64 (void) +{ + p64_1.d = 1.DD; + p64_1_0.d = 1.0DD; + p64_2_0.d = 2.0DD; + m64_1.d = -1.DD; + m64_1_0.d = -1.0DD; + m64_2_0.d = -2.0DD; +} + +void +init128 (void) +{ + p128_1.d = 1.DL; + p128_1_0.d = 1.0DL; + p128_2_0.d = 2.0DL; + m128_1.d = -1.DL; + m128_1_0.d = -1.0DL; + m128_2_0.d = -2.0DL; +} + +void +doit32 (void) +{ + /* Multiplying by a value with no trailing zero should not change the + quantum exponent. */ + + a32.d = p32_2_0.d * p32_1.d; + if (! (COMPARE32 (a32, p32_2_0))) + FAILURE + + a32.d = p32_2_0.d * 1.DF; + if (! (COMPARE32 (a32, p32_2_0))) + FAILURE + + a32.d = p32_2_0.d * m32_1.d; + if (! (COMPARE32 (a32, m32_2_0))) + FAILURE + + a32.d = p32_2_0.d * -1.DF; + if (! (COMPARE32 (a32, m32_2_0))) + FAILURE + + /* Multiplying by a value with a trailing zero should change the + quantum exponent. */ + + a32.d = p32_2_0.d * p32_1_0.d; + if (COMPARE32 (a32, p32_2_0)) + FAILURE + + a32.d = p32_2_0.d * 1.0DF; + if (COMPARE32 (a32, p32_2_0)) + FAILURE + + a32.d = p32_2_0.d * m32_1_0.d; + if (COMPARE32 (a32, m32_2_0)) + FAILURE + + a32.d = p32_2_0.d * -1.0DF; + if (COMPARE32 (a32, m32_2_0)) + FAILURE +} + +void +doit64 (void) +{ + /* Multiplying by a value with no trailing zero should not change the + quantum exponent. */ + + a64.d = p64_2_0.d * p64_1.d; + if (! (COMPARE64 (a64, p64_2_0))) + FAILURE + + a64.d = p64_2_0.d * 1.DD; + if (! (COMPARE64 (a64, p64_2_0))) + FAILURE + + a64.d = p64_2_0.d * m64_1.d; + if (! (COMPARE64 (a64, m64_2_0))) + FAILURE + + a64.d = p64_2_0.d * -1.DD; + if (! (COMPARE64 (a64, m64_2_0))) + FAILURE + + /* Multiplying by a value with a trailing zero should change the + quantum exponent. */ + + a64.d = p64_2_0.d * p64_1_0.d; + if (COMPARE64 (a64, p64_2_0)) + FAILURE + + a64.d = p64_2_0.d * 1.0DD; + if (COMPARE64 (a64, p64_2_0)) + FAILURE + + a64.d = p64_2_0.d * m64_1_0.d; + if (COMPARE64 (a64, m64_2_0)) + FAILURE + + a64.d = p64_2_0.d * -1.0DD; + if (COMPARE64 (a64, m64_2_0)) + FAILURE +} + +void +doit128 (void) +{ + /* Multiplying by a value with no trailing zero should not change the + quantum exponent. */ + + a128.d = p128_2_0.d * p128_1_0.d; + if (COMPARE128 (a128, p128_2_0)) + FAILURE + + a128.d = p128_2_0.d * 1.0DL; + if (COMPARE128 (a128, p128_2_0)) + FAILURE + + a128.d = p128_2_0.d * m128_1_0.d; + if (COMPARE128 (a128, m128_2_0)) + FAILURE + + a128.d = p128_2_0.d * -1.0DL; + if (COMPARE128 (a128, m128_2_0)) + FAILURE + + /* Multiplying by a value with a trailing zero should change the + quantum exponent. */ + + a128.d = p128_2_0.d * p128_1.d; + if (! (COMPARE128 (a128, p128_2_0))) + FAILURE + + a128.d = p128_2_0.d * 1.DL; + if (! (COMPARE128 (a128, p128_2_0))) + FAILURE + + a128.d = p128_2_0.d * m128_1.d; + if (! (COMPARE128 (a128, m128_2_0))) + FAILURE + + a128.d = p128_2_0.d * -1.DL; + if (! (COMPARE128 (a128, m128_2_0))) + FAILURE +} + +int +main (void) +{ + init32 (); + init64 (); + init128 (); + + doit32 (); + doit64 (); + doit128 (); + + FINISH +} Index: dfp/constants-zero.c =================================================================== --- dfp/constants-zero.c (nonexistent) +++ dfp/constants-zero.c (revision 686) @@ -0,0 +1,159 @@ +/* { dg-options "-O0" } */ + +/* Decimal float values can have significant trailing zeroes. This is + true for zero values as well. Check that various representations of + zero are handled correctly when specified as literal constants. */ + +#include "dfp-dbg.h" + +int big_endian; + +typedef union U32 { + unsigned int i; + _Decimal32 d; + unsigned char b[4]; +} u32_t; + +typedef union U64 { + unsigned long long i; + _Decimal64 d; +} u64_t; + +typedef union U128 { + unsigned long long i[2]; + _Decimal128 d; +} u128_t; + +int +compare32 (_Decimal32 d, unsigned int i) +{ + u32_t u; + + u.d = d; + return (u.i == i); +} + +int +compare64 (_Decimal64 d, unsigned long long i) +{ + u64_t u; + + u.d = d; + return (u.i == i); +} + +int +compare128 (_Decimal64 d, unsigned long long i, unsigned long long j) +{ + u128_t u; + + u.d = d; + if (big_endian) + return (u.i[0] == i && u.i[1] == j); + else + return (u.i[1] == i && u.i[0] == j); +} + +void +dpd_tests (void) +{ + if (! compare32 (0.DF, 0x22500000U)) + FAILURE + if (! compare32 (-0.DF, 0xa2500000U)) + FAILURE + if (! compare32 (0.E-4DF, 0x22100000U)) + FAILURE + if (! compare32 (0.E-7DF, 0x21e00000U)) + FAILURE + if (! compare32 (0.E+3DF, 0x22800000U)) + FAILURE + + if (! compare64 (0.DD, 0x2238000000000000ULL)) + FAILURE + if (! compare64 (-0.DD, 0xa238000000000000ULL)) + FAILURE + if (! compare64 (0.E-6DD, 0x2220000000000000ULL)) + FAILURE + if (! compare64 (0.E-7DD, 0x221c000000000000ULL)) + FAILURE + if (! compare64 (0.E+2DD, 0x2240000000000000ULL)) + FAILURE + + if (! compare128 (0.DL, 0x2208000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (-0.DL, 0xa208000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E-3DL, 0x2207400000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E-8DL, 0x2206000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E+2DL, 0x2208800000000000ULL, 0x0000000000000000ULL)) + FAILURE +} + +void +bid_tests (void) +{ + if (! compare32 (0.DF, 0x32800000U)) + FAILURE + if (! compare32 (-0.DF, 0xb2800000U)) + FAILURE + if (! compare32 (0.E-4DF, 0x30800000U)) + FAILURE + if (! compare32 (0.E-7DF, 0x2f000000U)) + FAILURE + if (! compare32 (0.E+3DF, 0x34000000U)) + FAILURE + + if (! compare64 (0.DD, 0x31c0000000000000ULL)) + FAILURE + if (! compare64 (-0.DD, 0xb1c0000000000000ULL)) + FAILURE + if (! compare64 (0.E-6DD, 0x3100000000000000ULL)) + FAILURE + if (! compare64 (0.E-7DD, 0x30e0000000000000ULL)) + FAILURE + if (! compare64 (0.E+2DD, 0x3200000000000000ULL)) + FAILURE + + if (! compare128 (0.DL, 0x3040000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (-0.DL, 0xb040000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E-3DL, 0x303a000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E-8DL, 0x3030000000000000ULL, 0x0000000000000000ULL)) + FAILURE + if (! compare128 (0.E+2DL, 0x3044000000000000ULL, 0x0000000000000000ULL)) + FAILURE +} + +int +main () +{ + u32_t u32; + + /* These sizes are probably always true for targets that support decimal + float types, but check anyway. Abort so we can fix the test. */ + if ((sizeof (_Decimal64) != sizeof (long long)) + || (sizeof (_Decimal128) != 2 * sizeof (long long)) + || (sizeof (_Decimal32) != sizeof (_Decimal32))) + FAILURE + + u32.d = 1.DF; + + if (u32.i == 0x22500001) + { + big_endian = (u32.b[0] == 0x22); + dpd_tests (); + } + else if (u32.i == 0x32800001) + { + big_endian = (u32.b[0] == 0x32); + bid_tests (); + } + else + FAILURE /* unknown format; test problem */ + + FINISH +} Index: dfp/struct-layout-1.c =================================================================== --- dfp/struct-layout-1.c (nonexistent) +++ dfp/struct-layout-1.c (revision 686) @@ -0,0 +1,71 @@ +#include +#include "dfp-dbg.h" + +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; +}; + +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; + + FINISH +} Index: dfp/compare-eq.h =================================================================== --- dfp/compare-eq.h (nonexistent) +++ dfp/compare-eq.h (revision 686) @@ -0,0 +1,92 @@ +/* Basic test of runtime equality comparisons using simple values that + are not affected by rounding. */ + +#include +#include "dfp-dbg.h" + +#define PASTE2(A,B) A ## B +#define PASTE(A,B) PASTE2(A,B) + +#undef FAILURE +#ifdef DBG +#define FAILURE(OP,KIND) \ + { printf ("failed at line %d: %s for %s values\n", __LINE__, OP, KIND); \ + failures++; } +#else +#define FAILURE(OP,KIND) __builtin_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") +} Index: dfp/convert-int-saturate.c =================================================================== --- dfp/convert-int-saturate.c (nonexistent) +++ dfp/convert-int-saturate.c (revision 686) @@ -0,0 +1,64 @@ +/* N1150 5.1 Conversion between decimal floating integer. + C99 6.3.1.4(1a) New. + Test integer saturation. */ + +#ifndef __STDC_WANT_DEC_FP__ +#define __STDC_WANT_DEC_FP__ 1 +#endif + +#include "dfp-dbg.h" +#include +#include + +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) + FAILURE + + usi = DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (usi != UINT_MAX) + FAILURE + + usi = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (usi != UINT_MAX) + FAILURE + + /* Signed. */ + si = DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MAX) + FAILURE + + si = DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MAX) + FAILURE + + si = DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MAX) + FAILURE + + si = - DEC32_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MIN) + FAILURE + + si = - DEC64_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MIN) + FAILURE + + si = - DEC128_MAX; /* { dg-warning "overflow in implicit constant conversion" } */ + if (si != INT_MIN) + FAILURE + + FINISH +} Index: dfp/compare-rel-d64.c =================================================================== --- dfp/compare-rel-d64.c (nonexistent) +++ dfp/compare-rel-d64.c (revision 686) @@ -0,0 +1,14 @@ +/* { dg-options "-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 (); + FINISH +} Index: dfp/convert-bfp-10.c =================================================================== --- dfp/convert-bfp-10.c (nonexistent) +++ dfp/convert-bfp-10.c (revision 686) @@ -0,0 +1,107 @@ +/* This test assumes IEEE float and double. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; + +/* Conversions using denormalized float values. */ +CONVERT_VALID (111, sf, sd, 1.2e-38f, 1.2e-38df, 0.df) +CONVERT_VALID (112, sf, sd, 1.1e-38f, 1.1e-38df, 0.df) +CONVERT_VALID (113, sf, sd, 1.1e-40f, 1.1e-40df, 1.1e-45df) + +CONVERT_VALID (121, sd, sf, 1.2e-38df, 1.2e-38f, 0.f) +CONVERT_VALID (122, sd, sf, 1.1e-38df, 1.1e-38f, 0.f) + +CONVERT_VALID (131, sf, sd, -1.2e-38f, -1.2e-38df, 0.df) +CONVERT_VALID (132, sf, sd, -1.1e-38f, -1.1e-38df, 0.df) + +CONVERT_VALID (141, sd, sf, -1.2e-38df, -1.2e-38f, 0.f) +CONVERT_VALID (142, sd, sf, -1.1e-38df, -1.1e-38f, 0.f) + +/* Conversions using denormalized double values. */ +CONVERT_VALID (211, df, sd, 1.2e-38, 1.2e-38df, 0.df) +CONVERT_VALID (212, df, sd, 1.1e-38, 1.1e-38df, 0.df) +CONVERT_VALID (213, df, sd, 1.e-40, 1.e-40df, 0.df) +CONVERT_VALID (214, df, sd, 8.e-44, 8.e-44df, 0.df) +CONVERT_VALID (215, df, sd, 9.e-44, 9.e-44df, 0.df) +CONVERT_VALID (216, df, sd, 8.e-46, 8.e-46df, 0.df) +CONVERT_VALID (217, df, sd, 7.e-46, 7.e-46df, 0.df) + +CONVERT_VALID (221, sd, df, 1.2e-38df, 1.2e-38, 1.e-53) +CONVERT_VALID (222, sd, df, 1.1e-38df, 1.1e-38, 1.e-53) +CONVERT_VALID (223, sd, df, 1.e-40df, 1.e-40, 0.) +CONVERT_VALID (224, sd, df, 8.e-44df, 8.e-44, 0.) +CONVERT_VALID (225, sd, df, 9.e-44df, 9.e-44, 0.) +CONVERT_VALID (226, sd, df, 8.e-46df, 8.e-46, 0.) +CONVERT_VALID (227, sd, df, 7.e-46df, 7.e-46, 0.) + +CONVERT_VALID (231, df, sd, -1.2e-38, -1.2e-38df, 0.df) +CONVERT_VALID (232, df, sd, -1.1e-38f, -1.1e-38df, 0.df) +CONVERT_VALID (233, df, sd, -1.e-40, -1.e-40df, 0.df) +CONVERT_VALID (234, df, sd, -8.e-44, -8.e-44df, 0.df) +CONVERT_VALID (235, df, sd, -9.e-44, -9.e-44df, 0.df) +CONVERT_VALID (236, df, sd, -8.e-46, -8.e-46df, 0.df) +CONVERT_VALID (237, df, sd, -7.e-46, -7.e-46df, 0.df) + +CONVERT_VALID (241, sd, df, -1.2e-38df, -1.2e-38, 1.e-53) +CONVERT_VALID (242, sd, df, -1.1e-38df, -1.1e-38, 1.e-53) +CONVERT_VALID (243, sd, df, -1.e-40df, -1.e-40, 0.) +CONVERT_VALID (244, sd, df, -8.e-44df, -8.e-44, 0.) +CONVERT_VALID (245, sd, df, -9.e-44df, -9.e-44, 0.) +CONVERT_VALID (246, sd, df, -8.e-46df, -8.e-46, 0.) +CONVERT_VALID (247, sd, df, -7.e-46df, -7.e-46, 0.) + +int +main () +{ + convert_111 (); + convert_112 (); + convert_113 (); + + convert_121 (); + convert_122 (); + + convert_131 (); + convert_132 (); + + convert_141 (); + convert_142 (); + + convert_211 (); + convert_212 (); + convert_213 (); + convert_214 (); + convert_215 (); + convert_216 (); + convert_217 (); + + convert_221 (); + convert_222 (); + convert_223 (); + convert_224 (); + convert_225 (); + convert_226 (); + convert_227 (); + + convert_231 (); + convert_232 (); + convert_233 (); + convert_234 (); + convert_235 (); + convert_236 (); + convert_237 (); + + convert_241 (); + convert_242 (); + convert_243 (); + convert_244 (); + convert_245 (); + convert_246 (); + convert_247 (); + + FINISH +} Index: dfp/func-vararg-alternate-d128-2.c =================================================================== --- dfp/func-vararg-alternate-d128-2.c (nonexistent) +++ dfp/func-vararg-alternate-d128-2.c (revision 686) @@ -0,0 +1,22 @@ +/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ +/* { dg-options "-mpreferred-stack-boundary=2" } */ + +/* Simple test of vararg passing for problematic types with and without + double values passed between them. */ + +#define DTYPE _Decimal128 +#define ONE 1.0dl +#define THREE 3.0dl +#define SEVEN 7.0dl +#define ELEVEN 11.0dl +#define INTS 4 + +#include "func-vararg-alternate.h" + +int +main () +{ + doit (); + + FINISH +} Index: dfp/func-vararg-size0.c =================================================================== --- dfp/func-vararg-size0.c (nonexistent) +++ dfp/func-vararg-size0.c (revision 686) @@ -0,0 +1,41 @@ +/* C99 6.5.2.2 Function calls. */ + +#include +#include "dfp-dbg.h" + +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) + FAILURE + + FINISH +} Index: dfp/pr39986.c =================================================================== --- dfp/pr39986.c (nonexistent) +++ dfp/pr39986.c (revision 686) @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +#include "dfp-dbg.h" + +/* Check that the compiler generates the correct decimal float constants. */ + +_Decimal32 a = 100.223df; +_Decimal32 b = -2.3df; +_Decimal64 c = 3.4e-4dd; +_Decimal64 d = -4.500dd; +_Decimal128 e = 5678901234567.89e+200dl; +_Decimal128 f = -678901.234e-6dl; + +/* The first value is DPD, the second is BID. The order differs depending + on whether the target is big-endian or little-endian. */ + +/* { dg-final { scan-assembler ".long\t(572653859|822183807)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(-1572863965|-1308622825)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(52|34)\n" } } */ +/* { dg-final { scan-assembler ".long\t(572784640|824180736)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(4736|4500)\n" } } */ +/* { dg-final { scan-assembler ".long\t(-1574174720|-1319108608)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(-1975952433|957645077)\n" } } */ +/* { dg-final { scan-assembler ".long\t(190215|132222)\n" } } */ +/* { dg-final { scan-assembler ".long\t(574193664|835452928)\n" } } */ + +/* { dg-final { scan-assembler ".long\t(931280180|678901234)\n" } } */ +/* { dg-final { scan-assembler ".long\t(-1576681472|-1339162624)\n" } } */ Index: dfp/func-vararg-alternate-d128.c =================================================================== --- dfp/func-vararg-alternate-d128.c (nonexistent) +++ dfp/func-vararg-alternate-d128.c (revision 686) @@ -0,0 +1,19 @@ +/* Simple test of vararg passing for problematic types with and without + double values passed between them. */ + +#define DTYPE _Decimal128 +#define ONE 1.0dl +#define THREE 3.0dl +#define SEVEN 7.0dl +#define ELEVEN 11.0dl +#define INTS 4 + +#include "func-vararg-alternate.h" + +int +main () +{ + doit (); + + FINISH +} Index: dfp/convert-bfp-12.c =================================================================== --- dfp/convert-bfp-12.c (nonexistent) +++ dfp/convert-bfp-12.c (revision 686) @@ -0,0 +1,16 @@ +/* Test for bug where fold wrongly removed conversions to double and + replaced them by conversions to float. */ + +#include "dfp-dbg.h" + +volatile float f = __builtin_inff (); +volatile _Decimal32 d32 = 1e40DF; + +int +main (void) +{ + if ((double) f == (double) d32) + FAILURE + + FINISH +} Index: dfp/convert-bfp-14.c =================================================================== --- dfp/convert-bfp-14.c (nonexistent) +++ dfp/convert-bfp-14.c (revision 686) @@ -0,0 +1,15 @@ +/* Test for bug where fold narrowed decimal floating-point + operations. */ + +#include "dfp-dbg.h" + +volatile _Decimal32 f = 1.23456DF; +volatile _Decimal64 d = 1.23456DD; + +int +main (void) +{ + if ((double)((_Decimal64)f * (_Decimal64)f) != (double)(d * d)) + FAILURE + FINISH +} Index: dfp/nan-2.c =================================================================== --- dfp/nan-2.c (nonexistent) +++ dfp/nan-2.c (revision 686) @@ -0,0 +1,53 @@ +/* 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. */ + +#include "dfp-dbg.h" + +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()) + FAILURE + if (123.45df/-0.0df != -__builtin_infd32()) + FAILURE + + d64 = 123.45f; + if (d64/-0.0dd != -__builtin_infd64()) + FAILURE + if (123.45dd/-0.0dd != -__builtin_infd64()) + FAILURE + + d128 = 123.45f; + if (d128/-0.0dl != -__builtin_infd64()) + FAILURE + if (123.45dl/-0.0dl != -__builtin_infd128()) + FAILURE + + d32 = 0.0df; + if (!__builtin_isnand32(-(d32/-0.0df))) + FAILURE + if (!__builtin_isnand32(-(0.0df/-0.0df))) + FAILURE + + d64 = 0.0dd; + if (!__builtin_isnand64(-(d64/-0.0dd))) + FAILURE + if (!__builtin_isnand64(-(0.0dd/-0.0dd))) + FAILURE + + d128 = 0.0dl; + if (!__builtin_isnand128(-(d128/-0.0dl))) + FAILURE + if (!__builtin_isnand128(-(0.0dl/-0.0dl))) + FAILURE + + FINISH +} Index: dfp/operator-cond.c =================================================================== --- dfp/operator-cond.c (nonexistent) +++ dfp/operator-cond.c (revision 686) @@ -0,0 +1,57 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.15 Conditional operator. + Test with decimal float operands. */ + +#include "dfp-dbg.h" + +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 () +{ + init (); + + /* 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 != d64c) + 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 + + FINISH +} Index: dfp/pr36800.c =================================================================== --- dfp/pr36800.c (nonexistent) +++ dfp/pr36800.c (revision 686) @@ -0,0 +1,32 @@ +/* { dg-do run } */ + +#include +#include "dfp-dbg.h" + +void +f (int a, ...) +{ + va_list ap; + if (a != 0) + FAILURE + va_start (ap, a); + if (va_arg (ap, _Decimal128) != 1.2DL) + FAILURE + if (va_arg (ap, _Decimal128) != 2.34DL) + FAILURE + if (va_arg (ap, _Decimal128) != 3.456DL) + FAILURE + if (va_arg (ap, _Decimal128) != 4.567DL) + FAILURE + if (va_arg (ap, double) != 5.125) + FAILURE + va_end (ap); +} + +int +main (void) +{ + f (0, 1.2DL, 2.34DL, 3.456DL, 4.567DL, 5.125); + + FINISH +} Index: dfp/func-vararg-dfp.c =================================================================== --- dfp/func-vararg-dfp.c (nonexistent) +++ dfp/func-vararg-dfp.c (revision 686) @@ -0,0 +1,95 @@ +/* C99 6.5.2.2 Function calls. + Test passing varargs of the decimal float types. */ + +#include +#include "dfp-dbg.h" + +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) + FAILURE + if (vararg32 (1, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 1.0df) + FAILURE + if (vararg32 (2, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 2.0df) + FAILURE + if (vararg32 (3, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 3.0df) + FAILURE + if (vararg32 (4, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 4.0df) + FAILURE + if (vararg32 (5, 0.0df, 1.0df, 2.0df, 3.0df, 4.0df, 5.0df) != 5.0df) + FAILURE + + /* _Decimal64 variants. */ + if (vararg64 (0, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 0.0dd) + FAILURE + if (vararg64 (1, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 1.0dd) + FAILURE + if (vararg64 (2, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 2.0dd) + FAILURE + if (vararg64 (3, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 3.0dd) + FAILURE + if (vararg64 (4, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 4.0dd) + FAILURE + if (vararg64 (5, 0.0dd, 1.0dd, 2.0dd, 3.0dd, 4.0dd, 5.0dd) != 5.0dd) + FAILURE + + /* _Decimal128 variants. */ + if (vararg128 (0, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 0.0dl) + FAILURE + if (vararg128 (1, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 1.0dl) + FAILURE + if (vararg128 (2, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 2.0dl) + FAILURE + if (vararg128 (3, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 3.0dl) + FAILURE + if (vararg128 (4, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 4.0dl) + FAILURE + if (vararg128 (5, 0.0dl, 1.0dl, 2.0dl, 3.0dl, 4.0dl, 5.0dl) != 5.0dl) + FAILURE + + FINISH +} Index: dfp/func-vararg-alternate-d64.c =================================================================== --- dfp/func-vararg-alternate-d64.c (nonexistent) +++ dfp/func-vararg-alternate-d64.c (revision 686) @@ -0,0 +1,19 @@ +/* Simple test of vararg passing for problematic types with and without + double values passed between them. */ + +#define DTYPE _Decimal64 +#define ONE 1.0dd +#define THREE 3.0dd +#define SEVEN 7.0dd +#define ELEVEN 11.0dd +#define INTS 2 + +#include "func-vararg-alternate.h" + +int +main () +{ + doit (); + + FINISH +} Index: dfp/pr39034.c =================================================================== --- dfp/pr39034.c (nonexistent) +++ dfp/pr39034.c (revision 686) @@ -0,0 +1,100 @@ +/* { dg-do run } */ +/* { dg-options "-O" } */ + +/* DFP TR 24732 == WG14 / N1176, N1312 */ +/* Based on a test from Fred Tydeman. */ + +#include "dfp-dbg.h" + +/* Test runtime computations. */ + +void +runtime32 (void) +{ + volatile float v1 = 28.f, v2 = 3.f, v3 = 9.f, v4 = 31.f, v5 = 3.f, v6 = 10.f; + float b32 = (float)((v1/v2-v3) - (v4/v5-v6)); + _Decimal32 d32 = (float)((v1/v2-v3) - (v4/v5-v6)); + + if (b32) + FAILURE + if (d32) + FAILURE +} + +void +runtime64 (void) +{ + volatile double v1 = 28., v2 = 3., v3 = 9., v4 = 31., v5 = 3., v6 = 10.; + double b64 = (double)((v1/v2-v3) - (v4/v5-v6)); + _Decimal64 d64 = (double)((v1/v2-v3) - (v4/v5-v6)); + + if (b64) + FAILURE + if (d64) + FAILURE +} + +void +runtime128 (void) +{ + volatile long double v1 = 28.l, v2 = 3.l, v3 = 9.l, + v4 = 31.l, v5 = 3.l, v6 = 10.l; + long double b128 = (long double)((v1/v2-v3) - (v4/v5-v6)); + _Decimal128 d128 = (long double)((v1/v2-v3) - (v4/v5-v6)); + + if (b128) + FAILURE + if (d128) + FAILURE +} + +/* Test constant folding. */ + +void +fold32 (void) +{ + double d32 = (float)((28.f/3.f-9.f) - (31.f/3.f-10.f)); + _Decimal32 b32 = (float)((28.f/3.f-9.f) - (31.f/3.f-10.f)); + + if (b32) + FAILURE + if (d32) + FAILURE +} + +void +fold64 (void) +{ + double b64 = (double)((28./3.-9.) - (31./3.-10.)); + _Decimal64 d64 = (double)((28./3.-9.) - (31./3.-10.)); + + if (b64) + FAILURE + if (d64) + FAILURE +} + +void +fold128 (void) +{ + long double b128 = (long double)((28./3.-9.) - (31./3.-10.)); + _Decimal128 d128 = (long double)((28./3.-9.) - (31./3.-10.)); + + if (b128) + FAILURE + if (d128) + FAILURE +} + +int +main () +{ + runtime32 (); + runtime64 (); + runtime128 (); + fold32 (); + fold64 (); + fold128 (); + + FINISH +} Index: dfp/convert-bfp-2.c =================================================================== --- dfp/convert-bfp-2.c (nonexistent) +++ dfp/convert-bfp-2.c (revision 686) @@ -0,0 +1,33 @@ +/* This test assumes IEEE float and double. It also tests long double + but makes no assumption about its size or range of values. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; /* might actually be df or xf, doesn't matter */ + +CONVERT_VALID_ALL (t1, 0.0, 0.) +CONVERT_VALID_ALL (t2, 1.0, 0.) +CONVERT_VALID_ALL (t3, -11.5, 0.) +CONVERT_VALID_ALL (t4, 7.0, 0.1e-14) +CONVERT_VALID_ALL (t5, -7.0, 0.1e-14) +CONVERT_VALID_ALL (t6, 999999., 0.) +CONVERT_VALID_ALL (t7, -999999., 0.) + +int +main () +{ + CALL_VALID_ALL (t1) + CALL_VALID_ALL (t2) + CALL_VALID_ALL (t3) + CALL_VALID_ALL (t4) + CALL_VALID_ALL (t5) + CALL_VALID_ALL (t6) + CALL_VALID_ALL (t7) + + FINISH +} Index: dfp/convert.h =================================================================== --- dfp/convert.h (nonexistent) +++ dfp/convert.h (revision 686) @@ -0,0 +1,462 @@ +#include "dfp-dbg.h" + +/* Macros are set up to skip using long double, which doesn't necessarily + map to TF mode. If there's a reason to skip those for a test, the + test itself can define USE_TF to be zero. */ +#ifndef USE_TF +#define USE_TF 1 +#endif + +/* Provide more information with FAILURE than what is available with + the version of that macro in dfp-dbg.h. */ + +#undef FAILURE +#if defined(DBG) || defined(DBG2) +#include +#define FAILURE(NUM) \ + { printf ("failed for test %s\n", NUM); failures++; } +#else +#define FAILURE(N) __builtin_abort (); +#endif + +/* This is useful when modifying the test to make sure that tests are + actually run. */ +#if defined(DBG2) +#define REPORT(NUM) \ + { printf ("%s\n", NUM); } +#else +#define REPORT(N) ; +#endif + +#define CONVERT_VALID(NUM,FROM,TO,FROMVAL,TOVAL,DIFF) \ +void \ +convert_##NUM (void) \ +{ \ + REPORT(#NUM " " #FROMVAL) \ + FROM = FROMVAL; \ + TO = FROM; \ + if (TO < (TOVAL - DIFF) || TO > (TOVAL + DIFF)) \ + FAILURE (#NUM); \ +} + +#define CONVERT_TO_PINF(NUM,FROM,TO,FROMVAL,TOSUFFIX) \ +void \ +convert_##NUM (void) \ +{ \ + REPORT(#NUM " " #FROMVAL) \ + FROM = FROMVAL; \ + TO = FROM; \ + if (__builtin_isinf##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " pinf: isinf"); \ + if (__builtin_signbit##TOSUFFIX (TO) != 0) \ + FAILURE (#NUM " pinf: sign"); \ +} + +#define CONVERT_TO_MINF(NUM,FROM,TO,FROMVAL,TOSUFFIX) \ +void \ +convert_##NUM (void) \ +{ \ + REPORT(#NUM " " #FROMVAL) \ + FROM = FROMVAL; \ + TO = FROM; \ + if (__builtin_isinf##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " pinf: isinf"); \ + if (__builtin_signbit##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " pinf: sign"); \ +} + +#define CONVERT_TO_PZERO(NUM,FROM,TO,FROMVAL,TOVAL,TOSUFFIX) \ +void \ +convert_##NUM (void) \ +{ \ + REPORT(#NUM " " #FROMVAL) \ + FROM = FROMVAL; \ + TO = FROM; \ + if (TO != TOVAL) \ + FAILURE (#NUM "_pzero: zero") \ + if (__builtin_signbit##TOSUFFIX (TO) != 0) \ + FAILURE (#NUM " _pzero: sign"); \ +} + +#define CONVERT_TO_MZERO(NUM,FROM,TO,FROMVAL,TOVAL,TOSUFFIX) \ +void \ +convert_##NUM (void) \ +{ \ + REPORT(#NUM " " #FROMVAL) \ + FROM = FROMVAL; \ + TO = FROM; \ + if (TO != TOVAL) \ + FAILURE (#NUM "_mzero: zero") \ + if (__builtin_signbit##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " _mzero: sign"); \ +} + +#define CONVERT_NAN(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ +void \ +convert_##NUM##_nan (void) \ +{ \ + REPORT(#NUM "_nan") \ + FROM = __builtin_nan##FROMSUFFIX (""); \ + TO = FROM; \ + if (__builtin_isnan##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " nan"); \ +} + +#define CONVERT_PINF(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ +void \ +convert_##NUM##_pinf (void) \ +{ \ + REPORT (#NUM "_pinf") \ + FROM = __builtin_inf##FROMSUFFIX (); \ + TO = FROM; \ + if (__builtin_isinf##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " pinf: isinf"); \ + if (__builtin_signbit##TOSUFFIX (TO) != 0) \ + FAILURE (#NUM " pinf: sign"); \ +} + +#define CONVERT_MINF(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ +void \ +convert_##NUM##_minf (void) \ +{ \ + REPORT (#NUM "_minf") \ + FROM = -__builtin_inf##FROMSUFFIX (); \ + TO = FROM; \ + if (__builtin_isinf##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " minf: isinf"); \ + if (__builtin_signbit##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " minf: sign"); \ +} + +#define CONVERT_PZERO(NUM,FROM,TO,FROMVALUE,TOVALUE,TOSUFFIX) \ +void \ +convert_##NUM##_pzero (void) \ +{ \ + REPORT (#NUM "_pzero") \ + FROM = FROMVALUE; \ + TO = FROM; \ + if (TO != TOVALUE) \ + FAILURE (#NUM "pzero: zero") \ + if (__builtin_signbit##TOSUFFIX (TO) != 0) \ + FAILURE (#NUM " pzero: sign"); \ +} + +#define CONVERT_MZERO(NUM,FROM,TO,FROMVALUE,TOVALUE,TOSUFFIX) \ +void \ +convert_##NUM##_mzero (void) \ +{ \ + REPORT (#NUM "_mzero") \ + FROM = FROMVALUE; \ + TO = FROM; \ + if (TO != TOVALUE) \ + FAILURE (#NUM "mzero: zero") \ + if (__builtin_signbit##TOSUFFIX (TO) == 0) \ + FAILURE (#NUM " mzero: sign"); \ +} + +#define CONVERT_VALID_NOTF(NUM,VAL,DIFF) \ +CONVERT_VALID (NUM##_sdsf, sd, sf, VAL##df, VAL##f, DIFF##f) \ +CONVERT_VALID (NUM##_sddf, sd, df, VAL##df, VAL, DIFF) \ +CONVERT_VALID (NUM##_ddsf, dd, sf, VAL##dd, VAL##f, DIFF##f) \ +CONVERT_VALID (NUM##_dddf, dd, df, VAL##dd, VAL, DIFF) \ +CONVERT_VALID (NUM##_tdsf, td, sf, VAL##dl, VAL##f, DIFF##f) \ +CONVERT_VALID (NUM##_tddf, td, df, VAL##dl, VAL, DIFF) \ +CONVERT_VALID (NUM##_sfsd, sf, sd, VAL##f, VAL##df, DIFF##df) \ +CONVERT_VALID (NUM##_sfdd, sf, dd, VAL##f, VAL##dd, DIFF##dd) \ +CONVERT_VALID (NUM##_sftd, sf, td, VAL##f, VAL##dl, DIFF##dl) \ +CONVERT_VALID (NUM##_dfsd, df, sd, VAL, VAL##df, DIFF##df) \ +CONVERT_VALID (NUM##_dfdd, df, dd, VAL, VAL##dd, DIFF##dd) \ +CONVERT_VALID (NUM##_dftd, df, td, VAL, VAL##dl, DIFF##dl) \ +CONVERT_VALID (NUM##_sddd, sd, dd, VAL##df, VAL##dd, DIFF##dd) \ +CONVERT_VALID (NUM##_sdtd, sd, dd, VAL##df, VAL##dd, DIFF##dd) \ +CONVERT_VALID (NUM##_ddsd, dd, sd, VAL##dd, VAL##df, DIFF##dd) \ +CONVERT_VALID (NUM##_ddtd, dd, td, VAL##dd, VAL##dl, DIFF##dl) \ +CONVERT_VALID (NUM##_tdsd, td, sd, VAL##dl, VAL##df, DIFF##df) \ +CONVERT_VALID (NUM##_tddd, td, dd, VAL##dl, VAL##dd, DIFF##dd) + +#if USE_TF == 0 +#define CONVERT_VALID_TF(NUM,VAL,DIFF) +#else +#define CONVERT_VALID_TF(NUM,VAL,DIFF) \ +CONVERT_VALID (NUM##_sdtf, sd, tf, VAL##df, VAL##l, DIFF##l) \ +CONVERT_VALID (NUM##_tdtf, td, tf, VAL##dl, VAL##l, DIFF##l) \ +CONVERT_VALID (NUM##_ddtf, dd, tf, VAL##dd, VAL##l, DIFF##l) \ +CONVERT_VALID (NUM##_tfsd, tf, sd, VAL##l, VAL##df, DIFF##df) \ +CONVERT_VALID (NUM##_tfdd, tf, dd, VAL##l, VAL##dd, DIFF##dd) \ +CONVERT_VALID (NUM##_tftd, tf, td, VAL##l, VAL##dl, DIFF##dl) +#endif + +#define CONVERT_VALID_ALL(NUM,VAL,DIFF) \ + CONVERT_VALID_NOTF(NUM,VAL,DIFF) \ + CONVERT_VALID_TF(NUM,VAL,DIFF) + +#define CALL_VALID_NOTF(NUM) \ + convert_##NUM##_sdsf (); \ + convert_##NUM##_sddf (); \ + convert_##NUM##_ddsf (); \ + convert_##NUM##_dddf (); \ + convert_##NUM##_tdsf (); \ + convert_##NUM##_tddf (); \ + convert_##NUM##_sfsd (); \ + convert_##NUM##_sfdd (); \ + convert_##NUM##_sftd (); \ + convert_##NUM##_dfsd (); \ + convert_##NUM##_dfdd (); \ + convert_##NUM##_dftd (); \ + convert_##NUM##_sddd (); \ + convert_##NUM##_sdtd (); \ + convert_##NUM##_ddsd (); \ + convert_##NUM##_ddtd (); \ + convert_##NUM##_tdsd (); \ + convert_##NUM##_tddd (); + +#if USE_TF == 0 +#define CALL_VALID_TF(NUM) +#else +#define CALL_VALID_TF(NUM) \ + convert_##NUM##_sdtf (); \ + convert_##NUM##_ddtf (); \ + convert_##NUM##_tdtf (); \ + convert_##NUM##_tfsd (); \ + convert_##NUM##_tfdd (); \ + convert_##NUM##_tftd (); +#endif + +#define CALL_VALID_ALL(NUM) \ + CALL_VALID_NOTF(NUM) \ + CALL_VALID_TF(NUM) + +#define CONVERT_ZEROES(NUM,FROM,TO,FROMVALUE,TOVALUE,TOSUFFIX) \ +CONVERT_PZERO(NUM, FROM, TO, FROMVALUE, TOVALUE, TOSUFFIX) \ +CONVERT_MZERO(NUM, FROM, TO, -FROMVALUE, -TOVALUE, TOSUFFIX) + +#define CONVERT_ZEROES_NOTF(NUM) \ +CONVERT_ZEROES (NUM##_sdsf, sd, sf, 0.0df, 0.0f, f) \ +CONVERT_ZEROES (NUM##_sddf, sd, df, 0.0df, 0.0, ) \ +CONVERT_ZEROES (NUM##_ddsf, dd, sf, 0.0dd, 0.0f, f) \ +CONVERT_ZEROES (NUM##_dddf, dd, df, 0.0dd, 0.0, ) \ +CONVERT_ZEROES (NUM##_tdsf, td, sf, 0.0dl, 0.0f, f) \ +CONVERT_ZEROES (NUM##_tddf, td, df, 0.0dl, 0.0, ) \ +CONVERT_ZEROES (NUM##_sfsd, sf, sd, 0.0f, 0.0df, d32) \ +CONVERT_ZEROES (NUM##_sfdd, sf, dd, 0.0f, 0.0dd, d64) \ +CONVERT_ZEROES (NUM##_sftd, sf, td, 0.0f, 0.0dl, d128) \ +CONVERT_ZEROES (NUM##_dfsd, df, sd, 0.0, 0.0df, d32) \ +CONVERT_ZEROES (NUM##_dfdd, df, dd, 0.0, 0.0dd, d64) \ +CONVERT_ZEROES (NUM##_dftd, df, td, 0.0, 0.0dl, d128) \ +CONVERT_ZEROES (NUM##_sddd, sd, dd, 0.0df, 0.0dd, d64) \ +CONVERT_ZEROES (NUM##_sdtd, sd, td, 0.0dl, 0.0dl, d128) \ +CONVERT_ZEROES (NUM##_ddsd, dd, sd, 0.0dd, 0.0df, d32) \ +CONVERT_ZEROES (NUM##_ddtd, dd, td, 0.0dd, 0.0dl, d128) \ +CONVERT_ZEROES (NUM##_tdsd, td, sd, 0.0dl, 0.0df, d32) \ +CONVERT_ZEROES (NUM##_tddd, td, dd, 0.0dl, 0.0dd, d64) + +#if USE_TF == 0 +#define CONVERT_ZEROES_TF(NUM) +#else +#define CONVERT_ZEROES_TF(NUM) \ +CONVERT_ZEROES (NUM##_sdtf, sd, tf, 0.0df, 0.0l, l) \ +CONVERT_ZEROES (NUM##_ddtf, dd, tf, 0.0dd, 0.0l, l) \ +CONVERT_ZEROES (NUM##_tdtf, td, tf, 0.0dl, 0.0l, l) \ +CONVERT_ZEROES (NUM##_tfsd, tf, sd, 0.0l, 0.0df, d32) \ +CONVERT_ZEROES (NUM##_tfdd, tf, dd, 0.0l, 0.0dd, d64) \ +CONVERT_ZEROES (NUM##_tftd, tf, td, 0.0l, 0.0dl, d128) +#endif + +#define CONVERT_ZEROES_ALL(NUM) \ + CONVERT_ZEROES_NOTF(NUM) \ + CONVERT_ZEROES_TF(NUM) + +#define CALL_ZEROES(NUM) \ + convert_##NUM##_pzero (); \ + convert_##NUM##_mzero (); + +#define CALL_ZEROES_NOTF(NUM) \ + CALL_ZEROES (NUM##_sdsf) \ + CALL_ZEROES (NUM##_sddf) \ + CALL_ZEROES (NUM##_ddsf) \ + CALL_ZEROES (NUM##_dddf) \ + CALL_ZEROES (NUM##_tdsf) \ + CALL_ZEROES (NUM##_tddf) \ + CALL_ZEROES (NUM##_sfsd) \ + CALL_ZEROES (NUM##_sfdd) \ + CALL_ZEROES (NUM##_sftd) \ + CALL_ZEROES (NUM##_dfsd) \ + CALL_ZEROES (NUM##_dfdd) \ + CALL_ZEROES (NUM##_dftd) \ + CALL_ZEROES (NUM##_sddd) \ + CALL_ZEROES (NUM##_sdtd) \ + CALL_ZEROES (NUM##_ddsd) \ + CALL_ZEROES (NUM##_ddtd) \ + CALL_ZEROES (NUM##_tdsd) \ + CALL_ZEROES (NUM##_tddd) + +#if USE_TF == 0 +#define CALL_ZEROES_TF(NUM) +#else +#define CALL_ZEROES_TF(NUM) \ + CALL_ZEROES (NUM##_sdtf) \ + CALL_ZEROES (NUM##_ddtf) \ + CALL_ZEROES (NUM##_tdtf) \ + CALL_ZEROES (NUM##_tfsd) \ + CALL_ZEROES (NUM##_tfdd) \ + CALL_ZEROES (NUM##_tftd) +#endif + +#define CALL_ZEROES_ALL(NUM) \ + CALL_ZEROES_NOTF(NUM) \ + CALL_ZEROES_TF(NUM) + +#define CONVERT_INF(NUM,FROM,TO,FROMSUFFIX,TOSUFFIX) \ +CONVERT_PINF (NUM, FROM, TO, FROMSUFFIX, TOSUFFIX) \ +CONVERT_MINF (NUM, FROM, TO, FROMSUFFIX, TOSUFFIX) + +#define CONVERT_INF_NOTF(NUM) \ +CONVERT_INF (NUM##_sdsf, sd, sf, d32, f) \ +CONVERT_INF (NUM##_sddf, sd, df, d32, ) \ +CONVERT_INF (NUM##_ddsf, dd, sf, d64, f) \ +CONVERT_INF (NUM##_dddf, dd, df, d64, ) \ +CONVERT_INF (NUM##_tdsf, td, sf, d128, f) \ +CONVERT_INF (NUM##_tddf, td, df, d128, ) \ +CONVERT_INF (NUM##_sfsd, sf, sd, f, d32) \ +CONVERT_INF (NUM##_sfdd, sf, dd, f, d64) \ +CONVERT_INF (NUM##_sftd, sf, td, f, d128) \ +CONVERT_INF (NUM##_dfsd, df, sd, , d32) \ +CONVERT_INF (NUM##_dfdd, df, dd, , d64) \ +CONVERT_INF (NUM##_dftd, df, td, , d128) \ +CONVERT_INF (NUM##_sddd, sd, dd, d32, d64) \ +CONVERT_INF (NUM##_sdtd, sd, td, d32, d128) \ +CONVERT_INF (NUM##_ddsd, dd, sd, d64, d32) \ +CONVERT_INF (NUM##_ddtd, dd, td, d64, d128) \ +CONVERT_INF (NUM##_tdsd, td, sd, d128, d32) \ +CONVERT_INF (NUM##_tddd, td, dd, d128, d64) + +#if USE_TF == 0 +#define CONVERT_INF_TF(NUM) +#else +#define CONVERT_INF_TF(NUM) \ +CONVERT_INF (NUM##_sdtf, sd, tf, d32, l) \ +CONVERT_INF (NUM##_ddtf, dd, tf, d64, l) \ +CONVERT_INF (NUM##_tdtf, td, tf, d128, l) \ +CONVERT_INF (NUM##_tfsd, tf, sd, l, d32) \ +CONVERT_INF (NUM##_tfdd, tf, dd, l, d64) \ +CONVERT_INF (NUM##_tftd, tf, td, l, d128) +#endif + +#define CONVERT_INF_ALL(NUM) \ + CONVERT_INF_NOTF(NUM) \ + CONVERT_INF_TF(NUM) + +#define CALL_INF(NUM) \ + convert_##NUM##_pinf (); \ + convert_##NUM##_minf (); + +#define CALL_INF_NOTF(NUM) \ + CALL_INF (NUM##_sdsf) \ + CALL_INF (NUM##_sddf) \ + CALL_INF (NUM##_ddsf) \ + CALL_INF (NUM##_dddf) \ + CALL_INF (NUM##_tdsf) \ + CALL_INF (NUM##_tddf) \ + CALL_INF (NUM##_sfsd) \ + CALL_INF (NUM##_sfdd) \ + CALL_INF (NUM##_sftd) \ + CALL_INF (NUM##_dfsd) \ + CALL_INF (NUM##_dfdd) \ + CALL_INF (NUM##_dftd) \ + CALL_INF (NUM##_sddd) \ + CALL_INF (NUM##_sdtd) \ + CALL_INF (NUM##_ddsd) \ + CALL_INF (NUM##_ddtd) \ + CALL_INF (NUM##_tdsd) \ + CALL_INF (NUM##_tddd) + +#if USE_TF == 0 +#define CALL_INF_TF(NUM) +#else +#define CALL_INF_TF(NUM) \ + CALL_INF (NUM##_sdtf) \ + CALL_INF (NUM##_ddtf) \ + CALL_INF (NUM##_tdtf) \ + CALL_INF (NUM##_tfsd) \ + CALL_INF (NUM##_tfdd) \ + CALL_INF (NUM##_tftd) +#endif + +#define CALL_INF_ALL(NUM) \ + CALL_INF_NOTF(NUM) \ + CALL_INF_TF(NUM) + +#define CONVERT_NAN_NOTF(NUM) \ +CONVERT_NAN (NUM##_sdsf, sd, sf, d32, f) \ +CONVERT_NAN (NUM##_sddf, sd, df, d32, ) \ +CONVERT_NAN (NUM##_ddsf, dd, sf, d64, f) \ +CONVERT_NAN (NUM##_dddf, dd, df, d64, ) \ +CONVERT_NAN (NUM##_tdsf, td, sf, d128, f) \ +CONVERT_NAN (NUM##_tddf, td, df, d128, ) \ +CONVERT_NAN (NUM##_sfsd, sf, sd, f, d32) \ +CONVERT_NAN (NUM##_sfdd, sf, dd, f, d64) \ +CONVERT_NAN (NUM##_sftd, sf, td, f, d128) \ +CONVERT_NAN (NUM##_dfsd, df, sd, , d32) \ +CONVERT_NAN (NUM##_dfdd, df, dd, , d64) \ +CONVERT_NAN (NUM##_dftd, df, td, , d128) \ +CONVERT_NAN (NUM##_sddd, sd, dd, d32, d64) \ +CONVERT_NAN (NUM##_sdtd, sd, td, d32, d128) \ +CONVERT_NAN (NUM##_ddsd, dd, sd, d64, d32) \ +CONVERT_NAN (NUM##_ddtd, dd, td, d64, d128) \ +CONVERT_NAN (NUM##_tdsd, td, sd, d128, d32) \ +CONVERT_NAN (NUM##_tddd, td, dd, d128, d64) + +#if USE_TF == 0 +#define CONVERT_NAN_TF(NUM) +#else +#define CONVERT_NAN_TF(NUM) \ +CONVERT_NAN (NUM##_sdtf, sd, tf, d32, l) \ +CONVERT_NAN (NUM##_ddtf, dd, tf, d64, l) \ +CONVERT_NAN (NUM##_tdtf, td, tf, d128, l) \ +CONVERT_NAN (NUM##_tfsd, tf, sd, l, d32) \ +CONVERT_NAN (NUM##_tfdd, tf, dd, l, d64) \ +CONVERT_NAN (NUM##_tftd, tf, td, l, d128) +#endif + +#define CONVERT_NAN_ALL(NUM) \ + CONVERT_NAN_NOTF(NUM) \ + CONVERT_NAN_TF(NUM) + +#define CALL_NAN(NUM) \ + convert_##NUM##_nan (); + +#define CALL_NAN_NOTF(NUM) \ + CALL_NAN (NUM##_sdsf) \ + CALL_NAN (NUM##_sddf) \ + CALL_NAN (NUM##_ddsf) \ + CALL_NAN (NUM##_dddf) \ + CALL_NAN (NUM##_tdsf) \ + CALL_NAN (NUM##_tddf) \ + CALL_NAN (NUM##_sfsd) \ + CALL_NAN (NUM##_sfdd) \ + CALL_NAN (NUM##_sftd) \ + CALL_NAN (NUM##_dfsd) \ + CALL_NAN (NUM##_dfdd) \ + CALL_NAN (NUM##_dftd) \ + CALL_NAN (NUM##_sddd) \ + CALL_NAN (NUM##_sdtd) \ + CALL_NAN (NUM##_ddsd) \ + CALL_NAN (NUM##_ddtd) \ + CALL_NAN (NUM##_tdsd) \ + CALL_NAN (NUM##_tddd) + +#if USE_TF == 0 +#define CALL_NAN_TF(NUM) +#else +#define CALL_NAN_TF(NUM) \ + CALL_NAN (NUM##_sdtf) \ + CALL_NAN (NUM##_ddtf) \ + CALL_NAN (NUM##_tdtf) \ + CALL_NAN (NUM##_tfsd) \ + CALL_NAN (NUM##_tfdd) \ + CALL_NAN (NUM##_tftd) +#endif + +#define CALL_NAN_ALL(NUM) \ + CALL_NAN_NOTF(NUM) \ + CALL_NAN_TF(NUM) Index: dfp/convert-bfp-4.c =================================================================== --- dfp/convert-bfp-4.c (nonexistent) +++ dfp/convert-bfp-4.c (revision 686) @@ -0,0 +1,21 @@ +/* This test assumes IEEE float and double. It also tests long double + but makes no assumption about its size or range of values. */ + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; /* might actually be df or xf, doesn't matter */ + +CONVERT_INF_ALL (t); + +int +main () +{ + CALL_INF_ALL (t) + + FINISH +} Index: dfp/operator-unary.c =================================================================== --- dfp/operator-unary.c (nonexistent) +++ dfp/operator-unary.c (revision 686) @@ -0,0 +1,52 @@ +/* C99 6.5.3 Unary operators. */ + +#include "dfp-dbg.h" + +#define AUTO_INCREASE_DECREASE(TYPE,SUFFIX) \ +do \ +{ \ + _Decimal##TYPE in_de_d##TYPE = 0.0##SUFFIX; \ + if (in_de_d##TYPE++) FAILURE \ + if (--in_de_d##TYPE) FAILURE \ + if (++in_de_d##TYPE == 0.0##SUFFIX) FAILURE \ + if (in_de_d##TYPE-- == 0.0##SUFFIX) FAILURE \ +} 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) FAILURE \ + /* + operator. */ \ + unary_d##TYPE = +unary_d##TYPE; \ + if (unary_d##TYPE != -1.0##SUFFIX) FAILURE \ + if (!unary_d##TYPE) FAILURE /*! 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) FAILURE + if (+ -0.df != -0.df) FAILURE + if (- -0.df != +0.df) FAILURE + + FINISH +} Index: dfp/convert-bfp-6.c =================================================================== --- dfp/convert-bfp-6.c (nonexistent) +++ dfp/convert-bfp-6.c (revision 686) @@ -0,0 +1,178 @@ +/* { dg-xfail-run-if "" { lax_strtofp } "*" "" } */ +/* { dg-options "-w" } */ + +/* This test assumes IEEE float and double. */ + +#define __STDC_WANT_DEC_FP__ +#include + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; +volatile long double tf; + +CONVERT_VALID (101, td, sf, 0.000488281251dl, 0.00048828125f, 0.f) + +/* 2**(-25) = 0.298023223876953125E-7. */ +CONVERT_VALID (102, td, sf, 2.98023223876953125e-8dl, 2.9802322387695312e-08f, + 01.e-13f) + +/* Fractional part doesn't fit. */ +CONVERT_VALID (103, df, sd, 1.0e-20, 1.0e-20df, 0.df) + +/* Exact power of 2. */ +CONVERT_VALID (104, df, sd, 0.00048828125, 0.00048828125df, 0.df) +CONVERT_VALID (105, df, sd, 1.0e-96, 0.dd, DEC32_MIN) + +/* A value slightly less than FLT_MAX can be converted in both directions. */ +CONVERT_VALID (201, sf, sd, 3.402819e+38f, 3.402819e+38df, 0.df) +CONVERT_VALID (202, sd, sf, 3.402819e+38df, 3.402819e+38f, 0.f) +CONVERT_VALID (203, sf, dd, 3.402819e+38f, 3.402819e+38dd, 1.e+30dd) +CONVERT_VALID (204, dd, sf, 3.402819e+38dd, 3.402819e+38f, 0.f) +CONVERT_VALID (205, sf, td, 3.402819e+38f, 3.402819e+38dl, 1.e+30dl) +CONVERT_VALID (206, td, sf, 3.402819e+38dl, 3.402819e+38f, 0.f) + +/* A value slightly less than DEC32_MAX can be converted in both directions. */ +CONVERT_VALID (211, sd, df, 9.999998e96df, 9.999998e96, 0.) +CONVERT_VALID (212, df, sd, 9.999998e96, 9.999998e96df, 0.df) + +/* A value slightly less than DBL_MAX can be converted in both directions. */ +CONVERT_VALID (221, df, dd, 1.79768e+308, 1.79768e+308dd, 0.dd) +CONVERT_VALID (222, dd, df, 1.79768e+308dd, 1.79768e+308, 0.) +CONVERT_VALID (223, df, td, 1.79768e+308, 1.79768e+308dl, 1.e292dl) +CONVERT_VALID (224, td, df, 1.79768e+308dl, 1.79768e+308, 0.) + +/* An integral value with 6 digits (FLT_DIG) can be converted between float + and _Decimal32 in both directions. */ +CONVERT_VALID (301, sd, sf, 100000.DF, 100000.F, 0.F) +CONVERT_VALID (302, sf, sd, 100000.F, 100000.DF, 0.DF) +CONVERT_VALID (303, sd, sf, 999999.DF, 999999.F, 0.F) +CONVERT_VALID (304, sf, sd, 999999.F, 999999.DF, 0.DF) + +/* An integral value with 7 digits (DEC32_MANT_DIG) can be converted between + _Decimal32 and double in both directions. */ +CONVERT_VALID (311, sd, df, 1000000.DF, 1000000., 0.) +CONVERT_VALID (312, df, sd, 1000000., 1000000.DF, 0.DF) +CONVERT_VALID (313, sd, df, 9999999.DF, 9999999., 0.) +CONVERT_VALID (314, df, sd, 9999999., 9999999.DF, 0.DF) + +/* An integral value with 15 digits (DBL_DIG) can be converted between + double and _Decimal64 in both directions. */ +CONVERT_VALID (321, dd, df, 100000000000000.DD, 100000000000000., 0.) +CONVERT_VALID (322, df, dd, 100000000000000., 100000000000000.DD, 0.DD); +CONVERT_VALID (323, dd, df, 999999999999999.DD, 999999999999999., 0.); +CONVERT_VALID (324, df, dd, 999999999999999., 999999999999999.DD, 0.DD); + +/* If LDBL_DIG is at least 16, an integral value with 16 digits can be + converted between _Decimal64 and long double in both directions. */ +CONVERT_VALID (331, dd, tf, 1000000000000000.DD, 1000000000000000.L, 0.L) +CONVERT_VALID (332, td, dd, 1000000000000000.L, 1000000000000000.DD, 0.DD) +CONVERT_VALID (333, dd, tf, 9999999999999999.DD, 9999999999999999.L, 0.L) +CONVERT_VALID (334, td, dd, 9999999999999999.L, 9999999999999999.DD, 0.DD) + +/* If LDBL_DIG is at least 18, an integral value with 18 digits can be + converted between long double and _Decimal128 in both directions. */ +CONVERT_VALID (341, td, tf, 100000000000000000.DL, 100000000000000000.L, 0.L) +CONVERT_VALID (342, tf, td, 100000000000000000.L, 100000000000000000.DL, 0.DL) +CONVERT_VALID (343, td, tf, 999999999999999999.DL, 999999999999999999.L, 0.L) +CONVERT_VALID (344, tf, td, 999999999999999999.L, 999999999999999999.DL, 0.DL) + +/* If LDBL_DIG is at least 31, an integral value with 31 digits can be + converted between long double and _Decimal128 in both directions. */ +CONVERT_VALID (351, td, tf, 1000000000000000000000000000000.DL, + 1000000000000000000000000000000.L, 0.L) +CONVERT_VALID (352, tf, td, 1000000000000000000000000000000.L, + 1000000000000000000000000000000.DL, 0.DL) +CONVERT_VALID (353, td, tf, 9999999999999999999999999999999.DL, + 9999999999999999999999999999999.L, 0.L) +CONVERT_VALID (354, tf, td, 9999999999999999999999999999999.L, + 9999999999999999999999999999999.DL, 0.DL) + +/* If LDBL_DIG is at least 33, an integral value with 33 digits can be + converted between long double and _Decimal128 in both directions. */ +CONVERT_VALID (361, td, tf, 100000000000000000000000000000000.DL, + 100000000000000000000000000000000.L, 0.L) +CONVERT_VALID (362, tf, td, 100000000000000000000000000000000.L, + 100000000000000000000000000000000.DL, 0.DL) +CONVERT_VALID (363, td, tf, 999999999999999999999999999999999.DL, + 999999999999999999999999999999999.L, 0.L) +CONVERT_VALID (364, tf, td, 999999999999999999999999999999999.L, + 999999999999999999999999999999999.DL, 0.DL) + +int +main () +{ + convert_101 (); + convert_102 (); + convert_103 (); + convert_104 (); + convert_105 (); + + convert_201 (); + convert_202 (); + convert_203 (); + convert_204 (); + convert_205 (); + convert_206 (); + + convert_211 (); + convert_212 (); + + convert_221 (); + convert_222 (); + convert_223 (); + convert_224 (); + + convert_301 (); + convert_302 (); + convert_303 (); + convert_304 (); + + convert_311 (); + convert_312 (); + convert_313 (); + convert_314 (); + + convert_321 (); + convert_322 (); + convert_323 (); + convert_324 (); + + if (LDBL_DIG >= 16) + { + convert_331 (); + convert_332 (); + convert_333 (); + convert_334 (); + } + + if (LDBL_DIG >= 18) + { + convert_341 (); + convert_342 (); + convert_343 (); + convert_344 (); + } + + if (LDBL_DIG >= 31) + { + convert_351 (); + convert_352 (); + convert_353 (); + convert_354 (); + } + + if (LDBL_DIG >= 33) + { + convert_361 (); + convert_362 (); + convert_363 (); + convert_364 (); + } + + FINISH +} Index: dfp/cast.c =================================================================== --- dfp/cast.c (nonexistent) +++ dfp/cast.c (revision 686) @@ -0,0 +1,75 @@ +/* C99 6.5.4 Cast operators. + Test valid casts involving decimal float. */ + +#include "dfp-dbg.h" + +_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) + FAILURE + if (d32 != (_Decimal32) d128) + FAILURE + + if (d64 != (_Decimal64) d32) + FAILURE + if (d64 != (_Decimal64) d128) + FAILURE + + if (d128 != (_Decimal128) d32) + FAILURE + if (d128 != (_Decimal128) d64) + FAILURE + + /* 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) + FAILURE + if ((double) d32 != 2.0l) + FAILURE + if ((float) d64 != 2.0f) + FAILURE + if ((double) d64 != 2.0l) + FAILURE + if ((float) d128 != 2.0f) + FAILURE + if ((double) d128 != 2.0l) + FAILURE + + /* float to decimal floating types. */ + if (d32 != (_Decimal32) f) + FAILURE + if (d64 != (_Decimal64) f) + FAILURE + if (d128 != (_Decimal128) f) + FAILURE + + /* double to decimal floating types. */ + if (d32 != (_Decimal32) d) + FAILURE + if (d64 != (_Decimal64) d) + FAILURE + if (d128 != (_Decimal128) d) + FAILURE + + FINISH +} Index: dfp/compare-special-d32.c =================================================================== --- dfp/compare-special-d32.c (nonexistent) +++ dfp/compare-special-d32.c (revision 686) @@ -0,0 +1,15 @@ +/* { dg-options "-O0" } */ + +/* C99 6.5.8 Relational operators. + C99 6.5.9 Equality operators. + Compare decimal float special values at runtime. */ + +#define WIDTH 32 +#include "compare-special.h" + +int +main () +{ + test_compares (); + FINISH +} Index: dfp/convert-bfp-8.c =================================================================== --- dfp/convert-bfp-8.c (nonexistent) +++ dfp/convert-bfp-8.c (revision 686) @@ -0,0 +1,71 @@ +/* { dg-options "-w" } */ + +/* This test assumes IEEE float and double. */ + +#define __STDC_WANT_DEC_FP__ +#include + +#include "convert.h" + +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; +volatile float sf; +volatile double df; + +/* Values slightly smaller than minimum (closest to zero) for result type. */ +CONVERT_VALID (401, sd, sf, 1.e-39df, 0.f, FLT_MIN) +CONVERT_VALID (402, sd, sf, -1.e-39df, 0.f, FLT_MIN) +CONVERT_VALID (403, sd, sf, 1.1e-38df, 0.f, FLT_MIN) +CONVERT_VALID (404, sd, sf, -1.1e-38df, 0.f, FLT_MIN) + +CONVERT_VALID (411, dd, sf, 1.e-39dd, 0.f, FLT_MIN) +CONVERT_VALID (412, dd, sf, -1.e-39dd, 0.f, FLT_MIN) +CONVERT_VALID (413, dd, sf, 1.1e-38dd, 0.f, FLT_MIN) +CONVERT_VALID (414, dd, sf, -1.1e-38dd, 0.f, FLT_MIN) + +CONVERT_VALID (421, dd, df, 3.e-309dd, 0., DBL_MIN) +CONVERT_VALID (422, dd, df, -3.e-309dd, 0., DBL_MIN) +CONVERT_VALID (423, dd, df, 2.e-308dd, 0., DBL_MIN) +CONVERT_VALID (424, dd, df, -2.e-308dd, 0., DBL_MIN) + +CONVERT_VALID (431, td, sf, 1.e-39dl, 0.f, FLT_MIN) +CONVERT_VALID (432, td, sf, -1.e-39dl, 0.f, FLT_MIN) +CONVERT_VALID (433, td, sf, 1.1e-38dl, 0.f, FLT_MIN) +CONVERT_VALID (434, td, sf, -1.1e-38dl, 0.f, FLT_MIN) + +CONVERT_VALID (441, td, df, 3.e-309dl, 0., DBL_MIN) +CONVERT_VALID (442, td, df, -3.e-309dl, 0., DBL_MIN) +CONVERT_VALID (443, td, df, 2.e-308dl, 0., DBL_MIN) +CONVERT_VALID (444, td, df, -2.e-308dl, 0., DBL_MIN) + +int +main () +{ + convert_401 (); + convert_402 (); + convert_403 (); + convert_404 (); + + convert_411 (); + convert_412 (); + convert_413 (); + convert_414 (); + + convert_421 (); + convert_422 (); + convert_423 (); + convert_424 (); + + convert_431 (); + convert_432 (); + convert_433 (); + convert_434 (); + + convert_441 (); + convert_442 (); + convert_443 (); + convert_444 (); + + FINISH +} Index: dfp/signbit-1.c =================================================================== --- dfp/signbit-1.c (nonexistent) +++ dfp/signbit-1.c (revision 686) @@ -0,0 +1,40 @@ +/* { dg-options "-O0" } */ + +/* Decimal float versions of __builtin_signbit. */ + +#include "dfp-dbg.h" + +#define CHECK32(D,I) \ + if ((__builtin_signbitd32 (D) != 0) != I) FAILURE + +#define CHECK64(D,I) \ + if ((__builtin_signbitd64 (D) != 0) != I) FAILURE + +#define CHECK128(D,I) \ + if ((__builtin_signbitd128 (D) != 0) != I) FAILURE + +/* Prevent the compiler from folding the calls at compile time. */ +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; + +int +main () +{ + sd = 1.9df; CHECK32 (sd, 0) + sd = -5.3df; CHECK32 (sd, 1) + sd = 0.0df; CHECK32 (sd, 0) + sd = -0.0df; CHECK32 (sd, 1) + + dd = 1.9dd; CHECK64 (dd, 0) + dd = -5.3dd; CHECK64 (dd, 1) + dd = 0.0dd; CHECK64 (dd, 0) + dd = -0.0dd; CHECK64 (dd, 1) + + td = 1.9dl; CHECK128 (td, 0) + td = -5.3dl; CHECK128 (td, 1) + td = 0.0dl; CHECK128 (td, 0) + td = -0.0dl; CHECK128 (td, 1) + + FINISH +} Index: pr46562.c =================================================================== --- pr46562.c (nonexistent) +++ pr46562.c (revision 686) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-ccp1" } */ + +static const int a[4] = {}; +int foo(void) +{ + int i = 1; + const int *p = &a[i]; + return *p; +} + +/* { dg-final { scan-tree-dump "return 0;" "ccp1" } } */ +/* { dg-final { cleanup-tree-dump "ccp1" } } */ Index: pr41779.c =================================================================== --- pr41779.c (nonexistent) +++ pr41779.c (revision 686) @@ -0,0 +1,56 @@ +/* PR41779: Wconversion cannot see throught real*integer promotions. */ +/* { dg-do compile } */ +/* { dg-skip-if "doubles are floats" { "avr-*-*" } { "*" } { "" } } */ +/* { dg-options "-std=c99 -Wconversion" { target c } } */ +/* { dg-options "-Wconversion" { target c++ } } */ +/* { dg-require-effective-target large_double } */ + +float f1(float x, unsigned short y) +{ + return x * y; +} + +float f2(float x, short y) +{ + return x * y; +} + +float f3(float x, char y) +{ + return x * y; +} + +float f4(float x, unsigned char y) +{ + return x * y; +} + +float f5(float x, int y) +{ + return x * y; /* { dg-warning "conversion" } */ +} + +double c1(float x, unsigned short y, int z) +{ + return z ? x + x : y; +} + +double c2(float x, short y, int z) +{ + return z ? x + x : y; +} + +double c3(float x, char y, int z) +{ + return z ? x + x : y; +} + +double c4(float x, unsigned char y, int z) +{ + return z ? x + x : y; +} + +double c5(float x, int y, int z) +{ + return z ? x + x : y; /* { dg-warning "conversion" } */ +} Index: restrict-1.c =================================================================== --- restrict-1.c (nonexistent) +++ restrict-1.c (revision 686) @@ -0,0 +1,20 @@ +/* { dg-do link } */ +/* { dg-options "-O -fno-strict-aliasing -fdump-tree-optimized" } */ + +extern void link_error (void); + +void bar0 (int * __restrict__ arr1, int * __restrict__ arr2) +{ + arr1[0] = 1; + arr2[0] = 1; + if (arr1[0] != 1) + link_error (); +} + +int main() +{ + return 0; +} + +/* { dg-final { scan-tree-dump-not "link_error" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.