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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [ext/] [packed4.C] - Diff between revs 154 and 816

Only display areas with differences | Details | Blame | View Log

Rev 154 Rev 816
// { dg-do run { target { ! default_packed } } }
// { dg-do run { target { ! default_packed } } }
// { dg-options "-w" }
// { dg-options "-w" }
// Copyright (C) 2003 Free Software Foundation, Inc.
// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 15 Jul 2003 
// Contributed by Nathan Sidwell 15 Jul 2003 
// Packed fields are unsuitable for direct reference binding.
// Packed fields are unsuitable for direct reference binding.
struct Unpacked { int i; };
struct Unpacked { int i; };
int ConstRef (int const &p, int const *ptr, int v)
int ConstRef (int const &p, int const *ptr, int v)
{
{
  if (p != v)
  if (p != v)
    return 1;
    return 1;
  if (&p == ptr)
  if (&p == ptr)
    return 2;
    return 2;
  return 0;
  return 0;
}
}
int ConstRef (Unpacked const &p, Unpacked const *ptr, int v)
int ConstRef (Unpacked const &p, Unpacked const *ptr, int v)
{
{
  if (p.i != v)
  if (p.i != v)
    return 1;
    return 1;
  if (&p == ptr)
  if (&p == ptr)
    return 2;
    return 2;
  return 0;
  return 0;
}
}
int Val (int p, int v)
int Val (int p, int v)
{
{
  if (p != v)
  if (p != v)
    return 1;
    return 1;
  return 0;
  return 0;
}
}
int Val (Unpacked p, int v)
int Val (Unpacked p, int v)
{
{
  if (p.i != v)
  if (p.i != v)
    return 1;
    return 1;
  return 0;
  return 0;
}
}
struct  __attribute__ ((packed)) Packed
struct  __attribute__ ((packed)) Packed
{
{
  char c;
  char c;
  int i;
  int i;
  Unpacked u;
  Unpacked u;
  char t;
  char t;
};
};
int Foo (Packed &p, int i, int ui)
int Foo (Packed &p, int i, int ui)
{
{
  int r;
  int r;
  if ((r = Val (p.i, i)))
  if ((r = Val (p.i, i)))
    return r;
    return r;
  if ((r = Val (p.u.i, ui)))
  if ((r = Val (p.u.i, ui)))
    return r + 2;
    return r + 2;
  if ((r = Val (p.u, ui)))
  if ((r = Val (p.u, ui)))
    return r + 4;
    return r + 4;
  if ((r = ConstRef (p.i, &p.i, i)))
  if ((r = ConstRef (p.i, &p.i, i)))
    return r + 6;
    return r + 6;
  return 0;
  return 0;
}
}
int main ()
int main ()
{
{
  Packed p;
  Packed p;
  p.c = 0x12;
  p.c = 0x12;
  p.i = 0x3456789a;
  p.i = 0x3456789a;
  p.u.i = 0xbcdef00f;
  p.u.i = 0xbcdef00f;
  p.t = 0xed;
  p.t = 0xed;
  return Foo (p, 0x3456789a, 0xbcdef00f);
  return Foo (p, 0x3456789a, 0xbcdef00f);
}
}
 
 

powered by: WebSVN 2.1.0

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