Lines Matching refs: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, "");
85 static_assert(n9 == 123, "");
124 static_assert(wme.A == 42, "");
136 static_assert(Sum() == 0, "");
137 static_assert(Sum(1) == 1, "");
138 static_assert(Sum(1, four) == 5, "");
139 static_assert(Sum(1, eight, &twentyseven) == 36, "");
140 static_assert(Sum(1, 2, &four, eight) == 15, "");
148 static_assert(F(0) == 0, "");
149 static_assert(F(1, 0) == 1, "");
150 static_assert(F(2, "test") == 2, "");
151 static_assert(F(3, &F) == 3, "");
153 static_assert(F(4, k) == 3, ""); // expected-error {{constant expression}} expected-note {{read of …
159 static_assert(fib(11) == 89, "");
168 static_assert(gcd(1749237, 5628959) == 7, "");
188 static_assert(S::f(19) == 800, "");
189 static_assert(s.f(19) == 800, "");
190 static_assert(n == 800, "");
204 static_assert(MaybeReturnJunk(false, 0) == 42, ""); // ok
210 static_assert(MaybeReturnNonstaticRef(false, 0) == 42, ""); // ok
222 static_assert(GrabCallersArgument(false, 1, 2) == 1, "");
223 static_assert(GrabCallersArgument(true, 4, 8) == 8, "");
234 static_assert(f(23, &x, &y, &z) == 788, "");
239 static_assert(g(23, x, y, z) == 788, "");
254 static_assert(1 + Apply(Select(4), 5) + Apply(Select(3), 7) == 42, "");
263 static_assert(&x == &y, "false"); // expected-error {{false}}
264 static_assert(&x != &y, "");
273 static_assert(&s.x == &s.y, "false"); // expected-error {{false}}
274 static_assert(&s.x != &s.y, "");
275 static_assert(&s.x <= &s.y, "");
276 static_assert(&s.x >= &s.y, "false"); // expected-error {{false}}
277 static_assert(&s.x < &s.y, "");
278 static_assert(&s.x > &s.y, "false"); // expected-error {{false}}
280 static_assert(0 == &y, "false"); // expected-error {{false}}
281 static_assert(0 != &y, "");
287 static_assert(&x == 0, "false"); // expected-error {{false}}
288 static_assert(&x != 0, "");
294 static_assert(&x == &x, "");
295 static_assert(&x != &x, "false"); // expected-error {{false}}
296 static_assert(&x <= &x, "");
297 static_assert(&x >= &x, "");
298 static_assert(&x < &x, "false"); // expected-error {{false}}
299 static_assert(&x > &x, "false"); // expected-error {{false}}
332 static_assert(0 != "foo", "");
344 static_assert(n, "");
345 static_assert(!same(4, 4), "");
346 static_assert(same(n, n), "");
347 static_assert(sameTemporary(9), "");
353 static_assert(&b1.a1 != &b1.a2, "");
354 static_assert(&b1.a1.r != &b1.a2.r, ""); // expected-error {{constant expression}} expected-note {{…
357 static_assert(&b1 != &b2, "");
358 static_assert(&b1.a1 != &b2.a1, ""); // expected-error {{constant expression}} expected-note {{outs…
368 static_assert(&b4 != &b2, "");
402 static_assert(MangleChars("constexpr!") == 1768383, "");
403 static_assert(MangleChars(u8"constexpr!") == 1768383, "");
404 static_assert(MangleChars(L"constexpr!") == 1768383, "");
405 static_assert(MangleChars(u"constexpr!") == 1768383, "");
406 static_assert(MangleChars(U"constexpr!") == 1768383, "");
415 static_assert(*p == 's', "");
426 static_assert(*max == 'z', "");
427 static_assert(max == str + 38, "");
429 static_assert(strcmp_ce("hello world", "hello world") == 0, "");
430 static_assert(strcmp_ce("hello world", "hello clang") > 0, "");
431 static_assert(strcmp_ce("constexpr", "test") < 0, "");
432 static_assert(strcmp_ce("", " ") < 0, "");
444 static_assert(t.c[0] == 'f', "");
445 static_assert(t.c[1] == 'o', "");
446 static_assert(t.c[2] == 'o', "");
447 static_assert(t.c[3] == 0, "");
448 static_assert(t.c[4] == 0, "");
449 static_assert(t.c[5] == 0, "");
450 static_assert(t.c[6] == 0, ""); // expected-error {{constant expression}} expected-note {{one-past-…
456 static_assert(u.chars[2] == L's', "");
462 static_assert(V().c[1] == "i"[0], "");
467 static_assert(a[0] == 'f', "");
468 static_assert(b[1] == 'o', "");
469 static_assert(c[2] == 'o', "");
470 static_assert(d[0] == 'f', "");
471 static_assert(e[1] == 'o', "");
472 static_assert(f[2] == 'o', "");
473 static_assert(f[5] == 0, "");
474 …static_assert(f[6] == 0, ""); // expected-error {{constant expression}} expected-note {{one-past-t…
489 static_assert(sum_xs == 15, "");
503 static_assert(InnerProduct == 35, "");
507 static_assert(DiffProd == 8, "");
508 static_assert(ZipFoldR(SubMul, 3, xs+3, ys+3, 1), ""); // \
520 static_assert(zs[0][0][0][0] == 1, "");
521 static_assert(zs[1][1][1][1] == 16, "");
522 static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant expression}} expected-note {{r…
523 static_assert((&zs[0][0][0][2])[-1] == 2, "");
524 static_assert(**(**(zs + 1) + 1) == 11, "");
525 static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][-1] + 1) == 11, ""); // expected-error {{…
526 static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2) == 11, "");
532 static_assert(fail(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2)) == 11, ""); // \
533 expected-error {{static_assert expression is not an integral constant expression}} \
543 static_assert(SumNonzero(arr) == 6, "");
544 static_assert(CountZero(arr, arr + 40) == 36, "");
555 static_assert(ArrayRVal().elems[3].f() == 0, "");
561 static_assert(selfref[0][0][0] == 1, "");
562 static_assert(selfref[0][0][1] == 2, "");
563 static_assert(selfref[0][1][0] == 1, "");
564 static_assert(selfref[0][1][1] == 2, "");
565 static_assert(selfref[1][0][0] == 1, "");
566 static_assert(selfref[1][0][1] == 3, "");
567 static_assert(selfref[1][1][0] == 0, "");
568 static_assert(selfref[1][1][1] == 0, "");
572 static_assert(TDCArray{}[1][1].n == 0, "");
576 static_assert(NATDCArray{}[1][1].n == 0, "");
605 static_assert(fn(A(4,5)) == 9, "");
616 static_assert(D().c.n == 42, "");
626 static_assert(e2.p == &e2.p, "");
628 static_assert(e3.p == &e3.p, "");
652 static_assert(g.t.u1.a == 42, ""); // expected-error {{constant expression}} expected-note {{read o…
653 static_assert(g.t.u1.b == 42, "");
654 static_assert(g.t.u2.c == 42, "");
655 static_assert(g.t.u2.d == 42, ""); // expected-error {{constant expression}} expected-note {{read o…
668 static_assert(S(15, &global).b == 15, "");
673 static_assert(CheckS(S(27, &global)), "");
683 static_assert(k == 0x007a7978, "");
696 static_assert(strcmp_ce(&agg1.c, "hello") == 0, "");
697 static_assert(agg1.n == 0, "");
698 static_assert(agg1.d == 0.0, "");
699 static_assert(agg1.arr[-1] == 0, ""); // expected-error {{constant expression}} expected-note {{can…
700 static_assert(agg1.arr[0] == 0, "");
701 static_assert(agg1.arr[4] == 0, "");
702 static_assert(agg1.arr[5] == 0, ""); // expected-error {{constant expression}} expected-note {{read…
703 static_assert(agg1.p == nullptr, "");
706 static_assert(uc[0] == 'f', "");
707 static_assert(uc[3] == 0, "");
719 static_assert(d.a == 3, "");
746 static_assert(derived.a == 76, "");
747 static_assert(derived.b[2] == 's', "");
748 static_assert(derived.c == 76 + 'e', "");
749 static_assert(derived.q == 123, "");
750 static_assert(derived.r == 76, "");
751 static_assert(&derived.r == &derived.a, "");
753 static_assert(!(derived == base), "");
754 static_assert(derived == base2, "");
758 static_assert(&bot1 != &bot2, "");
762 static_assert(&pb1 != &pb2, "");
763 static_assert(pb1 == &bot1, "");
764 static_assert(pb2 == &bot2, "");
769 static_assert(&ok2 == &derived, "");
774 static_assert(pok2 == &derived, "");
775 static_assert(&ok2 == pok2, "");
776 static_assert((Base2*)(Derived*)(Base*)pb1 == pok2, "");
777 static_assert((Derived*)(Base*)pb1 == (Derived*)pok2, "");
783 static_assert((Bottom*)nullB == 0, "");
784 static_assert((Derived*)nullB == 0, "");
785 static_assert((void*)(Bottom*)nullB == (void*)(Derived*)nullB, "");
793 static_assert(nullB1 == (1 - 1), ""); // expected-error {{comparison between pointer and integer}}
814 static_assert(S(5) == 11, "");
815 static_assert(check(S(5), 11), "");
822 static_assert(X() == 0, "");
837 static_assert(z == 0, ""); in h()
864 static_assert(S().f(), ""); // expected-error {{constant expression}} expected-note {{in call to '&…
865 static_assert(S().g(), ""); // expected-error {{constant expression}} expected-note {{in call to '&…
866 static_assert(T(3).f() == 3, "");
867 static_assert(T(4).g() == 4, "");
873 static_assert(f(T(5)) == 5, "");
876 static_assert(b(0), "");
894 static_assert(u[0].a == 0, "");
895 static_assert(u[0].b, ""); // expected-error {{constant expression}} expected-note {{read of member…
896 static_assert(u[1].b == 1, "");
897 static_assert((&u[1].b)[1] == 2, ""); // expected-error {{constant expression}} expected-note {{rea…
898 static_assert(*(&(u[1].b) + 1 + 1) == 3, ""); // expected-error {{constant expression}} expected-no…
899 static_assert((&(u[1]) + 1 + 1)->b == 3, "");
902 static_assert(v.a == 0, "");
910 static_assert(y.a == 42, "");
911 static_assert(y.b == 42, ""); // expected-error {{constant expression}} expected-note {{'b' of unio…
922 static_assert(A(5).*&A::n == 5, "");
923 static_assert((&a)->*&A::n == 7, "");
924 static_assert((A(8).*&A::f)() == 11, "");
925 static_assert(((&a)->*&A::f)() == 10, "");
933 static_assert(B(4, 11).*&A::n == 4, "");
934 static_assert(B(4, 11).*&B::m == 11, "");
935 static_assert(B(4, 11).*(int(A::*))&B::m == 11, "");
936 static_assert((&b)->*&A::n == 9, "");
937 static_assert((&b)->*&B::m == 13, "");
938 static_assert((&b)->*(int(A::*))&B::m == 13, "");
939 static_assert((B(4, 11).*&A::f)() == 7, "");
940 static_assert((B(4, 11).*&B::g)() == 16, "");
941 static_assert((B(4, 11).*(int(A::*)()const)&B::g)() == 16, "");
942 static_assert(((&b)->*&A::f)() == 12, "");
943 static_assert(((&b)->*&B::g)() == 23, "");
944 static_assert(((&b)->*(int(A::*)()const)&B::g)() == 23, "");
966 static_assert((s.*&S::f)() == 2, "");
967 static_assert((s.*s.pf)() == 2, "");
969 static_assert(pf == &S::f, "");
970 static_assert(pf == s.*&S::pf, "");
971 static_assert(pm == &S::m, "");
972 static_assert(pm != pn, "");
973 static_assert(s.pn != pn, "");
974 static_assert(s.pn == pm, "");
975 static_assert(pg != nullptr, "");
976 static_assert(pf != nullptr, "");
977 static_assert((int S::*)nullptr == nullptr, "");
978 …static_assert(pg == pg, ""); // expected-error {{constant expression}} expected-note {{comparison …
979 …static_assert(pf != pg, ""); // expected-error {{constant expression}} expected-note {{comparison …
989 static_assert(&(t17.*deepn) == &t17.n, "");
990 static_assert(deepn == &T<2>::n, "");
994 static_assert(&(t30.*deepm) == &t30.m, "");
995 static_assert(deepm == &T<50>::m, "");
996 static_assert(deepm != deepn, "");
1001 static_assert(&(p17_5->*(int(T<3>::*))deepn) == &t17.n, "");
1002 static_assert(&(p17_13->*deepn) == &t17.n, "");
1008 static_assert(&(p30_5->*(int(T<3>::*))deepn) == &t30.n, "");
1009 static_assert(&(p30_13->*deepn) == &t30.n, "");
1010 static_assert(&(p30_23->*deepn) == &t30.n, "");
1011 static_assert(&(p30_5->*(int(T<2>::*))deepm) == &t30.m, "");
1012 static_assert(&(((T<17>*)p30_13)->*deepm) == &t30.m, "");
1013 static_assert(&(p30_23->*deepm) == &t30.m, "");
1018 static_assert(&Mid<0>::n == &Mid<1>::n, "");
1019 static_assert((int Derived::*)(int Mid<0>::*)&Mid<0>::n !=
1021 static_assert(&Mid<0>::n == (int Mid<0>::*)&Base::n, "");
1038 static_assert(pb3 == pd3, "");
1056 static_assert(pd6 == &a[6], "");
1067 static_assert((pb9->*pfb)() == &a[9].n, "");
1099 static_assert(complex(1,0).real() == 1, "");
1100 static_assert(complex(1,0).imag() == 0, "");
1101 static_assert(((complex)1).imag() == 0, "");
1102 static_assert(k.real() == 34, "");
1103 static_assert(k.imag() == 12, "");
1104 static_assert(k - 34 == 12*i, "");
1105 static_assert((complex)1 == complex(1), "");
1106 static_assert((complex)1 != complex(0, 1), "");
1107 static_assert(complex(1) == complex(1), "");
1108 static_assert(complex(1) != complex(0, 1), "");
1110 static_assert(makeComplex(1,0) == complex(1), "");
1111 static_assert(makeComplex(1,0) != complex(0, 1), "");
1119 static_assert((complex_wrap)1 == complex(1), "");
1120 static_assert((complex)1 != complex_wrap(0, 1), "");
1121 static_assert(complex(1) == complex_wrap(1), "");
1122 static_assert(complex_wrap(1) != complex(0, 1), "");
1126 static_assert(makeComplexWrap(1,0) == complex(1), "");
1127 static_assert(makeComplexWrap(1,0) != complex(0, 1), "");
1134 …static_assert(B().x == 3, ""); // expected-error {{constant expression}} expected-note {{non-lite…
1198 static_assert(&t2r + 1 == &t2i, "");
1199 static_assert(t2r == 1.0, "");
1200 static_assert(t2i == 2.0, "");
1202 …static_assert(t2p[-1] == 0.0, ""); // expected-error {{constant expr}} expected-note {{cannot refe…
1203 static_assert(t2p[0] == 1.0, "");
1204 static_assert(t2p[1] == 2.0, "");
1205 …static_assert(t2p[2] == 0.0, ""); // expected-error {{constant expr}} expected-note {{one-past-the…
1206 …static_assert(t2p[3] == 0.0, ""); // expected-error {{constant expr}} expected-note {{cannot refer…
1214 static_assert(__real test6 == 5, "");
1215 static_assert(__imag test6 == 6, "");
1216 static_assert(&__imag test6 == &__real test6 + 1, "");
1231 static_assert(d1 == 0.5, "");
1232 static_assert(d3 == 3.0, "");
1240 static_assert(testVar.value == -1, "");
1294 static_assert(s1.a == 1, "");
1295 static_assert(s1.b == 2, "");
1296 …static_assert(s1.c == 0, ""); // expected-error {{constant expression}} expected-note {{union with…
1297 static_assert(s1.d == 3, "");
1298 static_assert(s1.e == 4, "");
1299 …static_assert(s1.f == 0, ""); // expected-error {{constant expression}} expected-note {{union with…
1301 …static_assert(s2.a == 0, ""); // expected-error {{constant expression}} expected-note {{union with…
1302 …static_assert(s2.b == 0, ""); // expected-error {{constant expression}} expected-note {{union with…
1303 static_assert(s2.c == 5, "");
1304 static_assert(s2.d == 6, "");
1305 …static_assert(s2.e == 0, ""); // expected-error {{constant expression}} expected-note {{union with…
1306 static_assert(s2.f == 7, "");
1384 static_assert(m == 123, "");
1405 static_assert(j == 1, "");
1428 static_assert(LastNonzero(begin(arr1), end(arr1)) == 4, "");
1431 static_assert(LastNonzero(begin(arr2), end(arr2)) == 5, "");
1442 static_assert(LastNonzero(begin(arr3), end(arr3)) == 2, "");
1503 static_assert(!__is_literal_type(Q), "");
1504 static_assert(!__is_literal_type(R), "");
1505 static_assert(!__is_literal_type(S), "");
1506 static_assert(!__is_literal_type(T), "");
1507 static_assert(!__is_literal_type(U), "");
1542 static_assert(S{}.t == 0, "");
1552 static_assert(x[0].m == 4, "");
1553 static_assert(x[1].m == 5, "");
1554 static_assert(x[2].m == 6, "");
1571 static_assert(f(a).v == 4, "");
1602 static_assert(get(arr, 1) == 1, "");
1603 static_assert(get(arr, 4) == 4, "");
1604 static_assert(get(arr, 0) == 4, ""); // expected-error{{not an integral constant expression}} \
1647 static_assert(a[0].p == &a[0].p, "");
1648 static_assert(a[9].p == &a[9].p, "");
1649 static_assert(a[0].p != &a[9].p, "");
1650 static_assert(a[9].p != &a[0].p, "");
1653 static_assert(b[0].p == &b[0].p, "");
1654 static_assert(b[9].p == &b[9].p, "");
1655 static_assert(b[0].p != &b[9].p, "");
1656 static_assert(b[9].p != &b[0].p, "");
1715 static_assert(sum({1, 2, 3, 4, 5}) == 15, "");
1717 static_assert(*std::initializer_list<int>{1, 2, 3}.begin() == 1, "");
1718 static_assert(std::initializer_list<int>{1, 2, 3}.begin()[2] == 3, "");
1724 static_assert(({ const int x = 5; x * 3; }) == 15, ""); // expected-warning {{extension}} in f()
1733 static_assert(g(123) == 15129, "");
1758 …static_assert(p->f() == sizeof(X<S1>), ""); // expected-error {{constant expression}} expected-not…
1763 static_assert(q->f() == sizeof(S2), "");
1810 static_assert(a.b == 0 && a.u == 1 && a.n == -1 && a.b2 == 0 &&
1818 static_assert(B(3).n == 3, "");
1819 static_assert(B(4).n == -4, "");
1820 static_assert(B(7).n == -1, "");
1821 static_assert(B(8).n == 0, "");
1822 static_assert(B(-1).n == -1, "");
1823 static_assert(B(-8889).n == -1, "");
1832 static_assert(X::f(3) == -1, "3 should truncate to -1");
1903 static_assert(__builtin_strlen("foo") == 3, "");
1904 static_assert(__builtin_strlen("foo\0quux") == 3, "");
1905 static_assert(__builtin_strlen("foo\0quux" + 4) == 4, "");
1919 static_assert(check(a), "");
1920 static_assert(check(b), "");
1921 static_assert(check(c), "");
1947 static_assert(&a + 1 != &b, ""); // expected-error {{constant expression}} in PR21327()
1966 static_assert(&start != &end, ""); // expected-error {{constant expression}}
1967 static_assert(&start != nullptr, "");
1974 static_assert(&Bar::x != nullptr, "");
1975 static_assert(&Bar::x != &Bar::y, "");