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
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index ab61487..a2d0e18 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3098,6 +3098,9 @@
         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 635d839..3ef07d3 100644
--- a/test/SemaTemplate/instantiate-method.cpp
+++ b/test/SemaTemplate/instantiate-method.cpp
@@ -117,3 +117,13 @@
 
 
 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>;
+}