summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2016-02-03 19:13:08 +0000
committerDouglas Gregor <dgregor@apple.com>2016-02-03 19:13:08 +0000
commit0fc3a001682c0bd076a329024192e57b3bc950fd (patch)
tree08abfa09d4a0537d8a966784e86e3c6d33e9129f
parent62d3a6570afd635986912a7b9cb5791bc37da137 (diff)
downloadbcm5719-llvm-0fc3a001682c0bd076a329024192e57b3bc950fd.tar.gz
bcm5719-llvm-0fc3a001682c0bd076a329024192e57b3bc950fd.zip
[Sema debugger support] Require non-void types to be complete in unknown-anytype casts.
When performing a cast from an __unknown_anytype function call to a non-void type, we need to make sure that type is complete. Fixes rdar://problem/23959960. llvm-svn: 259681
-rw-r--r--clang/lib/Sema/SemaExpr.cpp6
-rw-r--r--clang/test/SemaCXX/unknown-anytype.cpp11
2 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b7d494fa5cb..dc638798d10 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14478,6 +14478,12 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
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();
diff --git a/clang/test/SemaCXX/unknown-anytype.cpp b/clang/test/SemaCXX/unknown-anytype.cpp
index a07ec83d10a..95ad0409340 100644
--- a/clang/test/SemaCXX/unknown-anytype.cpp
+++ b/clang/test/SemaCXX/unknown-anytype.cpp
@@ -45,3 +45,14 @@ namespace test4 {
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>'}}
+ }
+}
OpenPOWER on IntegriCloud