aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/gnu2x-attrs-1.c
blob: 67ab48349a11f2b9b90bc08e1ebfe91a68e88162 (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
/* Test C23 attribute syntax.  Test GNU attributes appertain to
   appropriate constructs.  */
/* { dg-do compile } */
/* { dg-require-alias "" } */
/* { dg-options "-std=gnu23" } */

void f (void) {};

[[gnu::alias("f")]] void g (void); /* { dg-error "only weak" "" { target *-*-darwin* } } */

void [[gnu::alias("f")]] h (void); /* { dg-warning "does not apply to types" } */

struct [[gnu::packed]] s { int a; char b; };
_Static_assert (sizeof (struct s) == (sizeof (int) + sizeof (char)));

int
f2 (void)
{
  [[gnu::deprecated]] int a = 1;
  return a; /* { dg-warning "deprecated" } */
}

int
f3 (void)
{
  int a [[gnu::deprecated]] = 1;
  return a; /* { dg-warning "deprecated" } */
}

struct s2 { [[gnu::deprecated]] int a; int b [[gnu::deprecated]]; } x;

int
f4 (void)
{
  return x.a; /* { dg-warning "deprecated" } */
}

int
f5 (void)
{
  return x.b; /* { dg-warning "deprecated" } */
}

enum e { E1 [[gnu::deprecated]] };

enum e
f6 (void)
{
  return E1; /* { dg-warning "deprecated" } */
}

int
f7 ([[gnu::deprecated]] int y)
{
  return y; /* { dg-warning "deprecated" } */
}

union [[gnu::deprecated]] u { int x; };

void
f8 (void)
{
  union u var; /* { dg-warning "deprecated" } */
}

enum [[gnu::deprecated]] edep { E2 };

void
f9 (void)
{
  enum edep var; /* { dg-warning "deprecated" } */
}