aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/attr-assume7.C
blob: 441242ce05004eb238f8892a621541ea683a1d32 (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
// P1774R8 - Portable assumptions
// { dg-do compile { target c++11 } }
// { dg-options "-O2" }

int
foo (int x)
{
  [[assume (x == 42)]];
  return x;
}

int
bar (int x)
{
  [[assume (++x == 43)]];
  return x;
}

int
baz (int x)
{
  [[assume (({ int z = ++x; static int w; ++w; if (z == 51) return -1; if (z == 53) goto lab1; if (z == 64) throw 1; z == 43; }))]];
lab1:
  return x;
}

struct S { S (); S (const S &); ~S (); int a, b; int foo (); };

int
qux ()
{
  S s;
  [[assume (s.a == 42 && s.b == 43)]];
  return s.a + s.b;
}

int
S::foo ()
{
  [[assume (a == 42 && b == 43)]];
  return a + b;
}

int
corge (int x)
{
  [[assume (({ [[assume (x < 42)]]; x > -42; }))]];
  return x < 42;
}

int
garply (int x)
{
  [[assume (({ [[assume (++x < 43)]]; x > -42; }))]];
  return x < 42;
}