1- // RUN: %clang_cc1 %s -std=c++2c -fsyntax-only -fdeclspec -fblocks -Wno-vla-cxx-extension -fconstexpr-steps=1000 -verify
1+ // RUN: %clang_cc1 %s -std=c++2c -fsyntax-only -fdeclspec -fblocks -Wno-vla-cxx-extension -fconstexpr-steps=10000 -verify=expected,old-interp
2+ // RUN: %clang_cc1 %s -std=c++2c -fsyntax-only -fdeclspec -fblocks -Wno-vla-cxx-extension -fconstexpr-steps=10000 -verify=expected,new-interp -fexperimental-new-constant-interpreter
23namespace std {
34template <typename T>
45struct initializer_list {
@@ -154,10 +155,12 @@ struct NegativeSize {
154155void negative_size () {
155156 static constexpr NegativeSize n;
156157 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+ old-interp-note {{constexpr evaluation hit maximum step limit}} \
159+ new-interp-note {{cannot refer to element 5 of array of 4 elements in a constant expression}} \
158160 expected-note {{in call to}}
159161 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}} \
162+ old-interp-note {{constexpr evaluation hit maximum step limit}} \
163+ new-interp-note {{cannot refer to element 5 of array of 4 elements in a constant expression}} \
161164 expected-note {{in call to}}
162165}
163166
@@ -626,24 +629,26 @@ static_assert(f(c1, c2) == 5);
626629// TODO: This entire example should work without issuing any diagnostics once
627630// we have full support for references to constexpr variables (P2686).
628631consteval int f () {
629- constexpr Array<int , 3 > arr {1 , 2 , 3 }; // expected-note{{add 'static' to give it a constant address}}
632+ constexpr Array<int , 3 > arr {1 , 2 , 3 }; // expected-note{{add 'static' to give it a constant address}} \
633+ new-interp-note 2 {{add 'static' to give it a constant address}}
630634
631635 int result = 0 ;
632636
633637 // expected-error@#invalid-ref {{constexpr variable '__range1' must be initialized by a constant expression}}
634638 // expected-error@#invalid-ref {{constexpr variable '__begin1' must be initialized by a constant expression}}
635639 // expected-error@#invalid-ref {{constexpr variable '__end1' must be initialized by a constant expression}}
636- // expected-error@#invalid-ref {{expansion size is not a constant expression}}
637- // expected-note@#invalid-ref 3 {{member call on variable '__range1' whose value is not known}}
638- // expected-note@#invalid-ref 3 {{declared here}}
639640 // expected-note@#invalid-ref {{reference to 'arr' is not a constant expression}}
640- // expected-note@#invalid-ref {{in call to}}
641+ // old-interp-error@#invalid-ref {{expansion size is not a constant expression}}
642+ // old-interp-note@#invalid-ref {{in call to}}
643+ // old-interp-note@#invalid-ref 3 {{member call on variable '__range1' whose value is not known}}
644+ // old-interp-note@#invalid-ref 3 {{declared here}}
645+ // new-interp-note@#invalid-ref 2 {{pointer to subobject of 'arr' is not a constant expression}}
641646 template for (constexpr int s : arr) { // #invalid-ref // OK, iterating expansion statement
642647 result += sizeof (char [s]);
643648 }
644649 return result;
645650}
646- static_assert (f() == 6 ); // expected- error {{static assertion failed due to requirement 'f() == 6'}} expected -note {{expression evaluates to '0 == 6'}}
651+ static_assert (f() == 6 ); // old-interp- error {{static assertion failed due to requirement 'f() == 6'}} old-interp -note {{expression evaluates to '0 == 6'}}
647652
648653struct S {
649654 int i;
@@ -666,8 +671,9 @@ void not_constant_expression() {
666671 expected-note {{temporary created here}} \
667672 expected-error {{constexpr variable 'x' must be initialized by a constant expression}} \
668673 expected-note {{in instantiation of expansion statement requested here}} \
669- expected-note {{read of variable '[__u0]' whose value is not known}} \
670- expected-note {{declared here}}
674+ old-interp-note {{read of variable '[__u0]' whose value is not known}} \
675+ old-interp-note {{declared here}} \
676+ new-interp-note {{cannot access field of null pointer}}
671677 g (x);
672678 }
673679}
@@ -1105,12 +1111,15 @@ constexpr int f1() {
11051111constexpr int f2 () {
11061112 Array<int , 3 > a{1 , 2 , 3 };
11071113 int j = 0 ;
1108- template for (auto i : a) j +=i;
1114+ template for (auto i : a) j +=i; // new-interp-error {{expansion size is not a constant expression}} \
1115+ new-interp-note {{initializer of '__range1' is not a constant expression}} \
1116+ new-interp-note {{declared here}}
11091117 return j;
11101118}
11111119
11121120static_assert (f1() == 6 );
1113- static_assert (f2() == 6 );
1121+ static_assert (f2() == 6 ); // new-interp-error {{static assertion failed due to requirement 'f2() == 6'}} \
1122+ new-interp-note {{expression evaluates to '0 == 6'}}
11141123
11151124template <typename T>
11161125struct Span {
0 commit comments