Home | History | Annotate | Download | only in SemaCXX

Lines Matching refs:constexpr

5   constexpr S(int);
11 constexpr int &get(int n) { return arr[n]; }
12 constexpr const int &get(int n) const { return arr[n]; }
19 // Compound-statements can be used in constexpr functions.
20 constexpr int e() {{{{}} return 5; }}
23 // Types can be defined in constexpr functions.
24 constexpr int f() {
28 constexpr S(E e) : e(e) {}
29 constexpr int get() { return e; }
37 // Variables can be declared in constexpr functions.
38 constexpr int g(int k) {
45 constexpr int h(int n) {
46 static const int m = n; // expected-error {{static variable not permitted in a constexpr function}}
49 constexpr int i(int n) {
50 thread_local const int m = n; // expected-error {{thread_local variable not permitted in a constexpr function}}
54 // if-statements can be used in constexpr functions.
55 constexpr int j(int k) {
66 } // expected-note 2{{control reached end of constexpr function}}
75 constexpr void k() {
80 [[noreturn]] constexpr int fn() { // expected-error {{no return statement in constexpr function}}
84 // We evaluate the body of a constexpr constructor, to check for side-effects.
86 constexpr U(int n) {
90 constexpr U u1{1};
91 constexpr U u2{2}; // expected-error {{constant expression}} expected-note {{in call to 'U(2)'}}
94 constexpr int l(bool b) {
103 constexpr int htonl(int x) { // expected-error {{never produces a constant expression}}
109 constexpr int maybe_htonl(bool isBigEndian, int x) {
118 constexpr int swapped = maybe_htonl(false, 123); // expected-error {{constant expression}} expected-note {{in call}}
121 constexpr int n = 0;
123 constexpr int namespace_alias() {
129 constexpr int a = 0;
133 constexpr void set(const int &a, int b) {
136 constexpr int wrap(int a, int b) {
152 constexpr void swap(T &a, T &b) {
158 constexpr void reverse(Iterator begin, Iterator end) {
163 constexpr bool equal(Iterator1 a, Iterator1 ae, Iterator2 b, Iterator2 be) {
169 constexpr bool test1(int n) {
183 constexpr void f() {
187 constexpr int k = (f(), 0); // expected-error {{constant expression}} expected-note {{in call}}
191 constexpr int do_stuff(int k1, int k2) {
206 constexpr void set(int &n) { n = 1; }
207 constexpr int div_zero_1() { int z = 0; set(z); return 100 / z; } // no error
208 constexpr int div_zero_2() { // expected-error {{never produces a constant expression}}
213 constexpr int ref() { // expected-error {{never produces a constant expression}}
220 union A { constexpr A() : y(5) {} int x, y; };
223 union D { constexpr D() : c() {} constexpr D(int n) : n(n) {} C c; int n; };
224 constexpr void f(D &d) {
229 constexpr bool check(D &d) { return d.c.a.y == 3; }
231 constexpr bool g() { D d; f(d); return d.c.a.y == 3; }
235 constexpr bool h() { f(d); return check(d); } // expected-note {{in call}}
238 constexpr bool i() { D d(0); f(d); return check(d); } // expected-note {{in call}}
241 constexpr bool j() { D d; d.c.a.x = 3; return check(d); } // expected-note {{assignment to member 'x' of union with active member 'y'}}
246 constexpr int &&id(int &&n) { return static_cast<int&&>(n); }
247 constexpr int &&dead() { return id(0); } // expected-note {{temporary created here}}
248 constexpr int bad() { int &&n = dead(); n = 1; return n; } // expected-note {{assignment to temporary whose lifetime has ended}}
253 constexpr int modify(int &n) { return n = 1; } // expected-note 2 {{modification of object of const-qualified type 'const int'}}
254 constexpr int test1() { int k = 0; return modify(k); }
255 constexpr int test2() { const int k = 0; return modify(const_cast<int&>(k)); } // expected-note 2 {{in call}}
258 constexpr int i = test2(); // expected-error {{constant expression}} expected-note {{in call}}
262 constexpr int test(int *p) {
269 template<typename T> constexpr T &ref(T &&r) { return r; }
270 template<typename T> constexpr T postinc(T &&r) { return (r++, r); }
271 template<typename T> constexpr T postdec(T &&r) { return (r--, r); }
280 constexpr int overflow_int_inc_1 = ref(0x7fffffff)++; // expected-error {{constant}} expected-note {{2147483648}}
281 constexpr int overflow_int_inc_1_ok = ref(0x7ffffffe)++;
282 constexpr int overflow_int_inc_2 = ++ref(0x7fffffff); // expected-error {{constant}} expected-note {{2147483648}}
283 constexpr int overflow_int_inc_2_ok = ++ref(0x7ffffffe);
323 constexpr int f(U u) {
326 constexpr int wrong_member = f({0}); // expected-error {{constant}} expected-note {{in call to 'f({.a = 0})'}}
327 constexpr int vol = --ref<volatile int>(0); // expected-error {{constant}} expected-note {{decrement of volatile-qualified}}
329 constexpr int incr(int k) {
339 constexpr bool test_int() {
365 constexpr bool test_float() {
379 constexpr bool test_ptr() {
395 constexpr bool test_overflow() {
410 constexpr short test_promotion(short k) {
419 constexpr const char *test_bounds(const char *p, int o) {
432 constexpr int fib_loop(int a) {
443 constexpr bool breaks_work() {
470 constexpr bool no_cont_after_break() {
487 constexpr bool cond() {
500 constexpr int range_for() {
520 struct ignore { template<typename ...Ts> constexpr ignore(Ts &&...) {} };
523 constexpr array() : arr{} {}
525 constexpr array(X ...x) : arr{} {
528 template<int ...I, typename ...X> constexpr void init(ints<I...>, X ...x) {
534 constexpr explicit iterator(T *p) : p(p) {}
535 constexpr bool operator!=(iterator o) { return p != o.p; }
536 constexpr iterator &operator++() { ++p; return *this; }
537 constexpr T &operator*() { return *p; }
539 constexpr iterator begin() { return iterator(arr); }
540 constexpr iterator end() { return iterator(arr + N); }
543 constexpr int range_for_2() {
557 constexpr A() : n(5) {}
562 constexpr U() : y(4) {}
568 constexpr bool testA() {
579 constexpr B &operator=(const B&) {
588 constexpr bool testC() {
599 constexpr int f(char k) {
649 constexpr bool contin() {
665 constexpr bool switch_into_for() {
677 constexpr void duff_copy(char *a, const char *b, int n) {
693 constexpr bool test_copy(const char *str, int n) {
713 constexpr auto f() { return 0; }
714 template<typename T> constexpr auto g(T t) { return t; }
721 constexpr int f(int &r) { r *= 9; return r - 12; }
723 constexpr A a = { 6, f(a.temporary), a.temporary }; // expected-warning {{uninitialized}} expected-note {{temporary created here}}
726 constexpr int k = a.temporary++; // expected-error {{constant expression}} expected-note {{outside the expression that created the temporary}}
738 constexpr initializer_list(const _E* __b, size_t __s)
752 constexpr initializer_list() : __begin_(nullptr), __size_(0) {}
754 constexpr size_t size() const {return __size_;}
755 constexpr const _E* begin() const {return __begin_;}
756 constexpr const _E* end() const {return __begin_ + __size_;}
761 constexpr int sum(std::initializer_list<int> ints) {
770 constexpr int f(int k) {
783 constexpr int g() { // expected-error {{never produces a constant}}
788 constexpr int h() { // expected-error {{never produces a constant}}
802 constexpr X() {}
804 constexpr int f() { return sizeof(T); }
808 constexpr X<X<S1>> xxs1;
809 constexpr X<S1> *p = const_cast<X<X<S1>>*>(&xxs1);
813 constexpr X<X<S2>> xxs2;
814 constexpr X<S2> *q = const_cast<X<X<S2>>*>(&xxs2);
819 constexpr int &get(int &&r) { return r; }
820 constexpr int f() {
826 constexpr int g() {
838 constexpr int h(int n) {
859 constexpr void lifetime_versus_loops() {
880 constexpr bool test() {