1- // RUN: %clang_cc1 %s -std=c++2c -fsyntax-only -fdeclspec -fblocks -Wno-vla-cxx-extension -verify
1+ // RUN: %clang_cc1 %s -std=c++2c -fsyntax-only -fdeclspec -fblocks -Wno-vla-cxx-extension -fconstexpr-steps=1000 - verify
22namespace std {
33template <typename T>
44struct initializer_list {
@@ -153,8 +153,12 @@ struct NegativeSize {
153153
154154void negative_size () {
155155 static constexpr NegativeSize n;
156- template for (auto x : n) g (x); // expected-error {{expansion size must not be negative (was -3)}}
157- template for (constexpr auto x : n) g (x); // expected-error {{expansion size must not be negative (was -3)}}
156+ template for (auto x : n) g (x); // expected-error {{expansion size is not a constant expression}} \
157+ expected-note {{constexpr evaluation hit maximum step limit}} \
158+ expected-note {{in call to}}
159+ template for (constexpr auto x : n) g (x); // expected-error {{expansion size is not a constant expression}} \
160+ expected-note {{constexpr evaluation hit maximum step limit}} \
161+ expected-note {{in call to}}
158162}
159163
160164template <typename T, __SIZE_TYPE__ size>
@@ -236,18 +240,19 @@ static_assert(Protected::member_func() == 6);
236240struct SizeNotICE {
237241 struct iterator {
238242 friend constexpr iterator operator +(iterator a, __PTRDIFF_TYPE__) { return a; }
243+ constexpr iterator operator ++() { return *this ; }
239244 int constexpr operator *() const { return 7 ; }
240245
241246 // NOT constexpr!
242- friend int operator -(iterator, iterator) { return 7 ; } // expected-note {{declared here}}
243- friend int operator !=(iterator, iterator) { return 7 ; }
247+ friend int operator !=(iterator, iterator) { return 7 ; } // expected-note {{declared here}}
244248 };
245249 constexpr iterator begin () const { return {}; }
246250 constexpr iterator end () const { return {}; }
247251};
248252
249253struct PlusMissing {
250254 struct iterator {
255+ constexpr iterator operator ++() { return *this ; }
251256 int constexpr operator *() const { return 7 ; }
252257 };
253258 constexpr iterator begin () const { return {}; }
@@ -267,10 +272,9 @@ void missing_funcs() {
267272 static constexpr PlusMissing s2;
268273 static constexpr DerefMissing s3;
269274
270- // TODO: This message should start complaining about '!=' once we support the
271- // proper way of computing the size.
272275 template for (auto x : s1) g (x); // expected-error {{expansion size is not a constant expression}} \
273- expected-note {{non-constexpr function 'operator-' cannot be used in a constant expression}}
276+ expected-note {{non-constexpr function 'operator!=' cannot be used in a constant expression}} \
277+ expected-note {{in call to}}
274278
275279 template for (auto x : s2) g (x); // expected-error {{invalid operands to binary expression}}
276280 template for (auto x : s3) g (x); // expected-error {{indirection requires pointer operand ('iterator' invalid)}}
@@ -631,9 +635,10 @@ consteval int f() {
631635 // expected-error@#invalid-ref {{constexpr variable '__end1' must be initialized by a constant expression}}
632636 // expected-error@#invalid-ref {{expansion size is not a constant expression}}
633637 // expected-note@#invalid-ref 2 {{member call on variable '__range1' whose value is not known}}
634- // expected-note@#invalid-ref 1 {{initializer of '__end1 ' is not a constant expression}}
638+ // expected-note@#invalid-ref {{initializer of '__begin1 ' is not a constant expression}}
635639 // expected-note@#invalid-ref 3 {{declared here}}
636640 // expected-note@#invalid-ref {{reference to 'arr' is not a constant expression}}
641+ // expected-note@#invalid-ref {{in call to}}
637642 template for (constexpr int s : arr) { // #invalid-ref // OK, iterating expansion statement
638643 result += sizeof (char [s]);
639644 }
0 commit comments