summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/guality/pr43077-1.c
blob: d8d5eebe07ffc22476104659f82b165f43e32ed5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* PR debug/43077 */
/* { dg-do run } */
/* { dg-options "-g" } */

int varb;

int __attribute__((noinline))
fn1 (void)
{
  int vara = (varb == 3);		/* { dg-final { gdb-test 11 "vara" "0" } } */
  asm volatile ("" : : "g" (vara));	/* { dg-final { gdb-test 11 "varb" "2" } } */
  return 0;
}

int __attribute__((noinline))
fn2 (void)
{
  int vara = (varb == 3);		/* { dg-final { gdb-test 19 "vara" "1" } } */
  asm volatile ("" : : "g" (vara));	/* { dg-final { gdb-test 19 "varb" "3" } } */
  return 0;
}

int __attribute__((noinline))
foo (unsigned long *p, unsigned long *q)
{
  int ret;
  asm volatile ("" : "=r" (ret), "=r" (*p), "=r" (*q) : "0" (1), "1" (2), "2" (3));
  return ret;
}

int __attribute__((noinline))
fn3 (void)
{
  unsigned long a = 0, b = 0, c = 0;
  a = foo (&b, &c);
					/* { dg-final { gdb-test 42 "a" "1" } } */
					/* { dg-final { gdb-test 42 "b" "2" } } */
					/* { dg-final { gdb-test 42 "c" "3" } } */
  unsigned long vara = a;		/* { dg-final { gdb-test 42 "vara" "1" } } */
  unsigned long varb = b;		/* { dg-final { gdb-test 42 "varb" "2" } } */
  unsigned long varc = c;		/* { dg-final { gdb-test 42 "varc" "3" } } */
  asm volatile ("" : : "g" (vara), "g" (varb), "g" (varc));
  return a;
}

int
main (void)
{
  asm volatile ("" : "=r" (varb) : "0" (2));
  fn1 ();
  asm volatile ("" : "=r" (varb) : "0" (3));
  fn2 ();
  fn3 ();
  return 0;
}