[cfe-commits] r101203 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaTemplate/instantiate-method.cpp

John McCall rjmccall at apple.com
Tue Apr 13 18:27:20 PDT 2010


Author: rjmccall
Date: Tue Apr 13 20:27:20 2010
New Revision: 101203

URL: http://llvm.org/viewvc/llvm-project?rev=101203&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaTemplate/instantiate-method.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=101203&r1=101202&r2=101203&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 13 20:27:20 2010
@@ -3098,6 +3098,9 @@
         assert(Param->getDeclContext() != NewFD && "Was set before ?");
         Param->setDeclContext(NewFD);
         Params.push_back(Param);
+
+        if (Param->isInvalidDecl())
+          NewFD->setInvalidDecl();
       }
     }
 

Modified: cfe/trunk/test/SemaTemplate/instantiate-method.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-method.cpp?rev=101203&r1=101202&r2=101203&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-method.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-method.cpp Tue Apr 13 20:27:20 2010
@@ -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>;
+}





More information about the cfe-commits mailing list