view gcc/testsuite/g++.dg/guality/pr82630.C @ 138:fc828634a951

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:17:14 +0900
parents 04ced10e8804
children
line wrap: on
line source

// PR debug/82630
// { dg-do run }
// { dg-additional-options "-fPIC" { target fpic } }

struct C
{
  int &c;
  long d;
  __attribute__((always_inline)) C (int &x) : c(x), d() {}
};
int v;

__attribute__((noipa)) void
fn1 (const void *x)
{
  asm volatile ("" : : "g" (x) : "memory");
}

__attribute__((noipa)) void
fn2 (C x)
{
  int a = x.c + x.d;
  asm volatile ("" : : "g" (a) : "memory");
}

__attribute__((noipa)) void
fn3 (void)
{
  asm volatile ("" : : : "memory");
}

__attribute__((noipa))
#ifdef __i386__
__attribute__((regparm (2)))
#endif
static void
fn4 (int *x, const char *y, C z)
{
  fn2 (C (*x));
  fn1 ("baz");
  fn2 (z);	// { dg-final { gdb-test 41 "y\[0\]" "'f'" } }
  fn1 ("baz");	// { dg-final { gdb-test 41 "y\[1\]" "'o'" } }
}

__attribute__((noipa)) void
fn5 (int *x)
{
  fn4 (x, "foo", C (*x));
  fn3 ();
}

int
main ()
{
  int a = 10;
  fn5 (&a);
  return 0;
}