[cfe-commits] r164578 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaTemplate/class-template-ctor-initializer.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Mon Sep 24 17:23:05 PDT 2012
Author: rsmith
Date: Mon Sep 24 19:23:05 2012
New Revision: 164578
URL: http://llvm.org/viewvc/llvm-project?rev=164578&view=rev
Log:
Don't produce diagnostics for missing ctor-initializers during template
instantiations if we encountered errors parsing some of the initializers.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaTemplate/class-template-ctor-initializer.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=164578&r1=164577&r2=164578&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Sep 24 19:23:05 2012
@@ -2965,7 +2965,11 @@
NumInitializers * sizeof(CXXCtorInitializer*));
Constructor->setCtorInitializers(baseOrMemberInitializers);
}
-
+
+ // Let template instantiation know whether we had errors.
+ if (AnyErrors)
+ Constructor->setInvalidDecl();
+
return false;
}
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=164578&r1=164577&r2=164578&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Sep 24 19:23:05 2012
@@ -2986,7 +2986,7 @@
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(),
Modified: cfe/trunk/test/SemaTemplate/class-template-ctor-initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/class-template-ctor-initializer.cpp?rev=164578&r1=164577&r2=164578&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/class-template-ctor-initializer.cpp (original)
+++ cfe/trunk/test/SemaTemplate/class-template-ctor-initializer.cpp Mon Sep 24 19:23:05 2012
@@ -53,3 +53,20 @@
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;
+}
More information about the cfe-commits
mailing list