Mark a function declaration invalid if any of its parameter declarations

are invalid.  Prevents a crash-on-invalid during template instantiation.
I... really don't understand how this wasn't already present.

llvm-svn: 101203
This commit is contained in:
John McCall 2010-04-14 01:27:20 +00:00
parent b7eadda495
commit b723860aac
2 changed files with 13 additions and 0 deletions

View File

@ -3098,6 +3098,9 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
assert(Param->getDeclContext() != NewFD && "Was set before ?");
Param->setDeclContext(NewFD);
Params.push_back(Param);
if (Param->isInvalidDecl())
NewFD->setInvalidDecl();
}
}

View File

@ -117,3 +117,13 @@ struct X3 {
template struct X3<double>;
// Don't try to instantiate this, it's invalid.
namespace test1 {
template <class T> class A {};
template <class T> class B {
void foo(A<test1::Undeclared> &a) // expected-error {{no member named 'Undeclared' in namespace 'test1'}}
{}
};
template class B<int>;
}