You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
template for (auto x : p1) g(x); // expected-error 2 {{'begin' is a private member of 'Private'}} expected-error 2 {{'end' is a private member of 'Private'}}
220
+
template for (auto x : p1) g(x); // expected-error 3 {{'begin' is a private member of 'Private'}} expected-error 3 {{'end' is a private member of 'Private'}}
221
221
222
222
staticconstexpr Protected p2;
223
-
template for (auto x : p2) g(x); // expected-error 2 {{'begin' is a protected member of 'Protected'}} expected-error 2 {{'end' is a protected member of 'Protected'}}
223
+
template for (auto x : p2) g(x); // expected-error 3 {{'begin' is a protected member of 'Protected'}} expected-error 3 {{'end' is a protected member of 'Protected'}}
224
224
}
225
225
226
226
constexprintfriend_func() {
@@ -634,8 +634,7 @@ consteval int f() {
634
634
// expected-error@#invalid-ref {{constexpr variable '__begin1' must be initialized by a constant expression}}
635
635
// expected-error@#invalid-ref {{constexpr variable '__end1' must be initialized by a constant expression}}
636
636
// expected-error@#invalid-ref {{expansion size is not a constant expression}}
637
-
// expected-note@#invalid-ref 2 {{member call on variable '__range1' whose value is not known}}
638
-
// expected-note@#invalid-ref {{initializer of '__begin1' is not a constant expression}}
637
+
// expected-note@#invalid-ref 3 {{member call on variable '__range1' whose value is not known}}
639
638
// expected-note@#invalid-ref 3 {{declared here}}
640
639
// expected-note@#invalid-ref {{reference to 'arr' is not a constant expression}}
641
640
// expected-note@#invalid-ref {{in call to}}
@@ -1094,3 +1093,48 @@ void lambda_template(T a) {
1094
1093
voidlambda_template_call() {
1095
1094
lambda_template([]{}); // expected-note {{in instantiation of function template specialization}}
1096
1095
}
1096
+
1097
+
// CWG 3131 makes it possible to expand over non-constexpr ranges.
1098
+
namespacecwg3131 {
1099
+
constexprintf1() {
1100
+
int j = 0;
1101
+
template for (auto i : Array<int, 3>{1, 2, 3}) j +=i;
1102
+
return j;
1103
+
}
1104
+
1105
+
constexprintf2() {
1106
+
Array<int, 3> a{1, 2, 3};
1107
+
int j = 0;
1108
+
template for (auto i : a) j +=i;
1109
+
return j;
1110
+
}
1111
+
1112
+
static_assert(f1() == 6);
1113
+
static_assert(f2() == 6);
1114
+
1115
+
template <typename T>
1116
+
structSpan {
1117
+
T* data;
1118
+
__SIZE_TYPE__ size;
1119
+
1120
+
template <__SIZE_TYPE__ N>
1121
+
constexprSpan(T(&a)[N]) : data{a}, size{N} {}
1122
+
1123
+
constexprautobegin() const -> T* { return data; }
1124
+
constexprautoend() const -> T* { return data + size; }
0 commit comments