[PATCH] PR16225 - Assert-on-invalid: isa<LabelDecl>(D) && "declaration not instantiated in this scope"
Serge Pavlov
sepavloff at gmail.com
Wed Jun 5 10:03:43 PDT 2013
Fixed formatting. Thanks to Hans Wennborg!
http://llvm-reviews.chandlerc.com/D920
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D920?vs=2274&id=2277#toc
Files:
lib/Parse/ParseDeclCXX.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaCXX/PR16225.cpp
test/SemaCXX/class.cpp
Index: lib/Parse/ParseDeclCXX.cpp
===================================================================
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -917,8 +917,10 @@
<< Id;
}
- if (!Template)
+ if (!Template) {
+ SkipUntil(tok::greater, /*StopAtSemi=*/true, /*DontConsume=*/false);
return true;
+ }
// Form the template name
UnqualifiedId TemplateName;
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===================================================================
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3550,6 +3550,9 @@
return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]);
}
+ 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: test/SemaCXX/PR16225.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/PR16225.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify %s
+
+template <typename T> void f();
+
+template<typename C> void g(C*) {
+ struct LocalStruct : UnknownBase<Mumble, C> { }; // expected-error {{unknown template name 'UnknownBase'}}
+ 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 'g<S>'}}
+}
Index: test/SemaCXX/class.cpp
===================================================================
--- test/SemaCXX/class.cpp
+++ test/SemaCXX/class.cpp
@@ -128,10 +128,7 @@
namespace pr6629 {
// TODO: most of these errors are spurious
template<class T1, class T2> struct foo :
- bogus<foo<T1,T2> > // expected-error {{unknown template name 'bogus'}} \
- // BOGUS expected-error {{expected '{' after base class list}} \
- // BOGUS expected-error {{expected ';' after struct}} \
- // BOGUS expected-error {{expected unqualified-id}}
+ bogus<foo<T1,T2> > // expected-error {{unknown template name 'bogus'}}
{ };
template<> struct foo<unknown,unknown> { // expected-error {{undeclared identifier 'unknown'}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D920.2.patch
Type: text/x-patch
Size: 2344 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130605/9c0b8a09/attachment.bin>
More information about the cfe-commits
mailing list