Lines Matching refs:constexpr
28 constexpr NonConstexpr2(); // expected-note {{here}}
46 constexpr UndefinedConstexpr();
47 static constexpr int undefinedConstexpr1(); // expected-note {{here}}
55 static constexpr const int &id_ref(const int &n) { in id_ref()
61 constexpr const int *address_of(const int &a) { in address_of()
64 constexpr const int *return_param(int n) { // expected-note {{declared here}} in return_param()
78 constexpr T(const int &r) : in T()
83 constexpr int n = 0;
84 constexpr T t1(n); // ok
85 …constexpr T t2(0); // expected-error {{must be initialized by a constant expression}} expected-not…
95 constexpr int RecurseForever(int n) { in RecurseForever()
99 constexpr AlsoRecurseForever(int n) : in AlsoRecurseForever()
114 constexpr S *p = &s; // ok
118 constexpr S (*p2)[] = &sArr; // ok
121 constexpr S *operator&() const { return nullptr; } in operator &()
123 constexpr S *q = &s; // ok
146 constexpr int int_min = ~0x7fffffff;
147 …constexpr int minus_int_min = -int_min; // expected-error {{constant expression}} expected-note {{…
148 …constexpr int div0 = 3 / 0; // expected-error {{constant expression}} expected-note {{division by …
149 …constexpr int mod0 = 3 % 0; // expected-error {{constant expression}} expected-note {{division by …
150 …constexpr int int_min_div_minus_1 = int_min / -1; // expected-error {{constant expression}} expect…
151 …constexpr int int_min_mod_minus_1 = int_min % -1; // expected-error {{constant expression}} expect…
153 …constexpr int shl_m1 = 0 << -1; // expected-error {{constant expression}} expected-note {{negative…
154 constexpr int shl_0 = 0 << 0; // ok
155 constexpr int shl_31 = 0 << 31; // ok
156 …constexpr int shl_32 = 0 << 32; // expected-error {{constant expression}} expected-note {{shift co…
157 constexpr int shl_unsigned_negative = unsigned(-3) << 1; // ok
158 constexpr int shl_unsigned_into_sign = 1u << 31; // ok
159 constexpr int shl_unsigned_overflow = 1024u << 31; // ok
160 …constexpr int shl_signed_negative = (-3) << 1; // expected-warning {{shifting a negative signed va…
161 constexpr int shl_signed_ok = 1 << 30; // ok
162 constexpr int shl_signed_into_sign = 1 << 31; // ok (DR1457)
163 constexpr int shl_signed_into_sign_2 = 0x7fffffff << 1; // ok (DR1457)
164 …constexpr int shl_signed_off_end = 2 << 31; // expected-error {{constant expression}} expected-not…
165 …constexpr int shl_signed_off_end_2 = 0x7fffffff << 2; // expected-error {{constant expression}} ex…
166 …constexpr int shl_signed_overflow = 1024 << 31; // expected-error {{constant expression}} expected…
167 constexpr int shl_signed_ok2 = 1024 << 20; // ok
169 …constexpr int shr_m1 = 0 >> -1; // expected-error {{constant expression}} expected-note {{negative…
170 constexpr int shr_0 = 0 >> 0; // ok
171 constexpr int shr_31 = 0 >> 31; // ok
172 …constexpr int shr_32 = 0 >> 32; // expected-error {{constant expression}} expected-note {{shift co…
177 constexpr S s = { 5 };
178 constexpr const int *p = &s.m + 1;
179 constexpr const int &f(const int *q) { in f()
182 constexpr int n = (f(p), 0); // ok
191 …constexpr B *p = a[0] + 4; // expected-error {{constant expression}} expected-note {{element 4 of …
193 …constexpr A *pa = &b + 1; // expected-error {{constant expression}} expected-note {{base class of …
194 …constexpr B *pb = (B*)((A*)&b + 1); // expected-error {{constant expression}} expected-note {{deri…
195 …constexpr const int *pn = &(&b + 1)->n; // expected-error {{constant expression}} expected-note {{…
196 …constexpr B *parr = &a[3][0]; // expected-error {{constant expression}} expected-note {{array elem…
198 constexpr A *na = nullptr;
199 constexpr B *nb = nullptr;
200 …constexpr A &ra = *nb; // expected-error {{constant expression}} expected-note {{cannot access bas…
201 …constexpr B &rb = (B&)*na; // expected-error {{constant expression}} expected-note {{cannot access…
204 …constexpr const int &nf = nb->n; // expected-error {{constant expression}} expected-note {{cannot …
205 constexpr const int *np1 = (int*)nullptr + 0; // ok
206 constexpr const int *np2 = &(*(int(*)[4])nullptr)[0]; // ok
207 …constexpr const int *np3 = &(*(int(*)[4])nullptr)[2]; // expected-error {{constant expression}} ex…
210 constexpr int f() const { return 0; } in f()
211 } constexpr c = C();
212 constexpr int k1 = c.f(); // ok
213 …constexpr int k2 = ((C*)nullptr)->f(); // expected-error {{constant expression}} expected-note {{c…
214 …constexpr int k3 = (&c)[1].f(); // expected-error {{constant expression}} expected-note {{cannot c…
216 constexpr int k4 = c2.f(); // ok!
218 constexpr int diff1 = &a[2] - &a[0];
219 constexpr int diff2 = &a[1][3] - &a[1][0];
220 …constexpr int diff3 = &a[2][0] - &a[1][0]; // expected-error {{constant expression}} expected-note…
222 constexpr int diff4 = (&b + 1) - &b;
223 …constexpr int diff5 = &a[1][2].n - &a[1][0].n; // expected-error {{constant expression}} expected-…
224 constexpr int diff6 = &a[1][2].n - &a[1][2].n;
225 …constexpr int diff7 = (A*)&a[0][1] - (A*)&a[0][0]; // expected-error {{constant expression}} expec…
230 constexpr int n1 = 2 * 3 * 3 * 7 * 11 * 31 * 151 * 331; // ok
231 …constexpr int n2 = 65536 * 32768; // expected-error {{constant expression}} expected-note {{value …
232 constexpr int n3 = n1 + 1; // ok
233 …constexpr int n4 = n3 + 1; // expected-error {{constant expression}} expected-note {{value 2147483…
234 constexpr int n5 = -65536 * 32768; // ok
235 …constexpr int n6 = 3 * -715827883; // expected-error {{constant expression}} expected-note {{value…
236 constexpr int n7 = -n3 + -1; // ok
237 …constexpr int n8 = -1 + n7; // expected-error {{constant expression}} expected-note {{value -21474…
238 constexpr int n9 = n3 - 0; // ok
239 …constexpr int n10 = n3 - -1; // expected-error {{constant expression}} expected-note {{value 21474…
240 constexpr int n11 = -1 - n3; // ok
241 …constexpr int n12 = -2 - n3; // expected-error {{constant expression}} expected-note {{value -2147…
242 …constexpr int n13 = n5 + n5; // expected-error {{constant expression}} expected-note {{value -4294…
243 …constexpr int n14 = n3 - n5; // expected-error {{constant expression}} expected-note {{value 42949…
244 …constexpr int n15 = n5 * n5; // expected-error {{constant expression}} expected-note {{value 46116…
245 constexpr signed char c1 = 100 * 2; // ok expected-warning{{changes value}}
246 constexpr signed char c2 = '\x64' * '\2'; // also ok expected-warning{{changes value}}
247 constexpr long long ll1 = 0x7fffffffffffffff; // ok
248 …constexpr long long ll2 = ll1 + 1; // expected-error {{constant}} expected-note {{ 922337203685477…
249 constexpr long long ll3 = -ll1 - 1; // ok
250 …constexpr long long ll4 = ll3 - 1; // expected-error {{constant}} expected-note {{ -92233720368547…
251 …constexpr long long ll5 = ll3 * ll3; // expected-error {{constant}} expected-note {{ 8507059173023…
256 constexpr ptrdiff_t d1 = &melchizedek[0x7fffffff] - &melchizedek[0]; // ok
257 …constexpr ptrdiff_t d2 = &melchizedek[0x80000000u] - &melchizedek[0]; // expected-error {{constant…
258 constexpr ptrdiff_t d3 = &melchizedek[0] - &melchizedek[0x80000000u]; // ok
259 …constexpr ptrdiff_t d4 = &melchizedek[0] - &melchizedek[0x80000001u]; // expected-error {{constant…
268 constexpr float f1 = 1e38f * 3.4028f; // ok
269 …constexpr float f2 = 1e38f * 3.4029f; // expected-error {{constant expression}} expected-note {{fl…
270 constexpr float f3 = 1e38f / -.2939f; // ok
271 …constexpr float f4 = 1e38f / -.2938f; // expected-error {{constant expression}} expected-note {{fl…
272 …constexpr float f5 = 2e38f + 2e38f; // expected-error {{constant expression}} expected-note {{floa…
273 …constexpr float f6 = -2e38f - 2e38f; // expected-error {{constant expression}} expected-note {{flo…
274 …constexpr float f7 = 0.f / 0.f; // expected-error {{constant expression}} expected-note {{floating…
300 constexpr V() : v(1) {} in V()
303 constexpr V v; // expected-error {{non-literal type}}
305 constexpr S(int=0) : i(1), v(const_cast<volatile int&>(vi)) {} in S()
306 constexpr S(const S &s) : i(2), v(const_cast<volatile int&>(vi)) {} in S()
310 constexpr S s; // ok
311 constexpr volatile S vs; // expected-note {{here}}
312 constexpr const volatile S &vrs = s; // ok
323 constexpr volatile S f() { return S(); } in f()
341 union U { int a, b; } constexpr u = U();
343 constexpr const int *bp = &u.b;
344 …constexpr int b = *bp; // expected-error {{constant expression}} expected-note {{read of member 'b…
347 constexpr const int *pua = &pu.a;
348 constexpr const int *pub = &pu.b;
349 constexpr U pu = { .b = 1 }; // expected-warning {{C99 feature}}
350 …constexpr const int a2 = *pua; // expected-error {{constant expression}} expected-note {{read of m…
351 constexpr const int b2 = *pub; // ok
362 constexpr int e = 42;
365 constexpr int &h(); // expected-note {{here}}
367 constexpr int &j() { return b; } in j()
389 constexpr S s { 16 };
398 constexpr S s { 16 };
434 constexpr S *p = 0;
435 …constexpr const std::type_info &ti1 = typeid(*p); // expected-error {{must be initialized by a con…
438 constexpr const std::type_info &ti2 = typeid(t);
455 constexpr int *p = &a, *q = &b;
460 constexpr bool u1 = p < q; // expected-error {{constant expression}}
461 constexpr bool u2 = p > q; // expected-error {{constant expression}}
462 constexpr bool u3 = p <= q; // expected-error {{constant expression}}
463 constexpr bool u4 = p >= q; // expected-error {{constant expression}}
464 constexpr bool u5 = p < 0; // expected-error {{constant expression}}
465 constexpr bool u6 = p <= 0; // expected-error {{constant expression}}
466 constexpr bool u7 = p > 0; // expected-error {{constant expression}}
467 constexpr bool u8 = p >= 0; // expected-error {{constant expression}}
468 constexpr bool u9 = 0 < q; // expected-error {{constant expression}}
469 constexpr bool u10 = 0 <= q; // expected-error {{constant expression}}
470 constexpr bool u11 = 0 > q; // expected-error {{constant expression}}
471 constexpr bool u12 = 0 >= q; // expected-error {{constant expression}}
474 constexpr void (*pf)() = &f, (*pg)() = &g;
475 constexpr bool u13 = pf < pg; // expected-error {{constant expression}}
476 constexpr bool u14 = pf == pg;
482 constexpr A() : a(0), b(0) {} in A()
484 …constexpr bool cmp() const { return &a < &b; } // expected-note {{comparison of address of fields … in cmp()
492 …constexpr bool cmp() const { return &a.a < &b.a; } // expected-note {{comparison of address of fie… in cmp()
514 …constexpr bool base1 = &e.c[0] < &e.d; // expected-error {{constant expression}} expected-note {{c…
515 …constexpr bool base2 = &e.c[1] < &e.e.f; // expected-error {{constant expression}} expected-note {…
516 …constexpr bool base3 = &e.e.f < &e.d; // expected-error {{constant expression}} expected-note {{co…
522 constexpr void *null = 0;
523 constexpr void *pv = (void*)&s.a;
524 constexpr void *qv = (void*)&s.b;
525 constexpr bool v1 = null < 0;
526 constexpr bool v2 = null < pv; // expected-error {{constant expression}}
527 constexpr bool v3 = null == pv; // ok
528 constexpr bool v4 = qv == pv; // ok
529 …constexpr bool v5 = qv >= pv; // expected-error {{constant expression}} expected-note {{unequal po…
530 constexpr bool v6 = qv > null; // expected-error {{constant expression}}
531 constexpr bool v7 = qv <= (void*)&s.b; // ok
532 …constexpr bool v8 = qv > (void*)&s.a; // expected-error {{constant expression}} expected-note {{un…
544 constexpr Literal(const char *name) : name(name) {} in Literal()
548 constexpr Expr(Literal l) : IsLiteral(true), l(l) {} in Expr()
556 constexpr MulEq(Expr a, Expr b) : LHS(a), RHS(b) {} in MulEq()
560 constexpr MulEq operator*=(Expr a, Expr b) { return MulEq(a, b); } in operator *=()
603 constexpr intptr_t f(intptr_t x) { in f()
609 …constexpr intptr_t i = f((intptr_t)&foo - 10); // expected-error{{constexpr variable 'i' must be i…