]> granicus.if.org Git - clang/commitdiff
Propagate the invalid bit from bases to derived template classes.
authorMatt Beaumont-Gay <matthewbg@google.com>
Fri, 21 Jun 2013 18:58:32 +0000 (18:58 +0000)
committerMatt Beaumont-Gay <matthewbg@google.com>
Fri, 21 Jun 2013 18:58:32 +0000 (18:58 +0000)
Fixes PR16292.

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

lib/Sema/SemaTemplateInstantiate.cpp
test/SemaTemplate/derived.cpp

index 5e3ced47f44f7ac7b05ff41a00513464ff9f4fbf..9babafedc9573e22880694914293977fbac6ef77 100644 (file)
@@ -1754,6 +1754,10 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
          Base = Pattern->bases_begin(), BaseEnd = Pattern->bases_end();
        Base != BaseEnd; ++Base) {
     if (!Base->getType()->isDependentType()) {
+      if (const CXXRecordDecl *RD = Base->getType()->getAsCXXRecordDecl()) {
+        if (RD->isInvalidDecl())
+          Instantiation->setInvalidDecl();
+      }
       InstantiatedBases.push_back(new (Context) CXXBaseSpecifier(*Base));
       continue;
     }
index 7b91f9a3ed3f728d5af01c0933373cb0710e414b..a76b34fda26334191e218d71c3827c016e7f3e09 100644 (file)
@@ -28,3 +28,12 @@ namespace rdar13267210 {
     }
   };
 }
+
+namespace PR16292 {
+  class IncompleteClass;  // expected-note{{forward declaration}}
+  class BaseClass {
+    IncompleteClass Foo;  // expected-error{{field has incomplete type}}
+  };
+  template<class T> class DerivedClass : public BaseClass {};
+  void* p = new DerivedClass<void>;
+}