aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/guality/const-volatile.c
blob: 21f84b5c208ff0cabb78b36b73184f5a25aa5817 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* debuginfo tests for combinations of const and volatile type qualifiers. */
/* { dg-do run } */
/* { dg-options "-g" } */

int i __attribute__((used));
const int ci __attribute__((used));
volatile int vi;
const volatile int cvi;

int *pi __attribute__((used));
const int *pci __attribute__((used));
volatile int *pvi __attribute__((used));
const volatile int *pcvi __attribute__((used));

int * const cip __attribute__((used));
int * volatile vip;
int * const volatile cvip;

volatile struct
{
  const long cli;
  const signed char csc;
} vs;

struct foo
{
  const long cli;
  const signed char csc;
};

struct bar
{
  short s;
  const short cs;
  volatile short vs;
  const volatile short cvs;
  volatile long long vll;
};

struct bar bar __attribute__((used));
struct foo foo __attribute__((used));
const struct foo cfoo __attribute__((used));
volatile struct foo vfoo;
const volatile struct foo cvfoo;

typedef volatile signed char score;

score s;
const score cs;

static __attribute__((noclone, noinline)) int
f (const char *progname, volatile struct foo *dummy, const score s)
{
  return progname == 0 || dummy == 0 || dummy->csc == s;
}

int
main (int argc, char **argv)
{
  score as = argc;
  struct foo dummy = { 1, 1 };
  return f (argv[0], &dummy, as) - 1;
}

/* { dg-final { gdb-test "@main" "type:main" "int (int, char **)" } } */

/* { dg-final { gdb-test "@main" "type:i" "int" } } */
/* { dg-final { gdb-test "@main" "type:ci" "const int" } } */
/* { dg-final { gdb-test "@main" "type:vi" "volatile int" } } */
/* { dg-final { gdb-test "@main" "type:cvi" "const volatile int" } } */

/* { dg-final { gdb-test "@main" "type:pi" "int *" } } */
/* { dg-final { gdb-test "@main" "type:pci" "const int *" } } */
/* { dg-final { gdb-test "@main" "type:pvi" "volatile int *" } } */
/* { dg-final { gdb-test "@main" "type:pcvi" "const volatile int *" } } */

/* { dg-final { gdb-test "@main" "type:cip" "int * const" } } */
/* { dg-final { gdb-test "@main" "type:vip" "int * volatile" } } */
/* { dg-final { gdb-test "@main" "type:cvip" "int * const volatile" } } */

/* { dg-final { gdb-test "@main" "type:vs" "volatile struct { const long cli; const signed char csc; }" } } */

/* { dg-final { gdb-test "@main" "type:bar" "struct bar { short s; const short cs; volatile short vs; const volatile short cvs; volatile long long vll; }" } } */
/* { dg-final { gdb-test "@main" "type:foo" "struct foo { const long cli; const signed char csc; }" } } */
/* { dg-final { gdb-test "@main" "type:cfoo" "const struct foo { const long cli; const signed char csc; }" } } */
/* { dg-final { gdb-test "@main" "type:vfoo" "volatile struct foo { const long cli; const signed char csc; }" } } */
/* { dg-final { gdb-test "@main" "type:cvfoo" "const volatile struct foo { const long cli; const signed char csc; }" } } */

/* { dg-final { gdb-test "@main" "type:s" "volatile signed char" } } */
/* { dg-final { gdb-test "@main" "type:cs" "const volatile signed char" } } */

/* { dg-final { gdb-test "@main" "type:f" "int (const char *, volatile struct foo *, const score)" } } */