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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [init/] [init-ref1.C] - Rev 338

Compare with Previous | Blame | View Log

// Submitted by Erik Rozendaal <dlr@acm.org>
// Test case for GNATS bug 787.
// { dg-do run }

#include <stdio.h>
#include <stdlib.h>

static int calls;

int &foo (int &arg)
{
  calls++;
  arg=0;
  return arg;
}

int &identity (int &x)
{
  return x;
}

int main()
{
  int a;

  calls = 0;
  int &b = ++foo (a);
  if (calls > 1)
    abort ();
  if (&a != &b)
    abort ();
  if (a != 1)
    abort ();

  calls = 0;
  int &c = ++identity (++foo (a));
  if (calls > 1)
    abort ();
  if (&a != &c)
    abort ();
  if (a != 2)
    abort ();

  exit (0);
}

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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