File: noexcept50.C

package info (click to toggle)
gcc-arm-none-eabi 15%3A12.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 959,712 kB
  • sloc: cpp: 3,275,382; ansic: 2,061,766; ada: 840,956; f90: 208,513; makefile: 76,132; asm: 73,433; xml: 50,448; exp: 34,146; sh: 32,436; objc: 15,637; fortran: 14,012; python: 11,991; pascal: 6,787; awk: 4,779; perl: 3,054; yacc: 338; ml: 285; lex: 201; haskell: 122
file content (147 lines) | stat: -rw-r--r-- 2,880 bytes parent folder | download | duplicates (2)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// PR c++/86476 - noexcept-specifier is a complete-class context
// { dg-do compile { target c++11 } }

#define SA(X) static_assert(X, #X)

struct S {
  void f1() noexcept(noexcept(i)) { }
  void f2() noexcept(noexcept(fn())) { }
  void f3() noexcept(noexcept(fnx())) { }
  void f4() noexcept(noexcept(i));
  void f5() noexcept(noexcept(fn()));
  void f6() noexcept(noexcept(fnx()));

  void f7() noexcept(1);
  void f8() noexcept(0);
  void f9() noexcept(b);
  void f10() noexcept(!b);

  int i;
  static constexpr auto b = true;
  void fny() noexcept(noexcept(fn()));
  void fn();
  void fnx() noexcept;
};

S s;
SA(noexcept(s.f1()));
SA(!noexcept(s.f2()));
SA(noexcept(s.f3()));
SA(noexcept(s.f4()));
SA(!noexcept(s.f5()));
SA(noexcept(s.f6()));
SA(noexcept(s.f7()));
SA(!noexcept(s.f8()));
SA(noexcept(s.f9()));
SA(!noexcept(s.f10()));

struct S2 {
  struct V {
    void f1() noexcept(noexcept(fn()));
    void f2() noexcept(noexcept(fnx()));
    void f3() noexcept(noexcept(fn())) { }
    void f4() noexcept(noexcept(fnx())) { }
    void fn();
    void fnx() noexcept;
  } v;
  void fn();
  void fnx();
};

S2 s2;
SA(!noexcept(s2.v.f1()));
SA(noexcept(s2.v.f2()));
SA(!noexcept(s2.v.f3()));
SA(noexcept(s2.v.f4()));

struct S3 {
  void f1() noexcept(noexcept(fn()));
  void f2() noexcept(noexcept(fnx()));
  void fn();
  void fnx() noexcept;
};

void
S3::f1() noexcept(noexcept(fn()))
{
}

void
S3::f2() noexcept(noexcept(fnx()))
{
}

struct S4 {
  int f1 (int p) noexcept(noexcept(p)) { return p; }
  int f2 (int p) noexcept(noexcept(p));
  int f3 (int p = 10) noexcept(noexcept(p));
  int f4 () noexcept(noexcept(S4{}));
};

S4 s4;
SA(noexcept(s4.f1(1)));
SA(noexcept(s4.f2(1)));
SA(noexcept(s4.f3()));
SA(noexcept(s4.f4()));

template<typename T>
struct S5 {
  void f1() noexcept(noexcept(i)) { }
  void f2() noexcept(noexcept(fn())) { }
  void f3() noexcept(noexcept(fnx())) { }
  void f4() noexcept(noexcept(i));
  void f5() noexcept(noexcept(fn()));
  void f6() noexcept(noexcept(fnx()));
    
  int i;
  void fny() noexcept(noexcept(fn()));
  void fn();
  void fnx() noexcept;
};

S5<int> s5;
SA(noexcept(s5.f1()));
SA(!noexcept(s5.f2()));
SA(noexcept(s5.f3()));
SA(noexcept(s5.f4()));
SA(!noexcept(s5.f5()));
SA(noexcept(s5.f6()));

template<typename T>
struct S6 {
  void f1() noexcept(noexcept(x));
  T x;
};

struct S7 {
  template<typename U>
  void f1 () noexcept(noexcept(U(1))) { }

  template<int N>
  void f2() noexcept(noexcept(N));

  template <typename _Up>
  void f3(_Up __p) noexcept(noexcept(__p));
};

void glob();
void globx() noexcept;
struct S8 {
  void f1 () noexcept(noexcept(glob()));
  void f2 () noexcept(noexcept(globx()));
};

S8 s8;
SA(!noexcept(s8.f1()));
SA(noexcept(s8.f2()));

struct W {
  constexpr operator bool();
};

template<typename T>
struct S9 {
  S9() noexcept(noexcept(w)) { }
  S9 &operator=(S9 &&) noexcept(T::X);
  W w;
};