aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c
blob: 4e6f7a7e8ba26ada8fc9766b7eb4c0528e1ad53c (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* DWARF5 variant of inline2.
   Origin: PR debug/37801

  Abstract instances (DW_TAG_subroutines having the DW_AT_inline attribute)
  of second and first were having a DW_TAG_lexical_block DIE wrongly
  representing the inlined calls to third (in second) and to
  second (in first). At the same time, main didn't have children
  DW_TAG_inlined_subroutine DIEs representing the inlined calls to
  first, second and third.

  The ideal goal here is to test that we have no superfluous
  DW_TAG_lexical_block DIE anymore, that abstract instances DIEs have
  no descendant DIE with a DW_AT_abstract_origin attribute, and that main has
  properly nested DW_TAG_inlined_subroutine DIEs for third, second and first.
*/

/* Explicitly use dwarf-5 which uses DW_FORM_implicit_const.  */
/* { dg-do compile } */
/* { dg-options "-O -g3 -gdwarf-5 -dA -fgnu89-inline" } */
/* { dg-skip-if "AIX DWARF5" { powerpc-ibm-aix* } } */

/* There are 6 inlined subroutines:
   - One for each subroutine inlined into main, that's 3.
   - One for earch subroutine inline into the out of line instances
     of third, second and first.  */
/* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_inlined_subroutine" 6 } } */

/* We should have no DW_TAG_lexical_block DIEs, all inline instances
   should have the first subblock elided to match the abstract instance
   layout.  */
/* { dg-final { scan-assembler-times "\\(DIE \\(\[^\n\]*\\) DW_TAG_lexical_block" 0 } } */


/* There are 3 DW_AT_inline attributes: one per abstract inline instance.
   The value of the attribute must be 0x3, meaning the function was
   actually inlined.  */
/* { dg-final { scan-assembler-times  " DW_AT_inline \\(0x3\\)" 3 } } */

volatile int *a;

inline void
third (int arg3)
{
  int var3 = arg3;
  a[0] = var3;
}

inline void
second (int arg2)
{
  int var2 = arg2;
  third (var2+1);
}

inline void
first (int arg1)
{
  int var1 = arg1;
  second (var1+1);
}

int
main ()
{
  int some_int = 1;
  first (some_int);
  return 0;
}