Home | History | Annotate | Download | only in SemaCXX

Lines Matching defs:static_assert

6 static_assert(++x, "test"); // expected-error {{not an integral constant expression}}
7 static_assert(false, "test"); // expected-error {{test}}
41 static_assert((void*)p != (void*)q, "");
42 static_assert((A*)p == (A*)q, "");
43 static_assert((Aa*)p != (Aa*)q, "");
47 static_assert((void*)&pp != (void*)&qq, "");
48 static_assert(&(A&)pp == &(A&)qq, "");
49 static_assert(&(Aa&)pp != &(Aa&)qq, "");
54 static_assert(v == w, "");
55 static_assert(v == x, "");
57 static_assert((U*)&d == p, "");
58 static_assert((U*)&d == q, "");
59 static_assert((U*)&d == v, "");
60 static_assert((U*)&d == w, "");
61 static_assert((U*)&d == x, "");
68 static_assert((X*)(Y1*)&z != (X*)(Y2*)&z, "");
117 static_assert(wme.A == 42, "");
129 static_assert(Sum() == 0, "");
130 static_assert(Sum(1) == 1, "");
131 static_assert(Sum(1, four) == 5, "");
132 static_assert(Sum(1, eight, &twentyseven) == 36, "");
133 static_assert(Sum(1, 2, &four, eight) == 15, "");
141 static_assert(F(0) == 0, "");
142 static_assert(F(1, 0) == 1, "");
143 static_assert(F(2, "test") == 2, "");
144 static_assert(F(3, &F) == 3, "");
146 static_assert(F(4, k) == 3, ""); // expected-error {{constant expression}} expected-note {{read of non-const variable 'k'}}
152 static_assert(fib(11) == 89, "");
161 static_assert(gcd(1749237, 5628959) == 7, "");
181 static_assert(S::f(19) == 800, "");
182 static_assert(s.f(19) == 800, "");
183 static_assert(n == 800, "");
197 static_assert(MaybeReturnJunk(false, 0) == 42, ""); // ok
203 static_assert(MaybeReturnNonstaticRef(false, 0) == 42, ""); // ok
215 static_assert(GrabCallersArgument(false, 1, 2) == 1, "");
216 static_assert(GrabCallersArgument(true, 4, 8) == 8, "");
227 static_assert(f(23, &x, &y, &z) == 788, "");
232 static_assert(g(23, x, y, z) == 788, "");
247 static_assert(1 + Apply(Select(4), 5) + Apply(Select(3), 7) == 42, "");
256 static_assert(&x == &y, "false"); // expected-error {{false}}
257 static_assert(&x != &y, "");
266 static_assert(&s.x == &s.y, "false"); // expected-error {{false}}
267 static_assert(&s.x != &s.y, "");
268 static_assert(&s.x <= &s.y, "");
269 static_assert(&s.x >= &s.y, "false"); // expected-error {{false}}
270 static_assert(&s.x < &s.y, "");
271 static_assert(&s.x > &s.y, "false"); // expected-error {{false}}
273 static_assert(0 == &y, "false"); // expected-error {{false}}
274 static_assert(0 != &y, "");
280 static_assert(&x == 0, "false"); // expected-error {{false}}
281 static_assert(&x != 0, "");
287 static_assert(&x == &x, "");
288 static_assert(&x != &x, "false"); // expected-error {{false}}
289 static_assert(&x <= &x, "");
290 static_assert(&x >= &x, "");
291 static_assert(&x < &x, "false"); // expected-error {{false}}
292 static_assert(&x > &x, "false"); // expected-error {{false}}
325 static_assert(0 != "foo", "");
337 static_assert(n, "");
338 static_assert(!same(4, 4), "");
339 static_assert(same(n, n), "");
340 static_assert(sameTemporary(9), "");
355 static_assert(MangleChars("constexpr!") == 1768383, "");
356 static_assert(MangleChars(u8"constexpr!") == 1768383, "");
357 static_assert(MangleChars(L"constexpr!") == 1768383, "");
358 static_assert(MangleChars(u"constexpr!") == 1768383, "");
359 static_assert(MangleChars(U"constexpr!") == 1768383, "");
368 static_assert(*p == 's', "");
379 static_assert(*max == 'z', "");
380 static_assert(max == str + 38, "");
382 static_assert(strcmp_ce("hello world", "hello world") == 0, "");
383 static_assert(strcmp_ce("hello world", "hello clang") > 0, "");
384 static_assert(strcmp_ce("constexpr", "test") < 0, "");
385 static_assert(strcmp_ce("", " ") < 0, "");
397 static_assert(t.c[0] == 'f', "");
398 static_assert(t.c[1] == 'o', "");
399 static_assert(t.c[2] == 'o', "");
400 static_assert(t.c[3] == 0, "");
401 static_assert(t.c[4] == 0, "");
402 static_assert(t.c[5] == 0, "");
403 static_assert(t.c[6] == 0, ""); // expected-error {{constant expression}} expected-note {{one-past-the-end}}
409 static_assert(u.chars[2] == L's', "");
415 static_assert(V().c[1] == "i"[0], "");
429 static_assert(sum_xs == 15, "");
443 static_assert(InnerProduct == 35, "");
447 static_assert(DiffProd == 8, "");
448 static_assert(ZipFoldR(SubMul, 3, xs+3, ys+3, 1), ""); // \
460 static_assert(zs[0][0][0][0] == 1, "");
461 static_assert(zs[1][1][1][1] == 16, "");
462 static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
463 static_assert((&zs[0][0][0][2])[-1] == 2, "");
464 static_assert(**(**(zs + 1) + 1) == 11, "");
465 static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][-1] + 1) == 11, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1 of array of 2 elements in a constant expression}}
466 static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2) == 11, "");
472 static_assert(fail(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2)) == 11, ""); // \
473 expected-error {{static_assert expression is not an integral constant expression}} \
483 static_assert(SumNonzero(arr) == 6, "");
484 static_assert(CountZero(arr, arr + 40) == 36, "");
495 static_assert(ArrayRVal().elems[3].f() == 0, "");
501 static_assert(selfref[0][0][0] == 1, "");
502 static_assert(selfref[0][0][1] == 2, "");
503 static_assert(selfref[0][1][0] == 1, "");
504 static_assert(selfref[0][1][1] == 2, "");
505 static_assert(selfref[1][0][0] == 1, "");
506 static_assert(selfref[1][0][1] == 3, "");
507 static_assert(selfref[1][1][0] == 0, "");
508 static_assert(selfref[1][1][1] == 0, "");
512 static_assert(TDCArray{}[1][1].n == 0, "");
516 static_assert(NATDCArray{}[1][1].n == 0, "");
545 static_assert(fn(A(4,5)) == 9, "");
556 static_assert(D().c.n == 42, "");
566 static_assert(e2.p == &e2.p, "");
568 static_assert(e3.p == &e3.p, "");
592 static_assert(g.t.u1.a == 42, ""); // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}}
593 static_assert(g.t.u1.b == 42, "");
594 static_assert(g.t.u2.c == 42, "");
595 static_assert(g.t.u2.d == 42, ""); // expected-error {{constant expression}} expected-note {{read of member 'd' of union with active member 'c'}}
608 static_assert(S(15, &global).b == 15, "");
613 static_assert(CheckS(S(27, &global)), "");
623 static_assert(k == 0x007a7978, "");
636 static_assert(strcmp_ce(&agg1.c, "hello") == 0, "");
637 static_assert(agg1.n == 0, "");
638 static_assert(agg1.d == 0.0, "");
639 static_assert(agg1.arr[-1] == 0, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1}}
640 static_assert(agg1.arr[0] == 0, "");
641 static_assert(agg1.arr[4] == 0, "");
642 static_assert(agg1.arr[5] == 0, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end}}
643 static_assert(agg1.p == nullptr, "");
646 static_assert(uc[0] == 'f', "");
647 static_assert(uc[3] == 0, "");
659 static_assert(d.a == 3, "");
686 static_assert(derived.a == 76, "");
687 static_assert(derived.b[2] == 's', "");
688 static_assert(derived.c == 76 + 'e', "");
689 static_assert(derived.q == 123, "");
690 static_assert(derived.r == 76, "");
691 static_assert(&derived.r == &derived.a, "");
693 static_assert(!(derived == base), "");
694 static_assert(derived == base2, "");
698 static_assert(&bot1 != &bot2, "");
702 static_assert(&pb1 != &pb2, "");
703 static_assert(pb1 == &bot1, "");
704 static_assert(pb2 == &bot2, "");
709 static_assert(&ok2 == &derived, "");
714 static_assert(pok2 == &derived, "");
715 static_assert(&ok2 == pok2, "");
716 static_assert((Base2*)(Derived*)(Base*)pb1 == pok2, "");
717 static_assert((Derived*)(Base*)pb1 == (Derived*)pok2, "");
720 static_assert((Bottom*)nullB == 0, "");
721 static_assert((Derived*)nullB == 0, "");
722 static_assert((void*)(Bottom*)nullB == (void*)(Derived*)nullB, "");
727 static_assert(nullB == (1 - 1), "");
747 static_assert(S(5) == 11, "");
748 static_assert(check(S(5), 11), "");
755 static_assert(X() == 0, "");
782 static_assert(T(3).f() == 3, "");
788 static_assert(f(T(5)) == 5, "");
791 static_assert(b(0), "");
803 static_assert(u[0].a == 0, "");
804 static_assert(u[0].b, ""); // expected-error {{constant expression}} expected-note {{read of member 'b' of union with active member 'a'}}
805 static_assert(u[1].b == 1, "");
806 static_assert((&u[1].b)[1] == 2, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
807 static_assert(*(&(u[1].b) + 1 + 1) == 3, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element 2 of non-array object}}
808 static_assert((&(u[1]) + 1 + 1)->b == 3, "");
811 static_assert(v.a == 0, "");
819 static_assert(y.a == 42, "");
820 static_assert(y.b == 42, ""); // expected-error {{constant expression}} expected-note {{'b' of union with active member 'a'}}
831 static_assert(A(5).*&A::n == 5, "");
832 static_assert((&a)->*&A::n == 7, "");
833 static_assert((A(8).*&A::f)() == 11, "");
834 static_assert(((&a)->*&A::f)() == 10, "");
842 static_assert(B(4, 11).*&A::n == 4, "");
843 static_assert(B(4, 11).*&B::m == 11, "");
844 static_assert(B(4, 11).*(int(A::*))&B::m == 11, "");
845 static_assert((&b)->*&A::n == 9, "");
846 static_assert((&b)->*&B::m == 13, "");
847 static_assert((&b)->*(int(A::*))&B::m == 13, "");
848 static_assert((B(4, 11).*&A::f)() == 7, "");
849 static_assert((B(4, 11).*&B::g)() == 16, "");
850 static_assert((B(4, 11).*(int(A::*)()const)&B::g)() == 16, "");
851 static_assert(((&b)->*&A::f)() == 12, "");
852 static_assert(((&b)->*&B::g)() == 23, "");
853 static_assert(((&b)->*(int(A::*)()const)&B::g)() == 23, "");
875 static_assert((s.*&S::f)() == 2, "");
876 static_assert((s.*s.pf)() == 2, "");
878 static_assert(pf == &S::f, "");
879 static_assert(pf == s.*&S::pf, "");
880 static_assert(pm == &S::m, "");
881 static_assert(pm != pn, "");
882 static_assert(s.pn != pn, "");
883 static_assert(s.pn == pm, "");
884 static_assert(pg != nullptr, "");
885 static_assert(pf != nullptr, "");
886 static_assert((int S::*)nullptr == nullptr, "");
887 static_assert(pg == pg, ""); // expected-error {{constant expression}} expected-note {{comparison of pointer to virtual member function 'g' has unspecified value}}
888 static_assert(pf != pg, ""); // expected-error {{constant expression}} expected-note {{comparison of pointer to virtual member function 'g' has unspecified value}}
898 static_assert(&(t17.*deepn) == &t17.n, "");
899 static_assert(deepn == &T<2>::n, "");
903 static_assert(&(t30.*deepm) == &t30.m, "");
904 static_assert(deepm == &T<50>::m, "");
905 static_assert(deepm != deepn, "");
910 static_assert(&(p17_5->*(int(T<3>::*))deepn) == &t17.n, "");
911 static_assert(&(p17_13->*deepn) == &t17.n, "");
917 static_assert(&(p30_5->*(int(T<3>::*))deepn) == &t30.n, "");
918 static_assert(&(p30_13->*deepn) == &t30.n, "");
919 static_assert(&(p30_23->*deepn) == &t30.n, "");
920 static_assert(&(p30_5->*(int(T<2>::*))deepm) == &t30.m, "");
921 static_assert(&(((T<17>*)p30_13)->*deepm) == &t30.m, "");
922 static_assert(&(p30_23->*deepm) == &t30.m, "");
927 static_assert(&Mid<0>::n == &Mid<1>::n, "");
928 static_assert((int Derived::*)(int Mid<0>::*)&Mid<0>::n !=
930 static_assert(&Mid<0>::n == (int Mid<0>::*)&Base::n, "");
947 static_assert(pb3 == pd3, "");
965 static_assert(pd6 == &a[6], "");
976 static_assert((pb9->*pfb)() == &a[9].n, "");
1008 static_assert(complex(1,0).real() == 1, "");
1009 static_assert(complex(1,0).imag() == 0, "");
1010 static_assert(((complex)1).imag() == 0, "");
1011 static_assert(k.real() == 34, "");
1012 static_assert(k.imag() == 12, "");
1013 static_assert(k - 34 == 12*i, "");
1014 static_assert((complex)1 == complex(1), "");
1015 static_assert((complex)1 != complex(0, 1), "");
1016 static_assert(complex(1) == complex(1), "");
1017 static_assert(complex(1) != complex(0, 1), "");
1019 static_assert(makeComplex(1,0) == complex(1), "");
1020 static_assert(makeComplex(1,0) != complex(0, 1), "");
1028 static_assert((complex_wrap)1 == complex(1), "");
1029 static_assert((complex)1 != complex_wrap(0, 1), "");
1030 static_assert(complex(1) == complex_wrap(1), "");
1031 static_assert(complex_wrap(1) != complex(0, 1), "");
1035 static_assert(makeComplexWrap(1,0) == complex(1), "");
1036 static_assert(makeComplexWrap(1,0) != complex(0, 1), "");
1043 static_assert(B().x == 3, ""); // expected-error {{constant expression}} expected-note {{non-literal type 'PR11595::B' cannot be used in a constant expression}}
1107 static_assert(&t2r + 1 == &t2i, "");
1108 static_assert(t2r == 1.0, "");
1109 static_assert(t2i == 2.0, "");
1111 static_assert(t2p[-1] == 0.0, ""); // expected-error {{constant expr}} expected-note {{cannot refer to element -1 of array of 2 elements}}
1112 static_assert(t2p[0] == 1.0, "");
1113 static_assert(t2p[1] == 2.0, "");
1114 static_assert(t2p[2] == 0.0, ""); // expected-error {{constant expr}} expected-note {{one-past-the-end pointer}}
1115 static_assert(t2p[3] == 0.0, ""); // expected-error {{constant expr}} expected-note {{cannot refer to element 3 of array of 2 elements}}
1123 static_assert(__real test6 == 5, "");
1124 static_assert(__imag test6 == 6, "");
1125 static_assert(&__imag test6 == &__real test6 + 1, "");
1178 static_assert(s1.a == 1, "");
1179 static_assert(s1.b == 2, "");
1180 static_assert(s1.c == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
1181 static_assert(s1.d == 3, "");
1182 static_assert(s1.e == 4, "");
1183 static_assert(s1.f == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
1185 static_assert(s2.a == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
1186 static_assert(s2.b == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
1187 static_assert(s2.c == 5, "");
1188 static_assert(s2.d == 6, "");
1189 static_assert(s2.e == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
1190 static_assert(s2.f == 7, "");
1225 static_assert(m == 123, "");
1254 static_assert(LastNonzero(begin(arr1), end(arr1)) == 4, "");
1257 static_assert(LastNonzero(begin(arr2), end(arr2)) == 5, "");
1268 static_assert(LastNonzero(begin(arr3), end(arr3)) == 2, "");
1322 static_assert(!__is_literal_type(Q), "");
1323 static_assert(!__is_literal_type(R), "");
1324 static_assert(!__is_literal_type(S), "");
1325 static_assert(!__is_literal_type(T), "");
1326 static_assert(!__is_literal_type(U), "");
1361 static_assert(S{}.t == 0, "");
1371 static_assert(x[0].m == 4, "");
1372 static_assert(x[1].m == 5, "");
1373 static_assert(x[2].m == 6, "");
1390 static_assert(f(a).v == 4, "");
1421 static_assert(get(arr, 1) == 1, "");
1422 static_assert(get(arr, 4) == 4, "");
1423 static_assert(get(arr, 0) == 4, ""); // expected-error{{not an integral constant expression}} \