File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
1
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
2
- // RUN: %clang_cc1 -verify=ref %s
2
+ // RUN: %clang_cc1 -verify=ref -DCUR_INTERP %s
3
3
4
4
constexpr int m = 3 ;
5
5
constexpr const int *foo[][5 ] = {
@@ -350,3 +350,24 @@ namespace ZeroInit {
350
350
static_assert (b.f[0 ] == 0.0 , " " );
351
351
static_assert (b.f[1 ] == 0.0 , " " );
352
352
}
353
+
354
+ namespace ArrayInitLoop {
355
+ // / FIXME: The ArrayInitLoop for the decomposition initializer in g() has
356
+ // / f(n) as its CommonExpr. We need to evaluate that exactly once and not
357
+ // / N times as we do right now.
358
+ #ifndef CUR_INTERP
359
+ struct X {
360
+ int arr[3 ];
361
+ };
362
+ constexpr X f (int &r) {
363
+ return {++r, ++r, ++r};
364
+ }
365
+ constexpr int g () {
366
+ int n = 0 ;
367
+ auto [a, b, c] = f (n).arr ;
368
+ return a + b + c;
369
+ }
370
+ static_assert (g() == 6); // expected-error {{failed}} \
371
+ // expected-note {{15 == 6}}
372
+ #endif
373
+ }
You can’t perform that action at this time.
0 commit comments