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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [vaarg2.C] - Blame information for rev 12

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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