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, "");
85 static_assert(n9 == 123, "");
122 static_assert(wme.A == 42, "");
134 static_assert(Sum() == 0, "");
135 static_assert(Sum(1) == 1, "");
136 static_assert(Sum(1, four) == 5, "");
137 static_assert(Sum(1, eight, &twentyseven) == 36, "");
138 static_assert(Sum(1, 2, &four, eight) == 15, "");
146 static_assert(F(0) == 0, "");
147 static_assert(F(1, 0) == 1, "");
148 static_assert(F(2, "test") == 2, "");
149 static_assert(F(3, &F) == 3, "");
151 static_assert(F(4, k) == 3, ""); // expected-error {{constant expression}} expected-note {{read of non-const variable 'k'}}
157 static_assert(fib(11) == 89, "");
166 static_assert(gcd(1749237, 5628959) == 7, "");
186 static_assert(S::f(19) == 800, "");
187 static_assert(s.f(19) == 800, "");
188 static_assert(n == 800, "");
202 static_assert(MaybeReturnJunk(false, 0) == 42, ""); // ok
208 static_assert(MaybeReturnNonstaticRef(false, 0) == 42, ""); // ok
220 static_assert(GrabCallersArgument(false, 1, 2) == 1, "");
221 static_assert(GrabCallersArgument(true, 4, 8) == 8, "");
232 static_assert(f(23, &x, &y, &z) == 788, "");
237 static_assert(g(23, x, y, z) == 788, "");
252 static_assert(1 + Apply(Select(4), 5) + Apply(Select(3), 7) == 42, "");
261 static_assert(&x == &y, "false"); // expected-error {{false}}
262 static_assert(&x != &y, "");
271 static_assert(&s.x == &s.y, "false"); // expected-error {{false}}
272 static_assert(&s.x != &s.y, "");
273 static_assert(&s.x <= &s.y, "");
274 static_assert(&s.x >= &s.y, "false"); // expected-error {{false}}
275 static_assert(&s.x < &s.y, "");
276 static_assert(&s.x > &s.y, "false"); // expected-error {{false}}
278 static_assert(0 == &y, "false"); // expected-error {{false}}
279 static_assert(0 != &y, "");
285 static_assert(&x == 0, "false"); // expected-error {{false}}
286 static_assert(&x != 0, "");
292 static_assert(&x == &x, "");
293 static_assert(&x != &x, "false"); // expected-error {{false}}
294 static_assert(&x <= &x, "");
295 static_assert(&x >= &x, "");
296 static_assert(&x < &x, "false"); // expected-error {{false}}
297 static_assert(&x > &x, "false"); // expected-error {{false}}
330 static_assert(0 != "foo", "");
342 static_assert(n, "");
343 static_assert(!same(4, 4), "");
344 static_assert(same(n, n), "");
345 static_assert(sameTemporary(9), "");
351 static_assert(&b1.a1 != &b1.a2, "");
352 static_assert(&b1.a1.r != &b1.a2.r, ""); // expected-error {{constant expression}} expected-note {{outside the expression that created the temporary}}
355 static_assert(&b1 != &b2, "");
356 static_assert(&b1.a1 != &b2.a1, ""); // expected-error {{constant expression}} expected-note {{outside the expression that created the temporary}}
366 static_assert(&b4 != &b2, "");
400 static_assert(MangleChars("constexpr!") == 1768383, "");
401 static_assert(MangleChars(u8"constexpr!") == 1768383, "");
402 static_assert(MangleChars(L"constexpr!") == 1768383, "");
403 static_assert(MangleChars(u"constexpr!") == 1768383, "");
404 static_assert(MangleChars(U"constexpr!") == 1768383, "");
413 static_assert(*p == 's', "");
424 static_assert(*max == 'z', "");
425 static_assert(max == str + 38, "");
427 static_assert
428 static_assert(strcmp_ce("hello world", "hello clang") > 0, "");
429 static_assert(strcmp_ce("constexpr", "test") < 0, "");
430 static_assert(strcmp_ce("", " ") < 0, "");
442 static_assert(t.c[0] == 'f', "");
443 static_assert(t.c[1] == 'o', "");
444 static_assert(t.c[2] == 'o', "");
445 static_assert(t.c[3] == 0, "");
446 static_assert(t.c[4] == 0, "");
447 static_assert(t.c[5] == 0, "");
448 static_assert(t.c[6] == 0, ""); // expected-error {{constant expression}} expected-note {{one-past-the-end}}
454 static_assert(u.chars[2] == L's', "");
460 static_assert(V().c[1] == "i"[0], "");
465 static_assert(a[0] == 'f', "");
466 static_assert(b[1] == 'o', "");
467 static_assert(c[2] == 'o', "");
468 static_assert(d[0] == 'f', "");
469 static_assert(e[1] == 'o', "");
470 static_assert(f[2] == 'o', "");
471 static_assert(f[5] == 0, "");
472 static_assert(f[6] == 0, ""); // expected-error {{constant expression}} expected-note {{one-past-the-end}}
487 static_assert(sum_xs == 15, "");
501 static_assert(InnerProduct == 35, "");
505 static_assert(DiffProd == 8, "");
506 static_assert(ZipFoldR(SubMul, 3, xs+3, ys+3, 1), ""); // \
518 static_assert(zs[0][0][0][0] == 1, "");
519 static_assert(zs[1][1][1][1] == 16, "");
520 static_assert(zs[0][0][0][2] == 3, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
521 static_assert((&zs[0][0][0][2])[-1] == 2, "");
522 static_assert(**(**(zs + 1) + 1) == 11, "");
523 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}}
524 static_assert(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2) == 11, "");
530 static_assert(fail(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2)) == 11, ""); // \
531 expected-error {{static_assert expression is not an integral constant expression}} \
541 static_assert(SumNonzero(arr) == 6, "");
542 static_assert(CountZero(arr, arr + 40) == 36, "");
553 static_assert(ArrayRVal().elems[3].f() == 0, "");
559 static_assert(selfref[0][0][0] == 1, "");
560 static_assert(selfref[0][0][1] == 2, "");
561 static_assert(selfref[0][1][0] == 1, "");
562 static_assert(selfref[0][1][1] == 2, "");
563 static_assert(selfref[1][0][0] == 1, "");
564 static_assert(selfref[1][0][1] == 3, "");
565 static_assert(selfref[1][1][0] == 0, "");
566 static_assert(selfref[1][1][1] == 0, "");
570 static_assert(TDCArray{}[1][1].n == 0, "");
574 static_assert(NATDCArray{}[1][1].n == 0, "");
603 static_assert(fn(A(4,5)) == 9, "");
614 static_assert(D().c.n == 42, "");
624 static_assert(e2.p == &e2.p, "");
626 static_assert(e3.p == &e3.p, "");
650 static_assert(g.t.u1.a == 42, ""); // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}}
651 static_assert(g.t.u1.b == 42, "");
652 static_assert(g.t.u2.c == 42, "");
653 static_assert(g.t.u2.d == 42, ""); // expected-error {{constant expression}} expected-note {{read of member 'd' of union with active member 'c'}}
666 static_assert(S(15, &global).b == 15, "");
671 static_assert(CheckS(S(27, &global)), "");
681 static_assert(k == 0x007a7978, "");
694 static_assert(strcmp_ce(&agg1.c, "hello") == 0, "");
695 static_assert(agg1.n == 0, "");
696 static_assert(agg1.d == 0.0, "");
697 static_assert(agg1.arr[-1] == 0, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element -1}}
698 static_assert(agg1.arr[0] == 0, "");
699 static_assert(agg1.arr[4] == 0, "");
700 static_assert(agg1.arr[5] == 0, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end}}
701 static_assert(agg1.p == nullptr, "");
704 static_assert(uc[0] == 'f', "");
705 static_assert(uc[3] == 0, "");
717 static_assert(d.a == 3, "");
744 static_assert(derived.a == 76, "");
745 static_assert(derived.b[2] == 's', "");
746 static_assert(derived.c == 76 + 'e', "");
747 static_assert(derived.q == 123, "");
748 static_assert(derived.r == 76, "");
749 static_assert(&derived.r == &derived.a, "");
751 static_assert(!(derived == base), "");
752 static_assert(derived == base2, "");
756 static_assert(&bot1 != &bot2, "");
760 static_assert(&pb1 != &pb2, "");
761 static_assert(pb1 == &bot1, "");
762 static_assert(pb2 == &bot2, "");
767 static_assert(&ok2 == &derived, "");
772 static_assert(pok2 == &derived, "");
773 static_assert(&ok2 == pok2, "");
774 static_assert((Base2*)(Derived*)(Base*)pb1 == pok2, "");
775 static_assert((Derived*)(Base*)pb1 == (Derived*)pok2, "");
781 static_assert((Bottom*)nullB == 0, "");
782 static_assert((Derived*)nullB == 0, "");
783 static_assert((void*)(Bottom*)nullB == (void*)(Derived*)nullB, "");
791 static_assert(nullB1 == (1 - 1), ""); // expected-error {{comparison between pointer and integer}}
812 static_assert(S(5) == 11, "");
813 static_assert(check(S(5), 11), "");
820 static_assert(X() == 0, "");
849 static_assert(S().f(), ""); // expected-error {{constant expression}} expected-note {{in call to '&Temporaries::S()->f()'}}
850 static_assert(S().g(), ""); // expected-error {{constant expression}} expected-note {{in call to '&Temporaries::S()->g()'}}
851 static_assert(T(3).f() == 3, "");
852 static_assert(T(4).g() == 4, "");
858 static_assert(f(T(5)) == 5, "");
861 static_assert(b(0), "");
873 static_assert(u[0].a == 0, "");
874 static_assert(u[0].b, ""); // expected-error {{constant expression}} expected-note {{read of member 'b' of union with active member 'a'}}
875 static_assert(u[1].b == 1, "");
876 static_assert((&u[1].b)[1] == 2, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}}
877 static_assert(*(&(u[1].b) + 1 + 1) == 3, ""); // expected-error {{constant expression}} expected-note {{cannot refer to element 2 of non-array object}}
878 static_assert((&(u[1]) + 1 + 1)->b == 3, "");
881 static_assert(v.a == 0, "");
889 static_assert(y.a == 42, "");
890 static_assert(y.b == 42, ""); // expected-error {{constant expression}} expected-note {{'b' of union with active member 'a'}}
901 static_assert(A(5).*&A::n == 5, "");
902 static_assert((&a)->*&A::n == 7, "");
903 static_assert((A(8).*&A::f)() == 11, "");
904 static_assert(((&a)->*&A::f)() == 10, "");
912 static_assert(B(4, 11).*&A::n == 4, "");
913 static_assert(B(4, 11).*&B::m == 11, "");
914 static_assert(B(4, 11).*(int(A::*))&B::m == 11, "");
915 static_assert((&b)->*&A::n == 9, "");
916 static_assert((&b)->*&B::m == 13, "");
917 static_assert((&b)->*(int(A::*))&B::m == 13, "");
918 static_assert((B(4, 11).*&A::f)() == 7, "");
919 static_assert((B(4, 11).*&B::g)() == 16, "");
920 static_assert((B(4, 11).*(int(A::*)()const)&B::g)() == 16, "");
921 static_assert(((&b)->*&A::f)() == 12, "");
922 static_assert(((&b)->*&B::g)() == 23, "");
923 static_assert(((&b)->*(int(A::*)()const)&B::g)() == 23, "");
945 static_assert((s.*&S::f)() == 2, "");
946 static_assert((s.*s.pf)() == 2, "");
948 static_assert(pf == &S::f, "");
949 static_assert(pf == s.*&S::pf, "");
950 static_assert(pm == &S::m, "");
951 static_assert(pm != pn, "");
952 static_assert(s.pn != pn, "");
953 static_assert(s.pn == pm, "");
954 static_assert(pg != nullptr, "");
955 static_assert(pf != nullptr, "");
956 static_assert((int S::*)nullptr == nullptr, "");
957 static_assert(pg == pg, ""); // expected-error {{constant expression}} expected-note {{comparison of pointer to virtual member function 'g' has unspecified value}}
958 static_assert(pf != pg, ""); // expected-error {{constant expression}} expected-note {{comparison of pointer to virtual member function 'g' has unspecified value}}
968 static_assert(&(t17.*deepn) == &t17.n, "");
969 static_assert(deepn == &T<2>::n, "");
973 static_assert(&(t30.*deepm) == &t30.m, "");
974 static_assert(deepm == &T<50>::m, "");
975 static_assert(deepm != deepn, "");
980 static_assert(&(p17_5->*(int(T<3>::*))deepn) == &t17.n, "");
981 static_assert(&(p17_13->*deepn) == &t17.n, "");
987 static_assert(&(p30_5->*(int(T<3>::*))deepn) == &t30.n, "");
988 static_assert(&(p30_13->*deepn) == &t30.n, "");
989 static_assert(&(p30_23->*deepn) == &t30.n, "");
990 static_assert(&(p30_5->*(int(T<2>::*))deepm) == &t30.m, "");
991 static_assert(&(((T<17>*)p30_13)->*deepm) == &t30.m, "");
992 static_assert(&(p30_23->*deepm) == &t30.m, "");
997 static_assert(&Mid<0>::n == &Mid<1>::n, "");
998 static_assert((int Derived::*)(int Mid<0>::*)&Mid<0>::n !=
1000 static_assert(&Mid<0>::n == (int Mid<0>::*)&Base::n, "");
1017 static_assert(pb3 == pd3, "");
1035 static_assert(pd6 == &a[6], "");
1046 static_assert((pb9->*pfb)() == &a[9].n, "");
1078 static_assert(complex(1,0).real() == 1, "");
1079 static_assert(complex(1,0).imag() == 0, "");
1080 static_assert(((complex)1).imag() == 0, "");
1081 static_assert(k.real() == 34, "");
1082 static_assert(k.imag() == 12, "");
1083 static_assert(k - 34 == 12*i, "");
1084 static_assert((complex)1 == complex(1), "");
1085 static_assert((complex)1 != complex(0, 1), "");
1086 static_assert(complex(1) == complex(1), "");
1087 static_assert(complex(1) != complex(0, 1), "");
1089 static_assert(makeComplex(1,0) == complex(1), "");
1090 static_assert(makeComplex(1,0) != complex(0, 1), "");
1098 static_assert((complex_wrap)1 == complex(1), "");
1099 static_assert((complex)1 != complex_wrap(0, 1), "");
1100 static_assert(complex(1) == complex_wrap(1), "");
1101 static_assert(complex_wrap(1) != complex(0, 1), "");
1105 static_assert(makeComplexWrap(1,0) == complex(1), "");
1106 static_assert(makeComplexWrap(1,0) != complex(0, 1), "");
1113 static_assert(B().x == 3, ""); // expected-error {{constant expression}} expected-note {{non-literal type 'PR11595::B' cannot be used in a constant expression}}
1177 static_assert(&t2r + 1 == &t2i, "");
1178 static_assert(t2r == 1.0, "");
1179 static_assert(t2i == 2.0, "");
1181 static_assert(t2p[-1] == 0.0, ""); // expected-error {{constant expr}} expected-note {{cannot refer to element -1 of array of 2 elements}}
1182 static_assert(t2p[0] == 1.0, "");
1183 static_assert(t2p[1] == 2.0, "");
1184 static_assert(t2p[2] == 0.0, ""); // expected-error {{constant expr}} expected-note {{one-past-the-end pointer}}
1185 static_assert(t2p[3] == 0.0, ""); // expected-error {{constant expr}} expected-note {{cannot refer to element 3 of array of 2 elements}}
1193 static_assert(__real test6 == 5, "");
1194 static_assert(__imag test6 == 6, "");
1195 static_assert(&__imag test6 == &__real test6 + 1, "");
1210 static_assert(d1 == 0.5, "");
1211 static_assert(d3 == 3.0, "");
1219 static_assert(testVar.value == -1, "");
1273 static_assert(s1.a == 1, "");
1274 static_assert(s1.b == 2, "");
1275 static_assert(s1.c == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
1276 static_assert(s1.d == 3, "");
1277 static_assert(s1.e == 4, "");
1278 static_assert(s1.f == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
1280 static_assert(s2.a == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
1281 static_assert(s2.b == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
1282 static_assert(s2.c == 5, "");
1283 static_assert(s2.d == 6, "");
1284 static_assert(s2.e == 0, ""); // expected-error {{constant expression}} expected-note {{union with active member}}
1285 static_assert(s2.f == 7, "");
1320 static_assert(m == 123, "");
1341 static_assert(j == 1, "");
1364 static_assert(LastNonzero(begin(arr1), end(arr1)) == 4, "");
1367 static_assert(LastNonzero(begin(arr2), end(arr2)) == 5, "");
1378 static_assert(LastNonzero(begin(arr3), end(arr3)) == 2, "");
1439 static_assert(!__is_literal_type(Q), "");
1440 static_assert(!__is_literal_type(R), "");
1441 static_assert(!__is_literal_type(S), "");
1442 static_assert(!__is_literal_type(T), "");
1443 static_assert(!__is_literal_type(U), "");
1478 static_assert(S{}.t == 0, "");
1488 static_assert(x[0].m == 4, "");
1489 static_assert(x[1].m == 5, "");
1490 static_assert(x[2].m == 6, "");
1507 static_assert(f(a).v == 4, "");
1538 static_assert(get(arr, 1) == 1, "");
1539 static_assert(get(arr, 4) == 4, "");
1540 static_assert(get(arr, 0) == 4, ""); // expected-error{{not an integral constant expression}} \
1582 static_assert(a[0].p == &a[0].p, "");
1583 static_assert(a[9].p == &a[9].p, "");
1584 static_assert(a[0].p != &a[9].p, "");
1585 static_assert(a[9].p != &a[0].p, "");
1588 static_assert(b[0].p == &b[0].p, "");
1589 static_assert(b[9].p == &b[9].p, "");
1590 static_assert(b[0].p != &b[9].p, "");
1591 static_assert(b[9].p != &b[0].p, "");
1650 static_assert(sum({1, 2, 3, 4, 5}) == 15, "");
1656 static_assert(({ const int x = 5; x * 3; }) == 15, ""); // expected-warning {{extension}}
1665 static_assert(g(123) == 15129, "");
1690 static_assert(p->f() == sizeof(X<S1>), ""); // expected-error {{constant expression}} expected-note {{virtual function call}}
1695 static_assert(q->f() == sizeof(S2), "");
1742 static_assert(a.b == 0 && a.u == 1 && a.n == -1 && a.b2 == 0 &&
1750 static_assert(B(3).n == 3, "");
1751 static_assert(B(4).n == -4, "");
1752 static_assert(B(7).n == -1, "");
1753 static_assert(B(8).n == 0, "");
1754 static_assert(B(-1).n == -1, "");
1755 static_assert(B(-8889).n == -1, "");
1764 static_assert(X::f(3) == -1, "3 should truncate to -1");