Skip to content

Commit 8f8b9f2

Browse files
committed
PR47805: Use a single object for a function parameter in the caller and
callee in constant evaluation. We previously made a deep copy of function parameters of class type when passing them, resulting in the destructor for the parameter applying to the original argument value, ignoring any modifications made in the function body. This also meant that the 'this' pointer of the function parameter could be observed changing between the caller and the callee. This change completely reimplements how we model function parameters during constant evaluation. We now model them roughly as if they were variables living in the caller, albeit with an artificially reduced scope that covers only the duration of the function call, instead of modeling them as temporaries in the caller that we partially "reparent" into the callee at the point of the call. This brings some minor diagnostic improvements, as well as significantly reduced stack usage during constant evaluation.
1 parent 498c7fa commit 8f8b9f2

30 files changed

+395
-215
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 322 additions & 155 deletions
Large diffs are not rendered by default.

clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace M {
1010

1111
struct NonLiteral {
1212
NonLiteral() {}
13-
NonLiteral(int) {} // expected-note 2{{here}}
13+
NonLiteral(int) {}
1414
operator int() const { return 0; }
1515
};
1616
struct Literal {
@@ -42,8 +42,8 @@ template<typename ...P> struct ConstexprCtor {
4242
};
4343
constexpr ConstexprCtor<> f1() { return {}; } // ok
4444
constexpr ConstexprCtor<int> f2() { return 0; } // ok
45-
constexpr ConstexprCtor<NonLiteral> f3() { return { 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-constexpr constructor 'NonLiteral}}
46-
constexpr ConstexprCtor<int, NonLiteral> f4() { return { 0, 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-constexpr constructor 'NonLiteral}}
45+
constexpr ConstexprCtor<NonLiteral> f3() { return { 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-literal type 'NonLiteral}}
46+
constexpr ConstexprCtor<int, NonLiteral> f4() { return { 0, 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-literal type 'NonLiteral}}
4747

4848
struct VirtBase : virtual S {}; // expected-note {{here}}
4949

clang/test/CXX/except/except.spec/p1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace noex {
5555
struct A {};
5656

5757
void g1() noexcept(A()); // expected-error {{not contextually convertible}}
58-
void g2(bool b) noexcept(b); // expected-error {{argument to noexcept specifier must be a constant expression}} expected-note {{read of non-const variable 'b'}} expected-note {{here}}
58+
void g2(bool b) noexcept(b); // expected-error {{argument to noexcept specifier must be a constant expression}} expected-note {{function parameter 'b' with unknown value}} expected-note {{here}}
5959

6060
}
6161

clang/test/CXX/expr/expr.const/p2-0x.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ namespace NonConstExprReturn {
6262
constexpr const int *address_of(const int &a) {
6363
return &a;
6464
}
65-
constexpr const int *return_param(int n) { // expected-note {{declared here}}
65+
constexpr const int *return_param(int n) {
6666
return address_of(n);
6767
}
6868
struct S {
69-
int n : *return_param(0); // expected-error {{constant expression}} expected-note {{read of variable whose lifetime has ended}}
69+
int n : *return_param(0); // expected-error {{constant expression}} expected-note {{read of object outside its lifetime}}
7070
};
7171
}
7272

@@ -427,13 +427,12 @@ namespace PseudoDtor {
427427
int n : (k.~I(), 1); // expected-error {{constant expression}} expected-note {{visible outside that expression}}
428428
};
429429

430-
// FIXME: It's unclear whether this should be accepted in C++20 mode. The parameter is destroyed twice here.
431-
constexpr int f(int a = 1) { // cxx11-error {{constant expression}}
430+
constexpr int f(int a = 1) { // cxx11-error {{constant expression}} expected-note {{destroying object 'a' whose lifetime has already ended}}
432431
return (
433-
a.~I(), // cxx11-note 2{{pseudo-destructor}}
432+
a.~I(), // cxx11-note {{pseudo-destructor}}
434433
0);
435434
}
436-
static_assert(f() == 0, ""); // cxx11-error {{constant expression}} cxx11-note {{in call}}
435+
static_assert(f() == 0, ""); // expected-error {{constant expression}}
437436

438437
// This is OK in C++20: the union has no active member after the
439438
// pseudo-destructor call, so the union destructor has no effect.

clang/test/OpenMP/critical_messages.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int tmain(int argc, char **argv) { // expected-note {{declared here}}
6565
foo();
6666
#pragma omp critical (name2) hint(+ // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
6767
foo();
68-
#pragma omp critical (name2) hint(argc) // expected-error {{integral constant expression}} expected-note {{read of non-const variable 'argc' is not allowed in a constant expression}}
68+
#pragma omp critical (name2) hint(argc) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
6969
foo();
7070
#pragma omp critical (name) hint(N) // expected-error {{argument to 'hint' clause must be a strictly positive integer value}} expected-error {{constructs with the same name must have a 'hint' clause with the same value}} expected-note {{'hint' clause with value '4'}}
7171
foo();
@@ -128,7 +128,7 @@ int main(int argc, char **argv) { // expected-note {{declared here}}
128128
foo();
129129
#pragma omp critical (name2) hint(+ // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
130130
foo();
131-
#pragma omp critical (name2) hint(argc) // expected-error {{integral constant expression}} expected-note {{read of non-const variable 'argc' is not allowed in a constant expression}}
131+
#pragma omp critical (name2) hint(argc) // expected-error {{integral constant expression}} expected-note 0+{{constant expression}}
132132
foo();
133133
#pragma omp critical (name) hint(23) // expected-note {{previous 'hint' clause with value '23'}}
134134
foo();

clang/test/OpenMP/distribute_parallel_for_simd_safelen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ T tmain(T argc, S **argv) {
3939

4040
#pragma omp target
4141
#pragma omp teams
42-
#pragma omp distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
42+
#pragma omp distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
4343
for (int i = ST; i < N; i++)
4444
argv[0][i] = argv[0][i] - argv[0][i-ST];
4545

clang/test/OpenMP/distribute_simd_safelen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ T tmain(T argc, S **argv) {
3939

4040
#pragma omp target
4141
#pragma omp teams
42-
#pragma omp distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
42+
#pragma omp distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
4343
for (int i = ST; i < N; i++)
4444
argv[0][i] = argv[0][i] - argv[0][i-ST];
4545

clang/test/OpenMP/distribute_simd_simdlen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ T tmain(T argc, S **argv) {
3939

4040
#pragma omp target
4141
#pragma omp teams
42-
#pragma omp distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
42+
#pragma omp distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
4343
for (int i = ST; i < N; i++)
4444
argv[0][i] = argv[0][i] - argv[0][i-ST];
4545

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_safelen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ T tmain(T argc, S **argv) {
3131
#pragma omp target teams distribute parallel for simd safelen () // expected-error {{expected expression}}
3232
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3333

34-
#pragma omp target teams distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
34+
#pragma omp target teams distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
3535
for (int i = ST; i < N; i++)
3636
argv[0][i] = argv[0][i] - argv[0][i-ST];
3737

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_simdlen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ T tmain(T argc, S **argv) {
3131
#pragma omp target teams distribute parallel for simd safelen () // expected-error {{expected expression}}
3232
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3333

34-
#pragma omp target teams distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
34+
#pragma omp target teams distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
3535
for (int i = ST; i < N; i++)
3636
argv[0][i] = argv[0][i] - argv[0][i-ST];
3737

clang/test/OpenMP/target_teams_distribute_simd_safelen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ T tmain(T argc, S **argv) {
3131
#pragma omp target teams distribute simd safelen () // expected-error {{expected expression}}
3232
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3333

34-
#pragma omp target teams distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
34+
#pragma omp target teams distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
3535
for (int i = ST; i < N; i++)
3636
argv[0][i] = argv[0][i] - argv[0][i-ST];
3737

clang/test/OpenMP/target_teams_distribute_simd_simdlen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ T tmain(T argc, S **argv) {
3131
#pragma omp target teams distribute simd safelen () // expected-error {{expected expression}}
3232
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3333

34-
#pragma omp target teams distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
34+
#pragma omp target teams distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
3535
for (int i = ST; i < N; i++)
3636
argv[0][i] = argv[0][i] - argv[0][i-ST];
3737

clang/test/OpenMP/teams_distribute_parallel_for_simd_safelen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ T tmain(T argc, S **argv) {
3535
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3636

3737
#pragma omp target
38-
#pragma omp teams distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
38+
#pragma omp teams distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
3939
for (int i = ST; i < N; i++)
4040
argv[0][i] = argv[0][i] - argv[0][i-ST];
4141

clang/test/OpenMP/teams_distribute_parallel_for_simd_simdlen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ T tmain(T argc, S **argv) {
3535
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3636

3737
#pragma omp target
38-
#pragma omp teams distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
38+
#pragma omp teams distribute parallel for simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
3939
for (int i = ST; i < N; i++)
4040
argv[0][i] = argv[0][i] - argv[0][i-ST];
4141

clang/test/OpenMP/teams_distribute_simd_safelen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ T tmain(T argc, S **argv) {
3535
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3636

3737
#pragma omp target
38-
#pragma omp teams distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
38+
#pragma omp teams distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
3939
for (int i = ST; i < N; i++)
4040
argv[0][i] = argv[0][i] - argv[0][i-ST];
4141

clang/test/OpenMP/teams_distribute_simd_simdlen_messages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ T tmain(T argc, S **argv) {
3535
for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
3636

3737
#pragma omp target
38-
#pragma omp teams distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 2 {{read of non-const variable 'argc' is not allowed in a constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
38+
#pragma omp teams distribute simd safelen (argc // expected-note {{to match this '('}} expected-error 2 {{integral constant expression}} expected-note 0+{{constant expression}} expected-error {{expected ')'}}
3939
for (int i = ST; i < N; i++)
4040
argv[0][i] = argv[0][i] - argv[0][i-ST];
4141

clang/test/Sema/builtin-expect-with-probability-avr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ void test(int x, double p) { // expected-note {{declared here}}
55
dummy = __builtin_expect_with_probability(x > 0, 1, 0.9);
66
dummy = __builtin_expect_with_probability(x > 0, 1, 1.1); // expected-error {{probability argument to __builtin_expect_with_probability is outside the range [0.0, 1.0]}}
77
dummy = __builtin_expect_with_probability(x > 0, 1, -1); // expected-error {{probability argument to __builtin_expect_with_probability is outside the range [0.0, 1.0]}}
8-
dummy = __builtin_expect_with_probability(x > 0, 1, p); // expected-error {{probability argument to __builtin_expect_with_probability must be constant floating-point expression}} expected-note {{read of non-constexpr variable 'p' is not allowed in a constant expression}}
8+
dummy = __builtin_expect_with_probability(x > 0, 1, p); // expected-error {{probability argument to __builtin_expect_with_probability must be constant floating-point expression}} expected-note {{function parameter 'p' with unknown value}}
99
dummy = __builtin_expect_with_probability(x > 0, 1, "aa"); // expected-error {{cannot initialize a parameter of type 'double' with an lvalue of type 'const char [3]'}}
1010
dummy = __builtin_expect_with_probability(x > 0, 1, __builtin_nan("")); // expected-error {{probability argument to __builtin_expect_with_probability is outside the range [0.0, 1.0]}}
1111
dummy = __builtin_expect_with_probability(x > 0, 1, __builtin_inf()); // expected-error {{probability argument to __builtin_expect_with_probability is outside the range [0.0, 1.0]}}

clang/test/Sema/builtin-expect-with-probability.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void test(int x, double p) { // expected-note {{declared here}}
4343
dummy = __builtin_expect_with_probability(x > 0, 1, 0.9);
4444
dummy = __builtin_expect_with_probability(x > 0, 1, 1.1); // expected-error {{probability argument to __builtin_expect_with_probability is outside the range [0.0, 1.0]}}
4545
dummy = __builtin_expect_with_probability(x > 0, 1, -1); // expected-error {{probability argument to __builtin_expect_with_probability is outside the range [0.0, 1.0]}}
46-
dummy = __builtin_expect_with_probability(x > 0, 1, p); // expected-error {{probability argument to __builtin_expect_with_probability must be constant floating-point expression}} expected-note {{read of non-constexpr variable 'p' is not allowed in a constant expression}}
46+
dummy = __builtin_expect_with_probability(x > 0, 1, p); // expected-error {{probability argument to __builtin_expect_with_probability must be constant floating-point expression}} expected-note {{function parameter 'p'}}
4747
dummy = __builtin_expect_with_probability(x > 0, 1, "aa"); // expected-error {{cannot initialize a parameter of type 'double' with an lvalue of type 'const char [3]'}}
4848
dummy = __builtin_expect_with_probability(x > 0, 1, __builtin_nan("")); // expected-error {{probability argument to __builtin_expect_with_probability is outside the range [0.0, 1.0]}}
4949
dummy = __builtin_expect_with_probability(x > 0, 1, __builtin_inf()); // expected-error {{probability argument to __builtin_expect_with_probability is outside the range [0.0, 1.0]}}

clang/test/Sema/c89.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void test10 (int x[*]); /* expected-warning {{variable length arrays are a C99 f
6565
void test11 (int x[static 4]); /* expected-warning {{static array size is a C99 feature}} */
6666

6767
void test12 (int x[const 4]) { /* expected-warning {{qualifier in array size is a C99 feature}} */
68-
int Y[x[1]]; /* expected-warning {{variable length arrays are a C99 feature}} expected-note {{parameter 'x'}} */
68+
int Y[x[1]]; /* expected-warning {{variable length arrays are a C99 feature}} */
6969
}
7070

7171
/* PR4074 */

clang/test/SemaCUDA/constexpr-variables.cu

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ __host__ __device__ void foo(const T **a) {
1717
constexpr T e = sizeof(a);
1818
constexpr T f = **a;
1919
// expected-error@-1 {{constexpr variable 'f' must be initialized by a constant expression}}
20-
// expected-note@-2 {{read of non-constexpr variable 'a' is not allowed in a constant expression}}
20+
// expected-note@-2 {{}}
2121
a[0] = &b;
2222
a[1] = &c;
2323
a[2] = &d;
@@ -30,7 +30,7 @@ __device__ void device_fun(const int **a) {
3030
static constexpr int c = sizeof(a);
3131
constexpr int d = **a;
3232
// expected-error@-1 {{constexpr variable 'd' must be initialized by a constant expression}}
33-
// expected-note@-2 {{read of non-constexpr variable 'a' is not allowed in a constant expression}}
33+
// expected-note@-2 {{}}
3434
a[0] = &b;
3535
a[1] = &c;
3636
foo(a);
@@ -43,7 +43,7 @@ void host_fun(const int **a) {
4343
static constexpr int c = sizeof(a);
4444
constexpr int d = **a;
4545
// expected-error@-1 {{constexpr variable 'd' must be initialized by a constant expression}}
46-
// expected-note@-2 {{read of non-constexpr variable 'a' is not allowed in a constant expression}}
46+
// expected-note@-2 {{}}
4747
a[0] = &b;
4848
a[1] = &c;
4949
foo(a);
@@ -55,7 +55,7 @@ __host__ __device__ void host_device_fun(const int **a) {
5555
static constexpr int c = sizeof(a);
5656
constexpr int d = **a;
5757
// expected-error@-1 {{constexpr variable 'd' must be initialized by a constant expression}}
58-
// expected-note@-2 {{read of non-constexpr variable 'a' is not allowed in a constant expression}}
58+
// expected-note@-2 {{}}
5959
a[0] = &b;
6060
a[1] = &c;
6161
foo(a);

clang/test/SemaCXX/c99-variable-length-array-cxx11.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ struct POD {
1818

1919
// We allow VLAs of POD types, only.
2020
void vla(int N) { // expected-note 5{{here}}
21-
int array1[N]; // expected-warning{{variable length arrays are a C99 feature}} expected-note {{variable 'N'}}
22-
POD array2[N]; // expected-warning{{variable length arrays are a C99 feature}} expected-note {{variable 'N'}}
23-
StillPOD array3[N]; // expected-warning{{variable length arrays are a C99 feature}} expected-note {{variable 'N'}}
24-
StillPOD2 array4[N][3]; // expected-warning{{variable length arrays are a C99 feature}} expected-note {{variable 'N'}}
21+
int array1[N]; // expected-warning{{variable length arrays are a C99 feature}} expected-note {{parameter 'N'}}
22+
POD array2[N]; // expected-warning{{variable length arrays are a C99 feature}} expected-note {{parameter 'N'}}
23+
StillPOD array3[N]; // expected-warning{{variable length arrays are a C99 feature}} expected-note {{parameter 'N'}}
24+
StillPOD2 array4[N][3]; // expected-warning{{variable length arrays are a C99 feature}} expected-note {{parameter 'N'}}
2525
NonPOD array5[N]; // expected-error{{no matching constructor for initialization of 'NonPOD [N]'}}
26-
// expected-warning@-1{{variable length arrays are a C99 feature}} expected-note@-1 {{variable 'N'}}
26+
// expected-warning@-1{{variable length arrays are a C99 feature}} expected-note@-1 {{parameter 'N'}}
2727
// expected-note@-16{{candidate constructor not viable}}
2828
// expected-note@-18{{candidate constructor (the implicit copy constructor) not viable}}
2929
// expected-note@-19{{candidate constructor (the implicit move constructor) not viable}}

clang/test/SemaCXX/c99-variable-length-array.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct POD {
1313
};
1414

1515
// expected-note@* 1+{{read of non-const variable}}
16+
// expected-note@* 1+{{function parameter}}
1617
// expected-note@* 1+{{declared here}}
1718

1819
// We allow VLAs of POD types, only.

0 commit comments

Comments
 (0)