[PATCH] D76038: PR45000: Use Sema::SetParamDefaultArgument in TransformLambdaExpr
Aaron Puchert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 15 19:19:31 PDT 2020
aaronpuchert updated this revision to Diff 257938.
aaronpuchert added a comment.
Add test case, loosely based on that in the bug report. By choosing a conversion that should error out we can detect the issue in a pure frontend test.
However, we would expect the error only once. Further investigation is needed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76038/new/
https://reviews.llvm.org/D76038
Files:
clang/lib/Sema/TreeTransform.h
clang/test/SemaTemplate/instantiate-local-class.cpp
Index: clang/test/SemaTemplate/instantiate-local-class.cpp
===================================================================
--- clang/test/SemaTemplate/instantiate-local-class.cpp
+++ clang/test/SemaTemplate/instantiate-local-class.cpp
@@ -486,3 +486,14 @@
}
void g() { f<int>(); }
}
+
+namespace PR45000 {
+ template <typename T>
+ void f(int x = [](T x = nullptr) -> int { return x; }());
+ // expected-error at -1 2 {{cannot initialize a parameter of type 'int' with an rvalue of type 'nullptr_t'}}
+ // expected-note at -2 {{in instantiation of default function argument expression for 'operator()<int>'}}
+ // expected-note at -3 2 {{passing argument to parameter 'x' here}}
+
+ void g() { f<int>(); }
+ // expected-note at -1 2 {{in instantiation of default function argument expression for 'f<int>'}}
+}
Index: clang/lib/Sema/TreeTransform.h
===================================================================
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -12168,7 +12168,7 @@
Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed, P);
ExprResult R = getDerived().TransformExpr(
E->getCallOperator()->getParamDecl(I)->getDefaultArg());
- P->setDefaultArg(R.get());
+ getSema().SetParamDefaultArgument(P, R.get(), R.get()->getBeginLoc());
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76038.257938.patch
Type: text/x-patch
Size: 1338 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200416/dc19c531/attachment.bin>
More information about the cfe-commits
mailing list