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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [dfp/] [func-vararg-mixed.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-options "-std=gnu99" } */
2
 
3
/* C99 6.5.2.2 Function calls.
4
   Test passing varargs of the combination of decimal float types and
5
   other types.  */
6
 
7
#include <stdarg.h>
8
 
9
extern void abort (void);
10
 
11
/* Supposing the list of varying number of arguments is:
12
   unsigned int, _Decimal128, double, _Decimal32, _Decimal64.  */
13
 
14
static _Decimal32
15
vararg_d32 (unsigned arg, ...)
16
{
17
  va_list ap;
18
  _Decimal32 result;
19
 
20
  va_start (ap, arg);
21
 
22
  va_arg (ap, unsigned int);
23
  va_arg (ap, _Decimal128);
24
  va_arg (ap, double);
25
  result = va_arg (ap, _Decimal32);
26
 
27
  va_end (ap);
28
  return result;
29
}
30
 
31
static _Decimal32
32
vararg_d64 (unsigned arg, ...)
33
{
34
  va_list ap;
35
  _Decimal64 result;
36
 
37
  va_start (ap, arg);
38
 
39
  va_arg (ap, unsigned int);
40
  va_arg (ap, _Decimal128);
41
  va_arg (ap, double);
42
  va_arg (ap, _Decimal32);
43
  result = va_arg (ap, _Decimal64);
44
 
45
  va_end (ap);
46
  return result;
47
}
48
 
49
static _Decimal128
50
vararg_d128 (unsigned arg, ...)
51
{
52
  va_list ap;
53
  _Decimal128 result;
54
 
55
  va_start (ap, arg);
56
 
57
  va_arg (ap, unsigned int);
58
  result = va_arg (ap, _Decimal128);
59
 
60
  va_end (ap);
61
  return result;
62
}
63
 
64
static unsigned int
65
vararg_int (unsigned arg, ...)
66
{
67
  va_list ap;
68
  unsigned int result;
69
 
70
  va_start (ap, arg);
71
 
72
  result = va_arg (ap, unsigned int);
73
 
74
  va_end (ap);
75
  return result;
76
}
77
 
78
static double
79
vararg_double (unsigned arg, ...)
80
{
81
  va_list ap;
82
  float result;
83
 
84
  va_start (ap, arg);
85
 
86
  va_arg (ap, unsigned int);
87
  va_arg (ap, _Decimal128);
88
  result = va_arg (ap, double);
89
 
90
  va_end (ap);
91
  return result;
92
}
93
 
94
 
95
int
96
main ()
97
{
98
  if (vararg_d32 (3, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 3.0df) abort ();
99
  if (vararg_d64 (4, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 4.0dd) abort ();
100
  if (vararg_d128 (1, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 1.0dl) abort ();
101
  if (vararg_int (0, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 0) abort ();
102
  if (vararg_double (2, 0, 1.0dl, 2.0, 3.0df, 4.0dd) != 2.0) abort ();
103
 
104
  return 0;
105
}

powered by: WebSVN 2.1.0

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