summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp11
-rw-r--r--clang/test/SemaTemplate/instantiate-complete.cpp20
2 files changed, 29 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index d82f8854080..f8c6f6971da 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -3877,11 +3877,18 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion,
CK_FunctionToPointerDecay,
&ConversionRef, VK_RValue);
+ QualType CallResultType
+ = Conversion->getConversionType().getNonLValueExprType(Context);
+ if (RequireCompleteType(From->getLocStart(), CallResultType, 0)) {
+ Candidate.Viable = false;
+ Candidate.FailureKind = ovl_fail_bad_final_conversion;
+ return;
+ }
+
// Note that it is safe to allocate CallExpr on the stack here because
// there are 0 arguments (i.e., nothing is allocated using ASTContext's
// allocator).
- CallExpr Call(Context, &ConversionFn, 0, 0,
- Conversion->getConversionType().getNonLValueExprType(Context),
+ CallExpr Call(Context, &ConversionFn, 0, 0, CallResultType,
From->getLocStart());
ImplicitConversionSequence ICS =
TryCopyInitialization(*this, &Call, ToType,
diff --git a/clang/test/SemaTemplate/instantiate-complete.cpp b/clang/test/SemaTemplate/instantiate-complete.cpp
index 91d4d327073..4b27da7349f 100644
--- a/clang/test/SemaTemplate/instantiate-complete.cpp
+++ b/clang/test/SemaTemplate/instantiate-complete.cpp
@@ -126,3 +126,23 @@ namespace pr7199 {
template class B<int>; // expected-note {{in instantiation}}
}
+
+namespace PR8425 {
+ template <typename T>
+ class BaseT {};
+
+ template <typename T>
+ class DerivedT : public BaseT<T> {};
+
+ template <typename T>
+ class FromT {
+ public:
+ operator DerivedT<T>() const { return DerivedT<T>(); }
+ };
+
+ void test() {
+ FromT<int> ft;
+ BaseT<int> bt(ft);
+ }
+}
+
OpenPOWER on IntegriCloud