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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [vaarg2.C] - Blame information for rev 699

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do run  }
2
// { dg-options "-Wno-abi" { target arm_eabi } }
3
// Copyright (C) 1999, 2000 Free Software Foundation, Inc.
4
// Contributed by Nathan Sidwell 4 Oct 1999 
5
 
6
// Make sure we can deal with POD aggregate in va_args
7
 
8
#include 
9
extern "C" void abort ();
10
 
11
struct X {int m;};
12
struct Y {int a; int b; int c; int d; int e; int f;};
13
 
14
void fn1(va_list args)
15
{
16
  int i = va_arg (args, int);
17
  X x = va_arg (args, X);
18
  Y y = va_arg (args, Y);
19
  if (i != 1)
20
    abort ();
21
  if (x.m != 1)
22
    abort ();
23
  if (y.a != 1 || y.b != 2 || y.c != 3 || y.d != 4 ||
24
      y.e != 5 || y.f != 6)
25
    abort ();
26
}
27
 
28
void fn2(va_list args)
29
{
30
  const int &i = va_arg (args, int);
31
  const X &x = va_arg (args, X);
32
  const Y &y = va_arg (args, Y);
33
  if (i != 1)
34
    abort ();
35
  if (x.m != 1)
36
    abort ();
37
  if (y.a != 1 || y.b != 2 || y.c != 3 || y.d != 4 ||
38
      y.e != 5 || y.f != 6)
39
    abort ();
40
}
41
 
42
void
43
dispatch (int t, ...)
44
{
45
  va_list args;
46
 
47
  va_start (args, t);
48
  fn1 (args);
49
  va_end (args);
50
 
51
  va_start (args, t);
52
  fn2 (args);
53
  va_end (args);
54
}
55
 
56
int main ()
57
{
58
  X x = {1};
59
  Y y = {1, 2, 3, 4, 5, 6};
60
 
61
  dispatch (0, 1, x, y);
62
 
63
  return 0;
64
}

powered by: WebSVN 2.1.0

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