ExprResult Sema::checkUnknownAnyCast(SourceRange TypeRange, QualType CastType,
Expr *CastExpr, CastKind &CastKind,
ExprValueKind &VK, CXXCastPath &Path) {
+ // The type we're casting to must be either void or complete.
+ if (!CastType->isVoidType() &&
+ RequireCompleteType(TypeRange.getBegin(), CastType,
+ diag::err_typecheck_cast_to_incomplete))
+ return ExprError();
+
// Rewrite the casted expression from scratch.
ExprResult result = RebuildUnknownAnyExpr(*this, CastType).Visit(CastExpr);
if (!result.isUsable()) return ExprError();
int x = (int) test1; // expected-error {{function 'test1' with unknown type must be given a function type}}
}
}
+
+// rdar://problem/23959960
+namespace test5 {
+ template<typename T> struct X; // expected-note{{template is declared here}}
+
+ extern __unknown_anytype test0(...);
+
+ void test() {
+ (X<int>)test0(); // expected-error{{implicit instantiation of undefined template 'test5::X<int>'}}
+ }
+}