]> granicus.if.org Git - clang/commitdiff
Fix to PR16225 (Assert-on-invalid: isa<LabelDecl>(D) && "declaration not instantiated...
authorSerge Pavlov <sepavloff@gmail.com>
Sat, 10 Aug 2013 12:00:21 +0000 (12:00 +0000)
committerSerge Pavlov <sepavloff@gmail.com>
Sat, 10 Aug 2013 12:00:21 +0000 (12:00 +0000)
Differential Revision: http://llvm-reviews.chandlerc.com/D920

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188137 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaTemplate/recovery-crash.cpp

index ce7684c9edbfaf4a7216c7aeaa875fda4055be02..315a405c6d3f7bba3e3c161d4861e86c51500b11 100644 (file)
@@ -4063,6 +4063,9 @@ NamedDecl *Sema::FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
         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));
index b5a0e1fa13f27b7efbdffbbc98923aee3b53338f..78f6db40d5c85fc23d5e902e1fe605c4f4451f20 100644 (file)
@@ -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}}
+  }
+}