]> granicus.if.org Git - clang/commitdiff
[Sema debugger support] Require non-void types to be complete in unknown-anytype...
authorDouglas Gregor <dgregor@apple.com>
Wed, 3 Feb 2016 19:13:08 +0000 (19:13 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 3 Feb 2016 19:13:08 +0000 (19:13 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259681 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/unknown-anytype.cpp

index b7d494fa5cbb6e89538799e2dfa15884e2666838..dc638798d10ec9b0870f692864080b09a1dbd246 100644 (file)
@@ -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();
index a07ec83d10a0e46369a674464b1a72b800decac4..95ad040934051917db0a0d5035f1c7aceb22f409 100644 (file)
@@ -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>'}}
+  }
+}