From f19de1ce44b9c7ffdeb388d6fe2fa8a1d0288f64 Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 14 Apr 2010 01:27:20 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101203 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 3 +++ test/SemaTemplate/instantiate-method.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index ab61487b68..a2d0e18728 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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(); } } diff --git a/test/SemaTemplate/instantiate-method.cpp b/test/SemaTemplate/instantiate-method.cpp index 635d839b2b..3ef07d356d 100644 --- a/test/SemaTemplate/instantiate-method.cpp +++ b/test/SemaTemplate/instantiate-method.cpp @@ -117,3 +117,13 @@ struct X3 { template struct X3; + +// Don't try to instantiate this, it's invalid. +namespace test1 { + template class A {}; + template class B { + void foo(A &a) // expected-error {{no member named 'Undeclared' in namespace 'test1'}} + {} + }; + template class B; +} -- 2.40.0