]> granicus.if.org Git - clang/commitdiff
Mark a function declaration invalid if any of its parameter declarations
authorJohn McCall <rjmccall@apple.com>
Wed, 14 Apr 2010 01:27:20 +0000 (01:27 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 14 Apr 2010 01:27:20 +0000 (01:27 +0000)
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
test/SemaTemplate/instantiate-method.cpp

index ab61487b68b322d1ad4bbed92564382338163f30..a2d0e187285635eaec1fd802a156c53ee96e976e 100644 (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();
       }
     }
 
index 635d839b2bd286f097e56a735dc81a6f18b7db7d..3ef07d356d3e1ed6753fd6163450537a1f04aefd 100644 (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>;
+}