]> granicus.if.org Git - clang/commitdiff
Don't produce diagnostics for missing ctor-initializers during template
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Sep 2012 00:23:05 +0000 (00:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Sep 2012 00:23:05 +0000 (00:23 +0000)
instantiations if we encountered errors parsing some of the initializers.

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

lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaTemplate/class-template-ctor-initializer.cpp

index 03cec4ca864253a872aa5739aa0e69f164808b12..a4ddba3740d61a801bd42058f6e7c59a81a3a6ed 100644 (file)
@@ -2965,7 +2965,11 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor,
              NumInitializers * sizeof(CXXCtorInitializer*));
       Constructor->setCtorInitializers(baseOrMemberInitializers);
     }
-    
+
+    // Let template instantiation know whether we had errors.
+    if (AnyErrors)
+      Constructor->setInvalidDecl();
+
     return false;
   }
 
index 8c1722fdedbc468fb623f2fe49ec6541fedd7cd5..d1c30bdf0c87e06ada721fd7567c4645f662e7b9 100644 (file)
@@ -2986,7 +2986,7 @@ Sema::InstantiateMemInitializers(CXXConstructorDecl *New,
                            const MultiLevelTemplateArgumentList &TemplateArgs) {
 
   SmallVector<CXXCtorInitializer*, 4> NewInits;
-  bool AnyErrors = false;
+  bool AnyErrors = Tmpl->isInvalidDecl();
 
   // Instantiate all the initializers.
   for (CXXConstructorDecl::init_const_iterator Inits = Tmpl->init_begin(),
index 44bb4bda791e7349097d5649d63ee7c9e928eac9..6043327b7babe66899316540fc95afc6986be47e 100644 (file)
@@ -53,3 +53,20 @@ namespace PR7259 {
     return 0;
   }
 }
+
+namespace NonDependentError {
+  struct Base { Base(int); }; // expected-note 2{{candidate}}
+
+  template<typename T>
+  struct Derived1 : Base {
+    Derived1() : Base(1, 2) {} // expected-error {{no matching constructor}}
+  };
+
+  template<typename T>
+  struct Derived2 : Base {
+    Derived2() : BaseClass(1) {} // expected-error {{does not name a non-static data member or base}}
+  };
+
+  Derived1<void> d1;
+  Derived2<void> d2;
+}