r188137 - Fix to PR16225 (Assert-on-invalid: isa<LabelDecl>(D) && "declaration not instantiated in this scope")

Serge Pavlov sepavloff at gmail.com
Sat Aug 10 05:00:22 PDT 2013


Author: sepavloff
Date: Sat Aug 10 07:00:21 2013
New Revision: 188137

URL: http://llvm.org/viewvc/llvm-project?rev=188137&view=rev
Log:
Fix to PR16225 (Assert-on-invalid: isa<LabelDecl>(D) && "declaration not instantiated in this scope")

Differential Revision: http://llvm-reviews.chandlerc.com/D920

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/test/SemaTemplate/recovery-crash.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=188137&r1=188136&r2=188137&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Sat Aug 10 07:00:21 2013
@@ -4063,6 +4063,9 @@ NamedDecl *Sema::FindInstantiatedDecl(So
         isa<TemplateTemplateParmDecl>(D))
       return D;
 
+    if (D->isInvalidDecl())
+      return 0;
+
     // If we didn't find the decl, then we must have a label decl that hasn't
     // been found yet.  Lazily instantiate it and return it now.
     assert(isa<LabelDecl>(D));

Modified: cfe/trunk/test/SemaTemplate/recovery-crash.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/recovery-crash.cpp?rev=188137&r1=188136&r2=188137&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/recovery-crash.cpp (original)
+++ cfe/trunk/test/SemaTemplate/recovery-crash.cpp Sat Aug 10 07:00:21 2013
@@ -22,3 +22,16 @@ namespace PR16134 {
   template <class P> struct S // expected-error {{expected ';'}}
   template <> static S<Q>::f() // expected-error +{{}}
 }
+
+namespace PR16225 {
+  template <typename T> void f();
+  template<typename C> void g(C*) {
+    struct LocalStruct : UnknownBase<Mumble, C> { };  // expected-error {{unknown template name 'UnknownBase'}} \
+                                                      // expected-error {{use of undeclared identifier 'Mumble'}}
+    f<LocalStruct>();  // expected-warning {{template argument uses local type 'LocalStruct'}}
+  }
+  struct S;
+  void h() {
+    g<S>(0);  // expected-note {{in instantiation of function template specialization}}
+  }
+}





More information about the cfe-commits mailing list