
See PR47804: TreeTransform uses TransformedLocalDecls as a map of declarations that have been transformed already. When doing a "TransformDecl", which happens in the cases of updating a DeclRefExpr's target, the default implementation simply returns the already transformed declaration. However, this was not including ParmVarDecls. SO, any use of TreeTransform that didn't re-implement TransformDecl would NOT properly update the target of a DeclRefExpr, resulting in odd behavior. In the case of Typo-recovery, the result was that a lambda that used its own parameter would cause an error, since it thought that the ParmVarDecl referenced was a different lambda. Additionally, this caused a problem in the AST (a declrefexpr into another scope) such that a future instantiation would cause an assertion. This patch ensures that the ParmVarDecl transforming process records into TransformedLocalDecls so that the DeclRefExpr is ALSO updated.
19 lines
568 B
C++
19 lines
568 B
C++
// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
|
|
|
|
template <class InputIt, class Pred>
|
|
bool all_of(InputIt first, Pred p);
|
|
|
|
template <typename T> void load_test() {
|
|
// Ensure that this doesn't crash during CorrectDelayedTyposInExpr,
|
|
// or any other use of TreeTransform that doesn't implement TransformDecl
|
|
// separately. Also, this should only error on 'output', not that 'x' is not
|
|
// captured.
|
|
// expected-error@+1 {{use of undeclared identifier 'output'}}
|
|
all_of(output, [](T x) { return x; });
|
|
}
|
|
|
|
int main() {
|
|
load_test<int>();
|
|
return 0;
|
|
}
|