summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-16 19:28:15 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-16 19:28:15 +0000
commit71ad477ab3b8baa60cf7cc882b1ad924db9f37e6 (patch)
tree21be8589dc252d63566a5d85a3ee37025276454a /clang
parent10e3022b10d2a9ce18f91ccd9727221af9cd6d3c (diff)
downloadbcm5719-llvm-71ad477ab3b8baa60cf7cc882b1ad924db9f37e6.tar.gz
bcm5719-llvm-71ad477ab3b8baa60cf7cc882b1ad924db9f37e6.zip
Do not try to instantiate invalid declarations. It's a recipe for
disaster. Fixes PR6161. llvm-svn: 96371
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiateDecl.cpp3
-rw-r--r--clang/test/SemaCXX/new-delete.cpp6
-rw-r--r--clang/test/SemaTemplate/explicit-specialization-member.cpp12
3 files changed, 17 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 0b0efcb8332..f13bd69453d 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1304,6 +1304,9 @@ Decl * TemplateDeclInstantiator
Decl *Sema::SubstDecl(Decl *D, DeclContext *Owner,
const MultiLevelTemplateArgumentList &TemplateArgs) {
TemplateDeclInstantiator Instantiator(*this, Owner, TemplateArgs);
+ if (D->isInvalidDecl())
+ return 0;
+
return Instantiator.Visit(D);
}
diff --git a/clang/test/SemaCXX/new-delete.cpp b/clang/test/SemaCXX/new-delete.cpp
index acd4a23cb35..68323d8d075 100644
--- a/clang/test/SemaCXX/new-delete.cpp
+++ b/clang/test/SemaCXX/new-delete.cpp
@@ -159,12 +159,10 @@ void loadEngineFor() {
}
template <class T> struct TBase {
- void* operator new(T size, int); // expected-error {{'operator new' cannot take a dependent type as first parameter; use size_t}}\
- // expected-error {{'operator new' takes type size_t}}
+ void* operator new(T size, int); // expected-error {{'operator new' cannot take a dependent type as first parameter; use size_t}}
};
-// FIXME: We should not try to instantiate operator new, since it is invalid.
-TBase<int> t1; // expected-note {{in instantiation of template class 'struct TBase<int>' requested here}}
+TBase<int> t1;
class X6 {
public:
diff --git a/clang/test/SemaTemplate/explicit-specialization-member.cpp b/clang/test/SemaTemplate/explicit-specialization-member.cpp
index 06dd382fc7a..417cdc1f198 100644
--- a/clang/test/SemaTemplate/explicit-specialization-member.cpp
+++ b/clang/test/SemaTemplate/explicit-specialization-member.cpp
@@ -9,3 +9,15 @@ struct X0 {
template<> void X0<char>::f0(char);
template<> void X0<char>::f1(type);
+
+namespace PR6161 {
+ template<typename _CharT>
+ class numpunct : public locale::facet // expected-error{{use of undeclared identifier 'locale'}} \
+ // expected-error{{expected class name}} \
+ // expected-note{{attempt to specialize declaration here}}
+ {
+ static locale::id id; // expected-error{{use of undeclared identifier}}
+ };
+ numpunct<char>::~numpunct(); // expected-error{{template specialization requires 'template<>'}} \
+ // expected-error{{specialization of member 'PR6161::numpunct<char>::~numpunct' does not specialize an instantiated member}}
+}
OpenPOWER on IntegriCloud