mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 09:06:43 +00:00

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.
28 lines
1.0 KiB
C++
28 lines
1.0 KiB
C++
// RUN: %clang_cc1 -fsyntax-only -verify -Wvla %s
|
|
|
|
void test1(int n) { // expected-note {{here}}
|
|
int v[n]; // expected-warning {{variable length array}} expected-note {{parameter 'n'}}
|
|
}
|
|
|
|
void test2(int n, int v[n]) { // expected-warning {{variable length array}} expected-note {{parameter 'n'}} expected-note {{here}}
|
|
}
|
|
|
|
void test3(int n, int v[n]); // expected-warning {{variable length array}} expected-note {{parameter 'n'}} expected-note {{here}}
|
|
|
|
template<typename T>
|
|
void test4(int n) { // expected-note {{here}}
|
|
int v[n]; // expected-warning {{variable length array}} expected-note {{parameter 'n'}}
|
|
}
|
|
|
|
template<typename T>
|
|
void test5(int n, int v[n]) { // expected-warning {{variable length array}} expected-note {{parameter 'n'}} expected-note {{here}}
|
|
}
|
|
|
|
template<typename T>
|
|
void test6(int n, int v[n]); // expected-warning {{variable length array}} expected-note {{parameter 'n'}} expected-note {{here}}
|
|
|
|
template<typename T>
|
|
void test7(int n, T v[n]) { // expected-warning {{variable length array}} expected-note {{parameter 'n'}} expected-note {{here}}
|
|
}
|
|
|